25 #include "qgsgdalguiprovider.h" 26 #include "qgsogrguiprovider.h" 28 #ifdef HAVE_STATIC_PROVIDERS 29 #include "qgswmsprovidergui.h" 30 #include "qgspostgresprovidergui.h" 43 QString
const &providerKey )
45 QgsProviderGuiRegistry::GuiProviders::const_iterator i = metaData.find( providerKey );
46 if ( i != metaData.end() )
56 loadStaticProviders();
57 loadDynamicProviders( pluginPath );
60 void QgsProviderGuiRegistry::loadStaticProviders( )
64 mProviders[ gdal->
key() ] = gdal;
67 mProviders[ ogr->
key() ] = ogr;
69 #ifdef HAVE_STATIC_PROVIDERS 71 mProviders[ wms->
key() ] = wms;
74 mProviders[ postgres->
key() ] = postgres;
78 void QgsProviderGuiRegistry::loadDynamicProviders(
const QString &pluginPath )
80 #ifdef HAVE_STATIC_PROVIDERS 81 QgsDebugMsg( QStringLiteral(
"Forced only static GUI providers" ) );
86 QDir mLibraryDirectory( pluginPath );
87 mLibraryDirectory.setSorting( QDir::Name | QDir::IgnoreCase );
88 mLibraryDirectory.setFilter( QDir::Files | QDir::NoSymLinks );
90 #if defined(Q_OS_WIN) || defined(__CYGWIN__) 91 mLibraryDirectory.setNameFilters( QStringList(
"*.dll" ) );
92 #elif defined(ANDROID) 93 mLibraryDirectory.setNameFilters( QStringList(
"*provider.so" ) );
95 mLibraryDirectory.setNameFilters( QStringList( QStringLiteral(
"*.so" ) ) );
98 QgsDebugMsg( QStringLiteral(
"Checking %1 for GUI provider plugins" ).arg( mLibraryDirectory.path() ) );
100 if ( mLibraryDirectory.count() == 0 )
102 QgsDebugMsg( QStringLiteral(
"No dynamic QGIS GUI provider plugins found in:\n%1\n" ).arg( mLibraryDirectory.path() ) );
106 QString filePattern = getenv(
"QGIS_PROVIDER_FILE" );
108 if ( !filePattern.isEmpty() )
110 fileRegexp.setPattern( filePattern );
113 const auto constEntryInfoList = mLibraryDirectory.entryInfoList();
114 for (
const QFileInfo &fi : constEntryInfoList )
116 if ( !fileRegexp.isEmpty() )
118 if ( fileRegexp.indexIn( fi.fileName() ) == -1 )
120 QgsDebugMsg(
"provider " + fi.fileName() +
" skipped because doesn't match pattern " + filePattern );
125 QLibrary myLib( fi.filePath() );
128 QFunctionPointer func = myLib.resolve( QStringLiteral(
"providerGuiMetadataFactory" ).toLatin1().data() );
129 factory_function *
function =
reinterpret_cast< factory_function *
>(
cast_to_fptr( func ) );
138 const QString providerKey = meta->
key();
141 if ( findMetadata_( mProviders, providerKey ) )
144 mProviders[providerKey] = meta;
152 GuiProviders::const_iterator it = mProviders.begin();
153 while ( it != mProviders.end() )
163 GuiProviders::const_iterator it = mProviders.begin();
164 while ( it != mProviders.end() )
166 it->second->registerGui( parent );
176 return QList<QgsDataItemGuiProvider *>();
184 return QList<QgsSourceSelectProvider *> ();
192 return QList<QgsProjectStorageGuiProvider *>();
198 for ( GuiProviders::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
200 lst.append( it->first );
207 return findMetadata_( mProviders, providerKey );
std::map< QString, QgsProviderGuiMetadata * > GuiProviders
Type for data provider metadata associative container.
virtual QList< QgsProjectStorageGuiProvider * > projectStorageGuiProviders(const QString &providerKey)
Returns all project storage gui providers registered in provider with providerKey.
virtual const QList< QgsDataItemGuiProvider * > dataItemGuiProviders(const QString &providerKey)
Returns all data item gui providers registered in provider with providerKey.
QgsProviderGuiRegistry(const QString &pluginPath)
Creates registry and loads static provider plugins.
const QgsProviderGuiMetadata * providerMetadata(const QString &providerKey) const
Returns metadata of the provider or nullptr if not found.
virtual QList< QgsSourceSelectProvider * > sourceSelectProviders(const QString &providerKey)
Returns all source select providers registered in provider with providerKey.
QStringList providerList() const
Returns list of available providers by their keys.
void registerGuis(QMainWindow *widget)
Called during GUI initialization - allows providers to do its internal initialization of GUI componen...
virtual ~QgsProviderGuiRegistry()
dtor