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