forked from teamnwah/openmw-tes3coop
Files sorting (masters then plugins).
Remove unneeded includes.
This commit is contained in:
parent
0df7c7e5c1
commit
f4d60ae7b2
4 changed files with 21 additions and 49 deletions
|
@ -7,12 +7,7 @@
|
||||||
#include <components/fileorderlist/utils/naturalsort.hpp>
|
#include <components/fileorderlist/utils/naturalsort.hpp>
|
||||||
#include <components/fileorderlist/utils/filedialog.hpp>
|
#include <components/fileorderlist/utils/filedialog.hpp>
|
||||||
|
|
||||||
////#include "model/datafilesmodel.hpp"
|
|
||||||
////#include "model/esm/esmfile.hpp"
|
|
||||||
|
|
||||||
#include "utils/profilescombobox.hpp"
|
#include "utils/profilescombobox.hpp"
|
||||||
////#include "utils/filedialog.hpp"
|
|
||||||
////#include "utils/naturalsort.hpp"
|
|
||||||
#include "utils/textinputdialog.hpp"
|
#include "utils/textinputdialog.hpp"
|
||||||
|
|
||||||
#include "datafilespage.hpp"
|
#include "datafilespage.hpp"
|
||||||
|
@ -527,7 +522,5 @@ void DataFilesPage::profileRenamed(const QString &previous, const QString &curre
|
||||||
mProfilesComboBox->removeItem(mProfilesComboBox->findText(previous));
|
mProfilesComboBox->removeItem(mProfilesComboBox->findText(previous));
|
||||||
|
|
||||||
mDataFilesList->uncheckAll();
|
mDataFilesList->uncheckAll();
|
||||||
////mMastersModel->uncheckAll();
|
|
||||||
////mPluginsModel->uncheckAll();
|
|
||||||
readConfig();
|
readConfig();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
#include "utils/filedialog.hpp"
|
#include "utils/filedialog.hpp"
|
||||||
#include "utils/lineedit.hpp"
|
#include "utils/lineedit.hpp"
|
||||||
#include "utils/naturalsort.hpp"
|
|
||||||
|
|
||||||
#include "datafileslist.hpp"
|
#include "datafileslist.hpp"
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
|
|
||||||
#include "esm/esmfile.hpp"
|
#include "esm/esmfile.hpp"
|
||||||
|
|
||||||
#include "../utils/naturalsort.hpp"
|
|
||||||
|
|
||||||
#include "datafilesmodel.hpp"
|
#include "datafilesmodel.hpp"
|
||||||
|
|
||||||
DataFilesModel::DataFilesModel(QObject *parent) :
|
DataFilesModel::DataFilesModel(QObject *parent) :
|
||||||
|
@ -219,39 +217,21 @@ bool DataFilesModel::setData(const QModelIndex &index, const QVariant &value, in
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool lessThanEsmFile(const EsmFile *e1, const EsmFile *e2)
|
||||||
|
{
|
||||||
|
//Masters first then alphabetically
|
||||||
|
if (e1->fileName().endsWith(".esm") && !e2->fileName().endsWith(".esm"))
|
||||||
|
return true;
|
||||||
|
if (!e1->fileName().endsWith(".esm") && e2->fileName().endsWith(".esm"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return e1->fileName().toLower() < e2->fileName().toLower();
|
||||||
|
}
|
||||||
|
|
||||||
void DataFilesModel::sort(int column, Qt::SortOrder order)
|
void DataFilesModel::sort(int column, Qt::SortOrder order)
|
||||||
{
|
{
|
||||||
// TODO: Make this more efficient
|
|
||||||
emit layoutAboutToBeChanged();
|
emit layoutAboutToBeChanged();
|
||||||
|
qSort(mFiles.begin(), mFiles.end(), lessThanEsmFile);
|
||||||
QList<EsmFile *> sortedFiles;
|
|
||||||
|
|
||||||
QMultiMap<QString, QString> timestamps;
|
|
||||||
|
|
||||||
foreach (EsmFile *file, mFiles)
|
|
||||||
timestamps.insert(file->modified().toString(Qt::ISODate), file->fileName());
|
|
||||||
|
|
||||||
QMapIterator<QString, QString> ti(timestamps);
|
|
||||||
|
|
||||||
while (ti.hasNext()) {
|
|
||||||
ti.next();
|
|
||||||
|
|
||||||
QModelIndex index = indexFromItem(findItem(ti.value()));
|
|
||||||
|
|
||||||
if (!index.isValid())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
EsmFile *file = item(index.row());
|
|
||||||
|
|
||||||
if (!file)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
sortedFiles.append(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
mFiles.clear();
|
|
||||||
mFiles = sortedFiles;
|
|
||||||
|
|
||||||
emit layoutChanged();
|
emit layoutChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,15 +26,15 @@ public:
|
||||||
void setMasters(const QStringList &masters);
|
void setMasters(const QStringList &masters);
|
||||||
void setDescription(const QString &description);
|
void setDescription(const QString &description);
|
||||||
|
|
||||||
inline QString fileName() { return mFileName; }
|
inline QString fileName() const { return mFileName; }
|
||||||
inline QString author() { return mAuthor; }
|
inline QString author() const { return mAuthor; }
|
||||||
inline int size() { return mSize; }
|
inline int size() const { return mSize; }
|
||||||
inline QDateTime modified() { return mModified; }
|
inline QDateTime modified() const { return mModified; }
|
||||||
inline QDateTime accessed() { return mAccessed; }
|
inline QDateTime accessed() const { return mAccessed; }
|
||||||
inline float version() { return mVersion; }
|
inline float version() const { return mVersion; }
|
||||||
inline QString path() { return mPath; }
|
inline QString path() const { return mPath; }
|
||||||
inline QStringList masters() { return mMasters; }
|
inline QStringList masters() const { return mMasters; }
|
||||||
inline QString description() { return mDescription; }
|
inline QString description() const { return mDescription; }
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in a new issue