Changeset View
Changeset View
Standalone View
Standalone View
kcms/notifications/sourcesmodel.h
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | 39 | { | |||
---|---|---|---|---|---|
49 | QString display() const | 49 | QString display() const | ||
50 | { | 50 | { | ||
51 | return !name.isEmpty() ? name : comment; | 51 | return !name.isEmpty() ? name : comment; | ||
52 | } | 52 | } | ||
53 | }; | 53 | }; | ||
54 | 54 | | |||
55 | class SourcesModel : public QAbstractItemModel | 55 | class SourcesModel : public QAbstractItemModel | ||
56 | { | 56 | { | ||
57 | Q_OBJECT | 57 | Q_OBJECT | ||
broulik: Why not an enum? | |||||
58 | 58 | | |||
59 | public: | 59 | public: | ||
60 | SourcesModel(QObject *parent = nullptr); | 60 | SourcesModel(QObject *parent = nullptr); | ||
61 | ~SourcesModel() override; | 61 | ~SourcesModel() override; | ||
62 | 62 | | |||
63 | enum Roles { | 63 | enum Roles { | ||
64 | SourceTypeRole = Qt::UserRole + 1, | 64 | SourceTypeRole = Qt::UserRole + 1, | ||
65 | NotifyRcNameRole, | 65 | NotifyRcNameRole, | ||
Show All 11 Lines | |||||
77 | Q_ENUM(Type) | 77 | Q_ENUM(Type) | ||
78 | 78 | | |||
79 | Q_INVOKABLE QPersistentModelIndex makePersistentModelIndex(const QModelIndex &idx) const; | 79 | Q_INVOKABLE QPersistentModelIndex makePersistentModelIndex(const QModelIndex &idx) const; | ||
80 | 80 | | |||
81 | Q_INVOKABLE QPersistentModelIndex persistentIndexForDesktopEntry(const QString &desktopEntry) const; | 81 | Q_INVOKABLE QPersistentModelIndex persistentIndexForDesktopEntry(const QString &desktopEntry) const; | ||
82 | Q_INVOKABLE QPersistentModelIndex persistentIndexForNotifyRcName(const QString ¬ifyRcName) const; | 82 | Q_INVOKABLE QPersistentModelIndex persistentIndexForNotifyRcName(const QString ¬ifyRcName) const; | ||
83 | 83 | | |||
84 | int columnCount(const QModelIndex &parent) const override; | 84 | int columnCount(const QModelIndex &parent) const override; | ||
85 | int rowCount(const QModelIndex &parent) const override; | 85 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; | ||
86 | 86 | | |||
87 | QVariant data(const QModelIndex &index, int role) const override; | 87 | QVariant data(const QModelIndex &index, int role) const override; | ||
88 | bool setData(const QModelIndex &index, const QVariant &value, int role) override; | 88 | bool setData(const QModelIndex &index, const QVariant &value, int role) override; | ||
89 | 89 | | |||
90 | QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; | 90 | QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; | ||
91 | QModelIndex parent(const QModelIndex &child) const override; | 91 | QModelIndex parent(const QModelIndex &child) const override; | ||
92 | 92 | | |||
93 | QHash<int, QByteArray> roleNames() const override; | 93 | QHash<int, QByteArray> roleNames() const override; | ||
94 | 94 | | |||
95 | Q_INVOKABLE void load(); | 95 | Q_INVOKABLE void load(); | ||
96 | 96 | | |||
97 | private: | 97 | private: | ||
98 | QVector<SourceData> m_data; | 98 | QVector<SourceData> m_data; | ||
It's generally a better idea to define a small trivial struct when roll with QPair ervin: It's generally a better idea to define a small trivial struct when roll with QPair | |||||
99 | 99 | | |||
100 | }; | 100 | }; |
Why not an enum?