QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
Public Types | Signals | Public Member Functions | Static Public Member Functions | List of all members
QgsProviderMetadata Class Reference

Holds data provider key, description, and associated shared library file or function pointer information. More...

#include <qgsprovidermetadata.h>

Inheritance diagram for QgsProviderMetadata:
Inheritance graph
[legend]

Public Types

typedef std::function< QgsDataProvider *(const QString &, const QgsDataProvider::ProviderOptions &, Qgis::DataProviderReadFlags &) > CreateDataProviderFunction
 Typedef for data provider creation function.
 
typedef QFlags< ProviderCapabilityProviderCapabilities
 
enum  ProviderCapability { FileBasedUris = 1 << 0 , SaveLayerMetadata = 1 << 1 , ParallelCreateProvider = 1 << 2 }
 Provider capabilities. More...
 
typedef QFlags< ProviderMetadataCapabilityProviderMetadataCapabilities
 
enum  ProviderMetadataCapability { PriorityForUri = 1 << 0 , LayerTypesForUri = 1 << 1 , QuerySublayers = 1 << 2 , CreateDatabase = 1 << 3 }
 Indicates capabilities of the provider metadata implementation. More...
 

Signals

void connectionChanged (const QString &name)
 Emitted when the connection with the specified name is changed, e.g.
 
void connectionCreated (const QString &name)
 Emitted when a connection with the specified name is created.
 
void connectionDeleted (const QString &name)
 Emitted when the connection with the specified name was deleted.
 

Public Member Functions

Q_DECL_DEPRECATED QgsProviderMetadata (const QString &key, const QString &description, const QgsProviderMetadata::CreateDataProviderFunction &createFunc)
 Metadata for provider with direct provider creation function pointer, where no library is involved.
 
 QgsProviderMetadata (const QString &key, const QString &description, const QString &library=QString())
 Constructor for provider metadata.
 
virtual ~QgsProviderMetadata ()
 
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 QgsProviderMetadata::ProviderMetadataCapabilities capabilities () const
 Returns the provider metadata capabilities.
 
virtual void cleanupProvider ()
 Cleanup the provider.
 
virtual QMap< QString, QgsAbstractProviderConnection * > connections (bool cached=true)
 Returns a dictionary of stored provider connections, the dictionary key is the connection identifier.
 
template<typename T >
QMap< QString, T * > connections (bool cached=true)
 Returns a dictionary of provider connections of the specified type T, the dictionary key is the connection identifier.
 
virtual QgsAbstractProviderConnectioncreateConnection (const QString &name)
 Creates a new connection by loading the connection with the given name from the settings.
 
virtual QgsAbstractProviderConnectioncreateConnection (const QString &uri, const QVariantMap &configuration)
 Creates a new connection from uri and configuration, the newly created connection is not automatically stored in the settings, call saveConnection() to save it.
 
virtual bool createDatabase (const QString &uri, QString &errorMessage)
 Creates a new empty database at the specified uri.
 
virtual bool createDb (const QString &dbPath, QString &errCause)
 Creates database by the provider on the path.
 
virtual Qgis::VectorExportResult createEmptyLayer (const QString &uri, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, QMap< int, int > &oldToNewAttrIdxMap, QString &errorMessage, const QMap< QString, QVariant > *options)
 Creates new empty vector layer.
 
Q_DECL_DEPRECATED CreateDataProviderFunction createFunction () const
 Returns a pointer to the direct provider creation function, if supported by the provider.
 
virtual bool createMeshData (const QgsMesh &mesh, const QString &fileName, const QString &driverName, const QgsCoordinateReferenceSystem &crs, const QMap< QString, QString > &metadata=QMap< QString, QString >()) const
 Creates mesh data source from a file name fileName and a driver driverName, that is the mesh frame stored in file, memory or with other way (depending of the provider) Since QGIS 3.38 the optional metadata argument can be used to pass metadata to the provider.
 
