forked from qt-creator/qt-creator
QmlDesigner: Fix ComboBox for raw strings
Change-Id: Ie35bda95290042f2faaf938ee67b6ee02e8c55b1 Reviewed-by: Henning Gründl <henning.gruendl@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -38,6 +38,10 @@ StudioControls.ComboBox {
|
|||||||
enum ValueType { String, Integer, Enum }
|
enum ValueType { String, Integer, Enum }
|
||||||
property int valueType: ComboBox.ValueType.Enum
|
property int valueType: ComboBox.ValueType.Enum
|
||||||
|
|
||||||
|
onModelChanged: colorLogic.invalidate()
|
||||||
|
|
||||||
|
// This is available in all editors.
|
||||||
|
|
||||||
onValueTypeChanged: {
|
onValueTypeChanged: {
|
||||||
if (comboBox.valueType === ComboBox.ValueType.Integer)
|
if (comboBox.valueType === ComboBox.ValueType.Integer)
|
||||||
comboBox.useInteger = true
|
comboBox.useInteger = true
|
||||||
@@ -97,28 +101,34 @@ StudioControls.ComboBox {
|
|||||||
comboBox.valueFromBackendChanged()
|
comboBox.valueFromBackendChanged()
|
||||||
} else {
|
} else {
|
||||||
switch (comboBox.valueType) {
|
switch (comboBox.valueType) {
|
||||||
case ComboBox.ValueType.String:
|
case ComboBox.ValueType.String:
|
||||||
if (comboBox.currentText !== comboBox.backendValue.value)
|
if (comboBox.currentText !== comboBox.backendValue.value) {
|
||||||
comboBox.currentText = comboBox.backendValue.value
|
var index = comboBox.find(comboBox.backendValue.value)
|
||||||
break
|
|
||||||
case ComboBox.ValueType.Integer:
|
|
||||||
if (comboBox.currentIndex !== comboBox.backendValue.value)
|
|
||||||
comboBox.currentIndex = comboBox.backendValue.value
|
|
||||||
break
|
|
||||||
case ComboBox.ValueType.Enum:
|
|
||||||
default:
|
|
||||||
var enumString = comboBox.backendValue.enumeration
|
|
||||||
|
|
||||||
if (enumString === "")
|
|
||||||
enumString = comboBox.backendValue.value
|
|
||||||
|
|
||||||
var index = comboBox.find(enumString)
|
|
||||||
|
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
index = 0
|
index = 0
|
||||||
|
|
||||||
if (index !== comboBox.currentIndex)
|
if (index !== comboBox.currentIndex)
|
||||||
comboBox.currentIndex = index
|
comboBox.currentIndex = index
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case ComboBox.ValueType.Integer:
|
||||||
|
if (comboBox.currentIndex !== comboBox.backendValue.value)
|
||||||
|
comboBox.currentIndex = comboBox.backendValue.value
|
||||||
|
break
|
||||||
|
case ComboBox.ValueType.Enum:
|
||||||
|
default:
|
||||||
|
var enumString = comboBox.backendValue.enumeration
|
||||||
|
|
||||||
|
if (enumString === "")
|
||||||
|
enumString = comboBox.backendValue.value
|
||||||
|
|
||||||
|
index = comboBox.find(enumString)
|
||||||
|
|
||||||
|
if (index < 0)
|
||||||
|
index = 0
|
||||||
|
|
||||||
|
if (index !== comboBox.currentIndex)
|
||||||
|
comboBox.currentIndex = index
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,15 +147,15 @@ StudioControls.ComboBox {
|
|||||||
return
|
return
|
||||||
|
|
||||||
switch (comboBox.valueType) {
|
switch (comboBox.valueType) {
|
||||||
case ComboBox.ValueType.String:
|
case ComboBox.ValueType.String:
|
||||||
comboBox.backendValue.value = comboBox.currentText
|
comboBox.backendValue.value = comboBox.currentText
|
||||||
break
|
break
|
||||||
case ComboBox.ValueType.Integer:
|
case ComboBox.ValueType.Integer:
|
||||||
comboBox.backendValue.value = comboBox.currentIndex
|
comboBox.backendValue.value = comboBox.currentIndex
|
||||||
break
|
break
|
||||||
case ComboBox.ValueType.Enum:
|
case ComboBox.ValueType.Enum:
|
||||||
default:
|
default:
|
||||||
comboBox.backendValue.setEnumeration(comboBox.scope, comboBox.currentText)
|
comboBox.backendValue.setEnumeration(comboBox.scope, comboBox.currentText)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user