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