summaryrefslogtreecommitdiff
path: root/sowatchui/watchesmodel.h
blob: 396fc8d8ee36960166d11a48874e3660fb0f77eb (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
#ifndef WATCHESMODEL_H
#define WATCHESMODEL_H

#include <QAbstractListModel>

#include <sowatch.h>

#include "daemonproxy.h"

class WatchesModel : public QAbstractListModel
{
	Q_OBJECT
public:
	explicit WatchesModel(QObject *parent = 0);
	~WatchesModel();

	enum DataRoles {
		ObjectRole = Qt::UserRole,
		ConfigKeyRole,
		ConfigQmlUrlRole
	};

	int rowCount(const QModelIndex &parent) const;
	QVariant data(const QModelIndex &index, int role) const;
	bool removeRows(int row, int count, const QModelIndex &parent);

public slots:
	void addFoundWatch(const QVariantMap& info);

private slots:
	void reload();
	void handleConfigChanged();
	void handleSubkeyChanged(const QString& subkey);
	void handleWatchStatusChanged(const QString& watch, const QString& status);

private:
	int findRowByWatchId(const QString& id);
	bool isWatchIdActive(const QString& id) const;

private:
	sowatch::ConfigKey *_config;
	sowatch::ConfigKey *_active_watches;
	DaemonProxy *_daemon;
	QList<sowatch::ConfigKey*> _list;
	QMap<QString, QString> _status;
};

#endif // WATCHESMODEL_H