forked from qt-creator/qt-creator
Utils: Support sorting by QDir::Time in FilePath::dirEntries
Amends: f9c97d23c7
Task-number: QTCREATORBUG-26939
Change-Id: I9122d51af102547086687b1b9c6cb1553b609673
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -737,8 +737,14 @@ FilePaths FilePath::dirEntries(const QStringList &nameFilters,
|
|||||||
|
|
||||||
// FIXME: Not all flags supported here.
|
// FIXME: Not all flags supported here.
|
||||||
|
|
||||||
if ((sort & QDir::SortByMask) == QDir::Name)
|
const QDir::SortFlags sortBy = (sort & QDir::SortByMask);
|
||||||
|
if (sortBy == QDir::Name) {
|
||||||
Utils::sort(result);
|
Utils::sort(result);
|
||||||
|
} else if (sortBy == QDir::Time) {
|
||||||
|
Utils::sort(result, [](const FilePath &path1, const FilePath &path2) {
|
||||||
|
return path1.lastModified() < path2.lastModified();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (sort & QDir::Reversed)
|
if (sort & QDir::Reversed)
|
||||||
std::reverse(result.begin(), result.end());
|
std::reverse(result.begin(), result.end());
|
||||||
|
Reference in New Issue
Block a user