summaryrefslogtreecommitdiff
path: root/src/widgetinfomodel.h
blob: 4b2a700468c4f0739ea13387f021eeadbb786ad9 (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 WIDGETINFOMODEL_H
#define WIDGETINFOMODEL_H

#include <QtCore/QAbstractListModel>
#include <MDConfGroup>

#include "widgetinfo.h"

class WidgetInfoModel : public QAbstractListModel
{
	Q_OBJECT

public:
	explicit WidgetInfoModel(const QString &settingsPrefix, QObject *parent = 0);

	enum Roles {
		UrlRole = Qt::UserRole,
		InvertRole,
		PageRole,
		SizeRole,
		PositionRole
	};

	QHash<int, QByteArray> roleNames() const;
	int rowCount(const QModelIndex &parent) const;
	QVariant data(const QModelIndex &index, int role) const;

	QList<WidgetInfo> toList() const;

signals:

public slots:
	void reload();
	int addWidget(const QUrl &url, int page, WidgetInfo::WidgetPosition pos, WidgetInfo::WidgetSize size);
	void removeWidget(int widgetId);

private:
	int findEmptySlot();

private slots:
	void handleSettingChanged(const QString &key);

private:
	MDConfGroup *_settings;
	QVector<WidgetInfo> _widgets;
};

#endif // WIDGETINFOMODEL_H