diff options
| author | Mikaƫl Capelle <capelle.mikael@gmail.com> | 2021-01-14 09:11:52 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-14 09:11:52 +0100 |
| commit | 899308b31d541e78a3e4395bf33cd66c5ec4f769 (patch) | |
| tree | e360f819bbe96e7cc30626a53395c466967e8e0f /src | |
| parent | 34f7ae24501f75d5a74a09b6af939db6edaf6f1c (diff) | |
| parent | 853db4a60a0a701b92d3eb7be7c3a0d8d8f6f2b1 (diff) | |
Merge pull request #1360 from Holt59/organizercore-cleaning
OrganizerCore cleaning.
Diffstat (limited to 'src')
| -rw-r--r-- | src/filetreemodel.cpp | 2 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 7 | ||||
| -rw-r--r-- | src/modlist.cpp | 13 | ||||
| -rw-r--r-- | src/modlistviewactions.cpp | 4 | ||||
| -rw-r--r-- | src/organizercore.cpp | 18 | ||||
| -rw-r--r-- | src/organizercore.h | 47 |
6 files changed, 30 insertions, 61 deletions
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..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())); @@ -486,7 +485,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 +2454,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 +2516,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/modlist.cpp b/src/modlist.cpp index f820e4d1..1c097db4 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -900,7 +900,18 @@ QStringList ModList::allModsByProfilePriority(MOBase::IProfile* profile) const { Profile* mo2Profile = profile == nullptr ? m_Organizer->currentProfile() : static_cast<Profile*>(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->isBackup() && !modInfo->isOverwrite()) { + res.push_back(modInfo->internalName()); + } + } + return res; } MOBase::IModInterface* ModList::getMod(const QString& name) const diff --git a/src/modlistviewactions.cpp b/src/modlistviewactions.cpp index 09142026..ed26faa8 100644 --- a/src/modlistviewactions.cpp +++ b/src/modlistviewactions.cpp @@ -558,7 +558,7 @@ void ModListViewActions::sendModsToSeparator(const QModelIndexList& index) const int newPriority = std::numeric_limits<int>::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) { @@ -1139,7 +1139,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 90771c0a..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) { @@ -1500,7 +1484,7 @@ IOrganizer const* OrganizerCore::managedGameOrganizer() const std::vector<QString> OrganizerCore::enabledArchives() { std::vector<QString> 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..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<typename InputIterator>
bool operator()(InputIterator first, InputIterator last) const
{
@@ -81,14 +82,14 @@ private: private:
- using SignalAboutToRunApplication = boost::signals2::signal<bool (const QString&), SignalCombinerAnd>;
- using SignalFinishedRunApplication = boost::signals2::signal<void (const QString&, unsigned int)>;
- using SignalUserInterfaceInitialized = boost::signals2::signal<void (QMainWindow*)>;
+ using SignalAboutToRunApplication = boost::signals2::signal<bool(const QString&), SignalCombinerAnd>;
+ using SignalFinishedRunApplication = boost::signals2::signal<void(const QString&, unsigned int)>;
+ using SignalUserInterfaceInitialized = boost::signals2::signal<void(QMainWindow*)>;
using SignalProfileCreated = boost::signals2::signal<void(MOBase::IProfile*)>;
using SignalProfileRenamed = boost::signals2::signal<void(MOBase::IProfile*, QString const&, QString const&)>;
using SignalProfileRemoved = boost::signals2::signal<void(QString const&)>;
- using SignalProfileChanged = boost::signals2::signal<void (MOBase::IProfile *, MOBase::IProfile *)>;
- using SignalPluginSettingChanged = boost::signals2::signal<void (QString const&, const QString& key, const QVariant&, const QVariant&)>;
+ using SignalProfileChanged = boost::signals2::signal<void(MOBase::IProfile *, MOBase::IProfile *)>;
+ using SignalPluginSettingChanged = boost::signals2::signal<void(QString const&, const QString& key, const QVariant&, const QVariant&)>;
using SignalPluginEnabled = boost::signals2::signal<void(const MOBase::IPlugin*)>;
public:
@@ -300,15 +301,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;
@@ -348,16 +340,6 @@ public: boost::signals2::connection onPluginEnabled(std::function<void(const MOBase::IPlugin*)> const& func);
boost::signals2::connection onPluginDisabled(std::function<void(const MOBase::IPlugin*)> const& func);
- bool getArchiveParsing() const
- {
- return m_ArchiveParsing;
- }
-
- void setArchiveParsing(bool archiveParsing)
- {
- m_ArchiveParsing = archiveParsing;
- }
-
public: // IPluginDiagnose interface
virtual std::vector<unsigned int> activeProblems() const;
@@ -396,16 +378,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
@@ -422,13 +402,9 @@ private: void saveCurrentProfile();
void storeSettings();
- bool queryApi(QString &apiKey);
-
void updateModActiveState(int index, bool active);
void updateModsActiveState(const QList<unsigned int> &modIndices, bool active);
- bool testForSteam(bool *found, bool *access);
-
bool createDirectory(const QString &path);
QString oldMO1HookDll() const;
@@ -505,7 +481,6 @@ private: bool m_DirectoryUpdate;
bool m_ArchivesInit;
- bool m_ArchiveParsing{ m_Settings.archiveParsing() };
MOBase::DelayedFileWriter m_PluginListsWriter;
UsvfsConnector m_USVFS;
|
