Skip to content

Commit

Permalink
Refresh feature count legend text automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed May 11, 2017
1 parent 5267677 commit d452f7f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/core/layertree/qgslayertreemodellegendnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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();
}


Expand Down

0 comments on commit d452f7f

Please sign in to comment.