23#include <QRegularExpression>
26#include "qgsgdalguiprovider.h"
27#include "qgsogrguiprovider.h"
29#include "qgspointcloudproviderguimetadata.h"
33#include "qgsmbtilesvectortileguiprovider.h"
34#include "qgsvtpkvectortileguiprovider.h"
35#include "qgssensorthingsguiprovider.h"
37#include "qgseptproviderguimetadata.h"
41#include "qgscopcproviderguimetadata.h"
44#ifdef HAVE_STATIC_PROVIDERS
45#include "qgswmsprovidergui.h"
46#include "qgswcsprovidergui.h"
47#include "qgsdelimitedtextprovidergui.h"
48#include "qgsarcgisrestprovidergui.h"
50#include "qgsspatialiteprovidergui.h"
51#include "qgswfsprovidergui.h"
52#include "qgsvirtuallayerprovidergui.h"
55#include "qgspostgresprovidergui.h"
69 const QgsProviderGuiRegistry::GuiProviders::const_iterator i = metaData.find( providerKey );
70 if ( i != metaData.end() )
80 loadStaticProviders();
81 loadDynamicProviders( pluginPath );
84void QgsProviderGuiRegistry::loadStaticProviders()
91 mProviders[ogr->
key()] = ogr;
94 mProviders[vt->
key()] = vt;
97 mProviders[mbtilesVectorTiles->
key()] = mbtilesVectorTiles;
100 mProviders[vtpkVectorTiles->
key()] = vtpkVectorTiles;
104 mProviders[ept->
key()] = ept;
109 mProviders[copc->
key()] = copc;
116 mProviders[pointcloud->
key()] = pointcloud;
120 mProviders[tiledScene->
key()] = tiledScene;
123 mProviders[sensorThings->
key()] = sensorThings;
125#ifdef HAVE_STATIC_PROVIDERS
127 mProviders[wms->
key()] = wms;
129 mProviders[wcs->
key()] = wcs;
131 mProviders[delimitedtext->
key()] = delimitedtext;
133 mProviders[arc->
key()] = arc;
134#ifdef HAVE_SPATIALITE
136 mProviders[spatialite->
key()] = spatialite;
138 mProviders[wfs->
key()] = wfs;
140 mProviders[virtuallayer->
key()] = virtuallayer;
142#ifdef HAVE_POSTGRESQL
144 mProviders[postgres->
key()] = postgres;
149void QgsProviderGuiRegistry::loadDynamicProviders(
const QString &pluginPath )
151#ifdef HAVE_STATIC_PROVIDERS
152 Q_UNUSED( pluginPath )
153 QgsDebugMsgLevel( QStringLiteral(
"Forced only static GUI providers" ), 2 );
158 QDir mLibraryDirectory( pluginPath );
159 mLibraryDirectory.setSorting( QDir::Name | QDir::IgnoreCase );
160 mLibraryDirectory.setFilter( QDir::Files | QDir::NoSymLinks );
162#if defined( Q_OS_WIN ) || defined( __CYGWIN__ )
163 mLibraryDirectory.setNameFilters( QStringList(
"*.dll" ) );
164#elif defined( ANDROID )
165 mLibraryDirectory.setNameFilters( QStringList(
"*provider.so" ) );
167 mLibraryDirectory.setNameFilters( QStringList( QStringLiteral(
"*.so" ) ) );
170 QgsDebugMsgLevel( QStringLiteral(
"Checking %1 for GUI provider plugins" ).arg( mLibraryDirectory.path() ), 2 );
172 if ( mLibraryDirectory.count() == 0 )
174 QgsDebugError( QStringLiteral(
"No dynamic QGIS GUI provider plugins found in:\n%1\n" ).arg( mLibraryDirectory.path() ) );
178 const QString filePattern = getenv(
"QGIS_PROVIDER_FILE" );
179 QRegularExpression fileRegexp;
180 if ( !filePattern.isEmpty() )
182 fileRegexp.setPattern( filePattern );
185 const auto constEntryInfoList = mLibraryDirectory.entryInfoList();
186 for (
const QFileInfo &fi : constEntryInfoList )
188 if ( !fileRegexp.pattern().isEmpty() )
190 const QRegularExpressionMatch fileNameMatch = fileRegexp.match( fi.fileName() );
191 if ( !fileNameMatch.hasMatch() )
193 QgsDebugMsgLevel(
"provider " + fi.fileName() +
" skipped because doesn't match pattern " + filePattern, 2 );
198 QLibrary myLib( fi.filePath() );
201 QFunctionPointer func = myLib.resolve( QStringLiteral(
"providerGuiMetadataFactory" ).toLatin1().data() );
202 factory_function *function =
reinterpret_cast<factory_function *
>(
cast_to_fptr( func ) );
211 const QString providerKey = meta->
key();
214 if ( findMetadata_( mProviders, providerKey ) )
217 mProviders[providerKey] = meta;
225 GuiProviders::const_iterator it = mProviders.begin();
226 while ( it != mProviders.end() )
236 for (
auto it = mProviders.begin(); it != mProviders.end(); ++it )
238 it->second->registerGui( parent );
247 return QList<QgsDataItemGuiProvider *>();
255 return QList<QgsSourceSelectProvider *>();
263 return QList<QgsProjectStorageGuiProvider *>();
271 return QList<QgsSubsetStringEditorProvider *>();
279 return QList<QgsProviderSourceWidgetProvider *>();
284 QList<const QgsMapLayerConfigWidgetFactory *> res;
285 for ( GuiProviders::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
287 const QList<const QgsMapLayerConfigWidgetFactory *> providerFactories = ( *it ).second->mapLayerConfigWidgetFactories();
290 if ( !layer || factory->supportsLayer( layer ) )
300 for ( GuiProviders::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
302 lst.append( it->first );
309 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()
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)
#define QgsDebugError(str)