23#include <QRegularExpression>
26#include "qgsgdalguiprovider.h"
27#include "qgsogrguiprovider.h"
29#include "qgspointcloudproviderguimetadata.h"
32#include "qgsmbtilesvectortileguiprovider.h"
33#include "qgsvtpkvectortileguiprovider.h"
36#include "qgseptproviderguimetadata.h"
40#include "qgscopcproviderguimetadata.h"
43#ifdef HAVE_STATIC_PROVIDERS
44#include "qgswmsprovidergui.h"
45#include "qgswcsprovidergui.h"
46#include "qgsdelimitedtextprovidergui.h"
47#include "qgsarcgisrestprovidergui.h"
49#include "qgsspatialiteprovidergui.h"
50#include "qgswfsprovidergui.h"
51#include "qgsvirtuallayerprovidergui.h"
54#include "qgspostgresprovidergui.h"
68 QString
const &providerKey )
70 const QgsProviderGuiRegistry::GuiProviders::const_iterator i = metaData.find( providerKey );
71 if ( i != metaData.end() )
81 loadStaticProviders();
82 loadDynamicProviders( pluginPath );
85void QgsProviderGuiRegistry::loadStaticProviders( )
92 mProviders[ ogr->
key() ] = ogr;
95 mProviders[ vt->
key() ] = vt;
98 mProviders[ mbtilesVectorTiles->
key() ] = mbtilesVectorTiles;
101 mProviders[ vtpkVectorTiles->
key() ] = vtpkVectorTiles;
105 mProviders[ ept->
key() ] = ept;
110 mProviders[ copc->
key() ] = copc;
117 mProviders[ pointcloud->
key() ] = pointcloud;
120#ifdef HAVE_STATIC_PROVIDERS
122 mProviders[ wms->
key() ] = wms;
124 mProviders[ wcs->
key() ] = wcs;
126 mProviders[ delimitedtext->
key() ] = delimitedtext;
128 mProviders[ arc->
key() ] = arc;
129#ifdef HAVE_SPATIALITE
131 mProviders[ spatialite->
key() ] = spatialite;
133 mProviders[ wfs->
key() ] = wfs;
135 mProviders[ virtuallayer->
key() ] = virtuallayer;
137#ifdef HAVE_POSTGRESQL
139 mProviders[ postgres->
key() ] = postgres;
144void QgsProviderGuiRegistry::loadDynamicProviders(
const QString &pluginPath )
146#ifdef HAVE_STATIC_PROVIDERS
147 Q_UNUSED( pluginPath )
148 QgsDebugMsgLevel( QStringLiteral(
"Forced only static GUI providers" ), 2 );
153 QDir mLibraryDirectory( pluginPath );
154 mLibraryDirectory.setSorting( QDir::Name | QDir::IgnoreCase );
155 mLibraryDirectory.setFilter( QDir::Files | QDir::NoSymLinks );
157#if defined(Q_OS_WIN) || defined(__CYGWIN__)
158 mLibraryDirectory.setNameFilters( QStringList(
"*.dll" ) );
159#elif defined(ANDROID)
160 mLibraryDirectory.setNameFilters( QStringList(
"*provider.so" ) );
162 mLibraryDirectory.setNameFilters( QStringList( QStringLiteral(
"*.so" ) ) );
165 QgsDebugMsgLevel( QStringLiteral(
"Checking %1 for GUI provider plugins" ).arg( mLibraryDirectory.path() ), 2 );
167 if ( mLibraryDirectory.count() == 0 )
169 QgsDebugError( QStringLiteral(
"No dynamic QGIS GUI provider plugins found in:\n%1\n" ).arg( mLibraryDirectory.path() ) );
173 const QString filePattern = getenv(
"QGIS_PROVIDER_FILE" );
174 QRegularExpression fileRegexp;
175 if ( !filePattern.isEmpty() )
177 fileRegexp.setPattern( filePattern );
180 const auto constEntryInfoList = mLibraryDirectory.entryInfoList();
181 for (
const QFileInfo &fi : constEntryInfoList )
183 if ( !fileRegexp.pattern().isEmpty() )
185 const QRegularExpressionMatch fileNameMatch = fileRegexp.match( fi.fileName() );
186 if ( !fileNameMatch.hasMatch() )
188 QgsDebugMsgLevel(
"provider " + fi.fileName() +
" skipped because doesn't match pattern " + filePattern, 2 );
193 QLibrary myLib( fi.filePath() );
196 QFunctionPointer func = myLib.resolve( QStringLiteral(
"providerGuiMetadataFactory" ).toLatin1().data() );
197 factory_function *function =
reinterpret_cast< factory_function *
>(
cast_to_fptr( func ) );
206 const QString providerKey = meta->
key();
209 if ( findMetadata_( mProviders, providerKey ) )
212 mProviders[providerKey] = meta;
220 GuiProviders::const_iterator it = mProviders.begin();
221 while ( it != mProviders.end() )
231 for (
auto it = mProviders.begin(); it != mProviders.end(); ++it )
233 it->second->registerGui( parent );
242 return QList<QgsDataItemGuiProvider *>();
250 return QList<QgsSourceSelectProvider *> ();
258 return QList<QgsProjectStorageGuiProvider *>();
266 return QList<QgsSubsetStringEditorProvider *>();
274 return QList<QgsProviderSourceWidgetProvider *>();
279 QList<const QgsMapLayerConfigWidgetFactory *> res;
280 for ( GuiProviders::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
282 const QList<const QgsMapLayerConfigWidgetFactory *> providerFactories = ( *it ).second->mapLayerConfigWidgetFactories();
285 if ( !layer || factory->supportsLayer( layer ) )
295 for ( GuiProviders::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
297 lst.append( it->first );
304 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)