Skip to content
Permalink
Browse files

Data item registry: add utility method

  • Loading branch information
elpaso committed Mar 11, 2020
1 parent bc68bab commit 3439b22632725f5f8ca970007c15d5cfe89a4bbe
@@ -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/ );
@@ -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() )
@@ -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.

0 comments on commit 3439b22

Please sign in to comment.
You can’t perform that action at this time.