composer legend feature counts add only to multi symbol or labeled single symbols

This commit is contained in:
Radim Blazek 2013-03-20 10:50:19 +01:00
parent 981c174fb4
commit 7008cd403b

View File

@ -165,7 +165,12 @@ int QgsLegendModel::addVectorLayerItemsV2( QStandardItem* layerItem, QgsVectorLa
QString label = symbolIt->first;
if ( lItem->showFeatureCount() )
{
label += QString( " [%1]" ).arg( vlayer->featureCount( symbolIt->second ) );
// Add counts to multi symbols layers only or labeled single symbols,
// so that single symbol layers are still drawn on single line
if ( lst.size() > 1 || !label.isEmpty() )
{
label += QString( " [%1]" ).arg( vlayer->featureCount( symbolIt->second ) );
}
}
QgsComposerSymbolV2Item* currentSymbolItem = new QgsComposerSymbolV2Item( label );
currentSymbolItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );