From 39fa663cd08bd2b7d46ed170d49ac794c531c42e Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Fri, 10 Aug 2012 16:06:14 +0200 Subject: watchlet edit UI --- sowatchui/watchletsmodel.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 sowatchui/watchletsmodel.h (limited to 'sowatchui/watchletsmodel.h') diff --git a/sowatchui/watchletsmodel.h b/sowatchui/watchletsmodel.h new file mode 100644 index 0000000..e0c2c62 --- /dev/null +++ b/sowatchui/watchletsmodel.h @@ -0,0 +1,52 @@ +#ifndef WATCHLETSMODEL_H +#define WATCHLETSMODEL_H + +#include + +#include + +class WatchletsModel : public QAbstractListModel +{ + Q_OBJECT + Q_PROPERTY(QString configKey READ configKey WRITE setConfigKey NOTIFY configKeyChanged) + Q_PROPERTY(bool displayUnadded READ displayUnadded WRITE setDisplayUnadded NOTIFY displayUnaddedChanged) + +public: + explicit WatchletsModel(QObject *parent = 0); + + enum DataRoles { + NameRole = Qt::UserRole + }; + + QString configKey() const; + void setConfigKey(const QString& configKey); + + bool displayUnadded() const; + void setDisplayUnadded(bool displayUnadded); + + int rowCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role) const; + +public slots: + void addWatchlet(const QString& name); + void removeWatchlet(const QString& name); + void moveWatchletUp(const QString& name); + void moveWatchletDown(const QString& name); + +signals: + void configKeyChanged(); + void displayUnaddedChanged(); + +private slots: + void reload(); + void handleConfigChanged(); + +private: + sowatch::ConfigKey *_config; + bool _unadded; + QStringList _list; + QMap _info; + QSet _enabled; +}; + +#endif // WATCHLETSMODEL_H -- cgit v1.2.3