Skip to content

Commit

Permalink
Don't show non-spatial layers as disabled in layer tree
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 31, 2018
1 parent e73161f commit bb6e275
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/core/layertree/qgslayertreemodel.cpp
Expand Up @@ -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 ) )
Expand All @@ -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 );
}
Expand Down

0 comments on commit bb6e275

Please sign in to comment.