Skip to content

Commit

Permalink
Add missing help and show missing variables in editor
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 14, 2016
1 parent 40dc7dd commit 6fcb3ea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/core/qgsexpression.cpp
Expand Up @@ -4449,6 +4449,10 @@ void QgsExpression::initVariableHelp()
gVariableHelpTexts.insert( "row_number", QCoreApplication::translate( "variable_help", "Stores the number of the current row." ) );
gVariableHelpTexts.insert( "grid_number", QCoreApplication::translate( "variable_help", "Current grid annotation value." ) );
gVariableHelpTexts.insert( "grid_axis", QCoreApplication::translate( "variable_help", "Current grid annotation axis (eg, 'x' for longitude, 'y' for latitude)." ) );

//symbol variables
gVariableHelpTexts.insert( "geometry_part_count", QCoreApplication::translate( "variable_help", "Number of parts in rendered feature's geometry." ) );
gVariableHelpTexts.insert( "geometry_part_num", QCoreApplication::translate( "variable_help", "Current geometry part number for feature being rendered." ) );
}

QString QgsExpression::variableHelpText( const QString &variableName, bool showValue, const QVariant &value )
Expand Down
5 changes: 5 additions & 0 deletions src/gui/symbology-ng/qgssizescalewidget.cpp
Expand Up @@ -116,6 +116,11 @@ static QgsExpressionContext _getExpressionContext( const void* context )
if ( widget->layer() )
expContext << QgsExpressionContextUtils::layerScope( widget->layer() );

expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( "geometry_part_count", 1, true ) );
expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( "geometry_part_num", 1, true ) );

expContext.setHighlightedVariables( QStringList() << "geometry_part_num" );

return expContext;
}

Expand Down
5 changes: 4 additions & 1 deletion src/gui/symbology-ng/qgssymbollayerv2widget.cpp
Expand Up @@ -75,9 +75,12 @@ static QgsExpressionContext _getExpressionContext( const void* context )
if ( layer )
expContext << QgsExpressionContextUtils::layerScope( layer );

expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( "geometry_part_count", 1, true ) );
expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( "geometry_part_num", 1, true ) );

//TODO - show actual value
expContext.setOriginalValueVariable( QVariant() );
expContext.setHighlightedVariables( QStringList() << QgsExpressionContext::EXPR_ORIGINAL_VALUE );
expContext.setHighlightedVariables( QStringList() << QgsExpressionContext::EXPR_ORIGINAL_VALUE << "geometry_part_count" << "geometry_part_num" );

return expContext;
}
Expand Down

0 comments on commit 6fcb3ea

Please sign in to comment.