Skip to content

Commit

Permalink
Add flag to QgsProviderSublayerDetails to indicate that the uri
Browse files Browse the repository at this point in the history
may be a container for other sublayers but that indepth scanning
of the container was skipped
  • Loading branch information
nyalldawson committed Jul 23, 2021
1 parent e6f0c92 commit e28a0b7
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
Expand Up @@ -227,6 +227,22 @@ Returns the associated layer number, for providers which order sublayers.
Sets the associated layer ``number``, for providers which order sublayers.

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

void setSkippedContainerScan( bool skipped );
%Docstring
Set to ``True`` if the layer is a potential dataset container and an in-depth scan
of its contents was skipped.

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

bool skippedContainerScan() const;
%Docstring
Returns ``True`` if the layer is a potential dataset container and an in-depth scan
of its contents was skipped.

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

bool operator==( const QgsProviderSublayerDetails &other ) const;
Expand Down
1 change: 1 addition & 0 deletions src/core/providers/qgsprovidersublayerdetails.cpp
Expand Up @@ -38,6 +38,7 @@ bool QgsProviderSublayerDetails::operator==( const QgsProviderSublayerDetails &o
&& mGeometryColumnName == other.mGeometryColumnName
&& mPath == other.mPath
&& mWkbType == other.mWkbType
&& mSkippedContainerScan == other.mSkippedContainerScan
&& mDriverName == other.mDriverName;
}

Expand Down
17 changes: 17 additions & 0 deletions src/core/providers/qgsprovidersublayerdetails.h
Expand Up @@ -250,6 +250,22 @@ class CORE_EXPORT QgsProviderSublayerDetails
*/
void setLayerNumber( int number ) { mLayerNumber = number; }

/**
* Set to TRUE if the layer is a potential dataset container and an in-depth scan
* of its contents was skipped.
*
* \see skippedContainerScan();
*/
void setSkippedContainerScan( bool skipped ) { mSkippedContainerScan = skipped; }

/**
* Returns TRUE if the layer is a potential dataset container and an in-depth scan
* of its contents was skipped.
*
* \see setSkippedContainerScan();
*/
bool skippedContainerScan() const { return mSkippedContainerScan; }

// TODO c++20 - replace with = default
bool operator==( const QgsProviderSublayerDetails &other ) const;
bool operator!=( const QgsProviderSublayerDetails &other ) const;
Expand All @@ -267,6 +283,7 @@ class CORE_EXPORT QgsProviderSublayerDetails
QStringList mPath;
QgsWkbTypes::Type mWkbType = QgsWkbTypes::Unknown;
QString mDriverName;
bool mSkippedContainerScan = false;

};

Expand Down
10 changes: 10 additions & 0 deletions tests/src/python/test_qgsprovidersublayerdetails.py
Expand Up @@ -72,6 +72,11 @@ def testGettersSetters(self):
d.setDriverName('drv')
self.assertEqual(d.driverName(), 'drv')

d.setSkippedContainerScan(True)
self.assertTrue(d.skippedContainerScan())
d.setSkippedContainerScan(False)
self.assertFalse(d.skippedContainerScan())

def test_equality(self):
"""
Test equality operator
Expand Down Expand Up @@ -133,6 +138,11 @@ def test_equality(self):
d2.setDriverName('drv')
self.assertEqual(d, d2)

d.setSkippedContainerScan(True)
self.assertNotEqual(d, d2)
d2.setSkippedContainerScan(True)
self.assertEqual(d, d2)

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

0 comments on commit e28a0b7

Please sign in to comment.