102 Commits

Author SHA1 Message Date
Matthias Kuhn
f511401995 Fix bindings 2017-05-02 01:56:23 +02:00
Matthias Kuhn
b9ec373f4c Fully qualify nested classes for vintage sip 2017-05-02 01:54:58 +02:00
Matthias Kuhn
7a4527d47f Also report ScopedFunctions as static when approporiate 2017-05-02 01:54:58 +02:00
Matthias Kuhn
d70bb9c348 Specify for expression functions if they are static
... and prepare them whenever possible
2017-05-02 01:54:57 +02:00
Matthias Kuhn
8031ac43e0 Expression variables are more often than not static 2017-05-02 01:54:57 +02:00
Matthias Kuhn
c929d2abd8 Fix warnings 2017-05-01 10:22:34 +02:00
Matthias Kuhn
7f3941e073 Doxymentation 2017-05-01 00:04:29 +02:00
Matthias Kuhn
a8fc2c13d0 Fix remaining errors 2017-05-01 00:03:55 +02:00
Denis Rouzaud
fb1aec61ba sipify QgsExpression 2017-05-01 00:03:55 +02:00
Nyall Dawson
77e7693c48 Fix spelling errors in processing algorithm help 2017-03-25 16:23:29 +10:00
Matthias Kuhn
10f50ee68a Remove protected API from non-inherited class 2017-02-24 09:13:48 +01:00
Denis Rouzaud
0a63d1f2c2 [spellcheck] properly look into various cases and add more fixes" 2017-01-16 16:39:20 +01:00
Harrissou Sant-anna
ef85cdcf83 Replace "eg" by "e.g." or "for example" 2016-12-30 00:03:22 +01:00
Matthias Kuhn
0b3646b252 Expression functions can dynamically report geometry and columns 2016-10-27 23:11:51 +02:00
Matthias Kuhn
f80a33be65 [FEATURE] Expose @parent variable in aggregate functions
This makes it possible to access attributes and geometry from the parent
feature when in the filter of the "aggregate" expression function.

With this in place aggregates can be calculated per feature.

E.g. max "measurement" for each point_station per polygon_research_area.

