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());
 | 
			
		||||
    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();
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,6 +28,7 @@
 | 
			
		|||
 | 
			
		||||
#include <QAbstractListModel>
 | 
			
		||||
#include <QVector>
 | 
			
		||||
#include <QSet>
 | 
			
		||||
 | 
			
		||||
namespace Danbooru
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -57,6 +58,7 @@ public:
 | 
			
		|||
    QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
 | 
			
		||||
    void clear();
 | 
			
		||||
    QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
 | 
			
		||||
    QStringList postTags() const;
 | 
			
		||||
 | 
			
		||||
    enum PostRoles {
 | 
			
		||||
        FileUrlRole = Qt::UserRole + 1001,
 | 
			
		||||
| 
						 | 
				
			
			@ -69,6 +71,7 @@ public:
 | 
			
		|||
 | 
			
		||||
private:
 | 
			
		||||
    QVector<DanbooruPost *> m_items;
 | 
			
		||||
    QSet<QString> m_postTags;
 | 
			
		||||
 | 
			
		||||
public Q_SLOTS:
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue