当前位置: 首页>>代码示例>>C++>>正文


C++ BList::SortItems方法代码示例

本文整理汇总了C++中BList::SortItems方法的典型用法代码示例。如果您正苦于以下问题:C++ BList::SortItems方法的具体用法?C++ BList::SortItems怎么用?C++ BList::SortItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BList的用法示例。


在下文中一共展示了BList::SortItems方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getNumUniquePBNames

// fetch number of unique names on the slot list
int getNumUniquePBNames(struct pbSlot *sl = NULL) {
	if (!sl)
		return 0;
	if (sl->pb->CountItems() == 0)
		return 0;
	// clone slot list
	BList *l = new BList(*(sl->pb));
	// sort slot list by name
	l->SortItems(&pbNumCompareByName);
	int j = l->CountItems();
	int n = 1;
	struct pbNum *c = (struct pbNum*)l->ItemAt(0);
	BString *last = ((union pbVal*)c->attr->ItemAt(1))->text;
	BString *cur;
	// go through the list and ++ on each change
	for (int i=1;i<j;i++) {
		c = (struct pbNum*)l->ItemAt(i);
		cur = ((union pbVal*)c->attr->ItemAt(1))->text;
		if (cur->Compare(last->String()) != 0) {
			last = cur;
			n++;
		}
	}
	delete l;
	return n;
}
开发者ID:louisdem,项目名称:beos-bemobile,代码行数:27,代码来源:pbview.cpp

示例2: BList

void
HTGTimeLineView::addUnhandledTweets()
{
	if(unhandledList->IsEmpty())
		return;
		
	BList *newList = new BList();

	newList->AddList(unhandledList);
	unhandledList->MakeEmpty();
	
	HTGTweetItem *currentItem;
	while(!listView->IsEmpty()) {
		currentItem = (HTGTweetItem *)listView->FirstItem();
		listView->RemoveItem(currentItem);
		if(newList->CountItems() < 30) {//Only allow 30 tweets to be displayed at once... for now.
			newList->AddItem(currentItem);
			currentItem->ClearView(); //No need to keep everything in memory
									//if the view is at the bottom of the scrollbar (invisible)
		}
		else
			delete currentItem;
	}
	
	/*Sort tweets by date*/
	newList->SortItems(*HTGTweetItem::sortByDateFunc);
	
	/*Add our new list*/
	listView->AddList(newList);
		
	/*Clean up*/
	unhandledList->MakeEmpty();
}
开发者ID:,项目名称:,代码行数:33,代码来源:

示例3: curImage

