QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsvectorlayertoolscontext.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectorlayertoolscontext.cpp
3 ------------------------
4 begin : May 2024
5 copyright : (C) 2024 by Mathieu Pellerin
6 email : mathieu at opengis dot ch
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17
18#include <memory>
19
21
23 : mParentWidget( other.mParentWidget )
24 , mShowModal( other.mShowModal )
25 , mHideParent( other.mHideParent )
26{
27 if ( other.mAdditionalExpressionContextScope )
28 {
29 mAdditionalExpressionContextScope = std::make_unique<QgsExpressionContextScope>( *other.mAdditionalExpressionContextScope );
30 }
31 if ( other.mExpressionContext )
32 {
33 mExpressionContext = std::make_unique<QgsExpressionContext>( *other.mExpressionContext );
34 }
35}
36
38{
39 if ( &other == this )
40 return *this;
41
42 mParentWidget = other.mParentWidget;
43 mShowModal = other.mShowModal;
44 mHideParent = other.mHideParent;
45 if ( other.mAdditionalExpressionContextScope )
46 {
47 mAdditionalExpressionContextScope = std::make_unique<QgsExpressionContextScope>( *other.mAdditionalExpressionContextScope );
48 }
49 if ( other.mExpressionContext )
50 {
51 mExpressionContext = std::make_unique<QgsExpressionContext>( *other.mExpressionContext );
52 }
53 else
54 {
55 mExpressionContext.reset();
56 }
57 return *this;
58}
59
61{
62 if ( context )
63 mExpressionContext = std::make_unique<QgsExpressionContext>( *context );
64 else
65 mExpressionContext.reset();
66}
67
69{
70 return mExpressionContext.get();
71}
72
74{
75 if ( scope )
76 mAdditionalExpressionContextScope = std::make_unique<QgsExpressionContextScope>( *scope );
77 else
78 mAdditionalExpressionContextScope.reset();
79}
80
82{
83 return mAdditionalExpressionContextScope.get();
84}
Single scope for storing variables and functions for use within a QgsExpressionContext.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QgsVectorLayerToolsContext()=default
const QgsExpressionContextScope * additionalExpressionContextScope() const
Returns an additional expression context scope to be made available when calculating expressions.
void setExpressionContext(const QgsExpressionContext *context)
Sets the optional expression context used by the vector layer tools.
QgsVectorLayerToolsContext & operator=(const QgsVectorLayerToolsContext &other)
QgsExpressionContext * expressionContext() const
Returns the optional expression context used by the vector layer tools.
void setAdditionalExpressionContextScope(const QgsExpressionContextScope *scope)
Sets an additional expression context scope to be made available when calculating expressions.