From cbc9a523ff8ebcf43ba1a075c3489c918cb15c73 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Thu, 16 Nov 2017 17:50:52 -0500 Subject: [PATCH] Add manufacturer label in model list --- src/app/AddModuleWindow.cpp | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/app/AddModuleWindow.cpp b/src/app/AddModuleWindow.cpp index 50e3c834..5e6bf541 100644 --- a/src/app/AddModuleWindow.cpp +++ b/src/app/AddModuleWindow.cpp @@ -48,37 +48,37 @@ struct MetadataMenu : ListMenu { void step() override { if (model != sModel) { + model = sModel; clearChildren(); - if (sModel) { + if (model) { // Tag list - if (!sModel->tags.empty()) { - for (ModelTag tag : sModel->tags) { + if (!model->tags.empty()) { + for (ModelTag tag : model->tags) { addChild(construct(&MenuEntry::text, gTagNames[tag])); } addChild(construct()); } // Plugin name - std::string pluginName = sModel->plugin->slug; - if (!sModel->plugin->version.empty()) { + std::string pluginName = model->plugin->slug; + if (!model->plugin->version.empty()) { pluginName += " v"; - pluginName += sModel->plugin->version; + pluginName += model->plugin->version; } addChild(construct(&MenuEntry::text, pluginName)); // Plugin metadata - if (!sModel->plugin->website.empty()) { - addChild(construct(&MenuEntry::text, "Website", &UrlItem::url, sModel->plugin->path)); + if (!model->plugin->website.empty()) { + addChild(construct(&MenuEntry::text, "Website", &UrlItem::url, model->plugin->path)); } - if (!sModel->plugin->manual.empty()) { - addChild(construct(&MenuEntry::text, "Manual", &UrlItem::url, sModel->plugin->manual)); + if (!model->plugin->manual.empty()) { + addChild(construct(&MenuEntry::text, "Manual", &UrlItem::url, model->plugin->manual)); } - if (!sModel->plugin->path.empty()) { - addChild(construct(&MenuEntry::text, "Browse directory", &UrlItem::url, sModel->plugin->path)); + if (!model->plugin->path.empty()) { + addChild(construct(&MenuEntry::text, "Browse directory", &UrlItem::url, model->plugin->path)); } } - model = sModel; } ListMenu::step(); @@ -133,20 +133,22 @@ struct ModelMenu : ListMenu { void step() override { if (manufacturer != sManufacturer) { + manufacturer = sManufacturer; + filter = ""; clearChildren(); + addChild(construct(&MenuLabel::text, manufacturer)); // Add models for the selected manufacturer for (Plugin *plugin : gPlugins) { for (Model *model : plugin->models) { - if (model->manufacturer == sManufacturer) { + if (model->manufacturer == manufacturer) { addChild(construct(&MenuEntry::text, model->name, &ModelItem::model, model)); } } } - manufacturer = sManufacturer; - filter = ""; } if (filter != sFilter) { + filter = sFilter; // Make all children invisible for (Widget *child : children) { child->visible = false; @@ -157,11 +159,10 @@ struct ModelMenu : ListMenu { if (!item) continue; - if (isModelMatch(item->model, sFilter)) { + if (isModelMatch(item->model, filter)) { item->visible = true; } } - filter = sFilter; } ListMenu::step();