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 1f0db27 commit 1ab1ad54f03728e13148cbc0d4e3904891468bc8
@@ -85,6 +85,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()
@@ -243,6 +248,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
@@ -255,6 +255,7 @@ void QgsGeometryValidationModel::onSingleGeometryCheckCleared( QgsVectorLayer *l

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

@@ -277,7 +278,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 1ab1ad5

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