Warning, file /plasma/plasma-bigscreen/containments/homescreen/plugin/applicationlistmodel.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2014 Antonis Tsiapaliokas <antonis.tsiapaliokas@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef APPLICATIONLISTMODEL_H 0008 #define APPLICATIONLISTMODEL_H 0009 0010 // Qt 0011 #include <QAbstractListModel> 0012 #include <QList> 0013 #include <QObject> 0014 0015 class QString; 0016 0017 struct ApplicationData { 0018 QString name; 0019 QString comment; 0020 QString icon; 0021 QStringList categories; 0022 QString storageId; 0023 QString entryPath; 0024 QString desktopPath; 0025 bool startupNotify = true; 0026 }; 0027 0028 class ApplicationListModel : public QAbstractListModel 0029 { 0030 Q_OBJECT 0031 0032 Q_PROPERTY(int count READ count NOTIFY countChanged) 0033 Q_PROPERTY(QStringList appOrder READ appOrder WRITE setAppOrder NOTIFY appOrderChanged) 0034 Q_PROPERTY(QStringList voiceAppSkills READ voiceAppSkills NOTIFY voiceAppSkillsChanged) 0035 0036 public: 0037 ApplicationListModel(QObject *parent = nullptr); 0038 ~ApplicationListModel() override; 0039 0040 int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; 0041 0042 void moveRow(const QModelIndex &sourceParent, int sourceRow, const QModelIndex &destinationParent, int destinationChild); 0043 0044 int count() 0045 { 0046 return m_applicationList.count(); 0047 } 0048 0049 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; 0050 0051 Qt::ItemFlags flags(const QModelIndex &index) const override; 0052 0053 QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE; 0054 0055 QStringList voiceAppSkills() const; 0056 0057 enum Roles { 0058 ApplicationNameRole = Qt::UserRole + 1, 0059 ApplicationCommentRole, 0060 ApplicationIconRole, 0061 ApplicationCategoriesRole, 0062 ApplicationStorageIdRole, 0063 ApplicationEntryPathRole, 0064 ApplicationDesktopRole, 0065 ApplicationStartupNotifyRole, 0066 ApplicationOriginalRowRole 0067 }; 0068 Q_ENUM(Roles) 0069 0070 QStringList appOrder() const; 0071 void setAppOrder(const QStringList &order); 0072 0073 Q_INVOKABLE void moveItem(int row, int order); 0074 0075 Q_INVOKABLE void runApplication(const QString &storageId); 0076 0077 Q_INVOKABLE void loadApplications(); 0078 0079 Q_INVOKABLE void executeCommand(const QString &command); 0080 0081 public Q_SLOTS: 0082 void sycocaDbChanged(); 0083 0084 Q_SIGNALS: 0085 void countChanged(); 0086 void appOrderChanged(); 0087 void voiceAppSkillsChanged(); 0088 0089 private: 0090 QStringList m_voiceAppSkills; 0091 QList<ApplicationData> m_applicationList; 0092 0093 QStringList m_appOrder; 0094 QHash<QString, int> m_appPositions; 0095 }; 0096 0097 #endif // APPLICATIONLISTMODEL_H