qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.31k stars 2.97k forks source link

Filter for Relation Editor LinkFeatureDialog #58185

Closed signedav closed 2 weeks ago

signedav commented 1 month ago

Feature description

The Relation Editor Widget is a powerful tool to link children objects to a parent object or - with many-to-many relations - directly choose the "other" parent and perform an entry in the join table. There are options like creating child objects or linking exiting ones.

The "opposite" of it is the Relation Reference Widget, where we choose the parent object. There a useful feature is the filter.

But in Relation Editor Widget we still need to filter manually when we filter objects.

So this would be a very useful feature.

Example

We do have a layer representing fields named "Beurteilung_Wiese" with a parameter "uzl_subregion" what could be "1.1", "1.2", "1.3", depending where the field is: image

Now we want to link fauna-types to the current "Beurteilung_Wiese", but in the huge list of all the fauna-types we only want to have the ones that really exist in the current subregion. Means I need a filter like this:

image

But this filter I always have to set manually. I would like to have something like this: image

There's the QGIS Linking Relation Editor plugin where there is an unfinished prototype branch:

https://github.com/opengisch/qgis-linking-relation-editor/pull/49/files

image

image

But I believe it would make sense in the core.

Additional context

No response

signedav commented 1 month ago

The setting might should happen somewhere here...

https://github.com/qgis/QGIS/blob/master/src/gui/qgsabstractrelationeditorwidget.cpp#L472-L478

... kind of like this ...

selectionDlg->setFilterExpression("relevant_progrtyp_alr = True AND relevant_subregion_1_2 = True",QgsAttributeForm::ReplaceFilter);

... but setFilterExpression of QgsFeatureSelectionDlg needs to be public first.