diff options
| author | Nazar Kalinowski <[email protected]> | 2019-09-01 17:48:32 +0200 |
|---|---|---|
| committer | Elvis Angelaccio <[email protected]> | 2019-09-01 17:50:25 +0200 |
| commit | 7f6d49377b3b66da9811d94aa0166872e4f44836 (patch) | |
| tree | d4792f775649ce1f9e17b876070eea7cda96d01e /src/kitemviews/kfileitemmodel.cpp | |
| parent | eaec53a7af4e098acd957a274f059920d569e0be (diff) | |
Make non-empty textual columns come first in sorting
Summary:
Current behavior of dolphin in sorting of files with textual columns (e.g. tags) is to show files without this particular textual column (e.g. without tags) first.
This patch changes this behavior so that dolphin shows the files with some value before the files without any value for chosen sorting method.
BUG: 410538
Test Plan:
Sorting by name (isn't affected by the patch): https://i.imgur.com/eqbYwyZ.png
Sorting by textual column ("tags" in this particular example),
old version (non-tagged files and folders come first): https://i.imgur.com/5KLLujU.png
patched version (tagged files and folders come first): https://i.imgur.com/oUAeZ2z.png
Reviewers: #dolphin, #vdg, ngraham
Reviewed By: #dolphin, #vdg, ngraham
Subscribers: elvisangelaccio, ngraham, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D23482
Diffstat (limited to 'src/kitemviews/kfileitemmodel.cpp')
| -rw-r--r-- | src/kitemviews/kfileitemmodel.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index 49c96ec37..091044c06 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -1829,8 +1829,15 @@ int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b, const default: { const QByteArray role = roleForType(m_sortRole); - result = QString::compare(a->values.value(role).toString(), - b->values.value(role).toString()); + const QString roleValueA = a->values.value(role).toString(); + const QString roleValueB = b->values.value(role).toString(); + if (!roleValueA.isEmpty() && roleValueB.isEmpty()) { + result = -1; + } else if (roleValueA.isEmpty() && !roleValueB.isEmpty()) { + result = +1; + } else { + result = QString::compare(roleValueA, roleValueB); + } break; } |
