[Qgis-developer] Adding expressions support for layer's actions

Giuseppe Sucameli sucameli at faunalia.it
Sat Jan 7 19:24:24 EST 2012


Hi all,

I'm working on made actions more powerful adding the support for
expressions (the same used in the labelling system).
This requires to define how to include expressions into the action.

In this moment the syntax to include fields into an action definition
is %field, but even [%field]. There's no a parser, just a replace of
placeholders with the value of the field.

As the first syntax doesn't allow to insert a complex expression
(what's the end of the expression?), so I would use the second one.
What do you think about it?

Here's an example using a python action (it displays a message):
from PyQt4.QtGui import QMessageBox; QMessageBox.information(None,
"Feature info", "record id = [% $id ] \nfield misure = [% misure ]")

The [% expression ] will be replaced with the value of the expression,
so [% $id ] will be the rowid and [%misure] the value of the field "misure".
Of course every supported expression may be used.

In addition, should I drop the old behavior (I think it's better, but it breaks
API) or support both them (i.e. adding a version property for actions) or
keep the old behavior for compatibility only (adding an option in the settings
dialog)?

Thanks for your suggestions.
Regards.

-- 
Giuseppe Sucameli


More information about the Qgis-developer mailing list