Date 2019/07/31
Author David Signer @signedav
Contact david at opengis dot ch
maintainer @signedav
Version QGIS 3.10
In the attribute table the entries can be filtered.
The idea is to have the possiblity to store the expressions used for filtering, name them, and finally have them available in a submenu of the filter section of the attribute table.
"Save" or "Save As" button next to the "Apply" button.
The submenu could be under a section called "Stored Filter (Expression)".
-- Show Edited and New Features
-- Field Filter
|-- fid
|-- name
|-- uuid
-- Advanced Filter (Expression)
-- Stored Filter (Expression)
|-- my_stored_filter 1
|-- another stored_filter 2
Or it would slimmer, when it's directly in the "Advanced Filter (Expression)" section. But this could lead the user to think, that "Advanced Filter (Expression)" is only a menu section and not a functionality.
-- Advanced Filter (Expression)
|-- my_stored_filter 1
|-- another stored_filter 2
If the user does not define a name, it appends the expression text itself to the list.
-- Stored Filter (Expression)
|-- my_stored_filter 1
|-- another stored_filter 2
|-- "id" > 8
Furthermore an API that provides the possiblity to load and read stored expressions or lists of them:
Functions like e.g. for adding a single expression:
/**
* Adds a expression to the stored expressions
*
* \param name optional name of the expression
* \param expression the expression content
* \param tag some content, maybe scope where to be shown
*/
QgsVectorLayer::addStoredExpression( const QString &name, const QString &expression, const QString &tag )
Or for adding a list of expressions:
QgsVectorLayer::addStoredExpressions( QList(< QPair< QString, QString > > namedexpressions, const QString &tag )
Or for reading:
QgsVectorLayer::addStoredExpressions( const QString &tag )
(returning a list of tuples/pairs QList(< QPair< QString, QString > > or maybe in another format)
Reading and writing will be covered with unit tests.
As a future opportunity this stored expressions could be available at other places.
- Field Calculator
- Conditional Format rules
- etc.
