summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@qt.io>2020-01-17 13:35:08 +0100
committerDominik Holland <dominik.holland@qt.io>2020-01-21 16:03:15 +0100
commit5a37ae2620e7bb74760fe3ed435c1d5e1ce63232 (patch)
treecedc2b400ce7f9921acff2f9116e3d5959f73553
parent45317b232c926276555f8dc100be21988ea46405 (diff)
downloadqtivi-5a37ae2620e7bb74760fe3ed435c1d5e1ce63232.tar.gz
ivigenerator: Improve the autogenerated simulation
Because the simulationData contains only the data which has an annotation configuring the data in the qface file, it was possible that trying to access the settings for a property from the simulation returned 'undefined' which caused an QML warning giving this to C++. The generated code uses now a different structure to prevent checking the settings, when no settings are available. Change-Id: I3d2ade32195683a32d01af1852ffabe0cf0a39f2 Reviewed-by: Robert Griebl <robert.griebl@qt.io>
-rw-r--r--src/plugins/ivivehiclefunctions/vehiclefunctions_simulator/QIviConcreteWindowControlSimulation.qml77
-rw-r--r--src/tools/ivigenerator/templates/common/backend_simulation.qml.tpl28
2 files changed, 55 insertions, 50 deletions
diff --git a/src/plugins/ivivehiclefunctions/vehiclefunctions_simulator/QIviConcreteWindowControlSimulation.qml b/src/plugins/ivivehiclefunctions/vehiclefunctions_simulator/QIviConcreteWindowControlSimulation.qml
index 94e7d2b..770f847 100644
--- a/src/plugins/ivivehiclefunctions/vehiclefunctions_simulator/QIviConcreteWindowControlSimulation.qml
+++ b/src/plugins/ivivehiclefunctions/vehiclefunctions_simulator/QIviConcreteWindowControlSimulation.qml
@@ -140,45 +140,47 @@ QtObject {
function setHeaterMode(heaterMode, zone) {
- if (IviSimulator.checkSettings(settings["heaterMode"], heaterMode, zone)) {
- if (zone) {
- console.log("SIMULATION heaterMode for zone: " + zone + " changed to: " + heaterMode);
- backend.zones[zone].heaterMode = heaterMode
- } else {
- console.log("SIMULATION heaterMode changed to: " + heaterMode);
- backend.heaterMode = heaterMode
- }
- } else {
+ if ("heaterMode" in settings && !IviSimulator.checkSettings(settings["heaterMode"], heaterMode, zone)) {
console.error("SIMULATION changing heaterMode is not possible: provided: " + heaterMode + "constraint: " + IviSimulator.constraint(settings["heaterMode"]));
+ return;
+ }
+
+ if (zone) {
+ console.log("SIMULATION heaterMode for zone: " + zone + " changed to: " + heaterMode);
+ backend.zones[zone].heaterMode = heaterMode
+ } else {
+ console.log("SIMULATION heaterMode changed to: " + heaterMode);
+ backend.heaterMode = heaterMode
}
}
function setHeater(heater, zone) {
- if (IviSimulator.checkSettings(settings["heater"], heater, zone)) {
- console.log("SIMULATION heater changed to: " + heater);
- if (zone) {
- console.log("SIMULATION heater for zone: " + zone + " changed to: " + heater);
- backend.zones[zone].heater = heater
- } else {
- console.log("SIMULATION heater changed to: " + heater);
- backend.heater = heater
- }
- } else {
+ if ("heater" in settings && !IviSimulator.checkSettings(settings["heater"], heater, zone)) {
console.error("SIMULATION changing heater is not possible: provided: " + heater + "constraint: " + IviSimulator.constraint(settings["heater"]));
+ return;
+ }
+
+ if (zone) {
+ console.log("SIMULATION heater for zone: " + zone + " changed to: " + heater);
+ backend.zones[zone].heater = heater
+ } else {
+ console.log("SIMULATION heater changed to: " + heater);
+ backend.heater = heater
}
}
function setState(state, zone) {
- if (IviSimulator.checkSettings(settings["state"], state, zone)) {
- if (zone) {
- console.log("SIMULATION state for zone: " + zone + " changed to: " + state);
- backend.zones[zone].state = state
- } else {
- console.log("SIMULATION state changed to: " + state);
- backend.state = state
- }
- } else {
+ if ("state" in settings && !IviSimulator.checkSettings(settings["state"], state, zone)) {
console.error("SIMULATION changing state is not possible: provided: " + state + "constraint: " + IviSimulator.constraint(settings["state"]));
+ return;
+ }
+
+ if (zone) {
+ console.log("SIMULATION state for zone: " + zone + " changed to: " + state);
+ backend.zones[zone].state = state
+ } else {
+ console.log("SIMULATION state changed to: " + state);
+ backend.state = state
}
}
@@ -190,16 +192,17 @@ QtObject {
}
function setBlindState(blindState, zone) {
- if (IviSimulator.checkSettings(settings["blindState"], blindState, zone)) {
- if (zone) {
- console.log("SIMULATION blindState for zone: " + zone + " changed to: " + blindState);
- backend.zones[zone].blindState = blindState
- } else {
- console.log("SIMULATION blindState changed to: " + blindState);
- backend.blindState = blindState
- }
- } else {
+ if ("blindState" in settings && !IviSimulator.checkSettings(settings["blindState"], blindState, zone)) {
console.error("SIMULATION changing blindState is not possible: provided: " + blindState + "constraint: " + IviSimulator.constraint(settings["blindState"]));
+ return;
+ }
+
+ if (zone) {
+ console.log("SIMULATION blindState for zone: " + zone + " changed to: " + blindState);
+ backend.zones[zone].blindState = blindState
+ } else {
+ console.log("SIMULATION blindState changed to: " + blindState);
+ backend.blindState = blindState
}
}
}
diff --git a/src/tools/ivigenerator/templates/common/backend_simulation.qml.tpl b/src/tools/ivigenerator/templates/common/backend_simulation.qml.tpl
index 2cbbd11..1ee5e6b 100644
--- a/src/tools/ivigenerator/templates/common/backend_simulation.qml.tpl
+++ b/src/tools/ivigenerator/templates/common/backend_simulation.qml.tpl
@@ -70,26 +70,28 @@ QtObject {
{% if interface_zoned %}
function {{property|setter_name}}({{property}}, zone) {
- if (IviSimulator.checkSettings(settings["{{property}}"], {{property}}, zone)) {
- if (zone) {
- console.log(qLc{{interface|upperfirst}}, "SIMULATION {{ property }} for zone: " + zone + " changed to: " + {{property}});
- backend.zones[zone].{{property}} = {{property}}
- } else {
- console.log(qLc{{interface|upperfirst}}, "SIMULATION {{ property }} changed to: " + {{property}});
- backend.{{property}} = {{property}}
- }
- } else {
+ if ("{{property}}" in settings && !IviSimulator.checkSettings(settings["{{property}}"], {{property}}, zone)) {
console.error(qLc{{interface|upperfirst}}, "SIMULATION changing {{property}} is not possible: provided: " + {{property}} + " constraint: " + IviSimulator.constraint(settings["{{property}}"]));
+ return;
+ }
+
+ if (zone) {
+ console.log(qLc{{interface|upperfirst}}, "SIMULATION {{ property }} for zone: " + zone + " changed to: " + {{property}});
+ backend.zones[zone].{{property}} = {{property}}
+ } else {
+ console.log(qLc{{interface|upperfirst}}, "SIMULATION {{ property }} changed to: " + {{property}});
+ backend.{{property}} = {{property}}
}
}
{% else %}
function {{property|setter_name}}({{property}}) {
- if (IviSimulator.checkSettings(settings["{{property}}"], {{property}})) {
- console.log(qLc{{interface|upperfirst}}, "SIMULATION {{ property }} changed to: " + {{property}});
- backend.{{property}} = {{property}}
- } else {
+ if ("{{property}}" in settings && !IviSimulator.checkSettings(settings["{{property}}"], {{property}})) {
console.error(qLc{{interface|upperfirst}}, "SIMULATION changing {{property}} is not possible: provided: " + {{property}} + " constraint: " + IviSimulator.constraint(settings["{{property}}"]));
+ return;
}
+
+ console.log(qLc{{interface|upperfirst}}, "SIMULATION {{ property }} changed to: " + {{property}});
+ backend.{{property}} = {{property}}
}
{% endif %}
{% endfor %}