23#include <QRegularExpression>
26#include "qgsgdalguiprovider.h"
27#include "qgsogrguiprovider.h"
29#include "qgspointcloudproviderguimetadata.h"
33#include "qgsmbtilesvectortileguiprovider.h"
34#include "qgsvtpkvectortileguiprovider.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 ;
124#ifdef HAVE_STATIC_PROVIDERS
126 mProviders[ wms->
key() ] = wms;
128 mProviders[ wcs->
key() ] = wcs;
130 mProviders[ delimitedtext->
key() ] = delimitedtext;
132 mProviders[ arc->
key() ] = arc;
133#ifdef HAVE_SPATIALITE
135 mProviders[ spatialite->
key() ] = spatialite;
137 mProviders[ wfs->
key() ] = wfs;
139 mProviders[ virtuallayer->
key() ] = virtuallayer;
141#ifdef HAVE_POSTGRESQL
143 mProviders[ postgres->
key() ] = postgres;
148void QgsProviderGuiRegistry::loadDynamicProviders(
const QString &pluginPath )
150#ifdef HAVE_STATIC_PROVIDERS
151 Q_UNUSED( pluginPath )
152 QgsDebugMsgLevel( QStringLiteral(
"Forced only static GUI providers" ), 2 );
157 QDir mLibraryDirectory( pluginPath );
158 mLibraryDirectory.setSorting( QDir::Name | QDir::IgnoreCase );
159 mLibraryDirectory.setFilter( QDir::Files | QDir::NoSymLinks );
161#if defined(Q_OS_WIN) || defined(__CYGWIN__)
162 mLibraryDirectory.setNameFilters( QStringList(
"*.dll" ) );
163#elif defined(ANDROID)
164 mLibraryDirectory.setNameFilters( QStringList(
"*provider.so" ) );
166 mLibraryDirectory.setNameFilters( QStringList( QStringLiteral(
"*.so" ) ) );
169 QgsDebugMsgLevel( QStringLiteral(
"Checking %1 for GUI provider plugins" ).arg( mLibraryDirectory.path() ), 2 );
171 if ( mLibraryDirectory.count() == 0 )
173 QgsDebugError( QStringLiteral(
"No dynamic QGIS GUI provider plugins found in:\n%1\n" ).arg( mLibraryDirectory.path() ) );
177 const QString filePattern = getenv(
"QGIS_PROVIDER_FILE" );
178 QRegularExpression fileRegexp;
179 if ( !filePattern.isEmpty() )
181 fileRegexp.setPattern( filePattern );
184 const auto constEntryInfoList = mLibraryDirectory.entryInfoList();
185 for (
const QFileInfo &fi : constEntryInfoList )
187 if ( !fileRegexp.pattern().isEmpty() )
189 const QRegularExpressionMatch fileNameMatch = fileRegexp.match( fi.fileName() );
190 if ( !fileNameMatch.hasMatch() )
192 QgsDebugMsgLevel(
"provider " + fi.fileName() +
" skipped because doesn't match pattern " + filePattern, 2 );
197 QLibrary myLib( fi.filePath() );
200 QFunctionPointer func = myLib.resolve( QStringLiteral(
"providerGuiMetadataFactory" ).toLatin1().data() );
201 factory_function *function =
reinterpret_cast< factory_function *
>(
cast_to_fptr( func ) );
210 const QString providerKey = meta->
key();
213 if ( findMetadata_( mProviders, providerKey ) )
216 mProviders[providerKey] = meta;
224 GuiProviders::const_iterator it = mProviders.begin();
225 while ( it != mProviders.end() )
235 for (
auto it = mProviders.begin(); it != mProviders.end(); ++it )
237 it->second->registerGui( parent );
246 return QList<QgsDataItemGuiProvider *>();
254 return QList<QgsSourceSelectProvider *> ();
262 return QList<QgsProjectStorageGuiProvider *>();
270 return QList<QgsSubsetStringEditorProvider *>();
278 return QList<QgsProviderSourceWidgetProvider *>();
283 QList<const QgsMapLayerConfigWidgetFactory *> res;
284 for ( GuiProviders::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
286 const QList<const QgsMapLayerConfigWidgetFactory *> providerFactories = ( *it ).second->mapLayerConfigWidgetFactories();
289 if ( !layer || factory->supportsLayer( layer ) )
299 for ( GuiProviders::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
301 lst.append( it->first );
308 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)
#define QgsDebugError(str)