コード例 #1
0
ファイル: RosterView.cpp プロジェクト: devaspot/chat
void RosterView::LinkUser(UserID *added_user, bool sort = true)
{
	if (!added_user) return;
	
	Window()->Lock();
	
	if (added_user->UserType() == UserID::CONFERENCE)
	{
		AddUnder(new RosterItem(added_user), _conferences);
		if (sort) SortItemsUnder(_conferences, true, _ListComparison);
	}
	else if (added_user->UserType() == UserID::JABBER)
	{
		if (added_user->SubscriptionStatus() == "none")
		{
			AddUnder(new RosterItem(added_user), _unknown);
			if (sort) SortItemsUnder(_unknown, true, _ListComparison);
		}
		else 
		{
			if (added_user->OnlineStatus() == UserID::ONLINE)
			{
				AddUnder(new RosterItem(added_user), _online);
				if (sort) SortItemsUnder(_offline, true, _ListComparison);
			}
			else if (added_user->OnlineStatus() == UserID::CONF_STATUS)
			{
				AddUnder(new RosterItem(added_user), _conferences);
				if (sort) SortItemsUnder(_offline, true, _ListComparison);
			}
			else
			{
				AddUnder(new RosterItem(added_user), _offline);
				if (sort) SortItemsUnder(_offline, true, _ListComparison);
			}
		}
	}
	
	Window()->Unlock();
}
コード例 #2
0
void
MimeTypeListView::_MakeTypesUnique(MimeTypeItem* underItem)
{
	SortItemsUnder(underItem, underItem != NULL, &MimeTypeItem::Compare);

	bool lastItemSame = false;
	MimeTypeItem* last = NULL;

	int32 index = 0;
	uint32 level = 0;
	if (underItem != NULL) {
		index = FullListIndexOf(underItem) + 1;
		level = underItem->OutlineLevel() + 1;
	}

	for (; index < FullListCountItems(); index++) {
		MimeTypeItem* item = dynamic_cast<MimeTypeItem*>(FullListItemAt(index));
		if (item == NULL)
			continue;

		if (item->OutlineLevel() < level) {
			// left sub-tree
			break;
		}

		item->SetText(item->Description());

		if (last == NULL || MimeTypeItem::CompareLabels(last, item)) {
			if (lastItemSame) {
				last->AddSubtype();
				if (Window())
					InvalidateItem(IndexOf(last));
			}

			lastItemSame = false;
			last = item;
			continue;
		}

		lastItemSame = true;
		last->AddSubtype();
		if (Window())
			InvalidateItem(IndexOf(last));
		last = item;
	}

	if (lastItemSame) {
		last->AddSubtype();
		if (Window())
			InvalidateItem(IndexOf(last));
	}
}
コード例 #3
0
void
PrefListView::Sort(BListItem* node)
{
	SortItemsUnder(node, false, &sortX);
}
コード例 #4
0
void
BOutlineListView::FullListSortItems(int (*compareFunc)(const BListItem* a,
	const BListItem* b))
{
	SortItemsUnder(NULL, false, compareFunc);
}