summaryrefslogtreecommitdiff
path: root/libsowatch/watchletsmodel.h
diff options
context:
space:
mode:
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