Changeset View
Changeset View
Standalone View
Standalone View
kcms/icons/iconsmodel.h
Show All 21 Lines | |||||
22 | */ | 22 | */ | ||
23 | 23 | | |||
24 | #pragma once | 24 | #pragma once | ||
25 | 25 | | |||
26 | #include <QAbstractListModel> | 26 | #include <QAbstractListModel> | ||
27 | #include <QString> | 27 | #include <QString> | ||
28 | #include <QVector> | 28 | #include <QVector> | ||
29 | 29 | | |||
30 | class IconsSettings; | ||||
31 | | ||||
30 | struct IconsModelData | 32 | struct IconsModelData | ||
31 | { | 33 | { | ||
32 | QString display; | 34 | QString display; | ||
33 | QString themeName; | 35 | QString themeName; | ||
34 | QString description; | 36 | QString description; | ||
35 | bool removable; | 37 | bool removable; | ||
36 | bool pendingDeletion; | 38 | bool pendingDeletion; | ||
37 | }; | 39 | }; | ||
38 | Q_DECLARE_TYPEINFO(IconsModelData, Q_MOVABLE_TYPE); | 40 | Q_DECLARE_TYPEINFO(IconsModelData, Q_MOVABLE_TYPE); | ||
39 | 41 | | |||
40 | class IconsModel : public QAbstractListModel | 42 | class IconsModel : public QAbstractListModel | ||
41 | { | 43 | { | ||
42 | Q_OBJECT | 44 | Q_OBJECT | ||
43 | 45 | | |||
44 | Q_PROPERTY(QString selectedTheme READ selectedTheme WRITE setSelectedTheme NOTIFY selectedThemeChanged) | | |||
45 | Q_PROPERTY(int selectedThemeIndex READ selectedThemeIndex NOTIFY selectedThemeIndexChanged) | | |||
46 | | ||||
47 | public: | 46 | public: | ||
48 | IconsModel(QObject *parent); | 47 | IconsModel(IconsSettings *iconsSettings, QObject *parent = nullptr); | ||
ervin: Kind of a nitpick in this context, but parent should go last and default to nullptr. It's the… | |||||
49 | ~IconsModel() override; | 48 | ~IconsModel() override; | ||
50 | 49 | | |||
51 | enum Roles { | 50 | enum Roles { | ||
52 | ThemeNameRole = Qt::UserRole + 1, | 51 | ThemeNameRole = Qt::UserRole + 1, | ||
53 | DescriptionRole, | 52 | DescriptionRole, | ||
54 | RemovableRole, | 53 | RemovableRole, | ||
55 | PendingDeletionRole | 54 | PendingDeletionRole | ||
56 | }; | 55 | }; | ||
57 | 56 | | |||
58 | int rowCount(const QModelIndex &parent) const override; | 57 | int rowCount(const QModelIndex &parent) const override; | ||
59 | QVariant data(const QModelIndex &index, int role) const override; | 58 | QVariant data(const QModelIndex &index, int role) const override; | ||
60 | bool setData(const QModelIndex &index, const QVariant &value, int role) override; | 59 | bool setData(const QModelIndex &index, const QVariant &value, int role) override; | ||
61 | QHash<int, QByteArray> roleNames() const override; | 60 | QHash<int, QByteArray> roleNames() const override; | ||
62 | 61 | | |||
63 | QString selectedTheme() const; | | |||
64 | void setSelectedTheme(const QString &theme); | | |||
65 | | ||||
66 | int selectedThemeIndex() const; | | |||
67 | | ||||
68 | QStringList pendingDeletions() const; | 62 | QStringList pendingDeletions() const; | ||
69 | void removeItemsPendingDeletion(); | 63 | void removeItemsPendingDeletion(); | ||
70 | 64 | | |||
71 | void load(); | 65 | void load(); | ||
72 | 66 | | |||
73 | signals: | 67 | signals: | ||
74 | void selectedThemeChanged(); | | |||
75 | void selectedThemeIndexChanged(); | | |||
76 | | ||||
77 | void pendingDeletionsChanged(); | 68 | void pendingDeletionsChanged(); | ||
78 | 69 | | |||
79 | private: | 70 | private: | ||
80 | QString m_selectedTheme; | | |||
81 | | ||||
82 | QVector<IconsModelData> m_data; | 71 | QVector<IconsModelData> m_data; | ||
72 | IconsSettings *m_settings; | ||||
83 | 73 | | |||
84 | }; | 74 | }; |
Kind of a nitpick in this context, but parent should go last and default to nullptr. It's the Qt convention for QObject ctors.