mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-15 12:35:56 +08:00
Replace manual function calls to updateCurrentIndex with an explicit binding
This is mostly in support of Uranium PR #165 . That changes SettingPropertyProvider so that the "properties" property does not always change. However, in general this is the more correct approach. Relates to CURA-2232
This commit is contained in:
parent
fc310f2732
commit
5a14c5e5ba
@ -87,18 +87,16 @@ SettingItem
|
|||||||
}
|
}
|
||||||
|
|
||||||
onActivated: { forceActiveFocus(); propertyProvider.setPropertyValue("value", definition.options[index].key) }
|
onActivated: { forceActiveFocus(); propertyProvider.setPropertyValue("value", definition.options[index].key) }
|
||||||
onModelChanged: updateCurrentIndex();
|
|
||||||
|
|
||||||
Connections
|
Binding
|
||||||
|
{
|
||||||
|
target: control
|
||||||
|
property: "currentIndex"
|
||||||
|
value:
|
||||||
{
|
{
|
||||||
target: propertyProvider
|
|
||||||
onPropertiesChanged: control.updateCurrentIndex()
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateCurrentIndex() {
|
|
||||||
// FIXME this needs to go away once 'resolve' is combined with 'value' in our data model.
|
// FIXME this needs to go away once 'resolve' is combined with 'value' in our data model.
|
||||||
var value;
|
var value;
|
||||||
if ((propertyProvider.properties.resolve != "None") && (stackLevel != 0) && (stackLevel != 1)) {
|
if ((propertyProvider.properties.resolve != "None") && (base.stackLevel != 0) && (base.stackLevel != 1)) {
|
||||||
// We have a resolve function. Indicates that the setting is not settable per extruder and that
|
// We have a resolve function. Indicates that the setting is not settable per extruder and that
|
||||||
// we have to choose between the resolved value (default) and the global value
|
// we have to choose between the resolved value (default) and the global value
|
||||||
// (if user has explicitly set this).
|
// (if user has explicitly set this).
|
||||||
@ -107,14 +105,14 @@ SettingItem
|
|||||||
value = propertyProvider.properties.value;
|
value = propertyProvider.properties.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var i = 0; i < definition.options.length; ++i) {
|
for(var i = 0; i < control.model.length; ++i) {
|
||||||
if(definition.options[i].key == value) {
|
if(control.model[i].key == value) {
|
||||||
currentIndex = i;
|
return i;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
currentIndex = -1;
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user