bool requiresIndexer;
};
+ /**
+ * @return Provides static information for a role that is supported
+ * by KFileItemModel. Some roles can only be determined if
+ * Baloo is enabled and/or the Baloo indexing is enabled.
+ */
+ static RoleInfo roleInformation(const QByteArray &role);
+
/**
* @return Provides static information for all available roles that
* are supported by KFileItemModel. Some roles can only be
*/
static QList<RoleInfo> rolesInformation();
+ /**
+ * @return Provides static information for all available grouping
+ * behaviors supported by KFileItemModel but not directly
+ * mapped to roles of KFileItemModel.
+ */
+ static QList<RoleInfo> extraGroupingInformation();
+
/** set to true to hide application/x-trash files */
void setShowTrashMime(bool show);
void onGroupedSortingChanged(bool current) override;
void onSortRoleChanged(const QByteArray ¤t, const QByteArray &previous, bool resortItems = true) override;
void onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous) override;
+ void onGroupRoleChanged(const QByteArray ¤t, const QByteArray &previous, bool resortItems = true) override;
+ void onGroupOrderChanged(Qt::SortOrder current, Qt::SortOrder previous) override;
private Q_SLOTS:
/**
- * Resorts all items dependent on the set sortRole(), sortOrder()
- * and foldersFirst() settings.
+ * Resorts all items dependent on the set sortRole(), sortOrder(),
+ * groupRole(), groupOrder() and foldersFirst() settings.
*/
void resortAllItems();
QHash<QByteArray, QVariant> values;
ItemData *parent;
};
-
- enum RemoveItemsBehavior {
- KeepItemData,
- DeleteItemData,
- DeleteItemDataIfUnfiltered
+
+ struct ItemGroupInfo {
+ int comparable;
+ QString text;
+
+ bool operator==(const ItemGroupInfo &other) const;
+ bool operator!=(const ItemGroupInfo &other) const;
+ bool operator<(const ItemGroupInfo &other) const;
};
+ enum RemoveItemsBehavior { KeepItemData, DeleteItemData, DeleteItemDataIfUnfiltered };
+
void insertItems(QList<ItemData *> &items);
void removeItems(const KItemRangeList &itemRanges, RemoveItemsBehavior behavior);
*/
QList<ItemData *> createItemDataList(const QUrl &parentUrl, const KFileItemList &items) const;
+ /**
+ * Helper method for prepareItemsForSorting().
+ * For a set role, fills 'values' of ItemData non-lazily.
+ */
+ void prepareItemsWithRole(QList<ItemData *> &itemDataList, RoleType roleType);
+
/**
* Prepares the items for sorting. Normally, the hash 'values' in ItemData is filled
* lazily to save time and memory, but for some sort roles, it is expected that the
*/
int sortRoleCompare(const ItemData *a, const ItemData *b, const QCollator &collator) const;
+ /**
+ * Helper method for lessThan() and expandedParentsCountCompare(): Compares
+ * the passed item-data using m_groupRole as criteria. Both items must
+ * have the same parent item, otherwise the comparison will be wrong.
+ */
+ int groupRoleCompare(const ItemData *a, const ItemData *b, const QCollator &collator) const;
+
int stringCompare(const QString &a, const QString &b, const QCollator &collator) const;
+ ItemGroupInfo nameRoleGroup(const ItemData *itemData, bool withString = true) const;
+ ItemGroupInfo sizeRoleGroup(const ItemData *itemData, bool withString = true) const;
+ ItemGroupInfo timeRoleGroup(const std::function<QDateTime(const ItemData *)> &fileTimeCb, const ItemData *itemData, bool withString = true) const;
+ ItemGroupInfo permissionRoleGroup(const ItemData *itemData, bool withString = true) const;
+ ItemGroupInfo ratingRoleGroup(const ItemData *itemData, bool withString = true) const;
+ ItemGroupInfo typeRoleGroup(const ItemData *itemData) const;
+ ItemGroupInfo genericStringRoleGroup(const QByteArray &role, const ItemData *itemData) const;
+
QList<QPair<int, QVariant>> nameRoleGroups() const;
QList<QPair<int, QVariant>> sizeRoleGroups() const;
QList<QPair<int, QVariant>> timeRoleGroups(const std::function<QDateTime(const ItemData *)> &fileTimeCb) const;
QList<QPair<int, QVariant>> permissionRoleGroups() const;
QList<QPair<int, QVariant>> ratingRoleGroups() const;
+ QList<QPair<int, QVariant>> typeRoleGroups() const;
QList<QPair<int, QVariant>> genericStringRoleGroups(const QByteArray &typeForRole) const;
/**
bool m_sortHiddenLast;
RoleType m_sortRole;
+ RoleType m_groupRole;
+ QByteArray m_sortExtraInfo;
+ QByteArray m_groupExtraInfo;
+
int m_sortingProgressPercent; // Value of directorySortingProgress() signal
QSet<QByteArray> m_roles;
}
}
+inline bool KFileItemModel::ItemGroupInfo::operator==(const ItemGroupInfo &other) const
+{
+ return comparable == other.comparable && text == other.text;
+}
+
+inline bool KFileItemModel::ItemGroupInfo::operator!=(const ItemGroupInfo &other) const
+{
+ return comparable != other.comparable || text != other.text;
+}
+
#endif