Skip to content
Permalink
Browse files

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.
  • Loading branch information
m-kuhn committed Mar 13, 2019
1 parent 857fe53 commit d37546e90310bafbd5e97ae27076bdbc4750d9f9
@@ -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()
@@ -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 )
@@ -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
@@ -257,6 +257,7 @@ void QgsGeometryValidationModel::onSingleGeometryCheckCleared( QgsVectorLayer *l

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

@@ -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 );

@@ -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 );

0 comments on commit d37546e

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