本文整理汇总了C++中Model::Categories方法的典型用法代码示例。如果您正苦于以下问题:C++ Model::Categories方法的具体用法?C++ Model::Categories怎么用?C++ Model::Categories使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model
的用法示例。
在下文中一共展示了Model::Categories方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}