Skip to content

Commit

Permalink
Add uri to QgsProviderSublayerDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 23, 2021
1 parent 55e20eb commit 07f5812
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
Expand Up @@ -59,6 +59,20 @@ Returns the layer type.
Sets the layer ``type``.

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

QString uri() const;
%Docstring
Returns the layer's URI.

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

void setUri( const QString &uri );
%Docstring
Sets the layer's ``uri``.

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

QString name() const;
Expand Down
15 changes: 15 additions & 0 deletions src/core/providers/qgsprovidersublayerdetails.h
Expand Up @@ -72,6 +72,20 @@ class CORE_EXPORT QgsProviderSublayerDetails
*/
void setType( QgsMapLayerType type ) { mType = type; }

/**
* Returns the layer's URI.
*
* \see setUri()
*/
QString uri() const { return mUri; }

/**
* Sets the layer's \a uri.
*
* \see uri()
*/
void setUri( const QString &uri ) { mUri = uri; }

/**
* Returns the layer's name.
*
Expand Down Expand Up @@ -196,6 +210,7 @@ class CORE_EXPORT QgsProviderSublayerDetails

QString mProviderKey;
QgsMapLayerType mType = QgsMapLayerType::VectorLayer;
QString mUri;
int mLayerNumber = 0;
QString mName;
QString mDescription;
Expand Down
3 changes: 3 additions & 0 deletions tests/src/python/test_qgsprovidersublayerdetails.py
Expand Up @@ -39,6 +39,9 @@ def testGettersSetters(self):
d.setType(QgsMapLayerType.MeshLayer)
self.assertEqual(d.type(), QgsMapLayerType.MeshLayer)

d.setUri('some uri')
self.assertEqual(d.uri(), 'some uri')

d.setName('name')
self.assertEqual(d.name(), 'name')

Expand Down

0 comments on commit 07f5812

Please sign in to comment.