Hi Martin On 24.09.2014 19:32, Martin Dobias wrote: > Hi Andreas > > > On Wed, Sep 17, 2014 at 10:56 PM, Andreas Neumann <[email protected]> wrote: >> I noticed that line breaks are not preserved. This makes the statement >> much harder to read. >> >> Is there a chance that future QGIS versions could preserve linebreaks or >> is there a problem saving and restoring the line breaks of the expressions? > This is probably due to the fact that in _some_ cases expressions are > (unfortunately) not kept in verbatim format as they were input - > instead they are parsed and later converted back to text, loosing all > formatting.
I once introduced a method QgsExpression::expression() along QgsExpression::dump() which originally returned the saved verbatim string and was subsequently changed several times (responsibility for this including myself) to call dump() or return the original string. Last time I wanted to change this back to the saved string, I was stopped me because IIRC there are situations where the expression gets modified directly, so the input string does not correctly represent the expression and needs to be recreated. I would propose the following: - QgsExpression::dump() should always recreate the string from the data structure - save the original expression string and return it with QgsExpression::expression() - unless the expression is modified by other means, which will set the saved string to a NULL string in which case QgsExpression::expression() will be forwarded to QgsExpression::dump() -- Matthias _______________________________________________ Qgis-developer mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/qgis-developer
