diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/categories.cpp | 11 | ||||
| -rw-r--r-- | src/categories.h | 7 | ||||
| -rw-r--r-- | src/categoriesdialog.cpp | 38 | ||||
| -rw-r--r-- | src/categoriesdialog.h | 7 | ||||
| -rw-r--r-- | src/downloadmanager.cpp | 37 | ||||
| -rw-r--r-- | src/downloadmanager.h | 9 | ||||
| -rw-r--r-- | src/filterlist.cpp | 2 | ||||
| -rw-r--r-- | src/installationmanager.cpp | 4 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 33 | ||||
| -rw-r--r-- | src/mainwindow.h | 3 | ||||
| -rw-r--r-- | src/moapplication.cpp | 2 | ||||
| -rw-r--r-- | src/modinfo.cpp | 12 | ||||
| -rw-r--r-- | src/modinfodialogcategories.cpp | 12 | ||||
| -rw-r--r-- | src/modinfodialogcategories.h | 2 | ||||
| -rw-r--r-- | src/modinforegular.cpp | 10 | ||||
| -rw-r--r-- | src/modlist.cpp | 18 | ||||
| -rw-r--r-- | src/modlistsortproxy.cpp | 10 | ||||
| -rw-r--r-- | src/modlistviewactions.cpp | 8 | ||||
| -rw-r--r-- | src/organizercore.cpp | 3 | ||||
| -rw-r--r-- | src/settingsdialoggeneral.cpp | 2 |
20 files changed, 127 insertions, 103 deletions
diff --git a/src/categories.cpp b/src/categories.cpp index 18cee4f9..5d0d2bb7 100644 --- a/src/categories.cpp +++ b/src/categories.cpp @@ -146,10 +146,10 @@ void CategoryFactory::loadCategories() loadDefaultCategories(); } -CategoryFactory* CategoryFactory::instance() +CategoryFactory& CategoryFactory::instance() { static CategoryFactory s_Instance; - return &s_Instance; + return s_Instance; } void CategoryFactory::reset() @@ -285,7 +285,7 @@ void CategoryFactory::addCategory(int id, const QString& name, void CategoryFactory::setNexusCategories( std::vector<CategoryFactory::NexusCategory>& nexusCats) { - m_NexusMap.empty(); + m_NexusMap.clear(); for (auto nexusCat : nexusCats) { m_NexusMap.emplace(nexusCat.m_ID, nexusCat); } @@ -293,6 +293,11 @@ void CategoryFactory::setNexusCategories( saveCategories(); } +void CategoryFactory::refreshNexusCategories(CategoriesDialog* dialog) +{ + emit nexusCategoryRefresh(dialog); +} + void CategoryFactory::loadDefaultCategories() { // the order here is relevant as it defines the order in which the diff --git a/src/categories.h b/src/categories.h index 3f91e6c5..b7a9c214 100644 --- a/src/categories.h +++ b/src/categories.h @@ -25,6 +25,8 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include <map> #include <vector> +class CategoriesDialog; + /** * @brief Manage the available mod categories * @warning member functions of this class currently use a wild mix of ids and indexes @@ -116,6 +118,8 @@ public: void setNexusCategories(std::vector<CategoryFactory::NexusCategory>& nexusCats); + void refreshNexusCategories(CategoriesDialog* dialog); + int addCategory(const QString& name, const std::vector<NexusCategory>& nexusCats, int parentID); @@ -211,7 +215,7 @@ public: * * @return the reference to the singleton **/ - static CategoryFactory* instance(); + static CategoryFactory& instance(); /** * @return path to the file that contains the categories list @@ -224,6 +228,7 @@ public: static QString nexusMappingFilePath(); signals: + void nexusCategoryRefresh(CategoriesDialog*); void categoriesSaved(); private: diff --git a/src/categoriesdialog.cpp b/src/categoriesdialog.cpp index 5b6270f8..53c930f3 100644 --- a/src/categoriesdialog.cpp +++ b/src/categoriesdialog.cpp @@ -105,9 +105,8 @@ private: QValidator* m_Validator; }; -CategoriesDialog::CategoriesDialog(PluginContainer* pluginContainer, QWidget* parent) - : TutorableDialog("Categories", parent), ui(new Ui::CategoriesDialog), - m_PluginContainer(pluginContainer) +CategoriesDialog::CategoriesDialog(QWidget* parent) + : TutorableDialog("Categories", parent), ui(new Ui::CategoriesDialog) { ui->setupUi(this); fillTable(); @@ -144,8 +143,8 @@ void CategoriesDialog::cellChanged(int row, int) void CategoriesDialog::commitChanges() { - CategoryFactory* categories = CategoryFactory::instance(); - categories->reset(); + CategoryFactory& categories = CategoryFactory::instance(); + categories.reset(); for (int i = 0; i < ui->categoriesTable->rowCount(); ++i) { int index = ui->categoriesTable->verticalHeader()->logicalIndex(i); @@ -157,12 +156,12 @@ void CategoriesDialog::commitChanges() nexusCat.toList()[0].toString(), nexusCat.toList()[1].toInt())); } - categories->addCategory(ui->categoriesTable->item(index, 0)->text().toInt(), - ui->categoriesTable->item(index, 1)->text(), nexusCats, - ui->categoriesTable->item(index, 2)->text().toInt()); + categories.addCategory(ui->categoriesTable->item(index, 0)->text().toInt(), + ui->categoriesTable->item(index, 1)->text(), nexusCats, + ui->categoriesTable->item(index, 2)->text().toInt()); } - categories->setParents(); + categories.setParents(); std::vector<CategoryFactory::NexusCategory> nexusCats; for (int i = 0; i < ui->nexusCategoryList->count(); ++i) { @@ -171,9 +170,9 @@ void CategoriesDialog::commitChanges() ui->nexusCategoryList->item(i)->data(Qt::UserRole).toInt())); } - categories->setNexusCategories(nexusCats); + categories.setNexusCategories(nexusCats); - categories->saveCategories(); + categories.saveCategories(); } void CategoriesDialog::refreshIDs() @@ -190,7 +189,7 @@ void CategoriesDialog::refreshIDs() void CategoriesDialog::fillTable() { - CategoryFactory* categories = CategoryFactory::instance(); + CategoryFactory& categories = CategoryFactory::instance(); QTableWidget* table = ui->categoriesTable; QListWidget* list = ui->nexusCategoryList; @@ -211,8 +210,8 @@ void CategoriesDialog::fillTable() int row = 0; for (std::vector<CategoryFactory::Category>::const_iterator iter = - categories->m_Categories.begin(); - iter != categories->m_Categories.end(); ++iter, ++row) { + categories.m_Categories.begin(); + iter != categories.m_Categories.end(); ++iter, ++row) { const CategoryFactory::Category& category = *iter; if (category.m_ID == 0) { --row; @@ -235,12 +234,12 @@ void CategoriesDialog::fillTable() table->setItem(row, 3, nexusCatItem.take()); } - for (auto nexusCat : categories->m_NexusMap) { + for (auto nexusCat : categories.m_NexusMap) { QScopedPointer<QListWidgetItem> nexusItem(new QListWidgetItem()); nexusItem->setData(Qt::DisplayRole, nexusCat.second.m_Name); nexusItem->setData(Qt::UserRole, nexusCat.second.m_ID); list->addItem(nexusItem.take()); - auto item = table->item(categories->resolveNexusID(nexusCat.first) - 1, 3); + auto item = table->item(categories.resolveNexusID(nexusCat.first) - 1, 3); if (item != nullptr) { auto itemData = item->data(Qt::UserRole).toList(); QVariantList newData; @@ -285,10 +284,7 @@ void CategoriesDialog::removeNexusMap_clicked() void CategoriesDialog::nexusRefresh_clicked() { - NexusInterface& nexus = NexusInterface::instance(); - nexus.setPluginContainer(m_PluginContainer); - nexus.requestGameInfo(Settings::instance().game().plugin()->gameShortName(), this, - QVariant(), QString()); + CategoryFactory::instance().refreshNexusCategories(this); } void CategoriesDialog::nexusImport_clicked() @@ -356,7 +352,7 @@ void CategoriesDialog::nxmGameInfoAvailable(QString gameName, QVariant, { QVariantMap result = resultData.toMap(); QVariantList categories = result["categories"].toList(); - CategoryFactory* catFactory = CategoryFactory::instance(); + CategoryFactory& catFactory = CategoryFactory::instance(); QListWidget* list = ui->nexusCategoryList; list->clear(); for (auto category : categories) { diff --git a/src/categoriesdialog.h b/src/categoriesdialog.h index 1bcf273c..94f390b0 100644 --- a/src/categoriesdialog.h +++ b/src/categoriesdialog.h @@ -38,7 +38,7 @@ class CategoriesDialog : public MOBase::TutorableDialog Q_OBJECT public: - explicit CategoriesDialog(PluginContainer* pluginContainer, QWidget* parent = 0); + explicit CategoriesDialog(QWidget* parent = 0); ~CategoriesDialog(); // also saves and restores geometry @@ -52,16 +52,11 @@ public: void commitChanges(); public slots: - void nxmGameInfoAvailable(QString gameName, QVariant, QVariant resultData, int); void nxmRequestFailed(QString, int, int, QVariant, int, int errorCode, const QString& errorMessage); -signals: - void refreshNexusCategories(); - private slots: - void on_categoriesTable_customContextMenuRequested(const QPoint& pos); void addCategory_clicked(); void removeCategory_clicked(); diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 3c9e776e..d7a72c0b 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -153,6 +153,20 @@ DownloadManager::DownloadInfo::createFromMeta(const QString& filePath, bool show return info; } +ScopedDisableDirWatcher::ScopedDisableDirWatcher(DownloadManager* downloadManager) +{ + m_downloadManager = downloadManager; + m_downloadManager->startDisableDirWatcher(); + log::debug("Scoped Disable DirWatcher: Started"); +} + +ScopedDisableDirWatcher::~ScopedDisableDirWatcher() +{ + m_downloadManager->endDisableDirWatcher(); + m_downloadManager = nullptr; + log::debug("Scoped Disable DirWatcher: Stopped"); +} + void DownloadManager::startDisableDirWatcher() { DownloadManager::m_DirWatcherDisabler++; @@ -317,10 +331,9 @@ void DownloadManager::refreshList() { TimeThis tt("DownloadManager::refreshList()"); + // avoid triggering other refreshes + ScopedDisableDirWatcher scopedDirWatcher(this); try { - // avoid triggering other refreshes - startDisableDirWatcher(); - int downloadsBefore = m_ActiveDownloads.size(); // remove finished downloads @@ -419,10 +432,7 @@ void DownloadManager::refreshList() log::debug("saw {} downloads", m_ActiveDownloads.size()); - emit update(-1); - - // let watcher trigger refreshes again - endDisableDirWatcher(); + emit update(-1); } catch (const std::bad_alloc&) { reportError(tr("Memory allocation error (in refreshing directory).")); @@ -758,7 +768,7 @@ void DownloadManager::addNXMDownload(const QString& url) void DownloadManager::removeFile(int index, bool deleteFile) { // Avoid triggering refreshes from DirWatcher - startDisableDirWatcher(); + ScopedDisableDirWatcher scopedDirWatcher(this); if (index >= m_ActiveDownloads.size()) { throw MyException(tr("remove: invalid download index %1").arg(index)); @@ -770,7 +780,6 @@ void DownloadManager::removeFile(int index, bool deleteFile) (download->m_State == STATE_DOWNLOADING)) { // shouldn't have been possible log::error("tried to remove active download"); - endDisableDirWatcher(); return; } @@ -781,7 +790,6 @@ void DownloadManager::removeFile(int index, bool deleteFile) if (deleteFile) { if (!shellDelete(QStringList(filePath), true)) { reportError(tr("failed to delete %1").arg(filePath)); - endDisableDirWatcher(); return; } @@ -795,8 +803,6 @@ void DownloadManager::removeFile(int index, bool deleteFile) metaSettings.setValue("removed", true); } m_DownloadRemoved(index); - - endDisableDirWatcher(); } class LessThanWrapper @@ -1449,15 +1455,13 @@ void DownloadManager::markInstalled(int index) } // Avoid triggering refreshes from DirWatcher - startDisableDirWatcher(); + ScopedDisableDirWatcher scopedDirWatcher(this); DownloadInfo* info = m_ActiveDownloads.at(index); QSettings metaFile(info->m_Output.fileName() + ".meta", QSettings::IniFormat); metaFile.setValue("installed", true); metaFile.setValue("uninstalled", false); - endDisableDirWatcher(); - setState(m_ActiveDownloads.at(index), STATE_INSTALLED); } @@ -1686,7 +1690,7 @@ void DownloadManager::downloadReadyRead() void DownloadManager::createMetaFile(DownloadInfo* info) { // Avoid triggering refreshes from DirWatcher - startDisableDirWatcher(); + ScopedDisableDirWatcher scopedDirWatcher(this); QSettings metaFile(QString("%1.meta").arg(info->m_Output.fileName()), QSettings::IniFormat); @@ -1710,7 +1714,6 @@ void DownloadManager::createMetaFile(DownloadInfo* info) (info->m_State == DownloadManager::STATE_ERROR)); metaFile.setValue("removed", info->m_Hidden); - endDisableDirWatcher(); // slightly hackish... for (int i = 0; i < m_ActiveDownloads.size(); ++i) { if (m_ActiveDownloads[i] == info) { diff --git a/src/downloadmanager.h b/src/downloadmanager.h index d264ec87..618c2813 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -634,4 +634,13 @@ private: QTimer m_TimeoutTimer; }; +class ScopedDisableDirWatcher +{ +public: + ScopedDisableDirWatcher(DownloadManager* downloadManager); + ~ScopedDisableDirWatcher(); + +private: + DownloadManager* m_downloadManager; +}; #endif // DOWNLOADMANAGER_H diff --git a/src/filterlist.cpp b/src/filterlist.cpp index c88945f8..3be67def 100644 --- a/src/filterlist.cpp +++ b/src/filterlist.cpp @@ -425,7 +425,7 @@ void FilterList::checkCriteria() void FilterList::editCategories() { - CategoriesDialog dialog(&m_core.pluginContainer(), qApp->activeWindow()); + CategoriesDialog dialog(qApp->activeWindow()); if (dialog.exec() == QDialog::Accepted) { dialog.commitChanges(); diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index 3f247b38..37c86c7e 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -663,7 +663,7 @@ InstallationResult InstallationManager::install(const QString& fileName, version = metaFile.value("version", "").toString(); newestVersion = metaFile.value("newestVersion", "").toString(); category = metaFile.value("category", 0).toInt(); - unsigned int categoryIndex = CategoryFactory::instance()->resolveNexusID(category); + unsigned int categoryIndex = CategoryFactory::instance().resolveNexusID(category); if (category != 0 && categoryIndex == 0U && Settings::instance().nexus().categoryMappings()) { QMessageBox nexusQuery; @@ -685,7 +685,7 @@ InstallationResult InstallationManager::install(const QString& fileName, return MOBase::IPluginInstaller::RESULT_CATEGORYREQUESTED; } } else { - categoryID = CategoryFactory::instance()->getCategoryID(categoryIndex); + categoryID = CategoryFactory::instance().getCategoryID(categoryIndex); } repository = metaFile.value("repository", "").toString(); fileCategoryID = metaFile.value("fileCategory", 1).toInt(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 74504ed6..ce2c4dd0 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -290,7 +290,7 @@ MainWindow::MainWindow(Settings& settings, OrganizerCore& organizerCore, ui->statusBar->setAPI(ni.getAPIStats(), ni.getAPIUserAccount()); } - m_CategoryFactory->loadCategories(); + m_CategoryFactory.loadCategories(); ui->logList->setCore(m_OrganizerCore); @@ -455,8 +455,9 @@ MainWindow::MainWindow(Settings& settings, OrganizerCore& organizerCore, connect(&m_OrganizerCore, &OrganizerCore::modInstalled, this, &MainWindow::modInstalled); - connect(m_CategoryFactory, &CategoryFactory::categoriesSaved, this, - &MainWindow::categoriesSaved); + connect(&m_CategoryFactory, SIGNAL(nexusCategoryRefresh(CategoriesDialog*)), this, + SLOT(refreshNexusCategories(CategoriesDialog*))); + connect(&m_CategoryFactory, SIGNAL(categoriesSaved()), this, SLOT(categoriesSaved())); m_CheckBSATimer.setSingleShot(true); connect(&m_CheckBSATimer, SIGNAL(timeout()), this, SLOT(checkBSAList())); @@ -540,7 +541,7 @@ MainWindow::MainWindow(Settings& settings, OrganizerCore& organizerCore, void MainWindow::setupModList() { - ui->modList->setup(m_OrganizerCore, *m_CategoryFactory, this, ui); + ui->modList->setup(m_OrganizerCore, m_CategoryFactory, this, ui); connect(&ui->modList->actions(), &ModListViewActions::overwriteCleared, [=]() { scheduleCheckForProblems(); @@ -1291,11 +1292,11 @@ void MainWindow::showEvent(QShowEvent* event) if (newCatDialog.clickedButton() == &importBtn) { importCategories(false); } else if (newCatDialog.clickedButton() == &cancelBtn) { - m_CategoryFactory->reset(); + m_CategoryFactory.reset(); } else if (newCatDialog.clickedButton() == &defaultBtn) { - m_CategoryFactory->loadCategories(); + m_CategoryFactory.loadCategories(); } - m_CategoryFactory->saveCategories(); + m_CategoryFactory.saveCategories(); m_OrganizerCore.settings().setFirstStart(false); } else { @@ -2087,7 +2088,7 @@ void MainWindow::fixCategories() std::set<int> categories = modInfo->getCategories(); for (std::set<int>::iterator iter = categories.begin(); iter != categories.end(); ++iter) { - if (!m_CategoryFactory->categoryExists(*iter)) { + if (!m_CategoryFactory.categoryExists(*iter)) { modInfo->setCategory(*iter, false); } } @@ -2831,12 +2832,20 @@ void MainWindow::onPluginRegistrationChanged() m_DownloadsTab->update(); } +void MainWindow::refreshNexusCategories(CategoriesDialog* dialog) +{ + NexusInterface& nexus = NexusInterface::instance(); + nexus.setPluginContainer(&m_PluginContainer); + nexus.requestGameInfo(Settings::instance().game().plugin()->gameShortName(), dialog, + QVariant(), QString()); +} + void MainWindow::categoriesSaved() { for (auto modName : m_OrganizerCore.modList()->allMods()) { auto mod = ModInfo::getByName(modName); for (auto category : mod->getCategories()) { - if (!m_CategoryFactory->categoryExists(category)) + if (!m_CategoryFactory.categoryExists(category)) mod->setCategory(category, false); } } @@ -3457,14 +3466,14 @@ void MainWindow::nxmGameInfoAvailable(QString gameName, QVariant, QVariant resul { QVariantMap result = resultData.toMap(); QVariantList categories = result["categories"].toList(); - CategoryFactory* catFactory = CategoryFactory::instance(); - catFactory->reset(); + CategoryFactory& catFactory = CategoryFactory::instance(); + catFactory.reset(); for (auto category : categories) { auto catMap = category.toMap(); std::vector<CategoryFactory::NexusCategory> nexusCat; nexusCat.push_back(CategoryFactory::NexusCategory(catMap["name"].toString(), catMap["category_id"].toInt())); - catFactory->addCategory(catMap["name"].toString(), nexusCat, 0); + catFactory.addCategory(catMap["name"].toString(), nexusCat, 0); } } diff --git a/src/mainwindow.h b/src/mainwindow.h index eae50aa0..99feca83 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -283,7 +283,7 @@ private: QAction* m_ContextAction; - CategoryFactory* m_CategoryFactory; + CategoryFactory& m_CategoryFactory; QTimer m_CheckBSATimer; QTimer m_SaveMetaTimer; @@ -363,6 +363,7 @@ private slots: void importCategories(bool); + void refreshNexusCategories(CategoriesDialog* dialog); void categoriesSaved(); // update info diff --git a/src/moapplication.cpp b/src/moapplication.cpp index 7e95217e..e131d3d9 100644 --- a/src/moapplication.cpp +++ b/src/moapplication.cpp @@ -296,7 +296,7 @@ int MOApplication::setup(MOMultiProcess& multiProcess, bool forceSelect) m_instance->gamePlugin()->steamAPPId(), m_instance->gamePlugin()->gameDirectory().absolutePath()); - CategoryFactory::instance()->loadCategories(); + CategoryFactory::instance().loadCategories(); m_core->updateExecutablesList(); m_core->updateModInfoFromDisc(); m_core->setCurrentProfile(m_instance->profileName()); diff --git a/src/modinfo.cpp b/src/modinfo.cpp index 0ae28e73..1028c66f 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -493,9 +493,9 @@ void ModInfo::setPluginSelected(const bool& isSelected) void ModInfo::addCategory(const QString& categoryName) { - int id = CategoryFactory::instance()->getCategoryID(categoryName); + int id = CategoryFactory::instance().getCategoryID(categoryName); if (id == -1) { - id = CategoryFactory::instance()->addCategory( + id = CategoryFactory::instance().addCategory( categoryName, std::vector<CategoryFactory::NexusCategory>(), 0); } setCategory(id, true); @@ -503,7 +503,7 @@ void ModInfo::addCategory(const QString& categoryName) bool ModInfo::removeCategory(const QString& categoryName) { - int id = CategoryFactory::instance()->getCategoryID(categoryName); + int id = CategoryFactory::instance().getCategoryID(categoryName); if (id == -1) { return false; } @@ -518,9 +518,9 @@ QStringList ModInfo::categories() const { QStringList result; - CategoryFactory* catFac = CategoryFactory::instance(); + CategoryFactory& catFac = CategoryFactory::instance(); for (int id : m_Categories) { - result.append(catFac->getCategoryName(catFac->getCategoryIndex(id))); + result.append(catFac.getCategoryName(catFac.getCategoryIndex(id))); } return result; @@ -550,7 +550,7 @@ bool ModInfo::categorySet(int categoryID) const for (std::set<int>::const_iterator iter = m_Categories.begin(); iter != m_Categories.end(); ++iter) { if ((*iter == categoryID) || - (CategoryFactory::instance()->isDescendantOf(*iter, categoryID))) { + (CategoryFactory::instance().isDescendantOf(*iter, categoryID))) { return true; } } diff --git a/src/modinfodialogcategories.cpp b/src/modinfodialogcategories.cpp index 5665df9f..a7a4ce1e 100644 --- a/src/modinfodialogcategories.cpp +++ b/src/modinfodialogcategories.cpp @@ -44,19 +44,19 @@ bool CategoriesTab::usesOriginFiles() const return false; } -void CategoriesTab::add(const CategoryFactory* factory, +void CategoriesTab::add(const CategoryFactory& factory, const std::set<int>& enabledCategories, QTreeWidgetItem* root, int rootLevel) { - for (int i = 0; i < static_cast<int>(factory->numCategories()); ++i) { - if (factory->getParentID(i) != rootLevel) { + for (int i = 0; i < static_cast<int>(factory.numCategories()); ++i) { + if (factory.getParentID(i) != rootLevel) { continue; } - int categoryID = factory->getCategoryID(i); + int categoryID = factory.getCategoryID(i); QTreeWidgetItem* newItem = - new QTreeWidgetItem(QStringList(factory->getCategoryName(i))); + new QTreeWidgetItem(QStringList(factory.getCategoryName(i))); newItem->setFlags(newItem->flags() | Qt::ItemIsUserCheckable); @@ -67,7 +67,7 @@ void CategoriesTab::add(const CategoryFactory* factory, newItem->setData(0, Qt::UserRole, categoryID); - if (factory->hasChildren(i)) { + if (factory.hasChildren(i)) { add(factory, enabledCategories, newItem, categoryID); } diff --git a/src/modinfodialogcategories.h b/src/modinfodialogcategories.h index b390146c..03b3555b 100644 --- a/src/modinfodialogcategories.h +++ b/src/modinfodialogcategories.h @@ -13,7 +13,7 @@ public: bool usesOriginFiles() const override; private: - void add(const CategoryFactory* factory, const std::set<int>& enabledCategories, + void add(const CategoryFactory& factory, const std::set<int>& enabledCategories, QTreeWidgetItem* root, int rootLevel); void updatePrimary(); diff --git a/src/modinforegular.cpp b/src/modinforegular.cpp index 58590477..c79fc574 100644 --- a/src/modinforegular.cpp +++ b/src/modinforegular.cpp @@ -213,7 +213,7 @@ void ModInfoRegular::readMeta() continue; } if (ok && (categoryID != 0) && - (CategoryFactory::instance()->categoryExists(categoryID))) { + (CategoryFactory::instance().categoryExists(categoryID))) { m_Categories.insert(categoryID); if (iter == categories.begin()) { m_PrimaryCategory = categoryID; @@ -578,7 +578,7 @@ void ModInfoRegular::setInstallationFile(const QString& fileName) void ModInfoRegular::addNexusCategory(int categoryID) { - m_Categories.insert(CategoryFactory::instance()->resolveNexusID(categoryID)); + m_Categories.insert(CategoryFactory::instance().resolveNexusID(categoryID)); } void ModInfoRegular::setIsEndorsed(bool endorsed) @@ -734,15 +734,15 @@ QString ModInfoRegular::getDescription() const const std::set<int>& categories = getCategories(); std::wostringstream categoryString; categoryString << ToWString(tr("Categories: <br>")); - CategoryFactory* categoryFactory = CategoryFactory::instance(); + CategoryFactory& categoryFactory = CategoryFactory::instance(); for (std::set<int>::const_iterator catIter = categories.begin(); catIter != categories.end(); ++catIter) { if (catIter != categories.begin()) { categoryString << " , "; } categoryString << "<span style=\"white-space: nowrap;\"><i>" - << ToWString(categoryFactory->getCategoryName( - categoryFactory->getCategoryIndex(*catIter))) + << ToWString(categoryFactory.getCategoryName( + categoryFactory.getCategoryIndex(*catIter))) << "</font></span>"; } diff --git a/src/modlist.cpp b/src/modlist.cpp index 9f64cc71..7a951369 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -232,11 +232,11 @@ QVariant ModList::data(const QModelIndex& modelIndex, int role) const } else { int category = modInfo->primaryCategory(); if (category != -1) { - CategoryFactory* categoryFactory = CategoryFactory::instance(); - if (categoryFactory->categoryExists(category)) { + CategoryFactory& categoryFactory = CategoryFactory::instance(); + if (categoryFactory.categoryExists(category)) { try { - int categoryIdx = categoryFactory->getCategoryIndex(category); - return categoryFactory->getCategoryName(categoryIdx); + int categoryIdx = categoryFactory.getCategoryIndex(category); + return categoryFactory.getCategoryName(categoryIdx); } catch (const std::exception& e) { log::error("failed to retrieve category name: {}", e.what()); return QString(); @@ -286,10 +286,10 @@ QVariant ModList::data(const QModelIndex& modelIndex, int role) const if (column == COL_CATEGORY) { QVariantList categoryNames; std::set<int> categories = modInfo->getCategories(); - CategoryFactory* categoryFactory = CategoryFactory::instance(); + CategoryFactory& categoryFactory = CategoryFactory::instance(); for (auto iter = categories.begin(); iter != categories.end(); ++iter) { categoryNames.append( - categoryFactory->getCategoryName(categoryFactory->getCategoryIndex(*iter))); + categoryFactory.getCategoryName(categoryFactory.getCategoryIndex(*iter))); } if (categoryNames.count() != 0) { return categoryNames; @@ -447,7 +447,7 @@ QVariant ModList::data(const QModelIndex& modelIndex, int role) const const std::set<int>& categories = modInfo->getCategories(); std::wostringstream categoryString; categoryString << ToWString(tr("Categories: <br>")); - CategoryFactory* categoryFactory = CategoryFactory::instance(); + CategoryFactory& categoryFactory = CategoryFactory::instance(); for (std::set<int>::const_iterator catIter = categories.begin(); catIter != categories.end(); ++catIter) { if (catIter != categories.begin()) { @@ -455,8 +455,8 @@ QVariant ModList::data(const QModelIndex& modelIndex, int role) const } try { categoryString << "<span style=\"white-space: nowrap;\"><i>" - << ToWString(categoryFactory->getCategoryName( - categoryFactory->getCategoryIndex(*catIter))) + << ToWString(categoryFactory.getCategoryName( + categoryFactory.getCategoryIndex(*catIter))) << "</font></span>"; } catch (const std::exception& e) { log::error("failed to generate tooltip: {}", e.what()); diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp index e61f9494..704ec10b 100644 --- a/src/modlistsortproxy.cpp +++ b/src/modlistsortproxy.cpp @@ -171,11 +171,11 @@ bool ModListSortProxy::lessThan(const QModelIndex& left, const QModelIndex& righ lt = true; else { try { - CategoryFactory* categories = CategoryFactory::instance(); - QString leftCatName = categories->getCategoryName( - categories->getCategoryIndex(leftMod->primaryCategory())); - QString rightCatName = categories->getCategoryName( - categories->getCategoryIndex(rightMod->primaryCategory())); + CategoryFactory& categories = CategoryFactory::instance(); + QString leftCatName = categories.getCategoryName( + categories.getCategoryIndex(leftMod->primaryCategory())); + QString rightCatName = categories.getCategoryName( + categories.getCategoryIndex(rightMod->primaryCategory())); lt = leftCatName < rightCatName; } catch (const std::exception& e) { log::error("failed to compare categories: {}", e.what()); diff --git a/src/modlistviewactions.cpp b/src/modlistviewactions.cpp index d82dca87..983574ab 100644 --- a/src/modlistviewactions.cpp +++ b/src/modlistviewactions.cpp @@ -288,13 +288,13 @@ void ModListViewActions::assignCategories() const nexusCategory = downloadMeta.value("category", 0).toInt(); } } - int newCategory = CategoryFactory::instance()->resolveNexusID(nexusCategory); + 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); } } @@ -1136,10 +1136,10 @@ void ModListViewActions::remapCategory(const QModelIndexList& indices) const } } unsigned int categoryIndex = - CategoryFactory::instance()->resolveNexusID(categoryID); + CategoryFactory::instance().resolveNexusID(categoryID); if (categoryIndex != 0) modInfo->setPrimaryCategory( - CategoryFactory::instance()->getCategoryID(categoryIndex)); + CategoryFactory::instance().getCategoryID(categoryIndex)); } } diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 3781a4e1..dda731ba 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -804,7 +804,7 @@ OrganizerCore::doInstall(const QString& archivePath, GuessedValue<QString> modNa return {modIndex, modInfo}; } else { if (result.result() == MOBase::IPluginInstaller::RESULT_CATEGORYREQUESTED) { - CategoriesDialog dialog(&pluginContainer(), qApp->activeWindow()); + CategoriesDialog dialog(qApp->activeWindow()); if (dialog.exec() == QDialog::Accepted) { dialog.commitChanges(); @@ -831,6 +831,7 @@ OrganizerCore::doInstall(const QString& archivePath, GuessedValue<QString> modNa ModInfo::Ptr OrganizerCore::installDownload(int index, int priority) { + ScopedDisableDirWatcher scopedDirwatcher(&m_DownloadManager); try { QString fileName = m_DownloadManager.getFilePath(index); QString gameName = m_DownloadManager.getGameName(index); diff --git a/src/settingsdialoggeneral.cpp b/src/settingsdialoggeneral.cpp index 6a666437..62b26c2f 100644 --- a/src/settingsdialoggeneral.cpp +++ b/src/settingsdialoggeneral.cpp @@ -160,7 +160,7 @@ void GeneralSettingsTab::resetDialogs() void GeneralSettingsTab::onEditCategories() { - CategoriesDialog catDialog(m_PluginContainer, &dialog()); + CategoriesDialog catDialog(&dialog()); if (catDialog.exec() == QDialog::Accepted) { catDialog.commitChanges(); |
