Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #8464 from elpaso/bugfix-20455-value-relation-mult…
…iple-rules

Emit valueChanged when a widget value changes as a consequence of ano…
  • Loading branch information
elpaso committed Nov 13, 2018
2 parents 5dab30b + d479b4d commit 798155c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/core/qgseditorwidgetwrapper.cpp
Expand Up @@ -68,7 +68,7 @@ void QgsEditorWidgetWrapper::setEnabled( bool enabled )

void QgsEditorWidgetWrapper::setFeature( const QgsFeature &feature )
{
mFormFeature = feature;
setFormFeature( feature );
setValue( feature.attribute( mFieldIdx ) );
}

Expand Down
10 changes: 10 additions & 0 deletions src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp
Expand Up @@ -212,6 +212,7 @@ void QgsValueRelationWidgetWrapper::widgetValueChanged( const QString &attribute
// Do nothing if the value has not changed
if ( attributeChanged )
{
QVariant oldValue( value( ) );
setFormFeatureAttribute( attribute, newValue );
// Update combos if the value used in the filter expression has changed
if ( QgsValueRelationFieldFormatter::expressionRequiresFormScope( mExpression )
Expand All @@ -220,6 +221,15 @@ void QgsValueRelationWidgetWrapper::widgetValueChanged( const QString &attribute
populate();
// Restore value
setValue( value( ) );
// If the value has changed as a result of another widget's value change,
// we need to emit the signal to make sure other dependent widgets are
// updated.
if ( oldValue != value() && fieldIdx() < formFeature().fields().count() )
{
QString attributeName( formFeature().fields().names().at( fieldIdx() ) );
setFormFeatureAttribute( attributeName, value( ) );
emitValueChanged( );
}
}
}
}
Expand Down

0 comments on commit 798155c

Please sign in to comment.