Files sorting (masters then plugins).

Remove unneeded includes.
pull/37/head
Michal Sciubidlo 12 years ago
parent 0df7c7e5c1
commit f4d60ae7b2

@ -7,12 +7,7 @@
#include <components/fileorderlist/utils/naturalsort.hpp>
#include <components/fileorderlist/utils/filedialog.hpp>
////#include "model/datafilesmodel.hpp"
////#include "model/esm/esmfile.hpp"
#include "utils/profilescombobox.hpp"
////#include "utils/filedialog.hpp"
////#include "utils/naturalsort.hpp"
#include "utils/textinputdialog.hpp"
#include "datafilespage.hpp"
@ -527,7 +522,5 @@ void DataFilesPage::profileRenamed(const QString &previous, const QString &curre
mProfilesComboBox->removeItem(mProfilesComboBox->findText(previous));
mDataFilesList->uncheckAll();
////mMastersModel->uncheckAll();
////mPluginsModel->uncheckAll();
readConfig();
}

@ -8,7 +8,6 @@
#include "utils/filedialog.hpp"
#include "utils/lineedit.hpp"
#include "utils/naturalsort.hpp"
#include "datafileslist.hpp"

@ -8,8 +8,6 @@
#include "esm/esmfile.hpp"
#include "../utils/naturalsort.hpp"
#include "datafilesmodel.hpp"
DataFilesModel::DataFilesModel(QObject *parent) :
@ -219,39 +217,21 @@ bool DataFilesModel::setData(const QModelIndex &index, const QVariant &value, in
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)
{
// TODO: Make this more efficient
emit layoutAboutToBeChanged();
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;
qSort(mFiles.begin(), mFiles.end(), lessThanEsmFile);
emit layoutChanged();
}

@ -26,15 +26,15 @@ public:
void setMasters(const QStringList &masters);
void setDescription(const QString &description);
inline QString fileName() { return mFileName; }
inline QString author() { return mAuthor; }
inline int size() { return mSize; }
inline QDateTime modified() { return mModified; }
inline QDateTime accessed() { return mAccessed; }
inline float version() { return mVersion; }
inline QString path() { return mPath; }
inline QStringList masters() { return mMasters; }
inline QString description() { return mDescription; }
inline QString fileName() const { return mFileName; }
inline QString author() const { return mAuthor; }
inline int size() const { return mSize; }
inline QDateTime modified() const { return mModified; }
inline QDateTime accessed() const { return mAccessed; }
inline float version() const { return mVersion; }
inline QString path() const { return mPath; }
inline QStringList masters() const { return mMasters; }
inline QString description() const { return mDescription; }
private:

Loading…
Cancel
Save