@@ -217,6 +217,12 @@ class QgsExpressionContext
217217
218218 QgsExpressionContext ();
219219
220+ /* * Initializes the context with given list of scopes.
221+ * Ownership of the scopes is transferred to the stack.
222+ * @note added in QGIS 3.0
223+ */
224+ explicit QgsExpressionContext ( const QList<QgsExpressionContextScope*>& scopes /Transfer/ );
225+
220226 /* * Copy constructor
221227 */
222228 QgsExpressionContext ( const QgsExpressionContext& other );
@@ -359,6 +365,14 @@ class QgsExpressionContext
359365 */
360366 void appendScope ( QgsExpressionContextScope* scope /Transfer/ );
361367
368+ /* * Appends a list of scopes to the end of the context. This scopes will override
369+ * any matching variables or functions provided by existing scopes within the
370+ * context. Ownership of the scopes is transferred to the stack.
371+ * @param scopes scopes to append to context
372+ * @note added in QGIS 3.0
373+ */
374+ void appendScopes ( const QList<QgsExpressionContextScope*>& scopes /Transfer/ );
375+
362376 /* *
363377 * Removes the last scope from the expression context and return it.
364378 */
@@ -484,15 +498,20 @@ class QgsExpressionContextUtils
484498 static QgsExpressionContextScope* globalScope () /Factory/;
485499 static void setGlobalVariable ( const QString& name, const QVariant& value );
486500 static void setGlobalVariables ( const QVariantMap& variables );
487- static QgsExpressionContextScope* projectScope () /Factory/;
488- static void setProjectVariable ( const QString& name, const QVariant& value );
489- static void setProjectVariables ( const QVariantMap& variables );
501+ static QgsExpressionContextScope* projectScope ( const QgsProject* project ) /Factory/;
502+ static void setProjectVariable ( QgsProject* project, const QString& name, const QVariant& value );
503+ static void setProjectVariables ( QgsProject* project, const QVariantMap& variables );
490504
491505 /* * Creates a new scope which contains variables and functions relating to a QgsMapLayer.
492506 * For instance, layer name, id and fields.
493507 */
494508 static QgsExpressionContextScope* layerScope ( const QgsMapLayer *layer ) /Factory/;
495509
510+ /* * Creates a list of three scopes: global, layer's project and layer.
511+ * @note added in QGIS 3.0
512+ */
513+ static QList<QgsExpressionContextScope*> globalProjectLayerScopes ( const QgsMapLayer* layer ) /Factory/;
514+
496515 /* * Sets a layer context variable. This variable will be contained within scopes retrieved via
497516 * layerScope().
498517 * @param layer map layer
0 commit comments