Skip to content
Permalink
Browse files

disable topology check button if layer not editable

  • Loading branch information
3nids authored and m-kuhn committed Oct 3, 2018
1 parent d527fed commit e9e849a8e1a9212ec2a0d2c8fca6fcf348635715
Showing with 28 additions and 5 deletions.
  1. +25 −5 src/app/qgsgeometryvalidationdock.cpp
  2. +3 −0 src/app/qgsgeometryvalidationdock.h
@@ -260,13 +260,33 @@ void QgsGeometryValidationDock::onCurrentErrorChanged( const QModelIndex &curren

void QgsGeometryValidationDock::onCurrentLayerChanged( QgsMapLayer *layer )
{
// activate icon
if ( layer == mCurrentLayer )
return;

if ( mCurrentLayer )
{
disconnect( mCurrentLayer, &QgsVectorLayer::editingStarted, this, &QgsGeometryValidationDock::onLayerEditingStatusChanged );
disconnect( mCurrentLayer, &QgsVectorLayer::editingStopped, this, &QgsGeometryValidationDock::onLayerEditingStatusChanged );
}

mCurrentLayer = qobject_cast<QgsVectorLayer *>( layer );

if ( mCurrentLayer )
{
connect( mCurrentLayer, &QgsVectorLayer::editingStarted, this, &QgsGeometryValidationDock::onLayerEditingStatusChanged );
connect( mCurrentLayer, &QgsVectorLayer::editingStopped, this, &QgsGeometryValidationDock::onLayerEditingStatusChanged );
}

onLayerEditingStatusChanged();
}

void QgsGeometryValidationDock::onLayerEditingStatusChanged()
{
bool enabled = false;
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
if ( vl && vl->isSpatial() )
if ( mCurrentLayer && mCurrentLayer->isSpatial() && mCurrentLayer->isEditable() )
{
const QList<QgsGeometryCheckFactory *> topologyCheckFactories = QgsAnalysis::instance()->geometryCheckRegistry()->geometryCheckFactories( vl, QgsGeometryCheck::LayerCheck, QgsGeometryCheck::Flag::AvailableInValidation );
const QStringList activeChecks = vl->geometryOptions()->geometryChecks();
const QList<QgsGeometryCheckFactory *> topologyCheckFactories = QgsAnalysis::instance()->geometryCheckRegistry()->geometryCheckFactories( mCurrentLayer, QgsGeometryCheck::LayerCheck, QgsGeometryCheck::Flag::AvailableInValidation );
const QStringList activeChecks = mCurrentLayer->geometryOptions()->geometryChecks();
for ( const QgsGeometryCheckFactory *factory : topologyCheckFactories )
{
if ( activeChecks.contains( factory->id() ) )
@@ -25,6 +25,7 @@ class QgsGeometryValidationModel;
class QgsGeometryValidationService;
class QgsRubberBand;
class QgisApp;
class QgsVectorLayer;

/**
* @brief The QgsGeometryValidationDock class
@@ -46,6 +47,7 @@ class QgsGeometryValidationDock : public QgsDockWidget, public Ui_QgsGeometryVal
void updateCurrentError();
void onCurrentErrorChanged( const QModelIndex &current, const QModelIndex &previous );
void onCurrentLayerChanged( QgsMapLayer *layer );
void onLayerEditingStatusChanged();
void gotoNextError();
void gotoPreviousError();
void zoomToProblem();
@@ -76,6 +78,7 @@ class QgsGeometryValidationDock : public QgsDockWidget, public Ui_QgsGeometryVal
QgsRubberBand *mFeatureRubberband = nullptr;
QgsRubberBand *mErrorRubberband = nullptr;
QgsRubberBand *mErrorLocationRubberband = nullptr;
QgsVectorLayer *mCurrentLayer;
};

#endif // QGSGEOMETRYVALIDATIONPANEL_H

0 comments on commit e9e849a

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