25 #include "qgsgdalguiprovider.h"
26 #include "qgsogrguiprovider.h"
28 #include "qgspointcloudproviderguimetadata.h"
31 #include "qgseptproviderguimetadata.h"
34 #ifdef HAVE_STATIC_PROVIDERS
35 #include "qgswmsprovidergui.h"
36 #include "qgspostgresprovidergui.h"
49 QString
const &providerKey )
51 QgsProviderGuiRegistry::GuiProviders::const_iterator i = metaData.find( providerKey );
52 if ( i != metaData.end() )
62 loadStaticProviders();
63 loadDynamicProviders( pluginPath );
66 void QgsProviderGuiRegistry::loadStaticProviders( )
73 mProviders[ ogr->
key() ] = ogr;
76 mProviders[ vt->
key() ] = vt;
80 mProviders[ ept->
key() ] = ept;
87 mProviders[ pointcloud->
key() ] = pointcloud;
90 #ifdef HAVE_STATIC_PROVIDERS
92 mProviders[ wms->
key() ] = wms;
95 mProviders[ postgres->
key() ] = postgres;
99 void QgsProviderGuiRegistry::loadDynamicProviders(
const QString &pluginPath )
101 #ifdef HAVE_STATIC_PROVIDERS
102 QgsDebugMsg( QStringLiteral(
"Forced only static GUI providers" ) );
107 QDir mLibraryDirectory( pluginPath );
108 mLibraryDirectory.setSorting( QDir::Name | QDir::IgnoreCase );
109 mLibraryDirectory.setFilter( QDir::Files | QDir::NoSymLinks );
111 #if defined(Q_OS_WIN) || defined(__CYGWIN__)
112 mLibraryDirectory.setNameFilters( QStringList(
"*.dll" ) );
113 #elif defined(ANDROID)
114 mLibraryDirectory.setNameFilters( QStringList(
"*provider.so" ) );
116 mLibraryDirectory.setNameFilters( QStringList( QStringLiteral(
"*.so" ) ) );
119 QgsDebugMsgLevel( QStringLiteral(
"Checking %1 for GUI provider plugins" ).arg( mLibraryDirectory.path() ), 2 );
121 if ( mLibraryDirectory.count() == 0 )
123 QgsDebugMsg( QStringLiteral(
"No dynamic QGIS GUI provider plugins found in:\n%1\n" ).arg( mLibraryDirectory.path() ) );
127 QString filePattern = getenv(
"QGIS_PROVIDER_FILE" );
129 if ( !filePattern.isEmpty() )
131 fileRegexp.setPattern( filePattern );
134 const auto constEntryInfoList = mLibraryDirectory.entryInfoList();
135 for (
const QFileInfo &fi : constEntryInfoList )
137 if ( !fileRegexp.isEmpty() )
139 if ( fileRegexp.indexIn( fi.fileName() ) == -1 )
141 QgsDebugMsg(
"provider " + fi.fileName() +
" skipped because doesn't match pattern " + filePattern );
146 QLibrary myLib( fi.filePath() );
149 QFunctionPointer func = myLib.resolve( QStringLiteral(
"providerGuiMetadataFactory" ).toLatin1().data() );
150 factory_function *
function =
reinterpret_cast< factory_function *
>(
cast_to_fptr( func ) );
159 const QString providerKey = meta->
key();
162 if ( findMetadata_( mProviders, providerKey ) )
165 mProviders[providerKey] = meta;
173 GuiProviders::const_iterator it = mProviders.begin();
174 while ( it != mProviders.end() )
184 GuiProviders::const_iterator it = mProviders.begin();
185 while ( it != mProviders.end() )
187 it->second->registerGui( parent );
197 return QList<QgsDataItemGuiProvider *>();
205 return QList<QgsSourceSelectProvider *> ();
213 return QList<QgsProjectStorageGuiProvider *>();
221 return QList<QgsSubsetStringEditorProvider *>();
229 return QList<QgsProviderSourceWidgetProvider *>();
235 for ( GuiProviders::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
237 lst.append( it->first );
244 return findMetadata_( mProviders, providerKey );
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.
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)