mirror of
https://invent.kde.org/system/dolphin
synced 2024-10-28 03:21:56 +00:00
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
This commit is contained in:
parent
eaec53a7af
commit
7f6d49377b
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue