QGIS API Documentation  3.8.0-Zanzibar (11aff65)
qgsproviderregistry.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsproviderregistry.cpp - Singleton class for
3  registering data providers.
4  -------------------
5  begin : Sat Jan 10 2004
6  copyright : (C) 2004 by Gary E.Sherman
7  email : sherman at mrcc.com
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 #include "qgsproviderregistry.h"
20 
21 #include <QString>
22 #include <QDir>
23 #include <QLibrary>
24 
25 #include "qgis.h"
26 #include "qgsdataprovider.h"
27 #include "qgslogger.h"
28 #include "qgsmessageoutput.h"
29 #include "qgsmessagelog.h"
30 #include "qgsprovidermetadata.h"
31 #include "qgsvectorlayer.h"
32 #include "qgsproject.h"
35 
36 // typedefs for provider plugin functions of interest
37 typedef QString providerkey_t();
38 typedef QString description_t();
39 typedef bool isprovider_t();
40 typedef QString fileVectorFilters_t();
41 typedef void fileMeshFilters_t( QString &fileMeshFiltersString, QString &fileMeshDatasetFiltersString );
42 typedef void buildsupportedrasterfilefilter_t( QString &fileFiltersString );
43 typedef QString databaseDrivers_t();
44 typedef QString directoryDrivers_t();
45 typedef QString protocolDrivers_t();
46 typedef void initProviderFunction_t();
47 typedef QVariantMap decodeUri_t( const QString &uri );
48 
49 //typedef int dataCapabilities_t();
50 //typedef QgsDataItem * dataItem_t(QString);
51 
52 static QgsProviderRegistry *sInstance = nullptr;
53 
55 {
56  if ( !sInstance )
57  {
58  static QMutex sMutex;
59  QMutexLocker locker( &sMutex );
60  if ( !sInstance )
61  {
62  sInstance = new QgsProviderRegistry( pluginPath );
63  }
64  }
65  return sInstance;
66 } // QgsProviderRegistry::instance
67 
68 
69 
70 QgsProviderRegistry::QgsProviderRegistry( const QString &pluginPath )
71 {
72  // At startup, examine the libs in the qgis/lib dir and store those that
73  // are a provider shared lib
74  // check all libs in the current plugin directory and get name and descriptions
75  //TODO figure out how to register and identify data source plugin for a specific
76  //TODO layer type
77 #if 0
78  char **argv = qApp->argv();
79  QString appDir = argv[0];
80  int bin = appDir.findRev( "/bin", -1, false );
81  QString baseDir = appDir.left( bin );
82  QString mLibraryDirectory = baseDir + "/lib";
83 #endif
84  mLibraryDirectory = pluginPath;
85  init();
86 }
87 
88 
89 void QgsProviderRegistry::init()
90 {
91  // add standard providers
92  mProviders[ QgsMemoryProvider::providerKey() ] = new QgsProviderMetadata( QgsMemoryProvider::providerKey(), QgsMemoryProvider::providerDescription(), &QgsMemoryProvider::createProvider );
93  mProviders[ QgsMeshMemoryDataProvider::providerKey() ] = new QgsProviderMetadata( QgsMeshMemoryDataProvider::providerKey(), QgsMeshMemoryDataProvider::providerDescription(), &QgsMeshMemoryDataProvider::createProvider );
94 
95  mLibraryDirectory.setSorting( QDir::Name | QDir::IgnoreCase );
96  mLibraryDirectory.setFilter( QDir::Files | QDir::NoSymLinks );
97 
98 #if defined(Q_OS_WIN) || defined(__CYGWIN__)
99  mLibraryDirectory.setNameFilters( QStringList( "*.dll" ) );
100 #elif defined(ANDROID)
101  mLibraryDirectory.setNameFilters( QStringList( "*provider.so" ) );
102 #else
103  mLibraryDirectory.setNameFilters( QStringList( QStringLiteral( "*.so" ) ) );
104 #endif
105 
106  QgsDebugMsg( QStringLiteral( "Checking %1 for provider plugins" ).arg( mLibraryDirectory.path() ) );
107 
108  if ( mLibraryDirectory.count() == 0 )
109  {
110  QString msg = QObject::tr( "No QGIS data provider plugins found in:\n%1\n" ).arg( mLibraryDirectory.path() );
111  msg += QObject::tr( "No vector layers can be loaded. Check your QGIS installation" );
112 
114  output->setTitle( QObject::tr( "No Data Providers" ) );
116  output->showMessage();
117  return;
118  }
119 
120  // provider file regex pattern, only files matching the pattern are loaded if the variable is defined
121  QString filePattern = getenv( "QGIS_PROVIDER_FILE" );
122  QRegExp fileRegexp;
123  if ( !filePattern.isEmpty() )
124  {
125  fileRegexp.setPattern( filePattern );
126  }
127 
128  const auto constEntryInfoList = mLibraryDirectory.entryInfoList();
129  for ( const QFileInfo &fi : constEntryInfoList )
130  {
131  if ( !fileRegexp.isEmpty() )
132  {
133  if ( fileRegexp.indexIn( fi.fileName() ) == -1 )
134  {
135  QgsDebugMsg( "provider " + fi.fileName() + " skipped because doesn't match pattern " + filePattern );
136  continue;
137  }
138  }
139 
140  QLibrary myLib( fi.filePath() );
141  if ( !myLib.load() )
142  {
143  QgsDebugMsg( QStringLiteral( "Checking %1: ...invalid (lib not loadable): %2" ).arg( myLib.fileName(), myLib.errorString() ) );
144  continue;
145  }
146 
147  //MH: Added a further test to detect non-provider plugins linked to provider plugins.
148  //Only pure provider plugins have 'type' not defined
149  isprovider_t *hasType = reinterpret_cast< isprovider_t * >( cast_to_fptr( myLib.resolve( "type" ) ) );
150  if ( hasType )
151  {
152  QgsDebugMsg( QStringLiteral( "Checking %1: ...invalid (has type method)" ).arg( myLib.fileName() ) );
153  continue;
154  }
155 
156  // get the description and the key for the provider plugin
157  isprovider_t *isProvider = reinterpret_cast< isprovider_t * >( cast_to_fptr( myLib.resolve( "isProvider" ) ) );
158  if ( !isProvider )
159  {
160  QgsDebugMsg( QStringLiteral( "Checking %1: ...invalid (no isProvider method)" ).arg( myLib.fileName() ) );
161  continue;
162  }
163 
164  // check to see if this is a provider plugin
165  if ( !isProvider() )
166  {
167  QgsDebugMsg( QStringLiteral( "Checking %1: ...invalid (not a provider)" ).arg( myLib.fileName() ) );
168  continue;
169  }
170 
171  // looks like a provider. get the key and description
172  description_t *pDesc = reinterpret_cast< description_t * >( cast_to_fptr( myLib.resolve( "description" ) ) );
173  if ( !pDesc )
174  {
175  QgsDebugMsg( QStringLiteral( "Checking %1: ...invalid (no description method)" ).arg( myLib.fileName() ) );
176  continue;
177  }
178 
179  providerkey_t *pKey = reinterpret_cast< providerkey_t * >( cast_to_fptr( myLib.resolve( "providerKey" ) ) );
180  if ( !pKey )
181  {
182  QgsDebugMsg( QStringLiteral( "Checking %1: ...invalid (no providerKey method)" ).arg( myLib.fileName() ) );
183  continue;
184  }
185 
186  // add this provider to the provider map
187  mProviders[pKey()] = new QgsProviderMetadata( pKey(), pDesc(), myLib.fileName() );
188 
189  // load database drivers
190  databaseDrivers_t *pDatabaseDrivers = reinterpret_cast< databaseDrivers_t * >( cast_to_fptr( myLib.resolve( "databaseDrivers" ) ) );
191  if ( pDatabaseDrivers )
192  {
193  mDatabaseDrivers = pDatabaseDrivers();
194  }
195 
196  // load directory drivers
197  directoryDrivers_t *pDirectoryDrivers = reinterpret_cast< directoryDrivers_t * >( cast_to_fptr( myLib.resolve( "directoryDrivers" ) ) );
198  if ( pDirectoryDrivers )
199  {
200  mDirectoryDrivers = pDirectoryDrivers();
201  }
202 
203  // load protocol drivers
204  protocolDrivers_t *pProtocolDrivers = reinterpret_cast< protocolDrivers_t * >( cast_to_fptr( myLib.resolve( "protocolDrivers" ) ) );
205  if ( pProtocolDrivers )
206  {
207  mProtocolDrivers = pProtocolDrivers();
208  }
209 
210  // now get vector file filters, if any
211  fileVectorFilters_t *pFileVectorFilters = reinterpret_cast< fileVectorFilters_t * >( cast_to_fptr( myLib.resolve( "fileVectorFilters" ) ) );
212  if ( pFileVectorFilters )
213  {
214  QString fileVectorFilters = pFileVectorFilters();
215 
216  if ( !fileVectorFilters.isEmpty() )
217  mVectorFileFilters += fileVectorFilters;
218 
219  QgsDebugMsg( QStringLiteral( "Checking %1: ...loaded OK (%2 file filters)" ).arg( myLib.fileName() ).arg( fileVectorFilters.split( ";;" ).count() ) );
220  }
221 
222  // now get raster file filters, if any
223  // this replaces deprecated QgsRasterLayer::buildSupportedRasterFileFilter
225  reinterpret_cast< buildsupportedrasterfilefilter_t * >( cast_to_fptr( myLib.resolve( "buildSupportedRasterFileFilter" ) ) );
226  if ( pBuild )
227  {
228  QString fileRasterFilters;
229  pBuild( fileRasterFilters );
230 
231  QgsDebugMsg( "raster filters: " + fileRasterFilters );
232  if ( !fileRasterFilters.isEmpty() )
233  mRasterFileFilters += fileRasterFilters;
234 
235  QgsDebugMsg( QStringLiteral( "Checking %1: ...loaded OK (%2 file filters)" ).arg( myLib.fileName() ).arg( fileRasterFilters.split( ";;" ).count() ) );
236  }
237 
238  // now get mesh file filters, if any
239  fileMeshFilters_t *pFileMeshFilters = reinterpret_cast< fileMeshFilters_t * >( cast_to_fptr( myLib.resolve( "fileMeshFilters" ) ) );
240  if ( pFileMeshFilters )
241  {
242  QString fileMeshFilters;
243  QString fileMeshDatasetFilters;
244 
245  pFileMeshFilters( fileMeshFilters, fileMeshDatasetFilters );
246 
247  if ( !fileMeshFilters.isEmpty() )
248  mMeshFileFilters += fileMeshFilters;
249  if ( !fileMeshDatasetFilters.isEmpty() )
250  mMeshDatasetFileFilters += fileMeshDatasetFilters;
251 
252  QgsDebugMsg( QStringLiteral( "Checking %1: ...loaded OK (%2 file mesh filters, %3 file dataset filters)" ).arg( myLib.fileName() ).arg( mMeshFileFilters.split( ";;" ).count() ).arg( mMeshDatasetFileFilters.split( ";;" ).count() ) );
253  }
254 
255  // call initProvider() if such function is available - allows provider to register its services to QGIS
256  initProviderFunction_t *initFunc = reinterpret_cast< initProviderFunction_t * >( cast_to_fptr( myLib.resolve( "initProvider" ) ) );
257  if ( initFunc )
258  initFunc();
259  }
260 } // QgsProviderRegistry ctor
261 
262 
263 // typedef for the unload dataprovider function
265 
266 void QgsProviderRegistry::clean()
267 {
268  // avoid recreating a new project just to clean it
269  if ( QgsProject::sProject )
271 
272  Providers::const_iterator it = mProviders.begin();
273 
274  while ( it != mProviders.end() )
275  {
276  QgsDebugMsgLevel( QStringLiteral( "cleanup:%1" ).arg( it->first ), 5 );
277  QString lib = it->second->library();
278  if ( !lib.isEmpty() )
279  {
280  QLibrary myLib( lib );
281  if ( myLib.isLoaded() )
282  {
283  cleanupProviderFunction_t *cleanupFunc = reinterpret_cast< cleanupProviderFunction_t * >( cast_to_fptr( myLib.resolve( "cleanupProvider" ) ) );
284  if ( cleanupFunc )
285  cleanupFunc();
286  }
287  }
288  delete it->second;
289  ++it;
290  }
291  mProviders.clear();
292 }
293 
294 bool QgsProviderRegistry::exists()
295 {
296  return static_cast< bool >( sInstance );
297 }
298 
300 {
301  clean();
302  if ( sInstance == this )
303  sInstance = nullptr;
304 }
305 
306 
315 static
316 QgsProviderMetadata *findMetadata_( QgsProviderRegistry::Providers const &metaData,
317  QString const &providerKey )
318 {
319  QgsProviderRegistry::Providers::const_iterator i =
320  metaData.find( providerKey );
321 
322  if ( i != metaData.end() )
323  {
324  return i->second;
325  }
326 
327  return nullptr;
328 } // findMetadata_
329 
330 
331 
332 QString QgsProviderRegistry::library( QString const &providerKey ) const
333 {
334  QgsProviderMetadata *md = findMetadata_( mProviders, providerKey );
335 
336  if ( md )
337  {
338  return md->library();
339  }
340 
341  return QString();
342 }
343 
344 
345 QString QgsProviderRegistry::pluginList( bool asHTML ) const
346 {
347  Providers::const_iterator it = mProviders.begin();
348 
349  if ( mProviders.empty() )
350  return QObject::tr( "No data provider plugins are available. No vector layers can be loaded" );
351 
352  QString list;
353 
354  if ( asHTML )
355  list += QLatin1String( "<ol>" );
356 
357  while ( it != mProviders.end() )
358  {
359  if ( asHTML )
360  list += QLatin1String( "<li>" );
361 
362  list += it->second->description();
363 
364  if ( asHTML )
365  list += QLatin1String( "<br></li>" );
366  else
367  list += '\n';
368 
369  ++it;
370  }
371 
372  if ( asHTML )
373  list += QLatin1String( "</ol>" );
374 
375  return list;
376 }
377 
379 {
380  mLibraryDirectory = path;
381  clean();
382  init();
383 }
384 
386 {
387  return mLibraryDirectory;
388 }
389 
390 
391 
392 // typedef for the QgsDataProvider class factory
393 typedef QgsDataProvider *classFactoryFunction_t( const QString *, const QgsDataProvider::ProviderOptions &options );
394 
395 
396 /* Copied from QgsVectorLayer::setDataProvider
397  * TODO: Make it work in the generic environment
398  *
399  * TODO: Is this class really the best place to put a data provider loader?
400  * It seems more sensible to provide the code in one place rather than
401  * in qgsrasterlayer, qgsvectorlayer, serversourceselect, etc.
402  */
403 QgsDataProvider *QgsProviderRegistry::createProvider( QString const &providerKey, QString const &dataSource, const QgsDataProvider::ProviderOptions &options )
404 {
405  // XXX should I check for and possibly delete any pre-existing providers?
406  // XXX How often will that scenario occur?
407 
408  const QgsProviderMetadata *metadata = providerMetadata( providerKey );
409  if ( !metadata )
410  {
411  QgsMessageLog::logMessage( QObject::tr( "Invalid data provider %1" ).arg( providerKey ) );
412  return nullptr;
413  }
414 
415  if ( metadata->createFunction() )
416  {
417  return metadata->createFunction()( dataSource, options );
418  }
419 
420  // load the plugin
421  QString lib = library( providerKey );
422 
423 #ifdef TESTPROVIDERLIB
424  const char *cLib = lib.toUtf8();
425 
426  // test code to help debug provider loading problems
427  // void *handle = dlopen(cLib, RTLD_LAZY);
428  void *handle = dlopen( cOgrLib, RTLD_LAZY | RTLD_GLOBAL );
429  if ( !handle )
430  {
431  QgsLogger::warning( "Error in dlopen" );
432  }
433  else
434  {
435  QgsDebugMsg( QStringLiteral( "dlopen succeeded" ) );
436  dlclose( handle );
437  }
438 
439 #endif
440  // load the data provider
441  QLibrary myLib( lib );
442 
443  QgsDebugMsg( "Library name is " + myLib.fileName() );
444  if ( !myLib.load() )
445  {
446  QgsMessageLog::logMessage( QObject::tr( "Failed to load %1: %2" ).arg( lib, myLib.errorString() ) );
447  return nullptr;
448  }
449 
450  classFactoryFunction_t *classFactory = reinterpret_cast< classFactoryFunction_t * >( cast_to_fptr( myLib.resolve( "classFactory" ) ) );
451  if ( !classFactory )
452  {
453  QgsDebugMsg( QStringLiteral( "Failed to load %1: no classFactory method" ).arg( lib ) );
454  return nullptr;
455  }
456 
457  QgsDataProvider *dataProvider = classFactory( &dataSource, options );
458  if ( !dataProvider )
459  {
460  QgsMessageLog::logMessage( QObject::tr( "Unable to instantiate the data provider plugin %1" ).arg( lib ) );
461  myLib.unload();
462  return nullptr;
463  }
464 
465  QgsDebugMsg( QStringLiteral( "Instantiated the data provider plugin: %1" ).arg( dataProvider->name() ) );
466  return dataProvider;
467 } // QgsProviderRegistry::setDataProvider
468 
469 QVariantMap QgsProviderRegistry::decodeUri( const QString &providerKey, const QString &uri )
470 {
471  std::unique_ptr< QLibrary > library( createProviderLibrary( providerKey ) );
472  if ( !library )
473  {
474  return QVariantMap();
475  }
476 
477  decodeUri_t *decodeUri = reinterpret_cast< decodeUri_t *>( cast_to_fptr( library->resolve( "decodeUri" ) ) );
478  if ( !decodeUri )
479  {
480  return QVariantMap();
481  }
482  return decodeUri( uri );
483 }
484 
485 int QgsProviderRegistry::providerCapabilities( const QString &providerKey ) const
486 {
487  std::unique_ptr< QLibrary > library( createProviderLibrary( providerKey ) );
488  if ( !library )
489  {
491  }
492 
493  dataCapabilities_t *dataCapabilities = reinterpret_cast< dataCapabilities_t *>( cast_to_fptr( library->resolve( "dataCapabilities" ) ) );
494  if ( !dataCapabilities )
495  {
497  }
498 
499  return dataCapabilities();
500 }
501 
502 // This should be QWidget, not QDialog
503 typedef QWidget *selectFactoryFunction_t( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode );
504 
505 QWidget *QgsProviderRegistry::createSelectionWidget( const QString &providerKey,
506  QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode )
507 {
508  selectFactoryFunction_t *selectFactory =
509  reinterpret_cast< selectFactoryFunction_t * >( cast_to_fptr( function( providerKey, "selectWidget" ) ) );
510 
511  if ( !selectFactory )
512  return nullptr;
513 
514  return selectFactory( parent, fl, widgetMode );
515 }
516 
517 QFunctionPointer QgsProviderRegistry::function( QString const &providerKey,
518  QString const &functionName )
519 {
520  QString lib = library( providerKey );
521  if ( lib.isEmpty() )
522  return nullptr;
523 
524  QLibrary myLib( library( providerKey ) );
525 
526  QgsDebugMsg( "Library name is " + myLib.fileName() );
527 
528  if ( myLib.load() )
529  {
530  return myLib.resolve( functionName.toLatin1().data() );
531  }
532  else
533  {
534  QgsDebugMsg( "Cannot load library: " + myLib.errorString() );
535  return nullptr;
536  }
537 }
538 
539 QLibrary *QgsProviderRegistry::createProviderLibrary( QString const &providerKey ) const
540 {
541  QString lib = library( providerKey );
542  if ( lib.isEmpty() )
543  return nullptr;
544 
545  std::unique_ptr< QLibrary > myLib( new QLibrary( lib ) );
546 
547  QgsDebugMsg( "Library name is " + myLib->fileName() );
548 
549  if ( myLib->load() )
550  return myLib.release();
551 
552  QgsDebugMsg( "Cannot load library: " + myLib->errorString() );
553 
554  return nullptr;
555 }
556 
557 void QgsProviderRegistry::registerGuis( QWidget *parent )
558 {
559  typedef void registerGui_function( QWidget * parent );
560 
561  const auto constProviderList = providerList();
562  for ( const QString &provider : constProviderList )
563  {
564  registerGui_function *registerGui = reinterpret_cast< registerGui_function * >( cast_to_fptr( function( provider, "registerGui" ) ) );
565 
566  if ( !registerGui )
567  continue;
568 
569  registerGui( parent );
570  }
571 }
572 
574 {
575  if ( providerMetadata )
576  {
577  if ( mProviders.find( providerMetadata->key() ) == mProviders.end() )
578  {
579  mProviders[ providerMetadata->key() ] = providerMetadata;
580  return true;
581  }
582  else
583  {
584  QgsDebugMsgLevel( QStringLiteral( "Cannot register provider metadata: a provider with the same key (%1) was already registered!" ).arg( providerMetadata->key() ), 2 );
585  }
586  }
587  else
588  {
589  QgsDebugMsgLevel( QStringLiteral( "Trying to register a null metadata provider!" ), 2 );
590  }
591  return false;
592 }
593 
595 {
596  return mVectorFileFilters;
597 }
598 
600 {
601  return mRasterFileFilters;
602 }
603 
605 {
606  return mMeshFileFilters;
607 }
608 
610 {
611  return mMeshDatasetFileFilters;
612 }
613 
615 {
616  return mDatabaseDrivers;
617 }
618 
620 {
621  return mDirectoryDrivers;
622 }
623 
625 {
626  return mProtocolDrivers;
627 }
628 
630 {
631  QStringList lst;
632  for ( Providers::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
633  {
634  lst.append( it->first );
635  }
636  return lst;
637 }
638 
639 const QgsProviderMetadata *QgsProviderRegistry::providerMetadata( const QString &providerKey ) const
640 {
641  return findMetadata_( mProviders, providerKey );
642 }
bool registerProvider(QgsProviderMetadata *providerMetadata)
register a new vector data provider from its providerMetadata
WidgetMode
Different ways a source select dialog can be used (embedded is for the data source manager dialog) ...
QString databaseDrivers_t()
void cleanupProviderFunction_t()
QString key() const
This returns the unique key associated with the provider.
virtual void setTitle(const QString &title)=0
Sets title for the messages.
QVariantMap decodeUri_t(const QString &uri)
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
QString library() const
This returns the library file name.
static void warning(const QString &msg)
Goes to qWarning.
Definition: qgslogger.cpp:121
virtual QString protocolDrivers() const
Returns a string containing the available protocol drivers.
QString library(const QString &providerKey) const
Returns path for the library of the provider.
void registerGuis(QWidget *widget)
void fileMeshFilters_t(QString &fileMeshFiltersString, QString &fileMeshDatasetFiltersString)
virtual QString databaseDrivers() const
Returns a string containing the available database drivers.
QString directoryDrivers_t()
static QgsMessageOutput * createMessageOutput()
function that returns new class derived from QgsMessageOutput (don&#39;t forget to delete it then if show...
QgsDataProvider * classFactoryFunction_t(const QString *, const QgsDataProvider::ProviderOptions &options)
QVariantMap decodeUri(const QString &providerKey, const QString &uri)
Breaks a provider data source URI into its component paths (e.g.
Abstract base class for spatial data provider implementations.
virtual QString name() const =0
Returns a provider name.
QString description_t()
virtual QString fileVectorFilters() const
Returns vector file filter string.
QgsDataProvider * createProvider(const QString &providerKey, const QString &dataSource, const QgsDataProvider::ProviderOptions &options=QgsDataProvider::ProviderOptions())
Creates a new instance of a provider.
QWidget * createSelectionWidget(const QString &providerKey, QWidget *parent=nullptr, Qt::WindowFlags fl=Qt::WindowFlags(), QgsProviderRegistry::WidgetMode widgetMode=QgsProviderRegistry::WidgetMode::None)
Returns a new widget for selecting layers from a provider.
bool isprovider_t()
void initProviderFunction_t()
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
QLibrary * createProviderLibrary(const QString &providerKey) const
Returns a new QLibrary for the specified providerKey.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
virtual void setMessage(const QString &message, MessageType msgType)=0
Sets message, it won&#39;t be displayed until.
void setLibraryDirectory(const QDir &path)
Sets library directory where to search for plugins.
CreateDataProviderFunction createFunction() const
Returns a pointer to the direct provider creation function, if supported by the provider.
const QgsProviderMetadata * providerMetadata(const QString &providerKey) const
Returns metadata of the provider or nullptr if not found.
QString pluginList(bool asHtml=false) const
Returns list of provider plugins found.
void removeAllMapLayers()
Removes all registered layers.
#define cast_to_fptr(f)
Definition: qgis.h:158
virtual QString fileMeshDatasetFilters() const
Returns mesh&#39;s dataset file filter string.
QString fileVectorFilters_t()
A registry / canonical manager of data providers.
int providerCapabilities(const QString &providerKey) const
Returns the provider capabilities.
virtual void showMessage(bool blocking=true)=0
display the message to the user and deletes itself
Setting options for creating vector data providers.
virtual QString fileMeshFilters() const
Returns mesh file filter string.
QString providerkey_t()
Holds data provider key, description, and associated shared library file or function pointer informat...
virtual QString directoryDrivers() const
Returns a string containing the available directory drivers.
std::map< QString, QgsProviderMetadata * > Providers
Type for data provider metadata associative container.
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:438
QWidget * selectFactoryFunction_t(QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode)
QFunctionPointer function(const QString &providerKey, const QString &functionName)
Gets pointer to provider function.
virtual QString fileRasterFilters() const
Returns raster file filter string.
void buildsupportedrasterfilefilter_t(QString &fileFiltersString)
QString protocolDrivers_t()
QStringList providerList() const
Returns list of available providers by their keys.
Interface for showing messages from QGIS in GUI independent way.
int dataCapabilities_t()
QDir libraryDirectory() const
Returns the library directory where plugins are found.