Explicitely sort by file name after adding all data dirs

pull/3224/head
Evil Eye 3 years ago
parent ad44142dda
commit a3e039d862

@ -121,6 +121,7 @@ void Launcher::DataFilesPage::populateFileViews(const QString& contentModelName)
for (const QString &path : paths)
mSelector->addFiles(path);
mSelector->sortFiles();
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());
//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)
{
QString path = QString::fromUtf8 (iter->string().c_str());
mFileDialog.addFiles(path);
}
mFileDialog.addFiles(dataDirs);
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);
}
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)

@ -45,7 +45,7 @@ namespace CSVDoc
explicit FileDialog(QWidget *parent = nullptr);
void showDialog (ContentAction action);
void addFiles (const QString &path);
void addFiles(const std::vector<boost::filesystem::path>& dataDirs);
void setEncoding (const QString &encoding);
void clearFiles ();

@ -1,6 +1,7 @@
#include "contentmodel.hpp"
#include "esmfile.hpp"
#include <algorithm>
#include <stdexcept>
#include <QDir>
@ -474,8 +475,6 @@ void ContentSelectorModel::ContentModel::addFiles(const QString &path)
}
}
sortFiles();
}
void ContentSelectorModel::ContentModel::clearFiles()
@ -504,8 +503,13 @@ QStringList ContentSelectorModel::ContentModel::gameFiles() const
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
int sorted = 0;
int sorted = 1;
//iterate each file, obtaining a reference to its gamefiles list
for(int i = sorted; i < mFiles.size(); ++i)
{
@ -520,12 +524,10 @@ void ContentSelectorModel::ContentModel::sortFiles()
break;
}
if(i != j)
{
mFiles.move(i, j);
emit dataChanged(index(i, 0, QModelIndex()), index(j, 0, QModelIndex()));
}
++sorted;
}
emit layoutChanged();
}
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;
void addFiles(const QString &path);
void sortFiles();
void clearFiles();
QModelIndex indexFromItem(const EsmFile *item) const;
@ -68,8 +69,6 @@ namespace ContentSelectorModel
void addFile(EsmFile *file);
void sortFiles();
/// Checks a specific plug-in for load order errors
/// \return all errors found for specific plug-in
QList<LoadOrderError> checkForLoadOrderErrors(const EsmFile *file, int row) const;

@ -173,6 +173,11 @@ void ContentSelectorView::ContentSelector::addFiles(const QString &path)
mContentModel->checkForLoadOrderErrors();
}
void ContentSelectorView::ContentSelector::sortFiles()
{
mContentModel->sortFiles();
}
void ContentSelectorView::ContentSelector::clearFiles()
{
mContentModel->clearFiles();

@ -28,6 +28,7 @@ namespace ContentSelectorView
QString currentFile() const;
void addFiles(const QString &path);
void sortFiles();
void clearFiles();
void setProfileContent (const QStringList &fileList);

Loading…
Cancel
Save