Skip to content
Permalink
Browse files

Allow deactivating is valid checks in an edit session

If an is valid check is deactivated in an ongoing edit session, all check results
are invalidated and removed. This will help a user to save his edits if he wants
to even if is valid checks have been activated before.
  • Loading branch information
m-kuhn committed Feb 27, 2019
1 parent c748aac commit ef34ed8bef3c636612e60a9726a6e2d309518c36
@@ -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 ef34ed8

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