Skip to content
Permalink
Browse files

Merge pull request #5879 from pblottiere/refrelfilter_218

[bugfix]  Fixes auto select foreign key when filters are updated in QgsRelationReferenceWidget
  • Loading branch information
pblottiere committed Dec 18, 2017
2 parents 3277853 + 9b2320a commit d8143244a49d495e90126ebfbeed65d49d1e10dd
@@ -941,6 +941,18 @@ void QgsRelationReferenceWidget::filterChanged()
}

mFilterModel->setFilteredFeatures( featureIds );

if ( mChainFilters && mComboBox->count() > 0 )
{
if ( scb->currentIndex() == 0 )
{
mComboBox->setCurrentIndex( 0 );
}
else if ( mComboBox->count() > 1 )
{
mComboBox->setCurrentIndex( 1 );
}
}
}

void QgsRelationReferenceWidget::addEntry()
@@ -174,8 +174,20 @@ void TestQgsRelationReferenceWidget::testChainFilter()

// set the filter for "raccord" and then reset filter for "diameter". As
// chain filter is activated, the filter on "raccord" field should be reset
cbs[0]->setCurrentIndex( 0 );
QCOMPARE( w.mComboBox->currentIndex(), 0 );

cbs[0]->setCurrentIndex( cbs[0]->findText( "iron" ) );
QCOMPARE( w.mComboBox->currentIndex(), 1 );

cbs[1]->setCurrentIndex( cbs[1]->findText( "120" ) );
QCOMPARE( w.mComboBox->currentIndex(), 1 );

cbs[2]->setCurrentIndex( cbs[2]->findText( "brides" ) );
QCOMPARE( w.mComboBox->currentIndex(), 1 );

cbs[1]->setCurrentIndex( cbs[1]->findText( "diameter" ) );
QCOMPARE( w.mComboBox->currentIndex(), 0 );

// combobox should propose NULL, 10 and 11 because the filter is now:
// "material" == 'iron'

0 comments on commit d814324

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