62 Commits

Author SHA1 Message Date
Nyall Dawson
9cc9d424ce Add extra check for deprecations to documentation test
This check tests that if a function has been declared deprecated
with either Q_DECL_DEPRECATED or has a @deprecated Doxygen note
then it MUST have both the Q_DECL_DEPRECATD and @deprecated note.

It's important that both are used, as Q_DECL_DEPRECATED allows
throwing a warning if that method is used in code, while the
@deprecated doxygen note gives an indication to devs/PyQGIS users
of why it's deprecated and what should be used instead.

Ideally we'd also test for SIP /Deprecated/ tags, but I can't
find any reliable way to do this.
2015-12-07 21:55:36 +11:00
Nyall Dawson
48e4d1c977 Add a method for getting a quoted string value for use as a literal
in expressions
2015-12-01 19:33:27 +11:00
Matthias Kuhn
56ccb2b858 sipClass_Klass is deprecated for a long time: replace with sipType_Klass 2015-11-11 23:22:51 +01:00
Nyall Dawson
c49b5b777f Change a lot of arguments to const references in core/gui
Rationale:
- there was a lot of large objects passed by value, so potentially
there's a speed bump from this
- even for implicitly shared classes like QString/QList there's still
a (small) cost for copying the objects when there's no reason to
- it's the right thing to do!
2015-10-07 12:02:04 +11:00
Nyall Dawson
97096e2d6b Deprecate QgsExpression special column methods 2015-09-07 20:24:57 +10:00
Nyall Dawson
1c079ead02 Expression context fixes:
- Fix python API break in QgsExpression::Function
- Add convenience methods for retrieving feature/fields from a
context
2015-09-05 22:03:16 +10:00
Nyall Dawson
24b8405d58 Ensure standard expressions functions are deleted on exit
(Avoids a lot of LeakSanitiser noise)
2015-08-25 21:40:32 +10:00
Nyall Dawson
f74db81b9a Hide contextual functions from builder unless provided by context 2015-08-22 19:01:42 +10:00
Nyall Dawson
6487f1716c Add help text for variables 2015-08-22 19:01:42 +10:00
Nyall Dawson
c1adf623af Port field calculator to contexts 2015-08-22 19:01:39 +10:00
Nyall Dawson
f6e0ce788e New framework for context based expressions
This commit adds the ability for expressions to be evaluated against
specific contexts. It replaces the previous behaviour where
expressions were evaluated against a specific feature and could
utilise fragile global "special columns".

Now, expressions are instead evaluated using a context designed for
each individual expression. This is done via QgsExpressionContext
and QgsExpressionContextScope objects.

A QgsExpressionContextScope encapsulates the variables and functions
relating to a specific context. For instance, scopes can be created
for "global" variables (such as QGIS version, platform, and user-set
variables specified within the QGIS options dialog. Think things
like user name, work department, etc), or for "project" variables
(eg project path, title, filename, and user-set variables set
through the project properties dialog. Project version, reference
number, that kind of thing). Many more scopes are planned, including
map layer scopes (variables for layer name, id, user-set variables
through the layer properties dialog), composer scopes, etc...

QgsExpressionContextScopes are 'stacked' into a QgsExpressionContext
object. Scopes added later to a QgsExpressionContext will override
any variables or functions provided by earlier scopes, so for
instance a user could override their global 'author' variable set
within QGIS options with a different 'author' set via the project
properties dialog.

