Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 085b939
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/core/layertree/qgslayertreemodel.cpp
Expand Up @@ -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
Expand Down

0 comments on commit 085b939

Please sign in to comment.