Qfield Filter plugin

Hi,
I have build a plugin to filter features in your project.
With it you can select a layer and a field of your project and write 1 or many values to filter on this define layer field.
You can filter number or text and it is not case sensitive
It will highlight filtered geometries and hide others or show all geometries with filtered
If you longpress the plugin icon it will delete the filter.

It will be even better if someone can help me to:

  • change highlight color
  • auto-zoom to filtered geometries
  • Select field attributs (like list uniques values from existent fields)
  • and create points on filtered geometries

Thanks

5 Likes

Actually its like that


But i would like it like that

3 Likes

Really cool to see, I will try it out :slight_smile: @Mathieu_Pellerin Also nice for you to know I guess

In v0.2 of this plugin, i have found how to select field attributes (like list uniques values from existant fields)
Thanks to Heather_Hillers Demonstrations plugins

Hey, this is fantastic, thanks for sharing with us and the broader community. I’m going to look at it more closely this week to see if there are things we can improve on the QField side of things to facilitate such a plugin.

Big thanks again!

@woupss , regarding the wish for selection color to be changed, you can use the QgsProject’s selectionColor property ( QGIS API Documentation: QgsProject Class Reference ) to do that. So for e.g. if you wanted to change it to red, you would do in your plugin:

qgisProject.selectionColor = “#ff0000”

For zooming to selected geometries, you can use the QgsVectorLayer’s boundingBoxOfSelected function, that’s invokable from within QML ( QGIS API Documentation: QgsVectorLayer Class Reference ). Just make sure you reproject the returned extent CRS to match that of your project CRS.

One possibly nice functionality here would be to open the feature list form to show the selected features. It’d be possible to do that by setting the feature list form model with the same expression you’ve used to select the features. It’d look something like this:

let form = iface.findItemByObjectName(“featureForm”); // note this will likely change to featureListForm in the next QField version`
form.model.setFeatures(layer, “your expression”); // the model here is a MultiFeatureListModel object, more details here: ``https://api.qfield.org/QField/classMultiFeatureListModel 
form.show();
1 Like

Thanks @Mathieu_Pellerin
I will try to make it better with your golden advices

@Mathieu_Pellerin i just can’t change the yellow selectionColor
But auto-zoom is active :+1:

edit:
it seems link, in first post, to repo is dead and i can’t edit first post

Big improvement
Now you need to type your search value(s) and it will show you found values in the layer field.
You can search as many values as you want.
It can easily support layer with over 300000 values with no lag
And now it will show you features list if you want.

1 Like

Thank you very much for the helpful plugin, it’s really great and works very well even with large, complex projects!

I just tested it and am very satisfied. If I may make a suggestion for improvement, it would be to make it possible to delete the filter more quickly with a single click and find all elements again, unless I haven’t figured that out yet. :slight_smile:

All the best,

Tommy from COFT SARL-S

If you press and hold the button, it removes the filter.
A single press would prevent the dialog box from opening.