// Function taken from Haiku ShowImage,
// function originally written by Michael Pfeiffer
bool
SlideShowSaver::FindNextImage(entry_ref *in_current, entry_ref *out_image, bool next, bool rewind)
{
//	ASSERT(next || !rewind);
	BEntry curImage(in_current);
	entry_ref entry, *ref;
	BDirectory parent;
	BList entries;
	bool found = false;
	int32 cur;

	if (curImage.GetParent(&parent) != B_OK)
		return false;

	while (parent.GetNextRef(&entry) == B_OK) {
		if (entry != *in_current) {
			entries.AddItem(new entry_ref(entry));
		} else {
			// insert current ref, so we can find it easily after sorting
			entries.AddItem(in_current);
		}
	}

	entries.SortItems(CompareEntries);

	cur = entries.IndexOf(in_current);
//	ASSERT(cur >= 0);

	// remove it so FreeEntries() does not delete it
	entries.RemoveItem(in_current);

	if (next) {
		// find the next image in the list
		if (rewind) cur = 0; // start with first
		for (; (ref = (entry_ref*)entries.ItemAt(cur)) != NULL; cur ++) {
			if (IsImage(ref)) {
				found = true;
				*out_image = (const entry_ref)*ref;
				break;
			}
		}
	} else {
		// find the previous image in the list
		cur --;
		for (; cur >= 0; cur --) {
			ref = (entry_ref*)entries.ItemAt(cur);
			if (IsImage(ref)) {
				found = true;
				*out_image = (const entry_ref)*ref;
				break;
			}
		}
	}

	FreeEntries(&entries);
	return found;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:59,代码来源:SlideShowSaver.cpp

示例4: Create

void Accounts::Create(BListView *listView, BView *configView)
{
	gListView = listView;
	gConfigView = configView;

	BList inbound,outbound;

	GetInboundMailChains(&inbound);
	GetOutboundMailChains(&outbound);

	// create inbound accounts and assign matching outbound chains

	for (int32 i = inbound.CountItems();i-- > 0;)
	{
		BMailChain *inChain = (BMailChain *)inbound.ItemAt(i);
		BMailChain *outChain = NULL;
		for (int32 j = outbound.CountItems();j-- > 0;)
		{
			outChain = (BMailChain *)outbound.ItemAt(j);

			if (!strcmp(inChain->Name(),outChain->Name()))
				break;
			outChain = NULL;
		}
		gAccounts.AddItem(new Account(inChain,outChain));
		inbound.RemoveItem(i);
		if (outChain)
			outbound.RemoveItem(outChain);
	}

	// create remaining outbound only accounts

	for (int32 i = outbound.CountItems();i-- > 0;)
	{
		BMailChain *outChain = (BMailChain *)outbound.ItemAt(i);

		gAccounts.AddItem(new Account(NULL,outChain));
		outbound.RemoveItem(i);
	}

	// sort the list alphabetically
	gAccounts.SortItems(Accounts::Compare);
	
	for (int32 i = 0;Account *account = (Account *)gAccounts.ItemAt(i);i++)
		account->AddToListView();
}
开发者ID:mmanley,项目名称:Antares,代码行数:46,代码来源:Account.cpp

示例5:

//! newExtensionsList contains all the entries (char*) which are to be added.
status_t
merge_extensions(BMimeType& type, const BList& newExtensionsList,
	const char* removeExtension)
{
	BMessage extensions;
	status_t status = type.GetFileExtensions(&extensions);
	if (status < B_OK)
		return status;

	// replace the entry, and remove any equivalent entries
	BList mergedList;
	mergedList.AddList(&newExtensionsList);
	int32 originalCount = mergedList.CountItems();

	const char* extension;
	for (int32 i = 0; extensions.FindString("extensions", i,
			&extension) == B_OK; i++) {

		for (int32 j = originalCount; j-- > 0;) {
			if (!strcmp((const char*)mergedList.ItemAt(j), extension)) {
				// Do not add this old item again, since it's already
				// there.
				mergedList.RemoveItem(j);
				originalCount--;
			}
		}

		// The item will be added behind "originalCount", so we cannot
		// remove it accidentally in the next iterations, it's is added
		// for good.
		if (removeExtension == NULL || strcmp(removeExtension, extension))
			mergedList.AddItem((void *)extension);
	}

	mergedList.SortItems(compare_extensions);

	// Copy them to a new message (their memory is still part of the
	// original BMessage)
	BMessage newExtensions;
	for (int32 i = 0; i < mergedList.CountItems(); i++) {
		newExtensions.AddString("extensions",
			(const char*)mergedList.ItemAt(i));
	}

	return type.SetFileExtensions(&newExtensions);
}
开发者ID:mmanley,项目名称:Antares,代码行数:47,代码来源:ExtensionWindow.cpp

示例6: BMessage

/***********************************************************
 * Build
 ***********************************************************/
void
AddOnMenu::Build()
{
	// Build add addons menus
	if(!fPath.Path())
		return;
	BDirectory 	dir(fPath.Path());
	entry_ref 	ref;
	BEntry 		entry;
	BList		itemList;
	itemList.MakeEmpty();
	char 		name[B_FILE_NAME_LENGTH];
	char		shortcut = 0;
	BBitmap 	*bitmap(NULL);
	
	while(dir.GetNextEntry(&entry,true) == B_OK)
	{
		if(entry.IsFile() && entry.GetRef(&ref) == B_OK)
		{	
			shortcut = 0;
			bitmap = NULL;
			BMessage *msg = new BMessage(fWhat);
			msg->AddRef("refs",&ref);
			// make name and shortcut
			int32 nameLen = ::strlen(ref.name);
			::strcpy(name,ref.name);
			if(name[nameLen-2] == '-')
			{
				shortcut = name[nameLen-1];
				name[nameLen-2] = '\0';
			}
			if(fUseIcon)
				bitmap = GetIcon(ref);
			itemList.AddItem(new IconMenuItem(name,msg,shortcut,0,bitmap));
		}
	}
	
	// sort items
	itemList.SortItems(SortItems);
	
	int32 count = itemList.CountItems();
	for(int32 i = 0;i < count;i++)
		AddItem((IconMenuItem*)itemList.ItemAt(i));
}
开发者ID:HaikuArchives,项目名称:Scooby,代码行数:47,代码来源:AddOnMenu.cpp

示例7: node

void
BootPromptWindow::_PopulateKeymaps()
{
	// Get the name of the current keymap, so we can mark the correct entry
	// in the list view.
	BString currentName;
	entry_ref currentRef;
	if (_GetCurrentKeymapRef(currentRef) == B_OK) {
		BNode node(&currentRef);
		node.ReadAttrString("keymap:name", &currentName);
	}

	// TODO: common keymaps!
	BPath path;
	if (find_directory(B_SYSTEM_DATA_DIRECTORY, &path) != B_OK
		|| path.Append("Keymaps") != B_OK) {
		return;
	}

	// US-International is the default keymap, if we could not found a
	// matching one
	BString usInternational("US-International");

	// Populate the menu
	BDirectory directory;
	if (directory.SetTo(path.Path()) == B_OK) {
		entry_ref ref;
		BList itemsList;
		while (directory.GetNextRef(&ref) == B_OK) {
			BMessage* message = new BMessage(MSG_KEYMAP_SELECTED);
			message->AddRef("ref", &ref);
			BMenuItem* item = new BMenuItem(ref.name, message);
			itemsList.AddItem(item);
			if (currentName == ref.name)
				item->SetMarked(true);

			if (usInternational == ref.name)
				fDefaultKeymapItem = item;
		}
		itemsList.SortItems(compare_void_menu_items);
		fKeymapsMenuField->Menu()->AddList(&itemsList, 0);
	}
}
开发者ID:looncraz,项目名称:haiku,代码行数:43,代码来源:BootPromptWindow.cpp

示例8: dir

void
InstallerWindow::_PublishPackages()
{
	fPackagesView->Clean();
	PartitionMenuItem *item = (PartitionMenuItem *)fSrcMenu->FindMarked();
	if (!item)
		return;

	BPath directory;
	BDiskDeviceRoster roster;
	BDiskDevice device;
	BPartition *partition;
	if (roster.GetPartitionWithID(item->ID(), &device, &partition) == B_OK) {
		if (partition->GetMountPoint(&directory) != B_OK)
			return;
	} else if (roster.GetDeviceWithID(item->ID(), &device) == B_OK) {
		if (device.GetMountPoint(&directory) != B_OK)
			return;
	} else
		return; // shouldn't happen

	directory.Append(PACKAGES_DIRECTORY);
	BDirectory dir(directory.Path());
	if (dir.InitCheck() != B_OK)
		return;

	BEntry packageEntry;
	BList packages;
	while (dir.GetNextEntry(&packageEntry) == B_OK) {
		Package* package = Package::PackageFromEntry(packageEntry);
		if (package != NULL)
			packages.AddItem(package);
	}
	packages.SortItems(_ComparePackages);

	fPackagesView->AddPackages(packages, new BMessage(PACKAGE_CHECKBOX));
	PostMessage(PACKAGE_CHECKBOX);
}
开发者ID:mmanley,项目名称:Antares,代码行数:38,代码来源:InstallerWindow.cpp

示例9: self

void
TExpandoMenuBar::AttachedToWindow()
{
	BMessenger self(this);
	BList teamList;
	TBarApp::Subscribe(self, &teamList);
	float width = fVertical ? Frame().Width() : kMinimumWindowWidth;
	float height = -1.0f;

	// top or bottom mode, add be menu and sep for menubar tracking consistency
	if (!fVertical) {	
		TBeMenu *beMenu = new TBeMenu(fBarView);
		TBarWindow::SetBeMenu(beMenu);
 		fBeMenuItem = new TBarMenuTitle(kBeMenuWidth, Frame().Height(),
 			AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_BeLogoIcon), beMenu, true);
		AddItem(fBeMenuItem);
		
		fSeparatorItem = new TTeamMenuItem(kSepItemWidth, height, fVertical);
		AddItem(fSeparatorItem);
		fSeparatorItem->SetEnabled(false);
		fFirstApp = 2;
	} else {
		fBeMenuItem = NULL;
		fSeparatorItem = NULL;
	}

	desk_settings *settings = ((TBarApp *)be_app)->Settings();
	
	if (settings->sortRunningApps)
		teamList.SortItems(CompareByName);

	int32 count = teamList.CountItems();
	for (int32 i = 0; i < count; i++) {
		BarTeamInfo *barInfo = (BarTeamInfo *)teamList.ItemAt(i);
		if ((barInfo->flags & B_BACKGROUND_APP) == 0
			&& strcasecmp(barInfo->sig, TASK_BAR_MIME_SIG) != 0) {
			if ((settings->trackerAlwaysFirst)
				&& (strcmp(barInfo->sig, kTrackerSignature)) == 0) {
				AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon, 
					barInfo->name, barInfo->sig, width, height,
					fDrawLabel, fVertical), fFirstApp);
			} else {
				AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon, 
					barInfo->name, barInfo->sig, width, height,
					fDrawLabel, fVertical));
			}

			barInfo->teams = NULL;
			barInfo->icon = NULL;
			barInfo->name = NULL;
			barInfo->sig = NULL;
		}
		
		delete barInfo;
	}

	BMenuBar::AttachedToWindow();

	if (fVertical) {
		sDoMonitor = true;
		sMonThread = spawn_thread(monitor_team_windows,
			"Expando Window Watcher", B_LOW_PRIORITY, this);
		resume_thread(sMonThread);
	}
}
开发者ID:Ithamar,项目名称:cosmoe,代码行数:65,代码来源:ExpandoMenuBar.cpp

