本文整理汇总了C++中BStringItem::SetOutlineLevel方法的典型用法代码示例。如果您正苦于以下问题:C++ BStringItem::SetOutlineLevel方法的具体用法?C++ BStringItem::SetOutlineLevel怎么用?C++ BStringItem::SetOutlineLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BStringItem
的用法示例。
在下文中一共展示了BStringItem::SetOutlineLevel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parentDomain
BStringItem*
CookieWindow::_AddDomain(BString domain, bool fake)
{
BStringItem* parent = NULL;
int firstDot = domain.FindFirst('.');
if (firstDot >= 0) {
BString parentDomain(domain);
parentDomain.Remove(0, firstDot + 1);
parent = _AddDomain(parentDomain, true);
} else {
parent = (BStringItem*)fDomains->FullListItemAt(0);
}
BListItem* existing;
int i = 0;
// check that we aren't already there
while ((existing = fDomains->ItemUnderAt(parent, true, i++)) != NULL) {
DomainItem* stringItem = (DomainItem*)existing;
if (stringItem->Text() == domain) {
if (fake == false)
stringItem->fEmpty = false;
return stringItem;
}
}
#if 0
puts("==============================");
for (i = 0; i < fDomains->FullListCountItems(); i++) {
BStringItem* t = (BStringItem*)fDomains->FullListItemAt(i);
for (unsigned j = 0; j < t->OutlineLevel(); j++)
printf(" ");
printf("%s\n", t->Text());
}
#endif
// Insert the new item, keeping the list alphabetically sorted
BStringItem* domainItem = new DomainItem(domain, fake);
domainItem->SetOutlineLevel(parent->OutlineLevel() + 1);
BStringItem* sibling = NULL;
int siblingCount = fDomains->CountItemsUnder(parent, true);
for (i = 0; i < siblingCount; i++) {
sibling = (BStringItem*)fDomains->ItemUnderAt(parent, true, i);
if (strcmp(sibling->Text(), domainItem->Text()) > 0) {
fDomains->AddItem(domainItem, fDomains->FullListIndexOf(sibling));
return domainItem;
}
}
if (sibling) {
// There were siblings, but all smaller than what we try to insert.
// Insert after the last one (and its subitems)
fDomains->AddItem(domainItem, fDomains->FullListIndexOf(sibling)
+ fDomains->CountItemsUnder(sibling, false) + 1);
} else {
// There were no siblings, insert right after the parent
fDomains->AddItem(domainItem, fDomains->FullListIndexOf(parent) + 1);
}
return domainItem;
}