summaryrefslogtreecommitdiff
path: root/src/widgetinfomodel.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgetinfomodel.h')
-rw-r--r--src/widgetinfomodel.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/widgetinfomodel.h b/src/widgetinfomodel.h
new file mode 100644
index 0000000..6b30a91
--- /dev/null
+++ b/src/widgetinfomodel.h
@@ -0,0 +1,46 @@
+#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;
+
+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