Skip to content

Commit

Permalink
Disable automatic zoom to problem when fixing errors on geometries
Browse files Browse the repository at this point in the history
Single geomtry checks (is valid) are exuted on the fly, if the map canvas suddenly
changes the current extent while fixing a geometry this becomes very nervous for
a user.
  • Loading branch information
m-kuhn committed Mar 13, 2019
1 parent 857fe53 commit d37546e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/app/qgsgeometryvalidationdock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ void QgsGeometryValidationDock::setGeometryValidationModel( QgsGeometryValidatio
connect( mGeometryValidationModel, &QgsGeometryValidationModel::dataChanged, this, &QgsGeometryValidationDock::onDataChanged );
connect( mGeometryValidationModel, &QgsGeometryValidationModel::rowsRemoved, this, &QgsGeometryValidationDock::updateCurrentError );
connect( mGeometryValidationModel, &QgsGeometryValidationModel::rowsInserted, this, &QgsGeometryValidationDock::onRowsInserted );

// We cannot connect to the regular aboutToRemoveRows signal, because we need this to happen
// before the currentIndex is changed.
connect( mGeometryValidationModel, &QgsGeometryValidationModel::aboutToRemoveSingleGeometryCheck, this, [this]() { mPreventZoomToError = true; } );
connect( mGeometryValidationModel, &QgsGeometryValidationModel::rowsRemoved, this, [this]() { mPreventZoomToError = false; } );
}

void QgsGeometryValidationDock::gotoNextError()
Expand Down Expand Up @@ -244,6 +249,20 @@ void QgsGeometryValidationDock::onCurrentErrorChanged( const QModelIndex &curren

bool hasFeature = !FID_IS_NULL( current.data( QgsGeometryValidationModel::ErrorFeatureIdRole ) );
mZoomToFeatureButton->setEnabled( hasFeature );

if ( !mPreventZoomToError )
{
switch ( mLastZoomToAction )
{
case ZoomToProblem:
zoomToProblem();
break;

case ZoomToFeature:
zoomToFeature();
break;
}
}
}

void QgsGeometryValidationDock::onCurrentLayerChanged( QgsMapLayer *layer )
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsgeometryvalidationdock.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class QgsGeometryValidationDock : public QgsDockWidget, public Ui_QgsGeometryVal
QgsRubberBand *mErrorRubberband = nullptr;
QgsRubberBand *mErrorLocationRubberband = nullptr;
QgsVectorLayer *mCurrentLayer = nullptr;
bool mPreventZoomToError = false;
};

#endif // QGSGEOMETRYVALIDATIONPANEL_H
4 changes: 4 additions & 0 deletions src/app/qgsgeometryvalidationmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ void QgsGeometryValidationModel::onSingleGeometryCheckCleared( QgsVectorLayer *l

if ( mCurrentLayer == layer && !layerErrors.empty() )
{
emit aboutToRemoveSingleGeometryCheck();
beginRemoveRows( QModelIndex(), 0, layerErrors.size() - 1 );
}

Expand All @@ -279,7 +280,10 @@ void QgsGeometryValidationModel::onGeometryCheckCompleted( QgsVectorLayer *layer
if ( featureIdx > -1 && errors.empty() ) // && !mGeometryValidationService->validationActive( layer, fid ) )
{
if ( mCurrentLayer == layer )
{
emit aboutToRemoveSingleGeometryCheck();
beginRemoveRows( QModelIndex(), featureIdx, featureIdx );
}

layerErrors.removeAt( featureIdx );

Expand Down
9 changes: 9 additions & 0 deletions src/app/qgsgeometryvalidationmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ class QgsGeometryValidationModel : public QAbstractItemModel

QgsVectorLayer *currentLayer() const;

signals:

/**
* Emitted before single geometry check results are removed.
* This is guaranteed to be emitted before the models regular
* aboutToRemoveRows() signal.
*/
void aboutToRemoveSingleGeometryCheck();

public slots:
void setCurrentLayer( QgsVectorLayer *currentLayer );

Expand Down

0 comments on commit d37546e

Please sign in to comment.