25 #include "qgsgdalguiprovider.h"
26 #include "qgsogrguiprovider.h"
28 #include "qgspointcloudproviderguimetadata.h"
32 #include "qgseptproviderguimetadata.h"
35 #ifdef HAVE_STATIC_PROVIDERS
36 #include "qgswmsprovidergui.h"
37 #include "qgspostgresprovidergui.h"
50 QString
const &providerKey )
52 QgsProviderGuiRegistry::GuiProviders::const_iterator i = metaData.find( providerKey );
53 if ( i != metaData.end() )
63 loadStaticProviders();
64 loadDynamicProviders( pluginPath );
67 void QgsProviderGuiRegistry::loadStaticProviders( )
74 mProviders[ ogr->
key() ] = ogr;
77 mProviders[ vt->
key() ] = vt;
81 mProviders[ ept->
key() ] = ept;
88 mProviders[ pointcloud->
key() ] = pointcloud;
91 #ifdef HAVE_STATIC_PROVIDERS
93 mProviders[ wms->
key() ] = wms;
96 mProviders[ postgres->
key() ] = postgres;
100 void QgsProviderGuiRegistry::loadDynamicProviders(
const QString &pluginPath )
102 #ifdef HAVE_STATIC_PROVIDERS
103 QgsDebugMsg( QStringLiteral(
"Forced only static GUI providers" ) );
108 QDir mLibraryDirectory( pluginPath );
109 mLibraryDirectory.setSorting( QDir::Name | QDir::IgnoreCase );
110 mLibraryDirectory.setFilter( QDir::Files | QDir::NoSymLinks );
112 #if defined(Q_OS_WIN) || defined(__CYGWIN__)
113 mLibraryDirectory.setNameFilters( QStringList(
"*.dll" ) );
114 #elif defined(ANDROID)
115 mLibraryDirectory.setNameFilters( QStringList(
"*provider.so" ) );
117 mLibraryDirectory.setNameFilters( QStringList( QStringLiteral(
"*.so" ) ) );
120 QgsDebugMsgLevel( QStringLiteral(
"Checking %1 for GUI provider plugins" ).arg( mLibraryDirectory.path() ), 2 );
122 if ( mLibraryDirectory.count() == 0 )
124 QgsDebugMsg( QStringLiteral(
"No dynamic QGIS GUI provider plugins found in:\n%1\n" ).arg( mLibraryDirectory.path() ) );
128 QString filePattern = getenv(
"QGIS_PROVIDER_FILE" );
130 if ( !filePattern.isEmpty() )
132 fileRegexp.setPattern( filePattern );
135 const auto constEntryInfoList = mLibraryDirectory.entryInfoList();
136 for (
const QFileInfo &fi : constEntryInfoList )
138 if ( !fileRegexp.isEmpty() )
140 if ( fileRegexp.indexIn( fi.fileName() ) == -1 )
142 QgsDebugMsg(
"provider " + fi.fileName() +
" skipped because doesn't match pattern " + filePattern );
147 QLibrary myLib( fi.filePath() );
150 QFunctionPointer func = myLib.resolve( QStringLiteral(
"providerGuiMetadataFactory" ).toLatin1().data() );
151 factory_function *
function =
reinterpret_cast< factory_function *
>(
cast_to_fptr( func ) );
160 const QString providerKey = meta->
key();
163 if ( findMetadata_( mProviders, providerKey ) )
166 mProviders[providerKey] = meta;
174 GuiProviders::const_iterator it = mProviders.begin();
175 while ( it != mProviders.end() )
185 GuiProviders::const_iterator it = mProviders.begin();
186 while ( it != mProviders.end() )
188 it->second->registerGui( parent );
198 return QList<QgsDataItemGuiProvider *>();
206 return QList<QgsSourceSelectProvider *> ();
214 return QList<QgsProjectStorageGuiProvider *>();
222 return QList<QgsSubsetStringEditorProvider *>();
230 return QList<QgsProviderSourceWidgetProvider *>();
235 QList<const QgsMapLayerConfigWidgetFactory *> res;
236 for ( GuiProviders::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
238 const QList<const QgsMapLayerConfigWidgetFactory *> providerFactories = ( *it ).second->mapLayerConfigWidgetFactories();
241 if ( !layer || factory->supportsLayer( layer ) )
251 for ( GuiProviders::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
253 lst.append( it->first );
260 return findMetadata_( mProviders, providerKey );
Base class for all map layer types.
virtual const QList< QgsDataItemGuiProvider * > dataItemGuiProviders(const QString &providerKey)
Returns all data item gui providers registered in provider with providerKey.
virtual QList< QgsSubsetStringEditorProvider * > subsetStringEditorProviders(const QString &providerKey)
Returns all subset string editor providers registered in provider with providerKey.
const QgsProviderGuiMetadata * providerMetadata(const QString &providerKey) const
Returns metadata of the provider or nullptr if not found.
virtual QList< QgsProjectStorageGuiProvider * > projectStorageGuiProviders(const QString &providerKey)
Returns all project storage gui providers registered in provider with providerKey.
virtual QList< const QgsMapLayerConfigWidgetFactory * > mapLayerConfigWidgetFactories(QgsMapLayer *layer=nullptr)
Returns all map layer config widget factories associated with the registered providers.
std::map< QString, QgsProviderGuiMetadata * > GuiProviders
Type for data provider metadata associative container.
QgsProviderGuiRegistry(const QString &pluginPath)
Creates registry and loads static provider plugins.
virtual ~QgsProviderGuiRegistry()
dtor
virtual QList< QgsSourceSelectProvider * > sourceSelectProviders(const QString &providerKey)
Returns all source select providers registered in provider with providerKey.
virtual QList< QgsProviderSourceWidgetProvider * > sourceWidgetProviders(const QString &providerKey)
Returns all source widget providers registered in provider with providerKey.
void registerGuis(QMainWindow *widget)
Called during GUI initialization - allows providers to do its internal initialization of GUI componen...
QStringList providerList() const
Returns list of available providers by their keys.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
#define QgsDebugMsgLevel(str, level)