Skip to content

Commit cd2f261

Browse files
committed
Merge branch 'case-insensitive-bsa-name' into 'master'
Make the launcher ignore case in bsa names Closes #8201 See merge request OpenMW/openmw!4418
2 parents 69fa1ee + 7556ab6 commit cd2f261

File tree

4 files changed

+54
-4
lines changed

4 files changed

+54
-4
lines changed

apps/launcher/datafilespage.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <components/navmeshtool/protocol.hpp>
3131
#include <components/settings/values.hpp>
3232
#include <components/vfs/bsaarchive.hpp>
33+
#include <components/vfs/qtconversion.hpp>
3334

3435
#include "utils/profilescombobox.hpp"
3536
#include "utils/textinputdialog.hpp"
@@ -393,7 +394,7 @@ void Launcher::DataFilesPage::populateFileViews(const QString& contentModelName)
393394
int row = 0;
394395
for (const auto& archive : selectedArchives)
395396
{
396-
const auto match = ui.archiveListWidget->findItems(archive.value, Qt::MatchExactly);
397+
const auto match = ui.archiveListWidget->findItems(archive.value, Qt::MatchFixedString);
397398
if (match.isEmpty())
398399
continue;
399400
const auto name = match[0]->text();
@@ -889,9 +890,9 @@ void Launcher::DataFilesPage::addArchivesFromDir(const QString& path)
889890
QStringList archiveFilter{ "*.bsa", "*.ba2" };
890891
QDir dir(path);
891892

892-
std::unordered_set<QString> archives;
893+
std::unordered_set<VFS::Path::Normalized, VFS::Path::Hash> archives;
893894
for (int i = 0; i < ui.archiveListWidget->count(); ++i)
894-
archives.insert(ui.archiveListWidget->item(i)->text());
895+
archives.insert(VFS::Path::normalizedFromQString(ui.archiveListWidget->item(i)->text()));
895896

896897
for (const auto& fileinfo : dir.entryInfoList(archiveFilter))
897898
{
@@ -901,7 +902,7 @@ void Launcher::DataFilesPage::addArchivesFromDir(const QString& path)
901902

902903
const auto fileName = fileinfo.fileName();
903904

904-
if (archives.insert(fileName).second)
905+
if (archives.insert(VFS::Path::normalizedFromQString(fileName)).second)
905906
addArchive(fileName, Qt::Unchecked);
906907
}
907908
}

components/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,10 @@ if (USE_QT)
554554
application
555555
)
556556

557+
add_component_qt_dir (vfs
558+
qtconversion
559+
)
560+
557561
QT_WRAP_UI(ESM_UI_HDR ${ESM_UI})
558562
endif()
559563

components/vfs/qtconversion.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
#include "qtconversion.hpp"
3+
4+
#include <components/misc/strings/conversion.hpp>
5+
6+
QString VFS::Path::normalizedToQString(NormalizedView path)
7+
{
8+
return QString::fromUtf8(path.value().data(), path.value().size());
9+
}
10+
11+
QString VFS::Path::normalizedToQString(Normalized&& path)
12+
{
13+
return QString::fromUtf8(path.value().data(), path.value().size());
14+
}
15+
16+
VFS::Path::Normalized VFS::Path::normalizedFromQString(QStringView path)
17+
{
18+
const auto tmp = path.toUtf8();
19+
return Normalized{ tmp };
20+
}
21+
22+
VFS::Path::Normalized VFS::Path::normalizedFromQString(QString&& path)
23+
{
24+
const auto tmp = path.toUtf8();
25+
return Normalized{ tmp };
26+
}

components/vfs/qtconversion.hpp

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#ifndef COMPONENTS_VFS_QTCONVERSION_HPP
2+
#define COMPONENTS_VFS_QTCONVERSION_HPP
3+
4+
#include <QString>
5+
6+
#include "pathutil.hpp"
7+
8+
namespace VFS::Path
9+
{
10+
QString normalizedToQString(NormalizedView path);
11+
12+
QString normalizedToQString(Normalized&& path);
13+
14+
Normalized normalizedFromQString(QStringView path);
15+
16+
Normalized normalizedFromQString(QString&& path);
17+
}
18+
19+
#endif // COMPONENTS_VFS_QTCONVERSION_HPP

0 commit comments

Comments
 (0)