Changeset View
Changeset View
Standalone View
Standalone View
applets/systemtray/entrymodel.h
- This file was added.
1 | /** | ||||
---|---|---|---|---|---|
2 | * Copyright 2019 Nicolas Fella <nicolas.fella@gmx.de> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU General Public License as | ||||
6 | * published by the Free Software Foundation; either version 2 of | ||||
7 | * the License or (at your option) version 3 or any later version | ||||
8 | * accepted by the membership of KDE e.V. (or its successor approved | ||||
9 | * by the membership of KDE e.V.), which shall act as a proxy | ||||
10 | * defined in Section 14 of version 3 of the license. | ||||
11 | * | ||||
12 | * This program is distributed in the hope that it will be useful, | ||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | * GNU General Public License for more details. | ||||
16 | * | ||||
17 | * You should have received a copy of the GNU General Public License | ||||
18 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||||
19 | */ | ||||
20 | | ||||
21 | #ifndef ENTRYMODEL_H | ||||
22 | #define ENTRYMODEL_H | ||||
23 | | ||||
24 | #include <QAbstractListModel> | ||||
25 | #include <Plasma/Applet> | ||||
26 | | ||||
27 | #include "systemtray.h" | ||||
28 | struct Entry { | ||||
29 | QString name; | ||||
30 | QString iconName; | ||||
31 | QString taskId; | ||||
32 | QVariant icon; | ||||
33 | bool isPlasmoid; | ||||
34 | Plasma::Applet *applet; | ||||
35 | }; | ||||
36 | | ||||
37 | class EntryModel | ||||
38 | : public QAbstractListModel | ||||
39 | { | ||||
40 | Q_OBJECT | ||||
41 | | ||||
42 | public: | ||||
43 | enum ModelRoles { | ||||
44 | AppletRole = Qt::UserRole + 1, | ||||
45 | TaskIdRole, | ||||
46 | NameRole, | ||||
47 | IconNameRole, | ||||
48 | ShortcutRole, | ||||
49 | IconRole, | ||||
50 | IsPlasmoidRole | ||||
51 | }; | ||||
52 | | ||||
53 | explicit EntryModel(SystemTray *systemTray); | ||||
54 | ~EntryModel() override; | ||||
55 | | ||||
56 | QVariant data(const QModelIndex& index, int role) const override; | ||||
57 | bool setData(const QModelIndex &index, const QVariant &value, int role) override; | ||||
58 | | ||||
59 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; | ||||
60 | QHash<int, QByteArray> roleNames() const override; | ||||
61 | | ||||
62 | private: | ||||
63 | QVector<Entry> m_entries; | ||||
64 | }; | ||||
65 | | ||||
66 | #endif // ENTRYMODEL_H |