Skip to content

Commit e77bab9

Browse files
3nidsm-kuhn
authored andcommittedOct 15, 2018
enable zoom button only if error has feature
1 parent 29febc0 commit e77bab9

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed
 

‎src/app/qgsgeometryvalidationdock.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ void QgsGeometryValidationDock::onCurrentErrorChanged( const QModelIndex &curren
178178
}
179179
}
180180

181+
bool hasFeature = !FID_IS_NULL( current.data( QgsGeometryValidationModel::ErrorFeatureIdRole ) );
182+
mZoomToFeatureButton->setEnabled( hasFeature );
183+
181184
showHighlight( current );
182185

183186
switch ( mLastZoomToAction )

‎src/app/qgsgeometryvalidationmodel.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,20 @@ QVariant QgsGeometryValidationModel::data( const QModelIndex &index, int role )
9191
return topologyError->geometry();
9292
}
9393

94+
case ErrorFeatureIdRole:
95+
{
96+
return topologyError->featureId();
97+
}
98+
9499
case FeatureGeometryRole:
95100
{
96101
const QgsFeatureId fid = topologyError->featureId();
97-
const QgsFeature feature = mCurrentLayer->getFeature( fid ); // TODO: this should be cached!
98-
return feature.geometry();
102+
if ( !FID_IS_NULL( fid ) )
103+
{
104+
const QgsFeature feature = mCurrentLayer->getFeature( fid ); // TODO: this should be cached!
105+
return feature.geometry();
106+
}
107+
return QgsGeometry();
99108
}
100109

101110
case ErrorLocationGeometryRole:
@@ -149,6 +158,11 @@ QVariant QgsGeometryValidationModel::data( const QModelIndex &index, int role )
149158
break;
150159
}
151160

161+
case ErrorFeatureIdRole:
162+
{
163+
return featureItem.fid;
164+
}
165+
152166
case FeatureExtentRole:
153167
{
154168
return mCurrentLayer->getFeature( featureItem.fid ).geometry().boundingBox();

‎src/app/qgsgeometryvalidationmodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class QgsGeometryValidationModel : public QAbstractItemModel
1818
FeatureExtentRole = Qt::UserRole,
1919
ProblemExtentRole,
2020
ErrorGeometryRole,
21+
ErrorFeatureIdRole,
2122
FeatureGeometryRole,
2223
ErrorLocationGeometryRole,
2324
GeometryCheckErrorRole,

0 commit comments

Comments
 (0)
Please sign in to comment.