mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
[QgsQuick] Fix of value relation widget
Due to last changes in passing style object, styling property has been updated (widget had 0 height without fix). Fixed case when (current) value is not matching value relation map (it generated error while creating component).
This commit is contained in:
parent
0566f2c516
commit
a067a334cd
@ -28,7 +28,7 @@ Item {
|
||||
|
||||
id: fieldItem
|
||||
enabled: !readOnly
|
||||
height: customStyle.height
|
||||
height: customStyle.fields.height
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
@ -51,16 +51,18 @@ Item {
|
||||
|
||||
Component.onCompleted: {
|
||||
currentMap = QgsQuick.Utils.createValueRelationCache(config)
|
||||
var valueInKeys = false
|
||||
var keys = Object.keys(currentMap)
|
||||
for(var i=0; i< keys.length; i++)
|
||||
{
|
||||
var currentKey = keys[i]
|
||||
if (value == currentKey) valueInKeys = true
|
||||
var valueText = currentMap[currentKey]
|
||||
listModel.append( { text: valueText } )
|
||||
reversedMap[valueText] = currentKey;
|
||||
}
|
||||
model = listModel
|
||||
currentIndex = find(currentMap[value])
|
||||
currentIndex = valueInKeys ? find(currentMap[value]) : -1
|
||||
}
|
||||
|
||||
onCurrentTextChanged: {
|
||||
@ -69,7 +71,7 @@ Item {
|
||||
|
||||
// Workaround to get a signal when the value has changed
|
||||
onCurrentValueChanged: {
|
||||
currentIndex = find(currentMap[value])
|
||||
currentIndex = currentMap ? find(currentMap[value]) : -1
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user