Skip to content
Permalink
Browse files
Refresh feature count legend text automatically
  • Loading branch information
m-kuhn committed May 11, 2017
1 parent 5267677 commit d452f7f
Showing 1 changed file with 7 additions and 2 deletions.
@@ -135,7 +135,7 @@ QgsSymbolLegendNode::QgsSymbolLegendNode( QgsLayerTreeLayer *nodeLayer, const Qg
, mIconSize( 16, 16 )
{
updateLabel();
connect( qobject_cast<QgsVectorLayer*>( nodeLayer->layer() ), &QgsVectorLayer::symbolFeatureCountMapChanged, this, &QgsSymbolLegendNode::updateLabel );
connect( qobject_cast<QgsVectorLayer *>( nodeLayer->layer() ), &QgsVectorLayer::symbolFeatureCountMapChanged, this, &QgsSymbolLegendNode::updateLabel );

if ( mItem.symbol() )
mSymbolUsesMapUnits = ( mItem.symbol()->outputUnit() != QgsUnitTypes::RenderMillimeters );
@@ -459,8 +459,13 @@ void QgsSymbolLegendNode::updateLabel()
{
mLabel = mUserLabel.isEmpty() ? mItem.label() : mUserLabel;
if ( showFeatureCount && vl )
mLabel += QStringLiteral( " [%1]" ).arg( vl->featureCount( mItem.ruleKey() ) );
{
long count = vl->featureCount( mItem.ruleKey() );
mLabel += QStringLiteral( " [%1]" ).arg( count != -1 ? QString::number( count ) : tr( "N/A" ) );
}
}

emit dataChanged();
}


0 comments on commit d452f7f

Please sign in to comment.