The intended use is that a QgsExpressionContext is created before
a batch set of QgsExpression evaluations. Scopes are then added to
the context based on what makes sense for that particular
expression. Eg, almost all contexts will consist of the global
scope and project scope, and then additional scopes as required.
So a composer label would be evaluated against a context
consisting of the global scope, project scope, composition scope
and finally composer item scope. The batch set of expression
evaluations would then be performed using this context, after which
the context is discarded. In other words, a context is designed
for use for one specific set of expression evaluations only.
2015-08-22 19:01:39 +10:00
Juergen E. Fischer
9752c468c1 indentation update 2015-07-29 11:52:14 +02:00
Jürgen Fischer
6e3a1fa057 Merge pull request #2118 from jef-n/postgres-like-concat
expressions: let concat handle NULL like empty string (like in postgres; fixes #1927)
2015-06-26 01:14:20 +02:00
Matthias Kuhn
8342739b37 Expressions: preserve brackets for right-associative operators
Fixes #11475
2015-06-16 19:46:26 +02:00
Denis Rouzaud
a518e9f639 [fix #11475] expressions: add left and right associavity for dump of binary operators
complete test for left associativity
2015-06-16 19:07:45 +02:00
Juergen E. Fischer
3387d6f632 expression: let concat handle NULL like empty string (like in postgres) 2015-06-06 11:29:44 +02:00
Juergen E. Fischer
dd53fda846 indentation update 2015-05-29 08:57:54 +02:00
Nyall Dawson
ec01d7698e More Coverity memory leak fixes 2015-05-27 23:03:00 +10:00
Matthias Kuhn
a2ae8b4e38 Add unit tests for postgres provider
basically to get a framework to test the expression compiler
2015-05-22 11:57:16 +02:00
Matthias Kuhn
9b6e23d3af Add convenience method QgsVectorLayer::getFeatures( expression ) 2015-05-22 11:57:16 +02:00
Martin Dobias
56ada166c4 PyQGIS: add conversion from QgsExpression::Node to subclasses
This makes it possible to investigate expression node tree within Python
2015-05-12 17:24:57 +01:00
Juergen E. Fischer
edeafa95ac indentation and minor sip updates 2015-05-03 17:10:32 +02:00
Nyall Dawson
bd9e02be95 Add alias support for expression functions
Standardise naming of all internal functions to lowercase with
underscore convention. Add aliases for old names to avoid
breakage.
2015-05-03 20:57:36 +10:00
vmora
d4319621a5 Add an isField test for QgsExpression
Checks whether expression consists of solely a field reference
2015-04-27 18:22:18 +10:00
Juergen E. Fischer
abd4a04399 sip update 2015-02-03 02:21:52 +01:00
Nyall Dawson
232aaaca66 [expressions] Make int/int return double results.
Also add a new "//" operator to perform integer division.
(fix #5153)
2014-12-06 16:36:42 +11:00
Nyall Dawson
7400106e41 [FEATURE] Evaluate expressions entered in QgsDoubleSpinBox
Allows entry of QGIS expressions into the spin box. The expression
is evaluated on enter or loss of focus and then discarded.

(refs #10544)
2014-12-05 20:39:09 +11:00
Matthias Kuhn
a92d1a6e31 QgsExpression: some const fixes 2014-11-30 10:34:19 +01:00
Juergen E. Fischer
d4f64d9bde indentation update and typo fixes 2014-11-13 23:13:13 +01:00
Martin Dobias
37ba8e4187 Fix #9319 (copy of QgsExpression crashes)
Disabled the copy constructor for now (later we may introduce implicit sharing)
2014-10-22 23:03:53 +07:00
Nyall Dawson
0cb985465b [composer] Fix area calculation in expressions with OTF (fix #9791)
Adds an argument to QgsExpression::replaceExpressionText to allow
passing an optional QgsDistanceArea to use during calculations.
Ensure that html and label composer items correctly specify this
argument.
2014-10-19 11:04:57 +11:00
Nyall Dawson
1e39db6a0f [FEATURE] New expression functions for $currentfeature (returns current feature) and 'attribute' (returns value stored in specified field within a feature) 2014-07-10 14:10:44 +10:00
Juergen E. Fischer
03475be523 fix build error and update sips 2014-06-14 11:47:05 +02:00
Juergen E. Fischer
c1f50db1ac fix warnings 2014-05-29 01:43:04 +02:00
Juergen E. Fischer
c4c131ef75 sip sync 2014-05-27 23:32:42 +02:00
Martin Dobias
684dd890a3 Fix #9459 (layer fails to render when rule-based symbology make use of $atlasfeatureid) 2014-02-11 23:57:02 +07:00
Juergen E. Fischer
d647354a52 sip fixes 2014-01-28 00:26:13 +01:00
Juergen E. Fischer
74e7314c36 update sip bindings II 2014-01-27 09:22:53 +01:00
Juergen E. Fischer
d4e369414b update sip bindings 2014-01-26 18:36:29 +01:00
Nathan Woodrow
2cd89388b6 Use const pointer for QgsExpression:replaceExpressionText() 2013-10-10 13:37:53 +10:00
Matthias Kuhn
75896d922d QgsExpression takes const QgsFeature as pointer and by reference 2013-05-22 17:01:55 +02:00
Martin Dobias
b513674fa8 Moved expression to OGC filter code to QgsOgcUtils 2013-03-15 00:44:32 +01:00
Martin Dobias
16ec226d97 Moved visitor-based expression -> OGC filter code to QgsOgcUtils 2013-03-15 00:44:31 +01:00
Martin Dobias
837ac4de5c Moved creation of expression from OGC filter to QgsOgcUtils 2013-03-15 00:44:31 +01:00
Martin Dobias
9317ffd89a Merge remote-tracking branch 'origin/master' into new_vector_api
Also disabled mapserver until compilation is fixed.
Fixed tests.

Conflicts:
	src/app/legend/qgslegendlayer.cpp
	src/app/qgsattributedialog.cpp
	src/app/qgsattributedialog.h
	src/app/qgslabelpropertydialog.cpp
	src/app/qgsmaptoollabel.cpp
	src/app/qgsvectorlayerproperties.cpp
	src/core/CMakeLists.txt
	src/core/composer/qgsatlascomposition.cpp
	src/core/qgsexpression.cpp
	src/core/qgspallabeling.cpp
	src/core/qgsvectorlayer.cpp
	src/core/qgsvectorlayer.h
	src/core/qgsvectorlayerimport.cpp
	src/mapserver/qgsprojectparser.cpp
	src/mapserver/qgswfsserver.cpp
	src/mapserver/qgswfsserver.h
	src/mapserver/qgswmsserver.cpp
	src/providers/postgres/qgspostgresprovider.cpp
	src/providers/spatialite/qgsspatialiteprovider.h
	tests/src/core/testqgsexpression.cpp
	tests/src/python/test_qgsmemoryprovider.py
2012-12-18 01:35:06 +01:00
Magnus Homann
e063c237d0 Update from master 2012-11-23 21:01:04 +01:00
Nathan Woodrow
a7699e2696 [FEATURE] Add ability to create user defined Python (and C++) expression functions 2012-11-10 11:20:26 +10:00
Martin Dobias
51122d263a Store attributes and fields in vectors instead of maps 2012-10-20 22:19:55 +02:00
Hugo Mercier
45593bf4b5 Revert "Revert "Merge pull request #245 from Oslandia/atlas_integration""
This reverts commit 8a1953b9e710ea25dac502b32eab9e0e8d652b10.
2012-10-04 11:18:17 +02:00
Tim Sutton
8a1953b9e7 Revert "Merge pull request #245 from Oslandia/atlas_integration"
This reverts commit fe8385e7f5735507adf1acfcce81a399fa6bc6f5, reversing
changes made to 23352ce0d66855a4a9c403a81feaa1884415e45c.
2012-10-01 11:04:04 +02:00