diff options
Diffstat (limited to 'src/modlistcontextmenu.cpp')
| -rw-r--r-- | src/modlistcontextmenu.cpp | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/src/modlistcontextmenu.cpp b/src/modlistcontextmenu.cpp index e88cadc8..06cd19d6 100644 --- a/src/modlistcontextmenu.cpp +++ b/src/modlistcontextmenu.cpp @@ -94,13 +94,16 @@ void ModListGlobalContextMenu::populate(OrganizerCore& core, ModListView* view, addAction(tr("Check for updates"), [=]() { view->actions().checkModsForUpdates(); }); + addAction(tr("Auto assign categories"), [=]() { + view->actions().assignCategories(); + }); addAction(tr("Refresh"), &core, &OrganizerCore::profileRefresh); addAction(tr("Export to csv..."), [=]() { view->actions().exportModListCSV(); }); } -ModListChangeCategoryMenu::ModListChangeCategoryMenu(CategoryFactory& categories, +ModListChangeCategoryMenu::ModListChangeCategoryMenu(CategoryFactory* categories, ModInfo::Ptr mod, QMenu* parent) : QMenu(tr("Change Categories"), parent) { @@ -131,24 +134,24 @@ ModListChangeCategoryMenu::categories(const QMenu* menu) const return cats; } -bool ModListChangeCategoryMenu::populate(QMenu* menu, CategoryFactory& factory, +bool ModListChangeCategoryMenu::populate(QMenu* menu, CategoryFactory* factory, ModInfo::Ptr mod, int targetId) { const std::set<int>& categories = mod->getCategories(); bool childEnabled = false; - for (unsigned int i = 1; i < factory.numCategories(); ++i) { - if (factory.getParentID(i) == targetId) { + for (unsigned int i = 1; i < factory->numCategories(); ++i) { + if (factory->getParentID(i) == targetId) { QMenu* targetMenu = menu; - if (factory.hasChildren(i)) { - targetMenu = menu->addMenu(factory.getCategoryName(i).replace('&', "&&")); + if (factory->hasChildren(i)) { + targetMenu = menu->addMenu(factory->getCategoryName(i).replace('&', "&&")); } - int id = factory.getCategoryID(i); + int id = factory->getCategoryID(i); QScopedPointer<QCheckBox> checkBox(new QCheckBox(targetMenu)); bool enabled = categories.find(id) != categories.end(); - checkBox->setText(factory.getCategoryName(i).replace('&', "&&")); + checkBox->setText(factory->getCategoryName(i).replace('&', "&&")); if (enabled) { childEnabled = true; } @@ -159,8 +162,8 @@ bool ModListChangeCategoryMenu::populate(QMenu* menu, CategoryFactory& factory, checkableAction->setData(id); targetMenu->addAction(checkableAction.take()); - if (factory.hasChildren(i)) { - if (populate(targetMenu, factory, mod, factory.getCategoryID(i)) || enabled) { + if (factory->hasChildren(i)) { + if (populate(targetMenu, factory, mod, factory->getCategoryID(i)) || enabled) { targetMenu->setIcon(QIcon(":/MO/gui/resources/check.png")); } } @@ -169,7 +172,7 @@ bool ModListChangeCategoryMenu::populate(QMenu* menu, CategoryFactory& factory, return childEnabled; } -ModListPrimaryCategoryMenu::ModListPrimaryCategoryMenu(CategoryFactory& categories, +ModListPrimaryCategoryMenu::ModListPrimaryCategoryMenu(CategoryFactory* categories, ModInfo::Ptr mod, QMenu* parent) : QMenu(tr("Primary Category"), parent) { @@ -178,17 +181,17 @@ ModListPrimaryCategoryMenu::ModListPrimaryCategoryMenu(CategoryFactory& categori }); } -void ModListPrimaryCategoryMenu::populate(const CategoryFactory& factory, +void ModListPrimaryCategoryMenu::populate(const CategoryFactory* factory, ModInfo::Ptr mod) { clear(); const std::set<int>& categories = mod->getCategories(); for (int categoryID : categories) { - int catIdx = factory.getCategoryIndex(categoryID); + int catIdx = factory->getCategoryIndex(categoryID); QWidgetAction* action = new QWidgetAction(this); try { QRadioButton* categoryBox = - new QRadioButton(factory.getCategoryName(catIdx).replace('&', "&&"), this); + new QRadioButton(factory->getCategoryName(catIdx).replace('&', "&&"), this); categoryBox->setChecked(categoryID == mod->primaryCategory()); action->setDefaultWidget(categoryBox); action->setData(categoryID); @@ -216,7 +219,7 @@ int ModListPrimaryCategoryMenu::primaryCategory() const } ModListContextMenu::ModListContextMenu(const QModelIndex& index, OrganizerCore& core, - CategoryFactory& categories, ModListView* view) + CategoryFactory* categories, ModListView* view) : QMenu(view), m_core(core), m_categories(categories), m_index(index.model() == view->model() ? view->indexViewToModel(index) : index), m_view(view), m_actions(view->actions()) @@ -558,6 +561,12 @@ void ModListContextMenu::addRegularActions(ModInfo::Ptr mod) } } + if (mod->nexusId() > 0 && !mod->installationFile().isEmpty()) { + addAction(tr("Remap Category (From Nexus)"), [=]() { + m_actions.remapCategory(m_selected); + }); + } + if (mod->nexusId() > 0 && Settings::instance().nexus().trackedIntegration()) { switch (mod->trackedState()) { case TrackedState::TRACKED_FALSE: { |
