Skip to content

Commit 69f45e3

Browse files
committedFeb 12, 2019
Refactor QgsExpressionContext and move QgsExpressionContextUtils
out to its own header Avoids slow recompilation caused by changes to the frequently modified QgsExpressionContextUtils class
1 parent d281c8a commit 69f45e3

File tree

131 files changed

+1635
-1464
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+1635
-1464
lines changed
 
Lines changed: 334 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,334 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/core/expression/qgsexpressioncontextutils.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
12+
class QgsExpressionContextUtils
13+
{
14+
%Docstring
15+
Contains utilities for working with QgsExpressionContext objects, including methods
16+
for creating scopes for specific uses (e.g., project scopes, layer scopes).
17+
18+
.. versionadded:: 2.12
19+
%End
20+
21+
%TypeHeaderCode
22+
#include "qgsexpressioncontextutils.h"
23+
%End
24+
public:
25+
26+
static QgsExpressionContextScope *globalScope() /Factory/;
27+
%Docstring
28+
Creates a new scope which contains variables and functions relating to the global QGIS context.
29+
For instance, QGIS version numbers and variables specified through QGIS options.
30+
31+
.. seealso:: :py:func:`setGlobalVariable`
32+
%End
33+
34+
static QgsExpressionContextScope *formScope( const QgsFeature &formFeature = QgsFeature( ), const QString &formMode = QString() ) /Factory/;
35+
%Docstring
36+
Creates a new scope which contains functions and variables from the current attribute form/table ``feature``.
37+
The variables and values in this scope will reflect the current state of the form/row being edited.
38+
The ``formMode`` (SingleEditMode etc.) is passed as text
39+
40+
.. versionadded:: 3.2
41+
%End
42+
43+
static void setGlobalVariable( const QString &name, const QVariant &value );
44+
%Docstring
45+
Sets a global context variable. This variable will be contained within scopes retrieved via
46+
globalScope().
47+
48+
:param name: variable name
49+
:param value: variable value
50+
51+
.. seealso:: :py:func:`setGlobalVariable`
52+
53+
.. seealso:: :py:func:`globalScope`
54+
55+
.. seealso:: :py:func:`removeGlobalVariable`
56+
%End
57+
58+
static void setGlobalVariables( const QVariantMap &variables );
59+
%Docstring
60+
Sets all global context variables. Existing global variables will be removed and replaced
61+
with the variables specified.
62+
63+
:param variables: new set of global variables
64+
65+
.. seealso:: :py:func:`setGlobalVariable`
66+
67+
.. seealso:: :py:func:`globalScope`
68+
69+
.. seealso:: :py:func:`removeGlobalVariable`
70+
%End
71+
72+
static void removeGlobalVariable( const QString &name );
73+
%Docstring
74+
Remove a global context variable.
75+
76+
:param name: variable name
77+
78+
.. seealso:: :py:func:`setGlobalVariable`
79+
80+
.. seealso:: :py:func:`setGlobalVariables`
81+
82+
.. seealso:: :py:func:`globalScope`
83+
%End
84+
85+
static QgsExpressionContextScope *projectScope( const QgsProject *project ) /Factory/;
86+
%Docstring
87+
Creates a new scope which contains variables and functions relating to a QGIS project.
88+
For instance, project path and title, and variables specified through the project properties.
89+
90+
:param project: What project to use
91+
92+
.. seealso:: :py:func:`setProjectVariable`
93+
%End
94+
95+
static void setProjectVariable( QgsProject *project, const QString &name, const QVariant &value );
96+
%Docstring
97+
Sets a project context variable. This variable will be contained within scopes retrieved via
98+
projectScope().
99+
100+
:param project: Project to apply changes to
101+
:param name: variable name
102+
:param value: variable value
103+
104+
.. seealso:: :py:func:`setProjectVariables`
105+
106+
.. seealso:: :py:func:`removeProjectVariable`
107+
108+
.. seealso:: :py:func:`projectScope`
109+
%End
110+
111+
static void setProjectVariables( QgsProject *project, const QVariantMap &variables );
112+
%Docstring
113+
Sets all project context variables. Existing project variables will be removed and replaced
114+
with the variables specified.
115+
116+
:param project: Project to apply changes to
117+
:param variables: new set of project variables
118+
119+
.. seealso:: :py:func:`setProjectVariable`
120+
121+
.. seealso:: :py:func:`removeProjectVariable`
122+
123+
.. seealso:: :py:func:`projectScope`
124+
%End
125+
126+
static void removeProjectVariable( QgsProject *project, const QString &name );
127+
%Docstring
128+
Remove project context variable.
129+
130+
:param project: Project to apply changes to
131+
:param name: variable name
132+
133+
.. seealso:: :py:func:`setProjectVariable`
134+
135+
.. seealso:: :py:func:`setProjectVariables`
136+
137+
.. seealso:: :py:func:`projectScope`
138+
%End
139+
140+
static QgsExpressionContextScope *layerScope( const QgsMapLayer *layer ) /Factory/;
141+
%Docstring
142+
Creates a new scope which contains variables and functions relating to a :py:class:`QgsMapLayer`.
143+
For instance, layer name, id and fields.
144+
%End
145+
146+
static QList<QgsExpressionContextScope *> globalProjectLayerScopes( const QgsMapLayer *layer ) /Factory/;
147+
%Docstring
148+
Creates a list of three scopes: global, layer's project and layer.
149+
150+
.. versionadded:: 3.0
151+
%End
152+
153+
static void setLayerVariable( QgsMapLayer *layer, const QString &name, const QVariant &value );
154+
%Docstring
155+
Sets a layer context variable. This variable will be contained within scopes retrieved via
156+
layerScope().
157+
158+
:param layer: map layer
159+
:param name: variable name
160+
:param value: variable value
161+
162+
.. seealso:: :py:func:`setLayerVariables`
163+
164+
.. seealso:: :py:func:`layerScope`
165+
%End
166+
167+
static void setLayerVariables( QgsMapLayer *layer, const QVariantMap &variables );
168+
%Docstring
169+
Sets all layer context variables. Existing layer variables will be removed and replaced
170+
with the variables specified.
171+
172+
:param layer: map layer
173+
:param variables: new set of layer variables
174+
175+
.. seealso:: :py:func:`setLayerVariable`
176+
177+
.. seealso:: :py:func:`layerScope`
178+
%End
179+
180+
static QgsExpressionContextScope *mapSettingsScope( const QgsMapSettings &mapSettings ) /Factory/;
181+
%Docstring
182+
Creates a new scope which contains variables and functions relating to a QgsMapSettings object.
183+
For instance, map scale and rotation.
184+
%End
185+
186+
static QgsExpressionContextScope *mapToolCaptureScope( const QList<QgsPointLocator::Match> &matches ) /Factory/;
187+
%Docstring
188+
Sets the expression context variables which are available for expressions triggered by
189+
a map tool capture like add feature.
190+
191+
.. versionadded:: 3.0
192+
%End
193+
194+
static QgsExpressionContextScope *updateSymbolScope( const QgsSymbol *symbol, QgsExpressionContextScope *symbolScope = 0 );
195+
%Docstring
196+
Updates a symbol scope related to a QgsSymbol to an expression context.
197+
198+
:param symbol: symbol to extract properties from
199+
:param symbolScope: pointer to an existing scope to update
200+
201+
.. versionadded:: 2.14
202+
%End
203+
204+
static QgsExpressionContextScope *layoutScope( const QgsLayout *layout ) /Factory/;
205+
%Docstring
206+
Creates a new scope which contains variables and functions relating to a :py:class:`QgsLayout` ``layout``.
207+
For instance, number of pages and page sizes.
208+
209+
.. versionadded:: 3.0
210+
%End
211+
212+
static void setLayoutVariable( QgsLayout *layout, const QString &name, const QVariant &value );
213+
%Docstring
214+
Sets a layout context variable. This variable will be contained within scopes retrieved via
215+
layoutScope().
216+
217+
:param layout: target layout
218+
:param name: variable name
219+
:param value: variable value
220+
221+
.. seealso:: :py:func:`setLayoutVariables`
222+
223+
.. seealso:: :py:func:`layoutScope`
224+
225+
.. versionadded:: 3.0
226+
%End
227+
228+
static void setLayoutVariables( QgsLayout *layout, const QVariantMap &variables );
229+
%Docstring
230+
Sets all layout context variables. Existing layout variables will be removed and replaced
231+
with the variables specified.
232+
233+
:param layout: target layout
234+
:param variables: new set of layer variables
235+
236+
.. seealso:: :py:func:`setLayoutVariable`
237+
238+
.. seealso:: :py:func:`layoutScope`
239+
240+
.. versionadded:: 3.0
241+
%End
242+
243+
static QgsExpressionContextScope *atlasScope( QgsLayoutAtlas *atlas ) /Factory/;
244+
%Docstring
245+
Creates a new scope which contains variables and functions relating to a :py:class:`QgsLayoutAtlas`.
246+
For instance, current page name and number.
247+
248+
:param atlas: source atlas. If null, a set of default atlas variables will be added to the scope.
249+
%End
250+
251+
static QgsExpressionContextScope *layoutItemScope( const QgsLayoutItem *item ) /Factory/;
252+
%Docstring
253+
Creates a new scope which contains variables and functions relating to a :py:class:`QgsLayoutItem`.
254+
For instance, item size and position.
255+
256+
.. seealso:: :py:func:`setLayoutItemVariable`
257+
258+
.. seealso:: :py:func:`setLayoutItemVariables`
259+
260+
.. versionadded:: 3.0
261+
%End
262+
263+
static void setLayoutItemVariable( QgsLayoutItem *item, const QString &name, const QVariant &value );
264+
%Docstring
265+
Sets a layout ``item`` context variable, with the given ``name`` and ``value``.
266+
This variable will be contained within scopes retrieved via
267+
layoutItemScope().
268+
269+
.. seealso:: :py:func:`setLayoutItemVariables`
270+
271+
.. seealso:: :py:func:`layoutItemScope`
272+
273+
.. versionadded:: 3.0
274+
%End
275+
276+
static void setLayoutItemVariables( QgsLayoutItem *item, const QVariantMap &variables );
277+
%Docstring
278+
Sets all layout item context variables for an ``item``. Existing variables will be removed and replaced
279+
with the ``variables`` specified.
280+
281+
.. seealso:: :py:func:`setLayoutItemVariable`
282+
283+
.. seealso:: :py:func:`layoutItemScope`
284+
285+
.. versionadded:: 3.0
286+
%End
287+
288+
static QgsExpressionContext createFeatureBasedContext( const QgsFeature &feature, const QgsFields &fields );
289+
%Docstring
290+
Helper function for creating an expression context which contains just a feature and fields
291+
collection. Generally this method should not be used as the created context does not include
292+
standard scopes such as the global and project scopes.
293+
%End
294+
295+
static QgsExpressionContextScope *processingAlgorithmScope( const QgsProcessingAlgorithm *algorithm, const QVariantMap &parameters, QgsProcessingContext &context ) /Factory/;
296+
%Docstring
297+
Creates a new scope which contains variables and functions relating to a processing ``algorithm``,
298+
when used with the specified ``parameters`` and ``context``.
299+
For instance, algorithm name and parameter functions.
300+
301+
.. seealso:: :py:func:`processingModelAlgorithmScope`
302+
%End
303+
304+
static QgsExpressionContextScope *processingModelAlgorithmScope( const QgsProcessingModelAlgorithm *model, const QVariantMap &parameters, QgsProcessingContext &context ) /Factory/;
305+
%Docstring
306+
Creates a new scope which contains variables and functions relating to a processing ``model`` algorithm,
307+
when used with the specified ``parameters`` and ``context``.
308+
For instance, model name and path variables.
309+
310+
.. versionadded:: 3.6
311+
%End
312+
313+
static QgsExpressionContextScope *notificationScope( const QString &message = QString() ) /Factory/;
314+
%Docstring
315+
Creates a new scope which contains variables and functions relating to provider notifications
316+
317+
:param message: the notification message
318+
%End
319+
320+
static void registerContextFunctions();
321+
%Docstring
322+
Registers all known core functions provided by QgsExpressionContextScope objects.
323+
%End
324+
325+
public:
326+
};
327+
328+
/************************************************************************
329+
* This file has been generated automatically from *
330+
* *
331+
* src/core/expression/qgsexpressioncontextutils.h *
332+
* *
333+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
334+
************************************************************************/

0 commit comments

Comments
 (0)
Please sign in to comment.