Commit 001b93d9 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.PropertyEditor: Fix ComboBox



We have to wait until the model is properly set until we react
to currentTextChanged. We also have to guard against binding loops.

Task-number: QTCREATORBUG-12257
Change-Id: Id602f6f192962e83a6166bf24a0711b22baa7868
Reviewed-by: default avatarMarco Bubke <marco.bubke@digia.com>
parent e3ddc5ff
......@@ -41,33 +41,53 @@ Controls.ComboBox {
property bool useInteger: false
property bool __isCompleted: false
ColorLogic {
id: colorLogic
backendValue: comboBox.backendValue
onValueFromBackendChanged: {
if (!comboBox.useInt) {
invalidate();
}
function invalidate() {
if (!comboBox.useInteger) {
var enumString = comboBox.backendValue.enumeration;
if (enumString === "")
enumString = comboBox.backendValue.value
comboBox.currentIndex = comboBox.find(enumString);
var index = comboBox.find(enumString)
if (index !== comboBox.currentIndex)
comboBox.currentIndex = comboBox.find(enumString)
} else {
comboBox.currentIndex = backendValue.value
if (comboBox.currentIndex !== backendValue.value)
comboBox.currentIndex = backendValue.value
}
}
}
onCurrentTextChanged: {
if (!__isCompleted)
return;
if (backendValue === undefined)
return;
if (!comboBox.useInt) {
if (!comboBox.useInteger) {
backendValue.setEnumeration(comboBox.scope, comboBox.currentText);
} else {
print("useint" + comboBox.currentIndex)
backendValue.value = comboBox.currentIndex;
}
}
Component.onCompleted: {
colorLogic.invalidate()
__isCompleted = true;
}
style: CustomComboBoxStyle {
textColor: comboBox.textColor
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment