Skip to content
Permalink
Browse files

Centralize invalidateTopologyChecks handling

  • Loading branch information
m-kuhn committed Oct 1, 2018
1 parent 97a9659 commit f3261e1037789029d8d4bf845fda654c40118b93
Showing with 16 additions and 12 deletions.
  1. +15 −11 src/app/qgsgeometryvalidationservice.cpp
  2. +1 −1 src/app/qgsgeometryvalidationservice.h
@@ -63,34 +63,37 @@ void QgsGeometryValidationService::onFeatureAdded( QgsVectorLayer *layer, QgsFea
{
if ( !mLayerChecks[layer].topologyChecks.empty() )
{
// TODO: Cancel topology checks
layer->setAllowCommit( false );
invalidateTopologyChecks( layer );
}
processFeature( layer, fid );
}

void QgsGeometryValidationService::onGeometryChanged( QgsVectorLayer *layer, QgsFeatureId fid, const QgsGeometry &geometry )
{
Q_UNUSED( geometry )
// It would be nice to use the geometry here for the tests.
// But:
// 1. other codepaths to the checks also have no geometry (feature added / feature deleted)
// 2. and looking it up from the edit buffer (in memory) is really fast.
// so in short: it's still a good idea, but not as important as on first thought.

if ( !mLayerChecks[layer].topologyChecks.empty() )
{
// TODO: Cancel topology checks
layer->setAllowCommit( false );
invalidateTopologyChecks( layer );
}
Q_UNUSED( geometry )

cancelChecks( layer, fid );
processFeature( layer, fid );
}

void QgsGeometryValidationService::onFeatureDeleted( QgsVectorLayer *layer, QgsFeatureId fid )
{
if ( !mLayerChecks[layer].topologyChecks.empty() )
{
// TODO: Cancel topology checks
layer->setAllowCommit( false );
invalidateTopologyChecks( layer );
}

cancelChecks( layer, fid );
// There should be no geometry errors on an inexistent feature, right?
emit geometryCheckCompleted( layer, fid, QList<std::shared_ptr<QgsSingleGeometryCheckError>>() );
}

void QgsGeometryValidationService::onBeforeCommitChanges( QgsVectorLayer *layer )
@@ -220,9 +223,10 @@ void QgsGeometryValidationService::cancelTopologyCheck( QgsVectorLayer *layer )
}
}

void QgsGeometryValidationService::cancelChecks( QgsVectorLayer *layer, QgsFeatureId fid )
void QgsGeometryValidationService::invalidateTopologyChecks( QgsVectorLayer *layer )
{

cancelTopologyCheck( layer );
layer->setAllowCommit( false );
}

void QgsGeometryValidationService::processFeature( QgsVectorLayer *layer, QgsFeatureId fid )
@@ -84,7 +84,7 @@ class QgsGeometryValidationService : public QObject

void cancelTopologyCheck( QgsVectorLayer *layer );

void cancelChecks( QgsVectorLayer *layer, QgsFeatureId fid );
void invalidateTopologyChecks( QgsVectorLayer *layer );

void processFeature( QgsVectorLayer *layer, QgsFeatureId fid );

0 comments on commit f3261e1

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