summaryrefslogtreecommitdiff
path: root/libsowatch/watchletsmodel.h
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2013-05-11 19:17:07 +0200
committerJavier S. Pedro <maemo@javispedro.com>2013-05-11 19:17:07 +0200
commitbf083973efd101e05d75882b63aad9bdfa37dfbc (patch)
treec07769c2a82e4b5bba8d3d02558eb4c69a531001 /libsowatch/watchletsmodel.h
parentbc899047089079dde323e84a57efe46ce6af653d (diff)
downloadsowatch-bf083973efd101e05d75882b63aad9bdfa37dfbc.tar.gz
sowatch-bf083973efd101e05d75882b63aad9bdfa37dfbc.zip
store watchlets in model
Diffstat (limited to 'libsowatch/watchletsmodel.h')
-rw-r--r--libsowatch/watchletsmodel.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/libsowatch/watchletsmodel.h b/libsowatch/watchletsmodel.h
new file mode 100644
index 0000000..cdb6be4
--- /dev/null
+++ b/libsowatch/watchletsmodel.h
@@ -0,0 +1,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