QGIS API Documentation 3.39.0-Master (3783037d301)
Loading...
Searching...
No Matches
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 "qgis.h"
22#include "qgsdataprovider.h"
23#include "qgsdataitemprovider.h"
24#include "qgslogger.h"
25#include "qgsmessagelog.h"
26#include "qgsprovidermetadata.h"
29#include "qgsproject.h"
32#include "providers/gdal/qgsgdalprovider.h"
33#include "providers/ogr/qgsogrprovidermetadata.h"
34#include "providers/ogr/qgsogrprovider.h"
35#include "providers/meshmemory/qgsmeshmemorydataprovider.h"
37
42
45
46#ifdef HAVE_EPT
47#include "providers/ept/qgseptprovider.h"
48#endif
49
50#ifdef HAVE_COPC
51#include "providers/copc/qgscopcprovider.h"
52#include "providers/vpc/qgsvirtualpointcloudprovider.h"
53#endif
54
55#include "qgsruntimeprofiler.h"
56#include "qgsfileutils.h"
57
58#ifdef HAVE_STATIC_PROVIDERS
59#include "qgswmsprovider.h"
60#include "qgswcsprovider.h"
61#include "qgsdelimitedtextprovider.h"
62#include "qgsafsprovider.h"
63#include "qgsamsprovider.h"
64#ifdef HAVE_SPATIALITE
65#include "qgsspatialiteprovider.h"
66#include "qgswfsprovider.h"
67#include "qgswfsprovidermetadata.h"
68#include "qgsoapifprovider.h"
69#include "qgsvirtuallayerprovider.h"
70#endif
71#ifdef HAVE_POSTGRESQL
72#include "qgspostgresprovider.h"
73#endif
74#endif
75
76#include <QString>
77#include <QDir>
78#include <QLibrary>
79#include <QRegularExpression>
80
81static QgsProviderRegistry *sInstance = nullptr;
82
84{
85 if ( !sInstance )
86 {
87 static QMutex sMutex;
88 const QMutexLocker locker( &sMutex );
89 if ( !sInstance )
90 {
91 sInstance = new QgsProviderRegistry( pluginPath );
92 }
93 }
94 return sInstance;
95} // QgsProviderRegistry::instance
96
97
106static
107QgsProviderMetadata *findMetadata_( const QgsProviderRegistry::Providers &metaData,
108 const QString &providerKey )
109{
110 // first do case-sensitive match
111 const QgsProviderRegistry::Providers::const_iterator i =
112 metaData.find( providerKey );
113
114 if ( i != metaData.end() )
115 {
116 return i->second;
117 }
118
119 // fallback to case-insensitive match
120 for ( auto it = metaData.begin(); it != metaData.end(); ++it )
121 {
122 if ( providerKey.compare( it->first, Qt::CaseInsensitive ) == 0 )
123 return it->second;
124 }
125
126 return nullptr;
127}
128
129QgsProviderRegistry::QgsProviderRegistry( const QString &pluginPath )
130{
131 // At startup, examine the libs in the qgis/lib dir and store those that
132 // are a provider shared lib
133 // check all libs in the current plugin directory and get name and descriptions
134 //TODO figure out how to register and identify data source plugin for a specific
135 //TODO layer type
136#if 0
137 char **argv = qApp->argv();
138 QString appDir = argv[0];
139 int bin = appDir.findRev( "/bin", -1, false );
140 QString baseDir = appDir.left( bin );
141 QString mLibraryDirectory = baseDir + "/lib";
142#endif
143
144 const QgsScopedRuntimeProfile profile( QObject::tr( "Initialize data providers" ) );
145 mLibraryDirectory.setPath( pluginPath );
146 init();
147}
148
150class PdalUnusableUriHandlerInterface : public QgsProviderRegistry::UnusableUriHandlerInterface
151{
152 public:
153 bool matchesUri( const QString &uri ) const override
154 {
155 const QFileInfo fi( uri );
156 if ( fi.suffix().compare( QLatin1String( "las" ), Qt::CaseInsensitive ) == 0 || fi.suffix().compare( QLatin1String( "laz" ), Qt::CaseInsensitive ) == 0 )
157 return true;
158
159 return false;
160 }
161
162 QgsProviderRegistry::UnusableUriDetails details( const QString &uri ) const override
163 {
165 QObject::tr( "LAS and LAZ files cannot be opened by this QGIS install." ),
166 QList<Qgis::LayerType>() << Qgis::LayerType::PointCloud );
167
168#ifdef Q_OS_WIN
169 res.detailedWarning = QObject::tr( "The installer used to install this version of QGIS does "
170 "not include the PDAL library required for opening LAS and LAZ point clouds. Please "
171 "obtain one of the alternative installers from https://qgis.org which has point "
172 "cloud support enabled." );
173#else
174 res.detailedWarning = QObject::tr( "This QGIS build does not include the PDAL library dependency required for opening LAS or LAZ point clouds." );
175#endif
176 return res;
177 }
178};
180
181void QgsProviderRegistry::init()
182{
183 // add static providers
184 {
185 const QgsScopedRuntimeProfile profile( QObject::tr( "Create memory layer provider" ) );
186 mProviders[ QgsMemoryProvider::providerKey() ] = new QgsMemoryProviderMetadata();
187 }
188 {
189 const QgsScopedRuntimeProfile profile( QObject::tr( "Create mesh memory layer provider" ) );
190 mProviders[ QgsMeshMemoryDataProvider::providerKey() ] = new QgsMeshMemoryProviderMetadata();
191 }
192 {
193 const QgsScopedRuntimeProfile profile( QObject::tr( "Create GDAL provider" ) );
194 mProviders[ QgsGdalProvider::providerKey() ] = new QgsGdalProviderMetadata();
195 }
196 {
197 const QgsScopedRuntimeProfile profile( QObject::tr( "Create OGR provider" ) );
198 mProviders[ QgsOgrProvider::providerKey() ] = new QgsOgrProviderMetadata();
199 }
200 {
201 const QgsScopedRuntimeProfile profile( QObject::tr( "Create OGC SensorThings API provider" ) );
202 mProviders[ QgsSensorThingsProvider::providerKey() ] = new QgsSensorThingsProviderMetadata();
203 }
204 {
205 const QgsScopedRuntimeProfile profile( QObject::tr( "Create vector tile providers" ) );
206 QgsProviderMetadata *vt = new QgsVectorTileProviderMetadata();
207 mProviders[ vt->key() ] = vt;
208 vt = new QgsXyzVectorTileDataProviderMetadata();
209 mProviders[ vt->key() ] = vt;
210 vt = new QgsVtpkVectorTileDataProviderMetadata();
211 mProviders[ vt->key() ] = vt;
212 vt = new QgsArcGisVectorTileServiceDataProviderMetadata();
213 mProviders[ vt->key() ] = vt;
214 vt = new QgsMbTilesVectorTileDataProviderMetadata();
215 mProviders[ vt->key() ] = vt;
216 }
217#ifdef HAVE_EPT
218 {
219 const QgsScopedRuntimeProfile profile( QObject::tr( "Create EPT point cloud provider" ) );
220 QgsProviderMetadata *pc = new QgsEptProviderMetadata();
221 mProviders[ pc->key() ] = pc;
222 }
223#endif
224#ifdef HAVE_COPC
225 {
226 const QgsScopedRuntimeProfile profile( QObject::tr( "Create COPC point cloud provider" ) );
227 QgsProviderMetadata *pc = new QgsCopcProviderMetadata();
228 mProviders[ pc->key() ] = pc;
229 }
230 {
231 const QgsScopedRuntimeProfile profile( QObject::tr( "Create Virtual point cloud provider" ) );
232 QgsProviderMetadata *pc = new QgsVirtualPointCloudProviderMetadata();
233 mProviders[ pc->key() ] = pc;
234 }
235#endif
236 registerUnusableUriHandler( new PdalUnusableUriHandlerInterface() );
237
238 {
239 const QgsScopedRuntimeProfile profile( QObject::tr( "Create tiled scene providers" ) );
240 QgsProviderMetadata *metadata = new QgsTiledSceneProviderMetadata();
241 mProviders[ metadata->key() ] = metadata;
242
243 metadata = new QgsCesiumTilesProviderMetadata();
244 mProviders[ metadata->key() ] = metadata;
245
246 metadata = new QgsQuantizedMeshProviderMetadata();
247 mProviders[ metadata->key() ] = metadata;
248 }
249
250#ifdef HAVE_STATIC_PROVIDERS
251 mProviders[ QgsWmsProvider::providerKey() ] = new QgsWmsProviderMetadata();
252 mProviders[ QgsWcsProvider::providerKey() ] = new QgsWcsProviderMetadata();
253 mProviders[ QgsDelimitedTextProvider::providerKey() ] = new QgsDelimitedTextProviderMetadata();
254 mProviders[ QgsAfsProvider::providerKey() ] = new QgsAfsProviderMetadata();
255 mProviders[ QgsAmsProvider::providerKey() ] = new QgsAmsProviderMetadata();
256#ifdef HAVE_SPATIALITE
257 mProviders[ QgsSpatiaLiteProvider::providerKey() ] = new QgsSpatiaLiteProviderMetadata();
258 mProviders[ QgsWFSProvider::providerKey() ] = new QgsWfsProviderMetadata();
259 mProviders[ QgsOapifProvider::providerKey() ] = new QgsOapifProviderMetadata();
260 mProviders[ QgsVirtualLayerProvider::providerKey() ] = new QgsVirtualLayerProviderMetadata();
261#endif
262#ifdef HAVE_POSTGRESQL
263 mProviders[ QgsPostgresProvider::providerKey() ] = new QgsPostgresProviderMetadata();
264#endif
265#endif
266
267 // add dynamic providers
268#ifdef HAVE_STATIC_PROVIDERS
269 QgsDebugMsgLevel( QStringLiteral( "Forced only static providers" ), 2 );
270#else
271 typedef QgsProviderMetadata *factory_function( );
272
273 mLibraryDirectory.setSorting( QDir::Name | QDir::IgnoreCase );
274 mLibraryDirectory.setFilter( QDir::Files | QDir::NoSymLinks );
275
276#if defined(Q_OS_WIN) || defined(__CYGWIN__)
277 mLibraryDirectory.setNameFilters( QStringList( "*.dll" ) );
278#elif defined(ANDROID)
279 mLibraryDirectory.setNameFilters( QStringList( "*provider_*.so" ) );
280#else
281 mLibraryDirectory.setNameFilters( QStringList( QStringLiteral( "*.so" ) ) );
282#endif
283
284 QgsDebugMsgLevel( QStringLiteral( "Checking %1 for provider plugins" ).arg( mLibraryDirectory.path() ), 2 );
285
286 if ( mLibraryDirectory.count() == 0 )
287 {
288 QgsDebugError( QStringLiteral( "No dynamic QGIS data provider plugins found in:\n%1\n" ).arg( mLibraryDirectory.path() ) );
289 }
290
291 // provider file regex pattern, only files matching the pattern are loaded if the variable is defined
292 const QString filePattern = getenv( "QGIS_PROVIDER_FILE" );
293 QRegularExpression fileRegexp;
294 if ( !filePattern.isEmpty() )
295 {
296 fileRegexp.setPattern( filePattern );
297 }
298
299 typedef std::vector<QgsProviderMetadata *> *multiple_factory_function();
300
301 const auto constEntryInfoList = mLibraryDirectory.entryInfoList();
302 for ( const QFileInfo &fi : constEntryInfoList )
303 {
304 if ( !filePattern.isEmpty() )
305 {
306 if ( fi.fileName().indexOf( fileRegexp ) == -1 )
307 {
308 QgsDebugMsgLevel( "provider " + fi.fileName() + " skipped because doesn't match pattern " + filePattern, 2 );
309 continue;
310 }
311 }
312
313 // Always skip authentication methods
314 if ( fi.fileName().contains( QStringLiteral( "authmethod" ), Qt::CaseSensitivity::CaseInsensitive ) )
315 {
316 continue;
317 }
318
319 const QgsScopedRuntimeProfile profile( QObject::tr( "Load %1" ).arg( fi.fileName() ) );
320 QLibrary myLib( fi.filePath() );
321 if ( !myLib.load() )
322 {
323 QgsDebugError( QStringLiteral( "Checking %1: ...invalid (lib not loadable): %2" ).arg( myLib.fileName(), myLib.errorString() ) );
324 continue;
325 }
326
327 bool libraryLoaded { false };
328 QFunctionPointer func = myLib.resolve( QStringLiteral( "providerMetadataFactory" ).toLatin1().data() );
329 factory_function *function = reinterpret_cast< factory_function * >( cast_to_fptr( func ) );
330 if ( function )
331 {
333 if ( meta )
334 {
335 if ( findMetadata_( mProviders, meta->key() ) )
336 {
337 QgsDebugError( QStringLiteral( "Checking %1: ...invalid (key %2 already registered)" ).arg( myLib.fileName() ).arg( meta->key() ) );
338 delete meta;
339 continue;
340 }
341 // add this provider to the provider map
342 mProviders[meta->key()] = meta;
343 libraryLoaded = true;
344 }
345 }
346 else
347 {
348 QFunctionPointer multi_func = myLib.resolve( QStringLiteral( "multipleProviderMetadataFactory" ).toLatin1().data() );
349 multiple_factory_function *multi_function = reinterpret_cast< multiple_factory_function * >( cast_to_fptr( multi_func ) );
350 if ( multi_function )
351 {
352 std::vector<QgsProviderMetadata *> *metadatas = multi_function();
353 for ( const auto meta : *metadatas )
354 {
355 if ( findMetadata_( mProviders, meta->key() ) )
356 {
357 QgsDebugError( QStringLiteral( "Checking %1: ...invalid (key %2 already registered)" ).arg( myLib.fileName() ).arg( meta->key() ) );
358 delete meta;
359 continue;
360 }
361 // add this provider to the provider map
362 mProviders[meta->key()] = meta;
363 libraryLoaded = true;
364 }
365 delete metadatas;
366 }
367 }
368
369 if ( ! libraryLoaded )
370 {
371 QgsDebugMsgLevel( QStringLiteral( "Checking %1: ...invalid (no providerMetadataFactory method)" ).arg( myLib.fileName() ), 2 );
372 }
373 }
374
375#endif
376 QgsDebugMsgLevel( QStringLiteral( "Loaded %1 providers (%2) " ).arg( mProviders.size() ).arg( providerList().join( ';' ) ), 1 );
377
378 // now initialize all providers
379 for ( Providers::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
380 {
381 const QString &key = it->first;
382
383 const QgsScopedRuntimeProfile profile( QObject::tr( "Initialize %1" ).arg( key ) );
384
385 QgsProviderMetadata *meta = it->second;
386
387 // call initProvider() - allows provider to register its services to QGIS
388 meta->initProvider();
389 }
390
391 rebuildFilterStrings();
392
393 // load database drivers (only OGR)
394 mDatabaseDrivers = QgsOgrProviderUtils::databaseDrivers();
395
396 // load directory drivers (only OGR)
397 mDirectoryDrivers = QgsOgrProviderUtils::directoryDrivers();
398
399 // load protocol drivers (only OGR)
400 mProtocolDrivers = QgsOgrProviderUtils::protocolDrivers();
401}
402
403void QgsProviderRegistry::rebuildFilterStrings()
404{
405 mVectorFileFilters.clear();
406 mRasterFileFilters.clear();
407 mMeshFileFilters.clear();
408 mMeshDatasetFileFilters.clear();
409 mPointCloudFileFilters.clear();
410 mVectorTileFileFilters.clear();
411 mTiledSceneFileFilters.clear();
412
413 QStringList pointCloudWildcards;
414 QStringList pointCloudFilters;
415
416 QStringList vectorTileWildcards;
417 QStringList vectorTileFilters;
418
419 QStringList tiledSceneWildcards;
420 QStringList tiledSceneFilters;
421
422 for ( Providers::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
423 {
424 QgsProviderMetadata *meta = it->second;
425
426 // now get vector file filters, if any
428 if ( !fileVectorFilters.isEmpty() )
429 {
430 mVectorFileFilters += fileVectorFilters;
431 QgsDebugMsgLevel( QStringLiteral( "Checking %1: ...loaded OK (%2 file filters)" ).arg( it->first ).arg( fileVectorFilters.split( ";;" ).count() ), 2 );
432 }
433
434 // now get raster file filters, if any
436 if ( !fileRasterFilters.isEmpty() )
437 {
438 QgsDebugMsgLevel( "raster filters: " + fileRasterFilters, 2 );
439 mRasterFileFilters += fileRasterFilters;
440 QgsDebugMsgLevel( QStringLiteral( "Checking %1: ...loaded OK (%2 file filters)" ).arg( it->first ).arg( fileRasterFilters.split( ";;" ).count() ), 2 );
441 }
442
443 // now get mesh file filters, if any
444 const QString fileMeshFilters = meta->filters( Qgis::FileFilterType::Mesh );
445 if ( !fileMeshFilters.isEmpty() )
446 {
447 mMeshFileFilters += fileMeshFilters;
448 QgsDebugMsgLevel( QStringLiteral( "Checking %1: ...loaded OK (%2 file mesh filters)" ).arg( it->first ).arg( mMeshFileFilters.split( ";;" ).count() ), 2 );
449
450 }
451
453 if ( !fileMeshDatasetFilters.isEmpty() )
454 {
455 mMeshDatasetFileFilters += fileMeshDatasetFilters;
456 QgsDebugMsgLevel( QStringLiteral( "Checking %1: ...loaded OK (%2 file dataset filters)" ).arg( it->first ).arg( mMeshDatasetFileFilters.split( ";;" ).count() ), 2 );
457 }
458
459 // now get point cloud file filters, if any
461 if ( !filePointCloudFilters.isEmpty() )
462 {
463 QgsDebugMsgLevel( "point cloud filters: " + filePointCloudFilters, 2 );
464
465 const QStringList filters = filePointCloudFilters.split( QStringLiteral( ";;" ), Qt::SkipEmptyParts );
466 for ( const QString &filter : filters )
467 {
468 pointCloudFilters.append( filter );
469 pointCloudWildcards.append( QgsFileUtils::wildcardsFromFilter( filter ).split( ' ' ) );
470 }
471 }
472
473 // now get vector tile file filters, if any
475 if ( !fileVectorTileFilters.isEmpty() )
476 {
477 QgsDebugMsgLevel( "vector tile filters: " + fileVectorTileFilters, 2 );
478
479 const QStringList filters = fileVectorTileFilters.split( QStringLiteral( ";;" ), Qt::SkipEmptyParts );
480 for ( const QString &filter : filters )
481 {
482 vectorTileFilters.append( filter );
483 vectorTileWildcards.append( QgsFileUtils::wildcardsFromFilter( filter ).split( ' ' ) );
484 }
485 }
486
487 // now get tiled scene file filters, if any
489 if ( !fileTiledSceneFilters.isEmpty() )
490 {
491 QgsDebugMsgLevel( "tiled scene filters: " + fileTiledSceneFilters, 2 );
492
493 const QStringList filters = fileTiledSceneFilters.split( QStringLiteral( ";;" ), Qt::SkipEmptyParts );
494 for ( const QString &filter : filters )
495 {
496 tiledSceneFilters.append( filter );
497 tiledSceneWildcards.append( QgsFileUtils::wildcardsFromFilter( filter ).split( ' ' ) );
498 }
499 }
500 }
501
502 if ( !pointCloudFilters.empty() )
503 {
504 pointCloudFilters.insert( 0, QObject::tr( "All Supported Files" ) + QStringLiteral( " (%1)" ).arg( pointCloudWildcards.join( ' ' ) ) );
505 pointCloudFilters.insert( 1, QObject::tr( "All Files" ) + QStringLiteral( " (*.*)" ) );
506 mPointCloudFileFilters = pointCloudFilters.join( QLatin1String( ";;" ) );
507 }
508
509 if ( !vectorTileFilters.empty() )
510 {
511 vectorTileFilters.insert( 0, QObject::tr( "All Supported Files" ) + QStringLiteral( " (%1)" ).arg( vectorTileWildcards.join( ' ' ) ) );
512 vectorTileFilters.insert( 1, QObject::tr( "All Files" ) + QStringLiteral( " (*.*)" ) );
513 mVectorTileFileFilters = vectorTileFilters.join( QLatin1String( ";;" ) );
514 }
515
516 if ( !tiledSceneFilters.empty() )
517 {
518 tiledSceneFilters.insert( 0, QObject::tr( "All Supported Files" ) + QStringLiteral( " (%1)" ).arg( tiledSceneWildcards.join( ' ' ) ) );
519 tiledSceneFilters.insert( 1, QObject::tr( "All Files" ) + QStringLiteral( " (*.*)" ) );
520 mTiledSceneFileFilters = tiledSceneFilters.join( QLatin1String( ";;" ) );
521 }
522}
523
524// typedef for the unload dataprovider function
526
527void QgsProviderRegistry::clean()
528{
529 // avoid recreating a new project just to clean it
530 if ( QgsProject::sProject )
532
533 Providers::const_iterator it = mProviders.begin();
534
535 while ( it != mProviders.end() )
536 {
537 QgsDebugMsgLevel( QStringLiteral( "cleanup:%1" ).arg( it->first ), 5 );
538 it->second->cleanupProvider();
539 delete it->second;
540 ++it;
541 }
542 mProviders.clear();
543}
544
545bool QgsProviderRegistry::exists()
546{
547 return static_cast< bool >( sInstance );
548}
549
551{
552 qDeleteAll( mUnusableUriHandlers );
553
554 clean();
555 if ( sInstance == this )
556 sInstance = nullptr;
557}
558
559QString QgsProviderRegistry::library( QString const &providerKey ) const
560{
561 QgsProviderMetadata *md = findMetadata_( mProviders, providerKey );
562
563 if ( md )
564 {
566 return md->library();
568 }
569
570 return QString();
571}
572
573QString QgsProviderRegistry::pluginList( bool asHTML ) const
574{
575 Providers::const_iterator it = mProviders.begin();
576
577 if ( mProviders.empty() )
578 return QObject::tr( "No data provider plugins are available. No vector layers can be loaded" );
579
580 QString list;
581
582 if ( asHTML )
583 list += QLatin1String( "<ol>" );
584
585 while ( it != mProviders.end() )
586 {
587 if ( asHTML )
588 list += QLatin1String( "<li>" );
589
590 list += it->second->description();
591
592 if ( asHTML )
593 list += QLatin1String( "<br></li>" );
594 else
595 list += '\n';
596
597 ++it;
598 }
599
600 if ( asHTML )
601 list += QLatin1String( "</ol>" );
602
603 return list;
604}
605
607{
608 mLibraryDirectory = path;
609 clean();
610 init();
611}
612
614{
615 return mLibraryDirectory;
616}
617
618
619/* Copied from QgsVectorLayer::setDataProvider
620 * TODO: Make it work in the generic environment
621 *
622 * TODO: Is this class really the best place to put a data provider loader?
623 * It seems more sensible to provide the code in one place rather than
624 * in qgsrasterlayer, qgsvectorlayer, serversourceselect, etc.
625 */
626QgsDataProvider *QgsProviderRegistry::createProvider( QString const &providerKey, QString const &dataSource,
629{
630 // XXX should I check for and possibly delete any pre-existing providers?
631 // XXX How often will that scenario occur?
632
633 QgsProviderMetadata *metadata = findMetadata_( mProviders, providerKey );
634 if ( !metadata )
635 {
636 QgsMessageLog::logMessage( QObject::tr( "Invalid data provider %1" ).arg( providerKey ) );
637 return nullptr;
638 }
639
640 return metadata->createProvider( dataSource, options, flags );
641}
642
644{
645 const QList< QgsDataItemProvider * > itemProviders = dataItemProviders( providerKey );
647 //concat flags
648 for ( const QgsDataItemProvider *itemProvider : itemProviders )
649 {
650 ret |= itemProvider->capabilities();
651 }
652 return ret;
653}
654
655QVariantMap QgsProviderRegistry::decodeUri( const QString &providerKey, const QString &uri )
656{
657 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
658 if ( meta )
659 return meta->decodeUri( uri );
660 else
661 return QVariantMap();
662}
663
664QString QgsProviderRegistry::encodeUri( const QString &providerKey, const QVariantMap &parts )
665{
666 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
667 if ( meta )
668 return meta->encodeUri( parts );
669 else
670 return QString();
671}
672
673QString QgsProviderRegistry::absoluteToRelativeUri( const QString &providerKey, const QString &uri, const QgsReadWriteContext &context ) const
674{
675 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
676 if ( meta )
677 return meta->absoluteToRelativeUri( uri, context );
678 else
679 return uri;
680}
681
682QString QgsProviderRegistry::relativeToAbsoluteUri( const QString &providerKey, const QString &uri, const QgsReadWriteContext &context ) const
683{
684 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
685 if ( meta )
686 return meta->relativeToAbsoluteUri( uri, context );
687 else
688 return uri;
689}
690
692 const QString &uri,
693 const QgsFields &fields,
694 Qgis::WkbType wkbType,
696 bool overwrite, QMap<int, int> &oldToNewAttrIdxMap,
697 QString &errorMessage,
698 const QMap<QString, QVariant> *options )
699{
700 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
701 if ( meta )
702 return meta->createEmptyLayer( uri, fields, wkbType, srs, overwrite, oldToNewAttrIdxMap, errorMessage, options );
703 else
704 {
705 errorMessage = QObject::tr( "Unable to load %1 provider" ).arg( providerKey );
707 }
708}
709
710QgsRasterDataProvider *QgsProviderRegistry::createRasterDataProvider( const QString &providerKey, const QString &uri, const QString &format,
711 int nBands, Qgis::DataType type, int width, int height,
712 double *geoTransform, const QgsCoordinateReferenceSystem &crs,
713 const QStringList &createOptions )
714{
715 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
716 if ( meta )
717 return meta->createRasterDataProvider( uri, format, nBands, type, width, height, geoTransform, crs, createOptions );
718 else
719 return nullptr;
720}
721
722QList<QPair<QString, QString> > QgsProviderRegistry::pyramidResamplingMethods( const QString &providerKey )
723{
724 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
725 if ( meta )
726 return meta->pyramidResamplingMethods();
727 else
728 return QList<QPair<QString, QString> >();
729}
730
731QList<QgsDataItemProvider *> QgsProviderRegistry::dataItemProviders( const QString &providerKey ) const
732{
733 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
734 if ( meta )
735 return meta->dataItemProviders();
736 else
737 return QList<QgsDataItemProvider *>();
738}
739
740int QgsProviderRegistry::listStyles( const QString &providerKey, const QString &uri, QStringList &ids, QStringList &names, QStringList &descriptions, QString &errCause )
741{
742 int res = -1;
743 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
744 if ( meta )
745 {
746 res = meta->listStyles( uri, ids, names, descriptions, errCause );
747 }
748 else
749 {
750 errCause = QObject::tr( "Unable to load %1 provider" ).arg( providerKey );
751 }
752 return res;
753}
754
755bool QgsProviderRegistry::styleExists( const QString &providerKey, const QString &uri, const QString &styleId, QString &errorCause )
756{
757 errorCause.clear();
758
759 if ( QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey ) )
760 {
761 return meta->styleExists( uri, styleId, errorCause );
762 }
763 else
764 {
765 errorCause = QObject::tr( "Unable to load %1 provider" ).arg( providerKey );
766 return false;
767 }
768}
769
770QString QgsProviderRegistry::getStyleById( const QString &providerKey, const QString &uri, const QString &styleId, QString &errCause )
771{
772 QString ret;
773 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
774 if ( meta )
775 {
776 ret = meta->getStyleById( uri, styleId, errCause );
777 }
778 else
779 {
780 errCause = QObject::tr( "Unable to load %1 provider" ).arg( providerKey );
781 }
782 return ret;
783}
784
785bool QgsProviderRegistry::deleteStyleById( const QString &providerKey, const QString &uri, const QString &styleId, QString &errCause )
786{
787 const bool ret( false );
788
789 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
790 if ( meta )
791 return meta->deleteStyleById( uri, styleId, errCause );
792 else
793 {
794 errCause = QObject::tr( "Unable to load %1 provider" ).arg( providerKey );
795 }
796 return ret;
797}
798
799bool QgsProviderRegistry::saveStyle( const QString &providerKey, const QString &uri, const QString &qmlStyle,
800 const QString &sldStyle, const QString &styleName, const QString &styleDescription,
801 const QString &uiFileContent, bool useAsDefault, QString &errCause )
802{
803 bool ret( false );
804 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
805 if ( meta )
806 ret = meta->saveStyle( uri, qmlStyle, sldStyle, styleName, styleDescription,
807 uiFileContent, useAsDefault, errCause );
808 else
809 {
810 errCause = QObject::tr( "Unable to load %1 provider" ).arg( providerKey );
811 }
812 return ret;
813}
814
815QString QgsProviderRegistry::loadStyle( const QString &providerKey, const QString &uri, QString &errCause )
816{
817 QString ret;
818 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
819 if ( meta )
820 ret = meta->loadStyle( uri, errCause );
821 else
822 {
823 errCause = QObject::tr( "Unable to load %1 provider" ).arg( providerKey );
824 }
825 return ret;
826}
827
828QString QgsProviderRegistry::loadStoredStyle( const QString &providerKey, const QString &uri, QString &styleName, QString &errCause )
829{
830 QString ret;
831 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
832 if ( meta )
833 ret = meta->loadStoredStyle( uri, styleName, errCause );
834 else
835 {
836 errCause = QObject::tr( "Unable to load %1 provider" ).arg( providerKey );
837 }
838 return ret;
839}
840
841bool QgsProviderRegistry::saveLayerMetadata( const QString &providerKey, const QString &uri, const QgsLayerMetadata &metadata, QString &errorMessage )
842{
843 errorMessage.clear();
844 if ( QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey ) )
845 return meta->saveLayerMetadata( uri, metadata, errorMessage );
846 else
847 {
848 throw QgsNotSupportedException( QObject::tr( "Unable to load %1 provider" ).arg( providerKey ) );
849 }
850}
851
852bool QgsProviderRegistry::createDb( const QString &providerKey, const QString &dbPath, QString &errCause )
853{
854 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
855 if ( meta )
856 return meta->createDb( dbPath, errCause );
857 else
858 {
859 errCause = QStringLiteral( "Resolving createDb(...) failed" );
860 return false;
861 }
862}
863
864QgsTransaction *QgsProviderRegistry::createTransaction( const QString &providerKey, const QString &connString )
865{
866 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
867 if ( meta )
868 return meta->createTransaction( connString );
869 else
870 return nullptr;
871}
872
873QWidget *QgsProviderRegistry::createSelectionWidget( const QString &providerKey,
874 QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode )
875{
876 Q_UNUSED( providerKey );
877 Q_UNUSED( parent );
878 Q_UNUSED( fl );
879 Q_UNUSED( widgetMode );
880 QgsDebugError( "deprecated call - use QgsGui::sourceSelectProviderRegistry()->createDataSourceWidget() instead" );
881 return nullptr;
882}
883
884QFunctionPointer QgsProviderRegistry::function( QString const &providerKey,
885 QString const &functionName ) const
886{
888 const QString lib = library( providerKey );
890 if ( lib.isEmpty() )
891 return nullptr;
892
893 QLibrary myLib( lib );
894
895 QgsDebugMsgLevel( "Library name is " + myLib.fileName(), 2 );
896
897 if ( myLib.load() )
898 {
899 return myLib.resolve( functionName.toLatin1().data() );
900 }
901 else
902 {
903 QgsDebugError( "Cannot load library: " + myLib.errorString() );
904 return nullptr;
905 }
906}
907
908QLibrary *QgsProviderRegistry::createProviderLibrary( QString const &providerKey ) const
909{
911 const QString lib = library( providerKey );
913 if ( lib.isEmpty() )
914 return nullptr;
915
916 std::unique_ptr< QLibrary > myLib( new QLibrary( lib ) );
917
918 QgsDebugMsgLevel( "Library name is " + myLib->fileName(), 2 );
919
920 if ( myLib->load() )
921 return myLib.release();
922
923 QgsDebugError( "Cannot load library: " + myLib->errorString() );
924
925 return nullptr;
926}
927
929{
930 QgsDebugError( "deprecated - use QgsGui::providerGuiRegistry() instead." );
931}
932
934{
935 if ( providerMetadata )
936 {
937 if ( mProviders.find( providerMetadata->key() ) == mProviders.end() )
938 {
939 mProviders[ providerMetadata->key() ] = providerMetadata;
940
941 rebuildFilterStrings();
942 return true;
943 }
944 else
945 {
946 QgsDebugMsgLevel( QStringLiteral( "Cannot register provider metadata: a provider with the same key (%1) was already registered!" ).arg( providerMetadata->key() ), 2 );
947 }
948 }
949 else
950 {
951 QgsDebugMsgLevel( QStringLiteral( "Trying to register a null metadata provider!" ), 2 );
952 }
953 return false;
954}
955
957{
958 return mVectorFileFilters;
959}
960
962{
963 return mRasterFileFilters;
964}
965
967{
968 return mMeshFileFilters;
969}
970
972{
973 return mMeshDatasetFileFilters;
974}
975
977{
978 return mPointCloudFileFilters;
979}
980
982{
983 return mVectorTileFileFilters;
984}
985
987{
988 return mTiledSceneFileFilters;
989}
990
992{
993 return mDatabaseDrivers;
994}
995
997{
998 return mDirectoryDrivers;
999}
1000
1002{
1003 return mProtocolDrivers;
1004}
1005
1007{
1008 QStringList lst;
1009 for ( Providers::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
1010 {
1011 lst.append( it->first );
1012 }
1013 return lst;
1014}
1015
1017{
1018 return findMetadata_( mProviders, providerKey );
1019}
1020
1022{
1023 QSet<QString> lst;
1024 for ( Providers::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
1025 {
1026 if ( it->second->supportedLayerTypes().contains( type ) )
1027 lst.insert( it->first );
1028 }
1029 return lst;
1030}
1031
1032QList<QgsProviderRegistry::ProviderCandidateDetails> QgsProviderRegistry::preferredProvidersForUri( const QString &uri ) const
1033{
1034 QList< QgsProviderRegistry::ProviderCandidateDetails > res;
1035 int maxPriority = 0;
1036 for ( auto it = mProviders.begin(); it != mProviders.end(); ++it )
1037 {
1038 if ( !( it->second->capabilities() & QgsProviderMetadata::PriorityForUri ) )
1039 continue;
1040
1041 const int thisProviderPriority = it->second->priorityForUri( uri );
1042 if ( thisProviderPriority == 0 )
1043 continue;
1044
1045 if ( thisProviderPriority > maxPriority )
1046 {
1047 res.clear();
1048 maxPriority = thisProviderPriority;
1049 }
1050 if ( thisProviderPriority == maxPriority )
1051 {
1052 res.append( ProviderCandidateDetails( it->second, it->second->validLayerTypesForUri( uri ) ) );
1053 }
1054 }
1055 return res;
1056}
1057
1059{
1060 mUnusableUriHandlers << handler;
1061 return true;
1062}
1063
1064bool QgsProviderRegistry::handleUnusableUri( const QString &uri, UnusableUriDetails &details ) const
1065{
1066 for ( const QgsProviderRegistry::UnusableUriHandlerInterface *handler : mUnusableUriHandlers )
1067 {
1068 if ( handler->matchesUri( uri ) )
1069 {
1070 details = handler->details( uri );
1071 return true;
1072 }
1073 }
1074 return false;
1075}
1076
1077bool QgsProviderRegistry::shouldDeferUriForOtherProviders( const QString &uri, const QString &providerKey ) const
1078{
1079 const QList< ProviderCandidateDetails > providers = preferredProvidersForUri( uri );
1080 if ( providers.empty() )
1081 return false;
1082
1083 for ( const ProviderCandidateDetails &provider : providers )
1084 {
1085 if ( provider.metadata()->key() == providerKey )
1086 return false;
1087 }
1088 return true;
1089}
1090
1091bool QgsProviderRegistry::uriIsBlocklisted( const QString &uri ) const
1092{
1093 for ( auto it = mProviders.begin(); it != mProviders.end(); ++it )
1094 {
1095 if ( it->second->uriIsBlocklisted( uri ) )
1096 return true;
1097 }
1098 return false;
1099}
1100
1101QList<QgsProviderSublayerDetails> QgsProviderRegistry::querySublayers( const QString &uri, Qgis::SublayerQueryFlags flags, QgsFeedback *feedback ) const
1102{
1103 // never query sublayers for blocklisted uris
1104 if ( uriIsBlocklisted( uri ) )
1105 return {};
1106
1107 QList<QgsProviderSublayerDetails> res;
1108 for ( auto it = mProviders.begin(); it != mProviders.end(); ++it )
1109 {
1110 // if we should defer this uri for other providers, do so
1111 if ( shouldDeferUriForOtherProviders( uri, it->first ) )
1112 continue;
1113
1114 res.append( it->second->querySublayers( uri, flags, feedback ) );
1115 if ( feedback && feedback->isCanceled() )
1116 break;
1117 }
1118 return res;
1119}
@ TiledScene
Tiled scene layers.
@ Vector
Vector layers.
@ VectorTile
Vector tile layers.
@ Mesh
Mesh layers.
@ Raster
Raster layers.
@ MeshDataset
Mesh datasets.
@ PointCloud
Point clouds.
VectorExportResult
Vector layer export result codes.
Definition qgis.h:983
@ ErrorInvalidProvider
Could not find a matching provider key.
QFlags< DataItemProviderCapability > DataItemProviderCapabilities
Capabilities for data item providers.
Definition qgis.h:926
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:450
DataType
Raster data types.
Definition qgis.h:351
QFlags< SublayerQueryFlag > SublayerQueryFlags
Sublayer query flags.
Definition qgis.h:1309
LayerType
Types of layers that can be added to a map.
Definition qgis.h:169
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:256
This class represents a coordinate reference system (CRS).
This is the interface for those who want to add custom data items to the browser tree.
Abstract base class for spatial data provider implementations.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
bool isCanceled() const
Tells whether the operation has been canceled already.
Definition qgsfeedback.h:53
Container of fields for a vector layer.
Definition qgsfields.h:46
static QString wildcardsFromFilter(const QString &filter)
Given a filter string like GeoTIFF Files (*.tiff *.tif), extracts the wildcard portion of this filter...
A structured metadata store for a map layer.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
Custom exception class which is raised when an operation is not supported.
static QgsProject * instance()
Returns the QgsProject singleton instance.
void removeAllMapLayers()
Removes all registered layers.
Holds data provider key, description, and associated shared library file or function pointer informat...
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.
virtual QgsDataProvider * createProvider(const QString &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags=Qgis::DataProviderReadFlags())
Class factory to return a pointer to a newly created QgsDataProvider object.
virtual bool deleteStyleById(const QString &uri, const QString &styleId, QString &errCause)
Deletes a layer style defined by styleId.
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.
virtual QString encodeUri(const QVariantMap &parts) const
Reassembles a provider data source URI from its component paths (e.g.
virtual QString absoluteToRelativeUri(const QString &uri, const QgsReadWriteContext &context) const
Converts absolute path(s) to relative path(s) in the given provider-specific URI.
virtual Qgis::VectorExportResult createEmptyLayer(const QString &uri, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, QMap< int, int > &oldToNewAttrIdxMap, QString &errorMessage, const QMap< QString, QVariant > *options)
Creates new empty vector layer.
virtual bool styleExists(const QString &uri, const QString &styleId, QString &errorCause)
Returns true if a layer style with the specified styleId exists in the provider defined by uri.
virtual bool saveLayerMetadata(const QString &uri, const QgsLayerMetadata &metadata, QString &errorMessage)
Saves metadata to the layer corresponding to the specified uri.
virtual QString filters(Qgis::FileFilterType type)
Builds the list of file filter strings (supported formats)
QString key() const
This returns the unique key associated with the provider.
virtual QgsTransaction * createTransaction(const QString &connString)
Returns new instance of transaction.
virtual void initProvider()
Initialize the provider.
virtual QString getStyleById(const QString &uri, const QString &styleId, QString &errCause)
Gets a layer style defined by uri.
virtual QString loadStoredStyle(const QString &uri, QString &styleName, QString &errCause)
Loads a layer style from the provider storage, reporting its name.
@ PriorityForUri
Indicates that the metadata can calculate a priority for a URI.
virtual QString relativeToAbsoluteUri(const QString &uri, const QgsReadWriteContext &context) const
Converts relative path(s) to absolute path(s) in the given provider-specific URI.
virtual QString loadStyle(const QString &uri, QString &errCause)
Loads a layer style defined by uri.
virtual int listStyles(const QString &uri, QStringList &ids, QStringList &names, QStringList &descriptions, QString &errCause)
Lists stored layer styles in the provider defined by uri.
virtual QList< QPair< QString, QString > > pyramidResamplingMethods()
Returns pyramid resampling methods available for provider.
virtual QList< QgsDataItemProvider * > dataItemProviders() const
Returns data item providers.
virtual QVariantMap decodeUri(const QString &uri) const
Breaks a provider data source URI into its component paths (e.g.
Q_DECL_DEPRECATED QString library() const
This returns the library file name.
virtual bool createDb(const QString &dbPath, QString &errCause)
Creates database by the provider on the path.
Contains information pertaining to a candidate provider.
Contains information about unusable URIs which aren't handled by any registered providers.
QString detailedWarning
Contains a longer, user-friendly, translated message advising why the URI is not usable.
An interface used to handle unusable URIs which aren't handled by any registered providers,...
virtual UnusableUriDetails details(const QString &uri) const =0
Returns the details for advising the user why the uri is not usable.
virtual bool matchesUri(const QString &uri) const =0
Returns true if the handle is an unusable URI handler for the specified uri.
A registry / canonical manager of data providers.
QString absoluteToRelativeUri(const QString &providerKey, const QString &uri, const QgsReadWriteContext &context) const
Converts absolute path(s) to relative path(s) in the given provider-specific URI.
std::map< QString, QgsProviderMetadata * > Providers
Type for data provider metadata associative container.
bool styleExists(const QString &providerKey, const QString &uri, const QString &styleId, QString &errorCause)
Returns true if a layer style with the specified styleId exists in the provider defined by providerKe...
QString loadStyle(const QString &providerKey, const QString &uri, QString &errCause)
Loads a layer style defined by uri.
QString getStyleById(const QString &providerKey, const QString &uri, const QString &styleId, QString &errCause)
Gets a layer style defined by styleId.
QVariantMap decodeUri(const QString &providerKey, const QString &uri)
Breaks a provider data source URI into its component paths (e.g.
void setLibraryDirectory(const QDir &path)
Sets library directory where to search for plugins.
QString fileVectorTileFilters() const
Returns a file filter string for supported vector tile files.
QgsTransaction * createTransaction(const QString &providerKey, const QString &connString)
Returns new instance of transaction.
QList< QgsProviderSublayerDetails > querySublayers(const QString &uri, Qgis::SublayerQueryFlags flags=Qgis::SublayerQueryFlags(), QgsFeedback *feedback=nullptr) const
Queries the specified uri and returns a list of any valid sublayers found in the dataset which can be...
Q_DECL_DEPRECATED void registerGuis(QWidget *widget)
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
WidgetMode
Different ways a source select dialog can be used.
Q_DECL_DEPRECATED QWidget * createSelectionWidget(const QString &providerKey, QWidget *parent=nullptr, Qt::WindowFlags fl=Qt::WindowFlags(), QgsProviderRegistry::WidgetMode widgetMode=QgsProviderRegistry::WidgetMode::Standalone)
Returns a new widget for selecting layers from a provider.
QString protocolDrivers() const
Returns a string containing the available protocol drivers.
QList< QgsProviderRegistry::ProviderCandidateDetails > preferredProvidersForUri(const QString &uri) const
Returns the details for the preferred provider(s) for opening the specified uri.
Q_DECL_DEPRECATED QString library(const QString &providerKey) const
Returns path for the library of the provider.
QString fileTiledSceneFilters() const
Returns a file filter string for supported tiled scene files.
QString databaseDrivers() const
Returns a string containing the available database drivers.
QString encodeUri(const QString &providerKey, const QVariantMap &parts)
Reassembles a provider data source URI from its component paths (e.g.
QList< QgsDataItemProvider * > dataItemProviders(const QString &providerKey) const
Returns list of data item providers of the provider.
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.
QList< QPair< QString, QString > > pyramidResamplingMethods(const QString &providerKey)
Returns list of raster pyramid resampling methods.
bool uriIsBlocklisted(const QString &uri) const
Returns true if the specified uri is known by any registered provider to be something which should be...
Q_DECL_DEPRECATED QLibrary * createProviderLibrary(const QString &providerKey) const
Returns a new QLibrary for the specified providerKey.
Qgis::VectorExportResult createEmptyLayer(const QString &providerKey, const QString &uri, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, QMap< int, int > &oldToNewAttrIdxMap, QString &errorMessage, const QMap< QString, QVariant > *options)
Creates new empty vector layer.
bool handleUnusableUri(const QString &uri, UnusableUriDetails &details) const
Returns true if the specified uri can potentially be handled by QGIS, if additional dependencies or b...
QString fileVectorFilters() const
Returns a file filter string for supported vector files.
QgsDataProvider * createProvider(const QString &providerKey, const QString &dataSource, const QgsDataProvider::ProviderOptions &options=QgsDataProvider::ProviderOptions(), Qgis::DataProviderReadFlags flags=Qgis::DataProviderReadFlags())
Creates a new instance of a provider.
QString fileRasterFilters() const
Returns a file filter string for supported raster files.
bool saveLayerMetadata(const QString &providerKey, const QString &uri, const QgsLayerMetadata &metadata, QString &errorMessage)
Saves metadata to the layer corresponding to the specified uri.
QString fileMeshFilters() const
Returns a file filter string for supported mesh files.
QString pluginList(bool asHtml=false) const
Returns list of provider plugins found.
bool shouldDeferUriForOtherProviders(const QString &uri, const QString &providerKey) const
Returns true if the provider with matching providerKey should defer handling of the specified uri to ...
bool deleteStyleById(const QString &providerKey, const QString &uri, const QString &styleId, QString &errCause)
Deletes a layer style defined by styleId.
QStringList providerList() const
Returns list of available providers by their keys.
Q_DECL_DEPRECATED Qgis::DataItemProviderCapabilities providerCapabilities(const QString &providerKey) const
Returns the provider capabilities.
QString fileMeshDatasetFilters() const
Returns a file filter string for supported mesh dataset files.
QString loadStoredStyle(const QString &providerKey, const QString &uri, QString &styleName, QString &errCause)
Loads a layer style from the provider storage, reporting its name.
QDir libraryDirectory() const
Returns the library directory where plugins are found.
QString relativeToAbsoluteUri(const QString &providerKey, const QString &uri, const QgsReadWriteContext &context) const
Converts relative path(s) to absolute path(s) in the given provider-specific URI.
QgsProviderMetadata * providerMetadata(const QString &providerKey) const
Returns metadata of the provider or nullptr if not found.
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.
bool createDb(const QString &providerKey, const QString &dbPath, QString &errCause)
Creates database by the provider on the path.
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.
QSet< QString > providersForLayerType(Qgis::LayerType type) const
Returns a list of the provider keys for available providers which handle the specified layer type.
bool registerProvider(QgsProviderMetadata *providerMetadata)
register a new vector data provider from its providerMetadata
Q_DECL_DEPRECATED QFunctionPointer function(const QString &providerKey, const QString &functionName) const
Gets pointer to provider function.
QString directoryDrivers() const
Returns a string containing the available directory drivers.
bool registerUnusableUriHandler(UnusableUriHandlerInterface *handler)
Registers an unusable URI handler, used to handle unusable URIs which aren't handled by any registere...
QString filePointCloudFilters() const
Returns a file filter string for supported point clouds.
Base class for raster data providers.
The class is used as a container of context for various read/write operations on other objects.
Scoped object for logging of the runtime for a single operation or group of operations.
This class allows including a set of layers in a database-side transaction, provided the layer data p...
#define Q_NOWARN_DEPRECATED_POP
Definition qgis.h:6481
#define Q_NOWARN_DEPRECATED_PUSH
Definition qgis.h:6480
#define cast_to_fptr(f)
Definition qgis.h:5756
#define QgsDebugMsgLevel(str, level)
Definition qgslogger.h:39
#define QgsDebugError(str)
Definition qgslogger.h:38
void cleanupProviderFunction_t()
const QgsCoordinateReferenceSystem & crs
Setting options for creating vector data providers.