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)
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.
@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();
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.
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.