From 535623693e63569f485c15984274ea65c4d0c872 Mon Sep 17 00:00:00 2001 From: Jeremy Rimpo Date: Fri, 30 Jul 2021 21:29:16 -0500 Subject: Add menu item to auto-assign categories based on nexus assignments --- src/modlistviewactions.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/modlistviewactions.cpp') diff --git a/src/modlistviewactions.cpp b/src/modlistviewactions.cpp index a6f0f07e..21079f1d 100644 --- a/src/modlistviewactions.cpp +++ b/src/modlistviewactions.cpp @@ -12,6 +12,7 @@ #include "categories.h" #include "csvbuilder.h" #include "directoryrefresher.h" +#include "downloadmanager.h" #include "filedialogmemory.h" #include "filterlist.h" #include "listdialog.h" @@ -259,6 +260,23 @@ void ModListViewActions::checkModsForUpdates() const } } +void ModListViewActions::assignCategories() const +{ + for (auto mod : m_core.modList()->allMods()) { + ModInfo::Ptr modInfo = ModInfo::getByName(mod); + for (auto category : modInfo->categories()) { + modInfo->removeCategory(category); + } + QString file = modInfo->installationFile(); + auto download = m_core.downloadManager()->getDownloadIndex(file); + if (download >= 0) { + int nexusCategory = m_core.downloadManager()->getCategoryID(download); + int category = CategoryFactory::instance()->resolveNexusID(nexusCategory); + modInfo->setCategory(CategoryFactory::instance()->getCategoryID(category), true); + } + } +} + void ModListViewActions::checkModsForUpdates( std::multimap const& IDs) const { -- cgit v1.3.1