Skip to content
Permalink
Browse files

Bad layers indicator raster support

  • Loading branch information
elpaso committed Oct 30, 2018
1 parent 66b9b5f commit 2af5fd1950a1165d0b56c4a948acb5cb844877d0
Showing with 19 additions and 14 deletions.
  1. +15 −10 src/app/qgslayertreeviewindicatorprovider.cpp
  2. +4 −4 src/app/qgslayertreeviewindicatorprovider.h
@@ -20,6 +20,7 @@
#include "qgslayertreeutils.h"
#include "qgslayertreeview.h"
#include "qgsvectorlayer.h"
#include "qgsrasterlayer.h"
#include "qgisapp.h"

QgsLayerTreeViewIndicatorProvider::QgsLayerTreeViewIndicatorProvider( QgsLayerTreeView *view )
@@ -89,16 +90,20 @@ void QgsLayerTreeViewIndicatorProvider::onWillRemoveChildren( QgsLayerTreeNode *

void QgsLayerTreeViewIndicatorProvider::onLayerLoaded()
{

QgsLayerTreeLayer *layerNode = qobject_cast<QgsLayerTreeLayer *>( sender() );
if ( !layerNode )
return;

if ( QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layerNode->layer() ) )
if ( !( qobject_cast<QgsVectorLayer *>( layerNode->layer() ) || qobject_cast<QgsRasterLayer *>( layerNode->layer() ) ) )
return;

if ( QgsMapLayer *mapLayer = qobject_cast<QgsMapLayer *>( layerNode->layer() ) )
{
if ( vlayer )
if ( mapLayer )
{
connectSignals( vlayer );
addOrRemoveIndicator( layerNode, vlayer );
connectSignals( mapLayer );
addOrRemoveIndicator( layerNode, mapLayer );
}
}
}
@@ -123,18 +128,18 @@ void QgsLayerTreeViewIndicatorProvider::onLayerChanged()

void QgsLayerTreeViewIndicatorProvider::connectSignals( QgsMapLayer *layer )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
if ( !vlayer )
if ( !( qobject_cast<QgsVectorLayer *>( layer ) || qobject_cast<QgsRasterLayer *>( layer ) ) )
return;
connect( vlayer, &QgsVectorLayer::dataSourceChanged, this, &QgsLayerTreeViewIndicatorProvider::onLayerChanged );
QgsMapLayer *mapLayer = qobject_cast<QgsMapLayer *>( layer );
connect( mapLayer, &QgsMapLayer::dataSourceChanged, this, &QgsLayerTreeViewIndicatorProvider::onLayerChanged );
}

void QgsLayerTreeViewIndicatorProvider::disconnectSignals( QgsMapLayer *layer )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
if ( !vlayer )
if ( !( qobject_cast<QgsVectorLayer *>( layer ) || qobject_cast<QgsRasterLayer *>( layer ) ) )
return;
disconnect( vlayer, &QgsVectorLayer::dataSourceChanged, this, &QgsLayerTreeViewIndicatorProvider::onLayerChanged );
QgsMapLayer *mapLayer = qobject_cast<QgsMapLayer *>( layer );
disconnect( mapLayer, &QgsMapLayer::dataSourceChanged, this, &QgsLayerTreeViewIndicatorProvider::onLayerChanged );
}

std::unique_ptr< QgsLayerTreeViewIndicator > QgsLayerTreeViewIndicatorProvider::newIndicator( QgsMapLayer *layer )
@@ -38,8 +38,8 @@ class QgsMapLayer;
*
* Subclasses may override:
* - onIndicatorClicked() default implementation does nothing
* - connectSignals() default implementation connects vector layers to dataSourceChanged()
* - disconnectSignals() default implementation disconnects vector layers from dataSourceChanged()
* - connectSignals() default implementation connects layers to dataSourceChanged()
* - disconnectSignals() default implementation disconnects layers from dataSourceChanged()
*/
class QgsLayerTreeViewIndicatorProvider : public QObject
{
@@ -51,9 +51,9 @@ class QgsLayerTreeViewIndicatorProvider : public QObject
protected:

// Subclasses MAY override:
//! Connect signals, default implementation connects vector layers to dataSourceChanged()
//! Connect signals, default implementation connects layers to dataSourceChanged()
virtual void connectSignals( QgsMapLayer *layer );
//! Disconnect signals, default implementation disconnects vector layers from dataSourceChanged()
//! Disconnect signals, default implementation disconnects layers from dataSourceChanged()
virtual void disconnectSignals( QgsMapLayer *layer );

protected slots:

0 comments on commit 2af5fd1

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