23 #include <QRegularExpression>
26 #include "qgsgdalguiprovider.h"
27 #include "qgsogrguiprovider.h"
29 #include "qgspointcloudproviderguimetadata.h"
33 #include "qgseptproviderguimetadata.h"
36 #ifdef HAVE_STATIC_PROVIDERS
37 #include "qgswmsprovidergui.h"
38 #include "qgswcsprovidergui.h"
39 #include "qgsdelimitedtextprovidergui.h"
40 #include "qgsarcgisrestprovidergui.h"
41 #ifdef HAVE_SPATIALITE
42 #include "qgsspatialiteprovidergui.h"
43 #include "qgswfsprovidergui.h"
44 #include "qgsvirtuallayerprovidergui.h"
46 #ifdef HAVE_POSTGRESQL
47 #include "qgspostgresprovidergui.h"
61 QString
const &providerKey )
63 const QgsProviderGuiRegistry::GuiProviders::const_iterator i = metaData.find( providerKey );
64 if ( i != metaData.end() )
74 loadStaticProviders();
75 loadDynamicProviders( pluginPath );
78 void QgsProviderGuiRegistry::loadStaticProviders( )
85 mProviders[ ogr->
key() ] = ogr;
88 mProviders[ vt->
key() ] = vt;
92 mProviders[ ept->
key() ] = ept;
99 mProviders[ pointcloud->
key() ] = pointcloud;
102 #ifdef HAVE_STATIC_PROVIDERS
104 mProviders[ wms->
key() ] = wms;
106 mProviders[ wcs->
key() ] = wcs;
108 mProviders[ delimitedtext->
key() ] = delimitedtext;
110 mProviders[ arc->
key() ] = arc;
111 #ifdef HAVE_SPATIALITE
113 mProviders[ spatialite->
key() ] = spatialite;
115 mProviders[ wfs->
key() ] = wfs;
117 mProviders[ virtuallayer->
key() ] = virtuallayer;
119 #ifdef HAVE_POSTGRESQL
121 mProviders[ postgres->
key() ] = postgres;
126 void QgsProviderGuiRegistry::loadDynamicProviders(
const QString &pluginPath )
128 #ifdef HAVE_STATIC_PROVIDERS
129 Q_UNUSED( pluginPath )
130 QgsDebugMsg( QStringLiteral(
"Forced only static GUI providers" ) );
135 QDir mLibraryDirectory( pluginPath );
136 mLibraryDirectory.setSorting( QDir::Name | QDir::IgnoreCase );
137 mLibraryDirectory.setFilter( QDir::Files | QDir::NoSymLinks );
139 #if defined(Q_OS_WIN) || defined(__CYGWIN__)
140 mLibraryDirectory.setNameFilters( QStringList(
"*.dll" ) );
141 #elif defined(ANDROID)
142 mLibraryDirectory.setNameFilters( QStringList(
"*provider.so" ) );
144 mLibraryDirectory.setNameFilters( QStringList( QStringLiteral(
"*.so" ) ) );
147 QgsDebugMsgLevel( QStringLiteral(
"Checking %1 for GUI provider plugins" ).arg( mLibraryDirectory.path() ), 2 );
149 if ( mLibraryDirectory.count() == 0 )
151 QgsDebugMsg( QStringLiteral(
"No dynamic QGIS GUI provider plugins found in:\n%1\n" ).arg( mLibraryDirectory.path() ) );
155 const QString filePattern = getenv(
"QGIS_PROVIDER_FILE" );
156 QRegularExpression fileRegexp;
157 if ( !filePattern.isEmpty() )
159 fileRegexp.setPattern( filePattern );
162 const auto constEntryInfoList = mLibraryDirectory.entryInfoList();
163 for (
const QFileInfo &fi : constEntryInfoList )
165 if ( !fileRegexp.pattern().isEmpty() )
167 const QRegularExpressionMatch fileNameMatch = fileRegexp.match( fi.fileName() );
168 if ( !fileNameMatch.hasMatch() )
170 QgsDebugMsg(
"provider " + fi.fileName() +
" skipped because doesn't match pattern " + filePattern );
175 QLibrary myLib( fi.filePath() );
178 QFunctionPointer func = myLib.resolve( QStringLiteral(
"providerGuiMetadataFactory" ).toLatin1().data() );
179 factory_function *
function =
reinterpret_cast< factory_function *
>(
cast_to_fptr( func ) );
188 const QString providerKey = meta->
key();
191 if ( findMetadata_( mProviders, providerKey ) )
194 mProviders[providerKey] = meta;
202 GuiProviders::const_iterator it = mProviders.begin();
203 while ( it != mProviders.end() )
213 GuiProviders::const_iterator it = mProviders.begin();
214 while ( it != mProviders.end() )
216 it->second->registerGui( parent );
226 return QList<QgsDataItemGuiProvider *>();
234 return QList<QgsSourceSelectProvider *> ();
242 return QList<QgsProjectStorageGuiProvider *>();
250 return QList<QgsSubsetStringEditorProvider *>();
258 return QList<QgsProviderSourceWidgetProvider *>();
263 QList<const QgsMapLayerConfigWidgetFactory *> res;
264 for ( GuiProviders::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
266 const QList<const QgsMapLayerConfigWidgetFactory *> providerFactories = ( *it ).second->mapLayerConfigWidgetFactories();
269 if ( !layer || factory->supportsLayer( layer ) )
279 for ( GuiProviders::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
281 lst.append( it->first );
288 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)