From 74bc3cac2530031c0ec78fc5039342ac0f077eb7 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Sat, 29 Oct 2011 18:05:37 +0200 Subject: Implement grouping for all roles --- src/kitemviews/kfileitemmodel.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/kitemviews/kfileitemmodel.h') diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h index 8ccff95e8..f2e783f46 100644 --- a/src/kitemviews/kfileitemmodel.h +++ b/src/kitemviews/kfileitemmodel.h @@ -198,11 +198,17 @@ private: QList > sizeRoleGroups() const; QList > dateRoleGroups() const; QList > permissionRoleGroups() const; - QList > ownerRoleGroups() const; - QList > groupRoleGroups() const; - QList > typeRoleGroups() const; - QList > destinationRoleGroups() const; - QList > pathRoleGroups() const; + QList > genericStringRoleGroups(const QByteArray& role) const; + + /** + * Helper method for all xxxRoleGroups() methods to check whether the + * item with the given index is a child-item. A child-item is defined + * as item having an expansion-level > 0. All xxxRoleGroups() methods + * should skip the grouping if the item is a child-item (although + * KItemListView would be capable to show sub-groups in groups this + * results in visual clutter for most usecases). + */ + bool isChildItem(int index) const; private: QWeakPointer m_dirLister; @@ -241,6 +247,11 @@ private: friend class KFileItemModelTest; // For unit testing }; +inline bool KFileItemModel::isChildItem(int index) const +{ + return m_requestRole[ExpansionLevelRole] && m_data.at(index).value("expansionLevel").toInt() > 0; +} + #endif -- cgit v1.3