Skip to content

Commit

Permalink
API to register new vector data providers
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Jun 1, 2018
1 parent 222f3ad commit 9d66eb8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
13 changes: 13 additions & 0 deletions python/core/auto_generated/qgsproviderregistry.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,19 @@ Returns a string containing the available protocol drivers

void registerGuis( QWidget *widget );

void registerProvider( QgsProviderMetadata *providerMetadata /Transfer/ );
%Docstring
register a new vector data provider from its ``providerMetadata``

:param providerMetadata: QgsProviderMetadata instance describing the new provider

.. note::

ownership of the QgsProviderMetadata instance is transferred to the registry

.. versionadded:: 3.2
%End



private:
Expand Down
6 changes: 6 additions & 0 deletions src/core/qgsproviderregistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,12 @@ void QgsProviderRegistry::registerGuis( QWidget *parent )
}
}

void QgsProviderRegistry::registerProvider( QgsProviderMetadata *providerMetadata )
{
if ( providerMetadata )
mProviders[ providerMetadata->key() ] = providerMetadata;
}

QString QgsProviderRegistry::fileVectorFilters() const
{
return mVectorFileFilters;
Expand Down
8 changes: 8 additions & 0 deletions src/core/qgsproviderregistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ class CORE_EXPORT QgsProviderRegistry

void registerGuis( QWidget *widget );

/**
* \brief register a new vector data provider from its \a providerMetadata
* \param providerMetadata QgsProviderMetadata instance describing the new provider
* \note ownership of the QgsProviderMetadata instance is transferred to the registry
* \since QGIS 3.2
*/
void registerProvider( QgsProviderMetadata *providerMetadata SIP_TRANSFER );

/**
* Open the given vector data source
*
Expand Down

0 comments on commit 9d66eb8

Please sign in to comment.