示例10: font


//.........这里部分代码省略.........
		"Zousar Shaker\n"
		"Caitlin Shaw\n"
		"Daniel Switkin\n"
		"Atsushi Takamatsu\n"
		"James Urquhart\n"
		"Jason Vandermark\n"
		"Sandor Vroemisse\n"
		"Denis Washington\n"
		"Alex Wilson\n"
		"Ulrich Wimboeck\n"
		"Johannes Wischert\n"
		"James Woodcock\n"
		"Hong Yul Yang\n"
		"Gerald Zajac\n"
		"Łukasz Zemczak\n"
		"JiSheng Zhang\n"
		"Zhao Shuai\n");
	fCreditsView->Insert(
		B_TRANSLATE("\n" B_UTF8_ELLIPSIS
			" and probably some more we forgot to mention (sorry!)"
			"\n\n"));

	fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuOrange);
	fCreditsView->Insert(B_TRANSLATE("Translations:\n"));

	BLanguage* lang;
	BString langName;

	BList sortedTranslations;
	for (uint32 i = 0; i < kNumberOfTranslations; i ++) {
		const Translation* translation = &gTranslations[i];
		sortedTranslations.AddItem((void*)translation);
	}
	sortedTranslations.SortItems(TranslationComparator);

	for (uint32 i = 0; i < kNumberOfTranslations; i ++) {
		const Translation& translation =
			*(const Translation*)sortedTranslations.ItemAt(i);

		be_locale_roster->GetLanguage(translation.languageCode, &lang);
		langName.Truncate(0);
		lang->GetTranslatedName(langName);
		delete lang;

		fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuGreen);
		fCreditsView->Insert("\n");
		fCreditsView->Insert(langName);
		fCreditsView->Insert("\n");
		fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey);
		fCreditsView->Insert(
			translation.names
		);
	}

	fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuOrange);
	fCreditsView->Insert(B_TRANSLATE("\n\nSpecial thanks to:\n"));

	fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey);
	fCreditsView->Insert(
		B_TRANSLATE("Travis Geiselbrecht (and his NewOS kernel)\n"));
	fCreditsView->Insert(
		B_TRANSLATE("Michael Phipps (project founder)\n\n"));
	fCreditsView->Insert(
		B_TRANSLATE("The Haiku-Ports team\n"));
	fCreditsView->Insert(
		B_TRANSLATE("The Haikuware team and their bounty program\n"));
