23 #include <QRegularExpression>
26 #include "qgsgdalguiprovider.h"
27 #include "qgsogrguiprovider.h"
29 #include "qgspointcloudproviderguimetadata.h"
33 #include "qgseptproviderguimetadata.h"
37 #include "qgscopcproviderguimetadata.h"
40 #ifdef HAVE_STATIC_PROVIDERS
41 #include "qgswmsprovidergui.h"
42 #include "qgswcsprovidergui.h"
43 #include "qgsdelimitedtextprovidergui.h"
44 #include "qgsarcgisrestprovidergui.h"
45 #ifdef HAVE_SPATIALITE
46 #include "qgsspatialiteprovidergui.h"
47 #include "qgswfsprovidergui.h"
48 #include "qgsvirtuallayerprovidergui.h"
50 #ifdef HAVE_POSTGRESQL
51 #include "qgspostgresprovidergui.h"
65 QString
const &providerKey )
67 const QgsProviderGuiRegistry::GuiProviders::const_iterator i = metaData.find( providerKey );
68 if ( i != metaData.end() )
78 loadStaticProviders();
79 loadDynamicProviders( pluginPath );
82 void QgsProviderGuiRegistry::loadStaticProviders( )
89 mProviders[ ogr->
key() ] = ogr;
92 mProviders[ vt->
key() ] = vt;
96 mProviders[ ept->
key() ] = ept;
101 mProviders[ copc->
key() ] = copc;
108 mProviders[ pointcloud->
key() ] = pointcloud;
111 #ifdef HAVE_STATIC_PROVIDERS
113 mProviders[ wms->
key() ] = wms;
115 mProviders[ wcs->
key() ] = wcs;
117 mProviders[ delimitedtext->
key() ] = delimitedtext;
119 mProviders[ arc->
key() ] = arc;
120 #ifdef HAVE_SPATIALITE
122 mProviders[ spatialite->
key() ] = spatialite;
124 mProviders[ wfs->
key() ] = wfs;
126 mProviders[ virtuallayer->
key() ] = virtuallayer;
128 #ifdef HAVE_POSTGRESQL
130 mProviders[ postgres->
key() ] = postgres;
135 void QgsProviderGuiRegistry::loadDynamicProviders(
const QString &pluginPath )
137 #ifdef HAVE_STATIC_PROVIDERS
138 Q_UNUSED( pluginPath )
139 QgsDebugMsg( QStringLiteral(
"Forced only static GUI providers" ) );
144 QDir mLibraryDirectory( pluginPath );
145 mLibraryDirectory.setSorting( QDir::Name | QDir::IgnoreCase );
146 mLibraryDirectory.setFilter( QDir::Files | QDir::NoSymLinks );
148 #if defined(Q_OS_WIN) || defined(__CYGWIN__)
149 mLibraryDirectory.setNameFilters( QStringList(
"*.dll" ) );
150 #elif defined(ANDROID)
151 mLibraryDirectory.setNameFilters( QStringList(
"*provider.so" ) );
153 mLibraryDirectory.setNameFilters( QStringList( QStringLiteral(
"*.so" ) ) );
156 QgsDebugMsgLevel( QStringLiteral(
"Checking %1 for GUI provider plugins" ).arg( mLibraryDirectory.path() ), 2 );
158 if ( mLibraryDirectory.count() == 0 )
160 QgsDebugMsg( QStringLiteral(
"No dynamic QGIS GUI provider plugins found in:\n%1\n" ).arg( mLibraryDirectory.path() ) );
164 const QString filePattern = getenv(
"QGIS_PROVIDER_FILE" );
165 QRegularExpression fileRegexp;
166 if ( !filePattern.isEmpty() )
168 fileRegexp.setPattern( filePattern );
171 const auto constEntryInfoList = mLibraryDirectory.entryInfoList();
172 for (
const QFileInfo &fi : constEntryInfoList )
174 if ( !fileRegexp.pattern().isEmpty() )
176 const QRegularExpressionMatch fileNameMatch = fileRegexp.match( fi.fileName() );
177 if ( !fileNameMatch.hasMatch() )
179 QgsDebugMsg(
"provider " + fi.fileName() +
" skipped because doesn't match pattern " + filePattern );
184 QLibrary myLib( fi.filePath() );
187 QFunctionPointer func = myLib.resolve( QStringLiteral(
"providerGuiMetadataFactory" ).toLatin1().data() );
188 factory_function *
function =
reinterpret_cast< factory_function *
>(
cast_to_fptr( func ) );
197 const QString providerKey = meta->
key();
200 if ( findMetadata_( mProviders, providerKey ) )
203 mProviders[providerKey] = meta;
211 GuiProviders::const_iterator it = mProviders.begin();
212 while ( it != mProviders.end() )
222 GuiProviders::const_iterator it = mProviders.begin();
223 while ( it != mProviders.end() )
225 it->second->registerGui( parent );
235 return QList<QgsDataItemGuiProvider *>();
243 return QList<QgsSourceSelectProvider *> ();
251 return QList<QgsProjectStorageGuiProvider *>();
259 return QList<QgsSubsetStringEditorProvider *>();
267 return QList<QgsProviderSourceWidgetProvider *>();
272 QList<const QgsMapLayerConfigWidgetFactory *> res;
273 for ( GuiProviders::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
275 const QList<const QgsMapLayerConfigWidgetFactory *> providerFactories = ( *it ).second->mapLayerConfigWidgetFactories();
278 if ( !layer || factory->supportsLayer( layer ) )
288 for ( GuiProviders::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
290 lst.append( it->first );
297 return findMetadata_( mProviders, providerKey );