本文整理汇总了C++中BStringItem::OutlineLevel方法的典型用法代码示例。如果您正苦于以下问题:C++ BStringItem::OutlineLevel方法的具体用法?C++ BStringItem::OutlineLevel怎么用?C++ BStringItem::OutlineLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BStringItem
的用法示例。
在下文中一共展示了BStringItem::OutlineLevel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: BAlert
void
GrepWindow::_OnTrimSelection()
{
if (fSearchResults->CurrentSelection() < 0) {
BString text;
text << B_TRANSLATE("Please select the files you wish to keep searching.");
text << "\n";
text << B_TRANSLATE("The unselected files will be removed from the list.");
text << "\n";
BAlert* alert = new BAlert(NULL, text.String(), B_TRANSLATE("OK"), NULL, NULL,
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go(NULL);
return;
}
BMessage message;
BString path;
for (int32 index = 0; ; index++) {
BStringItem* item = dynamic_cast<BStringItem*>(
fSearchResults->ItemAt(index));
if (item == NULL)
break;
if (!item->IsSelected() || item->OutlineLevel() != 0)
continue;
if (path == item->Text())
continue;
path = item->Text();
entry_ref ref;
if (get_ref_for_path(path.String(), &ref) == B_OK)
message.AddRef("refs", &ref);
}
fModel->fDirectory = entry_ref();
// invalidated on purpose
fModel->fSelectedFiles.MakeEmpty();
fModel->fSelectedFiles = message;
PostMessage(MSG_START_CANCEL);
_SetWindowTitle();
}