Skip to content
Permalink
Browse files

Merge pull request #9298 from m-kuhn/is-valid-check-results-deactivate

[geometry validation] Allow deactivating is valid checks in an edit session
  • Loading branch information
m-kuhn committed Mar 2, 2019
2 parents 22b052d + ef34ed8 commit 77f2b60aa5d45e1d16d7f0a7a85426129230e229
@@ -27,6 +27,7 @@ QgsGeometryValidationModel::QgsGeometryValidationModel( QgsGeometryValidationSer
: QAbstractItemModel( parent )
, mGeometryValidationService( geometryValidationService )
{
connect( mGeometryValidationService, &QgsGeometryValidationService::singleGeometryCheckCleared, this, &QgsGeometryValidationModel::onSingleGeometryCheckCleared );
connect( mGeometryValidationService, &QgsGeometryValidationService::geometryCheckCompleted, this, &QgsGeometryValidationModel::onGeometryCheckCompleted );
connect( mGeometryValidationService, &QgsGeometryValidationService::geometryCheckStarted, this, &QgsGeometryValidationModel::onGeometryCheckStarted );
connect( mGeometryValidationService, &QgsGeometryValidationService::topologyChecksUpdated, this, &QgsGeometryValidationModel::onTopologyChecksUpdated );
@@ -250,6 +251,24 @@ void QgsGeometryValidationModel::setCurrentLayer( QgsVectorLayer *currentLayer )
endResetModel();
}

void QgsGeometryValidationModel::onSingleGeometryCheckCleared( QgsVectorLayer *layer )
{
auto &layerErrors = mErrorStorage[layer];

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

layerErrors.clear();

if ( mCurrentLayer == layer && !layerErrors.empty() )
{
endRemoveRows();
}

}

void QgsGeometryValidationModel::onGeometryCheckCompleted( QgsVectorLayer *layer, QgsFeatureId fid, const QList<std::shared_ptr<QgsSingleGeometryCheckError>> &errors )
{
auto &layerErrors = mErrorStorage[layer];
@@ -53,6 +53,7 @@ class QgsGeometryValidationModel : public QAbstractItemModel
void setCurrentLayer( QgsVectorLayer *currentLayer );

private slots:
void onSingleGeometryCheckCleared( QgsVectorLayer *layer );
void onGeometryCheckCompleted( QgsVectorLayer *layer, QgsFeatureId fid, const QList<std::shared_ptr<QgsSingleGeometryCheckError> > &errors );
void onGeometryCheckStarted( QgsVectorLayer *layer, QgsFeatureId fid );
void onTopologyChecksUpdated( QgsVectorLayer *layer, const QList<std::shared_ptr<QgsGeometryCheckError> > &errors );
@@ -250,6 +250,12 @@ void QgsGeometryValidationService::enableLayerChecks( QgsVectorLayer *layer )
singleGeometryChecks.append( dynamic_cast<QgsSingleGeometryCheck *>( check ) );
}

if ( singleGeometryChecks.empty() )
{
mLayerChecks[layer].singleFeatureCheckErrors.clear();
emit singleGeometryCheckCleared( layer );
}

checkInformation.singleFeatureChecks = singleGeometryChecks;

// Topology checks
@@ -71,6 +71,13 @@ class QgsGeometryValidationService : public QObject
void setMessageBar( QgsMessageBar *messageBar );

signals:

/**
* Emitted when geometry checks for this layer have been disabled and
* any existing cached result should be cleared.
*/
void singleGeometryCheckCleared( QgsVectorLayer *layer );

void geometryCheckStarted( QgsVectorLayer *layer, QgsFeatureId fid );
void geometryCheckCompleted( QgsVectorLayer *layer, QgsFeatureId fid, const QList<std::shared_ptr<QgsSingleGeometryCheckError>> &errors );
void topologyChecksUpdated( QgsVectorLayer *layer, const QList<std::shared_ptr<QgsGeometryCheckError> > &errors );

0 comments on commit 77f2b60

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