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