diff --git a/python/core/auto_additions/qgscoreenums.py b/python/core/auto_additions/qgscoreenums.py index 3fdfc1ee3809..e31ce1eb0bfd 100644 --- a/python/core/auto_additions/qgscoreenums.py +++ b/python/core/auto_additions/qgscoreenums.py @@ -17,3 +17,11 @@ QgsMapLayer.PointCloudLayer.__doc__ = "Added in 3.18" QgsMapLayerType.__doc__ = 'Types of layers that can be added to a map\n\n.. versionadded:: 3.8\n\n' + '* ``VectorLayer``: ' + QgsMapLayerType.VectorLayer.__doc__ + '\n' + '* ``RasterLayer``: ' + QgsMapLayerType.RasterLayer.__doc__ + '\n' + '* ``PluginLayer``: ' + QgsMapLayerType.PluginLayer.__doc__ + '\n' + '* ``MeshLayer``: ' + QgsMapLayerType.MeshLayer.__doc__ + '\n' + '* ``VectorTileLayer``: ' + QgsMapLayerType.VectorTileLayer.__doc__ + '\n' + '* ``AnnotationLayer``: ' + QgsMapLayerType.AnnotationLayer.__doc__ + '\n' + '* ``PointCloudLayer``: ' + QgsMapLayerType.PointCloudLayer.__doc__ # -- +QgsVectorDataProvider.FeatureCountState = FeatureCountState +# monkey patching scoped based enum +QgsVectorDataProvider.Uncounted = FeatureCountState.Uncounted +QgsVectorDataProvider.Uncounted.__doc__ = "Feature count not yet computed" +QgsVectorDataProvider.UnknownCount = FeatureCountState.UnknownCount +QgsVectorDataProvider.UnknownCount.__doc__ = "Provider returned an unknown feature count" +FeatureCountState.__doc__ = 'Enumeration of feature count states\n\n.. versionadded:: 3.20\n\n' + '* ``Uncounted``: ' + FeatureCountState.Uncounted.__doc__ + '\n' + '* ``UnknownCount``: ' + FeatureCountState.UnknownCount.__doc__ +# -- diff --git a/python/core/auto_generated/qgscoreenums.sip.in b/python/core/auto_generated/qgscoreenums.sip.in index ba788d53d620..94ab0246c761 100644 --- a/python/core/auto_generated/qgscoreenums.sip.in +++ b/python/core/auto_generated/qgscoreenums.sip.in @@ -20,6 +20,12 @@ enum class QgsMapLayerType PointCloudLayer, }; +enum class FeatureCountState + { + Uncounted, + UnknownCount, +}; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/core/auto_generated/vector/qgsvectordataprovider.sip.in b/python/core/auto_generated/vector/qgsvectordataprovider.sip.in index 4fb0fd51aac7..7e22a47d3e98 100644 --- a/python/core/auto_generated/vector/qgsvectordataprovider.sip.in +++ b/python/core/auto_generated/vector/qgsvectordataprovider.sip.in @@ -62,14 +62,6 @@ of feature and attribute information from a spatial datasource. static const int EditingCapabilities; - enum FeatureCountState - { - //! Feature count not yet computed - Uncounted, - //! Provider returned an unknown feature count - UnknownCount, - }; - QgsVectorDataProvider( const QString &uri = QString(), const QgsDataProvider::ProviderOptions &providerOptions = QgsDataProvider::ProviderOptions(), QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() ); diff --git a/scripts/sipify.pl b/scripts/sipify.pl index a01a5d05a42a..d5fb8306495e 100755 --- a/scripts/sipify.pl +++ b/scripts/sipify.pl @@ -1082,8 +1082,13 @@ sub detect_non_method_member{ { push @OUTPUT_PYTHON, "$ACTUAL_CLASS.$enum_member = $ACTUAL_CLASS.$enum_qualname.$enum_member\n"; } - push @OUTPUT_PYTHON, "$ACTUAL_CLASS.$enum_qualname.$enum_member.__doc__ = \"$comment\"\n"; - push @enum_members_doc, "'* ``$enum_member``: ' + $ACTUAL_CLASS.$enum_qualname.$enum_member.__doc__"; + if ( $ACTUAL_CLASS ne "" ){ + push @OUTPUT_PYTHON, "$ACTUAL_CLASS.$enum_qualname.$enum_member.__doc__ = \"$comment\"\n"; + push @enum_members_doc, "'* ``$enum_member``: ' + $ACTUAL_CLASS.$enum_qualname.$enum_member.__doc__"; + } else { + push @OUTPUT_PYTHON, "$enum_qualname.$enum_member.__doc__ = \"$comment\"\n"; + push @enum_members_doc, "'* ``$enum_member``: ' + $enum_qualname.$enum_member.__doc__"; + } } } $enum_decl = fix_annotations($enum_decl); @@ -1161,10 +1166,10 @@ sub detect_non_method_member{ # catch Q_DECLARE_FLAGS if ( $LINE =~ m/^(\s*)Q_DECLARE_FLAGS\(\s*(.*?)\s*,\s*(.*?)\s*\)\s*$/ ){ - my $ACTUAL_CLASS = $CLASSNAME[$#CLASSNAME]; + my $ACTUAL_CLASS = $#CLASSNAME >= 0 ? $CLASSNAME[$#CLASSNAME].'::' : ''; dbg_info("Declare flags: $ACTUAL_CLASS"); - $LINE = "$1typedef QFlags<${ACTUAL_CLASS}::$3> $2;\n"; - $QFLAG_HASH{"${ACTUAL_CLASS}::$2"} = "${ACTUAL_CLASS}::$3"; + $LINE = "$1typedef QFlags<${ACTUAL_CLASS}$3> $2;\n"; + $QFLAG_HASH{"${ACTUAL_CLASS}$2"} = "${ACTUAL_CLASS}$3"; } # catch Q_DECLARE_OPERATORS_FOR_FLAGS if ( $LINE =~ m/^(\s*)Q_DECLARE_OPERATORS_FOR_FLAGS\(\s*(.*?)\s*\)\s*$/ ){ diff --git a/src/app/qgsapplayertreeviewmenuprovider.h b/src/app/qgsapplayertreeviewmenuprovider.h index 1b68f807321c..9792f10caa38 100644 --- a/src/app/qgsapplayertreeviewmenuprovider.h +++ b/src/app/qgsapplayertreeviewmenuprovider.h @@ -18,9 +18,10 @@ #include #include "qgslayertreeview.h" -#include "qgsmaplayer.h" +#include "qgscoreenums.h" class QAction; +class QgsCoordinateReferenceSystem; struct LegendLayerAction { diff --git a/src/core/providers/ogr/qgsogrprovider.cpp b/src/core/providers/ogr/qgsogrprovider.cpp index 1c2a75885bc3..9ee5f1dcffbd 100644 --- a/src/core/providers/ogr/qgsogrprovider.cpp +++ b/src/core/providers/ogr/qgsogrprovider.cpp @@ -259,8 +259,8 @@ void QgsOgrProvider::repack() } - if ( mFeaturesCounted != QgsVectorDataProvider::Uncounted && - mFeaturesCounted != QgsVectorDataProvider::UnknownCount ) + if ( mFeaturesCounted != static_cast< long >( FeatureCountState::Uncounted ) && + mFeaturesCounted != static_cast< long >( FeatureCountState::UnknownCount ) ) { long oldcount = mFeaturesCounted; recalculateFeatureCount(); @@ -1842,7 +1842,7 @@ long QgsOgrProvider::featureCount() const { if ( ( mReadFlags & QgsDataProvider::SkipFeatureCount ) != 0 ) { - return QgsVectorDataProvider::UnknownCount; + return static_cast< long >( FeatureCountState::UnknownCount ); } if ( mRefreshFeatureCount ) { @@ -2238,8 +2238,8 @@ bool QgsOgrProvider::addFeatures( QgsFeatureList &flist, Flags flags ) returnvalue = false; } - if ( mFeaturesCounted != QgsVectorDataProvider::Uncounted && - mFeaturesCounted != QgsVectorDataProvider::UnknownCount ) + if ( mFeaturesCounted != static_cast< long >( FeatureCountState::Uncounted ) && + mFeaturesCounted != static_cast< long >( FeatureCountState::UnknownCount ) ) { if ( returnvalue ) mFeaturesCounted += flist.size(); @@ -2584,7 +2584,7 @@ bool QgsOgrProvider::_setSubsetString( const QString &theSQL, bool updateFeature if ( !mOgrOrigLayer ) return false; - if ( theSQL == mSubsetString && mFeaturesCounted != QgsVectorDataProvider::Uncounted ) + if ( theSQL == mSubsetString && mFeaturesCounted != static_cast< long >( FeatureCountState::Uncounted ) ) return true; const bool subsetStringHasChanged { theSQL != mSubsetString }; @@ -3200,8 +3200,8 @@ bool QgsOgrProvider::deleteFeatures( const QgsFeatureIds &id ) } else { - if ( mFeaturesCounted != QgsVectorDataProvider::Uncounted && - mFeaturesCounted != QgsVectorDataProvider::UnknownCount ) + if ( mFeaturesCounted != static_cast< long >( FeatureCountState::Uncounted ) && + mFeaturesCounted != static_cast< long >( FeatureCountState::UnknownCount ) ) { if ( returnvalue ) mFeaturesCounted -= id.size(); @@ -5002,7 +5002,7 @@ void QgsOgrProvider::recalculateFeatureCount() const { if ( !mOgrLayer ) { - mFeaturesCounted = QgsVectorDataProvider::Uncounted; + mFeaturesCounted = static_cast< long >( FeatureCountState::Uncounted ); return; } @@ -5020,7 +5020,7 @@ void QgsOgrProvider::recalculateFeatureCount() const mFeaturesCounted = mOgrLayer->GetApproxFeatureCount(); if ( mFeaturesCounted == -1 ) { - mFeaturesCounted = QgsVectorDataProvider::UnknownCount; + mFeaturesCounted = static_cast< long >( FeatureCountState::UnknownCount ); } } else @@ -5366,7 +5366,7 @@ void QgsOgrProvider::close() void QgsOgrProvider::reloadProviderData() { - mFeaturesCounted = QgsVectorDataProvider::Uncounted; + mFeaturesCounted = static_cast< long >( FeatureCountState::Uncounted ); bool wasValid = mValid; QgsOgrConnPool::instance()->invalidateConnections( QgsOgrProviderUtils::connectionPoolId( dataSourceUri( true ), mShareSameDatasetAmongLayers ) ); close(); diff --git a/src/core/providers/ogr/qgsogrprovider.h b/src/core/providers/ogr/qgsogrprovider.h index c66b3f8851bf..034b53fe308b 100644 --- a/src/core/providers/ogr/qgsogrprovider.h +++ b/src/core/providers/ogr/qgsogrprovider.h @@ -26,6 +26,7 @@ email : sherman at mrcc.com #include "qgsvectorlayerexporter.h" #include "qgsprovidermetadata.h" #include "qgis_sip.h" +#include "qgscoreenums.h" ///@cond PRIVATE #define SIP_NO_FILE @@ -309,7 +310,7 @@ class QgsOgrProvider final: public QgsVectorDataProvider //! Whether the next call to featureCount() should refresh the feature count mutable bool mRefreshFeatureCount = true; - mutable long mFeaturesCounted = QgsVectorDataProvider::Uncounted; + mutable long mFeaturesCounted = static_cast< long >( FeatureCountState::Uncounted ); mutable QStringList mSubLayerList; diff --git a/src/core/qgsbrowserproxymodel.h b/src/core/qgsbrowserproxymodel.h index 9b9b20811293..8250daf22808 100644 --- a/src/core/qgsbrowserproxymodel.h +++ b/src/core/qgsbrowserproxymodel.h @@ -17,7 +17,7 @@ #include "qgis_core.h" #include "qgis_sip.h" -#include "qgsmaplayer.h" +#include "qgscoreenums.h" #include class QgsBrowserModel; diff --git a/src/core/qgscoreenums.h b/src/core/qgscoreenums.h index 42636689d744..b01b2048a081 100644 --- a/src/core/qgscoreenums.h +++ b/src/core/qgscoreenums.h @@ -37,4 +37,15 @@ enum class QgsMapLayerType SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsMapLayer, LayerT PointCloudLayer, //!< Added in 3.18 }; +/** + * \ingroup core + * \brief Enumeration of feature count states + * \since QGIS 3.20 + */ +enum class FeatureCountState SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsVectorDataProvider, FeatureCountState ) : int + { + Uncounted = -2, //!< Feature count not yet computed + UnknownCount = -1, //!< Provider returned an unknown feature count +}; + #endif // QGSCOREENUMS_H diff --git a/src/core/qgsdataitem.h b/src/core/qgsdataitem.h index e6e9ed48838a..3628432ab6dc 100644 --- a/src/core/qgsdataitem.h +++ b/src/core/qgsdataitem.h @@ -29,7 +29,7 @@ #include #include -#include "qgsmaplayer.h" +#include "qgscoreenums.h" #include "qgscoordinatereferencesystem.h" #include "qgsmimedatautils.h" #include "qgswkbtypes.h" diff --git a/src/core/qgsmapclippingutils.h b/src/core/qgsmapclippingutils.h index 9766f92f5c35..428516daced4 100644 --- a/src/core/qgsmapclippingutils.h +++ b/src/core/qgsmapclippingutils.h @@ -18,7 +18,7 @@ #include "qgis_core.h" #include "qgis_sip.h" -#include "qgsmaplayer.h" +#include "qgscoreenums.h" #include #include diff --git a/src/core/qgsmaplayerfactory.h b/src/core/qgsmaplayerfactory.h index 2bcf1a5f76cb..7a24a0849507 100644 --- a/src/core/qgsmaplayerfactory.h +++ b/src/core/qgsmaplayerfactory.h @@ -19,7 +19,7 @@ #define QGSMAPLAYERFACTORY_H #include "qgis_core.h" -#include "qgsmaplayer.h" +#include "qgscoreenums.h" #include diff --git a/src/core/vector/qgsvectordataprovider.h b/src/core/vector/qgsvectordataprovider.h index b3fcd11456e5..332b221ffaf9 100644 --- a/src/core/vector/qgsvectordataprovider.h +++ b/src/core/vector/qgsvectordataprovider.h @@ -105,17 +105,6 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider, public QgsFeat ChangeAttributeValues | ChangeGeometries | AddAttributes | DeleteAttributes | RenameAttributes; - /** - * Enumeration of feature count states - */ - enum FeatureCountState - { - //! Feature count not yet computed - Uncounted = -2, - //! Provider returned an unknown feature count - UnknownCount = -1, - }; - /** * Constructor for a vector data provider. * diff --git a/src/gui/qgsdatasourceselectdialog.h b/src/gui/qgsdatasourceselectdialog.h index ebe316617ed4..bb15eb4a8e8d 100644 --- a/src/gui/qgsdatasourceselectdialog.h +++ b/src/gui/qgsdatasourceselectdialog.h @@ -19,7 +19,7 @@ #include "ui_qgsdatasourceselectdialog.h" #include "qgis_gui.h" -#include "qgsmaplayer.h" +#include "qgscoreenums.h" #include "qgsmimedatautils.h" #include "qgsbrowserguimodel.h" #include "qgsbrowserproxymodel.h" diff --git a/src/gui/qgsidentifymenu.h b/src/gui/qgsidentifymenu.h index fa723af1bdf8..4d8b8c1f2c4d 100644 --- a/src/gui/qgsidentifymenu.h +++ b/src/gui/qgsidentifymenu.h @@ -20,6 +20,7 @@ #include "qgsmaplayeractionregistry.h" #include "qgsmaptoolidentify.h" +#include "qgsexpressioncontext.h" #include "qgis_gui.h" #include "qgis_sip.h" diff --git a/src/gui/qgsmaplayeractionregistry.h b/src/gui/qgsmaplayeractionregistry.h index f6d6b4dc7e80..16ffbbaae4af 100644 --- a/src/gui/qgsmaplayeractionregistry.h +++ b/src/gui/qgsmaplayeractionregistry.h @@ -22,10 +22,11 @@ #include #include -#include "qgsmaplayer.h" +#include "qgscoreenums.h" #include "qgis_gui.h" class QgsFeature; +class QgsMapLayer; /** * \ingroup gui diff --git a/src/gui/qgsmaplayerstylecategoriesmodel.h b/src/gui/qgsmaplayerstylecategoriesmodel.h index e16e4afdf260..23801ff0a0c5 100644 --- a/src/gui/qgsmaplayerstylecategoriesmodel.h +++ b/src/gui/qgsmaplayerstylecategoriesmodel.h @@ -21,6 +21,7 @@ #include +#include "qgscoreenums.h" #include "qgsmaplayer.h" #include "qgis_gui.h"