Skip to content

Commit 579c97e

Browse files
3nidsm-kuhn
authored andcommittedOct 15, 2018
activate icon only when topology checks are available
1 parent 7f70c21 commit 579c97e

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed
 

‎src/app/qgsgeometryvalidationdock.cpp

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ email : matthias@opengis.ch
1313
* *
1414
***************************************************************************/
1515

16+
#include <QButtonGroup>
17+
18+
1619
#include "qgsgeometryvalidationdock.h"
1720
#include "qgsgeometryvalidationmodel.h"
1821
#include "qgsgeometryvalidationservice.h"
@@ -21,8 +24,11 @@ email : matthias@opengis.ch
2124
#include "qgsvectorlayer.h"
2225
#include "qgsgeometrycheck.h"
2326
#include "qgsgeometrycheckerror.h"
27+
#include "qgsanalysis.h"
28+
#include "qgsgeometrycheckregistry.h"
29+
#include "qgsgeometryoptions.h"
30+
#include "qgsgeometrycheckfactory.h"
2431

25-
#include <QButtonGroup>
2632

2733
QgsGeometryValidationDock::QgsGeometryValidationDock( const QString &title, QgsMapCanvas *mapCanvas, QWidget *parent, Qt::WindowFlags flags )
2834
: QgsDockWidget( title, parent, flags )
@@ -34,6 +40,7 @@ QgsGeometryValidationDock::QgsGeometryValidationDock( const QString &title, QgsM
3440
connect( mPreviousButton, &QPushButton::clicked, this, &QgsGeometryValidationDock::gotoPreviousError );
3541
connect( mZoomToProblemButton, &QPushButton::clicked, this, &QgsGeometryValidationDock::zoomToProblem );
3642
connect( mZoomToFeatureButton, &QPushButton::clicked, this, &QgsGeometryValidationDock::zoomToFeature );
43+
connect( mMapCanvas, &QgsMapCanvas::currentLayerChanged, this, &QgsGeometryValidationDock::onCurrentLayerChanged );
3744
connect( mMapCanvas, &QgsMapCanvas::currentLayerChanged, this, &QgsGeometryValidationDock::updateLayerTransform );
3845
connect( mMapCanvas, &QgsMapCanvas::destinationCrsChanged, this, &QgsGeometryValidationDock::updateLayerTransform );
3946
connect( mMapCanvas, &QgsMapCanvas::transformContextChanged, this, &QgsGeometryValidationDock::updateLayerTransform );
@@ -182,6 +189,27 @@ void QgsGeometryValidationDock::onCurrentErrorChanged( const QModelIndex &curren
182189
}
183190
}
184191

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+
185213
void QgsGeometryValidationDock::showHighlight( const QModelIndex &current )
186214
{
187215
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mMapCanvas->currentLayer() );

‎src/app/qgsgeometryvalidationdock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class QgsGeometryValidationDock : public QgsDockWidget, public Ui_QgsGeometryVal
4343

4444
private slots:
4545
void onCurrentErrorChanged( const QModelIndex &current, const QModelIndex &previous );
46+
void onCurrentLayerChanged( QgsMapLayer *layer );
4647
void gotoNextError();
4748
void gotoPreviousError();
4849
void zoomToProblem();

0 commit comments

Comments
 (0)
Please sign in to comment.