Skip to content

Commit

Permalink
Add api to QgsProviderMetadata to return any possible sidecar
Browse files Browse the repository at this point in the history
files which may exist for the provider given a layer path
  • Loading branch information
nyalldawson committed Aug 8, 2021
1 parent c986c1a commit 52dff0f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
14 changes: 14 additions & 0 deletions python/core/auto_generated/providers/qgsprovidermetadata.sip.in
Expand Up @@ -293,6 +293,20 @@ The default method returns ``False`` for all URIs.
ignore the specified ``uri``, not just the provider associated with this metadata!

.. versionadded:: 3.18
%End

virtual QStringList sidecarFilesForUri( const QString &uri ) const;
%Docstring
Given a ``uri``, returns any sidecar files which are associated with the URI and this
provider.

For instance, the OGR provider would return the corresponding .dbf, .idx, etc files for a
uri pointing at a .shp file.

Implementations should files any files which MAY exist for the URI, and it is up to the caller
to filter these to only existing files if required.

.. versionadded:: 3.22
%End

virtual QList< QgsProviderSublayerDetails > querySublayers( const QString &uri, Qgis::SublayerQueryFlags flags = Qgis::SublayerQueryFlags(), QgsFeedback *feedback = 0 ) const;
Expand Down
5 changes: 5 additions & 0 deletions src/core/providers/qgsprovidermetadata.cpp
Expand Up @@ -107,6 +107,11 @@ bool QgsProviderMetadata::uriIsBlocklisted( const QString & ) const
return false;
}

QStringList QgsProviderMetadata::sidecarFilesForUri( const QString & ) const
{
return QStringList();
}

QList<QgsProviderSublayerDetails> QgsProviderMetadata::querySublayers( const QString &, Qgis::SublayerQueryFlags, QgsFeedback * ) const
{
return QList<QgsProviderSublayerDetails>();
Expand Down
14 changes: 14 additions & 0 deletions src/core/providers/qgsprovidermetadata.h
Expand Up @@ -354,6 +354,20 @@ class CORE_EXPORT QgsProviderMetadata : public QObject
*/
virtual bool uriIsBlocklisted( const QString &uri ) const;

/**
* Given a \a uri, returns any sidecar files which are associated with the URI and this
* provider.
*
* For instance, the OGR provider would return the corresponding .dbf, .idx, etc files for a
* uri pointing at a .shp file.
*
* Implementations should files any files which MAY exist for the URI, and it is up to the caller
* to filter these to only existing files if required.
*
* \since QGIS 3.22
*/
virtual QStringList sidecarFilesForUri( const QString &uri ) const;

/**
* Queries the specified \a uri and returns a list of any valid sublayers found in the dataset which can be handled by this provider.
*
Expand Down

0 comments on commit 52dff0f

Please sign in to comment.