summaryrefslogtreecommitdiff
path: root/sowatchui/providersmodel.h
blob: 9cf6ec66a663742ff6c68449afdf4a7f24818eab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef PROVIDERSMODEL_H
#define PROVIDERSMODEL_H

#include <QtCore/QAbstractListModel>

#include <sowatch.h>

class ProvidersModel : public QAbstractListModel
{
	Q_OBJECT
	Q_PROPERTY(QString configKey READ configKey WRITE setConfigKey NOTIFY configKeyChanged)

public:
	explicit ProvidersModel(QObject *parent = 0);

	enum DataRoles {
		NameRole = Qt::UserRole,
		EnabledRole
	};

	QString configKey() const;
	void setConfigKey(const QString& configKey);

	int rowCount(const QModelIndex &parent) const;
	QVariant data(const QModelIndex &index, int role) const;
	bool setData(const QModelIndex &index, const QVariant &value, int role);

public slots:
	void setProviderEnabled(const QString& id, bool enabled);

signals:
	void configKeyChanged();
	
private slots:
	void reload();

private:
	sowatch::ConfigKey *_config;
	QStringList _all_list;
	QList<sowatch::NotificationPluginInterface::NotificationProviderInfo> _info_list;
	QSet<QString> _enabled;
};

#endif // PROVIDERSMODEL_H