Skip to content
Permalink
Browse files

[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).
  • Loading branch information
vsklencar authored and PeterPetrik committed May 7, 2019
1 parent 0566f2c commit a067a334cd1b18f122bb99e3fbe26c7483869988
Showing with 5 additions and 3 deletions.
  1. +5 −3 src/quickgui/plugin/editor/qgsquickvaluerelation.qml
@@ -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
}

}

0 comments on commit a067a33

Please sign in to comment.
You can’t perform that action at this time.