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


C++ Model::Depots方法代码示例

本文整理汇总了C++中Model::Depots方法的典型用法代码示例。如果您正苦于以下问题:C++ Model::Depots方法的具体用法?C++ Model::Depots怎么用?C++ Model::Depots使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model的用法示例。


在下文中一共展示了Model::Depots方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BMessage

void
FilterView::AdoptModel(const Model& model)
{
	BMenu* repositoryMenu = fRepositoryField->Menu();
		repositoryMenu->RemoveItems(0, repositoryMenu->CountItems(), true);

	repositoryMenu->AddItem(new BMenuItem(B_TRANSLATE("All depots"),
		new BMessage(MSG_DEPOT_SELECTED)));
	repositoryMenu->ItemAt(0)->SetMarked(true);

	repositoryMenu->AddItem(new BSeparatorItem());

	const DepotList& depots = model.Depots();
	for (int i = 0; i < depots.CountItems(); i++) {
		const DepotInfo& depot = depots.ItemAtFast(i);
		BMessage* message = new BMessage(MSG_DEPOT_SELECTED);
		message->AddString("name", depot.Name());
		BMenuItem* item = new BMenuItem(depot.Name(), message);
		repositoryMenu->AddItem(item);
	}

	BMenu* showMenu = fShowField->Menu();
	showMenu->RemoveItems(0, showMenu->CountItems(), true);

	showMenu->AddItem(new BMenuItem(B_TRANSLATE("All categories"),
		new BMessage(MSG_CATEGORY_SELECTED)));

	showMenu->AddItem(new BSeparatorItem());

	add_categories_to_menu(model.Categories(), showMenu);

	showMenu->ItemAt(0)->SetMarked(true);

	AdoptCheckmarks(model);
}
开发者ID:,项目名称:,代码行数:35,代码来源:

示例2: BMessage

void
FilterView::AdoptModel(const Model& model)
{
	// Adopt depots
	BMenu* repositoryMenu = fRepositoryField->Menu();
		repositoryMenu->RemoveItems(0, repositoryMenu->CountItems(), true);

	repositoryMenu->AddItem(new BMenuItem(B_TRANSLATE("All depots"),
		new BMessage(MSG_DEPOT_SELECTED)));

	repositoryMenu->AddItem(new BSeparatorItem());

	bool foundSelectedDepot = false;
	const DepotList& depots = model.Depots();
	for (int i = 0; i < depots.CountItems(); i++) {
		const DepotInfo& depot = depots.ItemAtFast(i);
		BMessage* message = new BMessage(MSG_DEPOT_SELECTED);
		message->AddString("name", depot.Name());
		BMenuItem* item = new BMenuItem(depot.Name(), message);
		repositoryMenu->AddItem(item);

		if (depot.Name() == model.Depot()) {
			item->SetMarked(true);
			foundSelectedDepot = true;
		}
	}

	if (!foundSelectedDepot)
		repositoryMenu->ItemAt(0)->SetMarked(true);

	// Adopt categories
	BMenu* showMenu = fShowField->Menu();
	showMenu->RemoveItems(0, showMenu->CountItems(), true);

	showMenu->AddItem(new BMenuItem(B_TRANSLATE("All categories"),
		new BMessage(MSG_CATEGORY_SELECTED)));

	showMenu->AddItem(new BSeparatorItem());

	add_categories_to_menu(model.Categories(), showMenu);

	bool foundSelectedCategory = false;
	for (int32 i = 0; i < showMenu->CountItems(); i++) {
		BMenuItem* item = showMenu->ItemAt(i);
		BMessage* message = item->Message();
		if (message == NULL)
			continue;
		BString category;
		if (message->FindString("name", &category) == B_OK
			&& model.Category() == category) {
			item->SetMarked(true);
			foundSelectedCategory = true;
			break;
		}
	}
	if (!foundSelectedCategory)
		showMenu->ItemAt(0)->SetMarked(true);
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:58,代码来源:FilterView.cpp

示例3: PackageInfoRef

PackageInfoRef
PackageAction::FindPackageByName(const BString& name)
{
	Model* model = GetModel();
	const DepotList& depots = model->Depots();
	// TODO: optimize!
	for (int32 i = 0; i < depots.CountItems(); i++) {
		const DepotInfo& depot = depots.ItemAtFast(i);
		const PackageList& packages = depot.Packages();
		for (int32 j = 0; j < packages.CountItems(); j++) {
			PackageInfoRef info = packages.ItemAtFast(j);
			if (info->Name() == name)
				return info;
		}
	}

	return PackageInfoRef();
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:18,代码来源:PackageAction.cpp


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