25 #include "qgsgdalguiprovider.h" 26 #include "qgsogrguiprovider.h" 28 #ifdef HAVE_STATIC_PROVIDERS 29 #include "qgswmsprovidergui.h" 42 QString
const &providerKey )
44 QgsProviderGuiRegistry::GuiProviders::const_iterator i = metaData.find( providerKey );
45 if ( i != metaData.end() )
55 loadStaticProviders();
56 loadDynamicProviders( pluginPath );
59 void QgsProviderGuiRegistry::loadStaticProviders( )
63 mProviders[ gdal->
key() ] = gdal;
66 mProviders[ ogr->
key() ] = ogr;
68 #ifdef HAVE_STATIC_PROVIDERS 70 mProviders[ wms->
key() ] = wms;
74 void QgsProviderGuiRegistry::loadDynamicProviders(
const QString &pluginPath )
76 #ifdef HAVE_STATIC_PROVIDERS 77 QgsDebugMsg( QStringLiteral(
"Forced only static GUI providers" ) );
82 QDir mLibraryDirectory( pluginPath );
83 mLibraryDirectory.setSorting( QDir::Name | QDir::IgnoreCase );
84 mLibraryDirectory.setFilter( QDir::Files | QDir::NoSymLinks );
86 #if defined(Q_OS_WIN) || defined(__CYGWIN__) 87 mLibraryDirectory.setNameFilters( QStringList(
"*.dll" ) );
88 #elif defined(ANDROID) 89 mLibraryDirectory.setNameFilters( QStringList(
"*provider.so" ) );
91 mLibraryDirectory.setNameFilters( QStringList( QStringLiteral(
"*.so" ) ) );
94 QgsDebugMsg( QStringLiteral(
"Checking %1 for GUI provider plugins" ).arg( mLibraryDirectory.path() ) );
96 if ( mLibraryDirectory.count() == 0 )
98 QgsDebugMsg( QStringLiteral(
"No dynamic QGIS GUI provider plugins found in:\n%1\n" ).arg( mLibraryDirectory.path() ) );
102 QString filePattern = getenv(
"QGIS_PROVIDER_FILE" );
104 if ( !filePattern.isEmpty() )
106 fileRegexp.setPattern( filePattern );
109 const auto constEntryInfoList = mLibraryDirectory.entryInfoList();
110 for (
const QFileInfo &fi : constEntryInfoList )
112 if ( !fileRegexp.isEmpty() )
114 if ( fileRegexp.indexIn( fi.fileName() ) == -1 )
116 QgsDebugMsg(
"provider " + fi.fileName() +
" skipped because doesn't match pattern " + filePattern );
121 QLibrary myLib( fi.filePath() );
124 QFunctionPointer func = myLib.resolve( QStringLiteral(
"providerGuiMetadataFactory" ).toLatin1().data() );
125 factory_function *
function =
reinterpret_cast< factory_function *
>(
cast_to_fptr( func ) );
134 const QString providerKey = meta->
key();
137 if ( findMetadata_( mProviders, providerKey ) )
140 mProviders[providerKey] = meta;
148 GuiProviders::const_iterator it = mProviders.begin();
149 while ( it != mProviders.end() )
159 GuiProviders::const_iterator it = mProviders.begin();
160 while ( it != mProviders.end() )
162 it->second->registerGui( parent );
172 return QList<QgsDataItemGuiProvider *>();
180 return QList<QgsSourceSelectProvider *> ();
188 return QList<QgsProjectStorageGuiProvider *>();
194 for ( GuiProviders::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
196 lst.append( it->first );
203 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