virtual bool createMeshData (const QgsMesh &mesh, const QString &uri, const QgsCoordinateReferenceSystem &crs, const QMap< QString, QString > &metadata=QMap< QString, QString >()) const
 Creates mesh data source from an uri, that is the mesh frame stored in file, memory or with other way (depending of the provider) Since QGIS 3.38 the optional metadata argument can be used to pass metadata to the provider.
 
virtual QgsDataProvidercreateProvider (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 QgsRasterDataProvidercreateRasterDataProvider (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 QgsTransactioncreateTransaction (const QString &connString)
 Returns new instance of transaction.
 
virtual QList< QgsDataItemProvider * > dataItemProviders () const
 Returns data item providers.
 
QMap< QString, QgsAbstractDatabaseProviderConnection * > dbConnections (bool cached=true)
 Returns a dictionary of database provider connections, the dictionary key is the connection identifier.
 
virtual QVariantMap decodeUri (const QString &uri) const
 Breaks a provider data source URI into its component paths (e.g.
 
virtual void deleteConnection (const QString &name)
 Removes the connection with the given name from the settings.
 
virtual bool deleteStyleById (const QString &uri, const QString &styleId, QString &errCause)
 Deletes a layer style defined by styleId.
 
QString description () const
 This returns descriptive text for the provider.
 
virtual QString encodeUri (const QVariantMap &parts) const
 Reassembles a provider data source URI from its component paths (e.g.
 
virtual QString filters (Qgis::FileFilterType type)
 Builds the list of file filter strings (supported formats)
 
QgsAbstractProviderConnectionfindConnection (const QString &name, bool cached=true)
 Searches and returns a (possibly nullptr) connection from the stored provider connections.
 
virtual QString getStyleById (const QString &uri, const QString &styleId, QString &errCause)
 Gets a layer style defined by uri.
 
virtual QIcon icon () const
 Returns an icon representing the provider.
 
virtual void initProvider ()
 Initialize the provider.
 
QString key () const
 This returns the unique key associated with the provider.
 
Q_DECL_DEPRECATED QString library () const
 This returns the library file name.
 
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 QString loadStoredStyle (const QString &uri, QString &styleName, QString &errCause)
 Loads a layer style from the provider storage, reporting its name.
 
virtual QString loadStyle (const QString &uri, QString &errCause)
 Loads a layer style defined by uri.
 
virtual QList< QgsMeshDriverMetadatameshDriversMetadata ()
 Builds the list of available mesh drivers metadata.
 
virtual int priorityForUri (const QString &uri) const
 Returns an integer representing the priority which this provider should have when opening a dataset with the specified uri.
 
virtual QgsProviderMetadata::ProviderCapabilities providerCapabilities () const
 Returns the provider's capabilities.
 
virtual QList< QPair< QString, QString > > pyramidResamplingMethods ()
 Returns pyramid resampling methods available for provider.
 
virtual 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 this provider.
 
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 void saveConnection (const QgsAbstractProviderConnection *connection, const QString &name)
 Stores the connection in the settings.
 
virtual bool saveLayerMetadata (const QString &uri, const QgsLayerMetadata &metadata, QString &errorMessage)
 Saves metadata to the layer corresponding to the specified uri.
 
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 QStringList sidecarFilesForUri (const QString &uri) const
 Given a uri, returns any sidecar files which are associated with the URI and this provider.
 
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 QString suggestGroupNameForUri (const QString &uri) const
 Returns a name that can be used as a group name for sublayers retrieved from the specified uri.
 
virtual QList< Qgis::LayerTypesupportedLayerTypes () const
 Returns a list of the map layer types supported by the provider.
 
virtual bool uriIsBlocklisted (const QString &uri) const
 Returns true if the specified uri is known by this provider to be something which should be blocklisted from the QGIS interface, e.g.
 
virtual QList< Qgis::LayerTypevalidLayerTypesForUri (const QString &uri) const
 Returns a list of valid layer types which the provider can be used with when opening the specified uri.
 

Static Public Member Functions

static bool boolParameter (const QVariantMap &uri, const QString &parameter, bool defaultValue=false)
 Returns the parameter value in the uri as a bool.
 
static void setBoolParameter (QVariantMap &uri, const QString &parameter, const QVariant &value)
 Sets the value into the uri parameter as a bool.
 

Detailed Description

Holds data provider key, description, and associated shared library file or function pointer information.

Provider metadata refers either to providers which are loaded via libraries or which are native providers that are included in the core QGIS installation and accessed through function pointers.

For library based providers, the metadata class is used in a lazy load implementation in QgsProviderRegistry. To save memory, data providers are only actually loaded via QLibrary calls if they're to be used. (Though they're all iteratively loaded once to get their metadata information, and then unloaded when the QgsProviderRegistry is created.) QgsProviderMetadata supplies enough information to be able to later load the associated shared library object.

Definition at line 176 of file qgsprovidermetadata.h.

Member Typedef Documentation

◆ CreateDataProviderFunction

Typedef for data provider creation function.

Definition at line 212 of file qgsprovidermetadata.h.

◆ ProviderCapabilities

Definition at line 207 of file qgsprovidermetadata.h.

◆ ProviderMetadataCapabilities

Definition at line 194 of file qgsprovidermetadata.h.

Member Enumeration Documentation

◆ ProviderCapability

Provider capabilities.

Since
QGIS 3.18.1
Enumerator
FileBasedUris 

Indicates that the provider can utilize URIs which are based on paths to files (as opposed to database or internet paths)

SaveLayerMetadata 

Indicates that the provider supports saving native layer metadata.

Since
QGIS 3.20
ParallelCreateProvider 

Indicates that the provider supports parallel creation, that is, can be created on another thread than the main thread.

Since
QGIS 3.32

Definition at line 201 of file qgsprovidermetadata.h.

◆ ProviderMetadataCapability

Indicates capabilities of the provider metadata implementation.

Since
QGIS 3.18
Enumerator
PriorityForUri 

Indicates that the metadata can calculate a priority for a URI.

LayerTypesForUri 

Indicates that the metadata can determine valid layer types for a URI.

QuerySublayers 

Indicates that the metadata can query sublayers for a URI.

Since
QGIS 3.22
CreateDatabase 

Indicates that the metadata can create new empty databases.

Since
QGIS 3.28

Definition at line 187 of file qgsprovidermetadata.h.

Constructor & Destructor Documentation

◆ QgsProviderMetadata() [1/2]

QgsProviderMetadata::QgsProviderMetadata ( const QString &  key,
const QString &  description,
const QString &  library = QString() 
)

Constructor for provider metadata.

Parameters
keyprovider key
descriptionprovider description
libraryplugin library file name (empty if the provider is not loaded from a library)

Definition at line 27 of file qgsprovidermetadata.cpp.

◆ QgsProviderMetadata() [2/2]

QgsProviderMetadata::QgsProviderMetadata ( const QString &  key,
const QString &  description,
const QgsProviderMetadata::CreateDataProviderFunction createFunc 
)

Metadata for provider with direct provider creation function pointer, where no library is involved.

Deprecated:
QGIS 3.10

Definition at line 35 of file qgsprovidermetadata.cpp.

◆ ~QgsProviderMetadata()

QgsProviderMetadata::~QgsProviderMetadata ( )
virtual

Definition at line 41 of file qgsprovidermetadata.cpp.

Member Function Documentation

◆ absoluteToRelativeUri()

QString QgsProviderMetadata::absoluteToRelativeUri ( const QString &  uri,
const QgsReadWriteContext context 
) const
virtual

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 191 of file qgsprovidermetadata.cpp.

◆ boolParameter()

bool QgsProviderMetadata::boolParameter ( const QVariantMap &  uri,
const QString &  parameter,
bool  defaultValue = false 
)
static

Returns the parameter value in the uri as a bool.

eg. "yes" value will be returned as true, 0 will be returned as false

Since
QGIS 3.14

Definition at line 163 of file qgsprovidermetadata.cpp.

◆ capabilities()

QgsProviderMetadata::ProviderMetadataCapabilities QgsProviderMetadata::capabilities ( ) const
virtual

Returns the provider metadata capabilities.

Since
QGIS 3.18

Definition at line 61 of file qgsprovidermetadata.cpp.

◆ cleanupProvider()

void QgsProviderMetadata::cleanupProvider ( )
virtual

Cleanup the provider.

Since
QGIS 3.10

Definition at line 96 of file qgsprovidermetadata.cpp.

◆ connectionChanged

void QgsProviderMetadata::connectionChanged ( const QString &  name)
signal

Emitted when the connection with the specified name is changed, e.g.

the settings relating to the connection have been updated.

Note
Only providers which implement the connection handling API will emit this signal.
Since
QGIS 3.14

◆ connectionCreated

void QgsProviderMetadata::connectionCreated ( const QString &  name)
signal

Emitted when a connection with the specified name is created.

Note
Only providers which implement the connection handling API will emit this signal.
Since
QGIS 3.14

◆ connectionDeleted

void QgsProviderMetadata::connectionDeleted ( const QString &  name)
signal

Emitted when the connection with the specified name was deleted.

Note
Only providers which implement the connection handling API will emit this signal.
Since
QGIS 3.14

◆ connections() [1/2]

QMap< QString, QgsAbstractProviderConnection * > QgsProviderMetadata::connections ( bool  cached = true)
virtual

Returns a dictionary of stored provider connections, the dictionary key is the connection identifier.

Ownership is not transferred. Raises a QgsProviderConnectionException if any errors are encountered.

Parameters
cachedif false connections will be re-read from the settings
Exceptions
QgsProviderConnectionException
Since
QGIS 3.10

Definition at line 314 of file qgsprovidermetadata.cpp.

◆ connections() [2/2]

template<typename T >
QMap< QString, T * > QgsProviderMetadata::connections ( bool  cached = true)

Returns a dictionary of provider connections of the specified type T, the dictionary key is the connection identifier.

Parameters
cachedif false connections will be re-read from the settings
Note
not available in Python bindings
Since
QGIS 3.10

Definition at line 381 of file qgsprovidermetadata.cpp.

◆ createConnection() [1/2]

QgsAbstractProviderConnection * QgsProviderMetadata::createConnection ( const QString &  name)
virtual

Creates a new connection by loading the connection with the given name from the settings.

Ownership is transferred to the caller.

Exceptions
QgsProviderConnectionException
See also
findConnection()

Definition at line 339 of file qgsprovidermetadata.cpp.

◆ createConnection() [2/2]

QgsAbstractProviderConnection * QgsProviderMetadata::createConnection ( const QString &  uri,
const QVariantMap &  configuration 
)
virtual

Creates a new connection from uri and configuration, the newly created connection is not automatically stored in the settings, call saveConnection() to save it.

Ownership is transferred to the caller.

Exceptions
QgsProviderConnectionException
See also
saveConnection()
Since
QGIS 3.10

Definition at line 346 of file qgsprovidermetadata.cpp.

◆ createDatabase()

bool QgsProviderMetadata::createDatabase ( const QString &  uri,
QString &  errorMessage 
)
virtual

Creates a new empty database at the specified uri.

This method can be used for supported providers to construct a new empty database. For instance, the OGR provider metadata createDatabase() method can be used to create new empty GeoPackage or FileGeodatabase databases.

Parameters
uridestination URI for newly created database.
errorMessagewill be set to a descriptive error message if the database could not be successfully created.
Returns
true if the database was successfully created
Note
This method is only supported by providers which return the QgsProviderMetadata::ProviderMetadataCapability::CreateDatabase capability.
Since
QGIS 3.28

Definition at line 210 of file qgsprovidermetadata.cpp.

◆ createDb()

bool QgsProviderMetadata::createDb ( const QString &  dbPath,
QString &  errCause 
)
virtual

Creates database by the provider on the path.

Since
QGIS 3.10

Definition at line 303 of file qgsprovidermetadata.cpp.

◆ createEmptyLayer()

Qgis::VectorExportResult QgsProviderMetadata::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 
)
virtual

Creates new empty vector layer.

Note
not available in Python bindings
Since
QGIS 3.10

Definition at line 201 of file qgsprovidermetadata.cpp.

◆ createFunction()

QgsProviderMetadata::CreateDataProviderFunction QgsProviderMetadata::createFunction ( ) const

Returns a pointer to the direct provider creation function, if supported by the provider.

Note
not available in Python bindings
Deprecated:
QGIS 3.10

Definition at line 86 of file qgsprovidermetadata.cpp.

◆ createMeshData() [1/2]

bool QgsProviderMetadata::createMeshData ( const QgsMesh mesh,
const QString &  fileName,
const QString &  driverName,
const QgsCoordinateReferenceSystem crs,
const QMap< QString, QString > &  metadata = QMap<QString, QString>() 
) const
virtual

Creates mesh data source from a file name fileName and a driver driverName, that is the mesh frame stored in file, memory or with other way (depending of the provider) Since QGIS 3.38 the optional metadata argument can be used to pass metadata to the provider.

Since
QGIS 3.16

Definition at line 226 of file qgsprovidermetadata.cpp.

◆ createMeshData() [2/2]

bool QgsProviderMetadata::createMeshData ( const QgsMesh mesh,
const QString &  uri,
const QgsCoordinateReferenceSystem crs,
const QMap< QString, QString > &  metadata = QMap<QString, QString>() 
) const
virtual

Creates mesh data source from an uri, that is the mesh frame stored in file, memory or with other way (depending of the provider) Since QGIS 3.38 the optional metadata argument can be used to pass metadata to the provider.

Since
QGIS 3.22

Definition at line 235 of file qgsprovidermetadata.cpp.

◆ createProvider()

QgsDataProvider * QgsProviderMetadata::createProvider ( const QString &  uri,
const QgsDataProvider::ProviderOptions options,
Qgis::DataProviderReadFlags  flags = Qgis::DataProviderReadFlags() 
)
virtual

Class factory to return a pointer to a newly created QgsDataProvider object.

Parameters
urithe datasource uri
optionscreation options
flagscreation flags, sing QGIS 3.16
Since
QGIS 3.10

Definition at line 136 of file qgsprovidermetadata.cpp.

◆ createRasterDataProvider()

QgsRasterDataProvider * QgsProviderMetadata::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() 
)
virtual

Creates a new instance of the raster data provider.

Since
QGIS 3.10

Definition at line 216 of file qgsprovidermetadata.cpp.

◆ createTransaction()

QgsTransaction * QgsProviderMetadata::createTransaction ( const QString &  connString)
virtual

Returns new instance of transaction.

Ownership is transferred to the caller

Since
QGIS 3.10

Definition at line 309 of file qgsprovidermetadata.cpp.

◆ dataItemProviders()

QList< QgsDataItemProvider * > QgsProviderMetadata::dataItemProviders ( ) const
virtual

Returns data item providers.

Caller is responsible for ownership of the item providers

See also
QgsProviderGuiMetadata::dataItemGuiProviders()
Note
Ownership of created data item providers is passed to the caller.
Since
QGIS 3.10

Definition at line 248 of file qgsprovidermetadata.cpp.

◆ dbConnections()

QMap< QString, QgsAbstractDatabaseProviderConnection * > QgsProviderMetadata::dbConnections ( bool  cached = true)

Returns a dictionary of database provider connections, the dictionary key is the connection identifier.

Ownership is not transferred. Raises a QgsProviderConnectionException if any errors are encountered.

Parameters
cachedif false connections will be re-read from the settings
Exceptions
QgsProviderConnectionException
Since
QGIS 3.10

Definition at line 320 of file qgsprovidermetadata.cpp.

◆ decodeUri()

QVariantMap QgsProviderMetadata::decodeUri ( const QString &  uri) const
virtual

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

file path, layer name).

