Skip to content

Commit

Permalink
Handle error fixing on frontend size
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Oct 15, 2018
1 parent a56062c commit 5b5ec8f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/app/qgsgeometryvalidationdock.cpp
Expand Up @@ -83,6 +83,7 @@ void QgsGeometryValidationDock::setGeometryValidationModel( QgsGeometryValidatio
mErrorListView->setModel( mGeometryValidationModel );

connect( mErrorListView->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsGeometryValidationDock::onCurrentErrorChanged );
connect( mGeometryValidationModel, &QgsGeometryValidationModel::rowsRemoved, this, &QgsGeometryValidationDock::updateCurrentError );
}

void QgsGeometryValidationDock::gotoNextError()
Expand Down Expand Up @@ -147,6 +148,15 @@ void QgsGeometryValidationDock::setGeometryValidationService( QgsGeometryValidat
mGeometryValidationService = geometryValidationService;
}

void QgsGeometryValidationDock::updateCurrentError()
{
mFeatureRubberband->hide();
mErrorRubberband->hide();
mErrorLocationRubberband->hide();

onCurrentErrorChanged( currentIndex(), QModelIndex() );
}

QModelIndex QgsGeometryValidationDock::currentIndex() const
{
return mErrorListView->selectionModel()->currentIndex();
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsgeometryvalidationdock.h
Expand Up @@ -42,6 +42,7 @@ class QgsGeometryValidationDock : public QgsDockWidget, public Ui_QgsGeometryVal
void setGeometryValidationService( QgsGeometryValidationService *geometryValidationService );

private slots:
void updateCurrentError();
void onCurrentErrorChanged( const QModelIndex &current, const QModelIndex &previous );
void onCurrentLayerChanged( QgsMapLayer *layer );
void gotoNextError();
Expand Down
19 changes: 18 additions & 1 deletion src/app/qgsgeometryvalidationmodel.cpp
Expand Up @@ -14,6 +14,7 @@ QgsGeometryValidationModel::QgsGeometryValidationModel( QgsGeometryValidationSer
connect( mGeometryValidationService, &QgsGeometryValidationService::geometryCheckStarted, this, &QgsGeometryValidationModel::onGeometryCheckStarted );
connect( mGeometryValidationService, &QgsGeometryValidationService::topologyChecksUpdated, this, &QgsGeometryValidationModel::onTopologyChecksUpdated );
connect( mGeometryValidationService, &QgsGeometryValidationService::topologyChecksCleared, this, &QgsGeometryValidationModel::onTopologyChecksCleared );
connect( mGeometryValidationService, &QgsGeometryValidationService::topologyErrorUpdated, this, &QgsGeometryValidationModel::onTopologyErrorUpdated );
}

QModelIndex QgsGeometryValidationModel::index( int row, int column, const QModelIndex &parent ) const
Expand Down Expand Up @@ -76,7 +77,6 @@ QVariant QgsGeometryValidationModel::data( const QModelIndex &index, int role )
{
return tr( "%1: %2" ).arg( featureTitle.toString(), topologyError->description() );
}

}

case FeatureExtentRole:
Expand Down Expand Up @@ -328,6 +328,23 @@ void QgsGeometryValidationModel::onTopologyChecksCleared( QgsVectorLayer *layer
}
}

void QgsGeometryValidationModel::onTopologyErrorUpdated( QgsVectorLayer *layer, QgsGeometryCheckError *error )
{
if ( layer == mCurrentLayer )
{
int i = 0;
for ( const auto &currentError : qgis::as_const( mTopologyErrorStorage[layer] ) )
{
if ( currentError.get() == error )
{
QModelIndex idx = index( i, 0, QModelIndex() );
emit dataChanged( idx, idx );
}
++i;
}
}
}

int QgsGeometryValidationModel::errorsForFeature( QgsVectorLayer *layer, QgsFeatureId fid )
{
const auto &layerErrors = mErrorStorage[layer];
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsgeometryvalidationmodel.h
Expand Up @@ -43,6 +43,7 @@ class QgsGeometryValidationModel : public QAbstractItemModel
void onGeometryCheckStarted( QgsVectorLayer *layer, QgsFeatureId fid );
void onTopologyChecksUpdated( QgsVectorLayer *layer, const QList<std::shared_ptr<QgsGeometryCheckError> > &errors );
void onTopologyChecksCleared( QgsVectorLayer *layer );
void onTopologyErrorUpdated( QgsVectorLayer *layer, QgsGeometryCheckError *error );

private:
struct FeatureErrors
Expand Down

0 comments on commit 5b5ec8f

Please sign in to comment.