Merge branch 'case-insensitive-bsa-name' into 'master'

Make the launcher ignore case in bsa names

Closes #8201

See merge request OpenMW/openmw!4418
pull/3236/head
psi29a 2 months ago
commit cd2f261ff5

@ -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"
@ -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();
@ -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))
{
@ -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);
}
}

@ -554,6 +554,10 @@ if (USE_QT)
application
)
add_component_qt_dir (vfs
qtconversion
)
QT_WRAP_UI(ESM_UI_HDR ${ESM_UI})
endif()

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

@ -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
Loading…
Cancel
Save