62 : mName( other.mName )
63 , mVariables( other.mVariables )
64 , mHasFeature( other.mHasFeature )
65 , mFeature( other.mFeature )
67 QHash<QString, QgsScopedExpressionFunction * >::const_iterator it = other.mFunctions.constBegin();
68 for ( ; it != other.mFunctions.constEnd(); ++it )
70 mFunctions.insert( it.key(), it.value()->clone() );
77 mVariables = other.mVariables;
78 mHasFeature = other.mHasFeature;
79 mFeature = other.mFeature;
81 qDeleteAll( mFunctions );
83 QHash<QString, QgsScopedExpressionFunction * >::const_iterator it = other.mFunctions.constBegin();
84 for ( ; it != other.mFunctions.constEnd(); ++it )
86 mFunctions.insert( it.key(), it.value()->clone() );
94 qDeleteAll( mFunctions );
99 if ( mVariables.contains( name ) )
102 existing.
value = value;
114 mVariables.insert( variable.
name, variable );
119 return mVariables.remove( name ) > 0;
124 return mVariables.contains( name );
129 return hasVariable( name ) ? mVariables.value( name ).value : QVariant();
134 QStringList names = mVariables.keys();
138 bool QgsExpressionContextScope::variableNameSort(
const QString &a,
const QString &b )
140 return QString::localeAwareCompare( a, b ) < 0;
144 class QgsExpressionContextVariableCompare
151 bool operator()(
const QString &a,
const QString &b )
const 153 bool aReadOnly = mScope.isReadOnly( a );
154 bool bReadOnly = mScope.isReadOnly( b );
155 if ( aReadOnly != bReadOnly )
157 return QString::localeAwareCompare( a, b ) < 0;
167 QStringList allVariables = mVariables.keys();
168 QStringList filtered;
169 Q_FOREACH (
const QString &
variable, allVariables )
171 if ( variable.startsWith(
'_' ) )
176 QgsExpressionContextVariableCompare cmp( *
this );
177 std::sort( filtered.begin(), filtered.end(), cmp );
184 return hasVariable( name ) ? mVariables.value( name ).readOnly :
false;
189 return hasVariable( name ) ? mVariables.value( name ).isStatic :
false;
194 return hasVariable( name ) ? mVariables.value( name ).description : QString();
199 return mFunctions.contains( name );
204 return mFunctions.contains( name ) ? mFunctions.value( name ) :
nullptr;
209 return mFunctions.keys();
214 mFunctions.insert( name,
function );
239 mHighlightedVariables = other.mHighlightedVariables;
240 mCachedValues = other.mCachedValues;
245 if (
this != &other )
247 qDeleteAll( mStack );
249 mStack = other.mStack;
250 other.mStack.clear();
252 mHighlightedVariables = other.mHighlightedVariables;
253 mCachedValues = other.mCachedValues;
260 qDeleteAll( mStack );
266 mHighlightedVariables = other.mHighlightedVariables;
267 mCachedValues = other.mCachedValues;
273 qDeleteAll( mStack );
290 return scope ? scope->
variable( name ) : QVariant();
297 Q_FOREACH (
const QString &name, names )
306 return mHighlightedVariables.contains( name );
317 QList< QgsExpressionContextScope * >::const_iterator it = mStack.constEnd();
318 while ( it != mStack.constBegin() )
321 if ( ( *it )->hasVariable( name ) )
330 QList< QgsExpressionContextScope * >::const_iterator it = mStack.constEnd();
331 while ( it != mStack.constBegin() )
334 if ( ( *it )->hasVariable( name ) )
342 if ( index < 0 || index >= mStack.count() )
345 return mStack.at( index );
350 if ( mStack.count() < 1 )
353 return mStack.last();
361 return mStack.indexOf( scope );
369 if ( scope->
name() == scopeName )
384 return names.toSet().toList();
390 QStringList filtered;
391 Q_FOREACH (
const QString &
variable, allVariables )
393 if ( variable.startsWith(
'_' ) )
436 result = result.toSet().toList();
444 QList< QgsExpressionContextScope * >::const_iterator it = mStack.constEnd();
445 while ( it != mStack.constBegin() )
448 if ( ( *it )->hasFunction( name ) )
449 return ( *it )->function( name );
456 return mStack.count();
461 mStack.append( scope );
466 mStack.append( scopes );
471 if ( !mStack.isEmpty() )
472 return mStack.takeLast();
479 QList<QgsExpressionContextScope *> stack = mStack;
486 mStack.append( scope );
492 if ( mStack.isEmpty() )
495 mStack.last()->setFeature( feature );
511 QList< QgsExpressionContextScope * >::const_iterator it = mStack.constEnd();
512 while ( it != mStack.constBegin() )
515 if ( ( *it )->hasFeature() )
516 return ( *it )->feature();
523 if ( mStack.isEmpty() )
526 mStack.last()->setFields( fields );
536 if ( mStack.isEmpty() )
545 mCachedValues.insert( key, value );
550 return mCachedValues.contains( key );
555 return mCachedValues.value( key, QVariant() );
560 mCachedValues.clear();
574 for ( QVariantMap::const_iterator it = customVariables.constBegin(); it != customVariables.constEnd(); ++it )
606 if ( vars.remove( name ) )
616 GetNamedProjectColor(
const QgsProject *project )
618 , mProject( project )
624 QStringList colorStrings = project->
readListEntry( QStringLiteral(
"Palette" ), QStringLiteral(
"/Colors" ) );
625 QStringList colorLabels = project->
readListEntry( QStringLiteral(
"Palette" ), QStringLiteral(
"/Labels" ) );
629 for ( QStringList::iterator it = colorStrings.begin();
630 it != colorStrings.end(); ++it )
634 if ( colorLabels.length() > colorIndex )
636 label = colorLabels.at( colorIndex );
639 mColors.insert( label.toLower(), color );
646 QString colorName = values.at( 0 ).toString().toLower();
647 if ( mColors.contains( colorName ) )
649 return QStringLiteral(
"%1,%2,%3" ).arg( mColors.value( colorName ).red() ).arg( mColors.value( colorName ).green() ).arg( mColors.value( colorName ).blue() );
657 return new GetNamedProjectColor( mProject );
663 QHash< QString, QColor > mColors;
680 QString
id = values.at( 0 ).toString();
693 return new GetLayoutItemVariables( mLayout );
705 GetLayerVisibility(
const QList<QgsMapLayer *> &layers )
712 if ( mLayers.isEmpty() )
714 return QVariant(
false );
717 QgsMapLayer *layer = _qgis_findLayer( mLayers, values.at( 0 ).toString() );
720 return QVariant(
true );
724 return QVariant(
false );
730 return new GetLayerVisibility( mLayers );
735 const QList<QgsMapLayer *> mLayers;
743 GetCurrentFormFieldValue( )
749 QString fieldName( values.at( 0 ).toString() );
751 if ( fieldName.isEmpty() || ! feat.isValid( ) )
755 return feat.attribute( fieldName ) ;
760 return new GetCurrentFormFieldValue( );
769 GetProcessingParameterValue(
const QVariantMap ¶ms )
776 return mParams.value( values.at( 0 ).toString() );
781 return new GetProcessingParameterValue( mParams );
786 const QVariantMap mParams;
796 scope->
addFunction( QStringLiteral(
"current_value" ),
new GetCurrentFormFieldValue( ) );
798 scope->
setVariable( QStringLiteral(
"current_feature" ), formFeature,
true );
811 QVariantMap::const_iterator it = vars.constBegin();
813 for ( ; it != vars.constEnd(); ++it )
819 QString projectFolder = QFileInfo( projectPath ).path();
820 QString projectFilename = QFileInfo( projectPath ).fileName();
821 QString projectBasename = project->
baseName();
841 QVariantMap keywords;
843 for (
auto it = metadataKeywords.constBegin(); it != metadataKeywords.constEnd(); ++it )
845 keywords.insert( it.key(), it.value() );
849 scope->
addFunction( QStringLiteral(
"project_color" ),
new GetNamedProjectColor( project ) );
860 vars.insert( name, value );
881 if ( vars.remove( name ) )
894 QStringList variableValues = layer->
customProperty( QStringLiteral(
"variableValues" ) ).toStringList();
897 Q_FOREACH (
const QString &variableName, variableNames )
899 if ( varIndex >= variableValues.length() )
904 QVariant varValue = variableValues.at( varIndex );
906 scope->
setVariable( variableName, varValue,
true );
928 QList<QgsExpressionContextScope *>
scopes;
929 scopes << globalScope();
933 scopes << projectScope( project );
936 scopes << layerScope( layer );
948 QStringList variableValues = layer->
customProperty( QStringLiteral(
"variableValues" ) ).toStringList();
950 variableNames << name;
951 variableValues << value.toString();
963 QStringList variableValues;
965 QVariantMap::const_iterator it = variables.constBegin();
966 for ( ; it != variables.constEnd(); ++it )
968 variableNames << it.key();
969 variableValues << it.value().toString();
998 scope->
addFunction( QStringLiteral(
"is_layer_visible" ),
new GetLayerVisibility( mapSettings.
layers() ) );
1007 QVariantList matchList;
1011 QVariantMap matchMap;
1013 matchMap.insert( QStringLiteral(
"valid" ), match.isValid() );
1014 matchMap.insert( QStringLiteral(
"layer" ), QVariant::fromValue<QgsWeakMapLayerPointer>(
QgsWeakMapLayerPointer( match.layer() ) ) );
1015 matchMap.insert( QStringLiteral(
"feature_id" ), match.featureId() );
1016 matchMap.insert( QStringLiteral(
"vertex_index" ), match.vertexIndex() );
1017 matchMap.insert( QStringLiteral(
"distance" ), match.distance() );
1019 matchList.append( matchMap );
1038 angle = markerSymbol->
angle();
1049 return scope.release();
1053 QStringList variableValues = layout->
customProperty( QStringLiteral(
"variableValues" ) ).toStringList();
1056 Q_FOREACH (
const QString &variableName, variableNames )
1058 if ( varIndex >= variableValues.length() )
1063 QVariant varValue = variableValues.at( varIndex );
1065 scope->setVariable( variableName, varValue );
1082 scope->addFunction( QStringLiteral(
"item_variables" ),
new GetLayoutItemVariables( layout ) );
1094 scope->setFeature( atlasFeature );
1100 return scope.release();
1110 QStringList variableValues = layout->
customProperty( QStringLiteral(
"variableValues" ) ).toStringList();
1112 variableNames << name;
1113 variableValues << value.toString();
1116 layout->
setCustomProperty( QStringLiteral(
"variableValues" ), variableValues );
1125 QStringList variableValues;
1127 QVariantMap::const_iterator it = variables.constBegin();
1128 for ( ; it != variables.constEnd(); ++it )
1130 variableNames << it.key();
1131 variableValues << it.value().toString();
1135 layout->
setCustomProperty( QStringLiteral(
"variableValues" ), variableValues );
1185 const QStringList variableValues = item->
customProperty( QStringLiteral(
"variableValues" ) ).toStringList();
1188 for (
const QString &variableName : variableNames )
1190 if ( varIndex >= variableValues.length() )
1195 QVariant varValue = variableValues.at( varIndex );
1231 QStringList variableValues = item->
customProperty( QStringLiteral(
"variableValues" ) ).toStringList();
1233 variableNames << name;
1234 variableValues << value.toString();
1246 QStringList variableValues;
1248 QVariantMap::const_iterator it = variables.constBegin();
1249 for ( ; it != variables.constEnd(); ++it )
1251 variableNames << it.key();
1252 variableValues << it.value().toString();
1270 Q_UNUSED( context );
1274 return scope.release();
1279 scope->addFunction( QStringLiteral(
"parameter" ),
new GetProcessingParameterValue( parameters ) );
1281 return scope.release();
1288 return scope.release();
1303 return mUsesGeometry;
1309 return mReferencedColumns;
1314 return allParamsStatic( node, parent, context );
bool isValid() const
Returns the validity of this feature.
bool hasVariable(const QString &name) const
Tests whether a variable with the specified name exists in the scope.
static const QString EXPR_ORIGINAL_VALUE
Inbuilt variable name for value original value variable.
Class for parsing and evaluation of expressions (formerly called "search strings").
static QString locale()
Returns the QGIS locale.
static QgsExpressionContextScope * updateSymbolScope(const QgsSymbol *symbol, QgsExpressionContextScope *symbolScope=nullptr)
Updates a symbol scope related to a QgsSymbol to an expression context.
QVariant cachedValue(const QString &key) const
Returns the matching cached value, if set.
QString description(const QString &name) const
Returns the translated description for the variable with the specified name (if set).
static QgsExpressionContextScope * processingAlgorithmScope(const QgsProcessingAlgorithm *algorithm, const QVariantMap ¶meters, QgsProcessingContext &context)
Creates a new scope which contains variables and functions relating to a processing algorithm...
static const QString EXPR_CLUSTER_COLOR
Inbuilt variable name for cluster color variable.
static void setLayoutItemVariable(QgsLayoutItem *item, const QString &name, const QVariant &value)
Sets a layout item context variable, with the given name and value.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Single variable definition for use within a QgsExpressionContextScope.
static void setGlobalVariable(const QString &name, const QVariant &value)
Sets a global context variable.
Base class for all map layer types.
void setCachedValue(const QString &key, const QVariant &value) const
Sets a value to cache within the expression context.
static void setLayoutItemVariables(QgsLayoutItem *item, const QVariantMap &variables)
Sets all layout item context variables for an item.
static const QString QGIS_VERSION
Version string.
QgsExpressionContextScope * scope(int index)
Returns the scope at the specified index within the context.
static void setLayerVariables(QgsMapLayer *layer, const QVariantMap &variables)
Sets all layer context variables.
QString id() const
Returns the unique ID for the algorithm, which is a combination of the algorithm provider's ID and th...
bool isReadOnly(const QString &name) const
Returns whether a variable is read only, and should not be modifiable by users.
Base class for graphical items within a QgsLayout.
static const QString EXPR_GEOMETRY_POINT_COUNT
Inbuilt variable name for point count variable.
static Q_INVOKABLE QString toString(QgsUnitTypes::DistanceUnit unit)
Returns a translated string representing a distance unit.
static void setLayoutVariable(QgsLayout *layout, const QString &name, const QVariant &value)
Sets a layout context variable.
QStringList filteredVariableNames() const
Returns a filtered list of variables names set by all scopes in the context.
static void setCustomVariables(const QVariantMap &customVariables)
Custom expression variables for this application.
QgsExpressionContext & operator=(const QgsExpressionContext &other)
double rotation() const
Returns the rotation of the resulting map image, in degrees clockwise.
bool hasFunction(const QString &name) const
Checks whether a specified function is contained in the context.
QVariant customProperty(const QString &key, const QVariant &defaultValue=QVariant()) const
Read a custom property from the layout.
void addFunction(const QString &name, QgsScopedExpressionFunction *function)
Adds a function to the scope.
QgsExpressionContextScope(const QString &name=QString())
Constructor for QgsExpressionContextScope.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
static void removeProjectVariable(QgsProject *project, const QString &name)
Remove project context variable.
QgsExpressionContextScope * activeScopeForVariable(const QString &name)
Returns the currently active scope from the context for a specified variable name.
static QgsExpressionContext createFeatureBasedContext(const QgsFeature &feature, const QgsFields &fields)
Helper function for creating an expression context which contains just a feature and fields collectio...
QStringList variableNames() const
Returns a list of variable names contained within the scope.
bool hasCachedValue(const QString &key) const
Returns true if the expression context contains a cached value with a matching key.
QgsLayoutSize sizeWithUnits() const
Returns the item's current size, including units.
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for the object.
QVariant customProperty(const QString &key, const QVariant &defaultValue=QVariant()) const
Read a custom property from the object.
QString toProj4() const
Returns a Proj4 string representation of this CRS.
bool isReadOnly(const QString &name) const
Tests whether the specified variable is read only and should not be editable by users.
Container of fields for a vector layer.
bool hasVariable(const QString &name) const
Check whether a variable is specified by any scope within the context.
A geometry is the spatial representation of a feature.
static QVariantMap customVariables()
Custom expression variables for this application.
void setFields(const QgsFields &fields)
Convenience function for setting a fields for the scope.
QgsFields fields() const
Convenience function for retrieving the fields for the context, if set.
static QgsExpressionContextScope * mapToolCaptureScope(const QList< QgsPointLocator::Match > &matches)
Sets the expression context variables which are available for expressions triggered by a map tool cap...
static QString variableHelpText(const QString &variableName)
Returns the help text for a specified variable.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
QList< QgsMapLayer * > layers() const
Gets list of layers for map rendering The layers are stored in the reverse order of how they are rend...
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QgsExpressionContextScope & operator=(const QgsExpressionContextScope &other)
QList< QgsExpressionContextScope * > takeScopes()
Returns all scopes from this context and remove them, leaving this context without any context...
bool usesGeometry(const QgsExpressionNodeFunction *node) const override
Does this function use a geometry object.
static void setLayoutVariables(QgsLayout *layout, const QVariantMap &variables)
Sets all layout context variables.
QPointer< QgsMapLayer > QgsWeakMapLayerPointer
Weak pointer for QgsMapLayer.
static const int QGIS_VERSION_INT
Version number used for comparing versions using the "Check QGIS Version" function.
Abstract base class for processing algorithms.
QList< QgsExpressionFunction::Parameter > ParameterList
List of parameters, used for function definition.
QgsLayoutRenderContext & renderContext()
Returns a reference to the layout's render context, which stores information relating to the current ...
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes takes output image size into accou...
QVariant variable(const QString &name) const
Fetches a matching variable from the context.
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
QgsExpressionContext & operator<<(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
static QString userFullName()
Returns the user's operating system login account full display name.
QgsCoordinateReferenceSystem destinationCrs() const
returns CRS of destination coordinate reference system
QString description(const QString &name) const
Returns a translated description string for the variable with specified name.
bool hasFeature() const
Returns true if the context has a feature associated with it.
QgsUnitTypes::DistanceUnit mapUnits() const
Gets units of map's geographical coordinates - used for scale calculation.
QgsLayout * layout() override
Returns the layout associated with the iterator.
The QgsMapSettings class contains configuration for rendering of the map.
void setVariable(const QString &name, const QVariant &value, bool isStatic=false)
Convenience method for setting a variable in the context scope by name name and value.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
~QgsExpressionContextScope()
QSizeF toQSizeF() const
Converts the layout size to a QSizeF.
static QgsExpressionContextScope * layoutItemScope(const QgsLayoutItem *item)
Creates a new scope which contains variables and functions relating to a QgsLayoutItem.
bool isStatic(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
Will be called during prepare to determine if the function is static.
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
bool removeVariable(const QString &name)
Removes a variable from the context scope, if found.
QgsExpressionContextScope * lastScope()
Returns the last scope added to the context.
QgsVectorLayer * layer() const
Returns the vector layer associated with the layout's context.
bool hasFunction(const QString &name) const
Tests whether a function with the specified name exists in the scope.
static const QString EXPR_SYMBOL_ANGLE
Inbuilt variable name for symbol angle variable.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
const QgsLayout * layout() const
Returns the layout the object is attached to.
QgsLayoutItemPage * page(int pageNumber)
Returns a specific page (by pageNumber) from the collection.
QgsFields fields() const override
Returns the list of fields of this layer.
int scopeCount() const
Returns the number of scopes contained in the context.
bool isHighlightedVariable(const QString &name) const
Returns true if the specified variable name is intended to be highlighted to the user.
QgsLayoutPageCollection * pageCollection()
Returns a pointer to the layout's page collection, which stores and manages page items in the layout...
static void setProjectVariables(QgsProject *project, const QVariantMap &variables)
Sets all project context variables.
QgsProjectMetadata metadata
double scale() const
Returns the calculated map scale.
double dpi() const
Returns the dpi for outputting the layout.
double width() const
Returns the width of the rectangle.
static QgsExpressionContextScope * notificationScope(const QString &message=QString())
Creates a new scope which contains variables and functions relating to provider notifications.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
static void removeGlobalVariable(const QString &name)
Remove a global context variable.
QgsCoordinateReferenceSystem crs
QVariantMap variablesToMap() const
Returns a map of variable name to value representing all the expression variables contained by the co...
Class used to render QgsLayout as an atlas, by iterating over the features from an associated vector ...
QVariant variable(const QString &name) const
Retrieves a variable's value from the scope.
static const QString EXPR_SYMBOL_COLOR
Inbuilt variable name for symbol color variable.
static bool registerFunction(QgsExpressionFunction *function, bool transferOwnership=false)
Registers a function to the expression engine.
QStringList readListEntry(const QString &scope, const QString &key, const QStringList &def=QStringList(), bool *ok=nullptr) const
Key value accessors.
Reads and writes project states.
static void setCustomVariable(const QString &name, const QVariant &value)
Set a single custom expression variable.
QString currentFilename() const
Returns the current feature filename.
int page() const
Returns the page the item is currently on, with the first page returning 0.
QString id() const
Returns the item's ID name.
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
QgsExpressionFunction * function(const QString &name) const
Retrieves a function from the scope.
static const QString EXPR_FIELDS
Inbuilt variable name for fields storage.
QStringList variableNames() const
Returns a list of variables names set by all scopes in the context.
int count() override
Returns the number of features to iterate over.
Single scope for storing variables and functions for use within a QgsExpressionContext.
An expression node for expression functions.
QgsGeometry geometry() const
Returns the geometry associated with this feature.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the scope.
QStringList functionNames() const
Retrieves a list of names of functions contained in the scope.
void setCustomVariables(const QVariantMap &customVariables)
A map of custom project variables.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
void setFields(const QgsFields &fields)
Convenience function for setting a fields for the context.
QgsProjectStorage * projectStorage() const
Returns pointer to project storage implementation that handles read/write of the project file...
static void setLayerVariable(QgsMapLayer *layer, const QString &name, const QVariant &value)
Sets a layer context variable.
static QString userLoginName()
Returns the user's operating system login account name.
static QString osName()
Returns a string name of the operating system QGIS is running on.
int pageCount() const
Returns the number of pages in the collection.
int currentFeatureNumber() const
Returns the current feature number, where a value of 0 corresponds to the first feature.
QgsLayoutReportContext & reportContext()
Returns a reference to the layout's report context, which stores information relating to the current ...
static void setProjectVariable(QgsProject *project, const QString &name, const QVariant &value)
Sets a project context variable.
A abstract base class for defining QgsExpression functions.
static void registerContextFunctions()
Registers all known core functions provided by QgsExpressionContextScope objects. ...
static QgsExpressionContextScope * atlasScope(QgsLayoutAtlas *atlas)
Creates a new scope which contains variables and functions relating to a QgsLayoutAtlas.
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object...
QStringList functionNames() const
Retrieves a list of function names contained in the context.
static const QString QGIS_RELEASE_NAME
Release name.
QgsExpressionContext()=default
Constructor for QgsExpressionContext.
static QgsExpressionContextScope * layoutScope(const QgsLayout *layout)
Creates a new scope which contains variables and functions relating to a QgsLayout layout...
static QgsExpressionContextScope * formScope(const QgsFeature &formFeature=QgsFeature())
Creates a new scope which contains functions and variables from the current attribute form/table feat...
void clearCachedValues() const
Clears all cached values from the context.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
static QgsProject * instance()
Returns the QgsProject singleton instance.
virtual QString uuid() const
Returns the item identification string.
This class represents a coordinate reference system (CRS).
bool isStatic(const QString &name) const
Tests whether the variable with the specified name is static and can be cached.
QString nameForPage(int page) const
Returns the calculated name for a specified atlas page number.
static QString platform()
Returns the QGIS platform name, e.g., "desktop" or "server".
static const QString EXPR_CLUSTER_SIZE
Inbuilt variable name for cluster size variable.
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for the layout.
bool enabled() const
Returns whether the atlas generation is enabled.
bool hasFeature() const
Returns true if the scope has a feature associated with it.
QgsFeature feature() const
Convenience function for retrieving the feature for the context, if set.
static const QString EXPR_GEOMETRY_POINT_NUM
Inbuilt variable name for point number variable.
QgsVectorLayer * coverageLayer() const
Returns the coverage layer used for the atlas features.
QgsFeature feature() const
Returns the current feature for evaluating the layout.
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user...
Represents a single parameter passed to a function.
void appendScopes(const QList< QgsExpressionContextScope *> &scopes)
Appends a list of scopes to the end of the context.
QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
QString title() const
Returns the project's title.
QgsPointXY center() const
Returns the center point of the rectangle.
QVariantMap customVariables() const
A map of custom project variables.
QString name() const
Returns the friendly display name of the context scope.
QgsExpressionContextScope * popScope()
Removes the last scope from the expression context and return it.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
QString baseName() const
Returns the base name of the project file without the path and without extension - derived from fileN...
Interface for master layout type objects, such as print layouts and reports.
static const QString EXPR_GEOMETRY_PART_NUM
Inbuilt variable name for geometry part number variable.
QString absoluteFilePath() const
Returns full absolute path to the project file if the project is stored in a file system - derived fr...
bool isStatic
A static variable can be cached for the lifetime of a context.
Represents a vector layer which manages a vector based data sets.
int indexOfScope(QgsExpressionContextScope *scope) const
Returns the index of the specified scope if it exists within the context.
static const QString EXPR_GEOMETRY_PART_COUNT
Inbuilt variable name for geometry part count variable.
Contains information about the context in which a processing algorithm is executed.
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
QStringList filteredVariableNames() const
Returns a filtered and sorted list of variable names contained within the scope.
QList< QgsExpressionContextScope *> scopes()
Returns a list of scopes contained within the stack.
static void setGlobalVariables(const QVariantMap &variables)
Sets all global context variables.
QgsExpressionFunction * function(const QString &name) const
Fetches a matching function from the context.
Expression function for use within a QgsExpressionContextScope.
double angle() const
Returns the marker angle for the whole symbol.
static QgsGeometry fromPointXY(const QgsPointXY &point)
Creates a new geometry from a QgsPointXY object.
QString authid() const
Returns the authority identifier for the CRS.
QString name
Variable name.
QSet< QString > referencedColumns(const QgsExpressionNodeFunction *node) const override
Returns a set of field names which are required for this function.
static QColor decodeColor(const QString &str)
double height() const
Returns the height of the rectangle.
Item representing the paper in a layout.
QVariant value
Variable value.