Parameters
uriuri string
Returns
map containing components. Standard components may include:
  • "path": file path
  • "layerName"
  • "url": base URL, for online services
  • "referer": referrer string, for HTTP requests
  • "host": hostname, for database services
  • "bounds": hardcoded layer bounds (as a QgsRectangle)
  • "crs": CRS definition
  • "authcfg": authentication configuration ID
Note
this function may not be supported by all providers, an empty map will be returned in such case
Since
QGIS 3.10

Definition at line 181 of file qgsprovidermetadata.cpp.

◆ deleteConnection()

void QgsProviderMetadata::deleteConnection ( const QString &  name)
virtual

Removes the connection with the given name from the settings.

Raises a QgsProviderConnectionException if any errors are encountered.

Exceptions
QgsProviderConnectionException
Since
QGIS 3.10

Definition at line 353 of file qgsprovidermetadata.cpp.

◆ deleteStyleById()

bool QgsProviderMetadata::deleteStyleById ( const QString &  uri,
const QString &  styleId,
QString &  errCause 
)
virtual

Deletes a layer style defined by styleId.

Since
QGIS 3.10

Definition at line 273 of file qgsprovidermetadata.cpp.

◆ description()

QString QgsProviderMetadata::description ( ) const

This returns descriptive text for the provider.

