diff options
| author | Peter Penz <[email protected]> | 2012-03-13 16:26:16 +0100 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2012-03-13 16:29:45 +0100 |
| commit | f041099904d809b5370285185fbbb2303c40b953 (patch) | |
| tree | 5070608d5c19033a119bec98b9466d889bd8bd7c /src/kitemviews/kfileitemmodel.h | |
| parent | 6c60bf0ad54258976d9dcbd6586b26c65d8d4b78 (diff) | |
Remove RolesInfoAccessor
Now KFileItemModel provides a way to access the available roles
including their translations. Note that the 3 roles "comments",
"rating" and "tags" have not been implemented yet in KFileItemModel
and turning them on does not work currently.
Diffstat (limited to 'src/kitemviews/kfileitemmodel.h')
| -rw-r--r-- | src/kitemviews/kfileitemmodel.h | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h index bb77003c3..5d7a7fc8b 100644 --- a/src/kitemviews/kfileitemmodel.h +++ b/src/kitemviews/kfileitemmodel.h @@ -90,7 +90,7 @@ public: virtual bool supportsDropping(int index) const; /** @reimp */ - virtual QString roleDescription(const QByteArray& role) const; + virtual QString roleDescription(const QByteArray& typeForRole) const; /** @reimp */ virtual QList<QPair<int, QVariant> > groups() const; @@ -158,6 +158,14 @@ public: void setNameFilter(const QString& nameFilter); QString nameFilter() const; + struct RoleInfo + { QByteArray role; + QString translation; + QString group; + }; + + static QList<RoleInfo> rolesInformation(); + signals: /** * Is emitted after the loading of a directory has been completed or new @@ -192,7 +200,7 @@ private slots: void dispatchPendingItemsToInsert(); private: - enum Role { + enum RoleType { NoRole, NameRole, SizeRole, @@ -239,16 +247,16 @@ private: void resetRoles(); /** - * @return Role-index for the given role byte-array. + * @return Role-type for the given role. * Runtime complexity is O(1). */ - Role roleIndex(const QByteArray& role) const; + RoleType typeForRole(const QByteArray& role) const; /** - * @return Role-byte-array for the given role-index. + * @return Role-byte-array for the given role-type. * Runtime complexity is O(1). */ - QByteArray roleByteArray(Role role) const; + QByteArray roleForType(RoleType roleType) const; QHash<QByteArray, QVariant> retrieveData(const KFileItem& item) const; @@ -314,7 +322,7 @@ private: QList<QPair<int, QVariant> > dateRoleGroups() const; QList<QPair<int, QVariant> > permissionRoleGroups() const; QList<QPair<int, QVariant> > ratingRoleGroups() const; - QList<QPair<int, QVariant> > genericStringRoleGroups(const QByteArray& role) const; + QList<QPair<int, QVariant> > genericStringRoleGroups(const QByteArray& typeForRole) const; /** * Helper method for all xxxRoleGroups() methods to check whether the @@ -331,13 +339,32 @@ private: */ KFileItemList childItems(const KFileItem& item) const; + /** + * Maps the QByteArray-roles to RoleTypes and provides translation- and + * group-contexts. + */ + struct RoleInfoMap + { + const char* const role; + const RoleType roleType; + const char* const roleTranslationContext; + const char* const roleTranslation; + const char* const groupTranslationContext; + const char* const groupTranslation; + }; + + /** + * @return Map of user visible roles that are accessible by KFileItemModel::rolesInformation(). + */ + static const RoleInfoMap* rolesInfoMap(int& count); + private: QWeakPointer<KDirLister> m_dirLister; bool m_naturalSorting; bool m_sortFoldersFirst; - Role m_sortRole; + RoleType m_sortRole; QSet<QByteArray> m_roles; Qt::CaseSensitivity m_caseSensitivity; |
