Skip to content
Permalink
Browse files

Allow provider libraries to create QgsDataItemGuiProviders

...by implementing dataItemGuiProviders()
  • Loading branch information
nyalldawson committed Oct 27, 2018
1 parent 310d4f9 commit c9f9374dbb6737610d5b8d7be377b891c980ed8f
Showing with 19 additions and 0 deletions.
  1. +19 −0 src/gui/qgsdataitemguiproviderregistry.cpp
@@ -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()

0 comments on commit c9f9374

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