This is used to provide a descriptive list of available data providers.

Definition at line 51 of file qgsprovidermetadata.cpp.

◆ encodeUri()

QString QgsProviderMetadata::encodeUri ( const QVariantMap &  parts) const
virtual

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

file path, layer name).

Parameters
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 186 of file qgsprovidermetadata.cpp.

◆ filters()

QString QgsProviderMetadata::filters ( Qgis::FileFilterType  type)
virtual

Builds the list of file filter strings (supported formats)

Suitable for use in a QFileDialog::getOpenFileNames() call.

Since
QGIS 3.10

Definition at line 101 of file qgsprovidermetadata.cpp.

◆ findConnection()

QgsAbstractProviderConnection * QgsProviderMetadata::findConnection ( const QString &  name,
bool  cached = true 
)

Searches and returns a (possibly nullptr) connection from the stored provider connections.

Ownership is not transferred. Raises a QgsProviderConnectionException if any errors are encountered.

Parameters
namethe connection name
cachedif false connections will be re-read from the settings
Exceptions
QgsProviderConnectionException
Since
QGIS 3.10

Definition at line 325 of file qgsprovidermetadata.cpp.

◆ getStyleById()

QString QgsProviderMetadata::getStyleById ( const QString &  uri,
const QString &  styleId,
QString &  errCause 
)
virtual

