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