开发者ID:mariuz,项目名称:haiku,代码行数:67,代码来源:AboutSystem.cpp

示例11: self

void
TExpandoMenuBar::AttachedToWindow()
{
	BMessenger self(this);
	BList teamList;
	TBarApp::Subscribe(self, &teamList);
	float width = fVertical ? Frame().Width() : sMinimumWindowWidth;
	float height = -1.0f;

	// top or bottom mode, add deskbar menu and sep for menubar tracking
	// consistency
	if (!fVertical) {
		TDeskbarMenu* beMenu = new TDeskbarMenu(fBarView);
		TBarWindow::SetDeskbarMenu(beMenu);
		const BBitmap* logoBitmap = AppResSet()->FindBitmap(B_MESSAGE_TYPE,
			R_LeafLogoBitmap);
		if (logoBitmap != NULL)
			fDeskbarMenuWidth = logoBitmap->Bounds().Width() + 16;
		fDeskbarMenuItem = new TBarMenuTitle(fDeskbarMenuWidth, Frame().Height(),
			logoBitmap, beMenu, true);
		AddItem(fDeskbarMenuItem);

		fSeparatorItem = new TTeamMenuItem(kSepItemWidth, height, fVertical);
		AddItem(fSeparatorItem);
		fSeparatorItem->SetEnabled(false);
		fFirstApp = 2;
	} else {
		fDeskbarMenuItem = NULL;
		fSeparatorItem = NULL;
	}

	desk_settings* settings = ((TBarApp*)be_app)->Settings();

	if (settings->sortRunningApps)
		teamList.SortItems(CompareByName);

	int32 count = teamList.CountItems();
	for (int32 i = 0; i < count; i++) {
		BarTeamInfo* barInfo = (BarTeamInfo*)teamList.ItemAt(i);
		if ((barInfo->flags & B_BACKGROUND_APP) == 0
			&& strcasecmp(barInfo->sig, kDeskbarSignature) != 0) {
			if (settings->trackerAlwaysFirst
				&& !strcmp(barInfo->sig, kTrackerSignature)) {
				AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon,
					barInfo->name, barInfo->sig, width, height,
					fDrawLabel, fVertical), fFirstApp);
			} else {
				AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon,
					barInfo->name, barInfo->sig, width, height,
					fDrawLabel, fVertical));
			}

			barInfo->teams = NULL;
			barInfo->icon = NULL;
			barInfo->name = NULL;
			barInfo->sig = NULL;
		}

		delete barInfo;
	}

	BMenuBar::AttachedToWindow();

	if (CountItems() == 0) {
		// If we're empty, BMenuBar::AttachedToWindow() resizes us to some
		// weird value - we just override it again
		ResizeTo(width, 0);
	}

	if (fVertical) {
		sDoMonitor = true;
		sMonThread = spawn_thread(monitor_team_windows,
			"Expando Window Watcher", B_LOW_PRIORITY, this);
		resume_thread(sMonThread);
	}
}
开发者ID:michael-manley,项目名称:haiku,代码行数:76,代码来源:ExpandoMenuBar.cpp