Gets a layer style defined by uri.

See also
styleExists()
Since
QGIS 3.10

Definition at line 267 of file qgsprovidermetadata.cpp.

◆ icon()

QIcon QgsProviderMetadata::icon ( ) const
virtual

Returns an icon representing the provider.

Since
QGIS 3.26

Definition at line 56 of file qgsprovidermetadata.cpp.

◆ initProvider()

void QgsProviderMetadata::initProvider ( )
virtual

Initialize the provider.

Since
QGIS 3.10

Definition at line 91 of file qgsprovidermetadata.cpp.

◆ key()

QString QgsProviderMetadata::key ( ) const

This returns the unique key associated with the provider.

This key string is used for the associative container in QgsProviderRegistry

Definition at line 46 of file qgsprovidermetadata.cpp.

◆ library()

QString QgsProviderMetadata::library ( ) const

This returns the library file name.

This is used to QLibrary calls to load the data provider (only for dynamically loaded libraries)

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

Definition at line 76 of file qgsprovidermetadata.cpp.

◆ listStyles()

int QgsProviderMetadata::listStyles ( const QString &  uri,
QStringList &  ids,
QStringList &  names,
QStringList &  descriptions,
QString &  errCause 
)
virtual

Lists stored layer styles in the provider defined by uri.

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