Or a default attribute value when digitizing features:

    aggregate(layer:='countries', aggregate:='max', expression:=\"code\",
filter:=intersects( $geometry, geometry(@parent) ) )
2016-10-27 23:11:50 +02:00
Nyall Dawson
0c4bf943c1 Allow expression functions to appear in multiple groups (fix #15682)
Now functions which make sense for multiple contexts (eg length,
to_date) can appear in more than one group.
2016-10-10 19:53:15 +10:00
Matthias Kuhn
722fdefe43 referencedColumns returns QSet<QString> instead of QStringList
The order of the elements is irrelevant and duplicate elements are unwanted. It
is therefore a perfect candidate for a set instead of a list. This prevents
filtering for duplicates manually be replacing some filer codes with (more
performant) builtin methods of QSet.
2016-10-05 14:33:38 +02:00
Matthias Kuhn
7332dda0d8 Remove visitor pattern from QgsExpression (#3569)
It is not in use anywhere and can easily be reintroduced if there is a use case
where it is an appropriate fit.

Fix https://github.com/qgis/qgis3.0_api/issues/64
2016-10-04 10:46:56 +02:00
Matthias Kuhn
b6779f63ff Rename QgsFields::fieldNameIndex() to lookupField()
To have two clearly different names for tolerant/intolerant index lookup
2016-10-01 15:39:03 +02:00
Matthias Kuhn
ac503770be Fix python bindings for QgsExpression::checkExpression 2016-09-09 14:26:27 +02:00
Matthias Kuhn
8cf0ef93c4 Add QgsOptional and QgsOptionalExpression 2016-09-09 14:26:24 +02:00
Matthias Kuhn
760816bb41 Public default constructor and comparison operator for QgsExpression 2016-09-09 14:25:58 +02:00
Nyall Dawson
b160f101c2 QgsExpression::setGeomCalculator now takes a pointer
This allows the calculator to be cleared
2016-08-10 17:56:01 +10:00
Nyall Dawson
cd5f813112 Standardise capitalisation in some QgsExpression methods 2016-08-10 17:56:01 +10:00
Nyall Dawson
a0360a6400 Remove substitution map from QgsExpression::replaceExpressionText
Since expression context variables should now be used instead. Also
remove all the deprecated methods which relied on this API.
2016-08-10 17:56:01 +10:00
Nyall Dawson
7da8110536 Remove deprecated methods from QgsExpression
Now all evaluate/prepare/etc methods must be called using QgsExpressionContexts

Also remove most remaining traces of special variables. This brings some
user facing changes, such that existing expressions may need to be
updated if they used these old special variables (eg $scale,
$feature). These changes are noted in doc/qgis3_user_changes.dox
so that we can include them in the release notes.
2016-08-10 17:55:06 +10:00
Nyall Dawson
f6f5010131 Move QGis::UnitType to QgsUnitTypes::DistanceUnit
This change consolidates more unit handling and conversion into
QgsUnitTypes.

Additionally, UnknownUnit was renamed to UnknownDistanceUnit.
All methods which accepted QGis::UnitType parameters have been
updated to take QgsUnitTypes::DistanceUnit instead.

ALso remove the unit handling methods toLiteral, fromLiteral, tr,
fromTr, and fromUnitToUnitFactor from QGis. Their corresponding
counterparts in QgsUnitTypes should be used instead.
2016-07-25 14:47:16 +10:00
Nyall Dawson
1a2231f10c Rename QGis class to Qgis, for capitalisation consistency 2016-07-21 22:01:38 +10:00
Nyall Dawson
ceba5264f7 New class QgsInterval for storing durations between datetimes
Move the QgsExpression::Interval class out to its own QgsInterval
class, extend with new methods and add tests

Add a typedef to keep API compatibility for 2.16
2016-05-10 19:00:33 +10:00
Nyall Dawson
ae00eb965c [FEATURE] Allow expression functions to use named parameters
This commit sets the framework for allowing expression functions to
use named parameters. Ie, instead of:

clamp(1,2,3)

you can use:

clamp( min:=1, value:=2, max:=3)

This also allows arguments to be switched, eg:

clamp( value:=2, max:=3, min:=1)

Additionally, it allows for a more structured definition of function
parameters to handle optional arguments and default values for
parameters. These are currently being done using a hacky infinite
argument list.

I've utilised the postgres ':=' syntax for specifying named arguments
to avoid potential collisions which may arise with the equality test
if we re-used just the '=' operator alone.

Sponsored by North Road
2016-04-04 13:59:13 +10:00
Nyall Dawson
59b216be74 Add missing sip bindings 2016-02-15 19:02:34 +11:00
Juergen E. Fischer
a90be95f7b sip sync 2016-02-14 03:50:49 +01:00
Nyall Dawson
9f772bce29 Add API call for setting preferred distance unit for QgsExpression
(refs #13209, #12939, #4857)
2016-02-13 11:36:51 +11:00
Nyall Dawson
229ef29170 If no geomCalculator is set for QgsExpression, perform cartesian
calculations for $length, $area, $perimeter (refs #13209)

ie, the default is now to use planimeteric calculations unless
a geomCalculator has been explicitly set
2016-02-12 20:54:25 +11:00
Nyall Dawson
c3a57434d9 Fix clazy 'pass small and trivially-copyable type by value' warnings 2016-02-02 19:47:21 +11:00
Nyall Dawson
39f0035246 Improve preview of current variable value in expression builder 2016-01-27 11:36:56 +11:00
Nyall Dawson
24d9c65494 Fix more classes which violate the rule-of-three
Also remove some empty destructors
2016-01-26 14:24:45 +11:00
Nyall Dawson
752f6bd150 Fix classes which violate rule of three, by implementing required
copy/= operators or making them private

This revealed (and fixes) some issues, including a potential crash
using server access control (refs #13919), and a potential crash with
diagrams
2016-01-22 18:45:45 +11:00
Nyall Dawson
881074b194 Boost coverage of SIP bindings
Now all classes and members are either exposed to bindings or marked
as "not available in Python bindings" in the docs.

Drop test thresholds to 0. Now it should be much easier to determine
what missing members have been added which are causing test
failures.
2016-01-05 11:16:15 +11:00
Matthias Kuhn
de1c319bf6 Implicit sharing for QgsExpression 2015-12-15 13:39:07 +01:00
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