Navigation Menu

Skip to content

Commit

Permalink
Allow provider libraries to create QgsDataItemGuiProviders
Browse files Browse the repository at this point in the history
...by implementing dataItemGuiProviders()
  • Loading branch information
nyalldawson committed Nov 4, 2018
1 parent 310d4f9 commit c9f9374
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/gui/qgsdataitemguiproviderregistry.cpp
Expand Up @@ -15,9 +15,28 @@

#include "qgsdataitemguiproviderregistry.h"
#include "qgsdataitemguiprovider.h"
#include "qgsproviderregistry.h"

typedef QList<QgsDataItemGuiProvider *> *dataItemGuiProviders_t();

QgsDataItemGuiProviderRegistry::QgsDataItemGuiProviderRegistry()
{
const QStringList providersList = QgsProviderRegistry::instance()->providerList();

for ( const QString &key : providersList )
{
std::unique_ptr< QLibrary > library( QgsProviderRegistry::instance()->createProviderLibrary( key ) );
if ( !library )
continue;

if ( dataItemGuiProviders_t *dataItemGuiProvidersFn = reinterpret_cast< dataItemGuiProviders_t * >( cast_to_fptr( library->resolve( "dataItemGuiProviders" ) ) ) )
{
const QList<QgsDataItemGuiProvider *> *providerList = dataItemGuiProvidersFn();
// the function is a factory - we keep ownership of the returned providers
mProviders << *providerList;
delete providerList;
}
}
}

QgsDataItemGuiProviderRegistry::~QgsDataItemGuiProviderRegistry()
Expand Down

0 comments on commit c9f9374

Please sign in to comment.