From 57178f898838afed6e7a50413899d6082aad9989 Mon Sep 17 00:00:00 2001 From: Project579 Date: Mon, 20 Aug 2018 12:55:02 -0500 Subject: Added button to disable Archives in Data Tree and entirely. --- src/mainwindow.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++++++-- src/mainwindow.h | 3 +++ src/mainwindow.ui | 46 ++++++++++++++++++++++++++++++------------ src/organizercore.cpp | 24 ++++++++++++++++------ src/organizercore.h | 3 +++ src/settings.cpp | 10 ++++++++- src/settings.h | 6 ++++++ src/settingsdialog.ui | 21 +++++++++++++++++++ 8 files changed, 147 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d7ae18fb..0d3abce5 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -448,6 +448,19 @@ MainWindow::MainWindow(QSettings &initSettings ui->profileBox->setCurrentText(m_OrganizerCore.currentProfile()->name()); + if (m_OrganizerCore.getArchiveParsing()) + { + ui->showArchiveDataCheckBox->setCheckState(Qt::Checked); + ui->showArchiveDataCheckBox->setEnabled(true); + m_showArchiveData = true; + } + else + { + ui->showArchiveDataCheckBox->setCheckState(Qt::Unchecked); + ui->showArchiveDataCheckBox->setEnabled(false); + m_showArchiveData = false; + } + refreshExecutablesList(); updateToolBar(); @@ -1250,11 +1263,15 @@ void MainWindow::updateTo(QTreeWidgetItem *subTree, const std::wstring &director if (conflictsOnly && (current->getAlternatives().size() == 0)) { continue; } + + bool isArchive = false; + int originID = current->getOrigin(isArchive); + if (!m_showArchiveData && isArchive) { + continue; + } QString fileName = ToQString(current->getName()); QStringList columns(fileName); - bool isArchive = false; - int originID = current->getOrigin(isArchive); FilesOrigin origin = m_OrganizerCore.directoryStructure()->getOriginByID(originID); QString source("data"); unsigned int modIndex = ModInfo::getIndex(ToQString(origin.getName())); @@ -4351,6 +4368,27 @@ void MainWindow::on_actionSettings_triggered() m_OrganizerCore.profileRefresh(); } + const auto state = settings.archiveParsing(); + if (state != m_OrganizerCore.getArchiveParsing()) + { + m_OrganizerCore.setArchiveParsing(state); + if (!state) + { + ui->showArchiveDataCheckBox->setCheckState(Qt::Unchecked); + ui->showArchiveDataCheckBox->setEnabled(false); + m_showArchiveData = false; + } + else + { + ui->showArchiveDataCheckBox->setCheckState(Qt::Checked); + ui->showArchiveDataCheckBox->setEnabled(true); + m_showArchiveData = true; + } + m_OrganizerCore.refreshModList(); + m_OrganizerCore.refreshDirectoryStructure(); + m_OrganizerCore.refreshLists(); + } + if (settings.getCacheDirectory() != oldCacheDirectory) { NexusInterface::instance(&m_PluginContainer)->setCacheDirectory(settings.getCacheDirectory()); } @@ -5985,3 +6023,17 @@ void MainWindow::sendSelectedModsToSeparator_clicked() } settings.setValue(key, dialog.saveGeometry()); } + +void MainWindow::on_showArchiveDataCheckBox_toggled(const bool checked) +{ + if (m_OrganizerCore.getArchiveParsing() && checked) + { + m_showArchiveData = checked; + } + else + { + m_showArchiveData = false; + } + refreshDataTree(); +} + diff --git a/src/mainwindow.h b/src/mainwindow.h index 69d08337..ad88c42c 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -373,6 +373,8 @@ private: bool m_closing{ false }; + bool m_showArchiveData{ true }; + std::vector> m_PersistedGeometry; MOBase::DelayedFileWriter m_ArchiveListWriter; @@ -600,6 +602,7 @@ private slots: // ui slots void on_btnRefreshDownloads_clicked(); void on_categoriesList_customContextMenuRequested(const QPoint &pos); void on_conflictsCheckBox_toggled(bool checked); + void on_showArchiveDataCheckBox_toggled(bool checked); void on_dataTree_customContextMenuRequested(const QPoint &pos); void on_executablesListBox_currentIndexChanged(int index); void on_modList_customContextMenuRequested(const QPoint &pos); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 41365768..fba246f5 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1152,19 +1152,39 @@ p, li { white-space: pre-wrap; } - - - - Filter the above list so that only conflicts are displayed. - - - Filter the above list so that only conflicts are displayed. - - - Show only conflicts - - - + + + + + + Filters the above list so that only conflicts are displayed. + + + Filters the above list so that only conflicts are displayed. + + + Show only conflicts + + + + + + + Filters the above list so that files from archives are not shown + + + + + + Filters the above list so that files from archives are not shown + + + Show files from Archives + + + + + diff --git a/src/organizercore.cpp b/src/organizercore.cpp index f19f56c3..d21fa844 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -786,6 +786,16 @@ std::wstring OrganizerCore::crashDumpsPath() { ).toStdWString(); } +bool OrganizerCore::getArchiveParsing() const +{ + return m_ArchiveParsing; +} + +void OrganizerCore::setArchiveParsing(const bool archiveParsing) +{ + m_ArchiveParsing = archiveParsing; +} + void OrganizerCore::setCurrentProfile(const QString &profileName) { if ((m_CurrentProfile != nullptr) @@ -1925,12 +1935,14 @@ IPluginGame const *OrganizerCore::managedGame() const std::vector OrganizerCore::enabledArchives() { std::vector result; - QFile archiveFile(m_CurrentProfile->getArchivesFileName()); - if (archiveFile.open(QIODevice::ReadOnly)) { - while (!archiveFile.atEnd()) { - result.push_back(QString::fromUtf8(archiveFile.readLine()).trimmed()); - } - archiveFile.close(); + if (m_ArchiveParsing) { + QFile archiveFile(m_CurrentProfile->getArchivesFileName()); + if (archiveFile.open(QIODevice::ReadOnly)) { + while (!archiveFile.atEnd()) { + result.push_back(QString::fromUtf8(archiveFile.readLine()).trimmed()); + } + archiveFile.close(); + } } return result; } diff --git a/src/organizercore.h b/src/organizercore.h index 086fa11d..d0964ed5 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -211,6 +211,8 @@ public: bool onFinishedRun(const std::function &func); void refreshModList(bool saveChanges = true); QStringList modsSortedByProfilePriority() const; + bool getArchiveParsing() const; + void setArchiveParsing(bool archiveParsing); public: // IPluginDiagnose interface @@ -335,6 +337,7 @@ private: bool m_AskForNexusPW; bool m_DirectoryUpdate; bool m_ArchivesInit; + bool m_ArchiveParsing{ m_Settings.archiveParsing() }; MOBase::DelayedFileWriter m_PluginListsWriter; UsvfsConnector m_USVFS; diff --git a/src/settings.cpp b/src/settings.cpp index 18e893cb..eb5b372f 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -474,6 +474,11 @@ uint Settings::getMotDHash() const return m_Settings.value("motd_hash", 0).toUInt(); } +bool Settings::archiveParsing() const +{ + return m_Settings.value("Settings/archive_parsing", true).toBool(); +} + QVariant Settings::pluginSetting(const QString &pluginName, const QString &key) const { auto iterPlugin = m_PluginSettings.find(pluginName); @@ -1085,6 +1090,7 @@ Settings::WorkaroundsTab::WorkaroundsTab(Settings *m_parent, , m_forceEnableBox(m_dialog.findChild("forceEnableBox")) , m_displayForeignBox(m_dialog.findChild("displayForeignBox")) , m_lockGUIBox(m_dialog.findChild("lockGUIBox")) + , m_enableArchiveParsingBox(m_dialog.findChild("enableArchiveParsingBox")) { m_appIDEdit->setText(m_parent->getSteamAppID()); @@ -1119,7 +1125,8 @@ Settings::WorkaroundsTab::WorkaroundsTab(Settings *m_parent, m_forceEnableBox->setChecked(m_parent->forceEnableCoreFiles()); m_displayForeignBox->setChecked(m_parent->displayForeign()); m_lockGUIBox->setChecked(m_parent->lockGUI()); - + m_enableArchiveParsingBox->setChecked(m_parent->archiveParsing()); + m_dialog.setExecutableBlacklist(m_parent->executablesBlacklist()); } @@ -1137,6 +1144,7 @@ void Settings::WorkaroundsTab::update() m_Settings.setValue("Settings/force_enable_core_files", m_forceEnableBox->isChecked()); m_Settings.setValue("Settings/display_foreign", m_displayForeignBox->isChecked()); m_Settings.setValue("Settings/lock_gui", m_lockGUIBox->isChecked()); + m_Settings.setValue("Settings/archive_parsing", m_enableArchiveParsingBox->isChecked()); m_Settings.setValue("Settings/executable_blacklist", m_dialog.getExecutableBlacklist()); diff --git a/src/settings.h b/src/settings.h index 912864e2..3694bfad 100644 --- a/src/settings.h +++ b/src/settings.h @@ -280,6 +280,11 @@ public: **/ void setMotDHash(uint hash); + /** + * @return true if the user wants to have archives being parsed to show conflicts and contents + */ + bool archiveParsing() const; + /** * @return hash of the last displayed message of the day **/ @@ -514,6 +519,7 @@ private: QCheckBox *m_forceEnableBox; QCheckBox *m_displayForeignBox; QCheckBox *m_lockGUIBox; + QCheckBox *m_enableArchiveParsingBox; }; private slots: diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui index 0412fc10..51f35683 100644 --- a/src/settingsdialog.ui +++ b/src/settingsdialog.ui @@ -1100,6 +1100,27 @@ programs you are intentionally running. + + + + Enable parsing of Archives Archives, has effects on perfromance. + + + + By default Mod Organizer will parse Archive files to calculate conflicts between themselves and loose files, this process has a noticeable cost in performance. + This feature should not be confused from the one offered by ModOrganizer 1, ModOrganizer 2 will only show conflicts with archives NOT load them into the game or program. + + If you disable this feature, MO will only display conflicts with Loose files. + + + + Enable parsing of Archives + + + true + + + -- cgit v1.3.1