示例12: name

// _CollectSequence
status_t
CollectingPlaylist::_CollectSequence(BList& collectables,
	const ServerObjectManager* library)
{
	collectables.SortItems(compare_collectables);

	// find the transition clip, if we are supposed to have one
	Clip* transitionClip = NULL;
	BString transitionClipID = TransitionClipID();

	if (transitionClipID.Length() > 0) {
		transitionClip = dynamic_cast<Clip*>(library->FindObject(
			transitionClipID.String()));
		if (!transitionClip) {
			print_error("CollectingPlaylist::_CollectSequence() - "
				"didn't find transition clip: %s (ignoring)\n",
				transitionClipID.String());
		}
	}

	BString previousName;

	int64 startFrame = 0;
	uint64 maxDuration = Value(PROPERTY_DURATION, (int64)0);
	uint64 defaultDuration = ItemDuration();

	int32 count = collectables.CountItems();
	for (int32 i = 0; i < count; i++) {
		CollectablePlaylist* collectable
			= (CollectablePlaylist*)collectables.ItemAtFast(i);

		uint64 itemDuration = collectable->PreferredDuration();
		if (itemDuration == 0)
			itemDuration = defaultDuration;
		if (maxDuration > 0 && startFrame + itemDuration > maxDuration) {
			// we would go past our maximum duration, so stop here
			break;
		}

		ClipPlaylistItem* item = new (nothrow) ClipPlaylistItem(collectable);
			// the item, if it was created, has it's own reference now
		if (!item) {
			print_error("CollectingPlaylist::_CollectSequence() - "
				"no memory to create ClipPlaylistItem\n");
			return B_NO_MEMORY;
		}

		BString name(collectable->Name());
		if (i > 0 && name != previousName && transitionClip) {
//printf("new sequence starts at %ld\n", i);
			// a new sequence starts
			ClipPlaylistItem* transitionItem
				= new (nothrow) ClipPlaylistItem(transitionClip);
			if (!transitionItem || !AddItem(transitionItem)) {
				delete transitionItem;
				print_error("CollectingPlaylist::_CollectSequence() - "
					"no memory to create/add ClipPlaylistItem (transition)\n");
				return B_NO_MEMORY;
			}

			transitionItem->SetStartFrame(startFrame);
			int64 transitionDuration = transitionClip->Duration();
			transitionItem->SetDuration(transitionDuration);
			startFrame += transitionDuration;
		}

		if (!AddItem(item)) {
			delete item;
			print_error("CollectingPlaylist::_CollectSequence() - "
				"no memory to add ClipPlaylistItem\n");
			return B_NO_MEMORY;
		}

		item->SetStartFrame(startFrame);
		item->SetDuration(itemDuration);
		item->SetTrack(0);

		startFrame += itemDuration;
		previousName = name;
	}
	return B_OK;
}
开发者ID:stippi,项目名称:Clockwerk,代码行数:83,代码来源:CollectingPlaylist.cpp

