Skip to content
Permalink
Browse files

Merge pull request #4598 from Gustry/atlas_expressions

[needs-docs] add layerid and layername to atlas expressions
  • Loading branch information
nyalldawson committed May 28, 2017
2 parents ba079d8 + 0a661d5 commit 83815baacff1a24403d533d34e974ab60a494552
Showing with 4 additions and 0 deletions.
  1. +2 −0 src/core/expression/qgsexpression.cpp
  2. +2 −0 src/core/qgsexpressioncontext.cpp
@@ -638,6 +638,8 @@ void QgsExpression::initVariableHelp()
sVariableHelpTexts.insert( QStringLiteral( "layout_dpi" ), QCoreApplication::translate( "variable_help", "Composition resolution (DPI)." ) );

//atlas variables
sVariableHelpTexts.insert( QStringLiteral( "atlas_layerid" ), QCoreApplication::translate( "variable_help", "Current atlas coverage layer ID." ) );
sVariableHelpTexts.insert( QStringLiteral( "atlas_layername" ), QCoreApplication::translate( "variable_help", "Current atlas coverage layer name." ) );
sVariableHelpTexts.insert( QStringLiteral( "atlas_totalfeatures" ), QCoreApplication::translate( "variable_help", "Total number of features in atlas." ) );
sVariableHelpTexts.insert( QStringLiteral( "atlas_featurenumber" ), QCoreApplication::translate( "variable_help", "Current atlas feature number." ) );
sVariableHelpTexts.insert( QStringLiteral( "atlas_filename" ), QCoreApplication::translate( "variable_help", "Current atlas file name." ) );
@@ -987,6 +987,8 @@ QgsExpressionContextScope *QgsExpressionContextUtils::atlasScope( const QgsAtlas
if ( atlas->enabled() && atlas->coverageLayer() )
{
scope->setFields( atlas->coverageLayer()->fields() );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "atlas_layerid" ), atlas->coverageLayer()->id(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "atlas_layername" ), atlas->coverageLayer()->name(), true ) );
}

if ( atlas->enabled() )

0 comments on commit 83815ba

Please sign in to comment.
You can’t perform that action at this time.