Skip to content

Commit

Permalink
activate icon only when topology checks are available
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids authored and m-kuhn committed Oct 15, 2018
1 parent 7f70c21 commit 579c97e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/app/qgsgeometryvalidationdock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ email : matthias@opengis.ch
* *
***************************************************************************/

#include <QButtonGroup>


#include "qgsgeometryvalidationdock.h"
#include "qgsgeometryvalidationmodel.h"
#include "qgsgeometryvalidationservice.h"
Expand All @@ -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 )
Expand All @@ -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 );
Expand Down Expand Up @@ -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() );
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsgeometryvalidationdock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 579c97e

Please sign in to comment.