mirror of
https://github.com/OpenMW/openmw.git
synced 2025-12-16 05:43:08 +00:00
Explicitely sort by file name after adding all data dirs
This commit is contained in:
parent
ad44142dda
commit
a3e039d862
8 changed files with 25 additions and 16 deletions
|
|
@ -121,6 +121,7 @@ void Launcher::DataFilesPage::populateFileViews(const QString& contentModelName)
|
||||||
|
|
||||||
for (const QString &path : paths)
|
for (const QString &path : paths)
|
||||||
mSelector->addFiles(path);
|
mSelector->addFiles(path);
|
||||||
|
mSelector->sortFiles();
|
||||||
|
|
||||||
PathIterator pathIterator(paths);
|
PathIterator pathIterator(paths);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -149,11 +149,7 @@ std::pair<Files::PathContainer, std::vector<std::string> > CS::Editor::readConfi
|
||||||
dataDirs.insert (dataDirs.end(), dataLocal.begin(), dataLocal.end());
|
dataDirs.insert (dataDirs.end(), dataLocal.begin(), dataLocal.end());
|
||||||
|
|
||||||
//iterate the data directories and add them to the file dialog for loading
|
//iterate the data directories and add them to the file dialog for loading
|
||||||
for (Files::PathContainer::const_reverse_iterator iter = dataDirs.rbegin(); iter != dataDirs.rend(); ++iter)
|
mFileDialog.addFiles(dataDirs);
|
||||||
{
|
|
||||||
QString path = QString::fromUtf8 (iter->string().c_str());
|
|
||||||
mFileDialog.addFiles(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
return std::make_pair (dataDirs, variables["fallback-archive"].as<Files::EscapeStringVector>().toStdStringVector());
|
return std::make_pair (dataDirs, variables["fallback-archive"].as<Files::EscapeStringVector>().toStdStringVector());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,14 @@ CSVDoc::FileDialog::FileDialog(QWidget *parent) :
|
||||||
mAdjusterWidget = new AdjusterWidget (this);
|
mAdjusterWidget = new AdjusterWidget (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::FileDialog::addFiles(const QString &path)
|
void CSVDoc::FileDialog::addFiles(const std::vector<boost::filesystem::path>& dataDirs)
|
||||||
{
|
{
|
||||||
mSelector->addFiles(path);
|
for (auto iter = dataDirs.rbegin(); iter != dataDirs.rend(); ++iter)
|
||||||
|
{
|
||||||
|
QString path = QString::fromUtf8(iter->string().c_str());
|
||||||
|
mSelector->addFiles(path);
|
||||||
|
}
|
||||||
|
mSelector->sortFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::FileDialog::setEncoding(const QString &encoding)
|
void CSVDoc::FileDialog::setEncoding(const QString &encoding)
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ namespace CSVDoc
|
||||||
explicit FileDialog(QWidget *parent = nullptr);
|
explicit FileDialog(QWidget *parent = nullptr);
|
||||||
void showDialog (ContentAction action);
|
void showDialog (ContentAction action);
|
||||||
|
|
||||||
void addFiles (const QString &path);
|
void addFiles(const std::vector<boost::filesystem::path>& dataDirs);
|
||||||
void setEncoding (const QString &encoding);
|
void setEncoding (const QString &encoding);
|
||||||
void clearFiles ();
|
void clearFiles ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "contentmodel.hpp"
|
#include "contentmodel.hpp"
|
||||||
#include "esmfile.hpp"
|
#include "esmfile.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
@ -474,8 +475,6 @@ void ContentSelectorModel::ContentModel::addFiles(const QString &path)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sortFiles();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorModel::ContentModel::clearFiles()
|
void ContentSelectorModel::ContentModel::clearFiles()
|
||||||
|
|
@ -504,8 +503,13 @@ QStringList ContentSelectorModel::ContentModel::gameFiles() const
|
||||||
|
|
||||||
void ContentSelectorModel::ContentModel::sortFiles()
|
void ContentSelectorModel::ContentModel::sortFiles()
|
||||||
{
|
{
|
||||||
|
emit layoutAboutToBeChanged();
|
||||||
|
std::sort(mFiles.begin(), mFiles.end(), [](const EsmFile* a, const EsmFile* b)
|
||||||
|
{
|
||||||
|
return a->fileName().compare(b->fileName(), Qt::CaseInsensitive) > 0;
|
||||||
|
});
|
||||||
//Dependency sort
|
//Dependency sort
|
||||||
int sorted = 0;
|
int sorted = 1;
|
||||||
//iterate each file, obtaining a reference to its gamefiles list
|
//iterate each file, obtaining a reference to its gamefiles list
|
||||||
for(int i = sorted; i < mFiles.size(); ++i)
|
for(int i = sorted; i < mFiles.size(); ++i)
|
||||||
{
|
{
|
||||||
|
|
@ -520,12 +524,10 @@ void ContentSelectorModel::ContentModel::sortFiles()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(i != j)
|
if(i != j)
|
||||||
{
|
|
||||||
mFiles.move(i, j);
|
mFiles.move(i, j);
|
||||||
emit dataChanged(index(i, 0, QModelIndex()), index(j, 0, QModelIndex()));
|
|
||||||
}
|
|
||||||
++sorted;
|
++sorted;
|
||||||
}
|
}
|
||||||
|
emit layoutChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContentSelectorModel::ContentModel::isChecked(const QString& filepath) const
|
bool ContentSelectorModel::ContentModel::isChecked(const QString& filepath) const
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ namespace ContentSelectorModel
|
||||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
|
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
|
||||||
|
|
||||||
void addFiles(const QString &path);
|
void addFiles(const QString &path);
|
||||||
|
void sortFiles();
|
||||||
void clearFiles();
|
void clearFiles();
|
||||||
|
|
||||||
QModelIndex indexFromItem(const EsmFile *item) const;
|
QModelIndex indexFromItem(const EsmFile *item) const;
|
||||||
|
|
@ -68,8 +69,6 @@ namespace ContentSelectorModel
|
||||||
|
|
||||||
void addFile(EsmFile *file);
|
void addFile(EsmFile *file);
|
||||||
|
|
||||||
void sortFiles();
|
|
||||||
|
|
||||||
/// Checks a specific plug-in for load order errors
|
/// Checks a specific plug-in for load order errors
|
||||||
/// \return all errors found for specific plug-in
|
/// \return all errors found for specific plug-in
|
||||||
QList<LoadOrderError> checkForLoadOrderErrors(const EsmFile *file, int row) const;
|
QList<LoadOrderError> checkForLoadOrderErrors(const EsmFile *file, int row) const;
|
||||||
|
|
|
||||||
|
|
@ -173,6 +173,11 @@ void ContentSelectorView::ContentSelector::addFiles(const QString &path)
|
||||||
mContentModel->checkForLoadOrderErrors();
|
mContentModel->checkForLoadOrderErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContentSelectorView::ContentSelector::sortFiles()
|
||||||
|
{
|
||||||
|
mContentModel->sortFiles();
|
||||||
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::clearFiles()
|
void ContentSelectorView::ContentSelector::clearFiles()
|
||||||
{
|
{
|
||||||
mContentModel->clearFiles();
|
mContentModel->clearFiles();
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ namespace ContentSelectorView
|
||||||
QString currentFile() const;
|
QString currentFile() const;
|
||||||
|
|
||||||
void addFiles(const QString &path);
|
void addFiles(const QString &path);
|
||||||
|
void sortFiles();
|
||||||
void clearFiles();
|
void clearFiles();
|
||||||
void setProfileContent (const QStringList &fileList);
|
void setProfileContent (const QStringList &fileList);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue