Skip to content

Commit cb390d7

Browse files
committed
Fixes relation reference widget by refreshing filter lists. Fixes #16400
1 parent 899a3cd commit cb390d7

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/gui/editorwidgets/qgsrelationreferencewidget.cpp

+17-3
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,20 @@ void QgsRelationReferenceWidget::setForeignKey( const QVariant& value )
276276
}
277277
else
278278
{
279+
QString nullValue = QSettings().value( "qgis/nullValue", "NULL" ).toString();
280+
281+
if ( mChainFilters && mFeature.isValid() && mFilterComboBoxes.count() >= mFilterFields.count() )
282+
{
283+
QgsFeature feature = mFeature;
284+
285+
for ( int i = 0; i < mFilterFields.size(); i++ )
286+
{
287+
QVariant v = feature.attribute( mFilterFields[i] );
288+
QString f = v.isNull() ? nullValue : v.toString();
289+
mFilterComboBoxes.at( i )->setCurrentIndex( mFilterComboBoxes.at( i )->findText( f ) );
290+
}
291+
}
292+
279293
int i = mComboBox->findData( mFeature.id(), QgsAttributeTableModel::FeatureIdRole );
280294
if ( i == -1 && mAllowNull )
281295
{
@@ -951,12 +965,12 @@ void QgsRelationReferenceWidget::disableChainedComboBoxes( const QComboBox *scb
951965
continue;
952966
}
953967

968+
cb->setCurrentIndex( 0 );
954969
if ( ccb->currentIndex() == 0 )
955970
{
956-
cb->setCurrentIndex( 0 );
957971
cb->setEnabled( false );
958972
}
959-
else
960-
ccb = cb;
973+
974+
ccb = cb;
961975
}
962976
}

0 commit comments

Comments
 (0)