rename removeDevice to removeThing
parent
553717a37e
commit
faac3d2de4
|
|
@ -196,13 +196,13 @@ void DeviceManager::notificationReceived(const QVariantMap &data)
|
|||
} else if (notification == "Devices.DeviceRemoved") {
|
||||
QUuid deviceId = data.value("params").toMap().value("deviceId").toUuid();
|
||||
// qDebug() << "JsonRpc: Notification: Device removed" << deviceId.toString();
|
||||
Device *device = m_devices->getDevice(deviceId);
|
||||
if (!device) {
|
||||
Device *thing = m_devices->getDevice(deviceId);
|
||||
if (!thing) {
|
||||
qWarning() << "Received a DeviceRemoved notification for a device we don't know!";
|
||||
return;
|
||||
}
|
||||
m_devices->removeDevice(device);
|
||||
device->deleteLater();
|
||||
m_devices->removeThing(thing);
|
||||
thing->deleteLater();
|
||||
} else if (notification == "Devices.DeviceChanged") {
|
||||
QUuid deviceId = data.value("params").toMap().value("device").toMap().value("id").toUuid();
|
||||
// qDebug() << "Device changed notification" << deviceId << data.value("params").toMap();
|
||||
|
|
@ -401,10 +401,10 @@ void DeviceManager::addDeviceResponse(int commandId, const QVariantMap ¶ms)
|
|||
emit addDeviceReply(commandId, params);
|
||||
}
|
||||
|
||||
void DeviceManager::removeDeviceResponse(int commandId, const QVariantMap ¶ms)
|
||||
void DeviceManager::removeThingResponse(int commandId, const QVariantMap ¶ms)
|
||||
{
|
||||
qDebug() << "Device removed response" << params;
|
||||
emit removeDeviceReply(commandId, params);
|
||||
qDebug() << "Thing removed response" << params;
|
||||
emit removeThingReply(commandId, params);
|
||||
}
|
||||
|
||||
void DeviceManager::pairDeviceResponse(int commandId, const QVariantMap ¶ms)
|
||||
|
|
@ -527,16 +527,16 @@ int DeviceManager::confirmPairing(const QUuid &pairingTransactionId, const QStri
|
|||
return m_jsonClient->sendCommand("Devices.ConfirmPairing", params, this, "confirmPairingResponse");
|
||||
}
|
||||
|
||||
int DeviceManager::removeDevice(const QUuid &deviceId, RemovePolicy removePolicy)
|
||||
int DeviceManager::removeThing(const QUuid &thingId, DeviceManager::RemovePolicy policy)
|
||||
{
|
||||
qDebug() << "JsonRpc: delete device" << deviceId.toString();
|
||||
qDebug() << "JsonRpc: delete device" << thingId.toString();
|
||||
QVariantMap params;
|
||||
params.insert("deviceId", deviceId.toString());
|
||||
if (removePolicy != RemovePolicyNone) {
|
||||
params.insert("deviceId", thingId.toString());
|
||||
if (policy != RemovePolicyNone) {
|
||||
QMetaEnum policyEnum = QMetaEnum::fromType<DeviceManager::RemovePolicy>();
|
||||
params.insert("removePolicy", policyEnum.valueToKey(removePolicy));
|
||||
params.insert("removePolicy", policyEnum.valueToKey(policy));
|
||||
}
|
||||
return m_jsonClient->sendCommand("Devices.RemoveConfiguredDevice", params, this, "removeDeviceResponse");
|
||||
return m_jsonClient->sendCommand("Devices.RemoveConfiguredDevice", params, this, "removeThingResponse");
|
||||
}
|
||||
|
||||
int DeviceManager::editDevice(const QUuid &deviceId, const QString &name)
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public:
|
|||
Q_INVOKABLE int pairDiscoveredDevice(const QUuid &deviceClassId, const QUuid &deviceDescriptorId, const QVariantList &deviceParams, const QString &name);
|
||||
Q_INVOKABLE int rePairDevice(const QUuid &deviceId, const QVariantList &deviceParams, const QString &name = QString());
|
||||
Q_INVOKABLE int confirmPairing(const QUuid &pairingTransactionId, const QString &secret = QString(), const QString &username = QString());
|
||||
Q_INVOKABLE int removeDevice(const QUuid &deviceId, RemovePolicy policy = RemovePolicyNone);
|
||||
Q_INVOKABLE int removeThing(const QUuid &thingId, RemovePolicy policy = RemovePolicyNone);
|
||||
Q_INVOKABLE int editDevice(const QUuid &deviceId, const QString &name);
|
||||
Q_INVOKABLE int setDeviceSettings(const QUuid &deviceId, const QVariantList &settings);
|
||||
Q_INVOKABLE int reconfigureDevice(const QUuid &deviceId, const QVariantList &deviceParams);
|
||||
|
|
@ -118,7 +118,7 @@ private:
|
|||
Q_INVOKABLE void getPluginConfigResponse(int commandId, const QVariantMap ¶ms);
|
||||
Q_INVOKABLE void getConfiguredDevicesResponse(int commandId, const QVariantMap ¶ms);
|
||||
Q_INVOKABLE void addDeviceResponse(int commandId, const QVariantMap ¶ms);
|
||||
Q_INVOKABLE void removeDeviceResponse(int commandId, const QVariantMap ¶ms);
|
||||
Q_INVOKABLE void removeThingResponse(int commandId, const QVariantMap ¶ms);
|
||||
Q_INVOKABLE void pairDeviceResponse(int commandId, const QVariantMap ¶ms);
|
||||
Q_INVOKABLE void confirmPairingResponse(int commandId, const QVariantMap ¶ms);
|
||||
Q_INVOKABLE void setPluginConfigResponse(int commandId, const QVariantMap ¶ms);
|
||||
|
|
@ -142,7 +142,7 @@ signals:
|
|||
void pairDeviceReply(int commandId, const QVariantMap ¶ms);
|
||||
void confirmPairingReply(int commandId, const QVariantMap ¶ms);
|
||||
void addDeviceReply(int commandId, const QVariantMap ¶ms);
|
||||
void removeDeviceReply(int commandId, const QVariantMap ¶ms);
|
||||
void removeThingReply(int commandId, const QVariantMap ¶ms);
|
||||
void savePluginConfigReply(int commandId, const QVariantMap ¶ms);
|
||||
void editDeviceReply(int commandId, const QVariantMap ¶ms);
|
||||
void reconfigureDeviceReply(int commandId, const QVariantMap ¶ms);
|
||||
|
|
|
|||
|
|
@ -126,15 +126,15 @@ void Devices::addDevice(Device *device)
|
|||
emit thingAdded(device);
|
||||
}
|
||||
|
||||
void Devices::removeDevice(Device *device)
|
||||
void Devices::removeThing(Device *thing)
|
||||
{
|
||||
int index = m_things.indexOf(device);
|
||||
int index = m_things.indexOf(thing);
|
||||
beginRemoveRows(QModelIndex(), index, index);
|
||||
qDebug() << "Devices: removed device" << device->name();
|
||||
qDebug() << "Removed thing" << thing->name();
|
||||
m_things.takeAt(index)->deleteLater();
|
||||
endRemoveRows();
|
||||
emit countChanged();
|
||||
emit thingRemoved(device);
|
||||
emit thingRemoved(thing);
|
||||
}
|
||||
|
||||
void Devices::clearModel()
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public:
|
|||
QVariant data(const QModelIndex & index, int role = RoleName) const;
|
||||
|
||||
void addDevice(Device *device);
|
||||
void removeDevice(Device *device);
|
||||
void removeThing(Device *thing);
|
||||
|
||||
void clearModel();
|
||||
|
||||
|
|
|
|||
|
|
@ -158,6 +158,7 @@ void registerQmlTypes() {
|
|||
|
||||
qmlRegisterType<Engine>(uri, 1, 0, "Engine");
|
||||
|
||||
qmlRegisterUncreatableType<DeviceManager>(uri, 1, 0, "ThingManager", "Can't create this in QML. Get it from the Engine.");
|
||||
qmlRegisterUncreatableType<DeviceManager>(uri, 1, 0, "DeviceManager", "Can't create this in QML. Get it from the Engine.");
|
||||
qmlRegisterUncreatableType<JsonRpcClient>(uri, 1, 0, "JsonRpcClient", "Can't create this in QML. Get it from the Engine.");
|
||||
qmlRegisterUncreatableType<NymeaConnection>(uri, 1, 0, "NymeaConnection", "Can't create this in QML. Get it from the Engine.");
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
<file>ui/components/MainPageTabButton.qml</file>
|
||||
<file>ui/components/AutoSizeMenu.qml</file>
|
||||
<file>ui/components/EmptyViewPlaceholder.qml</file>
|
||||
<file>ui/components/RemoveDeviceMethodDialog.qml</file>
|
||||
<file>ui/components/RemoveThingMethodDialog.qml</file>
|
||||
<file>ui/components/MainPageTile.qml</file>
|
||||
<file>ui/components/BusyOverlay.qml</file>
|
||||
<file>ui/components/SwipeDelegateGroup.qml</file>
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ Dialog {
|
|||
text: qsTr("Remove all those rules")
|
||||
progressive: false
|
||||
onClicked: {
|
||||
engine.deviceManager.removeDevice(root.device.id, DeviceManager.RemovePolicyCascade)
|
||||
engine.thingManager.removeThing(root.device.id, DeviceManager.RemovePolicyCascade)
|
||||
root.close()
|
||||
root.destroy();
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ Dialog {
|
|||
Layout.fillWidth: true
|
||||
progressive: false
|
||||
onClicked: {
|
||||
engine.deviceManager.removeDevice(root.device.id, DeviceManager.RemovePolicyUpdate)
|
||||
engine.thingManager.removeThing(root.device.id, DeviceManager.RemovePolicyUpdate)
|
||||
root.close()
|
||||
root.destroy();
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ SettingsPageBase {
|
|||
}
|
||||
|
||||
function deleteThing() {
|
||||
engine.deviceManager.removeDevice(root.device.id)
|
||||
engine.thingManager.removeThing(root.device.id)
|
||||
}
|
||||
|
||||
function reconfigureThing() {
|
||||
|
|
@ -100,8 +100,8 @@ SettingsPageBase {
|
|||
}
|
||||
|
||||
Connections {
|
||||
target: engine.deviceManager
|
||||
onRemoveDeviceReply: {
|
||||
target: engine.thingManager
|
||||
onRemoveThingReply: {
|
||||
switch (params.deviceError) {
|
||||
case "DeviceErrorNoError":
|
||||
pageStack.pop();
|
||||
|
|
@ -314,7 +314,7 @@ SettingsPageBase {
|
|||
|
||||
Component {
|
||||
id: removeMethodComponent
|
||||
RemoveDeviceMethodDialog {
|
||||
RemoveThingMethodDialog {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,23 +56,23 @@ Page {
|
|||
|
||||
QtObject {
|
||||
id: d
|
||||
property var deviceToRemove: null
|
||||
property var thingToRemove: null
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: engine.deviceManager
|
||||
onRemoveDeviceReply: {
|
||||
if (!d.deviceToRemove) {
|
||||
onRemoveThingReply: {
|
||||
if (!d.thingToRemove) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (params.deviceError) {
|
||||
case "DeviceErrorNoError":
|
||||
d.deviceToRemove = null;
|
||||
d.thingToRemove = null;
|
||||
return;
|
||||
case "DeviceErrorDeviceInRule":
|
||||
var removeMethodComponent = Qt.createComponent(Qt.resolvedUrl("../components/RemoveDeviceMethodDialog.qml"))
|
||||
var popup = removeMethodComponent.createObject(root, {device: d.deviceToRemove, rulesList: params["ruleIds"]});
|
||||
var removeMethodComponent = Qt.createComponent(Qt.resolvedUrl("../components/RemoveTThingMethodDialog.qml"))
|
||||
var popup = removeMethodComponent.createObject(root, {device: d.thingToRemove, rulesList: params["ruleIds"]});
|
||||
popup.open();
|
||||
return;
|
||||
default:
|
||||
|
|
@ -112,8 +112,8 @@ Page {
|
|||
pageStack.push(Qt.resolvedUrl("ConfigureThingPage.qml"), {device: device})
|
||||
}
|
||||
onDeleteClicked: {
|
||||
d.deviceToRemove = device;
|
||||
engine.deviceManager.removeDevice(d.deviceToRemove.id)
|
||||
d.thingToRemove = device;
|
||||
engine.thingManager.removeThing(d.thingToRemove.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue