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 QString
const &providerKey )
71 const QgsProviderGuiRegistry::GuiProviders::const_iterator i = metaData.find( providerKey );
72 if ( i != metaData.end() )
82 loadStaticProviders();
83 loadDynamicProviders( pluginPath );
86void QgsProviderGuiRegistry::loadStaticProviders( )
93 mProviders[ ogr->
key() ] = ogr;
96 mProviders[ vt->
key() ] = vt;
99 mProviders[ mbtilesVectorTiles->
key() ] = mbtilesVectorTiles;
102 mProviders[ vtpkVectorTiles->
key() ] = vtpkVectorTiles;
106 mProviders[ ept->
key() ] = ept;
111 mProviders[ copc->
key() ] = copc;
118 mProviders[ pointcloud->
key() ] = pointcloud;
122 mProviders[ tiledScene->
key() ] = tiledScene;
125 mProviders[ sensorThings->
key() ] = sensorThings;
127#ifdef HAVE_STATIC_PROVIDERS
129 mProviders[ wms->
key() ] = wms;
131 mProviders[ wcs->
key() ] = wcs;
133 mProviders[ delimitedtext->
key() ] = delimitedtext;
135 mProviders[ arc->
key() ] = arc;
136#ifdef HAVE_SPATIALITE
138 mProviders[ spatialite->
key() ] = spatialite;
140 mProviders[ wfs->
key() ] = wfs;
142 mProviders[ virtuallayer->
key() ] = virtuallayer;
144#ifdef HAVE_POSTGRESQL
146 mProviders[ postgres->
key() ] = postgres;
151void QgsProviderGuiRegistry::loadDynamicProviders(
const QString &pluginPath )
153#ifdef HAVE_STATIC_PROVIDERS
154 Q_UNUSED( pluginPath )
155 QgsDebugMsgLevel( QStringLiteral(
"Forced only static GUI providers" ), 2 );
160 QDir mLibraryDirectory( pluginPath );
161 mLibraryDirectory.setSorting( QDir::Name | QDir::IgnoreCase );
162 mLibraryDirectory.setFilter( QDir::Files | QDir::NoSymLinks );
164#if defined(Q_OS_WIN) || defined(__CYGWIN__)
165 mLibraryDirectory.setNameFilters( QStringList(
"*.dll" ) );
166#elif defined(ANDROID)
167 mLibraryDirectory.setNameFilters( QStringList(
"*provider.so" ) );
169 mLibraryDirectory.setNameFilters( QStringList( QStringLiteral(
"*.so" ) ) );
172 QgsDebugMsgLevel( QStringLiteral(
"Checking %1 for GUI provider plugins" ).arg( mLibraryDirectory.path() ), 2 );
174 if ( mLibraryDirectory.count() == 0 )
176 QgsDebugError( QStringLiteral(
"No dynamic QGIS GUI provider plugins found in:\n%1\n" ).arg( mLibraryDirectory.path() ) );
180 const QString filePattern = getenv(
"QGIS_PROVIDER_FILE" );
181 QRegularExpression fileRegexp;
182 if ( !filePattern.isEmpty() )
184 fileRegexp.setPattern( filePattern );
187 const auto constEntryInfoList = mLibraryDirectory.entryInfoList();
188 for (
const QFileInfo &fi : constEntryInfoList )
190 if ( !fileRegexp.pattern().isEmpty() )
192 const QRegularExpressionMatch fileNameMatch = fileRegexp.match( fi.fileName() );
193 if ( !fileNameMatch.hasMatch() )
195 QgsDebugMsgLevel(
"provider " + fi.fileName() +
" skipped because doesn't match pattern " + filePattern, 2 );
200 QLibrary myLib( fi.filePath() );
203 QFunctionPointer func = myLib.resolve( QStringLiteral(
"providerGuiMetadataFactory" ).toLatin1().data() );
204 factory_function *function =
reinterpret_cast< factory_function *
>(
cast_to_fptr( func ) );
213 const QString providerKey = meta->
key();
216 if ( findMetadata_( mProviders, providerKey ) )
219 mProviders[providerKey] = meta;
227 GuiProviders::const_iterator it = mProviders.begin();
228 while ( it != mProviders.end() )
238 for (
auto it = mProviders.begin(); it != mProviders.end(); ++it )
240 it->second->registerGui( parent );
249 return QList<QgsDataItemGuiProvider *>();
257 return QList<QgsSourceSelectProvider *> ();
265 return QList<QgsProjectStorageGuiProvider *>();
273 return QList<QgsSubsetStringEditorProvider *>();
281 return QList<QgsProviderSourceWidgetProvider *>();
286 QList<const QgsMapLayerConfigWidgetFactory *> res;
287 for ( GuiProviders::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
289 const QList<const QgsMapLayerConfigWidgetFactory *> providerFactories = ( *it ).second->mapLayerConfigWidgetFactories();
292 if ( !layer || factory->supportsLayer( layer ) )
302 for ( GuiProviders::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
304 lst.append( it->first );
311 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)