Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
disable topology check button if layer not editable
- Loading branch information
Showing
with
28 additions
and
5 deletions.
-
+25
−5
src/app/qgsgeometryvalidationdock.cpp
-
+3
−0
src/app/qgsgeometryvalidationdock.h
|
@@ -260,13 +260,33 @@ void QgsGeometryValidationDock::onCurrentErrorChanged( const QModelIndex ¤ |
|
|
|
|
|
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 ¤t, 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 |