From b9f05672b9692c96d39b8ff27e571a30cb82cd44 Mon Sep 17 00:00:00 2001 From: Jeremy Rimpo Date: Fri, 24 Dec 2021 17:54:55 -0600 Subject: Allow remapping category from context menu --- src/modlistviewactions.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/modlistviewactions.cpp') diff --git a/src/modlistviewactions.cpp b/src/modlistviewactions.cpp index 21079f1d..b9d0f419 100644 --- a/src/modlistviewactions.cpp +++ b/src/modlistviewactions.cpp @@ -1100,6 +1100,20 @@ void ModListViewActions::willNotEndorsed(const QModelIndexList& indices) const } } +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); + modInfo->setPrimaryCategory(CategoryFactory::instance()->getCategoryID(categoryIndex)); + } + } +} + void ModListViewActions::setColor(const QModelIndexList& indices, const QModelIndex& refIndex) const { -- cgit v1.3.1