From 3479c42968e53e44b9d0489d078fc22ae853346b Mon Sep 17 00:00:00 2001 From: Luca Beltrame Date: Fri, 20 Feb 2015 23:44:24 +0100 Subject: [PATCH] Add a custom role used to sort the tags with an upcoming proxy model --- src/model/danboorutagmodel.cpp | 2 ++ src/model/danboorutagmodel.h | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/model/danboorutagmodel.cpp b/src/model/danboorutagmodel.cpp index ed638f8..7a6d517 100644 --- a/src/model/danboorutagmodel.cpp +++ b/src/model/danboorutagmodel.cpp @@ -56,6 +56,8 @@ QVariant DanbooruTagModel::data(const QModelIndex &index, int role) const return i18np("%1 (%2 post)", "%1 (%2 posts)", tag->name(), tag->count()); } else if (role == Qt::ToolTipRole) { return i18n("Tag count: %1", tag->count()); + } else if (role == TagCountRole) { + return tag->count(); } // TODO: More roles depending on the type of information diff --git a/src/model/danboorutagmodel.h b/src/model/danboorutagmodel.h index 42ee03c..e532889 100644 --- a/src/model/danboorutagmodel.h +++ b/src/model/danboorutagmodel.h @@ -40,6 +40,11 @@ public: void clear(); DanbooruTag* itemAt(int index) const; + enum TagRoles { + // Needed for sorting through the proxy model + TagCountRole = Qt::UserRole + 4000 + }; + private: QVector m_items;