QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 "qgsdataitemprovider.h"
28 #include "qgslogger.h"
29 #include "qgsmessageoutput.h"
30 #include "qgsmessagelog.h"
31 #include "qgsprovidermetadata.h"
32 #include "qgsvectorlayer.h"
34 #include "qgsproject.h"
36 #include "providers/gdal/qgsgdalprovider.h"
37 #include "providers/ogr/qgsogrprovider.h"
38 #include "providers/meshmemory/qgsmeshmemorydataprovider.h"
39 #include "qgsruntimeprofiler.h"
40 
41 #ifdef HAVE_STATIC_PROVIDERS
42 #include "qgswmsprovider.h"
43 #include "qgspostgresprovider.h"
44 #endif
45 
46 static QgsProviderRegistry *sInstance = nullptr;
47 
49 {
50  if ( !sInstance )
51  {
52  static QMutex sMutex;
53  QMutexLocker locker( &sMutex );
54  if ( !sInstance )
55  {
56  sInstance = new QgsProviderRegistry( pluginPath );
57  }
58  }
59  return sInstance;
60 } // QgsProviderRegistry::instance
61 
62 
71 static
72 QgsProviderMetadata *findMetadata_( const QgsProviderRegistry::Providers &metaData,
73  const QString &providerKey )
74 {
75  // first do case-sensitive match
76  QgsProviderRegistry::Providers::const_iterator i =
77  metaData.find( providerKey );
78 
79  if ( i != metaData.end() )
80  {
81  return i->second;
82  }
83 
84  // fallback to case-insensitive match
85  for ( auto it = metaData.begin(); it != metaData.end(); ++it )
86  {
87  if ( providerKey.compare( it->first, Qt::CaseInsensitive ) == 0 )
88  return it->second;
89  }
90 
91  return nullptr;
92 }
93 
94 QgsProviderRegistry::QgsProviderRegistry( const QString &pluginPath )
95 {
96  // At startup, examine the libs in the qgis/lib dir and store those that
97  // are a provider shared lib
98  // check all libs in the current plugin directory and get name and descriptions
99  //TODO figure out how to register and identify data source plugin for a specific
100  //TODO layer type
101 #if 0
102  char **argv = qApp->argv();
103  QString appDir = argv[0];
104  int bin = appDir.findRev( "/bin", -1, false );
105  QString baseDir = appDir.left( bin );
106  QString mLibraryDirectory = baseDir + "/lib";
107 #endif
108 
109  QgsScopedRuntimeProfile profile( QObject::tr( "Initialize data providers" ) );
110  mLibraryDirectory.setPath( pluginPath );
111  init();
112 }
113 
114 void QgsProviderRegistry::init()
115 {
116  // add static providers
118  {
119  QgsScopedRuntimeProfile profile( QObject::tr( "Create memory layer provider" ) );
120  mProviders[ QgsMemoryProvider::providerKey() ] = new QgsProviderMetadata( QgsMemoryProvider::providerKey(), QgsMemoryProvider::providerDescription(), &QgsMemoryProvider::createProvider );
121  }
122  {
123  QgsScopedRuntimeProfile profile( QObject::tr( "Create mesh memory layer provider" ) );
124  mProviders[ QgsMeshMemoryDataProvider::providerKey() ] = new QgsProviderMetadata( QgsMeshMemoryDataProvider::providerKey(), QgsMeshMemoryDataProvider::providerDescription(), &QgsMeshMemoryDataProvider::createProvider );
125  }
127  {
128  QgsScopedRuntimeProfile profile( QObject::tr( "Create GDAL provider" ) );
129  mProviders[ QgsGdalProvider::providerKey() ] = new QgsGdalProviderMetadata();
130  }
131  {
132  QgsScopedRuntimeProfile profile( QObject::tr( "Create OGR provider" ) );
133  mProviders[ QgsOgrProvider::providerKey() ] = new QgsOgrProviderMetadata();
134  }
135  {
136  QgsScopedRuntimeProfile profile( QObject::tr( "Create vector tile provider" ) );
137  QgsProviderMetadata *vt = new QgsVectorTileProviderMetadata();
138  mProviders[ vt->key() ] = vt;
139  }
140 #ifdef HAVE_STATIC_PROVIDERS
141  mProviders[ QgsWmsProvider::providerKey() ] = new QgsWmsProviderMetadata();
142  mProviders[ QgsPostgresProvider::providerKey() ] = new QgsPostgresProviderMetadata();
143 #endif
144 
145  // add dynamic providers
146 #ifdef HAVE_STATIC_PROVIDERS
147  QgsDebugMsg( QStringLiteral( "Forced only static providers" ) );
148 #else
149  typedef QgsProviderMetadata *factory_function( );
150 
151  mLibraryDirectory.setSorting( QDir::Name | QDir::IgnoreCase );
152  mLibraryDirectory.setFilter( QDir::Files | QDir::NoSymLinks );
153 
154 #if defined(Q_OS_WIN) || defined(__CYGWIN__)
155  mLibraryDirectory.setNameFilters( QStringList( "*.dll" ) );
156 #elif defined(ANDROID)
157  mLibraryDirectory.setNameFilters( QStringList( "*provider*.so" ) );
158 #else
159  mLibraryDirectory.setNameFilters( QStringList( QStringLiteral( "*.so" ) ) );
160 #endif
161 
162  QgsDebugMsgLevel( QStringLiteral( "Checking %1 for provider plugins" ).arg( mLibraryDirectory.path() ), 2 );
163 
164  if ( mLibraryDirectory.count() == 0 )
165  {
166  QgsDebugMsg( QStringLiteral( "No dynamic QGIS data provider plugins found in:\n%1\n" ).arg( mLibraryDirectory.path() ) );
167  }
168 
169  // provider file regex pattern, only files matching the pattern are loaded if the variable is defined
170  QString filePattern = getenv( "QGIS_PROVIDER_FILE" );
171  QRegExp fileRegexp;
172  if ( !filePattern.isEmpty() )
173  {
174  fileRegexp.setPattern( filePattern );
175  }
176 
177  typedef std::vector<QgsProviderMetadata *> *multiple_factory_function();
178 
179  const auto constEntryInfoList = mLibraryDirectory.entryInfoList();
180  for ( const QFileInfo &fi : constEntryInfoList )
181  {
182  if ( !fileRegexp.isEmpty() )
183  {
184  if ( fileRegexp.indexIn( fi.fileName() ) == -1 )
185  {
186  QgsDebugMsg( "provider " + fi.fileName() + " skipped because doesn't match pattern " + filePattern );
187  continue;
188  }
189  }
190 
191  QgsScopedRuntimeProfile profile( QObject::tr( "Load %1" ).arg( fi.fileName() ) );
192  QLibrary myLib( fi.filePath() );
193  if ( !myLib.load() )
194  {
195  QgsDebugMsg( QStringLiteral( "Checking %1: ...invalid (lib not loadable): %2" ).arg( myLib.fileName(), myLib.errorString() ) );
196  continue;
197  }
198 
199  QFunctionPointer multi_func = myLib.resolve( QStringLiteral( "multipleProviderMetadataFactory" ).toLatin1().data() );
200  multiple_factory_function *multi_function = reinterpret_cast< multiple_factory_function * >( cast_to_fptr( multi_func ) );
201  if ( multi_function )
202  {
203  std::vector<QgsProviderMetadata *> *metadatas = multi_function();
204  for ( const auto meta : *metadatas )
205  {
206  if ( findMetadata_( mProviders, meta->key() ) )
207  {
208  QgsDebugMsg( QStringLiteral( "Checking %1: ...invalid (key %2 already registered)" ).arg( myLib.fileName() ).arg( meta->key() ) );
209  delete meta;
210  continue;
211  }
212  // add this provider to the provider map
213  mProviders[meta->key()] = meta;
214  }
215  delete metadatas;
216  }
217  else
218  {
219  QFunctionPointer func = myLib.resolve( QStringLiteral( "providerMetadataFactory" ).toLatin1().data() );
220  factory_function *function = reinterpret_cast< factory_function * >( cast_to_fptr( func ) );
221  if ( !function )
222  {
223  QgsDebugMsgLevel( QStringLiteral( "Checking %1: ...invalid (no providerMetadataFactory method)" ).arg( myLib.fileName() ), 2 );
224  continue;
225  }
226 
227  QgsProviderMetadata *meta = function();
228  if ( !meta )
229  {
230  QgsDebugMsg( QStringLiteral( "Checking %1: ...invalid (no metadata returned)" ).arg( myLib.fileName() ) );
231  continue;
232  }
233 
234  if ( findMetadata_( mProviders, meta->key() ) )
235  {
236  QgsDebugMsg( QStringLiteral( "Checking %1: ...invalid (key %2 already registered)" ).arg( myLib.fileName() ).arg( meta->key() ) );
237  delete meta;
238  continue;
239  }
240  // add this provider to the provider map
241  mProviders[meta->key()] = meta;
242  }
243  }
244 #endif
245  QgsDebugMsg( QStringLiteral( "Loaded %1 providers (%2) " ).arg( mProviders.size() ).arg( providerList().join( ';' ) ) );
246 
247  // now initialize all providers
248  for ( Providers::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
249  {
250  const QString &key = it->first;
251 
252  QgsScopedRuntimeProfile profile( QObject::tr( "Initialize %1" ).arg( key ) );
253 
254  QgsProviderMetadata *meta = it->second;
255 
256  // now get vector file filters, if any
258  if ( !fileVectorFilters.isEmpty() )
259  {
260  mVectorFileFilters += fileVectorFilters;
261  QgsDebugMsgLevel( QStringLiteral( "Checking %1: ...loaded OK (%2 file filters)" ).arg( key ).arg( fileVectorFilters.split( ";;" ).count() ), 2 );
262  }
263 
264  // now get raster file filters, if any
266  if ( !fileRasterFilters.isEmpty() )
267  {
268  QgsDebugMsgLevel( "raster filters: " + fileRasterFilters, 2 );
269  mRasterFileFilters += fileRasterFilters;
270  QgsDebugMsgLevel( QStringLiteral( "Checking %1: ...loaded OK (%2 file filters)" ).arg( key ).arg( fileRasterFilters.split( ";;" ).count() ), 2 );
271  }
272 
273  // now get mesh file filters, if any
275  if ( !fileMeshFilters.isEmpty() )
276  {
277  mMeshFileFilters += fileMeshFilters;
278  QgsDebugMsgLevel( QStringLiteral( "Checking %1: ...loaded OK (%2 file mesh filters)" ).arg( key ).arg( mMeshFileFilters.split( ";;" ).count() ), 2 );
279 
280  }
281 
283  if ( !fileMeshDatasetFilters.isEmpty() )
284  {
285  mMeshDatasetFileFilters += fileMeshDatasetFilters;
286  QgsDebugMsgLevel( QStringLiteral( "Checking %1: ...loaded OK (%2 file dataset filters)" ).arg( key ).arg( mMeshDatasetFileFilters.split( ";;" ).count() ), 2 );
287  }
288 
289  // call initProvider() - allows provider to register its services to QGIS
290  meta->initProvider();
291  }
292 
293  // load database drivers (only OGR)
294  mDatabaseDrivers = QgsOgrProviderUtils::databaseDrivers();
295 
296  // load directory drivers (only OGR)
297  mDirectoryDrivers = QgsOgrProviderUtils::directoryDrivers();
298 
299  // load protocol drivers (only OGR)
300  mProtocolDrivers = QgsOgrProviderUtils::protocolDrivers();
301 } // QgsProviderRegistry ctor
302 
303 
304 // typedef for the unload dataprovider function
306 
307 void QgsProviderRegistry::clean()
308 {
309  // avoid recreating a new project just to clean it
310  if ( QgsProject::sProject )
312 
313  Providers::const_iterator it = mProviders.begin();
314 
315  while ( it != mProviders.end() )
316  {
317  QgsDebugMsgLevel( QStringLiteral( "cleanup:%1" ).arg( it->first ), 5 );
318  it->second->cleanupProvider();
319  delete it->second;
320  ++it;
321  }
322  mProviders.clear();
323 }
324 
325 bool QgsProviderRegistry::exists()
326 {
327  return static_cast< bool >( sInstance );
328 }
329 
331 {
332  clean();
333  if ( sInstance == this )
334  sInstance = nullptr;
335 }
336 
337 QString QgsProviderRegistry::library( QString const &providerKey ) const
338 {
339  QgsProviderMetadata *md = findMetadata_( mProviders, providerKey );
340 
341  if ( md )
342  {
344  return md->library();
346  }
347 
348  return QString();
349 }
350 
351 QString QgsProviderRegistry::pluginList( bool asHTML ) const
352 {
353  Providers::const_iterator it = mProviders.begin();
354 
355  if ( mProviders.empty() )
356  return QObject::tr( "No data provider plugins are available. No vector layers can be loaded" );
357 
358  QString list;
359 
360  if ( asHTML )
361  list += QLatin1String( "<ol>" );
362 
363  while ( it != mProviders.end() )
364  {
365  if ( asHTML )
366  list += QLatin1String( "<li>" );
367 
368  list += it->second->description();
369 
370  if ( asHTML )
371  list += QLatin1String( "<br></li>" );
372  else
373  list += '\n';
374 
375  ++it;
376  }
377 
378  if ( asHTML )
379  list += QLatin1String( "</ol>" );
380 
381  return list;
382 }
383 
385 {
386  mLibraryDirectory = path;
387  clean();
388  init();
389 }
390 
392 {
393  return mLibraryDirectory;
394 }
395 
396 
397 /* Copied from QgsVectorLayer::setDataProvider
398  * TODO: Make it work in the generic environment
399  *
400  * TODO: Is this class really the best place to put a data provider loader?
401  * It seems more sensible to provide the code in one place rather than
402  * in qgsrasterlayer, qgsvectorlayer, serversourceselect, etc.
403  */
404 QgsDataProvider *QgsProviderRegistry::createProvider( QString const &providerKey, QString const &dataSource, const QgsDataProvider::ProviderOptions &options )
405 {
406  // XXX should I check for and possibly delete any pre-existing providers?
407  // XXX How often will that scenario occur?
408 
409  QgsProviderMetadata *metadata = findMetadata_( mProviders, providerKey );
410  if ( !metadata )
411  {
412  QgsMessageLog::logMessage( QObject::tr( "Invalid data provider %1" ).arg( providerKey ) );
413  return nullptr;
414  }
415 
416  return metadata->createProvider( dataSource, options );
417 }
418 
419 int QgsProviderRegistry::providerCapabilities( const QString &providerKey ) const
420 {
421  const QList< QgsDataItemProvider * > itemProviders = dataItemProviders( providerKey );
423  //concat flags
424  for ( const QgsDataItemProvider *itemProvider : itemProviders )
425  {
426  ret = ret | itemProvider->capabilities();
427  }
428  return ret;
429 }
430 
431 QVariantMap QgsProviderRegistry::decodeUri( const QString &providerKey, const QString &uri )
432 {
433  QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
434  if ( meta )
435  return meta->decodeUri( uri );
436  else
437  return QVariantMap();
438 }
439 
440 QString QgsProviderRegistry::encodeUri( const QString &providerKey, const QVariantMap &parts )
441 {
442  QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
443  if ( meta )
444  return meta->encodeUri( parts );
445  else
446  return QString();
447 }
448 
450  const QString &uri,
451  const QgsFields &fields,
452  QgsWkbTypes::Type wkbType,
453  const QgsCoordinateReferenceSystem &srs,
454  bool overwrite, QMap<int, int> &oldToNewAttrIdxMap,
455  QString &errorMessage,
456  const QMap<QString, QVariant> *options )
457 {
459 
460  QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
461  if ( meta )
462  return meta->createEmptyLayer( uri, fields, wkbType, srs, overwrite, oldToNewAttrIdxMap, errorMessage, options );
463  else
464  {
466  errorMessage = QObject::tr( "Unable to load %1 provider" ).arg( providerKey );
467  }
468 
469  return ret;
470 }
471 
472 QgsRasterDataProvider *QgsProviderRegistry::createRasterDataProvider( const QString &providerKey, const QString &uri, const QString &format,
473  int nBands, Qgis::DataType type, int width, int height,
474  double *geoTransform, const QgsCoordinateReferenceSystem &crs,
475  const QStringList &createOptions )
476 {
477  QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
478  if ( meta )
479  return meta->createRasterDataProvider( uri, format, nBands, type, width, height, geoTransform, crs, createOptions );
480  else
481  return nullptr;
482 }
483 
484 QList<QPair<QString, QString> > QgsProviderRegistry::pyramidResamplingMethods( const QString &providerKey )
485 {
486  QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
487  if ( meta )
488  return meta->pyramidResamplingMethods();
489  else
490  return QList<QPair<QString, QString> >();
491 }
492 
493 QList<QgsDataItemProvider *> QgsProviderRegistry::dataItemProviders( const QString &providerKey ) const
494 {
495  QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
496  if ( meta )
497  return meta->dataItemProviders();
498  else
499  return QList<QgsDataItemProvider *>();
500 }
501 
502 int QgsProviderRegistry::listStyles( const QString &providerKey, const QString &uri, QStringList &ids, QStringList &names, QStringList &descriptions, QString &errCause )
503 {
504  int res = -1;
505  QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
506  if ( meta )
507  {
508  res = meta->listStyles( uri, ids, names, descriptions, errCause );
509  }
510  else
511  {
512  errCause = QObject::tr( "Unable to load %1 provider" ).arg( providerKey );
513  }
514  return res;
515 }
516 
517 QString QgsProviderRegistry::getStyleById( const QString &providerKey, const QString &uri, QString styleId, QString &errCause )
518 {
519  QString ret;
520  QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
521  if ( meta )
522  {
523  ret = meta->getStyleById( uri, styleId, errCause );
524  }
525  else
526  {
527  errCause = QObject::tr( "Unable to load %1 provider" ).arg( providerKey );
528  }
529  return ret;
530 }
531 
532 bool QgsProviderRegistry::deleteStyleById( const QString &providerKey, const QString &uri, QString styleId, QString &errCause )
533 {
534  bool ret( false );
535 
536  QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
537  if ( meta )
538  return meta->deleteStyleById( uri, styleId, errCause );
539  else
540  {
541  errCause = QObject::tr( "Unable to load %1 provider" ).arg( providerKey );
542  }
543  return ret;
544 }
545 
546 bool QgsProviderRegistry::saveStyle( const QString &providerKey, const QString &uri, const QString &qmlStyle,
547  const QString &sldStyle, const QString &styleName, const QString &styleDescription,
548  const QString &uiFileContent, bool useAsDefault, QString &errCause )
549 {
550  bool ret( false );
551  QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
552  if ( meta )
553  ret = meta->saveStyle( uri, qmlStyle, sldStyle, styleName, styleDescription,
554  uiFileContent, useAsDefault, errCause );
555  else
556  {
557  errCause = QObject::tr( "Unable to load %1 provider" ).arg( providerKey );
558  }
559  return ret;
560 }
561 
562 QString QgsProviderRegistry::loadStyle( const QString &providerKey, const QString &uri, QString &errCause )
563 {
564  QString ret;
565  QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
566  if ( meta )
567  ret = meta->loadStyle( uri, errCause );
568  else
569  {
570  errCause = QObject::tr( "Unable to load %1 provider" ).arg( providerKey );
571  }
572  return ret;
573 }
574 
575 bool QgsProviderRegistry::createDb( const QString &providerKey, const QString &dbPath, QString &errCause )
576 {
577  QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
578  if ( meta )
579  return meta->createDb( dbPath, errCause );
580  else
581  {
582  errCause = QStringLiteral( "Resolving createDb(...) failed" );
583  return false;
584  }
585 }
586 
587 QgsTransaction *QgsProviderRegistry::createTransaction( const QString &providerKey, const QString &connString )
588 {
589  QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
590  if ( meta )
591  return meta->createTransaction( connString );
592  else
593  return nullptr;
594 }
595 
596 QWidget *QgsProviderRegistry::createSelectionWidget( const QString &providerKey,
597  QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode )
598 {
599  Q_UNUSED( providerKey );
600  Q_UNUSED( parent );
601  Q_UNUSED( fl );
602  Q_UNUSED( widgetMode );
603  QgsDebugMsg( "deprecated call - use QgsGui::sourceSelectProviderRegistry()->createDataSourceWidget() instead" );
604  return nullptr;
605 }
606 
607 QFunctionPointer QgsProviderRegistry::function( QString const &providerKey,
608  QString const &functionName )
609 {
611  QString lib = library( providerKey );
613  if ( lib.isEmpty() )
614  return nullptr;
615 
616  QLibrary myLib( lib );
617 
618  QgsDebugMsg( "Library name is " + myLib.fileName() );
619 
620  if ( myLib.load() )
621  {
622  return myLib.resolve( functionName.toLatin1().data() );
623  }
624  else
625  {
626  QgsDebugMsg( "Cannot load library: " + myLib.errorString() );
627  return nullptr;
628  }
629 }
630 
631 QLibrary *QgsProviderRegistry::createProviderLibrary( QString const &providerKey ) const
632 {
634  QString lib = library( providerKey );
636  if ( lib.isEmpty() )
637  return nullptr;
638 
639  std::unique_ptr< QLibrary > myLib( new QLibrary( lib ) );
640 
641  QgsDebugMsg( "Library name is " + myLib->fileName() );
642 
643  if ( myLib->load() )
644  return myLib.release();
645 
646  QgsDebugMsg( "Cannot load library: " + myLib->errorString() );
647 
648  return nullptr;
649 }
650 
652 {
653  QgsDebugMsg( "deprecated - use QgsGui::providerGuiRegistry() instead." );
654 }
655 
657 {
658  if ( providerMetadata )
659  {
660  if ( mProviders.find( providerMetadata->key() ) == mProviders.end() )
661  {
662  mProviders[ providerMetadata->key() ] = providerMetadata;
663  return true;
664  }
665  else
666  {
667  QgsDebugMsgLevel( QStringLiteral( "Cannot register provider metadata: a provider with the same key (%1) was already registered!" ).arg( providerMetadata->key() ), 2 );
668  }
669  }
670  else
671  {
672  QgsDebugMsgLevel( QStringLiteral( "Trying to register a null metadata provider!" ), 2 );
673  }
674  return false;
675 }
676 
678 {
679  return mVectorFileFilters;
680 }
681 
683 {
684  return mRasterFileFilters;
685 }
686 
688 {
689  return mMeshFileFilters;
690 }
691 
693 {
694  return mMeshDatasetFileFilters;
695 }
696 
698 {
699  return mDatabaseDrivers;
700 }
701 
703 {
704  return mDirectoryDrivers;
705 }
706 
708 {
709  return mProtocolDrivers;
710 }
711 
713 {
714  QStringList lst;
715  for ( Providers::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
716  {
717  lst.append( it->first );
718  }
719  return lst;
720 }
721 
722 QgsProviderMetadata *QgsProviderRegistry::providerMetadata( const QString &providerKey ) const
723 {
724  return findMetadata_( mProviders, providerKey );
725 }
cleanupProviderFunction_t
void cleanupProviderFunction_t()
Definition: qgsproviderregistry.cpp:305
QgsProviderRegistry::createProvider
QgsDataProvider * createProvider(const QString &providerKey, const QString &dataSource, const QgsDataProvider::ProviderOptions &options=QgsDataProvider::ProviderOptions())
Creates a new instance of a provider.
Definition: qgsproviderregistry.cpp:404
Qgis::DataType
DataType
Raster data types.
Definition: qgis.h:114
QgsProviderMetadata::dataItemProviders
virtual QList< QgsDataItemProvider * > dataItemProviders() const
Returns data item providers.
Definition: qgsprovidermetadata.cpp:161
qgsmessageoutput.h
qgsruntimeprofiler.h
QgsDataProvider::ProviderOptions
Setting options for creating vector data providers.
Definition: qgsdataprovider.h:104
QgsProviderMetadata::loadStyle
virtual QString loadStyle(const QString &uri, QString &errCause)
Loads a layer style defined by uri.
Definition: qgsprovidermetadata.cpp:192
QgsProviderRegistry::createDb
bool createDb(const QString &providerKey, const QString &dbPath, QString &errCause)
Creates database by the provider on the path.
Definition: qgsproviderregistry.cpp:575
QgsDataProvider
Definition: qgsdataprovider.h:41
QgsDebugMsgLevel
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
QgsProviderRegistry
Definition: qgsproviderregistry.h:54
QgsProviderRegistry::createProviderLibrary
Q_DECL_DEPRECATED QLibrary * createProviderLibrary(const QString &providerKey) const
Returns a new QLibrary for the specified providerKey.
Definition: qgsproviderregistry.cpp:631
QgsProviderRegistry::createTransaction
QgsTransaction * createTransaction(const QString &providerKey, const QString &connString)
Returns new instance of transaction.
Definition: qgsproviderregistry.cpp:587
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsProviderRegistry::~QgsProviderRegistry
virtual ~QgsProviderRegistry()
Definition: qgsproviderregistry.cpp:330
QgsProviderRegistry::encodeUri
QString encodeUri(const QString &providerKey, const QVariantMap &parts)
Reassembles a provider data source URI from its component paths (e.g.
Definition: qgsproviderregistry.cpp:440
QgsFields
Definition: qgsfields.h:44
QgsProviderRegistry::listStyles
int listStyles(const QString &providerKey, const QString &uri, QStringList &ids, QStringList &names, QStringList &descriptions, QString &errCause)
Lists stored layer styles in the provider defined by providerKey and uri.
Definition: qgsproviderregistry.cpp:502
QgsProviderRegistry::providerList
QStringList providerList() const
Returns list of available providers by their keys.
Definition: qgsproviderregistry.cpp:712
QgsProject::removeAllMapLayers
void removeAllMapLayers()
Removes all registered layers.
Definition: qgsproject.cpp:3331
qgsmemoryprovider.h
qgis.h
QgsProject::instance
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:458
QgsProviderRegistry::fileMeshFilters
virtual QString fileMeshFilters() const
Returns mesh file filter string.
Definition: qgsproviderregistry.cpp:687
QgsProviderRegistry::deleteStyleById
bool deleteStyleById(const QString &providerKey, const QString &uri, QString styleId, QString &errCause)
Deletes a layer style defined by styleId.
Definition: qgsproviderregistry.cpp:532
QgsWkbTypes::Type
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:68
QgsProviderMetadata::createEmptyLayer
virtual QgsVectorLayerExporter::ExportError createEmptyLayer(const QString &uri, const QgsFields &fields, QgsWkbTypes::Type wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, QMap< int, int > &oldToNewAttrIdxMap, QString &errorMessage, const QMap< QString, QVariant > *options)
Creates new empty vector layer.
Definition: qgsprovidermetadata.cpp:136
QgsTransaction
Definition: qgstransaction.h:56
QgsProviderRegistry::Providers
std::map< QString, QgsProviderMetadata * > Providers
Type for data provider metadata associative container.
Definition: qgsproviderregistry.h:361
QgsDebugMsg
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
QgsProviderMetadata::getStyleById
virtual QString getStyleById(const QString &uri, QString styleId, QString &errCause)
Gets a layer style defined by uri.
Definition: qgsprovidermetadata.cpp:173
QgsProviderRegistry::dataItemProviders
QList< QgsDataItemProvider * > dataItemProviders(const QString &providerKey) const
Returns list of data item providers of the provider.
Definition: qgsproviderregistry.cpp:493
QgsProviderRegistry::pyramidResamplingMethods
QList< QPair< QString, QString > > pyramidResamplingMethods(const QString &providerKey)
Returns list of raster pyramid resampling methods.
Definition: qgsproviderregistry.cpp:484
QgsProviderMetadata::createRasterDataProvider
virtual QgsRasterDataProvider * createRasterDataProvider(const QString &uri, const QString &format, int nBands, Qgis::DataType type, int width, int height, double *geoTransform, const QgsCoordinateReferenceSystem &crs, const QStringList &createOptions=QStringList())
Creates a new instance of the raster data provider.
Definition: qgsprovidermetadata.cpp:146
QgsProviderRegistry::WidgetMode
WidgetMode
Different ways a source select dialog can be used.
Definition: qgsproviderregistry.h:63
QgsProviderRegistry::createEmptyLayer
QgsVectorLayerExporter::ExportError createEmptyLayer(const QString &providerKey, const QString &uri, const QgsFields &fields, QgsWkbTypes::Type wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, QMap< int, int > &oldToNewAttrIdxMap, QString &errorMessage, const QMap< QString, QVariant > *options)
Creates new empty vector layer.
Definition: qgsproviderregistry.cpp:449
Q_NOWARN_DEPRECATED_POP
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:752
QgsProviderRegistry::setLibraryDirectory
void setLibraryDirectory(const QDir &path)
Sets library directory where to search for plugins.
Definition: qgsproviderregistry.cpp:384
QgsProviderRegistry::getStyleById
QString getStyleById(const QString &providerKey, const QString &uri, QString styleId, QString &errCause)
Gets a layer style defined by styleId.
Definition: qgsproviderregistry.cpp:517
qgsprovidermetadata.h
QgsProviderMetadata::encodeUri
virtual QString encodeUri(const QVariantMap &parts)
Reassembles a provider data source URI from its component paths (e.g.
Definition: qgsprovidermetadata.cpp:131
QgsProviderRegistry::pluginList
QString pluginList(bool asHtml=false) const
Returns list of provider plugins found.
Definition: qgsproviderregistry.cpp:351
qgsproviderregistry.h
QgsProviderRegistry::createRasterDataProvider
virtual QgsRasterDataProvider * createRasterDataProvider(const QString &providerKey, const QString &uri, const QString &format, int nBands, Qgis::DataType type, int width, int height, double *geoTransform, const QgsCoordinateReferenceSystem &crs, const QStringList &createOptions=QStringList())
Creates new instance of raster data provider.
Definition: qgsproviderregistry.cpp:472
QgsDataItemProvider
Definition: qgsdataitemprovider.h:45
QgsProviderMetadata::key
QString key() const
This returns the unique key associated with the provider.
Definition: qgsprovidermetadata.cpp:43
QgsProviderMetadata::listStyles
virtual int listStyles(const QString &uri, QStringList &ids, QStringList &names, QStringList &descriptions, QString &errCause)
Lists stored layer styles in the provider defined by uri.
Definition: qgsprovidermetadata.cpp:166
QgsProviderRegistry::function
Q_DECL_DEPRECATED QFunctionPointer function(const QString &providerKey, const QString &functionName)
Gets pointer to provider function.
Definition: qgsproviderregistry.cpp:607
QgsProviderRegistry::fileRasterFilters
virtual QString fileRasterFilters() const
Returns raster file filter string.
Definition: qgsproviderregistry.cpp:682
QgsProviderRegistry::decodeUri
QVariantMap decodeUri(const QString &providerKey, const QString &uri)
Breaks a provider data source URI into its component paths (e.g.
Definition: qgsproviderregistry.cpp:431
QgsProviderRegistry::providerMetadata
QgsProviderMetadata * providerMetadata(const QString &providerKey) const
Returns metadata of the provider or nullptr if not found.
Definition: qgsproviderregistry.cpp:722
QgsProviderRegistry::providerCapabilities
Q_DECL_DEPRECATED int providerCapabilities(const QString &providerKey) const
Returns the provider capabilities.
Definition: qgsproviderregistry.cpp:419
QgsVectorLayerExporter::ErrInvalidProvider
@ ErrInvalidProvider
Could not find a matching provider key.
Definition: qgsvectorlayerexporter.h:61
QgsCoordinateReferenceSystem
Definition: qgscoordinatereferencesystem.h:206
QgsProviderMetadata::createTransaction
virtual QgsTransaction * createTransaction(const QString &connString)
Returns new instance of transaction.
Definition: qgsprovidermetadata.cpp:204
QgsProviderRegistry::directoryDrivers
virtual QString directoryDrivers() const
Returns a string containing the available directory drivers.
Definition: qgsproviderregistry.cpp:702
QgsProviderMetadata
Definition: qgsprovidermetadata.h:126
qgsvectorlayer.h
QgsProviderMetadata::saveStyle
virtual bool saveStyle(const QString &uri, const QString &qmlStyle, const QString &sldStyle, const QString &styleName, const QString &styleDescription, const QString &uiFileContent, bool useAsDefault, QString &errCause)
Saves a layer style to provider.
Definition: qgsprovidermetadata.cpp:185
qgsvectortileprovidermetadata.h
QgsProviderRegistry::fileMeshDatasetFilters
virtual QString fileMeshDatasetFilters() const
Returns mesh's dataset file filter string.
Definition: qgsproviderregistry.cpp:692
QgsProviderRegistry::loadStyle
QString loadStyle(const QString &providerKey, const QString &uri, QString &errCause)
Loads a layer style defined by uri.
Definition: qgsproviderregistry.cpp:562
QgsProviderMetadata::deleteStyleById
virtual bool deleteStyleById(const QString &uri, QString styleId, QString &errCause)
Deletes a layer style defined by styleId.
Definition: qgsprovidermetadata.cpp:179
qgsdataitemprovider.h
QgsVectorLayerExporter::ExportError
ExportError
Error codes.
Definition: qgsvectorlayerexporter.h:51
QgsProviderRegistry::registerProvider
bool registerProvider(QgsProviderMetadata *providerMetadata)
register a new vector data provider from its providerMetadata
Definition: qgsproviderregistry.cpp:656
QgsProviderRegistry::saveStyle
bool saveStyle(const QString &providerKey, const QString &uri, const QString &qmlStyle, const QString &sldStyle, const QString &styleName, const QString &styleDescription, const QString &uiFileContent, bool useAsDefault, QString &errCause)
Saves a layer style to provider.
Definition: qgsproviderregistry.cpp:546
QgsProviderRegistry::databaseDrivers
virtual QString databaseDrivers() const
Returns a string containing the available database drivers.
Definition: qgsproviderregistry.cpp:697
QgsProviderMetadata::FilterType::FilterMesh
@ FilterMesh
QgsProviderMetadata::library
Q_DECL_DEPRECATED QString library() const
This returns the library file name.
Definition: qgsprovidermetadata.cpp:53
QgsScopedRuntimeProfile
Definition: qgsruntimeprofiler.h:115
QgsMessageLog::logMessage
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).
Definition: qgsmessagelog.cpp:27
QgsDataProvider::NoDataCapabilities
@ NoDataCapabilities
Definition: qgsdataprovider.h:75
qgsdataprovider.h
QgsProviderMetadata::initProvider
virtual void initProvider()
Initialize the provider.
Definition: qgsprovidermetadata.cpp:63
cast_to_fptr
#define cast_to_fptr(f)
Definition: qgis.h:208
QgsProviderRegistry::fileVectorFilters
virtual QString fileVectorFilters() const
Returns vector file filter string.
Definition: qgsproviderregistry.cpp:677
QgsProviderMetadata::FilterType::FilterVector
@ FilterVector
QgsProviderRegistry::protocolDrivers
virtual QString protocolDrivers() const
Returns a string containing the available protocol drivers.
Definition: qgsproviderregistry.cpp:707
qgslogger.h
QgsProviderRegistry::library
Q_DECL_DEPRECATED QString library(const QString &providerKey) const
Returns path for the library of the provider.
Definition: qgsproviderregistry.cpp:337
QgsProviderRegistry::libraryDirectory
QDir libraryDirectory() const
Returns the library directory where plugins are found.
Definition: qgsproviderregistry.cpp:391
QgsProviderRegistry::createSelectionWidget
Q_DECL_DEPRECATED 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.
Definition: qgsproviderregistry.cpp:596
QgsProviderMetadata::pyramidResamplingMethods
virtual QList< QPair< QString, QString > > pyramidResamplingMethods()
Returns pyramid resampling methods available for provider.
Definition: qgsprovidermetadata.cpp:156
QgsProviderRegistry::registerGuis
Q_DECL_DEPRECATED void registerGuis(QWidget *widget)
Definition: qgsproviderregistry.cpp:651
Q_NOWARN_DEPRECATED_PUSH
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:751
QgsProviderRegistry::instance
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
Definition: qgsproviderregistry.cpp:48
QgsRasterDataProvider
Definition: qgsrasterdataprovider.h:88
qgsproject.h
QgsProviderMetadata::filters
virtual QString filters(FilterType type)
Builds the list of file filter strings (supported formats)
Definition: qgsprovidermetadata.cpp:73
QgsProviderMetadata::decodeUri
virtual QVariantMap decodeUri(const QString &uri)
Breaks a provider data source URI into its component paths (e.g.
Definition: qgsprovidermetadata.cpp:126
QgsProviderMetadata::createDb
virtual bool createDb(const QString &dbPath, QString &errCause)
Creates database by the provider on the path.
Definition: qgsprovidermetadata.cpp:198
QgsProviderMetadata::FilterType::FilterMeshDataset
@ FilterMeshDataset
qgsmessagelog.h
QgsProviderMetadata::FilterType::FilterRaster
@ FilterRaster
QgsProviderMetadata::createProvider
virtual QgsDataProvider * createProvider(const QString &uri, const QgsDataProvider::ProviderOptions &options)
Class factory to return a pointer to a newly created QgsDataProvider object.
Definition: qgsprovidermetadata.cpp:83