summaryrefslogtreecommitdiff
path: root/libsowatch/watchletsmodel.h
blob: cdb6be4f5caed73eb23ded2656c7acc17bdc0dd5 (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
#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

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

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

	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 modelChanged();

protected:
	typedef WatchletPluginInterface::WatchletInfo WatchletInfo;

	static WatchletInfo getInfoForWatchlet(const Watchlet *w);

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

};

}

#endif // WATCHLETSMODEL_H