Merge PR #344: Allow removing childs which weren't autocreated

This commit is contained in:
Jenkins nymea 2020-03-26 19:35:51 +01:00
commit ad490ba00c
2 changed files with 9 additions and 3 deletions

View File

@ -57,10 +57,14 @@ Page {
Component.onCompleted: { Component.onCompleted: {
deviceMenu.addItem(menuEntryComponent.createObject(deviceMenu, {text: qsTr("Rename"), iconSource: "../images/edit.svg", functionName: "renameThing"})) deviceMenu.addItem(menuEntryComponent.createObject(deviceMenu, {text: qsTr("Rename"), iconSource: "../images/edit.svg", functionName: "renameThing"}))
if (!root.device.isChild) { // FIXME: This isn't entirely correct... we should have a way to know if a particular thing is in fact autocreated
// This check might be wrong for thingClasses with multiple create methods...
if (!root.device.isChild || root.deviceClass.createMethods !== ["auto"]) {
deviceMenu.addItem(menuEntryComponent.createObject(deviceMenu, {text: qsTr("Delete"), iconSource: "../images/delete.svg", functionName: "deleteThing"})) deviceMenu.addItem(menuEntryComponent.createObject(deviceMenu, {text: qsTr("Delete"), iconSource: "../images/delete.svg", functionName: "deleteThing"}))
} }
if (!root.device.isChild) { // FIXME: This isn't entirely correct... we should have a way to know if a particular thing is in fact autocreated
// This check might be wrong for thingClasses with multiple create methods...
if (!root.device.isChild || root.deviceClass.createMethods !== ["auto"]) {
deviceMenu.addItem(menuEntryComponent.createObject(deviceMenu, {text: qsTr("Reconfigure"), iconSource: "../images/configure.svg", functionName: "reconfigureThing"})) deviceMenu.addItem(menuEntryComponent.createObject(deviceMenu, {text: qsTr("Reconfigure"), iconSource: "../images/configure.svg", functionName: "reconfigureThing"}))
} }
} }

View File

@ -105,7 +105,9 @@ Page {
delegate: ThingDelegate { delegate: ThingDelegate {
device: deviceProxy.getDevice(model.id) device: deviceProxy.getDevice(model.id)
canDelete: !device.isChild // FIXME: This isn't entirely correct... we should have a way to know if a particular thing is in fact autocreated
// This check might be wrong for thingClasses with multiple create methods...
canDelete: !device.isChild && device.deviceClass.createMethods === ["auto"]
onClicked: { onClicked: {
print("clicked:", model.id) print("clicked:", model.id)
pageStack.push(Qt.resolvedUrl("ConfigureThingPage.qml"), {device: device}) pageStack.push(Qt.resolvedUrl("ConfigureThingPage.qml"), {device: device})