Skip to content
Permalink
Browse files
[api] Add flags to QgsProviderSublayerDetails, to indicate that
a sublayer is a system or internal table
  • Loading branch information
nyalldawson committed Aug 26, 2021
1 parent 3208b51 commit 7f090f64d12406113874c62d3a045d6981f21822
@@ -370,9 +370,15 @@
Qgis.SublayerQueryFlag.FastScan.__doc__ = "Indicates that the provider must scan for sublayers using the fastest possible approach -- e.g. by first checking that a uri has an extension which is known to be readable by the provider"
Qgis.SublayerQueryFlag.ResolveGeometryType.__doc__ = "Attempt to resolve the geometry type for vector sublayers"
Qgis.SublayerQueryFlag.CountFeatures.__doc__ = "Count features in vector sublayers"
Qgis.SublayerQueryFlag.__doc__ = 'Flags which control how data providers will scan for sublayers in a dataset.\n\n.. versionadded:: 3.22\n\n' + '* ``FastScan``: ' + Qgis.SublayerQueryFlag.FastScan.__doc__ + '\n' + '* ``ResolveGeometryType``: ' + Qgis.SublayerQueryFlag.ResolveGeometryType.__doc__ + '\n' + '* ``CountFeatures``: ' + Qgis.SublayerQueryFlag.CountFeatures.__doc__
Qgis.SublayerQueryFlag.IncludeSystemTables.__doc__ = "Include system or internal tables (these are not included by default)"
Qgis.SublayerQueryFlag.__doc__ = 'Flags which control how data providers will scan for sublayers in a dataset.\n\n.. versionadded:: 3.22\n\n' + '* ``FastScan``: ' + Qgis.SublayerQueryFlag.FastScan.__doc__ + '\n' + '* ``ResolveGeometryType``: ' + Qgis.SublayerQueryFlag.ResolveGeometryType.__doc__ + '\n' + '* ``CountFeatures``: ' + Qgis.SublayerQueryFlag.CountFeatures.__doc__ + '\n' + '* ``IncludeSystemTables``: ' + Qgis.SublayerQueryFlag.IncludeSystemTables.__doc__
# --
Qgis.SublayerQueryFlag.baseClass = Qgis
# monkey patching scoped based enum
Qgis.SublayerFlag.SystemTable.__doc__ = "Sublayer is a system or internal table, which should be hidden by default"
Qgis.SublayerFlag.__doc__ = 'Flags which reflect the properties of sublayers in a dataset.\n\n.. versionadded:: 3.22\n\n' + '* ``SystemTable``: ' + Qgis.SublayerFlag.SystemTable.__doc__
# --
Qgis.SublayerFlag.baseClass = Qgis
QgsRasterPipe.Role = Qgis.RasterPipeInterfaceRole
# monkey patching scoped based enum
QgsRasterPipe.UnknownRole = Qgis.RasterPipeInterfaceRole.Unknown
@@ -121,6 +121,20 @@ Returns the layer's description.
Sets the layer's ``description``.

.. seealso:: :py:func:`description`
%End

Qgis::SublayerFlags flags() const;
%Docstring
Returns the layer's flags, which indicate properties of the layer.

.. seealso:: :py:func:`setFlags`
%End

void setFlags( Qgis::SublayerFlags newFlags );
%Docstring
Sets the layer's ``flags``, which indicate properties of the layer.

.. seealso:: :py:func:`flags`
%End

QString driverName() const;
@@ -278,10 +278,18 @@ The development version
FastScan,
ResolveGeometryType,
CountFeatures,
IncludeSystemTables,
};
typedef QFlags<Qgis::SublayerQueryFlag> SublayerQueryFlags;


enum class SublayerFlag
{
SystemTable,
};
typedef QFlags<Qgis::SublayerFlag> SublayerFlags;