Definition at line 253 of file qgsprovidermetadata.cpp.

◆ loadStoredStyle()

QString QgsProviderMetadata::loadStoredStyle ( const QString &  uri,
QString &  styleName,
QString &  errCause 
)
virtual

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

Parameters
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 292 of file qgsprovidermetadata.cpp.

◆ loadStyle()

QString QgsProviderMetadata::loadStyle ( const QString &  uri,
QString &  errCause 
)
virtual

Loads a layer style defined by uri.

Since
QGIS 3.10

Definition at line 286 of file qgsprovidermetadata.cpp.

◆ meshDriversMetadata()

QList< QgsMeshDriverMetadata > QgsProviderMetadata::meshDriversMetadata ( )
virtual

Builds the list of available mesh drivers metadata.

Since
QGIS 3.12

Definition at line 106 of file qgsprovidermetadata.cpp.

◆ priorityForUri()

int QgsProviderMetadata::priorityForUri ( const QString &  uri) const
virtual

Returns an integer representing the priority which this provider should have when opening a dataset with the specified uri.

A larger priority means that the provider should be selected over others with a lower priority for the same URI.

The default implementation returns 0 for all URIs.

Warning
Not all providers implement this functionality. Check whether capabilities() returns the ProviderMetadataCapability::PriorityForUri to determine whether a specific provider metadata object supports this method.
Since
QGIS 3.18

