enable zoom button only if error has feature

This commit is contained in:
Denis Rouzaud 2018-10-01 14:37:38 -04:00 committed by Matthias Kuhn
parent 29febc0c1f
commit e77bab9d2c
No known key found for this signature in database
GPG Key ID: 7A7F1A1C90C3E6A7
3 changed files with 20 additions and 2 deletions

View File

@ -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 )

View File

@ -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:
@ -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();

View File

@ -18,6 +18,7 @@ class QgsGeometryValidationModel : public QAbstractItemModel
FeatureExtentRole = Qt::UserRole,
ProblemExtentRole,
ErrorGeometryRole,
ErrorFeatureIdRole,
FeatureGeometryRole,
ErrorLocationGeometryRole,
GeometryCheckErrorRole,