blob: 0fef3bbfd7303bae455c01ae748812d1a497608a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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
|