mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-26 10:41:33 +00:00
Use single set to check presence of archives
This commit is contained in:
parent
b1765cf05a
commit
5a691380ea
2 changed files with 9 additions and 6 deletions
|
@ -384,13 +384,13 @@ QStringList Launcher::DataFilesPage::selectedDirectoriesPaths() const
|
||||||
return dirList;
|
return dirList;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Launcher::DataFilesPage::selectedArchivePaths(bool all) const
|
QStringList Launcher::DataFilesPage::selectedArchivePaths() const
|
||||||
{
|
{
|
||||||
QStringList archiveList;
|
QStringList archiveList;
|
||||||
for (int i = 0; i < ui.archiveListWidget->count(); ++i)
|
for (int i = 0; i < ui.archiveListWidget->count(); ++i)
|
||||||
{
|
{
|
||||||
const auto* item = ui.archiveListWidget->item(i);
|
const QListWidgetItem* item = ui.archiveListWidget->item(i);
|
||||||
if (all || item->checkState() == Qt::Checked)
|
if (item->checkState() == Qt::Checked)
|
||||||
archiveList.append(item->text());
|
archiveList.append(item->text());
|
||||||
}
|
}
|
||||||
return archiveList;
|
return archiveList;
|
||||||
|
@ -720,6 +720,10 @@ void Launcher::DataFilesPage::addArchivesFromDir(const QString& path)
|
||||||
{
|
{
|
||||||
QDir dir(path, "*.bsa");
|
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())
|
for (const auto& fileinfo : dir.entryInfoList())
|
||||||
{
|
{
|
||||||
const auto absPath = fileinfo.absoluteFilePath();
|
const auto absPath = fileinfo.absoluteFilePath();
|
||||||
|
@ -727,9 +731,8 @@ void Launcher::DataFilesPage::addArchivesFromDir(const QString& path)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const auto fileName = fileinfo.fileName();
|
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);
|
addArchive(fileName, Qt::Unchecked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ namespace Launcher
|
||||||
* @return the file paths of all selected content files
|
* @return the file paths of all selected content files
|
||||||
*/
|
*/
|
||||||
QStringList selectedFilePaths() const;
|
QStringList selectedFilePaths() const;
|
||||||
QStringList selectedArchivePaths(bool all = false) const;
|
QStringList selectedArchivePaths() const;
|
||||||
QStringList selectedDirectoriesPaths() const;
|
QStringList selectedDirectoriesPaths() const;
|
||||||
|
|
||||||
class PathIterator
|
class PathIterator
|
||||||
|
|
Loading…
Reference in a new issue