Skip to content
Permalink
Browse files

Don't show non-spatial layers as disabled in layer tree

  • Loading branch information
nyalldawson committed Jan 31, 2018
1 parent e73161f commit bb6e275ef03375cafeada8916d00fe87fbeaf1f4
Showing with 5 additions and 6 deletions.
  1. +5 −6 src/core/layertree/qgslayertreemodel.cpp
@@ -242,11 +242,10 @@ QVariant QgsLayerTreeModel::data( const QModelIndex &index, int role ) const
if ( QgsLayerTree::isLayer( node ) )
{
QgsLayerTreeLayer *nodeLayer = QgsLayerTree::toLayer( node );
if ( nodeLayer->layer() && nodeLayer->layer()->type() == QgsMapLayer::VectorLayer )
{
if ( qobject_cast<QgsVectorLayer *>( nodeLayer->layer() )->geometryType() == QgsWkbTypes::NullGeometry )
return QVariant(); // do not show checkbox for non-spatial tables
}

if ( nodeLayer->layer() && !nodeLayer->layer()->isSpatial() )
return QVariant(); // do not show checkbox for non-spatial tables

return nodeLayer->itemVisibilityChecked() ? Qt::Checked : Qt::Unchecked;
}
else if ( QgsLayerTree::isGroup( node ) )
@@ -270,7 +269,7 @@ QVariant QgsLayerTreeModel::data( const QModelIndex &index, int role ) const
if ( QgsLayerTree::isLayer( node ) )
{
const QgsMapLayer *layer = QgsLayerTree::toLayer( node )->layer();
if ( !node->isVisible() || ( layer && !layer->isInScaleRange( mLegendMapViewScale ) ) )
if ( ( !node->isVisible() && ( !layer || layer->isSpatial() ) ) || ( layer && !layer->isInScaleRange( mLegendMapViewScale ) ) )
{
brush.setColor( Qt::lightGray );
}

0 comments on commit bb6e275

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