From 4a5ff2f2320656366a4c931300626a68c49bd7b6 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Wed, 13 Jan 2021 12:59:57 +0100 Subject: Remove archive parsing attribute from core and use the one from settings directly. --- src/filetreemodel.cpp | 2 +- src/mainwindow.cpp | 6 +++--- src/organizercore.cpp | 2 +- src/organizercore.h | 11 ----------- 4 files changed, 5 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/filetreemodel.cpp b/src/filetreemodel.cpp index 7095f492..22bcda28 100644 --- a/src/filetreemodel.cpp +++ b/src/filetreemodel.cpp @@ -273,7 +273,7 @@ const FileTreeModel::SortInfo& FileTreeModel::sortInfo() const bool FileTreeModel::showArchives() const { - return (m_flags.testFlag(Archives) && m_core.getArchiveParsing()); + return (m_flags.testFlag(Archives) && m_core.settings().archiveParsing()); } QModelIndex FileTreeModel::index( diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f7ff7b04..70432377 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -486,7 +486,7 @@ MainWindow::MainWindow(Settings &settings ui->profileBox->setCurrentText(m_OrganizerCore.currentProfile()->name()); - if (m_OrganizerCore.getArchiveParsing()) + if (settings.archiveParsing()) { ui->dataTabShowFromArchives->setCheckState(Qt::Checked); ui->dataTabShowFromArchives->setEnabled(true); @@ -2455,6 +2455,7 @@ void MainWindow::on_actionSettings_triggered() QString oldProfilesDirectory(settings.paths().profiles()); QString oldManagedGameDirectory(settings.game().directory().value_or("")); bool oldDisplayForeign(settings.interface().displayForeign()); + bool oldArchiveParsing(settings.archiveParsing()); bool proxy = settings.network().useProxy(); DownloadManager *dlManager = m_OrganizerCore.downloadManager(); const bool oldCheckForUpdates = settings.checkForUpdates(); @@ -2516,9 +2517,8 @@ void MainWindow::on_actionSettings_triggered() } const auto state = settings.archiveParsing(); - if (state != m_OrganizerCore.getArchiveParsing()) + if (state != oldArchiveParsing) { - m_OrganizerCore.setArchiveParsing(state); if (!state) { ui->dataTabShowFromArchives->setCheckState(Qt::Unchecked); diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 90771c0a..3d730c23 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -1500,7 +1500,7 @@ IOrganizer const* OrganizerCore::managedGameOrganizer() const std::vector OrganizerCore::enabledArchives() { std::vector result; - if (m_ArchiveParsing) { + if (settings().archiveParsing()) { QFile archiveFile(m_CurrentProfile->getArchivesFileName()); if (archiveFile.open(QIODevice::ReadOnly)) { while (!archiveFile.atEnd()) { diff --git a/src/organizercore.h b/src/organizercore.h index 905fb111..4ff375b7 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -348,16 +348,6 @@ public: boost::signals2::connection onPluginEnabled(std::function const& func); boost::signals2::connection onPluginDisabled(std::function const& func); - bool getArchiveParsing() const - { - return m_ArchiveParsing; - } - - void setArchiveParsing(bool archiveParsing) - { - m_ArchiveParsing = archiveParsing; - } - public: // IPluginDiagnose interface virtual std::vector activeProblems() const; @@ -505,7 +495,6 @@ private: bool m_DirectoryUpdate; bool m_ArchivesInit; - bool m_ArchiveParsing{ m_Settings.archiveParsing() }; MOBase::DelayedFileWriter m_PluginListsWriter; UsvfsConnector m_USVFS; -- cgit v1.3.1 From 163b33f22817fda6ead29de8f9d9624434766be9 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Wed, 13 Jan 2021 13:00:34 +0100 Subject: Remove unused close() signal from OrganizerCore. Remove declarations without definitions. --- src/mainwindow.cpp | 1 - src/organizercore.h | 14 ++++---------- 2 files changed, 4 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 70432377..c9824a24 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -436,7 +436,6 @@ MainWindow::MainWindow(Settings &settings connect(&m_PluginContainer, &PluginContainer::pluginUnregistered, this, &MainWindow::onPluginRegistrationChanged); connect(&m_OrganizerCore, &OrganizerCore::modInstalled, this, &MainWindow::modInstalled); - connect(&m_OrganizerCore, &OrganizerCore::close, this, &QMainWindow::close); m_CheckBSATimer.setSingleShot(true); connect(&m_CheckBSATimer, SIGNAL(timeout()), this, SLOT(checkBSAList())); diff --git a/src/organizercore.h b/src/organizercore.h index 4ff375b7..e8b42609 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -386,16 +386,14 @@ public slots: signals: - /** - * @brief emitted after a mod has been installed - * @node this is currently only used for tutorials - */ + // emitted after a mod has been installed + // void modInstalled(const QString &modName); + // emitted when the managed game changes + // void managedGameChanged(MOBase::IPluginGame const *gamePlugin); - void close(); - // emitted when the profile is changed, before notifying plugins // // the new profile can be stored but the old one is temporary and @@ -412,13 +410,9 @@ private: void saveCurrentProfile(); void storeSettings(); - bool queryApi(QString &apiKey); - void updateModActiveState(int index, bool active); void updateModsActiveState(const QList &modIndices, bool active); - bool testForSteam(bool *found, bool *access); - bool createDirectory(const QString &path); QString oldMO1HookDll() const; -- cgit v1.3.1 From c93cf33c8324052b321fc0428c394016abcee115 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Wed, 13 Jan 2021 13:00:54 +0100 Subject: Remove OrganizerCore::modsSortedByProfilePriority. --- src/modlist.cpp | 14 +++++++++++++- src/modlistviewactions.cpp | 4 ++-- src/organizercore.cpp | 16 ---------------- src/organizercore.h | 9 --------- 4 files changed, 15 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/modlist.cpp b/src/modlist.cpp index f820e4d1..d4ffbeff 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -900,7 +900,19 @@ QStringList ModList::allModsByProfilePriority(MOBase::IProfile* profile) const { Profile* mo2Profile = profile == nullptr ? m_Organizer->currentProfile() : static_cast(profile); - return m_Organizer->modsSortedByProfilePriority(mo2Profile); + + QStringList res; + for (int i = mo2Profile->getPriorityMinimum(); + i < mo2Profile->getPriorityMinimum() + (int)mo2Profile->numRegularMods(); + ++i) { + int modIndex = mo2Profile->modIndexByPriority(i); + auto modInfo = ModInfo::getByIndex(modIndex); + if (!modInfo->hasFlag(ModInfo::FLAG_OVERWRITE) && + !modInfo->hasFlag(ModInfo::FLAG_BACKUP)) { + res.push_back(ModInfo::getByIndex(modIndex)->internalName()); + } + } + return res; } MOBase::IModInterface* ModList::getMod(const QString& name) const diff --git a/src/modlistviewactions.cpp b/src/modlistviewactions.cpp index cc50f009..63d74192 100644 --- a/src/modlistviewactions.cpp +++ b/src/modlistviewactions.cpp @@ -547,7 +547,7 @@ void ModListViewActions::sendModsToSeparator(const QModelIndexList& index) const int newPriority = std::numeric_limits::max(); bool foundSection = false; - for (auto mod : m_core.modsSortedByProfilePriority(m_core.currentProfile())) { + for (auto mod : m_core.modList()->allModsByProfilePriority()) { unsigned int modIndex = ModInfo::getIndex(mod); ModInfo::Ptr modInfo = ModInfo::getByIndex(modIndex); if (!foundSection && result.compare(mod) == 0) { @@ -1128,7 +1128,7 @@ void ModListViewActions::moveOverwriteContentToExistingMod() const QString modAbsolutePath; - for (const auto& mod : m_core.modsSortedByProfilePriority(m_core.currentProfile())) { + for (const auto& mod : m_core.modList()->allModsByProfilePriority()) { if (result.compare(mod) == 0) { ModInfo::Ptr modInfo = ModInfo::getByIndex(ModInfo::getIndex(mod)); modAbsolutePath = modInfo->absolutePath(); diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 3d730c23..bbf6029b 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -1016,22 +1016,6 @@ ModList *OrganizerCore::modList() return &m_ModList; } -QStringList OrganizerCore::modsSortedByProfilePriority(Profile *profile) const -{ - QStringList res; - for (int i = profile->getPriorityMinimum(); - i < profile->getPriorityMinimum() + (int)profile->numRegularMods(); - ++i) { - int modIndex = profile->modIndexByPriority(i); - auto modInfo = ModInfo::getByIndex(modIndex); - if (!modInfo->hasFlag(ModInfo::FLAG_OVERWRITE) && - !modInfo->hasFlag(ModInfo::FLAG_BACKUP)) { - res.push_back(ModInfo::getByIndex(modIndex)->internalName()); - } - } - return res; -} - bool OrganizerCore::previewFileWithAlternatives( QWidget* parent, QString fileName, int selectedOrigin) { diff --git a/src/organizercore.h b/src/organizercore.h index e8b42609..7ec4dda8 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -300,15 +300,6 @@ public: static void setGlobalCoreDumpType(env::CoreDumpTypes type); static std::wstring getGlobalCoreDumpPath(); - /** - * @brief Returns the name of all the mods in the priority order of the given profile. - * - * @param profile Profile to use for the mod order. - * - * @return the name of all the mods in the priority order of the given profile. - */ - QStringList modsSortedByProfilePriority(Profile* profile) const; - public: MOBase::IModRepositoryBridge *createNexusBridge() const; QString profileName() const; -- cgit v1.3.1 From ce95d8b1bdcfbf6504e0be1588a42bf0f3e78849 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Wed, 13 Jan 2021 13:01:11 +0100 Subject: Minor cleaning for boost signal declarations in OrganizerCore. --- src/organizercore.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/organizercore.h b/src/organizercore.h index 7ec4dda8..8add5542 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -65,7 +65,8 @@ private: struct SignalCombinerAnd { - typedef bool result_type; + using result_type = bool; + template bool operator()(InputIterator first, InputIterator last) const { @@ -81,14 +82,14 @@ private: private: - using SignalAboutToRunApplication = boost::signals2::signal; - using SignalFinishedRunApplication = boost::signals2::signal; - using SignalUserInterfaceInitialized = boost::signals2::signal; + using SignalAboutToRunApplication = boost::signals2::signal; + using SignalFinishedRunApplication = boost::signals2::signal; + using SignalUserInterfaceInitialized = boost::signals2::signal; using SignalProfileCreated = boost::signals2::signal; using SignalProfileRenamed = boost::signals2::signal; using SignalProfileRemoved = boost::signals2::signal; - using SignalProfileChanged = boost::signals2::signal; - using SignalPluginSettingChanged = boost::signals2::signal; + using SignalProfileChanged = boost::signals2::signal; + using SignalPluginSettingChanged = boost::signals2::signal; using SignalPluginEnabled = boost::signals2::signal; public: -- cgit v1.3.1 From 853db4a60a0a701b92d3eb7be7c3a0d8d8f6f2b1 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Wed, 13 Jan 2021 13:27:36 +0100 Subject: Use isBackup() and isOverwrite() instead of testing flags. --- src/modlist.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/modlist.cpp b/src/modlist.cpp index d4ffbeff..1c097db4 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -907,9 +907,8 @@ QStringList ModList::allModsByProfilePriority(MOBase::IProfile* profile) const ++i) { int modIndex = mo2Profile->modIndexByPriority(i); auto modInfo = ModInfo::getByIndex(modIndex); - if (!modInfo->hasFlag(ModInfo::FLAG_OVERWRITE) && - !modInfo->hasFlag(ModInfo::FLAG_BACKUP)) { - res.push_back(ModInfo::getByIndex(modIndex)->internalName()); + if (!modInfo->isBackup() && !modInfo->isOverwrite()) { + res.push_back(modInfo->internalName()); } } return res; -- cgit v1.3.1