Skip to content

Commit 1ab1ad5

Browse files
committed
Disable automatic zoom to problem when fixing errors on geometries
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.
1 parent 1f0db27 commit 1ab1ad5

4 files changed

+33
-0
lines changed

src/app/qgsgeometryvalidationdock.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ void QgsGeometryValidationDock::setGeometryValidationModel( QgsGeometryValidatio
8585
connect( mGeometryValidationModel, &QgsGeometryValidationModel::dataChanged, this, &QgsGeometryValidationDock::onDataChanged );
8686
connect( mGeometryValidationModel, &QgsGeometryValidationModel::rowsRemoved, this, &QgsGeometryValidationDock::updateCurrentError );
8787
connect( mGeometryValidationModel, &QgsGeometryValidationModel::rowsInserted, this, &QgsGeometryValidationDock::onRowsInserted );
88+
89+
// We cannot connect to the regular aboutToRemoveRows signal, because we need this to happen
90+
// before the currentIndex is changed.
91+
connect( mGeometryValidationModel, &QgsGeometryValidationModel::aboutToRemoveSingleGeometryCheck, this, [this]() { mPreventZoomToError = true; } );
92+
connect( mGeometryValidationModel, &QgsGeometryValidationModel::rowsRemoved, this, [this]() { mPreventZoomToError = false; } );
8893
}
8994

9095
void QgsGeometryValidationDock::gotoNextError()
@@ -243,6 +248,20 @@ void QgsGeometryValidationDock::onCurrentErrorChanged( const QModelIndex &curren
243248

244249
bool hasFeature = !FID_IS_NULL( current.data( QgsGeometryValidationModel::ErrorFeatureIdRole ) );
245250
mZoomToFeatureButton->setEnabled( hasFeature );
251+
252+
if ( !mPreventZoomToError )
253+
{
254+
switch ( mLastZoomToAction )
255+
{
256+
case ZoomToProblem:
257+
zoomToProblem();
258+
break;
259+
260+
case ZoomToFeature:
261+
zoomToFeature();
262+
break;
263+
}
264+
}
246265
}
247266

248267
void QgsGeometryValidationDock::onCurrentLayerChanged( QgsMapLayer *layer )

src/app/qgsgeometryvalidationdock.h

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class QgsGeometryValidationDock : public QgsDockWidget, public Ui_QgsGeometryVal
8080
QgsRubberBand *mErrorRubberband = nullptr;
8181
QgsRubberBand *mErrorLocationRubberband = nullptr;
8282
QgsVectorLayer *mCurrentLayer = nullptr;
83+
bool mPreventZoomToError = false;
8384
};
8485

8586
#endif // QGSGEOMETRYVALIDATIONPANEL_H

src/app/qgsgeometryvalidationmodel.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ void QgsGeometryValidationModel::onSingleGeometryCheckCleared( QgsVectorLayer *l
255255

256256
if ( mCurrentLayer == layer && !layerErrors.empty() )
257257
{
258+
emit aboutToRemoveSingleGeometryCheck();
258259
beginRemoveRows( QModelIndex(), 0, layerErrors.size() - 1 );
259260
}
260261

@@ -277,7 +278,10 @@ void QgsGeometryValidationModel::onGeometryCheckCompleted( QgsVectorLayer *layer
277278
if ( featureIdx > -1 && errors.empty() ) // && !mGeometryValidationService->validationActive( layer, fid ) )
278279
{
279280
if ( mCurrentLayer == layer )
281+
{
282+
emit aboutToRemoveSingleGeometryCheck();
280283
beginRemoveRows( QModelIndex(), featureIdx, featureIdx );
284+
}
281285

282286
layerErrors.removeAt( featureIdx );
283287

src/app/qgsgeometryvalidationmodel.h

+9
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ class QgsGeometryValidationModel : public QAbstractItemModel
4949

5050
QgsVectorLayer *currentLayer() const;
5151

52+
signals:
53+
54+
/**
55+
* Emitted before single geometry check results are removed.
56+
* This is guaranteed to be emitted before the models regular
57+
* aboutToRemoveRows() signal.
58+
*/
59+
void aboutToRemoveSingleGeometryCheck();
60+
5261
public slots:
5362
void setCurrentLayer( QgsVectorLayer *currentLayer );
5463

0 commit comments

Comments
 (0)