fixes #30564 : Emit signal for value relation widget so other dependent widgets

could be updated
This commit is contained in:
Julien Cabieces 2019-07-11 16:00:52 +02:00
parent 956c6d694e
commit 540df6c0c0
2 changed files with 10 additions and 0 deletions

View File

@ -277,6 +277,11 @@ void QgsValueRelationWidgetWrapper::setFeature( const QgsFeature &feature )
setFormFeature( feature );
whileBlocking( this )->populate();
whileBlocking( this )->setValue( feature.attribute( fieldIdx() ) );
// As we block any signals, possible depending widgets will not being updated
// so we force emit signal once and for all
emitValueChanged();
// A bit of logic to set the default value if AllowNull is false and this is a new feature
// Note that this needs to be here after the cache has been created/updated by populate()
// and signals unblocked (we want this to propagate to the feature itself)

View File

@ -175,7 +175,12 @@ void TestQgsValueRelationWidgetWrapper::testDrillDown()
QCOMPARE( w_municipality.mCache.size(), 2 );
QCOMPARE( w_municipality.mComboBox->count(), 2 );
// check that valueChanged signal is correctly triggered
QSignalSpy spy( &w_municipality, &QgsEditorWidgetWrapper::valueChanged );
w_municipality.setFeature( f3 );
QCOMPARE( spy.count(), 1 );
QCOMPARE( w_municipality.mCache.size(), 1 );
// Check first is selected