File indexing completed on 2024-05-12 05:04:09

0001 // SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
0002 // SPDX-License-Identifier: GPL-3.0-only
0003 
0004 #pragma once
0005 
0006 #include <QtQml>
0007 
0008 class FeaturedTagsModel : public QAbstractListModel
0009 {
0010     Q_OBJECT
0011     QML_ELEMENT
0012 
0013     /// The account id of the account we want to display
0014     Q_PROPERTY(QString accountId READ accountId WRITE setAccountId NOTIFY accountIdChanged)
0015 
0016 public:
0017     /// Custom roles for this model
0018     enum CustomRoles {
0019         NameRole = Qt::UserRole, ///< Name of the tag
0020     };
0021 
0022     explicit FeaturedTagsModel(QObject *parent = nullptr);
0023 
0024     QString accountId() const;
0025     void setAccountId(const QString &accountId);
0026 
0027     QVariant data(const QModelIndex &index, int role) const override;
0028     int rowCount(const QModelIndex &parent) const override;
0029     QHash<int, QByteArray> roleNames() const override;
0030 
0031 Q_SIGNALS:
0032     void accountIdChanged();
0033 
0034 private:
0035     void fill();
0036 
0037     QString m_accountId;
0038     QVector<QString> m_tags;
0039 };