示例13:

void
AttributeWindow::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case kMsgAttributeUpdated:
		case kMsgAlignmentChosen:
		case kMsgTypeChosen:
			_CheckDisplayAs();
			_CheckAcceptable();
			break;

		case kMsgDisplayAsChosen:
			fSpecialControl->SetEnabled(!_DefaultDisplayAs()->IsMarked());
			_CheckAcceptable();
			break;

		case kMsgVisibilityChanged:
		{
			bool enabled = fVisibleCheckBox->Value() != B_CONTROL_OFF;

			fDisplayAsMenuField->SetEnabled(enabled);
			fWidthControl->SetEnabled(enabled);
			fAlignmentMenuField->SetEnabled(enabled);
			fEditableCheckBox->SetEnabled(enabled);

			_CheckDisplayAs();
			_CheckAcceptable();
			break;
		}

		case kMsgAccept:
		{
			BMessage attributes;
			status_t status = fMimeType.GetAttrInfo(&attributes);
			if (status == B_OK) {
				// replace the entry, and remove any equivalent entries
				BList list;

				const char* newAttribute = fAttributeControl->Text();
				list.AddItem(_NewItemFromCurrent());

				const char* attribute;
				for (int32 i = 0; attributes.FindString("attr:name", i,
						&attribute) == B_OK; i++) {
					if (!strcmp(fAttribute.Name(), attribute)
						|| !strcmp(newAttribute, attribute)) {
						// remove this item
						continue;
					}

					AttributeItem* item = create_attribute_item(attributes, i);
					if (item != NULL)
						list.AddItem(item);
				}

				list.SortItems(compare_attributes);

				// Copy them to a new message (their memory is still part of the
				// original BMessage)
				BMessage newAttributes;
				for (int32 i = 0; i < list.CountItems(); i++) {
					AttributeItem* item = (AttributeItem*)list.ItemAt(i);

					newAttributes.AddString("attr:name", item->Name());
					newAttributes.AddString("attr:public_name", item->PublicName());
					newAttributes.AddInt32("attr:type", (int32)item->Type());
					newAttributes.AddString("attr:display_as", item->DisplayAs());
					newAttributes.AddInt32("attr:alignment", item->Alignment());
					newAttributes.AddInt32("attr:width", item->Width());
					newAttributes.AddBool("attr:viewable", item->Visible());
					newAttributes.AddBool("attr:editable", item->Editable());
					
					delete item;
				}

				status = fMimeType.SetAttrInfo(&newAttributes);
			}

			if (status != B_OK)
				error_alert("Could not change attributes", status);

			PostMessage(B_QUIT_REQUESTED);
			break;
		}

		default:
			BWindow::MessageReceived(message);
			break;
	}
}
开发者ID:mmanley,项目名称:Antares,代码行数:90,代码来源:AttributeWindow.cpp

