1/*
2 * BluezQt - Asynchronous Bluez wrapper library
3 *
4 * SPDX-FileCopyrightText: 2014-2015 David Rosca <nowrep@gmail.com>
5 *
6 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8
9#ifndef DECLARATIVEMANAGER_H
10#define DECLARATIVEMANAGER_H
11
12#include <QHash>
13#include <QQmlEngine>
14#include <QQmlListProperty>
15
16#include "manager.h"
17
18class DeclarativeDevice;
19class DeclarativeAdapter;
20
21class DeclarativeManager : public BluezQt::Manager
22{
23 Q_OBJECT
24 QML_NAMED_ELEMENT(Manager)
25 QML_SINGLETON
26 Q_PROPERTY(DeclarativeAdapter *usableAdapter READ usableAdapter NOTIFY usableAdapterChanged)
27 Q_PROPERTY(QQmlListProperty<DeclarativeAdapter> adapters READ declarativeAdapters NOTIFY adaptersChanged)
28 Q_PROPERTY(QQmlListProperty<DeclarativeDevice> devices READ declarativeDevices NOTIFY devicesChanged)
29
30public:
31 explicit DeclarativeManager(QObject *parent = nullptr);
32
33 DeclarativeAdapter *usableAdapter() const;
34 QQmlListProperty<DeclarativeAdapter> declarativeAdapters();
35 QQmlListProperty<DeclarativeDevice> declarativeDevices();
36
37 DeclarativeAdapter *declarativeAdapterFromPtr(BluezQt::AdapterPtr ptr) const;
38 DeclarativeDevice *declarativeDeviceFromPtr(BluezQt::DevicePtr ptr) const;
39
40 QHash<QString, DeclarativeAdapter *> m_adapters;
41 QHash<QString, DeclarativeDevice *> m_devices;
42
43public Q_SLOTS:
44 DeclarativeAdapter *adapterForAddress(const QString &address) const;
45 DeclarativeAdapter *adapterForUbi(const QString &ubi) const;
46 DeclarativeDevice *deviceForAddress(const QString &address) const;
47 DeclarativeDevice *deviceForUbi(const QString &ubi) const;
48
49Q_SIGNALS:
50 void initFinished();
51 void initError(const QString &errorText);
52 void adapterAdded(DeclarativeAdapter *adapter);
53 void adapterRemoved(DeclarativeAdapter *adapter);
54 void adapterChanged(DeclarativeAdapter *adapter);
55 void deviceAdded(DeclarativeDevice *device);
56 void deviceRemoved(DeclarativeDevice *device);
57 void deviceChanged(DeclarativeDevice *device);
58 void usableAdapterChanged(DeclarativeAdapter *adapter);
59
60 void adaptersChanged(QQmlListProperty<DeclarativeAdapter> adapters);
61 void devicesChanged(QQmlListProperty<DeclarativeDevice> devices);
62
63private Q_SLOTS:
64 void initJobResult(BluezQt::InitManagerJob *job);
65
66 void slotAdapterAdded(BluezQt::AdapterPtr adapter);
67 void slotAdapterRemoved(BluezQt::AdapterPtr adapter);
68 void slotDeviceAdded(BluezQt::DevicePtr device);
69 void slotDeviceRemoved(BluezQt::DevicePtr device);
70 void slotUsableAdapterChanged(BluezQt::AdapterPtr adapter);
71};
72
73#endif // DECLARATIVEMANAGER_H
74

source code of bluez-qt/src/imports/declarativemanager.h