Skip to content
Permalink
Browse files

[layout] Make "show feature count" button apply to all selected indexes

Fixes #37194
  • Loading branch information
nyalldawson committed Jun 15, 2020
1 parent 803f507 commit 671cebcf817e2b6fc17ce0307edf7fa377b665d3
Showing with 10 additions and 11 deletions.
  1. +10 −11 src/gui/layout/qgslayoutlegendwidget.cpp
@@ -1012,25 +1012,24 @@ void QgsLayoutLegendWidget::resetLayerNodeToDefaults()

void QgsLayoutLegendWidget::mCountToolButton_clicked( bool checked )
{
QgsDebugMsgLevel( QStringLiteral( "Entered." ), 4 );
if ( !mLegend )
{
return;
}

//get current item
QModelIndex currentIndex = mItemTreeView->currentIndex();
if ( !currentIndex.isValid() )
{
return;
}

QgsLayerTreeNode *currentNode = mItemTreeView->currentNode();
if ( !QgsLayerTree::isLayer( currentNode ) )
const QList< QModelIndex > selectedIndexes = mItemTreeView->selectionModel()->selectedIndexes();
if ( selectedIndexes.empty() )
return;

mLegend->beginCommand( tr( "Update Legend" ) );
currentNode->setCustomProperty( QStringLiteral( "showFeatureCount" ), checked ? 1 : 0 );
for ( const QModelIndex &index : selectedIndexes )
{
QgsLayerTreeNode *currentNode = mItemTreeView->layerTreeModel()->index2node( index );
if ( !QgsLayerTree::isLayer( currentNode ) )
continue;

currentNode->setCustomProperty( QStringLiteral( "showFeatureCount" ), checked ? 1 : 0 );
}
mLegend->updateFilterByMap();
mLegend->adjustBoxSize();
mLegend->endCommand();

0 comments on commit 671cebc

Please sign in to comment.
You can’t perform that action at this time.