示例14: node


//.........这里部分代码省略.........
			if(node.InitCheck() != B_OK)
				continue;
			
			ReadNodeAttrString(&node,"META:name",&name);		
			ReadNodeAttrString(&node,"META:email",&addr[0]);
			ReadNodeAttrString(&node,"META:email2",&addr[1]);
			ReadNodeAttrString(&node,"META:email3",&addr[2]);
			ReadNodeAttrString(&node,"META:email4",&addr[3]);
			ReadNodeAttrString(&node,"META:group",&group);
			ReadNodeAttrString(&node,"META:nickname",&nick);
			
			for(int32 i = 0;i < 4;i++)
			{
				if(addr[i].Length() > 0)
				{
					if(nick.Length() > 0)
					{
						nick += " <";
						nick += addr[i];
						nick += ">";
						fAddrList.AddItem(strdup(nick.String()));
					}
					fAddrList.AddItem(strdup(addr[i].String()));
					
					BString title = name;
					title << " <" << addr[i] << ">";
				
					AddPersonToList(peopleList,title.String(),group.String());
				}
			}
		}
		
		// Sort people data
		peopleList.SortItems(HAddressView::SortPeople);
		// Build menus
		BTextControl *control[3] = {fTo,fCc,fBcc};
		BMenu *menus[3] = {toMenu,ccMenu,bccMenu};
		int32 count = peopleList.CountItems();
		PersonData *data;
		bool needSeparator = false;
		bool hasSeparator = false;
		for(int32 k = 0;k < 3;k++)
		{
			for(int32 i = 0;i < count;i++)
			{
				BMessage *msg = new BMessage(M_ADDR_MSG);
				msg->AddPointer("pointer",control[k]);
				data =  (PersonData*)peopleList.ItemAt(i);
				msg->AddString("email",data->email);
				if(needSeparator && !hasSeparator && strlen(data->group) == 0)
				{
					menus[k]->AddSeparatorItem();
					hasSeparator = true;
				}else
					needSeparator = true;
				AddPerson(menus[k],data->email,data->group,msg,0,0);
			}
			hasSeparator = false;
			needSeparator = false;
		}
		// free all data
		while(count > 0)
		{
			data =  (PersonData*)peopleList.RemoveItem(--count);
			free(data->email);
			free(data->group);
开发者ID:HaikuArchives,项目名称:Scooby,代码行数:67,代码来源:HAddressView.cpp

示例15: JudgeScore

// returns true if score is destined for greatness
bool Hall::JudgeScore(unsigned long gametime, unsigned long game, int tiles)
{
bool Yes = false;

BList *L;
	
	switch(tiles)
	{
	case 14 * 6: L = List1; break;
	case 18 * 8: L = List2; break;
	case 24 * 12: L = List3; break;
	case 28 * 16: L = List4; break;
	case 32 * 20: L = List5; break;
	default: L = NULL;
	}

	if (!L)
	{
		//printf("No game size!\n");
		return false;
	}

	HSList *h = new HSList();
		

	h->SetGameID(game);
	h->SetGameTime(gametime);
	h->SetNumberTiles(tiles);
	h->SetTimeOfGame(time(NULL));
			

	h->SetName(NULL);

	/* Add the new item
	 */
	L->AddItem(h); 

	L->SortItems(cmpFunc);


	/*
	 * Limit entries to 5
	 */
	if (L->CountItems() > 5)
	{
		HSList *hs;
		hs = (HSList *)L->RemoveItem(5);
		delete hs;
	}

	if (L->HasItem(h))
	{
	AskName *Ask = new AskName();
	char *name;

		name = Ask->Go();
		Ask->Lock();
		Ask->Quit();
		be_app->SetCursor(B_HAND_CURSOR);
		h->SetName(name);
		free(name);
		_changed = true;
		Yes = true;
	}

	return Yes;
}
开发者ID:HaikuArchives,项目名称:BShisen,代码行数:68,代码来源:Hall.cpp


注:本文中的BList::SortItems方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。