summaryrefslogtreecommitdiff
path: root/rockwork/notificationsourcemodel.h
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2016-02-11 23:55:16 +0100
committerAndrew Branson <andrew.branson@cern.ch>2016-02-11 23:55:16 +0100
commit29aaea2d80a9eb1715b6cddfac2d2aacf76358bd (patch)
tree012795b6bec16c72f38d33cff46324c9a0225868 /rockwork/notificationsourcemodel.h
launchpad ~mzanetti/rockwork/trunk r87
Diffstat (limited to 'rockwork/notificationsourcemodel.h')
-rw-r--r--rockwork/notificationsourcemodel.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/rockwork/notificationsourcemodel.h b/rockwork/notificationsourcemodel.h
new file mode 100644
index 0000000..89fa26f
--- /dev/null
+++ b/rockwork/notificationsourcemodel.h
@@ -0,0 +1,48 @@
+#ifndef NOTIFICATIONSOURCEMODEL_H
+#define NOTIFICATIONSOURCEMODEL_H
+
+#include <QAbstractListModel>
+
+class NotificationSourceItem
+{
+public:
+ QString m_id;
+ QString m_displayName;
+ QString m_icon;
+ bool m_enabled = false;
+
+ bool operator ==(const NotificationSourceItem &other) {
+ return m_id == other.m_id;
+ }
+};
+
+class NotificationSourceModel : public QAbstractListModel
+{
+ Q_OBJECT
+ Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
+public:
+ enum Roles {
+ RoleName,
+ RoleEnabled,
+ RoleIcon
+ };
+
+ explicit NotificationSourceModel(QObject *parent = 0);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex &index, int role) const override;
+ QHash<int, QByteArray> roleNames() const override;
+
+ void insert(const QString &sourceId, bool enabled);
+
+signals:
+ void countChanged();
+
+private:
+ NotificationSourceItem fromDesktopFile(const QString &sourceId);
+
+private:
+ QList<NotificationSourceItem> m_sources;
+};
+
+#endif // NOTIFICATIONSOURCEMODEL_H