QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Holds data provider key, description, and associated shared library file or function pointer information. More...
#include <qgsprovidermetadata.h>
Public Types | |
typedef std::function< QgsDataProvider *(const QString &, const QgsDataProvider::ProviderOptions &, QgsDataProvider::ReadFlags &) > | CreateDataProviderFunction |
Typedef for data provider creation function. More... | |
enum | FilterType { FilterType::FilterVector = 1, FilterType::FilterRaster, FilterType::FilterMesh, FilterType::FilterMeshDataset, FilterType::FilterPointCloud } |
Type of file filters. More... | |
enum | ProviderCapability { FileBasedUris = 1 << 0, SaveLayerMetadata = 1 << 1 } |
Provider capabilities. More... | |
enum | ProviderMetadataCapability { PriorityForUri = 1 << 0, LayerTypesForUri = 1 << 1, QuerySublayers = 1 << 2 } |
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. More... | |
void | connectionCreated (const QString &name) |
Emitted when a connection with the specified name is created. More... | |
void | connectionDeleted (const QString &name) |
Emitted when the connection with the specified name was deleted. More... | |
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. More... | |
QgsProviderMetadata (const QString &key, const QString &description, const QString &library=QString()) | |
Constructor for provider metadata. More... | |
virtual | ~QgsProviderMetadata () |
dtor More... | |
virtual QgsProviderMetadata::ProviderMetadataCapabilities | capabilities () const |
Returns the provider metadata capabilities. More... | |
virtual void | cleanupProvider () |
Cleanup the provider. More... | |
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. More... | |
virtual QMap< QString, QgsAbstractProviderConnection * > | connections (bool cached=true) SIP_THROW(QgsProviderConnectionException) |
Returns a dictionary of stored provider connections, the dictionary key is the connection identifier. More... | |
virtual QgsAbstractProviderConnection * | createConnection (const QString &name) SIP_THROW(QgsProviderConnectionException) |
Creates a new connection by loading the connection with the given name from the settings. More... | |
virtual QgsAbstractProviderConnection * | createConnection (const QString &uri, const QVariantMap &configuration) SIP_THROW(QgsProviderConnectionException) |
Creates a new connection from uri and configuration, the newly created connection is not automatically stored in the settings, call saveConnection() to save it. More... | |
virtual bool | createDb (const QString &dbPath, QString &errCause) |
Creates database by the provider on the path. More... | |
virtual Qgis::VectorExportResult | createEmptyLayer (const QString &uri, const QgsFields &fields, QgsWkbTypes::Type wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, QMap< int, int > &oldToNewAttrIdxMap, QString &errorMessage, const QMap< QString, QVariant > *options) |
Creates new empty vector layer. More... | |
Q_DECL_DEPRECATED CreateDataProviderFunction | createFunction () const |
Returns a pointer to the direct provider creation function, if supported by the provider. More... | |
virtual bool | createMeshData (const QgsMesh &mesh, const QString &fileName, const QString &driverName, const QgsCoordinateReferenceSystem &crs) 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) More... | |
virtual bool | createMeshData (const QgsMesh &mesh, const QString &uri, const QgsCoordinateReferenceSystem &crs) 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) More... | |
virtual QgsDataProvider * | createProvider (const QString &uri, const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags=QgsDataProvider::ReadFlags()) |
Class factory to return a pointer to a newly created QgsDataProvider object. More... | |
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. More... | |
virtual QgsTransaction * | createTransaction (const QString &connString) |
Returns new instance of transaction. More... | |
virtual QList< QgsDataItemProvider * > | dataItemProviders () const |
Returns data item providers. More... | |
QMap< QString, QgsAbstractDatabaseProviderConnection * > | dbConnections (bool cached=true) SIP_THROW(QgsProviderConnectionException) |
Returns a dictionary of database provider connections, the dictionary key is the connection identifier. More... | |
virtual QVariantMap | decodeUri (const QString &uri) const |
Breaks a provider data source URI into its component paths (e.g. More... | |
virtual void | deleteConnection (const QString &name) SIP_THROW(QgsProviderConnectionException) |
Removes the connection with the given name from the settings. More... | |
virtual bool | deleteStyleById (const QString &uri, const QString &styleId, QString &errCause) |
Deletes a layer style defined by styleId. More... | |
QString | description () const |
This returns descriptive text for the provider. More... | |
virtual QString | encodeUri (const QVariantMap &parts) const |
Reassembles a provider data source URI from its component paths (e.g. More... | |
virtual QString | filters (FilterType type) |
Builds the list of file filter strings (supported formats) More... | |
QgsAbstractProviderConnection * | findConnection (const QString &name, bool cached=true) SIP_THROW(QgsProviderConnectionException) |
Searches and returns a (possibly NULL) connection from the stored provider connections. More... | |
virtual QString | getStyleById (const QString &uri, const QString &styleId, QString &errCause) |
Gets a layer style defined by uri. More... | |
virtual QIcon | icon () const |
Returns an icon representing the provider. More... | |
virtual void | initProvider () |
Initialize the provider. More... | |
QString | key () const |
This returns the unique key associated with the provider. More... | |
Q_DECL_DEPRECATED QString | library () const |
This returns the library file name. More... | |
virtual int | listStyles (const QString &uri, QStringList &ids, QStringList &names, QStringList &descriptions, QString &errCause) |
Lists stored layer styles in the provider defined by uri. More... | |
virtual QString | loadStyle (const QString &uri, QString &errCause) |
Loads a layer style defined by uri. More... | |
virtual QList< QgsMeshDriverMetadata > | meshDriversMetadata () |
Builds the list of available mesh drivers metadata. More... | |
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. More... | |
virtual QgsProviderMetadata::ProviderCapabilities | providerCapabilities () const |
Returns the provider's capabilities. More... | |
virtual QList< QPair< QString, QString > > | pyramidResamplingMethods () |
Returns pyramid resampling methods available for provider. More... | |
virtual 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 handled by this provider. More... | |
virtual void | saveConnection (const QgsAbstractProviderConnection *connection, const QString &name) SIP_THROW(QgsProviderConnectionException) |
Stores the connection in the settings. More... | |
virtual bool | saveLayerMetadata (const QString &uri, const QgsLayerMetadata &metadata, QString &errorMessage) SIP_THROW(QgsNotSupportedException) |
Saves metadata to the layer corresponding to the specified uri. More... | |
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. More... | |
virtual QStringList | sidecarFilesForUri (const QString &uri) const |
Given a uri, returns any sidecar files which are associated with the URI and this provider. More... | |
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. More... | |
virtual QList< QgsMapLayerType > | supportedLayerTypes () const |
Returns a list of the map layer types supported by the provider. More... | |
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. More... | |
virtual QList< QgsMapLayerType > | validLayerTypesForUri (const QString &uri) const |
Returns a list of valid layer types which the provider can be used with when opening the specified uri. More... | |
Static Public Member Functions | |
static bool | boolParameter (const QVariantMap &uri, const QString ¶meter, bool defaultValue=false) |
Returns the parameter value in the uri as a bool. More... | |
static void | setBoolParameter (QVariantMap &uri, const QString ¶meter, const QVariant &value) |
Sets the value into the uri parameter as a bool. More... | |
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 177 of file qgsprovidermetadata.h.
typedef std::function< QgsDataProvider*( const QString &, const QgsDataProvider::ProviderOptions &, QgsDataProvider::ReadFlags & ) > QgsProviderMetadata::CreateDataProviderFunction |
Typedef for data provider creation function.
Definition at line 212 of file qgsprovidermetadata.h.
|
strong |
Type of file filters.
Enumerator | |
---|---|
FilterVector | Vector layers. |
FilterRaster | Raster layers. |
FilterMesh | Mesh layers. |
FilterMeshDataset | Mesh datasets. |
FilterPointCloud | Point clouds (since QGIS 3.18) |
Definition at line 347 of file qgsprovidermetadata.h.
Provider capabilities.
Definition at line 201 of file qgsprovidermetadata.h.
Indicates capabilities of the provider metadata implementation.
Definition at line 188 of file qgsprovidermetadata.h.
QgsProviderMetadata::QgsProviderMetadata | ( | const QString & | key, |
const QString & | description, | ||
const QString & | library = QString() |
||
) |
Constructor for provider metadata.
key | provider key |
description | provider description |
library | plugin library file name (empty if the provider is not loaded from a library) |
Definition at line 26 of file qgsprovidermetadata.cpp.
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.
Definition at line 34 of file qgsprovidermetadata.cpp.
|
virtual |
dtor
Definition at line 40 of file qgsprovidermetadata.cpp.
|
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
Definition at line 157 of file qgsprovidermetadata.cpp.
|
virtual |
Returns the provider metadata capabilities.
Definition at line 60 of file qgsprovidermetadata.cpp.
|
virtual |
|
signal |
Emitted when the connection with the specified name is changed, e.g.
the settings relating to the connection have been updated.
|
signal |
Emitted when a connection with the specified name is created.
|
signal |
Emitted when the connection with the specified name was deleted.
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.
cached | if false connections will be re-read from the settings |
Definition at line 351 of file qgsprovidermetadata.cpp.
|
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.
cached | if false connections will be re-read from the settings |
QgsProviderConnectionException |
Definition at line 284 of file qgsprovidermetadata.cpp.
|
virtual |
Creates a new connection by loading the connection with the given name from the settings.
Ownership is transferred to the caller.
QgsProviderConnectionException |
Definition at line 309 of file qgsprovidermetadata.cpp.
|
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.
QgsProviderConnectionException |
Definition at line 316 of file qgsprovidermetadata.cpp.
|
virtual |
Creates database by the provider on the path.
Definition at line 273 of file qgsprovidermetadata.cpp.
|
virtual |
Creates new empty vector layer.
Definition at line 185 of file qgsprovidermetadata.cpp.
QgsProviderMetadata::CreateDataProviderFunction QgsProviderMetadata::createFunction | ( | ) | const |
Returns a pointer to the direct provider creation function, if supported by the provider.
Definition at line 80 of file qgsprovidermetadata.cpp.
|
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)
Definition at line 205 of file qgsprovidermetadata.cpp.
|
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)
Definition at line 213 of file qgsprovidermetadata.cpp.
|
virtual |
Class factory to return a pointer to a newly created QgsDataProvider object.
uri | the datasource uri |
options | creation options |
flags | creation flags, sing QGIS 3.16 |
Definition at line 130 of file qgsprovidermetadata.cpp.
|
virtual |
Creates a new instance of the raster data provider.
Definition at line 195 of file qgsprovidermetadata.cpp.
|
virtual |
Returns new instance of transaction.
Ownership is transferred to the caller
Definition at line 279 of file qgsprovidermetadata.cpp.
|
virtual |
Returns data item providers.
Caller is responsible for ownership of the item providers
Definition at line 225 of file qgsprovidermetadata.cpp.
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.
cached | if false connections will be re-read from the settings |
QgsProviderConnectionException |
Definition at line 290 of file qgsprovidermetadata.cpp.
|
virtual |
Breaks a provider data source URI into its component paths (e.g.
file path, layer name).
uri | uri string |
Definition at line 175 of file qgsprovidermetadata.cpp.
|
virtual |
Removes the connection with the given name from the settings.
Raises a QgsProviderConnectionException if any errors are encountered.
QgsProviderConnectionException |
Definition at line 323 of file qgsprovidermetadata.cpp.
|
virtual |
Deletes a layer style defined by styleId.
Definition at line 249 of file qgsprovidermetadata.cpp.
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 50 of file qgsprovidermetadata.cpp.
|
virtual |
Reassembles a provider data source URI from its component paths (e.g.
file path, layer name).
parts | parts as returned by decodeUri |
Definition at line 180 of file qgsprovidermetadata.cpp.
|
virtual |
Builds the list of file filter strings (supported formats)
Suitable for use in a QFileDialog::getOpenFileNames() call.
Definition at line 95 of file qgsprovidermetadata.cpp.
QgsAbstractProviderConnection * QgsProviderMetadata::findConnection | ( | const QString & | name, |
bool | cached = true |
||
) |
Searches and returns a (possibly NULL) connection from the stored provider connections.
Ownership is not transferred. Raises a QgsProviderConnectionException if any errors are encountered.
name | the connection name |
cached | if false connections will be re-read from the settings |
QgsProviderConnectionException |
Definition at line 295 of file qgsprovidermetadata.cpp.
|
virtual |
Gets a layer style defined by uri.
Definition at line 243 of file qgsprovidermetadata.cpp.
|
virtual |
Returns an icon representing the provider.
Definition at line 55 of file qgsprovidermetadata.cpp.
|
virtual |
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 45 of file qgsprovidermetadata.cpp.
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)
Definition at line 75 of file qgsprovidermetadata.cpp.
|
virtual |
Lists stored layer styles in the provider defined by uri.
Definition at line 230 of file qgsprovidermetadata.cpp.
|
virtual |
Loads a layer style defined by uri.
Definition at line 262 of file qgsprovidermetadata.cpp.
|
virtual |
Builds the list of available mesh drivers metadata.
Definition at line 100 of file qgsprovidermetadata.cpp.
|
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.
Definition at line 105 of file qgsprovidermetadata.cpp.
|
virtual |
Returns the provider's capabilities.
Definition at line 65 of file qgsprovidermetadata.cpp.
|
virtual |
Returns pyramid resampling methods available for provider.
Definition at line 220 of file qgsprovidermetadata.cpp.
|
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.
Definition at line 125 of file qgsprovidermetadata.cpp.
|
virtual |
Stores the connection in the settings.
connection | the connection to be stored in the settings |
name | the name under which the connection will be stored |
QgsProviderConnectionException |
Definition at line 329 of file qgsprovidermetadata.cpp.
|
virtual |
Saves metadata to the layer corresponding to the specified uri.
uri | uri of layer to store metadata for |
metadata | layer metadata |
errorMessage | descriptive string of error if encountered |
true
if the metadata was successfully saved.QgsNotSupportedException | if the provider does not support saving layer metadata for the specified uri. |
Definition at line 268 of file qgsprovidermetadata.cpp.
|
virtual |
Saves a layer style to provider.
Definition at line 255 of file qgsprovidermetadata.cpp.
|
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
Definition at line 141 of file qgsprovidermetadata.cpp.
|
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.
Definition at line 120 of file qgsprovidermetadata.cpp.
|
virtual |
Returns true
if a layer style with the specified styleId exists in the provider defined by uri.
uri | provider URI |
styleId | style ID to test for |
errorCause | will be set to a descriptive error message, if an error occurs while checking if the style exists |
true
if the layer style already existsDefinition at line 237 of file qgsprovidermetadata.cpp.
|
virtual |
Returns a list of the map layer types supported by the provider.
Definition at line 70 of file qgsprovidermetadata.cpp.
|
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.
true
from an implementation of this method indicates that ALL providers should ignore the specified uri, not just the provider associated with this metadata!Definition at line 115 of file qgsprovidermetadata.cpp.
|
virtual |
Returns a list of valid layer types which the provider can be used with when opening the specified uri.
Definition at line 110 of file qgsprovidermetadata.cpp.