diff options
| author | George Vogiatzis <[email protected]> | 2020-01-28 08:50:06 -0700 |
|---|---|---|
| committer | Nate Graham <[email protected]> | 2020-01-28 08:52:58 -0700 |
| commit | 9e3418bd558293a92b2e8bcba55f5a3f5d3cc5a4 (patch) | |
| tree | ecfa3ffd734901b396fe4d723116561484aeca65 /src/kitemviews/kfileitemmodel.h | |
| parent | c2fa8ae9ab0df08781b7d032e99d7b8f220c10e0 (diff) | |
Add natural sorting and case-insensitive sorting for all role-types
Summary:
Add natural sorting and case-insensitive sorting, for all role-types
that benefit from.
BUG: 406296
FIXED-IN: 19.12.2
Test Plan:
Sort by any role type specified in `isRoleValueNatural()`
Before: Sorting is always case sensitive
After: Sorting according to 'Sorting mode' in configuration.
Reviewers: #dolphin, nicolasfella, meven, elvisangelaccio, ngraham
Reviewed By: #dolphin, meven, elvisangelaccio, ngraham
Subscribers: cfeck, meven, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D25741
Diffstat (limited to 'src/kitemviews/kfileitemmodel.h')
| -rw-r--r-- | src/kitemviews/kfileitemmodel.h | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h index c2dfd0167..132a76e46 100644 --- a/src/kitemviews/kfileitemmodel.h +++ b/src/kitemviews/kfileitemmodel.h @@ -356,6 +356,11 @@ private: QHash<QByteArray, QVariant> retrieveData(const KFileItem& item, const ItemData* parent) const; /** + * @return True if role values benefit from natural or case insensitive sorting. + */ + static bool isRoleValueNatural(const RoleType roleType); + + /** * @return True if \a a has a KFileItem whose text is 'less than' the one * of \a b according to QString::operator<(const QString&). */ @@ -504,12 +509,27 @@ private: friend class DolphinPart; // Accesses m_dirLister }; +inline bool KFileItemModel::isRoleValueNatural(RoleType roleType) +{ + return (roleType == TypeRole || + roleType == TagsRole || + roleType == CommentRole || + roleType == TitleRole || + roleType == ArtistRole || + roleType == GenreRole || + roleType == AlbumRole || + roleType == PathRole || + roleType == DestinationRole || + roleType == OriginUrlRole || + roleType == OwnerRole || + roleType == GroupRole); +} + inline bool KFileItemModel::nameLessThan(const ItemData* a, const ItemData* b) { return a->item.text() < b->item.text(); } - inline bool KFileItemModel::isChildItem(int index) const { if (m_itemData.at(index)->parent) { |
