@@ -67,6 +67,7 @@ class TestQgsRelationReferenceWidget : public QObject
67
67
void testAddEntryNoGeom ();
68
68
void testDependencies (); // Test relation datasource, id etc. config storage
69
69
void testSetFilterExpression ();
70
+ void testSetFilterExpressionWithOrClause ();
70
71
71
72
private:
72
73
std::unique_ptr<QgsVectorLayer> mLayer1 ;
@@ -735,5 +736,42 @@ void TestQgsRelationReferenceWidget::testSetFilterExpression()
735
736
QCOMPARE ( w.mComboBox ->count (), 3 );
736
737
}
737
738
739
+
740
+
741
+ void TestQgsRelationReferenceWidget::testSetFilterExpressionWithOrClause ()
742
+ {
743
+
744
+ // init a relation reference widget
745
+ QStringList filterFields = { " material" , " diameter" , " raccord" };
746
+
747
+ QWidget parentWidget;
748
+ QgsRelationReferenceWidget w ( &parentWidget );
749
+
750
+ QEventLoop loop;
751
+ connect ( qobject_cast<QgsFeatureFilterModel *>( w.mComboBox ->model () ), &QgsFeatureFilterModel::filterJobCompleted, &loop, &QEventLoop::quit );
752
+
753
+ w.setChainFilters ( true );
754
+ w.setFilterFields ( filterFields );
755
+ w.setRelation ( *mRelation , true );
756
+ w.setFilterExpression ( QStringLiteral ( " \" raccord\" = 'sleeve' OR FALSE " ) );
757
+ w.init ();
758
+
759
+ QStringList items = getComboBoxItems ( w.mComboBox );
760
+
761
+ loop.exec ();
762
+
763
+ // in case there is no filter, the number of filtered features will be 4
764
+ QCOMPARE ( w.mComboBox ->count (), 2 );
765
+
766
+ QList<QComboBox *> cbs = w.mFilterComboBoxes ;
767
+ cbs[0 ]->setCurrentIndex ( cbs[0 ]->findText ( " steel" ) );
768
+
769
+ loop.exec ();
770
+
771
+ QCOMPARE ( w.mComboBox ->currentText (), QStringLiteral ( " NULL" ) );
772
+ // in case there is no field filter, the number of filtered features will be 2
773
+ QCOMPARE ( w.mComboBox ->count (), 1 );
774
+ }
775
+
738
776
QGSTEST_MAIN ( TestQgsRelationReferenceWidget )
739
777
#include " testqgsrelationreferencewidget.moc"
0 commit comments