File indexing completed on 2024-06-23 05:29:06
0001 /* 0002 SPDX-FileCopyrightText: 2014 Aditya Mehra <aix.m@outlook.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KCMSLISTMODEL_H 0008 #define KCMSLISTMODEL_H 0009 0010 #include <KPluginMetaData> 0011 #include <QAbstractListModel> 0012 0013 #include "configuration.h" 0014 #include <QList> 0015 #include <QObject> 0016 0017 class QString; 0018 0019 struct KcmData { 0020 QString name; 0021 QString description; 0022 QString iconName; 0023 QString id; 0024 }; 0025 0026 class KcmsListModel : public QAbstractListModel 0027 { 0028 Q_OBJECT 0029 Q_PROPERTY(int count READ count NOTIFY countChanged) 0030 0031 public: 0032 enum Roles { KcmIdRole = Qt::UserRole + 1, KcmIconNameRole, KcmDescriptionRole, KcmNameRole, KcmRole }; 0033 Q_ENUM(Roles) 0034 0035 KcmsListModel(QObject *parent = nullptr); 0036 ~KcmsListModel() override; 0037 0038 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; 0039 int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; 0040 void moveRow(const QModelIndex &sourceParent, int sourceRow, const QModelIndex &destinationParent, int destinationChild); 0041 0042 Qt::ItemFlags flags(const QModelIndex &index) const override; 0043 0044 Q_INVOKABLE void moveItem(int row, int destination); 0045 Q_INVOKABLE void loadKcms(); 0046 0047 QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE; 0048 0049 int count(); 0050 0051 QStringList appOrder() const; 0052 void setAppOrder(const QStringList &order); 0053 0054 Q_SIGNALS: 0055 void countChanged(); 0056 void appOrderChanged(); 0057 0058 private: 0059 QList<KcmData> m_kcms; 0060 0061 QStringList m_appOrder; 0062 QHash<QString, int> m_appPositions; 0063 0064 Configuration m_configuration; 0065 bool m_mycroftEnabled; 0066 }; 0067 0068 #endif // KCMSLISTMODEL_H