@@ -13,6 +13,9 @@ email : matthias@opengis.ch
13
13
* *
14
14
***************************************************************************/
15
15
16
+ #include < QButtonGroup>
17
+
18
+
16
19
#include " qgsgeometryvalidationdock.h"
17
20
#include " qgsgeometryvalidationmodel.h"
18
21
#include " qgsgeometryvalidationservice.h"
@@ -21,8 +24,11 @@ email : matthias@opengis.ch
21
24
#include " qgsvectorlayer.h"
22
25
#include " qgsgeometrycheck.h"
23
26
#include " qgsgeometrycheckerror.h"
27
+ #include " qgsanalysis.h"
28
+ #include " qgsgeometrycheckregistry.h"
29
+ #include " qgsgeometryoptions.h"
30
+ #include " qgsgeometrycheckfactory.h"
24
31
25
- #include < QButtonGroup>
26
32
27
33
QgsGeometryValidationDock::QgsGeometryValidationDock ( const QString &title, QgsMapCanvas *mapCanvas, QWidget *parent, Qt::WindowFlags flags )
28
34
: QgsDockWidget( title, parent, flags )
@@ -34,6 +40,7 @@ QgsGeometryValidationDock::QgsGeometryValidationDock( const QString &title, QgsM
34
40
connect ( mPreviousButton , &QPushButton::clicked, this , &QgsGeometryValidationDock::gotoPreviousError );
35
41
connect ( mZoomToProblemButton , &QPushButton::clicked, this , &QgsGeometryValidationDock::zoomToProblem );
36
42
connect ( mZoomToFeatureButton , &QPushButton::clicked, this , &QgsGeometryValidationDock::zoomToFeature );
43
+ connect ( mMapCanvas , &QgsMapCanvas::currentLayerChanged, this , &QgsGeometryValidationDock::onCurrentLayerChanged );
37
44
connect ( mMapCanvas , &QgsMapCanvas::currentLayerChanged, this , &QgsGeometryValidationDock::updateLayerTransform );
38
45
connect ( mMapCanvas , &QgsMapCanvas::destinationCrsChanged, this , &QgsGeometryValidationDock::updateLayerTransform );
39
46
connect ( mMapCanvas , &QgsMapCanvas::transformContextChanged, this , &QgsGeometryValidationDock::updateLayerTransform );
@@ -182,6 +189,27 @@ void QgsGeometryValidationDock::onCurrentErrorChanged( const QModelIndex ¤
182
189
}
183
190
}
184
191
192
+ void QgsGeometryValidationDock::onCurrentLayerChanged ( QgsMapLayer *layer )
193
+ {
194
+ // activate icon
195
+ bool enabled = false ;
196
+ QgsVectorLayer *vl = dynamic_cast <QgsVectorLayer *>( layer );
197
+ if ( vl && vl->isSpatial () )
198
+ {
199
+ const QList<QgsGeometryCheckFactory *> topologyCheckFactories = QgsAnalysis::instance ()->geometryCheckRegistry ()->geometryCheckFactories ( vl, QgsGeometryCheck::LayerCheck, QgsGeometryCheck::Flag::AvailableInValidation );
200
+ const QStringList activeChecks = vl->geometryOptions ()->geometryChecks ();
201
+ for ( const QgsGeometryCheckFactory *factory : topologyCheckFactories )
202
+ {
203
+ if ( activeChecks.contains ( factory->id () ) )
204
+ {
205
+ enabled = true ;
206
+ break ;
207
+ }
208
+ }
209
+ }
210
+ mTopologyChecksPendingButton ->setEnabled ( enabled );
211
+ }
212
+
185
213
void QgsGeometryValidationDock::showHighlight ( const QModelIndex ¤t )
186
214
{
187
215
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mMapCanvas ->currentLayer () );
0 commit comments