QGIS API Documentation  3.14.0-Pi (9f7028fd23)
Public Types | Signals | Public Member Functions | Static Public Member Functions | List of all members
QgsProviderMetadata Class Reference

#include <qgsprovidermetadata.h>

Inheritance diagram for QgsProviderMetadata:
Inheritance graph
[legend]

Public Types

typedef std::function< QgsDataProvider *(const QString &, const QgsDataProvider::ProviderOptions &) > CreateDataProviderFunction
 Typedef for data provider creation function. More...
 
enum  FilterType { FilterType::FilterVector = 1, FilterType::FilterRaster, FilterType::FilterMesh, FilterType::FilterMeshDataset }
 Type of file filters. 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 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 QgsAbstractProviderConnectioncreateConnection (const QString &name) SIP_THROW(QgsProviderConnectionException)
 Creates a new connection by loading the connection with the given name from the settings. More...
 
virtual QgsAbstractProviderConnectioncreateConnection (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 QgsVectorLayerExporter::ExportError 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 QgsDataProvidercreateProvider (const QString &uri, const QgsDataProvider::ProviderOptions &options)
 Class factory to return a pointer to a newly created QgsDataProvider object. More...
 
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. More...
 
virtual QgsTransactioncreateTransaction (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)
 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, 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)
 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...
 
QgsAbstractProviderConnectionfindConnection (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, QString styleId, QString &errCause)
 Gets a layer style defined by uri. 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< QgsMeshDriverMetadatameshDriversMetadata ()
 Builds the list of available mesh drivers metadata. More...
 
virtual QList< QPair< QString, QString > > pyramidResamplingMethods ()
 Returns pyramid resampling methods available for provider. More...
 
virtual void saveConnection (const QgsAbstractProviderConnection *connection, const QString &name) SIP_THROW(QgsProviderConnectionException)
 Stores the connection in the settings. 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...
 

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. More...
 
static void setBoolParameter (QVariantMap &uri, const QString &parameter, const QVariant &value)
 Sets the value into the uri parameter as a bool. More...
 

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 126 of file qgsprovidermetadata.h.

Member Typedef Documentation

◆ CreateDataProviderFunction

Typedef for data provider creation function.

Since
QGIS 3.0

Definition at line 136 of file qgsprovidermetadata.h.

Member Enumeration Documentation

◆ FilterType

Type of file filters.

Since
QGIS 3.10
Enumerator
FilterVector 
FilterRaster 
FilterMesh 
FilterMeshDataset 

Definition at line 205 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 24 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.

Since
QGIS 3.0
Deprecated:
QGIS 3.10

Definition at line 32 of file qgsprovidermetadata.cpp.

◆ ~QgsProviderMetadata()

QgsProviderMetadata::~QgsProviderMetadata ( )
virtual

dtor

Definition at line 38 of file qgsprovidermetadata.cpp.

Member Function Documentation

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

◆ cleanupProvider()

void QgsProviderMetadata::cleanupProvider ( )
virtual

Cleanup the provider.

Since
QGIS 3.10

Definition at line 68 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]

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

◆ connections() [2/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 209 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 234 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 241 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 198 of file qgsprovidermetadata.cpp.

◆ createEmptyLayer()

QgsVectorLayerExporter::ExportError QgsProviderMetadata::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 
)
virtual

Creates new empty vector layer.

Note
not available in Python bindings
Since
QGIS 3.10

Definition at line 136 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
Since
QGIS 3.0
Deprecated:
QGIS 3.10

Definition at line 58 of file qgsprovidermetadata.cpp.

◆ createProvider()

QgsDataProvider * QgsProviderMetadata::createProvider ( const QString &  uri,
const QgsDataProvider::ProviderOptions options 
)
virtual

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

Since
QGIS 3.10

Definition at line 83 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 146 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 204 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 161 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 215 of file qgsprovidermetadata.cpp.

◆ decodeUri()

QVariantMap QgsProviderMetadata::decodeUri ( const QString &  uri)
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 126 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 248 of file qgsprovidermetadata.cpp.

◆ deleteStyleById()

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

Deletes a layer style defined by styleId.

Since
QGIS 3.10

Definition at line 179 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 48 of file qgsprovidermetadata.cpp.

◆ encodeUri()

QString QgsProviderMetadata::encodeUri ( const QVariantMap &  parts)
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 131 of file qgsprovidermetadata.cpp.

◆ filters()

QString QgsProviderMetadata::filters ( FilterType  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 73 of file qgsprovidermetadata.cpp.

◆ findConnection()

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.

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

Definition at line 220 of file qgsprovidermetadata.cpp.

◆ getStyleById()

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

Gets a layer style defined by uri.

Since
QGIS 3.10

Definition at line 173 of file qgsprovidermetadata.cpp.

◆ initProvider()

void QgsProviderMetadata::initProvider ( )
virtual

Initialize the provider.

Since
QGIS 3.10

Definition at line 63 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 43 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 53 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 166 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 192 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 78 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 156 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 254 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.

Since
QGIS 3.10

Definition at line 185 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 92 of file qgsprovidermetadata.cpp.


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