QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
QgsProviderRegistry Class Reference

A registry / canonical manager of data providers. More...

#include <qgsproviderregistry.h>

Classes

class  ProviderCandidateDetails
 Contains information pertaining to a candidate provider. More...
 
class  UnusableUriDetails
 Contains information about unusable URIs which aren't handled by any registered providers. More...
 
class  UnusableUriHandlerInterface
 An interface used to handle unusable URIs which aren't handled by any registered providers, and construct user-friendly warnings as to why the URI is unusable. More...
 

Public Types

typedef std::map< QString, QgsProviderMetadata * > Providers
 Type for data provider metadata associative container.
 
enum  WidgetMode { Standalone , Embedded , Manager }
 Different ways a source select dialog can be used. More...
 

Public Member Functions

 ~QgsProviderRegistry ()
 
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.
 
bool createDb (const QString &providerKey, const QString &dbPath, QString &errCause)
 Creates database by the provider on the path.
 
Qgis::VectorExportResult createEmptyLayer (const QString &providerKey, const QString &uri, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, QMap< int, int > &oldToNewAttrIdxMap, QString &errorMessage, const QMap< QString, QVariant > *options)
 Creates new empty vector layer.
 
QgsDataProvidercreateProvider (const QString &providerKey, const QString &dataSource, const QgsDataProvider::ProviderOptions &options=QgsDataProvider::ProviderOptions(), Qgis::DataProviderReadFlags flags=Qgis::DataProviderReadFlags())
 Creates a new instance of a provider.
 
Q_DECL_DEPRECATED QLibrary * createProviderLibrary (const QString &providerKey) const
 Returns a new QLibrary for the specified providerKey.
 
