Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Data item registry: add utility method
  • Loading branch information
elpaso committed Mar 11, 2020
1 parent bc68bab commit 3439b22
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions python/core/auto_generated/qgsdataitemproviderregistry.sip.in
Expand Up @@ -36,6 +36,13 @@ QgsDataItemProviderRegistry is not usually directly created, but rather accessed
QList<QgsDataItemProvider *> providers() const;
%Docstring
Returns the list of available providers.
%End

QgsDataItemProvider *provider( const QString &providerName ) const;
%Docstring
Returns the (possibly NULL) data item provider named ``providerName``

.. versionadded:: 3.14
%End

void addProvider( QgsDataItemProvider *provider /Transfer/ );
Expand Down
12 changes: 12 additions & 0 deletions src/core/qgsdataitemproviderregistry.cpp
Expand Up @@ -47,6 +47,18 @@ QgsDataItemProviderRegistry::~QgsDataItemProviderRegistry()

QList<QgsDataItemProvider *> QgsDataItemProviderRegistry::providers() const { return mProviders; }

QgsDataItemProvider *QgsDataItemProviderRegistry::provider( const QString &providerName ) const
{
for ( const auto &p : qgis::as_const( mProviders ) )
{
if ( p->name() == providerName )
{
return p;
}
}
return nullptr;
}

void QgsDataItemProviderRegistry::addProvider( QgsDataItemProvider *provider )
{
if ( ! provider->dataProviderKey().isEmpty() )
Expand Down
6 changes: 6 additions & 0 deletions src/core/qgsdataitemproviderregistry.h
Expand Up @@ -53,6 +53,12 @@ class CORE_EXPORT QgsDataItemProviderRegistry
*/
QList<QgsDataItemProvider *> providers() const;

/**
* Returns the (possibly NULL) data item provider named \a providerName
* \since QGIS 3.14
*/
QgsDataItemProvider *provider( const QString &providerName ) const;

/**
* Adds a \a provider implementation to the registry. Ownership of the provider
* is transferred to the registry.
Expand Down

0 comments on commit 3439b22

Please sign in to comment.