diff options
| author | Ramil Nurmanov <[email protected]> | 2026-06-05 00:06:12 +0400 |
|---|---|---|
| committer | Ramil Nurmanov <[email protected]> | 2026-06-11 14:30:18 +0400 |
| commit | 989c0f4f0319f7d8e573c8a88fe8011bd3315466 (patch) | |
| tree | 2cecdf3bed6375269e4d9b6948ebc4c34918988d /src/kitemviews/kitemmodelbase.h | |
| parent | 6eed05fd769b01c37530b8b62cdcd65933ea8d14 (diff) | |
Allow grouping by a separate criterion
Add an explicit group role to Dolphin views so items can be grouped independently from the active sort role.
Previously, Dolphin's grouped view always used the current sort role as the grouping criterion. This meant that grouping and sorting were tied together, for example grouping by type also required sorting by type.
This change adds a separate Group By menu. It replaces the previous Show in Groups toggle and allows the user to disable grouping, keep the old Same as Sort behavior, or explicitly group by a selected criterion.
When an explicit group role is set, the model keeps groups stable and uses the normal sort role as a secondary key inside each group. The roles
updater also receives the active group role, so roles used only for grouping are still updated correctly.
BUG: 416134
CCBUG: 510670
CCBUG: 513235
CCBUG: 46393
Diffstat (limited to 'src/kitemviews/kitemmodelbase.h')
| -rw-r--r-- | src/kitemviews/kitemmodelbase.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/kitemviews/kitemmodelbase.h b/src/kitemviews/kitemmodelbase.h index 42a9c54c9..68d1d5d8a 100644 --- a/src/kitemviews/kitemmodelbase.h +++ b/src/kitemviews/kitemmodelbase.h @@ -76,6 +76,10 @@ public: void setSortRole(const QByteArray &role, bool resortItems = true); QByteArray sortRole() const; + void setGroupRole(const QByteArray &role); + QByteArray groupRole() const; + QByteArray rawGroupRole() const; + /** * Sets the sort order to \a order. The method KItemModelBase::onSortOrderChanged() will be * called so that model-implementations can react on the sort order change. Afterwards the @@ -248,6 +252,8 @@ Q_SIGNALS: void sortRoleChanged(const QByteArray ¤t, const QByteArray &previous); void sortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous); + void groupRoleChanged(const QByteArray ¤t, const QByteArray &previous); + protected: /** * Is invoked if the grouped sorting has been changed by KItemModelBase::setGroupedSorting(). Allows @@ -266,6 +272,8 @@ protected: */ virtual void onSortRoleChanged(const QByteArray ¤t, const QByteArray &previous, bool resortItems = true); + virtual void onGroupRoleChanged(const QByteArray ¤t, const QByteArray &previous, bool resortItems = true); + /** * Is invoked if the sort order has been changed by KItemModelBase::setSortOrder(). Allows * to react on the changed sort order before the signal sortOrderChanged() will be emitted. @@ -279,6 +287,7 @@ protected: private: bool m_groupedSorting; QByteArray m_sortRole; + QByteArray m_groupRole; Qt::SortOrder m_sortOrder; }; |
