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:
Alessandro Portale
2022-01-27 09:25:03 +01:00
parent 77749e6e28
commit ec0513bf4b

View File

@@ -737,8 +737,14 @@ FilePaths FilePath::dirEntries(const QStringList &nameFilters,
// 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);
} else if (sortBy == QDir::Time) {
Utils::sort(result, [](const FilePath &path1, const FilePath &path2) {
return path1.lastModified() < path2.lastModified();
});
}
if (sort & QDir::Reversed)
std::reverse(result.begin(), result.end());