From 942d1ffd1ec93dbd2ada9b2a4399464d37596ec9 Mon Sep 17 00:00:00 2001 From: Luca Beltrame Date: Fri, 20 Feb 2015 23:35:13 +0100 Subject: [PATCH] Keep a set of all the tags from the posts stored This allows later on to get post-specific tags. --- src/model/danboorupostmodel.cpp | 7 +++++++ src/model/danboorupostmodel.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/model/danboorupostmodel.cpp b/src/model/danboorupostmodel.cpp index 332a9b0..b300253 100644 --- a/src/model/danboorupostmodel.cpp +++ b/src/model/danboorupostmodel.cpp @@ -57,6 +57,7 @@ void DanbooruPostModel::addPost(Danbooru::DanbooruPost *post) beginInsertRows(QModelIndex(), m_items.size(), m_items.size()); m_items.append(post); + m_postTags.unite(post->tags()); endInsertRows(); } @@ -147,5 +148,11 @@ QHash< int, QByteArray > DanbooruPostModel::roleNames() const return roles; } +QStringList DanbooruPostModel::postTags() const +{ + + return m_postTags.toList(); + +} }; diff --git a/src/model/danboorupostmodel.h b/src/model/danboorupostmodel.h index 7f56009..2a71e99 100644 --- a/src/model/danboorupostmodel.h +++ b/src/model/danboorupostmodel.h @@ -28,6 +28,7 @@ #include #include +#include namespace Danbooru { @@ -57,6 +58,7 @@ public: QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; void clear(); QHash roleNames() const Q_DECL_OVERRIDE; + QStringList postTags() const; enum PostRoles { FileUrlRole = Qt::UserRole + 1001, @@ -69,6 +71,7 @@ public: private: QVector m_items; + QSet m_postTags; public Q_SLOTS: /**