diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2016-02-11 23:55:16 +0100 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2016-02-11 23:55:16 +0100 |
| commit | 29aaea2d80a9eb1715b6cddfac2d2aacf76358bd (patch) | |
| tree | 012795b6bec16c72f38d33cff46324c9a0225868 /rockwork/pebbles.h | |
launchpad ~mzanetti/rockwork/trunk r87
Diffstat (limited to 'rockwork/pebbles.h')
| -rw-r--r-- | rockwork/pebbles.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/rockwork/pebbles.h b/rockwork/pebbles.h new file mode 100644 index 0000000..0fef3bb --- /dev/null +++ b/rockwork/pebbles.h @@ -0,0 +1,56 @@ +#ifndef PEBBLES_H +#define PEBBLES_H + +#include <QObject> +#include <QAbstractListModel> +#include <QDBusServiceWatcher> +#include <QDBusObjectPath> + +class Pebble; +class QDBusInterface; + +class Pebbles : public QAbstractListModel +{ + Q_OBJECT + Q_PROPERTY(QString version READ version) + + Q_PROPERTY(int count READ rowCount NOTIFY countChanged) +public: + enum Roles { + RoleAddress, + RoleName, + RoleSerialNumber, + RoleConnected + }; + + Pebbles(QObject *parent = 0); + + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + QVariant data(const QModelIndex &index, int role) const override; + QHash<int, QByteArray> roleNames() const override; + + QString version() const; + + Q_INVOKABLE Pebble *get(int index) const; + int find(const QString &address) const; + + +signals: + void countChanged(); + +private slots: + void refresh(); + + void pebbleConnectedChanged(); + +private: + int find(const QDBusObjectPath &path) const; + static bool sortPebbles(Pebble *a, Pebble *b); + +private: + QDBusInterface *m_iface; + QList<Pebble*> m_pebbles; + QDBusServiceWatcher *m_watcher; +}; + +#endif // PEBBLES_H |
