File indexing completed on 2024-05-12 03:53:11
0001 /* 0002 * BluezQt - Asynchronous Bluez wrapper library 0003 * 0004 * SPDX-FileCopyrightText: 2014-2015 David Rosca <nowrep@gmail.com> 0005 * 0006 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 0009 #ifndef DECLARATIVEMANAGER_H 0010 #define DECLARATIVEMANAGER_H 0011 0012 #include <QHash> 0013 #include <QQmlListProperty> 0014 0015 #include "manager.h" 0016 0017 class DeclarativeDevice; 0018 class DeclarativeAdapter; 0019 0020 class DeclarativeManager : public BluezQt::Manager 0021 { 0022 Q_OBJECT 0023 Q_PROPERTY(DeclarativeAdapter *usableAdapter READ usableAdapter NOTIFY usableAdapterChanged) 0024 Q_PROPERTY(QQmlListProperty<DeclarativeAdapter> adapters READ declarativeAdapters NOTIFY adaptersChanged) 0025 Q_PROPERTY(QQmlListProperty<DeclarativeDevice> devices READ declarativeDevices NOTIFY devicesChanged) 0026 0027 public: 0028 explicit DeclarativeManager(QObject *parent = nullptr); 0029 0030 DeclarativeAdapter *usableAdapter() const; 0031 QQmlListProperty<DeclarativeAdapter> declarativeAdapters(); 0032 QQmlListProperty<DeclarativeDevice> declarativeDevices(); 0033 0034 DeclarativeAdapter *declarativeAdapterFromPtr(BluezQt::AdapterPtr ptr) const; 0035 DeclarativeDevice *declarativeDeviceFromPtr(BluezQt::DevicePtr ptr) const; 0036 0037 QHash<QString, DeclarativeAdapter *> m_adapters; 0038 QHash<QString, DeclarativeDevice *> m_devices; 0039 0040 public Q_SLOTS: 0041 DeclarativeAdapter *adapterForAddress(const QString &address) const; 0042 DeclarativeAdapter *adapterForUbi(const QString &ubi) const; 0043 DeclarativeDevice *deviceForAddress(const QString &address) const; 0044 DeclarativeDevice *deviceForUbi(const QString &ubi) const; 0045 0046 Q_SIGNALS: 0047 void initFinished(); 0048 void initError(const QString &errorText); 0049 void adapterAdded(DeclarativeAdapter *adapter); 0050 void adapterRemoved(DeclarativeAdapter *adapter); 0051 void adapterChanged(DeclarativeAdapter *adapter); 0052 void deviceAdded(DeclarativeDevice *device); 0053 void deviceRemoved(DeclarativeDevice *device); 0054 void deviceChanged(DeclarativeDevice *device); 0055 void usableAdapterChanged(DeclarativeAdapter *adapter); 0056 0057 void adaptersChanged(QQmlListProperty<DeclarativeAdapter> adapters); 0058 void devicesChanged(QQmlListProperty<DeclarativeDevice> devices); 0059 0060 private Q_SLOTS: 0061 void initJobResult(BluezQt::InitManagerJob *job); 0062 0063 void slotAdapterAdded(BluezQt::AdapterPtr adapter); 0064 void slotAdapterRemoved(BluezQt::AdapterPtr adapter); 0065 void slotDeviceAdded(BluezQt::DevicePtr device); 0066 void slotDeviceRemoved(BluezQt::DevicePtr device); 0067 void slotUsableAdapterChanged(BluezQt::AdapterPtr adapter); 0068 }; 0069 0070 #endif // DECLARATIVEMANAGER_H