Skip to content

Commit

Permalink
enable zoom button only if error has feature
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids authored and m-kuhn committed Oct 15, 2018
1 parent 29febc0 commit e77bab9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/app/qgsgeometryvalidationdock.cpp
Expand Up @@ -178,6 +178,9 @@ void QgsGeometryValidationDock::onCurrentErrorChanged( const QModelIndex &curren
}
}

bool hasFeature = !FID_IS_NULL( current.data( QgsGeometryValidationModel::ErrorFeatureIdRole ) );
mZoomToFeatureButton->setEnabled( hasFeature );

showHighlight( current );

switch ( mLastZoomToAction )
Expand Down
18 changes: 16 additions & 2 deletions src/app/qgsgeometryvalidationmodel.cpp
Expand Up @@ -91,11 +91,20 @@ QVariant QgsGeometryValidationModel::data( const QModelIndex &index, int role )
return topologyError->geometry();
}

case ErrorFeatureIdRole:
{
return topologyError->featureId();
}

case FeatureGeometryRole:
{
const QgsFeatureId fid = topologyError->featureId();
const QgsFeature feature = mCurrentLayer->getFeature( fid ); // TODO: this should be cached!
return feature.geometry();
if ( !FID_IS_NULL( fid ) )
{
const QgsFeature feature = mCurrentLayer->getFeature( fid ); // TODO: this should be cached!
return feature.geometry();
}
return QgsGeometry();
}

case ErrorLocationGeometryRole:
Expand Down Expand Up @@ -149,6 +158,11 @@ QVariant QgsGeometryValidationModel::data( const QModelIndex &index, int role )
break;
}

case ErrorFeatureIdRole:
{
return featureItem.fid;
}

case FeatureExtentRole:
{
return mCurrentLayer->getFeature( featureItem.fid ).geometry().boundingBox();
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsgeometryvalidationmodel.h
Expand Up @@ -18,6 +18,7 @@ class QgsGeometryValidationModel : public QAbstractItemModel
FeatureExtentRole = Qt::UserRole,
ProblemExtentRole,
ErrorGeometryRole,
ErrorFeatureIdRole,
FeatureGeometryRole,
ErrorLocationGeometryRole,
GeometryCheckErrorRole,
Expand Down

0 comments on commit e77bab9

Please sign in to comment.