Keep a set of all the tags from the posts stored
This allows later on to get post-specific tags.
This commit is contained in:
		
					parent
					
						
							
								f6aa593ee5
							
						
					
				
			
			
				commit
				
					
						942d1ffd1e
					
				
			
		
					 2 changed files with 10 additions and 0 deletions
				
			
		| 
						 | 
					@ -57,6 +57,7 @@ void DanbooruPostModel::addPost(Danbooru::DanbooruPost *post)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    beginInsertRows(QModelIndex(), m_items.size(), m_items.size());
 | 
					    beginInsertRows(QModelIndex(), m_items.size(), m_items.size());
 | 
				
			||||||
    m_items.append(post);
 | 
					    m_items.append(post);
 | 
				
			||||||
 | 
					    m_postTags.unite(post->tags());
 | 
				
			||||||
    endInsertRows();
 | 
					    endInsertRows();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -147,5 +148,11 @@ QHash< int, QByteArray > DanbooruPostModel::roleNames() const
 | 
				
			||||||
    return roles;
 | 
					    return roles;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QStringList DanbooruPostModel::postTags() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return m_postTags.toList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,6 +28,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QAbstractListModel>
 | 
					#include <QAbstractListModel>
 | 
				
			||||||
#include <QVector>
 | 
					#include <QVector>
 | 
				
			||||||
 | 
					#include <QSet>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru
 | 
					namespace Danbooru
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -57,6 +58,7 @@ public:
 | 
				
			||||||
    QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
 | 
					    QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
 | 
				
			||||||
    void clear();
 | 
					    void clear();
 | 
				
			||||||
    QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
 | 
					    QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
 | 
				
			||||||
 | 
					    QStringList postTags() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    enum PostRoles {
 | 
					    enum PostRoles {
 | 
				
			||||||
        FileUrlRole = Qt::UserRole + 1001,
 | 
					        FileUrlRole = Qt::UserRole + 1001,
 | 
				
			||||||
| 
						 | 
					@ -69,6 +71,7 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    QVector<DanbooruPost *> m_items;
 | 
					    QVector<DanbooruPost *> m_items;
 | 
				
			||||||
 | 
					    QSet<QString> m_postTags;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public Q_SLOTS:
 | 
					public Q_SLOTS:
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue