Skip to content

Commit 6fcb3ea

Browse files
committed
Add missing help and show missing variables in editor
1 parent 40dc7dd commit 6fcb3ea

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/core/qgsexpression.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -4449,6 +4449,10 @@ void QgsExpression::initVariableHelp()
44494449
gVariableHelpTexts.insert( "row_number", QCoreApplication::translate( "variable_help", "Stores the number of the current row." ) );
44504450
gVariableHelpTexts.insert( "grid_number", QCoreApplication::translate( "variable_help", "Current grid annotation value." ) );
44514451
gVariableHelpTexts.insert( "grid_axis", QCoreApplication::translate( "variable_help", "Current grid annotation axis (eg, 'x' for longitude, 'y' for latitude)." ) );
4452+
4453+
//symbol variables
4454+
gVariableHelpTexts.insert( "geometry_part_count", QCoreApplication::translate( "variable_help", "Number of parts in rendered feature's geometry." ) );
4455+
gVariableHelpTexts.insert( "geometry_part_num", QCoreApplication::translate( "variable_help", "Current geometry part number for feature being rendered." ) );
44524456
}
44534457

44544458
QString QgsExpression::variableHelpText( const QString &variableName, bool showValue, const QVariant &value )

src/gui/symbology-ng/qgssizescalewidget.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ static QgsExpressionContext _getExpressionContext( const void* context )
116116
if ( widget->layer() )
117117
expContext << QgsExpressionContextUtils::layerScope( widget->layer() );
118118

119+
expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( "geometry_part_count", 1, true ) );
120+
expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( "geometry_part_num", 1, true ) );
121+
122+
expContext.setHighlightedVariables( QStringList() << "geometry_part_num" );
123+
119124
return expContext;
120125
}
121126

src/gui/symbology-ng/qgssymbollayerv2widget.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,12 @@ static QgsExpressionContext _getExpressionContext( const void* context )
7575
if ( layer )
7676
expContext << QgsExpressionContextUtils::layerScope( layer );
7777

78+
expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( "geometry_part_count", 1, true ) );
79+
expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( "geometry_part_num", 1, true ) );
80+
7881
//TODO - show actual value
7982
expContext.setOriginalValueVariable( QVariant() );
80-
expContext.setHighlightedVariables( QStringList() << QgsExpressionContext::EXPR_ORIGINAL_VALUE );
83+
expContext.setHighlightedVariables( QStringList() << QgsExpressionContext::EXPR_ORIGINAL_VALUE << "geometry_part_count" << "geometry_part_num" );
8184

8285
return expContext;
8386
}

0 commit comments

Comments
 (0)