Skip to content
Permalink
Browse files
Move QgsVectorDataProvider::FeatureCountState enum to qgscoreenums.h
  • Loading branch information
nyalldawson committed May 18, 2021
1 parent c47b2fb commit 239092e0f187668d29b6d4c1fe80a3a0eedb2899
@@ -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__
# --
@@ -20,6 +20,12 @@ enum class QgsMapLayerType
PointCloudLayer,
};

enum class FeatureCountState
{
Uncounted,
UnknownCount,
};

/************************************************************************
* This file has been generated automatically from *
* *
@@ -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() );
@@ -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*$/ ){
@@ -18,9 +18,10 @@
#include <QObject>

#include "qgslayertreeview.h"
#include "qgsmaplayer.h"
#include "qgscoreenums.h"

class QAction;
class QgsCoordinateReferenceSystem;

struct LegendLayerAction
{
@@ -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();
@@ -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;

@@ -17,7 +17,7 @@

#include "qgis_core.h"
#include "qgis_sip.h"
#include "qgsmaplayer.h"
#include "qgscoreenums.h"
#include <QSortFilterProxyModel>

class QgsBrowserModel;
@@ -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
@@ -29,7 +29,7 @@
#include <QVector>
#include <QDateTime>

#include "qgsmaplayer.h"
#include "qgscoreenums.h"
#include "qgscoordinatereferencesystem.h"
#include "qgsmimedatautils.h"
#include "qgswkbtypes.h"
@@ -18,7 +18,7 @@

#include "qgis_core.h"
#include "qgis_sip.h"
#include "qgsmaplayer.h"
#include "qgscoreenums.h"

#include <QList>
#include <QPainterPath>
@@ -19,7 +19,7 @@
#define QGSMAPLAYERFACTORY_H

#include "qgis_core.h"
#include "qgsmaplayer.h"
#include "qgscoreenums.h"

#include <QString>

@@ -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.
*
@@ -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"
@@ -20,6 +20,7 @@

#include "qgsmaplayeractionregistry.h"
#include "qgsmaptoolidentify.h"
#include "qgsexpressioncontext.h"
#include "qgis_gui.h"
#include "qgis_sip.h"

@@ -22,10 +22,11 @@
#include <QMap>
#include <QAction>

#include "qgsmaplayer.h"
#include "qgscoreenums.h"
#include "qgis_gui.h"

class QgsFeature;
class QgsMapLayer;

/**
* \ingroup gui
@@ -21,6 +21,7 @@

#include <QAbstractListModel>

#include "qgscoreenums.h"
#include "qgsmaplayer.h"
#include "qgis_gui.h"

0 comments on commit 239092e

Please sign in to comment.