QGIS API Documentation 3.39.0-Master (be2050b798e)
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"
36
41
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
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 {
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
246#ifdef HAVE_STATIC_PROVIDERS
247 mProviders[ QgsWmsProvider::providerKey() ] = new QgsWmsProviderMetadata();
248 mProviders[ QgsWcsProvider::providerKey() ] = new QgsWcsProviderMetadata();
249 mProviders[ QgsDelimitedTextProvider::providerKey() ] = new QgsDelimitedTextProviderMetadata();
250 mProviders[ QgsAfsProvider::providerKey() ] = new QgsAfsProviderMetadata();
251 mProviders[ QgsAmsProvider::providerKey() ] = new QgsAmsProviderMetadata();
252#ifdef HAVE_SPATIALITE
253 mProviders[ QgsSpatiaLiteProvider::providerKey() ] = new QgsSpatiaLiteProviderMetadata();
254 mProviders[ QgsWFSProvider::providerKey() ] = new QgsWfsProviderMetadata();
255 mProviders[ QgsOapifProvider::providerKey() ] = new QgsOapifProviderMetadata();
256 mProviders[ QgsVirtualLayerProvider::providerKey() ] = new QgsVirtualLayerProviderMetadata();
257#endif
258#ifdef HAVE_POSTGRESQL
259 mProviders[ QgsPostgresProvider::providerKey() ] = new QgsPostgresProviderMetadata();
260#endif
261#endif
262
263 // add dynamic providers
264#ifdef HAVE_STATIC_PROVIDERS
265 QgsDebugMsgLevel( QStringLiteral( "Forced only static providers" ), 2 );
266#else
267 typedef QgsProviderMetadata *factory_function( );
268
269 mLibraryDirectory.setSorting( QDir::Name | QDir::IgnoreCase );
270 mLibraryDirectory.setFilter( QDir::Files | QDir::NoSymLinks );
271
272#if defined(Q_OS_WIN) || defined(__CYGWIN__)
273 mLibraryDirectory.setNameFilters( QStringList( "*.dll" ) );
274#elif defined(ANDROID)
275 mLibraryDirectory.setNameFilters( QStringList( "*provider_*.so" ) );
276#else
277 mLibraryDirectory.setNameFilters( QStringList( QStringLiteral( "*.so" ) ) );
278#endif
279
280 QgsDebugMsgLevel( QStringLiteral( "Checking %1 for provider plugins" ).arg( mLibraryDirectory.path() ), 2 );
281
282 if ( mLibraryDirectory.count() == 0 )
283 {
284 QgsDebugError( QStringLiteral( "No dynamic QGIS data provider plugins found in:\n%1\n" ).arg( mLibraryDirectory.path() ) );
285 }
286
287 // provider file regex pattern, only files matching the pattern are loaded if the variable is defined
288 const QString filePattern = getenv( "QGIS_PROVIDER_FILE" );
289 QRegularExpression fileRegexp;
290 if ( !filePattern.isEmpty() )
291 {
292 fileRegexp.setPattern( filePattern );
293 }
294
295 typedef std::vector<QgsProviderMetadata *> *multiple_factory_function();
296
297 const auto constEntryInfoList = mLibraryDirectory.entryInfoList();
298 for ( const QFileInfo &fi : constEntryInfoList )
299 {
300 if ( !filePattern.isEmpty() )
301 {
302 if ( fi.fileName().indexOf( fileRegexp ) == -1 )
303 {
304 QgsDebugMsgLevel( "provider " + fi.fileName() + " skipped because doesn't match pattern " + filePattern, 2 );
305 continue;
306 }
307 }
308
309 // Always skip authentication methods
310 if ( fi.fileName().contains( QStringLiteral( "authmethod" ), Qt::CaseSensitivity::CaseInsensitive ) )
311 {
312 continue;
313 }
314
315 const QgsScopedRuntimeProfile profile( QObject::tr( "Load %1" ).arg( fi.fileName() ) );
316 QLibrary myLib( fi.filePath() );
317 if ( !myLib.load() )
318 {
319 QgsDebugError( QStringLiteral( "Checking %1: ...invalid (lib not loadable): %2" ).arg( myLib.fileName(), myLib.errorString() ) );
320 continue;
321 }
322
323 bool libraryLoaded { false };
324 QFunctionPointer func = myLib.resolve( QStringLiteral( "providerMetadataFactory" ).toLatin1().data() );
325 factory_function *function = reinterpret_cast< factory_function * >( cast_to_fptr( func ) );
326 if ( function )
327 {
329 if ( meta )
330 {
331 if ( findMetadata_( mProviders, meta->key() ) )
332 {
333 QgsDebugError( QStringLiteral( "Checking %1: ...invalid (key %2 already registered)" ).arg( myLib.fileName() ).arg( meta->key() ) );
334 delete meta;
335 continue;
336 }
337 // add this provider to the provider map
338 mProviders[meta->key()] = meta;
339 libraryLoaded = true;
340 }
341 }
342 else
343 {
344 QFunctionPointer multi_func = myLib.resolve( QStringLiteral( "multipleProviderMetadataFactory" ).toLatin1().data() );
345 multiple_factory_function *multi_function = reinterpret_cast< multiple_factory_function * >( cast_to_fptr( multi_func ) );
346 if ( multi_function )
347 {
348 std::vector<QgsProviderMetadata *> *metadatas = multi_function();
349 for ( const auto meta : *metadatas )
350 {
351 if ( findMetadata_( mProviders, meta->key() ) )
352 {
353 QgsDebugError( QStringLiteral( "Checking %1: ...invalid (key %2 already registered)" ).arg( myLib.fileName() ).arg( meta->key() ) );
354 delete meta;
355 continue;
356 }
357 // add this provider to the provider map
358 mProviders[meta->key()] = meta;
359 libraryLoaded = true;
360 }
361 delete metadatas;
362 }
363 }
364
365 if ( ! libraryLoaded )
366 {
367 QgsDebugMsgLevel( QStringLiteral( "Checking %1: ...invalid (no providerMetadataFactory method)" ).arg( myLib.fileName() ), 2 );
368 }
369 }
370
371#endif
372 QgsDebugMsgLevel( QStringLiteral( "Loaded %1 providers (%2) " ).arg( mProviders.size() ).arg( providerList().join( ';' ) ), 1 );
373
374 // now initialize all providers
375 for ( Providers::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
376 {
377 const QString &key = it->first;
378
379 const QgsScopedRuntimeProfile profile( QObject::tr( "Initialize %1" ).arg( key ) );
380
381 QgsProviderMetadata *meta = it->second;
382
383 // call initProvider() - allows provider to register its services to QGIS
384 meta->initProvider();
385 }
386
387 rebuildFilterStrings();
388
389 // load database drivers (only OGR)
390 mDatabaseDrivers = QgsOgrProviderUtils::databaseDrivers();
391
392 // load directory drivers (only OGR)
393 mDirectoryDrivers = QgsOgrProviderUtils::directoryDrivers();
394
395 // load protocol drivers (only OGR)
396 mProtocolDrivers = QgsOgrProviderUtils::protocolDrivers();
397}
398
399void QgsProviderRegistry::rebuildFilterStrings()
400{
401 mVectorFileFilters.clear();
402 mRasterFileFilters.clear();
403 mMeshFileFilters.clear();
404 mMeshDatasetFileFilters.clear();
405 mPointCloudFileFilters.clear();
406 mVectorTileFileFilters.clear();
407 mTiledSceneFileFilters.clear();
408
409 QStringList pointCloudWildcards;
410 QStringList pointCloudFilters;
411
412 QStringList vectorTileWildcards;
413 QStringList vectorTileFilters;
414
415 QStringList tiledSceneWildcards;
416 QStringList tiledSceneFilters;
417
418 for ( Providers::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
419 {
420 QgsProviderMetadata *meta = it->second;
421
422 // now get vector file filters, if any
424 if ( !fileVectorFilters.isEmpty() )
425 {
426 mVectorFileFilters += fileVectorFilters;
427 QgsDebugMsgLevel( QStringLiteral( "Checking %1: ...loaded OK (%2 file filters)" ).arg( it->first ).arg( fileVectorFilters.split( ";;" ).count() ), 2 );
428 }
429
430 // now get raster file filters, if any
432 if ( !fileRasterFilters.isEmpty() )
433 {
434 QgsDebugMsgLevel( "raster filters: " + fileRasterFilters, 2 );
435 mRasterFileFilters += fileRasterFilters;
436 QgsDebugMsgLevel( QStringLiteral( "Checking %1: ...loaded OK (%2 file filters)" ).arg( it->first ).arg( fileRasterFilters.split( ";;" ).count() ), 2 );
437 }
438
439 // now get mesh file filters, if any
440 const QString fileMeshFilters = meta->filters( Qgis::FileFilterType::Mesh );
441 if ( !fileMeshFilters.isEmpty() )
442 {
443 mMeshFileFilters += fileMeshFilters;
444 QgsDebugMsgLevel( QStringLiteral( "Checking %1: ...loaded OK (%2 file mesh filters)" ).arg( it->first ).arg( mMeshFileFilters.split( ";;" ).count() ), 2 );
445
446 }
447
449 if ( !fileMeshDatasetFilters.isEmpty() )
450 {
451 mMeshDatasetFileFilters += fileMeshDatasetFilters;
452 QgsDebugMsgLevel( QStringLiteral( "Checking %1: ...loaded OK (%2 file dataset filters)" ).arg( it->first ).arg( mMeshDatasetFileFilters.split( ";;" ).count() ), 2 );
453 }
454
455 // now get point cloud file filters, if any
457 if ( !filePointCloudFilters.isEmpty() )
458 {
459 QgsDebugMsgLevel( "point cloud filters: " + filePointCloudFilters, 2 );
460
461 const QStringList filters = filePointCloudFilters.split( QStringLiteral( ";;" ), Qt::SkipEmptyParts );
462 for ( const QString &filter : filters )
463 {
464 pointCloudFilters.append( filter );
465 pointCloudWildcards.append( QgsFileUtils::wildcardsFromFilter( filter ).split( ' ' ) );
466 }
467 }
468
469 // now get vector tile file filters, if any
471 if ( !fileVectorTileFilters.isEmpty() )
472 {
473 QgsDebugMsgLevel( "vector tile filters: " + fileVectorTileFilters, 2 );
474
475 const QStringList filters = fileVectorTileFilters.split( QStringLiteral( ";;" ), Qt::SkipEmptyParts );
476 for ( const QString &filter : filters )
477 {
478 vectorTileFilters.append( filter );
479 vectorTileWildcards.append( QgsFileUtils::wildcardsFromFilter( filter ).split( ' ' ) );
480 }
481 }
482
483 // now get tiled scene file filters, if any
485 if ( !fileTiledSceneFilters.isEmpty() )
486 {
487 QgsDebugMsgLevel( "tiled scene filters: " + fileTiledSceneFilters, 2 );
488
489 const QStringList filters = fileTiledSceneFilters.split( QStringLiteral( ";;" ), Qt::SkipEmptyParts );
490 for ( const QString &filter : filters )
491 {
492 tiledSceneFilters.append( filter );
493 tiledSceneWildcards.append( QgsFileUtils::wildcardsFromFilter( filter ).split( ' ' ) );
494 }
495 }
496 }
497
498 if ( !pointCloudFilters.empty() )
499 {
500 pointCloudFilters.insert( 0, QObject::tr( "All Supported Files" ) + QStringLiteral( " (%1)" ).arg( pointCloudWildcards.join( ' ' ) ) );
501 pointCloudFilters.insert( 1, QObject::tr( "All Files" ) + QStringLiteral( " (*.*)" ) );
502 mPointCloudFileFilters = pointCloudFilters.join( QLatin1String( ";;" ) );
503 }
504
505 if ( !vectorTileFilters.empty() )
506 {
507 vectorTileFilters.insert( 0, QObject::tr( "All Supported Files" ) + QStringLiteral( " (%1)" ).arg( vectorTileWildcards.join( ' ' ) ) );
508 vectorTileFilters.insert( 1, QObject::tr( "All Files" ) + QStringLiteral( " (*.*)" ) );
509 mVectorTileFileFilters = vectorTileFilters.join( QLatin1String( ";;" ) );
510 }
511
512 if ( !tiledSceneFilters.empty() )
513 {
514 tiledSceneFilters.insert( 0, QObject::tr( "All Supported Files" ) + QStringLiteral( " (%1)" ).arg( tiledSceneWildcards.join( ' ' ) ) );
515 tiledSceneFilters.insert( 1, QObject::tr( "All Files" ) + QStringLiteral( " (*.*)" ) );
516 mTiledSceneFileFilters = tiledSceneFilters.join( QLatin1String( ";;" ) );
517 }
518}
519
520// typedef for the unload dataprovider function
522
523void QgsProviderRegistry::clean()
524{
525 // avoid recreating a new project just to clean it
526 if ( QgsProject::sProject )
528
529 Providers::const_iterator it = mProviders.begin();
530
531 while ( it != mProviders.end() )
532 {
533 QgsDebugMsgLevel( QStringLiteral( "cleanup:%1" ).arg( it->first ), 5 );
534 it->second->cleanupProvider();
535 delete it->second;
536 ++it;
537 }
538 mProviders.clear();
539}
540
541bool QgsProviderRegistry::exists()
542{
543 return static_cast< bool >( sInstance );
544}
545
547{
548 qDeleteAll( mUnusableUriHandlers );
549
550 clean();
551 if ( sInstance == this )
552 sInstance = nullptr;
553}
554
555QString QgsProviderRegistry::library( QString const &providerKey ) const
556{
557 QgsProviderMetadata *md = findMetadata_( mProviders, providerKey );
558
559 if ( md )
560 {
562 return md->library();
564 }
565
566 return QString();
567}
568
569QString QgsProviderRegistry::pluginList( bool asHTML ) const
570{
571 Providers::const_iterator it = mProviders.begin();
572
573 if ( mProviders.empty() )
574 return QObject::tr( "No data provider plugins are available. No vector layers can be loaded" );
575
576 QString list;
577
578 if ( asHTML )
579 list += QLatin1String( "<ol>" );
580
581 while ( it != mProviders.end() )
582 {
583 if ( asHTML )
584 list += QLatin1String( "<li>" );
585
586 list += it->second->description();
587
588 if ( asHTML )
589 list += QLatin1String( "<br></li>" );
590 else
591 list += '\n';
592
593 ++it;
594 }
595
596 if ( asHTML )
597 list += QLatin1String( "</ol>" );
598
599 return list;
600}
601
603{
604 mLibraryDirectory = path;
605 clean();
606 init();
607}
608
610{
611 return mLibraryDirectory;
612}
613
614
615/* Copied from QgsVectorLayer::setDataProvider
616 * TODO: Make it work in the generic environment
617 *
618 * TODO: Is this class really the best place to put a data provider loader?
619 * It seems more sensible to provide the code in one place rather than
620 * in qgsrasterlayer, qgsvectorlayer, serversourceselect, etc.
621 */
622QgsDataProvider *QgsProviderRegistry::createProvider( QString const &providerKey, QString const &dataSource,
625{
626 // XXX should I check for and possibly delete any pre-existing providers?
627 // XXX How often will that scenario occur?
628
629 QgsProviderMetadata *metadata = findMetadata_( mProviders, providerKey );
630 if ( !metadata )
631 {
632 QgsMessageLog::logMessage( QObject::tr( "Invalid data provider %1" ).arg( providerKey ) );
633 return nullptr;
634 }
635
636 return metadata->createProvider( dataSource, options, flags );
637}
638
640{
641 const QList< QgsDataItemProvider * > itemProviders = dataItemProviders( providerKey );
643 //concat flags
644 for ( const QgsDataItemProvider *itemProvider : itemProviders )
645 {
646 ret |= itemProvider->capabilities();
647 }
648 return ret;
649}
650
651QVariantMap QgsProviderRegistry::decodeUri( const QString &providerKey, const QString &uri )
652{
653 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
654 if ( meta )
655 return meta->decodeUri( uri );
656 else
657 return QVariantMap();
658}
659
660QString QgsProviderRegistry::encodeUri( const QString &providerKey, const QVariantMap &parts )
661{
662 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
663 if ( meta )
664 return meta->encodeUri( parts );
665 else
666 return QString();
667}
668
669QString QgsProviderRegistry::absoluteToRelativeUri( const QString &providerKey, const QString &uri, const QgsReadWriteContext &context ) const
670{
671 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
672 if ( meta )
673 return meta->absoluteToRelativeUri( uri, context );
674 else
675 return uri;
676}
677
678QString QgsProviderRegistry::relativeToAbsoluteUri( const QString &providerKey, const QString &uri, const QgsReadWriteContext &context ) const
679{
680 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
681 if ( meta )
682 return meta->relativeToAbsoluteUri( uri, context );
683 else
684 return uri;
685}
686
688 const QString &uri,
689 const QgsFields &fields,
690 Qgis::WkbType wkbType,
692 bool overwrite, QMap<int, int> &oldToNewAttrIdxMap,
693 QString &errorMessage,
694 const QMap<QString, QVariant> *options )
695{
696 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
697 if ( meta )
698 return meta->createEmptyLayer( uri, fields, wkbType, srs, overwrite, oldToNewAttrIdxMap, errorMessage, options );
699 else
700 {
701 errorMessage = QObject::tr( "Unable to load %1 provider" ).arg( providerKey );
703 }
704}
705
706QgsRasterDataProvider *QgsProviderRegistry::createRasterDataProvider( const QString &providerKey, const QString &uri, const QString &format,
707 int nBands, Qgis::DataType type, int width, int height,
708 double *geoTransform, const QgsCoordinateReferenceSystem &crs,
709 const QStringList &createOptions )
710{
711 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
712 if ( meta )
713 return meta->createRasterDataProvider( uri, format, nBands, type, width, height, geoTransform, crs, createOptions );
714 else
715 return nullptr;
716}
717
718QList<QPair<QString, QString> > QgsProviderRegistry::pyramidResamplingMethods( const QString &providerKey )
719{
720 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
721 if ( meta )
722 return meta->pyramidResamplingMethods();
723 else
724 return QList<QPair<QString, QString> >();
725}
726
727QList<QgsDataItemProvider *> QgsProviderRegistry::dataItemProviders( const QString &providerKey ) const
728{
729 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
730 if ( meta )
731 return meta->dataItemProviders();
732 else
733 return QList<QgsDataItemProvider *>();
734}
735
736int QgsProviderRegistry::listStyles( const QString &providerKey, const QString &uri, QStringList &ids, QStringList &names, QStringList &descriptions, QString &errCause )
737{
738 int res = -1;
739 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
740 if ( meta )
741 {
742 res = meta->listStyles( uri, ids, names, descriptions, errCause );
743 }
744 else
745 {
746 errCause = QObject::tr( "Unable to load %1 provider" ).arg( providerKey );
747 }
748 return res;
749}
750
751bool QgsProviderRegistry::styleExists( const QString &providerKey, const QString &uri, const QString &styleId, QString &errorCause )
752{
753 errorCause.clear();
754
755 if ( QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey ) )
756 {
757 return meta->styleExists( uri, styleId, errorCause );
758 }
759 else
760 {
761 errorCause = QObject::tr( "Unable to load %1 provider" ).arg( providerKey );
762 return false;
763 }
764}
765
766QString QgsProviderRegistry::getStyleById( const QString &providerKey, const QString &uri, const QString &styleId, QString &errCause )
767{
768 QString ret;
769 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
770 if ( meta )
771 {
772 ret = meta->getStyleById( uri, styleId, errCause );
773 }
774 else
775 {
776 errCause = QObject::tr( "Unable to load %1 provider" ).arg( providerKey );
777 }
778 return ret;
779}
780
781bool QgsProviderRegistry::deleteStyleById( const QString &providerKey, const QString &uri, const QString &styleId, QString &errCause )
782{
783 const bool ret( false );
784
785 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
786 if ( meta )
787 return meta->deleteStyleById( uri, styleId, errCause );
788 else
789 {
790 errCause = QObject::tr( "Unable to load %1 provider" ).arg( providerKey );
791 }
792 return ret;
793}
794
795bool QgsProviderRegistry::saveStyle( const QString &providerKey, const QString &uri, const QString &qmlStyle,
796 const QString &sldStyle, const QString &styleName, const QString &styleDescription,
797 const QString &uiFileContent, bool useAsDefault, QString &errCause )
798{
799 bool ret( false );
800 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
801 if ( meta )
802 ret = meta->saveStyle( uri, qmlStyle, sldStyle, styleName, styleDescription,
803 uiFileContent, useAsDefault, errCause );
804 else
805 {
806 errCause = QObject::tr( "Unable to load %1 provider" ).arg( providerKey );
807 }
808 return ret;
809}
810
811QString QgsProviderRegistry::loadStyle( const QString &providerKey, const QString &uri, QString &errCause )
812{
813 QString ret;
814 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
815 if ( meta )
816 ret = meta->loadStyle( uri, errCause );
817 else
818 {
819 errCause = QObject::tr( "Unable to load %1 provider" ).arg( providerKey );
820 }
821 return ret;
822}
823
824QString QgsProviderRegistry::loadStoredStyle( const QString &providerKey, const QString &uri, QString &styleName, QString &errCause )
825{
826 QString ret;
827 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
828 if ( meta )
829 ret = meta->loadStoredStyle( uri, styleName, errCause );
830 else
831 {
832 errCause = QObject::tr( "Unable to load %1 provider" ).arg( providerKey );
833 }
834 return ret;
835}
836
837bool QgsProviderRegistry::saveLayerMetadata( const QString &providerKey, const QString &uri, const QgsLayerMetadata &metadata, QString &errorMessage )
838{
839 errorMessage.clear();
840 if ( QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey ) )
841 return meta->saveLayerMetadata( uri, metadata, errorMessage );
842 else
843 {
844 throw QgsNotSupportedException( QObject::tr( "Unable to load %1 provider" ).arg( providerKey ) );
845 }
846}
847
848bool QgsProviderRegistry::createDb( const QString &providerKey, const QString &dbPath, QString &errCause )
849{
850 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
851 if ( meta )
852 return meta->createDb( dbPath, errCause );
853 else
854 {
855 errCause = QStringLiteral( "Resolving createDb(...) failed" );
856 return false;
857 }
858}
859
860QgsTransaction *QgsProviderRegistry::createTransaction( const QString &providerKey, const QString &connString )
861{
862 QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
863 if ( meta )
864 return meta->createTransaction( connString );
865 else
866 return nullptr;
867}
868
869QWidget *QgsProviderRegistry::createSelectionWidget( const QString &providerKey,
870 QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode )
871{
872 Q_UNUSED( providerKey );
873 Q_UNUSED( parent );
874 Q_UNUSED( fl );
875 Q_UNUSED( widgetMode );
876 QgsDebugError( "deprecated call - use QgsGui::sourceSelectProviderRegistry()->createDataSourceWidget() instead" );
877 return nullptr;
878}
879
880QFunctionPointer QgsProviderRegistry::function( QString const &providerKey,
881 QString const &functionName ) const
882{
884 const QString lib = library( providerKey );
886 if ( lib.isEmpty() )
887 return nullptr;
888
889 QLibrary myLib( lib );
890
891 QgsDebugMsgLevel( "Library name is " + myLib.fileName(), 2 );
892
893 if ( myLib.load() )
894 {
895 return myLib.resolve( functionName.toLatin1().data() );
896 }
897 else
898 {
899 QgsDebugError( "Cannot load library: " + myLib.errorString() );
900 return nullptr;
901 }
902}
903
904QLibrary *QgsProviderRegistry::createProviderLibrary( QString const &providerKey ) const
905{
907 const QString lib = library( providerKey );
909 if ( lib.isEmpty() )
910 return nullptr;
911
912 std::unique_ptr< QLibrary > myLib( new QLibrary( lib ) );
913
914 QgsDebugMsgLevel( "Library name is " + myLib->fileName(), 2 );
915
916 if ( myLib->load() )
917 return myLib.release();
918
919 QgsDebugError( "Cannot load library: " + myLib->errorString() );
920
921 return nullptr;
922}
923
925{
926 QgsDebugError( "deprecated - use QgsGui::providerGuiRegistry() instead." );
927}
928
930{
931 if ( providerMetadata )
932 {
933 if ( mProviders.find( providerMetadata->key() ) == mProviders.end() )
934 {
935 mProviders[ providerMetadata->key() ] = providerMetadata;
936
937 rebuildFilterStrings();
938 return true;
939 }
940 else
941 {
942 QgsDebugMsgLevel( QStringLiteral( "Cannot register provider metadata: a provider with the same key (%1) was already registered!" ).arg( providerMetadata->key() ), 2 );
943 }
944 }
945 else
946 {
947 QgsDebugMsgLevel( QStringLiteral( "Trying to register a null metadata provider!" ), 2 );
948 }
949 return false;
950}
951
953{
954 return mVectorFileFilters;
955}
956
958{
959 return mRasterFileFilters;
960}
961
963{
964 return mMeshFileFilters;
965}
966
968{
969 return mMeshDatasetFileFilters;
970}
971
973{
974 return mPointCloudFileFilters;
975}
976
978{
979 return mVectorTileFileFilters;
980}
981
983{
984 return mTiledSceneFileFilters;
985}
986
988{
989 return mDatabaseDrivers;
990}
991
993{
994 return mDirectoryDrivers;
995}
996
998{
999 return mProtocolDrivers;
1000}
1001
1003{
1004 QStringList lst;
1005 for ( Providers::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
1006 {
1007 lst.append( it->first );
1008 }
1009 return lst;
1010}
1011
1013{
1014 return findMetadata_( mProviders, providerKey );
1015}
1016
1018{
1019 QSet<QString> lst;
1020 for ( Providers::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
1021 {
1022 if ( it->second->supportedLayerTypes().contains( type ) )
1023 lst.insert( it->first );
1024 }
1025 return lst;
1026}
1027
1028QList<QgsProviderRegistry::ProviderCandidateDetails> QgsProviderRegistry::preferredProvidersForUri( const QString &uri ) const
1029{
1030 QList< QgsProviderRegistry::ProviderCandidateDetails > res;
1031 int maxPriority = 0;
1032 for ( auto it = mProviders.begin(); it != mProviders.end(); ++it )
1033 {
1034 if ( !( it->second->capabilities() & QgsProviderMetadata::PriorityForUri ) )
1035 continue;
1036
1037 const int thisProviderPriority = it->second->priorityForUri( uri );
1038 if ( thisProviderPriority == 0 )
1039 continue;
1040
1041 if ( thisProviderPriority > maxPriority )
1042 {
1043 res.clear();
1044 maxPriority = thisProviderPriority;
1045 }
1046 if ( thisProviderPriority == maxPriority )
1047 {
1048 res.append( ProviderCandidateDetails( it->second, it->second->validLayerTypesForUri( uri ) ) );
1049 }
1050 }
1051 return res;
1052}
1053
1055{
1056 mUnusableUriHandlers << handler;
1057 return true;
1058}
1059
1060bool QgsProviderRegistry::handleUnusableUri( const QString &uri, UnusableUriDetails &details ) const
1061{
1062 for ( const QgsProviderRegistry::UnusableUriHandlerInterface *handler : mUnusableUriHandlers )
1063 {
1064 if ( handler->matchesUri( uri ) )
1065 {
1066 details = handler->details( uri );
1067 return true;
1068 }
1069 }
1070 return false;
1071}
1072
1073bool QgsProviderRegistry::shouldDeferUriForOtherProviders( const QString &uri, const QString &providerKey ) const
1074{
1075 const QList< ProviderCandidateDetails > providers = preferredProvidersForUri( uri );
1076 if ( providers.empty() )
1077 return false;
1078
1079 for ( const ProviderCandidateDetails &provider : providers )
1080 {
1081 if ( provider.metadata()->key() == providerKey )
1082 return false;
1083 }
1084 return true;
1085}
1086
1087bool QgsProviderRegistry::uriIsBlocklisted( const QString &uri ) const
1088{
1089 for ( auto it = mProviders.begin(); it != mProviders.end(); ++it )
1090 {
1091 if ( it->second->uriIsBlocklisted( uri ) )
1092 return true;
1093 }
1094 return false;
1095}
1096
1097QList<QgsProviderSublayerDetails> QgsProviderRegistry::querySublayers( const QString &uri, Qgis::SublayerQueryFlags flags, QgsFeedback *feedback ) const
1098{
1099 // never query sublayers for blocklisted uris
1100 if ( uriIsBlocklisted( uri ) )
1101 return {};
1102
1103 QList<QgsProviderSublayerDetails> res;
1104 for ( auto it = mProviders.begin(); it != mProviders.end(); ++it )
1105 {
1106 // if we should defer this uri for other providers, do so
1107 if ( shouldDeferUriForOtherProviders( uri, it->first ) )
1108 continue;
1109
1110 res.append( it->second->querySublayers( uri, flags, feedback ) );
1111 if ( feedback && feedback->isCanceled() )
1112 break;
1113 }
1114 return res;
1115}
@ 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:886
@ ErrorInvalidProvider
Could not find a matching provider key.
QFlags< DataItemProviderCapability > DataItemProviderCapabilities
Capabilities for data item providers.
Definition qgis.h:829
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:376
DataType
Raster data types.
Definition qgis.h:288
QFlags< SublayerQueryFlag > SublayerQueryFlags
Sublayer query flags.
Definition qgis.h:1212
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:201
This class represents a coordinate reference system (CRS).
This is the interface for those who want to add custom data items to the browser tree.
Abstract base class for spatial data provider implementations.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
bool isCanceled() const
Tells whether the operation has been canceled already.
Definition qgsfeedback.h:53
Container of fields for a vector layer.
Definition qgsfields.h:46
static QString wildcardsFromFilter(const QString &filter)
Given a filter string like "GeoTIFF Files (*.tiff *.tif)", extracts the wildcard portion of this 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 QgsDataProvider * createProvider(const QString &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags=Qgis::DataProviderReadFlags())
Class factory to return a pointer to a newly created QgsDataProvider object.
virtual bool deleteStyleById(const QString &uri, const QString &styleId, QString &errCause)
Deletes a layer style defined by styleId.
virtual bool saveStyle(const QString &uri, const QString &qmlStyle, const QString &sldStyle, const QString &styleName, const QString &styleDescription, const QString &uiFileContent, bool useAsDefault, QString &errCause)
Saves a layer style to provider.
virtual QString encodeUri(const QVariantMap &parts) const
Reassembles a provider data source URI from its component paths (e.g.
virtual QString absoluteToRelativeUri(const QString &uri, const QgsReadWriteContext &context) const
Converts absolute path(s) to relative path(s) in the given provider-specific URI.
virtual Qgis::VectorExportResult createEmptyLayer(const QString &uri, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, QMap< int, int > &oldToNewAttrIdxMap, QString &errorMessage, const QMap< QString, QVariant > *options)
Creates new empty vector layer.
virtual bool styleExists(const QString &uri, const QString &styleId, QString &errorCause)
Returns true if a layer style with the specified styleId exists in the provider defined by uri.
virtual bool saveLayerMetadata(const QString &uri, const QgsLayerMetadata &metadata, QString &errorMessage)
Saves metadata to the layer corresponding to the specified uri.
virtual QString filters(Qgis::FileFilterType type)
Builds the list of file filter strings (supported formats)
QString key() const
This returns the unique key associated with the provider.
virtual QgsTransaction * createTransaction(const QString &connString)
Returns new instance of transaction.
virtual void initProvider()
Initialize the provider.
virtual QString getStyleById(const QString &uri, const QString &styleId, QString &errCause)
Gets a layer style defined by uri.
virtual QString loadStoredStyle(const QString &uri, QString &styleName, QString &errCause)
Loads a layer style from the provider storage, reporting its name.
@ PriorityForUri
Indicates that the metadata can calculate a priority for a URI.
virtual QString relativeToAbsoluteUri(const QString &uri, const QgsReadWriteContext &context) const
Converts relative path(s) to absolute path(s) in the given provider-specific URI.
virtual QString loadStyle(const QString &uri, QString &errCause)
Loads a layer style defined by uri.
virtual int listStyles(const QString &uri, QStringList &ids, QStringList &names, QStringList &descriptions, QString &errCause)
Lists stored layer styles in the provider defined by uri.
virtual QList< QPair< QString, QString > > pyramidResamplingMethods()
Returns pyramid resampling methods available for provider.
virtual QList< QgsDataItemProvider * > dataItemProviders() const
Returns data item providers.
virtual QVariantMap decodeUri(const QString &uri) const
Breaks a provider data source URI into its component paths (e.g.
Q_DECL_DEPRECATED QString library() const
This returns the library file name.
virtual bool createDb(const QString &dbPath, QString &errCause)
Creates database by the provider on the path.
Contains information pertaining to a candidate provider.
Contains information about unusable URIs which aren't handled by any registered providers.
QString detailedWarning
Contains a longer, user-friendly, translated message advising why the URI is not usable.
An interface used to handle unusable URIs which aren't handled by any registered providers,...
virtual UnusableUriDetails details(const QString &uri) const =0
Returns the details for advising the user why the uri is not usable.
virtual bool matchesUri(const QString &uri) const =0
Returns true if the handle is an unusable URI handler for the specified uri.
A registry / canonical manager of data providers.
QString absoluteToRelativeUri(const QString &providerKey, const QString &uri, const QgsReadWriteContext &context) const
Converts absolute path(s) to relative path(s) in the given provider-specific URI.
std::map< QString, QgsProviderMetadata * > Providers
Type for data provider metadata associative container.
bool styleExists(const QString &providerKey, const QString &uri, const QString &styleId, QString &errorCause)
Returns true if a layer style with the specified styleId exists in the provider defined by providerKe...
QString loadStyle(const QString &providerKey, const QString &uri, QString &errCause)
Loads a layer style defined by uri.
QString getStyleById(const QString &providerKey, const QString &uri, const QString &styleId, QString &errCause)
Gets a layer style defined by styleId.
QVariantMap decodeUri(const QString &providerKey, const QString &uri)
Breaks a provider data source URI into its component paths (e.g.
void setLibraryDirectory(const QDir &path)
Sets library directory where to search for plugins.
QString fileVectorTileFilters() const
Returns a file filter string for supported vector tile files.
QgsTransaction * createTransaction(const QString &providerKey, const QString &connString)
Returns new instance of transaction.
QList< QgsProviderSublayerDetails > querySublayers(const QString &uri, Qgis::SublayerQueryFlags flags=Qgis::SublayerQueryFlags(), QgsFeedback *feedback=nullptr) const
Queries the specified uri and returns a list of any valid sublayers found in the dataset which can be...
Q_DECL_DEPRECATED void registerGuis(QWidget *widget)
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
WidgetMode
Different ways a source select dialog can be used.
QString protocolDrivers() const
Returns a string containing the available protocol drivers.
QList< QgsProviderRegistry::ProviderCandidateDetails > preferredProvidersForUri(const QString &uri) const
Returns the details for the preferred provider(s) for opening the specified uri.
Q_DECL_DEPRECATED QString library(const QString &providerKey) const
Returns path for the library of the provider.
QString fileTiledSceneFilters() const
Returns a file filter string for supported tiled scene files.
QString databaseDrivers() const
Returns a string containing the available database drivers.
QString encodeUri(const QString &providerKey, const QVariantMap &parts)
Reassembles a provider data source URI from its component paths (e.g.
QList< QgsDataItemProvider * > dataItemProviders(const QString &providerKey) const
Returns list of data item providers of the provider.
QgsRasterDataProvider * createRasterDataProvider(const QString &providerKey, const QString &uri, const QString &format, int nBands, Qgis::DataType type, int width, int height, double *geoTransform, const QgsCoordinateReferenceSystem &crs, const QStringList &createOptions=QStringList())
Creates new instance of raster data provider.
QList< QPair< QString, QString > > pyramidResamplingMethods(const QString &providerKey)
Returns list of raster pyramid resampling methods.
bool uriIsBlocklisted(const QString &uri) const
Returns true if the specified uri is known by any registered provider to be something which should be...
Q_DECL_DEPRECATED QLibrary * createProviderLibrary(const QString &providerKey) const
Returns a new QLibrary for the specified providerKey.
Qgis::VectorExportResult createEmptyLayer(const QString &providerKey, const QString &uri, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, QMap< int, int > &oldToNewAttrIdxMap, QString &errorMessage, const QMap< QString, QVariant > *options)
Creates new empty vector layer.
bool handleUnusableUri(const QString &uri, UnusableUriDetails &details) const
Returns true if the specified uri can potentially be handled by QGIS, if additional dependencies or b...
QString fileVectorFilters() const
Returns a file filter string for supported vector files.
QgsDataProvider * createProvider(const QString &providerKey, const QString &dataSource, const QgsDataProvider::ProviderOptions &options=QgsDataProvider::ProviderOptions(), Qgis::DataProviderReadFlags flags=Qgis::DataProviderReadFlags())
Creates a new instance of a provider.
QString fileRasterFilters() const
Returns a file filter string for supported raster files.
bool saveLayerMetadata(const QString &providerKey, const QString &uri, const QgsLayerMetadata &metadata, QString &errorMessage)
Saves metadata to the layer corresponding to the specified uri.
QString fileMeshFilters() const
Returns a file filter string for supported mesh files.
QString pluginList(bool asHtml=false) const
Returns list of provider plugins found.
bool shouldDeferUriForOtherProviders(const QString &uri, const QString &providerKey) const
Returns true if the provider with matching providerKey should defer handling of the specified uri to ...
bool deleteStyleById(const QString &providerKey, const QString &uri, const QString &styleId, QString &errCause)
Deletes a layer style defined by styleId.
QStringList providerList() const
Returns list of available providers by their keys.
Q_DECL_DEPRECATED Qgis::DataItemProviderCapabilities providerCapabilities(const QString &providerKey) const
Returns the provider capabilities.
QString fileMeshDatasetFilters() const
Returns a file filter string for supported mesh dataset files.
QString loadStoredStyle(const QString &providerKey, const QString &uri, QString &styleName, QString &errCause)
Loads a layer style from the provider storage, reporting its name.
QDir libraryDirectory() const
Returns the library directory where plugins are found.
QString relativeToAbsoluteUri(const QString &providerKey, const QString &uri, const QgsReadWriteContext &context) const
Converts relative path(s) to absolute path(s) in the given provider-specific URI.
QgsProviderMetadata * providerMetadata(const QString &providerKey) const
Returns metadata of the provider or nullptr if not found.
int listStyles(const QString &providerKey, const QString &uri, QStringList &ids, QStringList &names, QStringList &descriptions, QString &errCause)
Lists stored layer styles in the provider defined by providerKey and uri.
bool createDb(const QString &providerKey, const QString &dbPath, QString &errCause)
Creates database by the provider on the path.
bool saveStyle(const QString &providerKey, const QString &uri, const QString &qmlStyle, const QString &sldStyle, const QString &styleName, const QString &styleDescription, const QString &uiFileContent, bool useAsDefault, QString &errCause)
Saves a layer style to provider.
QSet< QString > providersForLayerType(Qgis::LayerType type) const
Returns a list of the provider keys for available providers which handle the specified layer type.
bool registerProvider(QgsProviderMetadata *providerMetadata)
register a new vector data provider from its providerMetadata
Q_DECL_DEPRECATED QFunctionPointer function(const QString &providerKey, const QString &functionName) const
Gets pointer to provider function.
QString directoryDrivers() const
Returns a string containing the available directory drivers.
bool registerUnusableUriHandler(UnusableUriHandlerInterface *handler)
Registers an unusable URI handler, used to handle unusable URIs which aren't handled by any registere...
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:6229
#define Q_NOWARN_DEPRECATED_PUSH
Definition qgis.h:6228
#define cast_to_fptr(f)
Definition qgis.h:5504
#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.