diff options
| author | Jeremy Rimpo <jeremy.rimpo@servermonkey.com> | 2023-09-25 17:39:41 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-25 17:39:41 -0500 |
| commit | 79d457f598bcfa7a8d094a87033a31f370c9c4c1 (patch) | |
| tree | 3674e6b1223ac104422ce77b06d020c50ad31cc0 /src/modlistviewactions.cpp | |
| parent | 70509275405d2a5c5e94743786f03b17ef2051f2 (diff) | |
| parent | 74668b9363d877d055a5e8b8c7d001ba448dc832 (diff) | |
Merge pull request #1880 from ModOrganizer2/qt6-category
WIP: Category Revamp
Diffstat (limited to 'src/modlistviewactions.cpp')
| -rw-r--r-- | src/modlistviewactions.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/modlistviewactions.cpp b/src/modlistviewactions.cpp index a6f0f07e..cbac9c6c 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,44 @@ void ModListViewActions::checkModsForUpdates() const } } +void ModListViewActions::assignCategories() const +{ + if (!GlobalSettings::hideAssignCategoriesQuestion()) { + QMessageBox warning; + warning.setWindowTitle(tr("Are you sure?")); + warning.setText( + tr("This action will remove any existing categories on any mod with a valid " + "Nexus category mapping. Are you certain you want to proceed?")); + warning.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel); + QCheckBox dontShow(tr("&Don't show this again")); + warning.setCheckBox(&dontShow); + auto result = warning.exec(); + if (dontShow.isChecked()) + GlobalSettings::setHideAssignCategoriesQuestion(true); + if (result == QMessageBox::Cancel) + return; + } + for (auto mod : m_core.modList()->allMods()) { + ModInfo::Ptr modInfo = ModInfo::getByName(mod); + int nexusCategory = modInfo->getNexusCategory(); + if (!nexusCategory) { + QSettings downloadMeta(m_core.downloadsPath() + "/" + + modInfo->installationFile() + ".meta", + QSettings::IniFormat); + if (downloadMeta.contains("category")) { + nexusCategory = downloadMeta.value("category", 0).toInt(); + } + } + int newCategory = CategoryFactory::instance().resolveNexusID(nexusCategory); + if (newCategory != 0) { + for (auto category : modInfo->categories()) { + modInfo->removeCategory(category); + } + } + modInfo->setCategory(CategoryFactory::instance().getCategoryID(newCategory), true); + } +} + void ModListViewActions::checkModsForUpdates( std::multimap<QString, int> const& IDs) const { @@ -1082,6 +1121,27 @@ 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 categoryID = modInfo->getNexusCategory(); + if (!categoryID) { + QSettings downloadMeta(m_core.downloadsPath() + "/" + + modInfo->installationFile() + ".meta", + QSettings::IniFormat); + if (downloadMeta.contains("category")) { + categoryID = downloadMeta.value("category", 0).toInt(); + } + } + unsigned int categoryIndex = CategoryFactory::instance().resolveNexusID(categoryID); + if (categoryIndex != 0) + modInfo->setPrimaryCategory( + CategoryFactory::instance().getCategoryID(categoryIndex)); + } +} + void ModListViewActions::setColor(const QModelIndexList& indices, const QModelIndex& refIndex) const { |
