本文整理汇总了C++中BListItem::SetOutlineLevel方法的典型用法代码示例。如果您正苦于以下问题:C++ BListItem::SetOutlineLevel方法的具体用法?C++ BListItem::SetOutlineLevel怎么用?C++ BListItem::SetOutlineLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BListItem
的用法示例。
在下文中一共展示了BListItem::SetOutlineLevel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DomainItem
void
CookieWindow::_BuildDomainList()
{
// Empty the domain list (TODO should we do this when hiding instead?)
for (int i = fDomains->FullListCountItems() - 1; i >= 1; i--) {
delete fDomains->FullListItemAt(i);
}
fDomains->MakeEmpty();
// BOutlineListView does not handle parent = NULL in many methods, so let's
// make sure everything always has a parent.
DomainItem* rootItem = new DomainItem("", true);
fDomains->AddItem(rootItem);
// Populate the domain list
BNetworkCookieJar::Iterator it = fCookieJar.GetIterator();
const BNetworkCookie* cookie;
while ((cookie = it.NextDomain()) != NULL) {
_AddDomain(cookie->Domain(), false);
}
int i = 1;
while (i < fDomains->FullListCountItems())
{
DomainItem* item = (DomainItem*)fDomains->FullListItemAt(i);
// Detach items from the fake root
item->SetOutlineLevel(item->OutlineLevel() - 1);
i++;
}
fDomains->RemoveItem(rootItem);
delete rootItem;
i = 0;
int firstNotEmpty = i;
// Collapse empty items to keep the list short
while (i < fDomains->FullListCountItems())
{
DomainItem* item = (DomainItem*)fDomains->FullListItemAt(i);
if (item->fEmpty == true) {
if (fDomains->CountItemsUnder(item, true) == 1) {
// The item has no cookies, and only a single child. We can
// remove it and move its child one level up in the tree.
int count = fDomains->CountItemsUnder(item, false);
int index = fDomains->FullListIndexOf(item) + 1;
for (int j = 0; j < count; j++) {
BListItem* child = fDomains->FullListItemAt(index + j);
child->SetOutlineLevel(child->OutlineLevel() - 1);
}
fDomains->RemoveItem(item);
delete item;
// The moved child is at the same index the removed item was.
// We continue the loop without incrementing i to process it.
continue;
} else {
// The item has no cookies, but has multiple children. Mark it
// as disabled so it is not selectable.
item->SetEnabled(false);
if (i == firstNotEmpty)
firstNotEmpty++;
}
}
i++;
}
fDomains->Select(firstNotEmpty);
}