Skip to content
Permalink
Browse files

Merge pull request #9504 from m-kuhn/geometry_validator_zoom_to_impro…

…vements

Disable automatic zoom to problem when fixing errors on geometries
  • Loading branch information
m-kuhn committed Mar 18, 2019
2 parents 7653e45 + d37546e commit 4e9c4b5a0c80b0280dcebba2b3282d6bcef262b3
@@ -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 4e9c4b5

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