From 952d7048142ea3e5e9b23e9c619ba90ba91aa82a Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Tue, 14 Jan 2020 16:51:59 +0100 Subject: [PATCH] Rename QgsGeometryCheckFix to QgsGeometryCheckResolutionMethod --- python/analysis/analysis_auto.sip | 2 +- .../geometry_checker/qgsgeometrycheck.sip.in | 17 ++++-- ...> qgsgeometrycheckresolutionmethod.sip.in} | 11 ++-- src/analysis/CMakeLists.txt | 4 +- .../geometry_checker/qgsgeometrycheck.cpp | 13 ++++- .../geometry_checker/qgsgeometrycheck.h | 15 +++-- .../qgsgeometrycheckerror.cpp | 4 +- .../geometry_checker/qgsgeometrycheckfix.cpp | 29 ---------- .../geometry_checker/qgsgeometrycheckfix.h | 42 -------------- .../qgsgeometrycheckresolutionmethod.cpp | 44 +++++++++++++++ .../qgsgeometrycheckresolutionmethod.h | 56 +++++++++++++++++++ .../geometry_checker/qgsgeometrygapcheck.cpp | 14 ++--- .../geometry_checker/qgsgeometrygapcheck.h | 2 +- src/app/qgsgeometryvalidationdock.cpp | 4 +- 14 files changed, 155 insertions(+), 102 deletions(-) rename python/analysis/auto_generated/vector/geometry_checker/{qgsgeometrycheckfix.sip.in => qgsgeometrycheckresolutionmethod.sip.in} (79%) delete mode 100644 src/analysis/vector/geometry_checker/qgsgeometrycheckfix.cpp delete mode 100644 src/analysis/vector/geometry_checker/qgsgeometrycheckfix.h create mode 100644 src/analysis/vector/geometry_checker/qgsgeometrycheckresolutionmethod.cpp create mode 100644 src/analysis/vector/geometry_checker/qgsgeometrycheckresolutionmethod.h diff --git a/python/analysis/analysis_auto.sip b/python/analysis/analysis_auto.sip index 2e21242b518..99b54826dd1 100644 --- a/python/analysis/analysis_auto.sip +++ b/python/analysis/analysis_auto.sip @@ -32,7 +32,7 @@ %Include auto_generated/raster/qgstotalcurvaturefilter.sip %Include auto_generated/vector/geometry_checker/qgsfeaturepool.sip %Include auto_generated/vector/geometry_checker/qgsgeometrycheck.sip -%Include auto_generated/vector/geometry_checker/qgsgeometrycheckfix.sip +%Include auto_generated/vector/geometry_checker/qgsgeometrycheckresolutionmethod.sip %Include auto_generated/vector/geometry_checker/qgsgeometrycheckcontext.sip %Include auto_generated/vector/geometry_checker/qgsgeometrycheckerror.sip %Include auto_generated/vector/geometry_checker/qgsgeometrycheckerutils.sip diff --git a/python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheck.sip.in b/python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheck.sip.in index 424fdf11b15..9ece5921e8d 100644 --- a/python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheck.sip.in +++ b/python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheck.sip.in @@ -213,11 +213,20 @@ Progress should be reported to ``feedback``. Only features and layers listed in %End - virtual QList availableResolutionMethods() const; - - virtual QStringList resolutionMethods() const = 0; + virtual QList availableResolutionMethods() const; %Docstring -Returns a list of descriptions for available resolutions for errors. The index will be passed as ``method`` to :py:func:`fixError`. +Returns a list of available resolution methods. + +.. versionadded:: 3.12 +%End + + virtual QStringList resolutionMethods() const; +%Docstring +Returns a list of descriptions for available resolutions for errors. +The index will be passed as ``method`` to :py:func:`fixError`. + +.. deprecated:: QGIS 3.12 + use availableResolutionMethods() instead .. versionadded:: 3.4 %End diff --git a/python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheckfix.sip.in b/python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheckresolutionmethod.sip.in similarity index 79% rename from python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheckfix.sip.in rename to python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheckresolutionmethod.sip.in index 8b778d8ff09..7e0a312530a 100644 --- a/python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheckfix.sip.in +++ b/python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheckresolutionmethod.sip.in @@ -1,13 +1,14 @@ /************************************************************************ * This file has been generated automatically from * * * - * src/analysis/vector/geometry_checker/qgsgeometrycheckfix.h * + * src/analysis/vector/geometry_checker/qgsgeometrycheckresolutionmethod.h * * * * Do not edit manually ! Edit header and run scripts/sipify.pl again * ************************************************************************/ -class QgsGeometryCheckFix + +class QgsGeometryCheckResolutionMethod { %Docstring This class implements a fix for problems detected in geometry checks. @@ -16,10 +17,10 @@ This class implements a fix for problems detected in geometry checks. %End %TypeHeaderCode -#include "qgsgeometrycheckfix.h" +#include "qgsgeometrycheckresolutionmethod.h" %End public: - QgsGeometryCheckFix( int id, const QString &name, const QString &description, bool isStable = true ); + QgsGeometryCheckResolutionMethod( int id, const QString &name, const QString &description, bool isStable = true ); int id() const; @@ -43,7 +44,7 @@ A human readable and translated description for this fix. /************************************************************************ * This file has been generated automatically from * * * - * src/analysis/vector/geometry_checker/qgsgeometrycheckfix.h * + * src/analysis/vector/geometry_checker/qgsgeometrycheckresolutionmethod.h * * * * Do not edit manually ! Edit header and run scripts/sipify.pl again * ************************************************************************/ diff --git a/src/analysis/CMakeLists.txt b/src/analysis/CMakeLists.txt index f86ca80e7cd..6b9822ca3e8 100644 --- a/src/analysis/CMakeLists.txt +++ b/src/analysis/CMakeLists.txt @@ -205,7 +205,7 @@ SET(QGIS_ANALYSIS_SRCS vector/geometry_checker/qgsgeometryanglecheck.cpp vector/geometry_checker/qgsgeometryareacheck.cpp vector/geometry_checker/qgsgeometrycheck.cpp - vector/geometry_checker/qgsgeometrycheckfix.cpp + vector/geometry_checker/qgsgeometrycheckresolutionmethod.cpp vector/geometry_checker/qgsgeometrycheckcontext.cpp vector/geometry_checker/qgsgeometrychecker.cpp vector/geometry_checker/qgsgeometrycheckerror.cpp @@ -298,7 +298,7 @@ SET(QGIS_ANALYSIS_HDRS vector/geometry_checker/qgsgeometryanglecheck.h vector/geometry_checker/qgsgeometryareacheck.h vector/geometry_checker/qgsgeometrycheck.h - vector/geometry_checker/qgsgeometrycheckfix.h + vector/geometry_checker/qgsgeometrycheckresolutionmethod.h vector/geometry_checker/qgsgeometrycheckcontext.h vector/geometry_checker/qgsgeometrychecker.h vector/geometry_checker/qgsgeometrycheckerror.h diff --git a/src/analysis/vector/geometry_checker/qgsgeometrycheck.cpp b/src/analysis/vector/geometry_checker/qgsgeometrycheck.cpp index 9bfe51fa04f..6d304b88ac1 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrycheck.cpp +++ b/src/analysis/vector/geometry_checker/qgsgeometrycheck.cpp @@ -56,20 +56,27 @@ void QgsGeometryCheck::fixError( const QMap &featureP Q_UNUSED( changes ) } -QList QgsGeometryCheck::availableResolutionMethods() const +QList QgsGeometryCheck::availableResolutionMethods() const { - QList fixes; + QList fixes; + Q_NOWARN_DEPRECATED_PUSH const QStringList methods = resolutionMethods(); + Q_NOWARN_DEPRECATED_POP int i = 0; for ( const QString &method : methods ) { - fixes.append( QgsGeometryCheckFix( i, method, QString(), false ) ); + fixes.append( QgsGeometryCheckResolutionMethod( i, method, QString(), false ) ); } return fixes; } +QStringList QgsGeometryCheck::resolutionMethods() const +{ + return QStringList(); +} + QMap QgsGeometryCheck::allLayerFeatureIds( const QMap &featurePools ) const { QMap featureIds; diff --git a/src/analysis/vector/geometry_checker/qgsgeometrycheck.h b/src/analysis/vector/geometry_checker/qgsgeometrycheck.h index 312cc3de85d..3ec291e967d 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrycheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometrycheck.h @@ -26,7 +26,7 @@ #include "qgsvectorlayer.h" #include "qgsgeometry.h" #include "qgsgeometrycheckerutils.h" -#include "qgsgeometrycheckfix.h" +#include "qgsgeometrycheckresolutionmethod.h" #include "qgssettings.h" class QgsGeometryCheckError; @@ -312,14 +312,21 @@ class ANALYSIS_EXPORT QgsGeometryCheck */ virtual void fixError( const QMap &featurePools, QgsGeometryCheckError *error, int method, const QMap &mergeAttributeIndices, Changes &changes SIP_INOUT ) const SIP_SKIP; - virtual QList availableResolutionMethods() const; + /** + * Returns a list of available resolution methods. + * + * \since QGIS 3.12 + */ + virtual QList availableResolutionMethods() const; /** - * Returns a list of descriptions for available resolutions for errors. The index will be passed as ``method`` to \see fixError(). + * Returns a list of descriptions for available resolutions for errors. + * The index will be passed as ``method`` to \see fixError(). * + * \deprecated since QGIS 3.12, use availableResolutionMethods() instead * \since QGIS 3.4 */ - virtual QStringList resolutionMethods() const = 0; + Q_DECL_DEPRECATED virtual QStringList resolutionMethods() const; /** * Returns a human readable description for this check. diff --git a/src/analysis/vector/geometry_checker/qgsgeometrycheckerror.cpp b/src/analysis/vector/geometry_checker/qgsgeometrycheckerror.cpp index 0f534a7c2f0..8e5f4335191 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrycheckerror.cpp +++ b/src/analysis/vector/geometry_checker/qgsgeometrycheckerror.cpp @@ -98,8 +98,8 @@ QgsRectangle QgsGeometryCheckError::affectedAreaBBox() const void QgsGeometryCheckError::setFixed( int method ) { mStatus = StatusFixed; - const QList methods = mCheck->availableResolutionMethods(); - for ( const QgsGeometryCheckFix &fix : methods ) + const QList methods = mCheck->availableResolutionMethods(); + for ( const QgsGeometryCheckResolutionMethod &fix : methods ) { if ( fix.id() == method ) mResolutionMessage = fix.name(); diff --git a/src/analysis/vector/geometry_checker/qgsgeometrycheckfix.cpp b/src/analysis/vector/geometry_checker/qgsgeometrycheckfix.cpp deleted file mode 100644 index 60dd66a662d..00000000000 --- a/src/analysis/vector/geometry_checker/qgsgeometrycheckfix.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "qgsgeometrycheckfix.h" - -QgsGeometryCheckFix::QgsGeometryCheckFix( int id, const QString &name, const QString &description, bool isStable ) -{ - mId = id; - mName = name; - mDescription = description; - mIsStable = isStable; -} - -int QgsGeometryCheckFix::id() const -{ - return mId; -} - -bool QgsGeometryCheckFix::isStable() const -{ - return mIsStable; -} - -QString QgsGeometryCheckFix::name() const -{ - return mName; -} - -QString QgsGeometryCheckFix::description() const -{ - return mDescription; -} diff --git a/src/analysis/vector/geometry_checker/qgsgeometrycheckfix.h b/src/analysis/vector/geometry_checker/qgsgeometrycheckfix.h deleted file mode 100644 index 29670d33380..00000000000 --- a/src/analysis/vector/geometry_checker/qgsgeometrycheckfix.h +++ /dev/null @@ -1,42 +0,0 @@ -// LICENSE HEADER TODO -#ifndef QGSGEOMETRYCHECKFIX_H -#define QGSGEOMETRYCHECKFIX_H - -#include -#include "qgis_analysis.h" - -/** - * This class implements a fix for problems detected in geometry checks. - * - * \since QGIS 3.12 - */ -class ANALYSIS_EXPORT QgsGeometryCheckFix -{ - public: - QgsGeometryCheckFix( int id, const QString &name, const QString &description, bool isStable = true ); - - int id() const; - - /** - * If this fix is stable enough to be listed by default. - */ - bool isStable() const; - - /** - * A human readable and translated name for this fix. - */ - QString name() const; - - /** - * A human readable and translated description for this fix. - */ - QString description() const; - - private: - int mId = -1; - bool mIsStable = false; - QString mName; - QString mDescription; -}; - -#endif // QGSGEOMETRYCHECKFIX_H diff --git a/src/analysis/vector/geometry_checker/qgsgeometrycheckresolutionmethod.cpp b/src/analysis/vector/geometry_checker/qgsgeometrycheckresolutionmethod.cpp new file mode 100644 index 00000000000..00eca36b2d0 --- /dev/null +++ b/src/analysis/vector/geometry_checker/qgsgeometrycheckresolutionmethod.cpp @@ -0,0 +1,44 @@ +/*************************************************************************** + qgsgeometrycheckresolutionmethod.cpp + -------------------------------------- + Date : January 2020 + Copyright : (C) 2020 Matthias Kuhn + Email : matthias@opengis.ch + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "qgsgeometrycheckresolutionmethod.h" + +QgsGeometryCheckResolutionMethod::QgsGeometryCheckResolutionMethod( int id, const QString &name, const QString &description, bool isStable ) +{ + mId = id; + mName = name; + mDescription = description; + mIsStable = isStable; +} + +int QgsGeometryCheckResolutionMethod::id() const +{ + return mId; +} + +bool QgsGeometryCheckResolutionMethod::isStable() const +{ + return mIsStable; +} + +QString QgsGeometryCheckResolutionMethod::name() const +{ + return mName; +} + +QString QgsGeometryCheckResolutionMethod::description() const +{ + return mDescription; +} diff --git a/src/analysis/vector/geometry_checker/qgsgeometrycheckresolutionmethod.h b/src/analysis/vector/geometry_checker/qgsgeometrycheckresolutionmethod.h new file mode 100644 index 00000000000..3bc575575a7 --- /dev/null +++ b/src/analysis/vector/geometry_checker/qgsgeometrycheckresolutionmethod.h @@ -0,0 +1,56 @@ +/*************************************************************************** + qgsgeometrycheckresolutionmethod.h + -------------------------------------- + Date : January 2020 + Copyright : (C) 2020 Matthias Kuhn + Email : matthias@opengis.ch + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef QGSGEOMETRYCHECKRESOLUTIONMETHOD_H +#define QGSGEOMETRYCHECKRESOLUTIONMETHOD_H + +#include +#include "qgis_analysis.h" + +/** + * This class implements a fix for problems detected in geometry checks. + * + * \since QGIS 3.12 + */ +class ANALYSIS_EXPORT QgsGeometryCheckResolutionMethod +{ + public: + QgsGeometryCheckResolutionMethod( int id, const QString &name, const QString &description, bool isStable = true ); + + int id() const; + + /** + * If this fix is stable enough to be listed by default. + */ + bool isStable() const; + + /** + * A human readable and translated name for this fix. + */ + QString name() const; + + /** + * A human readable and translated description for this fix. + */ + QString description() const; + + private: + int mId = -1; + bool mIsStable = false; + QString mName; + QString mDescription; +}; + +#endif // QGSGEOMETRYCHECKRESOLUTIONMETHOD_H diff --git a/src/analysis/vector/geometry_checker/qgsgeometrygapcheck.cpp b/src/analysis/vector/geometry_checker/qgsgeometrygapcheck.cpp index fc7d3dab271..85121d9bce6 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrygapcheck.cpp +++ b/src/analysis/vector/geometry_checker/qgsgeometrygapcheck.cpp @@ -419,19 +419,19 @@ QStringList QgsGeometryGapCheck::resolutionMethods() const return methods; } -QList QgsGeometryGapCheck::availableResolutionMethods() const +QList QgsGeometryGapCheck::availableResolutionMethods() const { - QList fixes + QList fixes { - QgsGeometryCheckFix( MergeLongestEdge, tr( "Add to longest shared edge" ), tr( "Add the gap area to the neighbouring polygon with the longest shared edge." ), false ), - QgsGeometryCheckFix( CreateNewFeature, tr( "Create new feature" ), tr( "Create a new feature from the gap area." ), false ), - QgsGeometryCheckFix( MergeLargestArea, tr( "Add to largest neighbouring area" ), tr( "Add the gap area to the neighbouring polygon with the largest area." ), false ) + QgsGeometryCheckResolutionMethod( MergeLongestEdge, tr( "Add to longest shared edge" ), tr( "Add the gap area to the neighbouring polygon with the longest shared edge." ), false ), + QgsGeometryCheckResolutionMethod( CreateNewFeature, tr( "Create new feature" ), tr( "Create a new feature from the gap area." ), false ), + QgsGeometryCheckResolutionMethod( MergeLargestArea, tr( "Add to largest neighbouring area" ), tr( "Add the gap area to the neighbouring polygon with the largest area." ), false ) }; if ( mAllowedGapsSource ) - fixes << QgsGeometryCheckFix( AddToAllowedGaps, tr( "Add gap to allowed exceptions" ), tr( "Create a new feature from the gap geometry on the allowed exceptions layer." ), false ); + fixes << QgsGeometryCheckResolutionMethod( AddToAllowedGaps, tr( "Add gap to allowed exceptions" ), tr( "Create a new feature from the gap geometry on the allowed exceptions layer." ), false ); - fixes << QgsGeometryCheckFix( NoChange, tr( "No action" ), tr( "Do not perform any action and mark this error as fixed." ), false ); + fixes << QgsGeometryCheckResolutionMethod( NoChange, tr( "No action" ), tr( "Do not perform any action and mark this error as fixed." ), false ); return fixes; } diff --git a/src/analysis/vector/geometry_checker/qgsgeometrygapcheck.h b/src/analysis/vector/geometry_checker/qgsgeometrygapcheck.h index b646636a476..55ed33f95b4 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrygapcheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometrygapcheck.h @@ -116,7 +116,7 @@ class ANALYSIS_EXPORT QgsGeometryGapCheck : public QgsGeometryCheck void fixError( const QMap &featurePools, QgsGeometryCheckError *error, int method, const QMap &mergeAttributeIndices, Changes &changes ) const override; QStringList resolutionMethods() const override; - QList availableResolutionMethods() const override; + QList availableResolutionMethods() const override; QString description() const override; QString id() const override; diff --git a/src/app/qgsgeometryvalidationdock.cpp b/src/app/qgsgeometryvalidationdock.cpp index 585fb728a2e..517cd2c7e74 100644 --- a/src/app/qgsgeometryvalidationdock.cpp +++ b/src/app/qgsgeometryvalidationdock.cpp @@ -218,10 +218,10 @@ void QgsGeometryValidationDock::onCurrentErrorChanged( const QModelIndex ¤ if ( error->status() != QgsGeometryCheckError::StatusFixed ) { - const QList resolutionMethods = error->check()->availableResolutionMethods(); + const QList resolutionMethods = error->check()->availableResolutionMethods(); QGridLayout *layout = new QGridLayout( mResolutionWidget ); int resolutionIndex = 0; - for ( const QgsGeometryCheckFix &resolutionMethod : resolutionMethods ) + for ( const QgsGeometryCheckResolutionMethod &resolutionMethod : resolutionMethods ) { QToolButton *resolveBtn = new QToolButton( mResolutionWidget ); resolveBtn->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmCheckGeometry.svg" ) ) );