summaryrefslogtreecommitdiff
path: root/src/modlistviewactions.cpp
diff options
context:
space:
mode:
authorJeremy Rimpo <jeremy.rimpo@servermonkey.com>2023-09-19 02:37:24 -0500
committerJeremy Rimpo <jeremy.rimpo@servermonkey.com>2023-09-21 17:35:08 -0500
commitc50ad588432a27612fe5be39b1520e2962d5eef7 (patch)
tree676dd52d7022d9167eccc267ae9811367d8de666 /src/modlistviewactions.cpp
parentf6bb73deb21228acf0e7f74500f50421143aa739 (diff)
Add nexus category ID to mod info
- We will check the mod info first then fall back to the download file - Add category field in the info dialog nexus tab
Diffstat (limited to 'src/modlistviewactions.cpp')
-rw-r--r--src/modlistviewactions.cpp44
1 files changed, 25 insertions, 19 deletions
diff --git a/src/modlistviewactions.cpp b/src/modlistviewactions.cpp
index aa962c1e..a86c9067 100644
--- a/src/modlistviewactions.cpp
+++ b/src/modlistviewactions.cpp
@@ -265,18 +265,20 @@ void ModListViewActions::assignCategories() const
for (auto mod : m_core.modList()->allMods()) {
ModInfo::Ptr modInfo = ModInfo::getByName(mod);
QString file = modInfo->installationFile();
- auto download = m_core.downloadManager()->getDownloadIndex(file);
- if (download >= 0) {
- int nexusCategory = m_core.downloadManager()->getCategoryID(download);
- int newCategory = CategoryFactory::instance()->resolveNexusID(nexusCategory);
- if (newCategory != 0) {
- for (auto category : modInfo->categories()) {
- modInfo->removeCategory(category);
- }
+ int nexusCategory = modInfo->getNexusCategory();
+ if (!nexusCategory) {
+ auto download = m_core.downloadManager()->getDownloadIndex(file);
+ if (download >= 0) {
+ int nexusCategory = m_core.downloadManager()->getCategoryID(download);
+ }
+ }
+ int newCategory = CategoryFactory::instance()->resolveNexusID(nexusCategory);
+ if (newCategory != 0) {
+ for (auto category : modInfo->categories()) {
+ modInfo->removeCategory(category);
}
- modInfo->setCategory(CategoryFactory::instance()->getCategoryID(newCategory),
- true);
}
+ modInfo->setCategory(CategoryFactory::instance()->getCategoryID(newCategory), true);
}
}
@@ -1108,16 +1110,20 @@ void ModListViewActions::remapCategory(const QModelIndexList& indices) const
for (auto& idx : indices) {
ModInfo::Ptr modInfo = ModInfo::getByIndex(idx.data(ModList::IndexRole).toInt());
- int downloadIndex =
- m_core.downloadManager()->getDownloadIndex(modInfo->installationFile());
- if (downloadIndex >= 0) {
- auto downloadInfo = m_core.downloadManager()->getFileInfo(downloadIndex);
- unsigned int categoryIndex =
- CategoryFactory::instance()->resolveNexusID(downloadInfo->categoryID);
- if (categoryIndex != 0)
- modInfo->setPrimaryCategory(
- CategoryFactory::instance()->getCategoryID(categoryIndex));
+ int categoryID = modInfo->getNexusCategory();
+ if (!categoryID) {
+ int downloadIndex =
+ m_core.downloadManager()->getDownloadIndex(modInfo->installationFile());
+ if (downloadIndex >= 0) {
+ auto downloadInfo = m_core.downloadManager()->getFileInfo(downloadIndex);
+ categoryID = downloadInfo->categoryID;
+ }
}
+ unsigned int categoryIndex =
+ CategoryFactory::instance()->resolveNexusID(categoryID);
+ if (categoryIndex != 0)
+ modInfo->setPrimaryCategory(
+ CategoryFactory::instance()->getCategoryID(categoryIndex));
}
}