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"
46#include "qgsspatialiteprovidergui.h"
47#include "qgswfsprovidergui.h"
48#include "qgsvirtuallayerprovidergui.h"
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 );
82void 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;
135void 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 );
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)