summaryrefslogtreecommitdiff
path: root/sowatchui/watchscannermodel.h
blob: 32701f7e938faf11c2d9f27dae7c0471163e0dd8 (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
#ifndef WATCHSCANNERMODEL_H
#define WATCHSCANNERMODEL_H

#include <QtCore/QAbstractListModel>

#include <sowatch.h>

class WatchScannerModel : public QAbstractListModel
{
	Q_OBJECT
	Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
	Q_PROPERTY(bool active READ active NOTIFY activeChanged)

public:
	explicit WatchScannerModel(QObject *parent = 0);
	~WatchScannerModel();

	enum DataRoles {
		ObjectRole = Qt::UserRole
	};

	bool enabled() const;
	void setEnabled(bool enabled);

	bool active() const;

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

signals:
	void activeChanged();

private slots:
	void handleWatchFound(const QVariantMap& info);
	void handleStarted();
	void handleFinished();
	void handleTimeout();

private:
	sowatch::WatchScanner *_scanner;
	QList<QVariantMap> _list;
	QTimer *_timer;
	bool _enabled;
	bool _active;
};

#endif // WATCHSCANNERMODEL_H