summaryrefslogtreecommitdiff
path: root/libsowatch/watchletsmodel.h
blob: 3bbabf9158e93e796790d8ab833a242141dd0bc9 (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
53
54
55
56
57
58
59
60
#ifndef SOWATCH_WATCHLETSMODEL_H
#define SOWATCH_WATCHLETSMODEL_H

#include <QtCore/QAbstractListModel>

#include "watchlet.h"
#include "watchletplugininterface.h"

namespace sowatch
{

class WatchletsModel : public QAbstractListModel
{
	Q_OBJECT
	Q_PROPERTY(QString watchModel READ watchModel WRITE setWatchModel NOTIFY watchModelChanged)

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

	enum DataRoles {
		ObjectRole = Qt::UserRole,
		TitleRole = Qt::DisplayRole,
		IconRole = Qt::DecorationRole
	};

	QString watchModel() const;
	void setWatchModel(const QString& s);

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

	int size() const;
	Watchlet * at(int position) const;

	void add(Watchlet *w);
	void insert(int position, Watchlet *w);
	void move(const Watchlet *w, int to);
	void move(int position, int to);
	void remove(const Watchlet *w);
	void remove(int position);

signals:
	void watchModelChanged();
	void modelChanged();

protected:
	typedef WatchletPluginInterface::WatchletInfo WatchletInfo;

	WatchletInfo getInfoForWatchlet(const Watchlet *w);

private:
	QString _watchModel;
	QList<Watchlet*> _list;
	QList<WatchletInfo> _info;

};

}

#endif // WATCHLETSMODEL_H