From 04cdf63818ae56c344cd4421fb14a1d4d61848a6 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Thu, 28 Feb 2019 13:22:42 +0100 Subject: [PATCH] Add icons to geometry validation checks --- images/images.qrc | 4 + .../themes/default/checks/InvalidGeometry.svg | 77 +++++++++++ .../themes/default/checks/MissingVertex.svg | 103 ++++++++++++++ images/themes/default/checks/Overlap.svg | 128 ++++++++++++++++++ images/themes/default/checks/SliverOrGap.svg | 93 +++++++++++++ .../qgsgeometrycheckerror.sip.in | 6 + .../qgsgeometrycheckerror.cpp | 9 ++ .../geometry_checker/qgsgeometrycheckerror.h | 6 + .../geometry_checker/qgsgeometrygapcheck.cpp | 10 ++ .../geometry_checker/qgsgeometrygapcheck.h | 2 + .../qgsgeometrymissingvertexcheck.cpp | 10 ++ .../qgsgeometrymissingvertexcheck.h | 2 + .../qgsgeometryoverlapcheck.cpp | 10 ++ .../qgsgeometryoverlapcheck.h | 1 + src/app/qgsgeometryvalidationmodel.cpp | 13 +- 15 files changed, 463 insertions(+), 11 deletions(-) create mode 100644 images/themes/default/checks/InvalidGeometry.svg create mode 100644 images/themes/default/checks/MissingVertex.svg create mode 100644 images/themes/default/checks/Overlap.svg create mode 100644 images/themes/default/checks/SliverOrGap.svg diff --git a/images/images.qrc b/images/images.qrc index 51f3d20b8c1..963fbbde0a3 100644 --- a/images/images.qrc +++ b/images/images.qrc @@ -75,6 +75,10 @@ north_arrows/gpsarrow2.svg splash/splash.png composer/missing_image.svg + themes/default/checks/SliverOrGap.svg + themes/default/checks/InvalidGeometry.svg + themes/default/checks/MissingVertex.svg + themes/default/checks/Overlap.svg themes/default/algorithms/mAlgorithmAddGeometryAttributes.svg themes/default/algorithms/mAlgorithmBasicStatistics.svg themes/default/algorithms/mAlgorithmBuffer.svg diff --git a/images/themes/default/checks/InvalidGeometry.svg b/images/themes/default/checks/InvalidGeometry.svg new file mode 100644 index 00000000000..a4314610505 --- /dev/null +++ b/images/themes/default/checks/InvalidGeometry.svg @@ -0,0 +1,77 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/images/themes/default/checks/MissingVertex.svg b/images/themes/default/checks/MissingVertex.svg new file mode 100644 index 00000000000..d4c4f4a26cb --- /dev/null +++ b/images/themes/default/checks/MissingVertex.svg @@ -0,0 +1,103 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + diff --git a/images/themes/default/checks/Overlap.svg b/images/themes/default/checks/Overlap.svg new file mode 100644 index 00000000000..3c2b826efb3 --- /dev/null +++ b/images/themes/default/checks/Overlap.svg @@ -0,0 +1,128 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/images/themes/default/checks/SliverOrGap.svg b/images/themes/default/checks/SliverOrGap.svg new file mode 100644 index 00000000000..aae0dda2164 --- /dev/null +++ b/images/themes/default/checks/SliverOrGap.svg @@ -0,0 +1,93 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheckerror.sip.in b/python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheckerror.sip.in index 6a9f6c4ddaa..d8f6c543261 100644 --- a/python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheckerror.sip.in +++ b/python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheckerror.sip.in @@ -163,6 +163,12 @@ Will be used to update existing errors whenever they are re-checked. + virtual QIcon icon() const; +%Docstring +Returns an icon that should be shown for this kind of error. + +.. versionadded:: 3.8 +%End protected: QgsGeometryCheckError( const QgsGeometryCheck *check, diff --git a/src/analysis/vector/geometry_checker/qgsgeometrycheckerror.cpp b/src/analysis/vector/geometry_checker/qgsgeometrycheckerror.cpp index 566690ef11e..5f748e7f244 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrycheckerror.cpp +++ b/src/analysis/vector/geometry_checker/qgsgeometrycheckerror.cpp @@ -16,6 +16,7 @@ ***************************************************************************/ #include "qgsgeometrycheckerror.h" +#include "qgsapplication.h" QgsGeometryCheckError::QgsGeometryCheckError( const QgsGeometryCheck *check, const QString &layerId, @@ -186,6 +187,14 @@ QMap QgsGeometryCheckError::involvedFeatures() const return QMap >(); } +QIcon QgsGeometryCheckError::icon() const +{ + if ( status() == QgsGeometryCheckError::StatusFixed ) + return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmCheckGeometry.svg" ) ); + else + return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmLineIntersections.svg" ) ); +} + void QgsGeometryCheckError::update( const QgsGeometryCheckError *other ) { Q_ASSERT( mCheck == other->mCheck ); diff --git a/src/analysis/vector/geometry_checker/qgsgeometrycheckerror.h b/src/analysis/vector/geometry_checker/qgsgeometrycheckerror.h index b7b6646f8cc..63bb5c864e1 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrycheckerror.h +++ b/src/analysis/vector/geometry_checker/qgsgeometrycheckerror.h @@ -188,6 +188,12 @@ class ANALYSIS_EXPORT QgsGeometryCheckError */ virtual QMap involvedFeatures() const SIP_SKIP; + /** + * Returns an icon that should be shown for this kind of error. + * + * \since QGIS 3.8 + */ + virtual QIcon icon() const; protected: /** diff --git a/src/analysis/vector/geometry_checker/qgsgeometrygapcheck.cpp b/src/analysis/vector/geometry_checker/qgsgeometrygapcheck.cpp index f3ea33fd43a..63138a45903 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrygapcheck.cpp +++ b/src/analysis/vector/geometry_checker/qgsgeometrygapcheck.cpp @@ -20,6 +20,7 @@ #include "qgsfeaturepool.h" #include "qgsvectorlayer.h" #include "qgsfeedback.h" +#include "qgsapplication.h" #include "geos_c.h" @@ -328,3 +329,12 @@ QMap QgsGeometryGapCheckError::involvedFeatures() const { return mNeighbors; } + +QIcon QgsGeometryGapCheckError::icon() const +{ + + if ( status() == QgsGeometryCheckError::StatusFixed ) + return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmCheckGeometry.svg" ) ); + else + return QgsApplication::getThemeIcon( QStringLiteral( "/checks/SliverOrGap.svg" ) ); +} diff --git a/src/analysis/vector/geometry_checker/qgsgeometrygapcheck.h b/src/analysis/vector/geometry_checker/qgsgeometrygapcheck.h index d41fba1e4b7..aa2c345b512 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrygapcheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometrygapcheck.h @@ -67,6 +67,8 @@ class ANALYSIS_EXPORT QgsGeometryGapCheckError : public QgsGeometryCheckError QMap involvedFeatures() const override; + QIcon icon() const override; + private: QMap mNeighbors; QgsRectangle mGapAreaBBox; diff --git a/src/analysis/vector/geometry_checker/qgsgeometrymissingvertexcheck.cpp b/src/analysis/vector/geometry_checker/qgsgeometrymissingvertexcheck.cpp index 57301c849a1..8418229be27 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrymissingvertexcheck.cpp +++ b/src/analysis/vector/geometry_checker/qgsgeometrymissingvertexcheck.cpp @@ -23,6 +23,7 @@ #include "qgslinestring.h" #include "qgsgeometryengine.h" #include "qgsgeometryutils.h" +#include "qgsapplication.h" QgsGeometryMissingVertexCheck::QgsGeometryMissingVertexCheck( const QgsGeometryCheckContext *context, const QVariantMap &geometryCheckConfiguration ) : QgsGeometryCheck( context, geometryCheckConfiguration ) @@ -289,3 +290,12 @@ void QgsGeometryMissingVertexCheckError::setInvolvedFeatures( const QMap &involvedFeatures ); + QIcon icon() const override; + private: QgsRectangle mAffectedAreaBBox; QMap mInvolvedFeatures; diff --git a/src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.cpp b/src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.cpp index 642d53a7026..d5711fa746d 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.cpp +++ b/src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.cpp @@ -19,6 +19,7 @@ #include "qgsfeaturepool.h" #include "qgsvectorlayer.h" #include "qgsfeedback.h" +#include "qgsapplication.h" QgsGeometryOverlapCheck::QgsGeometryOverlapCheck( const QgsGeometryCheckContext *context, const QVariantMap &configuration ) : QgsGeometryCheck( context, configuration ) @@ -312,3 +313,12 @@ QMap QgsGeometryOverlapCheckError::involvedFeatures() co features[mOverlappedFeature.layerId()].insert( mOverlappedFeature.featureId() ); return features; } + +QIcon QgsGeometryOverlapCheckError::icon() const +{ + + if ( status() == QgsGeometryCheckError::StatusFixed ) + return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmCheckGeometry.svg" ) ); + else + return QgsApplication::getThemeIcon( QStringLiteral( "/checks/Overlap.svg" ) ); +} diff --git a/src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.h b/src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.h index 6ea1ee48cf9..f4c85fc81ff 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.h @@ -78,6 +78,7 @@ class ANALYSIS_EXPORT QgsGeometryOverlapCheckError : public QgsGeometryCheckErro QString description() const override; QMap involvedFeatures() const override; + QIcon icon() const override; private: OverlappedFeature mOverlappedFeature; diff --git a/src/app/qgsgeometryvalidationmodel.cpp b/src/app/qgsgeometryvalidationmodel.cpp index 38daae10c66..31163b190ff 100644 --- a/src/app/qgsgeometryvalidationmodel.cpp +++ b/src/app/qgsgeometryvalidationmodel.cpp @@ -72,10 +72,7 @@ QVariant QgsGeometryValidationModel::data( const QModelIndex &index, int role ) switch ( role ) { case Qt::DecorationRole: - if ( topologyError->status() == QgsGeometryCheckError::StatusFixed ) - return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmCheckGeometry.svg" ) ); - else - return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmLineIntersections.svg" ) ); + return topologyError->icon(); case Qt::DisplayRole: case DetailsRole: @@ -166,13 +163,7 @@ QVariant QgsGeometryValidationModel::data( const QModelIndex &index, int role ) case Qt::DecorationRole: { -#if 0 - if ( mGeometryValidationService->validationActive( mCurrentLayer, featureItem.fid ) ) - return QgsApplication::getThemeIcon( "/mActionTracing.svg" ); - else - return QVariant(); -#endif - break; + return QgsApplication::getThemeIcon( "/checks/InvalidGeometry.svg" ); } case GeometryCheckErrorRole: