DeviceDiscovery is not using the Engine singleton any more
This commit is contained in:
parent
5f6a3f5f31
commit
b1338caf33
@ -43,16 +43,38 @@ void DeviceDiscovery::discoverDevices(const QUuid &deviceClassId, const QVariant
|
|||||||
endResetModel();
|
endResetModel();
|
||||||
emit countChanged();
|
emit countChanged();
|
||||||
|
|
||||||
|
if (!m_jsonRpcClient) {
|
||||||
|
qWarning() << "Cannot discover devices. No JsonRpcClient set";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!m_jsonRpcClient->connected()) {
|
||||||
|
qWarning() << "Cannot discover devices. JsonRpcClient not connected.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QVariantMap params;
|
QVariantMap params;
|
||||||
params.insert("deviceClassId", deviceClassId.toString());
|
params.insert("deviceClassId", deviceClassId.toString());
|
||||||
if (!discoveryParams.isEmpty()) {
|
if (!discoveryParams.isEmpty()) {
|
||||||
params.insert("discoveryParams", discoveryParams);
|
params.insert("discoveryParams", discoveryParams);
|
||||||
}
|
}
|
||||||
Engine::instance()->jsonRpcClient()->sendCommand("Devices.GetDiscoveredDevices", params, this, "discoverDevicesResponse");
|
m_jsonRpcClient->sendCommand("Devices.GetDiscoveredDevices", params, this, "discoverDevicesResponse");
|
||||||
m_busy = true;
|
m_busy = true;
|
||||||
emit busyChanged();
|
emit busyChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JsonRpcClient *DeviceDiscovery::jsonRpcClient() const
|
||||||
|
{
|
||||||
|
return m_jsonRpcClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceDiscovery::setJsonRpcClient(JsonRpcClient *jsonRpcClient)
|
||||||
|
{
|
||||||
|
if (m_jsonRpcClient != jsonRpcClient) {
|
||||||
|
m_jsonRpcClient = jsonRpcClient;
|
||||||
|
emit jsonRpcClientChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool DeviceDiscovery::busy() const
|
bool DeviceDiscovery::busy() const
|
||||||
{
|
{
|
||||||
return m_busy;
|
return m_busy;
|
||||||
|
|||||||
@ -4,9 +4,12 @@
|
|||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
||||||
|
#include "jsonrpc/jsonrpcclient.h"
|
||||||
|
|
||||||
class DeviceDiscovery : public QAbstractListModel
|
class DeviceDiscovery : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(JsonRpcClient* jsonRpcClient READ jsonRpcClient WRITE setJsonRpcClient)
|
||||||
Q_PROPERTY(bool busy READ busy NOTIFY busyChanged)
|
Q_PROPERTY(bool busy READ busy NOTIFY busyChanged)
|
||||||
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
|
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
|
||||||
public:
|
public:
|
||||||
@ -25,6 +28,9 @@ public:
|
|||||||
|
|
||||||
Q_INVOKABLE void discoverDevices(const QUuid &deviceClassId, const QVariantList &discoveryParams = {});
|
Q_INVOKABLE void discoverDevices(const QUuid &deviceClassId, const QVariantList &discoveryParams = {});
|
||||||
|
|
||||||
|
JsonRpcClient* jsonRpcClient() const;
|
||||||
|
void setJsonRpcClient(JsonRpcClient *jsonRpcClient);
|
||||||
|
|
||||||
bool busy() const;
|
bool busy() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@ -33,6 +39,7 @@ private slots:
|
|||||||
signals:
|
signals:
|
||||||
void busyChanged();
|
void busyChanged();
|
||||||
void countChanged();
|
void countChanged();
|
||||||
|
void jsonRpcClientChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class DeviceDescriptor {
|
class DeviceDescriptor {
|
||||||
@ -43,6 +50,7 @@ private:
|
|||||||
QString m_description;
|
QString m_description;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
JsonRpcClient *m_jsonRpcClient = nullptr;
|
||||||
bool m_busy = false;
|
bool m_busy = false;
|
||||||
|
|
||||||
bool contains(const QUuid &deviceDescriptorId) const;
|
bool contains(const QUuid &deviceDescriptorId) const;
|
||||||
|
|||||||
@ -61,6 +61,7 @@ Page {
|
|||||||
|
|
||||||
DeviceDiscovery {
|
DeviceDiscovery {
|
||||||
id: discovery
|
id: discovery
|
||||||
|
jsonRpcClient: Engine.jsonRpcClient
|
||||||
}
|
}
|
||||||
|
|
||||||
StackView {
|
StackView {
|
||||||
|
|||||||
Reference in New Issue
Block a user