Use single set to check presence of archives

depth-refraction
elsid 2 years ago
parent b1765cf05a
commit 5a691380ea
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -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<QString> 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);
}
}

@ -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

Loading…
Cancel
Save