Skip to content
Permalink
Browse files

Remove invisible layers from legend

Do not show invisible layers in composer legend.
Useful for raster layers as QgsMapHitTest only take care of vector layers.
Related with #14194
Related with #11641
  • Loading branch information
arnaud-morvan authored and wonder-sk committed Aug 5, 2017
1 parent b0c29da commit a3bd321baf4321b145f7c48f760449ac1ad0d4a3
Showing with 14 additions and 11 deletions.
  1. +14 −11 src/core/layertree/qgslayertreemodel.cpp
@@ -1138,24 +1138,27 @@ QList<QgsLayerTreeModelLegendNode *> QgsLayerTreeModel::filterLegendNodes( const
}
else if ( mLegendFilterMapSettings )
{
Q_FOREACH ( QgsLayerTreeModelLegendNode *node, nodes )
if ( !nodes.isEmpty() && mLegendFilterMapSettings->layers().contains( nodes.at( 0 )->layerNode()->layer() ) )
{
QString ruleKey = node->data( QgsSymbolLegendNode::RuleKeyRole ).toString();
bool checked = mLegendFilterUsesExtent || node->data( Qt::CheckStateRole ).toInt() == Qt::Checked;
if ( checked )
Q_FOREACH ( QgsLayerTreeModelLegendNode *node, nodes )
{
if ( QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( node->layerNode()->layer() ) )
QString ruleKey = node->data( QgsSymbolLegendNode::RuleKeyRole ).toString();
bool checked = mLegendFilterUsesExtent || node->data( Qt::CheckStateRole ).toInt() == Qt::Checked;
if ( checked )
{
if ( mLegendFilterHitTest->legendKeyVisible( ruleKey, vl ) )
if ( QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( node->layerNode()->layer() ) )
{
if ( mLegendFilterHitTest->legendKeyVisible( ruleKey, vl ) )
filtered << node;
}
else
{
filtered << node;
}
}
else
{
else // unknown node type or unchecked
filtered << node;
}
}
else // unknown node type or unchecked
filtered << node;
}
}
else

0 comments on commit a3bd321

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