summaryrefslogtreecommitdiff
path: root/rockwork/pebbles.h
diff options
context:
space:
mode:
Diffstat (limited to 'rockwork/pebbles.h')
-rw-r--r--rockwork/pebbles.h56
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