Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
More gui expression porting
  • Loading branch information
nyalldawson committed Aug 22, 2015
1 parent 786de4b commit 000a62f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/app/qgsdiagramproperties.cpp
Expand Up @@ -526,14 +526,20 @@ void QgsDiagramProperties::on_mFindMaximumValueButton_clicked()
if ( isExpression )
{
QgsExpression exp( sizeFieldNameOrExp );
exp.prepare( mLayer->fields() );
QgsExpressionContext context;
context << QgsExpressionContextUtils::globalScope()
<< QgsExpressionContextUtils::projectScope()
<< QgsExpressionContextUtils::layerScope( mLayer );

exp.prepare( &context );
if ( !exp.hasEvalError() )
{
QgsFeature feature;
QgsFeatureIterator features = mLayer->getFeatures();
while ( features.nextFeature( *&feature ) )
{
maxValue = qMax( maxValue, exp.evaluate( &feature ).toFloat() );
context.setFeature( feature );
maxValue = qMax( maxValue, exp.evaluate( &context ).toFloat() );
}
}
else
Expand Down

0 comments on commit 000a62f

Please sign in to comment.