QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
|
Abstract base class for spatial data provider implementations. More...
#include <qgsdataprovider.h>
Classes | |
struct | PreviewContext |
Stores settings related to the context in which a preview job runs. More... | |
struct | ProviderOptions |
Setting options for creating vector data providers. More... | |
Public Types | |
enum | DataCapability { NoDataCapabilities = 0 , File = 1 , Dir = 1 << 1 , Database = 1 << 2 , Net = 1 << 3 } |
Used in browser model to understand which items for which providers should be populated. More... | |
enum | ProviderProperty { EvaluateDefaultValues , CustomData = 3000 } |
Properties are used to pass custom configuration options into data providers. More... | |
enum | ReadFlag { FlagTrustDataSource = 1 << 0 , SkipFeatureCount = 1 << 1 , FlagLoadDefaultStyle = 1 << 2 , SkipGetExtent = 1 << 3 , SkipFullScan = 1 << 4 , ForceReadOnly = 1 << 5 , SkipCredentialsRequest = 1 << 6 , ParallelThreadLoading = 1 << 7 } |
Flags which control dataprovider construction. More... | |
Signals | |
void | dataChanged () |
Emitted whenever a change is made to the data provider which may have caused changes in the provider's data OUTSIDE of QGIS. | |
void | fullExtentCalculated () |
Emitted whenever a deferred extent calculation is completed by the provider. | |
void | notify (const QString &msg) |
Emitted when the datasource issues a notification. | |
Public Member Functions | |
QgsDataProvider (const QString &uri=QString(), const QgsDataProvider::ProviderOptions &providerOptions=QgsDataProvider::ProviderOptions(), QgsDataProvider::ReadFlags flags=QgsDataProvider::ReadFlags()) | |
Create a new dataprovider with the specified in the uri. | |
virtual QgsCoordinateReferenceSystem | crs () const =0 |
Returns the coordinate system for the data source. | |
virtual QString | dataComment () const |
Returns a short comment for the data that this provider is providing access to (e.g. | |
virtual QString | dataSourceUri (bool expandAuthConfig=false) const |
Gets the data source specification. | |
virtual QDateTime | dataTimestamp () const |
Current time stamp of data source. | |
virtual QString | description () const =0 |
Returns description. | |
virtual QgsDataProviderElevationProperties * | elevationProperties () |
Returns the provider's elevation properties. | |
virtual const QgsDataProviderElevationProperties * | elevationProperties () const |
Returns the provider's elevation properties. | |
virtual bool | enterUpdateMode () |
Enter update mode. | |
virtual QgsError | error () const |
Gets current status error. | |
virtual QgsRectangle | extent () const =0 |
Returns the extent of the layer. | |
virtual QString | fileRasterFilters () const |
Returns raster file filter string. | |
virtual QString | fileVectorFilters () const |
Returns vector file filter string. | |
virtual Qgis::DataProviderFlags | flags () const |
Returns the generic data provider flags. | |
virtual void | invalidateConnections (const QString &connection) |
Invalidate connections corresponding to specified name. | |
virtual bool | isValid () const =0 |
Returns true if this is a valid layer. | |
virtual QgsLayerMetadata | layerMetadata () const |
Returns layer metadata collected from the provider's source. | |
virtual bool | leaveUpdateMode () |
Leave update mode. | |
virtual QString | name () const =0 |
Returns a provider name. | |
QVariant | providerProperty (int property, const QVariant &defaultValue) const |
Gets the current value of a certain provider property. | |
QVariant | providerProperty (ProviderProperty property, const QVariant &defaultValue=QVariant()) const |
Gets the current value of a certain provider property. | |
virtual void | reloadData () |
Reloads the data from the source for providers with data caches to synchronize, changes in the data source, feature counts and other specific actions. | |
virtual bool | renderInPreview (const QgsDataProvider::PreviewContext &context) |
Returns whether the layer must be rendered in preview jobs. | |
virtual void | setDataSourceUri (const QString &uri) |
Set the data source specification. | |
virtual void | setLayerOrder (const QStringList &layers) |
Reorder the list of layer names to be rendered by this provider (in order from bottom to top) | |
virtual void | setListening (bool isListening) |
Set whether the provider will listen to datasource notifications If set, the provider will issue notify signals. | |
void | setProviderProperty (int property, const QVariant &value) |
Allows setting arbitrary properties on the provider. | |
void | setProviderProperty (ProviderProperty property, const QVariant &value) |
Allows setting arbitrary properties on the provider. | |
virtual void | setSubLayerVisibility (const QString &name, bool vis) |
Set the visibility of the given sublayer name. | |
virtual bool | setSubsetString (const QString &subset, bool updateFeatureCount=true) |
Set the subset string used to create a subset of features in the layer. | |
virtual void | setTransformContext (const QgsCoordinateTransformContext &transformContext) |
Sets data coordinate transform context to transformContext. | |
void | setUri (const QgsDataSourceUri &uri) |
Set the data source specification. | |
virtual Qgis::ProviderStyleStorageCapabilities | styleStorageCapabilities () const |
Returns the style storage capabilities. | |
virtual uint | subLayerCount () const |
Returns the number of layers for the current data source. | |
virtual QStringList | subLayers () const |
Sub-layers handled by this provider, in order from bottom to top. | |
virtual QStringList | subLayerStyles () const |
Sub-layer styles for each sub-layer handled by this provider, in order from bottom to top. | |
virtual QString | subsetString () const |
Returns the subset definition string (typically sql) currently in use by the layer and used by the provider to limit the feature set. | |
virtual bool | supportsSubsetString () const |
Returns true if the provider supports setting of subset strings. | |
virtual QgsDataProviderTemporalCapabilities * | temporalCapabilities () |
Returns the provider's temporal capabilities. | |
virtual const QgsDataProviderTemporalCapabilities * | temporalCapabilities () const |
Returns the provider's temporal capabilities. | |
virtual QDateTime | timestamp () const |
Time stamp of data source in the moment when data/metadata were loaded by provider. | |
QgsCoordinateTransformContext | transformContext () const |
Returns data provider coordinate transform context. | |
virtual void | updateExtents () |
Update the extents of the layer. | |
QgsDataSourceUri | uri () const |
Gets the data source specification. | |
virtual bool | writeLayerMetadata (const QgsLayerMetadata &metadata) |
Writes layer metadata to the underlying provider source. | |
Static Public Member Functions | |
static QString | sublayerSeparator () |
String sequence used for separating components of sublayers strings. | |
Protected Member Functions | |
void | appendError (const QgsErrorMessage &message) |
Add error message. | |
void | setError (const QgsError &error) |
Sets error message. | |
Protected Attributes | |
QgsError | mError |
Error. | |
QgsDataProvider::ReadFlags | mReadFlags = QgsDataProvider::ReadFlags() |
Read flags. It's up to the subclass to respect these when needed. | |
QDateTime | mTimestamp |
Timestamp of data in the moment when the data were loaded by provider. | |
Friends | |
class | TestQgsProject |
Abstract base class for spatial data provider implementations.
Definition at line 41 of file qgsdataprovider.h.
Used in browser model to understand which items for which providers should be populated.
Enumerator | |
---|---|
NoDataCapabilities | |
File | |
Dir | |
Database | |
Net |
Definition at line 77 of file qgsdataprovider.h.
Properties are used to pass custom configuration options into data providers.
This enum defines a list of custom properties which can be used on different providers. It depends on the provider, which properties are supported. In addition to these default properties, providers can add their custom properties starting from CustomData.
Definition at line 94 of file qgsdataprovider.h.
Flags which control dataprovider construction.
Enumerator | |
---|---|
FlagTrustDataSource | Trust datasource config (primary key unicity, geometry type and srid, etc). Improves provider load time by skipping expensive checks like primary key unicity, geometry type and srid and by using estimated metadata on data load. Since QGIS 3.16. |
SkipFeatureCount | Make featureCount() return -1 to indicate unknown, and subLayers() to return a unknown feature count as well. Since QGIS 3.18. Only implemented by OGR provider at time of writing. |
FlagLoadDefaultStyle | Reset the layer's style to the default for the datasource. |
SkipGetExtent | Skip the extent from provider. |
SkipFullScan | Skip expensive full scan on files (i.e. on delimited text) (since QGIS 3.24) |
ForceReadOnly | Open layer in a read-only mode (since QGIS 3.28) |
SkipCredentialsRequest | |
ParallelThreadLoading | Skip credentials if the provided one are not valid, let the provider be invalid, avoiding to block the thread creating the provider if it is not the main thread (since QGIS 3.32). |
Definition at line 122 of file qgsdataprovider.h.
QgsDataProvider::QgsDataProvider | ( | const QString & | uri = QString() , |
const QgsDataProvider::ProviderOptions & | providerOptions = QgsDataProvider::ProviderOptions() , |
||
QgsDataProvider::ReadFlags | flags = QgsDataProvider::ReadFlags() |
||
) |
Create a new dataprovider with the specified in the uri.
Additional creation options are specified within the options value and since QGIS 3.16 creation flags are specified within the flags value.
Definition at line 23 of file qgsdataprovider.cpp.
|
inlineprotected |
Add error message.
Definition at line 688 of file qgsdataprovider.h.
|
pure virtual |
Returns the coordinate system for the data source.
If the provider isn't capable of returning its projection then an invalid QgsCoordinateReferenceSystem will be returned.
|
signal |
Emitted whenever a change is made to the data provider which may have caused changes in the provider's data OUTSIDE of QGIS.
When emitted from a QgsVectorDataProvider, any cached information such as feature ids should be invalidated.
|
inlinevirtual |
Returns a short comment for the data that this provider is providing access to (e.g.
the comment for postgres table).
Reimplemented in QgsVectorDataProvider.
Definition at line 190 of file qgsdataprovider.h.
|
inlinevirtual |
Gets the data source specification.
This may be a path or database connection string
expandAuthConfig | Whether to expand any assigned authentication configuration |
false
. This keeps credentials out of layer data source URIs and project files. Expansion should be specifically done only when needed within a provider Definition at line 170 of file qgsdataprovider.h.
|
inlinevirtual |
Current time stamp of data source.
Reimplemented in QgsRasterDataProvider.
Definition at line 454 of file qgsdataprovider.h.
|
pure virtual |
Returns description.
Returns a terse string describing what the provider is.
Instead of being pure virtual, might be better to generalize this behavior and presume that none of the sub-classes are going to do anything strange with regards to their name or description?
|
virtual |
Returns the provider's elevation properties.
This may be nullptr
, depending on the data provider.
Reimplemented in QgsRasterDataProvider.
Definition at line 52 of file qgsdataprovider.cpp.
|
virtual |
Returns the provider's elevation properties.
This may be nullptr
, depending on the data provider.
Reimplemented in QgsRasterDataProvider.
Definition at line 59 of file qgsdataprovider.cpp.
|
inlinevirtual |
Enter update mode.
This is aimed at providers that can open differently the connection to the datasource, according it to be in update mode or in read-only mode. A call to this method shall be balanced with a call to leaveUpdateMode(), if this method returns true
.
Most providers will have an empty implementation for that method.
For backward compatibility, providers that implement enterUpdateMode() should still make sure to allow editing operations to work even if enterUpdateMode() is not explicitly called.
Several successive calls to enterUpdateMode() can be done. So there is a concept of stack of calls that must be handled by the provider. Only the first call to enterUpdateMode() will really turn update mode on.
true
in case of success (or no-op implementation), false
in case of failure.Definition at line 491 of file qgsdataprovider.h.
|
inlinevirtual |
Gets current status error.
This error describes some principal problem for which provider cannot work and thus is not valid. It is not last error after accessing data by block(), identify() etc.
Definition at line 461 of file qgsdataprovider.h.
|
pure virtual |
Returns the extent of the layer.
Implemented in QgsVectorTileDataProvider, and QgsRasterDataProvider.
|
inlinevirtual |
Returns raster file filter string.
Returns a string suitable for a QFileDialog of raster file formats supported by the data provider. Naturally this will be an empty string for those data providers that do not deal with plain files, such as databases and servers.
Definition at line 434 of file qgsdataprovider.h.
|
inlinevirtual |
Returns vector file filter string.
Returns a string suitable for a QFileDialog of vector file formats supported by the data provider. Naturally this will be an empty string for those data providers that do not deal with plain files, such as databases and servers.
Definition at line 418 of file qgsdataprovider.h.
|
virtual |
Returns the generic data provider flags.
Definition at line 31 of file qgsdataprovider.cpp.
|
signal |
Emitted whenever a deferred extent calculation is completed by the provider.
Layers should connect to this signal and update their cached extents whenever it is emitted.
|
inlinevirtual |
Invalidate connections corresponding to specified name.
Definition at line 467 of file qgsdataprovider.h.
|
pure virtual |
Returns true
if this is a valid layer.
It is up to individual providers to determine what constitutes a valid layer.
|
inlinevirtual |
Returns layer metadata collected from the provider's source.
Individual data providers must implement this method if they support collecting metadata.
Definition at line 595 of file qgsdataprovider.h.
|
inlinevirtual |
Leave update mode.
This is aimed at providers that can open differently the connection to the datasource, according it to be in update mode or in read-only mode. This method shall be balanced with a successful call to enterUpdateMode().
Most providers will have an empty implementation for that method.
Several successive calls to enterUpdateMode() can be done. So there is a concept of stack of calls that must be handled by the provider. Only the last call to leaveUpdateMode() will really turn update mode off.
true
in case of success (or no-op implementation), false
in case of failure.Definition at line 510 of file qgsdataprovider.h.
|
pure virtual |
Returns a provider name.
Essentially just returns the provider key. Should be used to build file dialogs so that providers can be shown with their supported types. Thus if more than one provider supports a given format, the user is able to select a specific provider to open that file.
Instead of being pure virtual, might be better to generalize this behavior and presume that none of the sub-classes are going to do anything strange with regards to their name or description?
|
signal |
QVariant QgsDataProvider::providerProperty | ( | int | property, |
const QVariant & | defaultValue = QVariant() |
||
) | const |
Gets the current value of a certain provider property.
It depends on the provider which properties are supported.
Definition at line 96 of file qgsdataprovider.cpp.
QVariant QgsDataProvider::providerProperty | ( | QgsDataProvider::ProviderProperty | property, |
const QVariant & | defaultValue = QVariant() |
||
) | const |
Gets the current value of a certain provider property.
It depends on the provider which properties are supported.
Definition at line 89 of file qgsdataprovider.cpp.
|
virtual |
Reloads the data from the source for providers with data caches to synchronize, changes in the data source, feature counts and other specific actions.
Emits the dataChanged
signal
Definition at line 66 of file qgsdataprovider.cpp.
|
virtual |
Returns whether the layer must be rendered in preview jobs.
The context argument gives useful information which can be used to determine whether the layer should be rendered or not.
The base implementation returns true
if lastRenderingTimeMs <= maxRenderingTimeMs.
Reimplemented in QgsVectorTileDataProvider.
Definition at line 110 of file qgsdataprovider.cpp.
|
inlinevirtual |
Set the data source specification.
This may be a path or database connection string
uri | source specification |
Definition at line 156 of file qgsdataprovider.h.
|
inlineprotected |
Sets error message.
Definition at line 691 of file qgsdataprovider.h.
|
inlinevirtual |
Reorder the list of layer names to be rendered by this provider (in order from bottom to top)
Definition at line 350 of file qgsdataprovider.h.
|
virtual |
Set whether the provider will listen to datasource notifications If set, the provider will issue notify signals.
The default implementation does nothing.
Definition at line 103 of file qgsdataprovider.cpp.
void QgsDataProvider::setProviderProperty | ( | int | property, |
const QVariant & | value | ||
) |
Allows setting arbitrary properties on the provider.
It depends on the provider which properties are supported.
Definition at line 82 of file qgsdataprovider.cpp.
void QgsDataProvider::setProviderProperty | ( | QgsDataProvider::ProviderProperty | property, |
const QVariant & | value | ||
) |
Allows setting arbitrary properties on the provider.
It depends on the provider which properties are supported.
Definition at line 75 of file qgsdataprovider.cpp.
|
inlinevirtual |
Set the visibility of the given sublayer name.
Definition at line 364 of file qgsdataprovider.h.
|
inlinevirtual |
Set the subset string used to create a subset of features in the layer.
This may be a sql where clause or any other string that can be used by the data provider to create a subset. Must be implemented in the dataprovider.
Reimplemented in QgsPointCloudDataProvider.
Definition at line 284 of file qgsdataprovider.h.
|
virtual |
Sets data coordinate transform context to transformContext.
The default implementation is a simple setter, subclasses may override to perform additional actions required by a change of coordinate transform context.
Definition at line 125 of file qgsdataprovider.cpp.
|
inline |
|
virtual |
Returns the style storage capabilities.
Definition at line 138 of file qgsdataprovider.cpp.
|
inlinevirtual |
Returns the number of layers for the current data source.
Definition at line 339 of file qgsdataprovider.h.
|
inlinevirtual |
Sub-layers handled by this provider, in order from bottom to top.
Sub-layers are used when the provider's source can combine layers it knows about in some way before it hands them off to the provider.
Reimplemented in QgsRasterDataProvider.
Definition at line 318 of file qgsdataprovider.h.
|
static |
String sequence used for separating components of sublayers strings.
Definition at line 133 of file qgsdataprovider.cpp.
|
inlinevirtual |
Sub-layer styles for each sub-layer handled by this provider, in order from bottom to top.
Sub-layer styles are used to abstract the way the provider's source can symbolise layers in some way at the server, before it serves them to the provider.
Definition at line 330 of file qgsdataprovider.h.
|
inlinevirtual |
Returns the subset definition string (typically sql) currently in use by the layer and used by the provider to limit the feature set.
Must be overridden in the dataprovider, otherwise returns a null QString.
Reimplemented in QgsPointCloudDataProvider.
Definition at line 304 of file qgsdataprovider.h.
|
inlinevirtual |
Returns true
if the provider supports setting of subset strings.
Reimplemented in QgsPointCloudDataProvider.
Definition at line 296 of file qgsdataprovider.h.
|
virtual |
Returns the provider's temporal capabilities.
This may be nullptr
, depending on the data provider.
Reimplemented in QgsMeshDataProvider, QgsRasterDataProvider, and QgsVectorDataProvider.
Definition at line 38 of file qgsdataprovider.cpp.
|
virtual |
Returns the provider's temporal capabilities.
This may be nullptr
, depending on the data provider.
Reimplemented in QgsMeshDataProvider, QgsRasterDataProvider, and QgsVectorDataProvider.
Definition at line 45 of file qgsdataprovider.cpp.
|
inlinevirtual |
Time stamp of data source in the moment when data/metadata were loaded by provider.
Reimplemented in QgsRasterDataProvider.
Definition at line 451 of file qgsdataprovider.h.
QgsCoordinateTransformContext QgsDataProvider::transformContext | ( | ) | const |
Returns data provider coordinate transform context.
Definition at line 117 of file qgsdataprovider.cpp.
|
inlinevirtual |
Update the extents of the layer.
Not implemented by default.
Definition at line 272 of file qgsdataprovider.h.
|
inline |
|
inlinevirtual |
Writes layer metadata to the underlying provider source.
Support depends on individual provider capabilities.
Returns true
if metadata was successfully written to the data provider.
Definition at line 605 of file qgsdataprovider.h.
|
friend |
Definition at line 719 of file qgsdataprovider.h.
|
protected |
Error.
Definition at line 685 of file qgsdataprovider.h.
|
protected |
Read flags. It's up to the subclass to respect these when needed.
Definition at line 694 of file qgsdataprovider.h.
|
protected |
Timestamp of data in the moment when the data were loaded by provider.
Definition at line 682 of file qgsdataprovider.h.