Skip to content

Commit

Permalink
[QgsQuick] Fix of value relation widget
Browse files Browse the repository at this point in the history
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 a067a33
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/quickgui/plugin/editor/qgsquickvaluerelation.qml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Item {

id: fieldItem
enabled: !readOnly
height: customStyle.height
height: customStyle.fields.height
anchors {
left: parent.left
right: parent.right
Expand All @@ -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: {
Expand All @@ -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
}

}
Expand Down

0 comments on commit a067a33

Please sign in to comment.