Definition at line 111 of file qgsprovidermetadata.cpp.

◆ providerCapabilities()

QgsProviderMetadata::ProviderCapabilities QgsProviderMetadata::providerCapabilities ( ) const
virtual

Returns the provider's capabilities.

Since
QGIS 3.18.1

Definition at line 66 of file qgsprovidermetadata.cpp.

◆ pyramidResamplingMethods()

QList< QPair< QString, QString > > QgsProviderMetadata::pyramidResamplingMethods ( )
virtual

Returns pyramid resampling methods available for provider.

Since
QGIS 3.10

Definition at line 243 of file qgsprovidermetadata.cpp.

◆ querySublayers()

QList< QgsProviderSublayerDetails > QgsProviderMetadata::querySublayers ( const QString &  uri,
Qgis::SublayerQueryFlags  flags = Qgis::SublayerQueryFlags(),
QgsFeedback feedback = nullptr 
) const
virtual

Queries the specified uri and returns a list of any valid sublayers found in the dataset which can be handled by this provider.

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.

Note
Providers which implement this method should always return a list of sublayer details for any valid, even if the uri only relates to a single layer. Returning a non-empty list indicates that the provider is able to load at least one layer using the uri, and is used to collate a combined layer of all providers which support the URI (e.g. in the case that a URI may be readable by multiple different providers).
Since
QGIS 3.22

Definition at line 131 of file qgsprovidermetadata.cpp.

◆ relativeToAbsoluteUri()

QString QgsProviderMetadata::relativeToAbsoluteUri ( const QString &  uri,
const QgsReadWriteContext context 
) const
virtual

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 196 of file qgsprovidermetadata.cpp.

◆ saveConnection()

void QgsProviderMetadata::saveConnection ( const QgsAbstractProviderConnection connection,
const QString &  name 
)
virtual

Stores the connection in the settings.

Parameters
connectionthe connection to be stored in the settings
namethe name under which the connection will be stored
Exceptions
QgsProviderConnectionException
Since
QGIS 3.10

Definition at line 359 of file qgsprovidermetadata.cpp.

◆ saveLayerMetadata()

bool QgsProviderMetadata::saveLayerMetadata ( const QString &  uri,
const QgsLayerMetadata metadata,
QString &  errorMessage 
)
virtual

Saves metadata to the layer corresponding to the specified uri.

Parameters
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 298 of file qgsprovidermetadata.cpp.