QgsRasterDataProvidercreateRasterDataProvider (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.
 
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.
 
QgsTransactioncreateTransaction (const QString &providerKey, const QString &connString)
 Returns new instance of transaction.
 
QString databaseDrivers () const
 Returns a string containing the available database drivers.
 
QList< QgsDataItemProvider * > dataItemProviders (const QString &providerKey) const
 Returns list of data item providers of the provider.
 
QVariantMap decodeUri (const QString &providerKey, const QString &uri)
 Breaks a provider data source URI into its component paths (e.g.
 
bool deleteStyleById (const QString &providerKey, const QString &uri, const QString &styleId, QString &errCause)
 Deletes a layer style defined by styleId.
 
QString directoryDrivers () const
 Returns a string containing the available directory drivers.
 
QString encodeUri (const QString &providerKey, const QVariantMap &parts)
 Reassembles a provider data source URI from its component paths (e.g.
 
QString fileMeshDatasetFilters () const
 Returns a file filter string for supported mesh dataset files.
 
QString fileMeshFilters () const
 Returns a file filter string for supported mesh files.
 
QString filePointCloudFilters () const
 Returns a file filter string for supported point clouds.
 
QString fileRasterFilters () const
 Returns a file filter string for supported raster files.
 
QString fileTiledSceneFilters () const
 Returns a file filter string for supported tiled scene files.
 
QString fileVectorFilters () const
 Returns a file filter string for supported vector files.
 
QString fileVectorTileFilters () const
 Returns a file filter string for supported vector tile files.
 
Q_DECL_DEPRECATED QFunctionPointer function (const QString &providerKey, const QString &functionName) const
 Gets pointer to provider function.
 
QString getStyleById (const QString &providerKey, const QString &uri, const QString &styleId, QString &errCause)
 Gets a layer style defined by styleId.
 
bool handleUnusableUri (const QString &uri, UnusableUriDetails &details) const
 Returns true if the specified uri can potentially be handled by QGIS, if additional dependencies or build-time requirements are present.
 
Q_DECL_DEPRECATED QString library (const QString &providerKey) const
 Returns path for the library of the provider.
 
QDir libraryDirectory () const
 Returns the library directory where plugins are 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.
 
QString loadStoredStyle (const QString &providerKey, const QString &uri, QString &styleName, QString &errCause)
 Loads a layer style from the provider storage, reporting its name.
 
QString loadStyle (const QString &providerKey, const QString &uri, QString &errCause)
 Loads a layer style defined by uri.
 
QString pluginList (bool asHtml=false) const
 Returns list of provider plugins found.
 
QList< QgsProviderRegistry::ProviderCandidateDetailspreferredProvidersForUri (const QString &uri) const
 Returns the details for the preferred provider(s) for opening the specified uri.
 
QString protocolDrivers () const
 Returns a string containing the available protocol drivers.
 
Q_DECL_DEPRECATED Qgis::DataItemProviderCapabilities providerCapabilities (const QString &providerKey) const
 Returns the provider capabilities.
 
QStringList providerList () const
 Returns list of available providers by their keys.
 
QgsProviderMetadataproviderMetadata (const QString &providerKey) const
 Returns metadata of the provider or nullptr if not found.
 
QSet< QString > providersForLayerType (Qgis::LayerType type) const
 Returns a list of the provider keys for available providers which handle the specified layer type.
 
QList< QPair< QString, QString > > pyramidResamplingMethods (const QString &providerKey)
 Returns list of raster pyramid resampling methods.
 
QList< QgsProviderSublayerDetailsquerySublayers (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 handled by any registered data provider.
 
Q_DECL_DEPRECATED void registerGuis (QWidget *widget)
 
bool registerProvider (QgsProviderMetadata *providerMetadata)
 register a new vector data provider from its providerMetadata
 
bool registerUnusableUriHandler (UnusableUriHandlerInterface *handler)
 Registers an unusable URI handler, used to handle unusable URIs which aren't handled by any registered providers, and construct user-friendly warnings as to why the URI is unusable.
 
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.
 
bool saveLayerMetadata (const QString &providerKey, const QString &uri, const QgsLayerMetadata &metadata, QString &errorMessage)
 Saves metadata to the layer corresponding to the specified uri.
 
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.
 
void setLibraryDirectory (const QDir &path)
 Sets library directory where to search for plugins.
 
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 another provider.
 
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 providerKey and uri.
 
bool uriIsBlocklisted (const QString &uri) const
 Returns true if the specified uri is known by any registered provider to be something which should be blocklisted from the QGIS interface, e.g.
 

Static Public Member Functions

static QgsProviderRegistryinstance (const QString &pluginPath=QString())
 Means of accessing canonical single instance.
 

Friends

class QgsApplication
 

Detailed Description

A registry / canonical manager of data providers.

This is a Singleton class that manages data provider access.

Providers can be either loaded via libraries or native providers that are included in the core QGIS installation and accessed through function pointers.

Loaded providers may be restricted using QGIS_PROVIDER_FILE environment variable. QGIS_PROVIDER_FILE is regexp pattern applied to provider file name (not provider key). For example, if the variable is set to gdal|ogr|postgres it will load only providers gdal, ogr and postgres.

Definition at line 57 of file qgsproviderregistry.h.

Member Typedef Documentation

◆ Providers

Type for data provider metadata associative container.

Definition at line 747 of file qgsproviderregistry.h.

Member Enumeration Documentation

◆ WidgetMode

Different ways a source select dialog can be used.

Enumerator
Standalone 

Basic mode when the widget is used as a standalone dialog.

Originally used as GUI for individual "Add XXX layer" buttons in the main window. Likely not used in live code anymore.

Embedded 

Used for the data source manager dialog where the widget is embedded as the main content for a particular tab.

Manager 

Used by data items for QgsDataItem::paramWidget().

Originally used by QGIS Browser, but does not seem to be in live code anymore. The mode was meant to avoid some actions to keep the browser interface simple (supposedly).

Definition at line 67 of file qgsproviderregistry.h.

Constructor & Destructor Documentation

◆ ~QgsProviderRegistry()

QgsProviderRegistry::~QgsProviderRegistry ( )

Definition at line 550 of file qgsproviderregistry.cpp.

Member Function Documentation

◆ absoluteToRelativeUri()

QString QgsProviderRegistry::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.

and returns modified URI according to the context object's configuration. This is commonly used when writing project files. If a provider does not work with paths, unmodified URI will be returned.

Returns
modified URI with relative path(s)
Note
this function may not be supported by all providers. The default implementation uses QgsPathResolver::writePath() on the whole URI.
See also
relativeToAbsoluteUri()
Since
QGIS 3.30

Definition at line 673 of file qgsproviderregistry.cpp.

◆ createDb()

bool QgsProviderRegistry::createDb ( const QString &  providerKey,
const QString &  dbPath,
QString &  errCause 
)

Creates database by the provider on the path.

Since
QGIS 3.10

Definition at line 852 of file qgsproviderregistry.cpp.

◆ createEmptyLayer()

Qgis::VectorExportResult QgsProviderRegistry::createEmptyLayer ( const QString &  providerKey,
const QString &  uri,
const QgsFields fields,
Qgis::WkbType  wkbType,
const QgsCoordinateReferenceSystem srs,
bool  overwrite,
QMap< int, int > &  oldToNewAttrIdxMap,
QString &  errorMessage,
const QMap< QString, QVariant > *  options 
)

Creates new empty vector layer.

Note
not available in Python bindings
Since
QGIS 3.10

Definition at line 691 of file qgsproviderregistry.cpp.

◆ createProvider()

QgsDataProvider * QgsProviderRegistry::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.

Parameters
providerKeyidentifier of the provider
dataSourcestring containing data source for the provider
optionsprovider options
flagsprovider flags since QGIS 3.16
Returns
new instance of provider or nullptr on error
See also
createRasterDataProvider()

Definition at line 626 of file qgsproviderregistry.cpp.

◆ createProviderLibrary()

QLibrary * QgsProviderRegistry::createProviderLibrary ( const QString &  providerKey) const

Returns a new QLibrary for the specified providerKey.

Ownership of the returned object is transferred to the caller and the caller is responsible for deleting it.

If the provider uses direct provider function pointers instead of a library nullptr will be returned.

Deprecated:
QGIS 3.10. Providers may not need to be loaded from a library.

Definition at line 908 of file qgsproviderregistry.cpp.

◆ createRasterDataProvider()

QgsRasterDataProvider * QgsProviderRegistry::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.

See also
createProvider()
Since
QGIS 3.10

Definition at line 710 of file qgsproviderregistry.cpp.

◆ createSelectionWidget()

QWidget * QgsProviderRegistry::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.

Either the parent widget must be set or the caller becomes responsible for deleting the returned widget.

Deprecated:
QGIS 3.10. Use QgsGui::sourceSelectProviderRegistry()->createDataSourceWidget() instead.

Definition at line 873 of file qgsproviderregistry.cpp.

◆ createTransaction()

QgsTransaction * QgsProviderRegistry::createTransaction ( const QString &  providerKey,
const QString &  connString 
)

Returns new instance of transaction.

Ownership is transferred to the caller

Since
QGIS 3.10

Definition at line 864 of file qgsproviderregistry.cpp.

◆ databaseDrivers()

QString QgsProviderRegistry::databaseDrivers ( ) const

Returns a string containing the available database drivers.

Definition at line 991 of file qgsproviderregistry.cpp.

◆ dataItemProviders()

QList< QgsDataItemProvider * > QgsProviderRegistry::dataItemProviders ( const QString &  providerKey) const

Returns list of data item providers of the provider.

Note
Ownership of created data item providers is passed to the caller.
Since
QGIS 3.10

Definition at line 731 of file qgsproviderregistry.cpp.

◆ decodeUri()

QVariantMap QgsProviderRegistry::decodeUri ( const QString &  providerKey,
const QString &  uri 
)

Breaks a provider data source URI into its component paths (e.g.

file path, layer name).

Parameters
providerKeyidentifier of the provider
uriuri string
Returns
map containing components. Standard components include "path", "layerName", "url".
Note
this function may not be supported by all providers, an empty map will be returned in such case
Since
QGIS 3.4

Definition at line 655 of file qgsproviderregistry.cpp.

◆ deleteStyleById()

bool QgsProviderRegistry::deleteStyleById ( const QString &  providerKey,
const QString &  uri,
const QString &  styleId,
QString &  errCause 
)

Deletes a layer style defined by styleId.

Since
QGIS 3.10

Definition at line 785 of file qgsproviderregistry.cpp.

◆ directoryDrivers()

QString QgsProviderRegistry::directoryDrivers ( ) const

Returns a string containing the available directory drivers.

Definition at line 996 of file qgsproviderregistry.cpp.

◆ encodeUri()

QString QgsProviderRegistry::encodeUri ( const QString &  providerKey,
const QVariantMap &  parts 
)

Reassembles a provider data source URI from its component paths (e.g.

file path, layer name).

Parameters
providerKeyidentifier of the provider
partsparts as returned by decodeUri
Returns
datasource uri string
Note
this function may not be supported by all providers, an empty string will be returned in such case
See also
decodeUri()
Since
QGIS 3.12

Definition at line 664 of file qgsproviderregistry.cpp.

◆ fileMeshDatasetFilters()

QString QgsProviderRegistry::fileMeshDatasetFilters ( ) const

Returns a file filter string for supported mesh dataset files.

Returns a string suitable for a QFileDialog of mesh datasets file formats supported by all data providers.

See also
fileMeshFilters()
Since
QGIS 3.6

Definition at line 971 of file qgsproviderregistry.cpp.

◆ fileMeshFilters()

QString QgsProviderRegistry::fileMeshFilters ( ) const

Returns a file filter string for supported mesh files.

Returns a string suitable for a QFileDialog of mesh file formats supported by all data providers.

See also
fileMeshDatasetFilters()
fileRasterFilters()
fileVectorFilters()
filePointCloudFilters()
fileVectorTileFilters()
fileTiledSceneFilters()
Since
QGIS 3.6

Definition at line 966 of file qgsproviderregistry.cpp.

◆ filePointCloudFilters()

QString QgsProviderRegistry::filePointCloudFilters ( ) const

Returns a file filter string for supported point clouds.

Returns a string suitable for a QFileDialog of point cloud file formats supported by all data providers.

See also
fileMeshFilters()
fileRasterFilters()
fileVectorFilters()
fileVectorTileFilters()
fileTiledSceneFilters()
Since
QGIS 3.18

Definition at line 976 of file qgsproviderregistry.cpp.

◆ fileRasterFilters()

QString QgsProviderRegistry::fileRasterFilters ( ) const

Returns a file filter string for supported raster files.

Returns a string suitable for a QFileDialog of raster file formats supported by all data providers.

Note
This replaces QgsRasterLayer::buildSupportedRasterFileFilter()
See also
fileVectorFilters()
fileMeshFilters()
filePointCloudFilters()
fileVectorTileFilters()
fileTiledSceneFilters()

Definition at line 961 of file qgsproviderregistry.cpp.

◆ fileTiledSceneFilters()

QString QgsProviderRegistry::fileTiledSceneFilters ( ) const

Returns a file filter string for supported tiled scene files.

Returns a string suitable for a QFileDialog of tiled scene file formats supported by all data providers.

See also
fileMeshFilters()
fileRasterFilters()
fileVectorFilters()
filePointCloudFilters()
fileVectorTileFilters()
Since
QGIS 3.34

Definition at line 986 of file qgsproviderregistry.cpp.

◆ fileVectorFilters()

QString QgsProviderRegistry::fileVectorFilters ( ) const

Returns a file filter string for supported vector files.

Returns a string suitable for a QFileDialog of vector file formats supported by all data providers.

See also
fileRasterFilters()
fileMeshFilters()
filePointCloudFilters()
fileVectorTileFilters()
fileTiledSceneFilters()

Definition at line 956 of file qgsproviderregistry.cpp.

◆ fileVectorTileFilters()

QString QgsProviderRegistry::fileVectorTileFilters ( ) const

Returns a file filter string for supported vector tile files.

Returns a string suitable for a QFileDialog of vector tile file formats supported by all data providers.

See also
fileMeshFilters()
fileRasterFilters()
fileVectorFilters()
filePointCloudFilters()
fileTiledSceneFilters()
Since
QGIS 3.32

Definition at line 981 of file qgsproviderregistry.cpp.

◆ function()

QFunctionPointer QgsProviderRegistry::function ( const QString &  providerKey,
const QString &  functionName 
) const

Gets pointer to provider function.

Parameters
providerKeyidentifier of the provider
functionNamename of function
Returns
pointer to function or nullptr on error. If the provider uses direct provider function pointers instead of a library nullptr will be returned.
Deprecated:
QGIS 3.10. Any provider functionality should be accessed through QgsProviderMetadata.

Definition at line 884 of file qgsproviderregistry.cpp.

◆ getStyleById()

QString QgsProviderRegistry::getStyleById ( const QString &  providerKey,
const QString &  uri,
const QString &  styleId,
QString &  errCause 
)

Gets a layer style defined by styleId.

See also
styleExists()
Since
QGIS 3.10

Definition at line 770 of file qgsproviderregistry.cpp.

◆ handleUnusableUri()

bool QgsProviderRegistry::handleUnusableUri ( const QString &  uri,
UnusableUriDetails details 
) const

Returns true if the specified uri can potentially be handled by QGIS, if additional dependencies or build-time requirements are present.

This can be used to show user-friendly warning messages advising them why a particular uri cannot be opened on their QGIS install. For example, if a QGIS install is built without the PDAL library then las/laz files are unusable, and this method can be used to retrieve a user-friendly warning as to why the las/laz files cannot be used on their QGIS build.

Warning
This method does not perform the test to actually determine if the given uri can be handled by any registered provider. It is assumed that prior to calling this method the caller has already determined in advance that the uri could not be handled.
Parameters
uriURI to test
detailswill be populated with details allowing construction of a user-friendly warning message
Returns
true if the uri was matched to a registered QgsProviderRegistry::UnusableUriHandlerInterface.
See also
registerUnusableUriHandler()
Since
QGIS 3.18.1

Definition at line 1064 of file qgsproviderregistry.cpp.

◆ instance()

QgsProviderRegistry * QgsProviderRegistry::instance ( const QString &  pluginPath = QString())
static

Means of accessing canonical single instance.

Definition at line 83 of file qgsproviderregistry.cpp.

◆ library()

QString QgsProviderRegistry::library ( const QString &  providerKey) const

Returns path for the library of the provider.

If the provider uses direct provider function pointers instead of a library an empty string will be returned.

Deprecated:
QGIS 3.10. Providers may not need to be loaded from a library (empty string returned).

Definition at line 559 of file qgsproviderregistry.cpp.

◆ libraryDirectory()

QDir QgsProviderRegistry::libraryDirectory ( ) const

Returns the library directory where plugins are found.

Definition at line 613 of file qgsproviderregistry.cpp.

◆ listStyles()

int QgsProviderRegistry::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.

Returns
-1 if not implemented by provider, otherwise number of styles stored
Since
QGIS 3.10

Definition at line 740 of file qgsproviderregistry.cpp.

◆ loadStoredStyle()

QString QgsProviderRegistry::loadStoredStyle ( const QString &  providerKey,
const QString &  uri,
QString &  styleName,
QString &  errCause 
)

Loads a layer style from the provider storage, reporting its name.

Parameters
providerKeyname of the data provider
uridata source uri
styleNamethe name of the style if available, empty otherwise
errCausereport errors
Returns
the style QML (XML)
Since
QGIS 3.30

Definition at line 828 of file qgsproviderregistry.cpp.

◆ loadStyle()

QString QgsProviderRegistry::loadStyle ( const QString &  providerKey,
const QString &  uri,
QString &  errCause 
)

Loads a layer style defined by uri.

Returns
the style QML (XML)
Since
QGIS 3.10

Definition at line 815 of file qgsproviderregistry.cpp.

◆ pluginList()

QString QgsProviderRegistry::pluginList ( bool  asHtml = false) const

Returns list of provider plugins found.

Definition at line 573 of file qgsproviderregistry.cpp.

◆ preferredProvidersForUri()

QList< QgsProviderRegistry::ProviderCandidateDetails > QgsProviderRegistry::preferredProvidersForUri ( const QString &  uri) const

Returns the details for the preferred provider(s) for opening the specified uri.

The preferred provider is determined by comparing the priority returned by QgsProviderMetadata::priorityForUri() for all registered providers, and selecting the provider with the largest non-zero priority.

An empty list may be returned, which indicates that no providers are available which returned a non-zero priority for the specified URI.

In the case that multiple providers returned the same priority for the URI then all of these providers will be returned.

See also
shouldDeferUriForOtherProviders()
Since
QGIS 3.18

Definition at line 1032 of file qgsproviderregistry.cpp.

◆ protocolDrivers()

QString QgsProviderRegistry::protocolDrivers ( ) const

Returns a string containing the available protocol drivers.

Definition at line 1001 of file qgsproviderregistry.cpp.

◆ providerCapabilities()

Qgis::DataItemProviderCapabilities QgsProviderRegistry::providerCapabilities ( const QString &  providerKey) const

Returns the provider capabilities.

Parameters
providerKeyidentifier of the provider
Deprecated:
QGIS 3.10. Use instead capabilities() method of individual data item provider.

Definition at line 643 of file qgsproviderregistry.cpp.

◆ providerList()

QStringList QgsProviderRegistry::providerList ( ) const

Returns list of available providers by their keys.

Definition at line 1006 of file qgsproviderregistry.cpp.

◆ providerMetadata()

QgsProviderMetadata * QgsProviderRegistry::providerMetadata ( const QString &  providerKey) const

Returns metadata of the provider or nullptr if not found.

Definition at line 1016 of file qgsproviderregistry.cpp.

◆ providersForLayerType()

QSet< QString > QgsProviderRegistry::providersForLayerType ( Qgis::LayerType  type) const

Returns a list of the provider keys for available providers which handle the specified layer type.

Since
QGIS 3.26

Definition at line 1021 of file qgsproviderregistry.cpp.

◆ pyramidResamplingMethods()

QList< QPair< QString, QString > > QgsProviderRegistry::pyramidResamplingMethods ( const QString &  providerKey)

Returns list of raster pyramid resampling methods.

Since
QGIS 3.10

Definition at line 722 of file qgsproviderregistry.cpp.

◆ querySublayers()

QList< QgsProviderSublayerDetails > QgsProviderRegistry::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 handled by any registered data provider.

This method iteratively queries each registered data provider and returns the complete collated list of all valid sublayers found in the dataset which can be opened by the data providers.

The optional flags argument can be used to control the behavior of the query.

The optional feedback argument can be used to provide cancellation support for long-running queries.

Since
QGIS 3.22

Definition at line 1101 of file qgsproviderregistry.cpp.

◆ registerGuis()

void QgsProviderRegistry::registerGuis ( QWidget *  widget)
Deprecated:
QGIS 3.10. Does nothing - use QgsGui::providerGuiRegistry().

Definition at line 928 of file qgsproviderregistry.cpp.

◆ registerProvider()

bool QgsProviderRegistry::registerProvider ( QgsProviderMetadata providerMetadata)

register a new vector data provider from its providerMetadata

Returns
true on success, false if a provider with the same key was already registered
Note
ownership of the QgsProviderMetadata instance is transferred to the registry
Since
QGIS 3.2

Definition at line 933 of file qgsproviderregistry.cpp.

◆ registerUnusableUriHandler()

bool QgsProviderRegistry::registerUnusableUriHandler ( QgsProviderRegistry::UnusableUriHandlerInterface handler)

Registers an unusable URI handler, used to handle unusable URIs which aren't handled by any registered providers, and construct user-friendly warnings as to why the URI is unusable.

Returns
true on success
Note
ownership of the UnusableUriHandlerInterface instance is transferred to the registry
Since
QGIS 3.18.1

Definition at line 1058 of file qgsproviderregistry.cpp.

◆ relativeToAbsoluteUri()

QString QgsProviderRegistry::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.

and returns modified URI according to the context object's configuration. This is commonly used when reading project files. If a provider does not work with paths, unmodified URI will be returned.

Returns
modified URI with absolute path(s)
Note
this function may not be supported by all providers. The default implementation uses QgsPathResolver::readPath() on the whole URI.
See also
absoluteToRelativeUri()
Since
QGIS 3.30

Definition at line 682 of file qgsproviderregistry.cpp.

◆ saveLayerMetadata()

bool QgsProviderRegistry::saveLayerMetadata ( const QString &  providerKey,
const QString &  uri,
const QgsLayerMetadata metadata,
QString &  errorMessage 
)

Saves metadata to the layer corresponding to the specified uri.

Parameters
providerKeyidentifier of the provider
uriuri of layer to store metadata for
metadatalayer metadata
errorMessagedescriptive string of error if encountered
Returns
true if the metadata was successfully saved.
Exceptions
QgsNotSupportedExceptionif the provider does not support saving layer metadata for the specified uri.
Since
QGIS 3.20

Definition at line 841 of file qgsproviderregistry.cpp.

◆ saveStyle()

bool QgsProviderRegistry::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.

Since
QGIS 3.10

Definition at line 799 of file qgsproviderregistry.cpp.

◆ setLibraryDirectory()

void QgsProviderRegistry::setLibraryDirectory ( const QDir &  path)

Sets library directory where to search for plugins.

Definition at line 606 of file qgsproviderregistry.cpp.

◆ shouldDeferUriForOtherProviders()

bool QgsProviderRegistry::shouldDeferUriForOtherProviders ( const QString &  uri,
const QString &  providerKey 
) const

Returns true if the provider with matching providerKey should defer handling of the specified uri to another provider.

This method tests whether any providers are listed as the preferred provider for uri (see preferredProvidersForUri()), and if so tests whether the specified provider is included in that preferred providers list. Returns true only if the specified provider is calculated as one of the preferred providers for the URI.

In the case that there is no registered preferred provider for the URI then false will be returned, and the provider must use another metric to determine whether it should handle the URI.

See also
preferredProvidersForUri()
Since
QGIS 3.18

Definition at line 1077 of file qgsproviderregistry.cpp.

◆ styleExists()

bool QgsProviderRegistry::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 providerKey and uri.

Parameters
providerKeyprovider key
uriprovider URI
styleIdstyle ID to test for
errorCausewill be set to a descriptive error message, if an error occurs while checking if the style exists
Returns
true if the layer style already exists
See also
getStyleById()
Since
QGIS 3.24

Definition at line 755 of file qgsproviderregistry.cpp.

◆ uriIsBlocklisted()

bool QgsProviderRegistry::uriIsBlocklisted ( const QString &  uri) const

Returns true if the specified uri is known by any registered provider to be something which should be blocklisted from the QGIS interface, e.g.

an internal detail only.

Specifically, this method can be utilized by the browser panel to hide noisy internal details for URIs which are known to be sidecar files only, such as ".aux.xml" files or ".shp.xml" files, or the "ept-build.json" files which sit alongside Entwine "ept.json" point cloud sources.

This method tests whether any of the registered providers return true for the their QgsProviderMetadata::uriIsBlocklisted() implementation for the specified URI.

Since
QGIS 3.18

Definition at line 1091 of file qgsproviderregistry.cpp.

Friends And Related Symbol Documentation

◆ QgsApplication

friend class QgsApplication
friend

Definition at line 839 of file qgsproviderregistry.h.


The documentation for this class was generated from the following files: