From 5a691380eaf5a2c7aab270b01f37d3ee9fc992d8 Mon Sep 17 00:00:00 2001 From: elsid Date: Mon, 20 Mar 2023 23:24:29 +0100 Subject: [PATCH] Use single set to check presence of archives --- apps/launcher/datafilespage.cpp | 13 ++++++++----- apps/launcher/datafilespage.hpp | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 2bfcabb570..8d956e3f24 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -384,13 +384,13 @@ QStringList Launcher::DataFilesPage::selectedDirectoriesPaths() const return dirList; } -QStringList Launcher::DataFilesPage::selectedArchivePaths(bool all) const +QStringList Launcher::DataFilesPage::selectedArchivePaths() const { QStringList archiveList; for (int i = 0; i < ui.archiveListWidget->count(); ++i) { - const auto* item = ui.archiveListWidget->item(i); - if (all || item->checkState() == Qt::Checked) + const QListWidgetItem* item = ui.archiveListWidget->item(i); + if (item->checkState() == Qt::Checked) archiveList.append(item->text()); } return archiveList; @@ -720,6 +720,10 @@ void Launcher::DataFilesPage::addArchivesFromDir(const QString& path) { QDir dir(path, "*.bsa"); + std::unordered_set archives; + for (int i = 0; i < ui.archiveListWidget->count(); ++i) + archives.insert(ui.archiveListWidget->item(i)->text()); + for (const auto& fileinfo : dir.entryInfoList()) { const auto absPath = fileinfo.absoluteFilePath(); @@ -727,9 +731,8 @@ void Launcher::DataFilesPage::addArchivesFromDir(const QString& path) continue; const auto fileName = fileinfo.fileName(); - const auto currentList = selectedArchivePaths(true); - if (!currentList.contains(fileName, Qt::CaseInsensitive)) + if (archives.insert(fileName).second) addArchive(fileName, Qt::Unchecked); } } diff --git a/apps/launcher/datafilespage.hpp b/apps/launcher/datafilespage.hpp index 60082595c9..930e1392aa 100644 --- a/apps/launcher/datafilespage.hpp +++ b/apps/launcher/datafilespage.hpp @@ -138,7 +138,7 @@ namespace Launcher * @return the file paths of all selected content files */ QStringList selectedFilePaths() const; - QStringList selectedArchivePaths(bool all = false) const; + QStringList selectedArchivePaths() const; QStringList selectedDirectoriesPaths() const; class PathIterator