Skip to content
Permalink
Browse files

activate icon only when topology checks are available

  • Loading branch information
3nids authored and m-kuhn committed Oct 1, 2018
1 parent 7f70c21 commit 579c97e7ead088453d7170e291216eccb3ba15fb
Showing with 30 additions and 1 deletion.
  1. +29 −1 src/app/qgsgeometryvalidationdock.cpp
  2. +1 −0 src/app/qgsgeometryvalidationdock.h
@@ -13,6 +13,9 @@ email : matthias@opengis.ch
* *
***************************************************************************/

#include <QButtonGroup>


#include "qgsgeometryvalidationdock.h"
#include "qgsgeometryvalidationmodel.h"
#include "qgsgeometryvalidationservice.h"
@@ -21,8 +24,11 @@ email : matthias@opengis.ch
#include "qgsvectorlayer.h"
#include "qgsgeometrycheck.h"
#include "qgsgeometrycheckerror.h"
#include "qgsanalysis.h"
#include "qgsgeometrycheckregistry.h"
#include "qgsgeometryoptions.h"
#include "qgsgeometrycheckfactory.h"

#include <QButtonGroup>

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

void QgsGeometryValidationDock::onCurrentLayerChanged( QgsMapLayer *layer )
{
// activate icon
bool enabled = false;
QgsVectorLayer *vl = dynamic_cast<QgsVectorLayer *>( layer );
if ( vl && vl->isSpatial() )
{
const QList<QgsGeometryCheckFactory *> topologyCheckFactories = QgsAnalysis::instance()->geometryCheckRegistry()->geometryCheckFactories( vl, QgsGeometryCheck::LayerCheck, QgsGeometryCheck::Flag::AvailableInValidation );
const QStringList activeChecks = vl->geometryOptions()->geometryChecks();
for ( const QgsGeometryCheckFactory *factory : topologyCheckFactories )
{
if ( activeChecks.contains( factory->id() ) )
{
enabled = true;
break;
}
}
}
mTopologyChecksPendingButton->setEnabled( enabled );
}

void QgsGeometryValidationDock::showHighlight( const QModelIndex &current )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mMapCanvas->currentLayer() );
@@ -43,6 +43,7 @@ class QgsGeometryValidationDock : public QgsDockWidget, public Ui_QgsGeometryVal

private slots:
void onCurrentErrorChanged( const QModelIndex &current, const QModelIndex &previous );
void onCurrentLayerChanged( QgsMapLayer *layer );
void gotoNextError();
void gotoPreviousError();
void zoomToProblem();

0 comments on commit 579c97e

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