File indexing completed on 2024-04-28 15:39:41
0001 // SPDX-FileCopyrightText: 2014-2022 Jesper K. Pedersen <blackie@kde.org> 0002 // 0003 // SPDX-License-Identifier: GPL-2.0-or-later 0004 0005 #ifndef CATEGORYMODEL_H 0006 #define CATEGORYMODEL_H 0007 0008 #include <QAbstractListModel> 0009 #include <QList> 0010 0011 #include "RemoteCommand.h" 0012 0013 namespace RemoteControl 0014 { 0015 0016 using RoleMap = QHash<int, QByteArray>; 0017 class CategoryModel : public QAbstractListModel 0018 { 0019 Q_OBJECT 0020 Q_PROPERTY(bool hasData READ hasData NOTIFY hasDataChanged) 0021 0022 public: 0023 enum { NameRole, 0024 IconRole, 0025 EnabledRole, 0026 TypeRole }; 0027 explicit CategoryModel(QObject *parent = 0); 0028 int rowCount(const QModelIndex &parent) const override; 0029 QVariant data(const QModelIndex &index, int role) const override; 0030 RoleMap roleNames() const override; 0031 void setCategories(const QList<Category> &); 0032 bool hasData() const; 0033 0034 Q_SIGNALS: 0035 void hasDataChanged(); 0036 0037 private: 0038 QList<Category> m_categories; 0039 }; 0040 0041 } 0042 Q_DECLARE_METATYPE(RemoteControl::CategoryModel *); 0043 0044 #endif // CATEGORYMODEL_H