本文整理汇总了C++中ModelMenuItem::TargetModel方法的典型用法代码示例。如果您正苦于以下问题:C++ ModelMenuItem::TargetModel方法的具体用法?C++ ModelMenuItem::TargetModel怎么用?C++ ModelMenuItem::TargetModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelMenuItem
的用法示例。
在下文中一共展示了ModelMenuItem::TargetModel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: entry
void
SpringLoadedFolderSetMenuStates(const BMenu* menu,
const BObjectList<BString>* typeslist)
{
if (!menu || !typeslist || typeslist->IsEmpty())
return;
// if a types list exists
// iterate through the list and see if each item
// can support any item in the list
// set the enabled state of the item
int32 count = menu->CountItems();
for (int32 index = 0 ; index < count ; index++) {
ModelMenuItem* item = dynamic_cast<ModelMenuItem*>(menu->ItemAt(index));
if (!item)
continue;
const Model* model = item->TargetModel();
if (!model)
continue;
if (model->IsSymLink()) {
// find out what the model is, resolve if symlink
BEntry entry(model->EntryRef(), true);
if (entry.InitCheck() == B_OK) {
if (entry.IsDirectory()) {
// folder? always keep enabled
item->SetEnabled(true);
} else {
// other, check its support
Model resolvedModel(&entry);
int32 supported = resolvedModel.SupportsMimeType(NULL, typeslist);
item->SetEnabled(supported != kDoesNotSupportType);
}
} else
// bad entry ref (bad symlink?), disable
item->SetEnabled(false);
} else if (model->IsDirectory() || model->IsRoot() || model->IsVolume())
// always enabled if a container
item->SetEnabled(true);
else if (model->IsFile() || model->IsExecutable()) {
int32 supported = model->SupportsMimeType(NULL, typeslist);
item->SetEnabled(supported != kDoesNotSupportType);
} else
item->SetEnabled(false);
}
}
示例2: model
//.........这里部分代码省略.........
{
TrackerSettings settings;
showDesktop = settings.DesktopFilePanelRoot();
showDisksIcon = settings.ShowDisksIcon();
}
// might start one level above startEntry
if (!includeStartEntry) {
BDirectory parent;
BDirectory dir(&entry);
if (!showDesktop && dir.InitCheck() == B_OK
&& dir.IsRootDirectory()) {
// if we're at the root directory skip "mnt" and
// go straight to "/"
parent.SetTo("/");
} else
entry.GetParent(&parent);
parent.GetEntry(&entry);
}
BDirectory desktopDir;
FSGetDeskDir(&desktopDir);
BEntry desktopEntry;
desktopDir.GetEntry(&desktopEntry);
for (;;) {
BNode node(&entry);
ThrowOnInitCheckError(&node);
PoseInfo info;
ReadAttrResult result = ReadAttr(&node, kAttrPoseInfo,
kAttrPoseInfoForeign, B_RAW_TYPE, 0, &info, sizeof(PoseInfo),
&PoseInfo::EndianSwap);
BDirectory parent;
entry.GetParent(&parent);
bool hitRoot = false;
BDirectory dir(&entry);
if (!showDesktop && dir.InitCheck() == B_OK
&& dir.IsRootDirectory()) {
// if we're at the root directory skip "mnt" and
// go straight to "/"
hitRoot = true;
parent.SetTo("/");
}
if (showDesktop) {
BEntry root("/");
// warp from "/" to Desktop properly
if (entry == root) {
if (showDisksIcon)
AddDisksIconToMenu(reverse);
entry = desktopEntry;
}
if (entry == desktopEntry)
hitRoot = true;
}
if (result == kReadAttrFailed || !info.fInvisible
|| (showDesktop && desktopEntry == entry)) {
AddItemToDirMenu(&entry, originatingWindow, reverse,
addShortcuts, navMenuEntries);
}
if (hitRoot) {
if (!showDesktop && showDisksIcon && *startEntry != "/")
AddDisksIconToMenu(reverse);
break;
}
parent.GetEntry(&entry);
}
// select last item in menu
if (!select)
return;
ModelMenuItem* item
= dynamic_cast<ModelMenuItem*>(ItemAt(CountItems() - 1));
if (item) {
item->SetMarked(true);
if (menu) {
entry.SetTo(item->TargetModel()->EntryRef());
ThrowOnError(menu->SetEntry(&entry));
}
}
} catch (status_t err) {
PRINT(("BDirMenu::Populate: caught error %s\n", strerror(err)));
if (!CountItems()) {
BString error;
error << "Error [" << strerror(err) << "] populating menu";
AddItem(new BMenuItem(error.String(), 0));
}
}
}