Skip to content
Permalink
Browse files

Merge pull request #7250 from rldhont/composer-filter-legend-nodes-fi…

…x-218

Remove invisible layers from legend
  • Loading branch information
rldhont committed Jun 18, 2018
2 parents 4d07516 + cf3054d commit 085b93941cbb815b250f9fa7ffded711a0a575cc
Showing with 13 additions and 10 deletions.
  1. +13 −10 src/core/layertree/qgslayertreemodel.cpp
@@ -1150,21 +1150,24 @@ QList<QgsLayerTreeModelLegendNode*> QgsLayerTreeModel::filterLegendNodes( const
}
else if ( mLegendFilterMapSettings )
{
Q_FOREACH ( QgsLayerTreeModelLegendNode* node, nodes )
if ( !nodes.isEmpty() && mLegendFilterMapSettings->layers().contains( nodes.at( 0 )->layerNode()->layerId() ) )
{
QgsSymbolV2* ruleKey = reinterpret_cast< QgsSymbolV2* >( node->data( QgsSymbolV2LegendNode::SymbolV2LegacyRuleKeyRole ).value<void*>() );
bool checked = mLegendFilterUsesExtent || node->data( Qt::CheckStateRole ).toInt() == Qt::Checked;
if ( ruleKey && checked )
Q_FOREACH ( QgsLayerTreeModelLegendNode* node, nodes )
{
QString ruleKey = node->data( QgsSymbolV2LegendNode::RuleKeyRole ).toString();
if ( QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( node->layerNode()->layer() ) )
QgsSymbolV2* ruleKey = reinterpret_cast< QgsSymbolV2* >( node->data( QgsSymbolV2LegendNode::SymbolV2LegacyRuleKeyRole ).value<void*>() );
bool checked = mLegendFilterUsesExtent || node->data( Qt::CheckStateRole ).toInt() == Qt::Checked;
if ( ruleKey && checked )
{
if ( mLegendFilterHitTest->legendKeyVisible( ruleKey, vl ) )
filtered << node;
QString ruleKey = node->data( QgsSymbolV2LegendNode::RuleKeyRole ).toString();
if ( QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( node->layerNode()->layer() ) )
{
if ( mLegendFilterHitTest->legendKeyVisible( ruleKey, vl ) )
filtered << node;
}
}
else // unknown node type or unchecked
filtered << node;
}
else // unknown node type or unchecked
filtered << node;
}
}
else

0 comments on commit 085b939

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