25 #include "qgsgdalguiprovider.h"
26 #include "qgsogrguiprovider.h"
29 #ifdef HAVE_STATIC_PROVIDERS
30 #include "qgswmsprovidergui.h"
31 #include "qgspostgresprovidergui.h"
44 QString
const &providerKey )
46 QgsProviderGuiRegistry::GuiProviders::const_iterator i = metaData.find( providerKey );
47 if ( i != metaData.end() )
57 loadStaticProviders();
58 loadDynamicProviders( pluginPath );
61 void QgsProviderGuiRegistry::loadStaticProviders( )
68 mProviders[ ogr->
key() ] = ogr;
71 mProviders[ vt->
key() ] = vt;
73 #ifdef HAVE_STATIC_PROVIDERS
75 mProviders[ wms->
key() ] = wms;
78 mProviders[ postgres->
key() ] = postgres;
82 void QgsProviderGuiRegistry::loadDynamicProviders(
const QString &pluginPath )
84 #ifdef HAVE_STATIC_PROVIDERS
85 QgsDebugMsg( QStringLiteral(
"Forced only static GUI providers" ) );
90 QDir mLibraryDirectory( pluginPath );
91 mLibraryDirectory.setSorting( QDir::Name | QDir::IgnoreCase );
92 mLibraryDirectory.setFilter( QDir::Files | QDir::NoSymLinks );
94 #if defined(Q_OS_WIN) || defined(__CYGWIN__)
95 mLibraryDirectory.setNameFilters( QStringList(
"*.dll" ) );
96 #elif defined(ANDROID)
97 mLibraryDirectory.setNameFilters( QStringList(
"*provider.so" ) );
99 mLibraryDirectory.setNameFilters( QStringList( QStringLiteral(
"*.so" ) ) );
102 QgsDebugMsgLevel( QStringLiteral(
"Checking %1 for GUI provider plugins" ).arg( mLibraryDirectory.path() ), 2 );
104 if ( mLibraryDirectory.count() == 0 )
106 QgsDebugMsg( QStringLiteral(
"No dynamic QGIS GUI provider plugins found in:\n%1\n" ).arg( mLibraryDirectory.path() ) );
110 QString filePattern = getenv(
"QGIS_PROVIDER_FILE" );
112 if ( !filePattern.isEmpty() )
114 fileRegexp.setPattern( filePattern );
117 const auto constEntryInfoList = mLibraryDirectory.entryInfoList();
118 for (
const QFileInfo &fi : constEntryInfoList )
120 if ( !fileRegexp.isEmpty() )
122 if ( fileRegexp.indexIn( fi.fileName() ) == -1 )
124 QgsDebugMsg(
"provider " + fi.fileName() +
" skipped because doesn't match pattern " + filePattern );
129 QLibrary myLib( fi.filePath() );
132 QFunctionPointer func = myLib.resolve( QStringLiteral(
"providerGuiMetadataFactory" ).toLatin1().data() );
133 factory_function *
function =
reinterpret_cast< factory_function *
>(
cast_to_fptr( func ) );
142 const QString providerKey = meta->
key();
145 if ( findMetadata_( mProviders, providerKey ) )
148 mProviders[providerKey] = meta;
156 GuiProviders::const_iterator it = mProviders.begin();
157 while ( it != mProviders.end() )
167 GuiProviders::const_iterator it = mProviders.begin();
168 while ( it != mProviders.end() )
170 it->second->registerGui( parent );
180 return QList<QgsDataItemGuiProvider *>();
188 return QList<QgsSourceSelectProvider *> ();
196 return QList<QgsProjectStorageGuiProvider *>();
202 for ( GuiProviders::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
204 lst.append( it->first );
211 return findMetadata_( mProviders, providerKey );