当前位置: 首页>>代码示例>>C++>>正文


C++ ModelMenuItem::TargetModel方法代码示例

本文整理汇总了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);
	}
}
开发者ID:RAZVOR,项目名称:haiku,代码行数:47,代码来源:NavMenu.cpp

示例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));
		}
	}
}
开发者ID:RTOSkit,项目名称:haiku,代码行数:101,代码来源:DirMenu.cpp


注:本文中的ModelMenuItem::TargetModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。