Skip to content

Commit

Permalink
Merge branch 'case-insensitive-bsa-name' into 'master'
Browse files Browse the repository at this point in the history
Make the launcher ignore case in bsa names

Closes #8201

See merge request OpenMW/openmw!4418
  • Loading branch information
psi29a committed Oct 23, 2024
2 parents 69fa1ee + 7556ab6 commit cd2f261
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 4 deletions.
9 changes: 5 additions & 4 deletions apps/launcher/datafilespage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <components/navmeshtool/protocol.hpp>
#include <components/settings/values.hpp>
#include <components/vfs/bsaarchive.hpp>
#include <components/vfs/qtconversion.hpp>

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

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

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

const auto fileName = fileinfo.fileName();

if (archives.insert(fileName).second)
if (archives.insert(VFS::Path::normalizedFromQString(fileName)).second)
addArchive(fileName, Qt::Unchecked);
}
}
Expand Down
4 changes: 4 additions & 0 deletions components/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,10 @@ if (USE_QT)
application
)

add_component_qt_dir (vfs
qtconversion
)

QT_WRAP_UI(ESM_UI_HDR ${ESM_UI})
endif()

Expand Down
26 changes: 26 additions & 0 deletions components/vfs/qtconversion.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

#include "qtconversion.hpp"

#include <components/misc/strings/conversion.hpp>

QString VFS::Path::normalizedToQString(NormalizedView path)
{
return QString::fromUtf8(path.value().data(), path.value().size());
}

QString VFS::Path::normalizedToQString(Normalized&& path)
{
return QString::fromUtf8(path.value().data(), path.value().size());
}

VFS::Path::Normalized VFS::Path::normalizedFromQString(QStringView path)
{
const auto tmp = path.toUtf8();
return Normalized{ tmp };
}

VFS::Path::Normalized VFS::Path::normalizedFromQString(QString&& path)
{
const auto tmp = path.toUtf8();
return Normalized{ tmp };
}
19 changes: 19 additions & 0 deletions components/vfs/qtconversion.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef COMPONENTS_VFS_QTCONVERSION_HPP
#define COMPONENTS_VFS_QTCONVERSION_HPP

#include <QString>

#include "pathutil.hpp"

namespace VFS::Path
{
QString normalizedToQString(NormalizedView path);

QString normalizedToQString(Normalized&& path);

Normalized normalizedFromQString(QStringView path);

Normalized normalizedFromQString(QString&& path);
}

#endif // COMPONENTS_VFS_QTCONVERSION_HPP

0 comments on commit cd2f261

Please sign in to comment.