enum class RasterPipeInterfaceRole
{
Unknown,
@@ -534,6 +542,8 @@ QFlags<Qgis::BrowserItemCapability> operator|(Qgis::BrowserItemCapability f1, QF

QFlags<Qgis::SublayerQueryFlag> operator|(Qgis::SublayerQueryFlag f1, QFlags<Qgis::SublayerQueryFlag> f2);

QFlags<Qgis::SublayerFlag> operator|(Qgis::SublayerFlag f1, QFlags<Qgis::SublayerFlag> f2);

QFlags<Qgis::SqlLayerDefinitionCapability> operator|(Qgis::SqlLayerDefinitionCapability f1, QFlags<Qgis::SqlLayerDefinitionCapability> f2);

QFlags<Qgis::BabelFormatCapability> operator|(Qgis::BabelFormatCapability f1, QFlags<Qgis::BabelFormatCapability> f2);
@@ -30,6 +30,7 @@ bool QgsProviderSublayerDetails::operator==( const QgsProviderSublayerDetails &o
{
return mProviderKey == other.mProviderKey
&& mType == other.mType
&& mFlags == other.mFlags
&& mUri == other.mUri
&& mLayerNumber == other.mLayerNumber
&& mName == other.mName
@@ -142,6 +142,20 @@ class CORE_EXPORT QgsProviderSublayerDetails
*/
void setDescription( const QString &description ) { mDescription = description; }

/**
* Returns the layer's flags, which indicate properties of the layer.
*
* \see setFlags()
*/
Qgis::SublayerFlags flags() const { return mFlags; }

/**
* Sets the layer's \a flags, which indicate properties of the layer.
*
* \see flags()
*/
void setFlags( Qgis::SublayerFlags newFlags ) { mFlags = newFlags; }

/**
* Returns the layer's driver name.
*
@@ -284,6 +298,7 @@ class CORE_EXPORT QgsProviderSublayerDetails
QgsWkbTypes::Type mWkbType = QgsWkbTypes::Unknown;
QString mDriverName;
bool mSkippedContainerScan = false;
Qgis::SublayerFlags mFlags = Qgis::SublayerFlags();

};

@@ -413,10 +413,23 @@ class CORE_EXPORT Qgis
FastScan = 1 << 0, //!< Indicates that the provider must scan for sublayers using the fastest possible approach -- e.g. by first checking that a uri has an extension which is known to be readable by the provider
ResolveGeometryType = 1 << 1, //!< Attempt to resolve the geometry type for vector sublayers
CountFeatures = 1 << 2, //!< Count features in vector sublayers
IncludeSystemTables = 1 << 3, //!< Include system or internal tables (these are not included by default)
};
Q_DECLARE_FLAGS( SublayerQueryFlags, SublayerQueryFlag )
Q_ENUM( SublayerQueryFlag )

/**
* Flags which reflect the properties of sublayers in a dataset.
*
* \since QGIS 3.22
*/
enum class SublayerFlag : int
{
SystemTable = 1 << 0, //!< Sublayer is a system or internal table, which should be hidden by default
};
Q_DECLARE_FLAGS( SublayerFlags, SublayerFlag )
Q_ENUM( SublayerFlag )

/**
* Raster pipe interface roles.
*
@@ -836,6 +849,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SymbolFlags )
Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SymbolPreviewFlags )
Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::BrowserItemCapabilities )
Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SublayerQueryFlags )
Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SublayerFlags )
Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SqlLayerDefinitionCapabilities )
Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::BabelFormatCapabilities )
Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::BabelCommandFlags )
@@ -77,6 +77,11 @@ def testGettersSetters(self):
d.setSkippedContainerScan(False)
self.assertFalse(d.skippedContainerScan())

d.setFlags(Qgis.SublayerFlag.SystemTable)
self.assertEqual(d.flags(), Qgis.SublayerFlags(Qgis.SublayerFlag.SystemTable))
d.setFlags(Qgis.SublayerFlags())
self.assertEqual(d.flags(), Qgis.SublayerFlags())

def test_equality(self):
"""
Test equality operator
@@ -143,6 +148,11 @@ def test_equality(self):
d2.setSkippedContainerScan(True)
self.assertEqual(d, d2)

d.setFlags(Qgis.SublayerFlag.SystemTable)
self.assertNotEqual(d, d2)
d2.setFlags(Qgis.SublayerFlag.SystemTable)
self.assertEqual(d, d2)

def test_to_layer(self):
"""
Test converting sub layer details to a layer

0 comments on commit 7f090f6

Please sign in to comment.