#include <qmessagebox.h>
#include <qapplication.h>
+#include <algorithm>
+
#ifdef Q_OS_WIN
# include <QtCore/QVarLengthArray>
# include <qt_windows.h>
r->fileName, Qt::CaseInsensitive) < 0;
}
case 1:
+ {
// Directories go first
- if (l->isDir() && !r->isDir())
- return true;
- return l->size() < r->size();
+ bool left = l->isDir();
+ bool right = r->isDir();
+ if (left ^ right)
+ return left;
+
+ qint64 sizeDifference = l->size() - r->size();
+ if (sizeDifference == 0)
+ return QFileSystemModelPrivate::naturalCompare(l->fileName, r->fileName, Qt::CaseInsensitive) < 0;
+
+ return sizeDifference < 0;
+ }
case 2:
- return l->type() < r->type();
+ {
+ int compare = QString::localeAwareCompare(l->type(), r->type());
+ if (compare == 0)
+ return QFileSystemModelPrivate::naturalCompare(l->fileName, r->fileName, Qt::CaseInsensitive) < 0;
+
+ return compare < 0;
+ }
case 3:
+ {
+ if (l->lastModified() == r->lastModified())
+ return QFileSystemModelPrivate::naturalCompare(l->fileName, r->fileName, Qt::CaseInsensitive) < 0;
+
return l->lastModified() < r->lastModified();
}
+ }
Q_ASSERT(false);
return false;
}
i++;
}
QFileSystemModelSorter ms(column);
- qStableSort(values.begin(), values.end(), ms);
+ std::sort(values.begin(), values.end(), ms);
// First update the new visible list
indexNode->visibleChildren.clear();
//No more dirty item we reset our internal dirty index
QTest::qWait(500);
QModelIndex parent = myModel->index(dirPath, 0);
QList<QString> expectedOrder;
- expectedOrder << tempFile2.fileName() << tempFile.fileName() << dirPath + QChar('/') + "." << dirPath + QChar('/') + "..";
+ expectedOrder << tempFile2.fileName() << tempFile.fileName() << dirPath + QChar('/') + ".." << dirPath + QChar('/') + ".";
//File dialog Mode means sub trees are not sorted, only the current root
if (fileDialogMode) {
// FIXME: we were only able to disableRecursiveSort in developer builds, so we can only