summaryrefslogtreecommitdiff
path: root/sowatchui/watchletsmodel.h
blob: e0c2c626a34895f29d9cd98a4e51eced5f8fa08a (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
45
46
47
48
49
50
51
52
#ifndef WATCHLETSMODEL_H
#define WATCHLETSMODEL_H

#include <QAbstractListModel>

#include <sowatch.h>

class WatchletsModel : public QAbstractListModel
{
	Q_OBJECT
	Q_PROPERTY(QString configKey READ configKey WRITE setConfigKey NOTIFY configKeyChanged)
	Q_PROPERTY(bool displayUnadded READ displayUnadded WRITE setDisplayUnadded NOTIFY displayUnaddedChanged)

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

	enum DataRoles {
		NameRole = Qt::UserRole
	};

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

	bool displayUnadded() const;
	void setDisplayUnadded(bool displayUnadded);

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

public slots:
	void addWatchlet(const QString& name);
	void removeWatchlet(const QString& name);
	void moveWatchletUp(const QString& name);
	void moveWatchletDown(const QString& name);

signals:
	void configKeyChanged();
	void displayUnaddedChanged();

private slots:
	void reload();
	void handleConfigChanged();

private:
	sowatch::ConfigKey *_config;
	bool _unadded;
	QStringList _list;
	QMap<QString, sowatch::WatchletPluginInterface::WatchletInfo> _info;
	QSet<QString> _enabled;
};

#endif // WATCHLETSMODEL_H