◆ saveStyle()

bool QgsProviderMetadata::saveStyle ( const QString &  uri,
const QString &  qmlStyle,
const QString &  sldStyle,
const QString &  styleName,
const QString &  styleDescription,
const QString &  uiFileContent,
bool  useAsDefault,
QString &  errCause 
)
virtual

Saves a layer style to provider.

Note
Prior to QGIS 3.24, this method would show a message box warning when a style with the same styleName already existed to confirm replacing the style with the user. Since 3.24, calling this method will ALWAYS overwrite any existing style with the same name. Use styleExists() to test in advance if a style already exists and handle this appropriately in your client code.
Since
QGIS 3.10

Definition at line 279 of file qgsprovidermetadata.cpp.

◆ setBoolParameter()

void QgsProviderMetadata::setBoolParameter ( QVariantMap &  uri,
const QString &  parameter,
const QVariant &  value 
)
static

Sets the value into the uri parameter as a bool.

eg. "yes" value will be saved as true, 0 will be saved as false

Since
QGIS 3.14

Definition at line 147 of file qgsprovidermetadata.cpp.

◆ sidecarFilesForUri()

QStringList QgsProviderMetadata::sidecarFilesForUri ( const QString &  uri) const
virtual

Given a uri, returns any sidecar files which are associated with the URI and this provider.

In this context a sidecar file is defined as a file which shares the same base filename as a dataset, but which differs in file extension. It defines the list of additional files which must be renamed or deleted alongside the main file associated with the dataset in order to completely rename/delete the dataset.

For instance, the OGR provider would return the corresponding .dbf, .idx, etc files for a uri pointing at a .shp file.

Implementations should files any files which MAY exist for the URI, and it is up to the caller to filter these to only existing files if required.

Note
Some file formats consist of a set of static file names, such as ESRI aigrid datasets which consist of a folder with files with the names "hdr.adf", "prj.adf", etc. These statically named files are NOT considered as sidecar files.
Since
QGIS 3.22

Definition at line 126 of file qgsprovidermetadata.cpp.

◆ styleExists()

bool QgsProviderMetadata::styleExists ( const QString &  uri,
const QString &  styleId,
QString &  errorCause 
)
virtual

Returns true if a layer style with the specified styleId exists in the provider defined by uri.

Parameters
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 261 of file qgsprovidermetadata.cpp.

◆ suggestGroupNameForUri()

QString QgsProviderMetadata::suggestGroupNameForUri ( const QString &  uri) const
virtual

Returns a name that can be used as a group name for sublayers retrieved from the specified uri.

The default implementation returns an empty string.

Since
QGIS 3.30

Definition at line 81 of file qgsprovidermetadata.cpp.

◆ supportedLayerTypes()

QList< Qgis::LayerType > QgsProviderMetadata::supportedLayerTypes ( ) const
virtual

Returns a list of the map layer types supported by the provider.

Since
QGIS 3.26

Definition at line 71 of file qgsprovidermetadata.cpp.

◆ uriIsBlocklisted()

bool QgsProviderMetadata::uriIsBlocklisted ( const QString &  uri) const
virtual

Returns true if the specified uri is known by this 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 by returning true 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.

The default method returns false for all URIs.

Warning
Returning true from an implementation of this method indicates that ALL providers should ignore the specified uri, not just the provider associated with this metadata!
Since
QGIS 3.18

Definition at line 121 of file qgsprovidermetadata.cpp.

◆ validLayerTypesForUri()

QList< Qgis::LayerType > QgsProviderMetadata::validLayerTypesForUri ( const QString &  uri) const
virtual

Returns a list of valid layer types which the provider can be used with when opening the specified uri.

Warning
Not all providers implement this functionality. Check whether capabilities() returns the ProviderMetadataCapability::LayerTypesForUri to determine whether a specific provider metadata object supports this method.
Since
QGIS 3.18

Definition at line 116 of file qgsprovidermetadata.cpp.


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