-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservicesmodel.h
47 lines (35 loc) · 1.25 KB
/
servicesmodel.h
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
#ifndef SERVICESMODEL_H
#define SERVICESMODEL_H
#include <QAbstractListModel>
#include <QPointer>
class QLowEnergyService;
class QLowEnergyController;
class ServicesModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(bool running READ isRunning NOTIFY runningChanged)
Q_PROPERTY(bool connected READ isConnected NOTIFY connectedChanged)
Q_PROPERTY(QString errorString READ errorString NOTIFY errorOccurred)
public:
explicit ServicesModel(QObject *parent = nullptr);
bool isRunning() const;
bool isConnected() const;
QString errorString() const;
Q_INVOKABLE void update(const QString &deviceAddress);
Q_INVOKABLE QObject *service(const QString &serviceUuid) const;
signals:
void runningChanged(bool running);
void connectedChanged(bool connected);
void errorOccurred();
private:
void setRunning(bool running);
void setConnected(bool connected);
int rowCount(const QModelIndex &parent) const final;
QVariant data(const QModelIndex &index, int role) const final;
QHash<int, QByteArray> roleNames() const final;
bool m_running = false;
bool m_connected = false;
QVector<QLowEnergyService *> m_services;
QPointer<QLowEnergyController> m_controller;
};
#endif // SERVICESMODEL_H