QGIS API Documentation  2.99.0-Master (e077efd)
Classes | Public Types | Signals | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Friends | List of all members
QgsVectorDataProvider Class Referenceabstract

This is the base class for vector data providers. More...

#include <qgsvectordataprovider.h>

Inheritance diagram for QgsVectorDataProvider:
Inheritance graph
[legend]

Classes

struct  NativeType
 

Public Types

enum  Capability {
  NoCapabilities = 0, AddFeatures = 1, DeleteFeatures = 1 << 1, ChangeAttributeValues = 1 << 2,
  AddAttributes = 1 << 3, DeleteAttributes = 1 << 4, CreateSpatialIndex = 1 << 6, SelectAtId = 1 << 7,
  ChangeGeometries = 1 << 8, SelectEncoding = 1 << 13, CreateAttributeIndex = 1 << 12, SimplifyGeometries = 1 << 14,
  SimplifyGeometriesWithTopologicalValidation = 1 << 15, TransactionSupport = 1 << 16, CircularGeometries = 1 << 17, ChangeFeatures = 1 << 18,
  RenameAttributes = 1 << 19
}
 enumeration with capabilities that providers might implement More...
 
- Public Types inherited from QgsDataProvider
enum  DataCapability {
  NoDataCapabilities = 0, File = 1, Dir = 1 << 1, Database = 1 << 2,
  Net = 1 << 3
}
 
enum  ProviderProperty { EvaluateDefaultValues, CustomData = 3000 }
 Properties are used to pass custom configuration options into data providers. More...
 

Signals

void raiseError (const QString &msg) const
 Signals an error in this provider. More...
 
- Signals inherited from QgsDataProvider
void dataChanged ()
 This is emitted whenever an asynchronous operation has finished and the data should be redrawn. More...
 
void fullExtentCalculated ()
 This is emitted whenever the worker thread has fully calculated the PostGIS extents for this layer, and its event has been received by this provider. More...
 

Public Member Functions

 QgsVectorDataProvider (const QString &uri=QString())
 Constructor of the vector provider. More...
 
virtual ~QgsVectorDataProvider ()
 Destructor. More...
 
virtual bool addAttributes (const QList< QgsField > &attributes)
 Adds new attributes. More...
 
virtual bool addFeatures (QgsFeatureList &flist)
 Adds a list of features. More...
 
virtual QVariant aggregate (QgsAggregateCalculator::Aggregate aggregate, int index, const QgsAggregateCalculator::AggregateParameters &parameters, QgsExpressionContext *context, bool &ok) const
 Calculates an aggregated value from the layer's features. More...
 
virtual QgsAttributeList attributeIndexes () const
 Return list of indexes to fetch all attributes in nextFeature() More...
 
virtual Capabilities capabilities () const
 Returns flags containing the supported capabilities. More...
 
QString capabilitiesString () const
 Returns the above in friendly format. More...
 
virtual bool changeAttributeValues (const QgsChangedAttributesMap &attr_map)
 Changes attribute values of existing features. More...
 
virtual bool changeFeatures (const QgsChangedAttributesMap &attr_map, const QgsGeometryMap &geometry_map)
 Changes attribute values and geometries of existing features. More...
 
virtual bool changeGeometryValues (const QgsGeometryMap &geometry_map)
 Changes geometries of existing features. More...
 
void clearErrors ()
 Clear recorded errors. More...
 
virtual bool createAttributeIndex (int field)
 Create an attribute index on the datasource. More...
 
virtual bool createSpatialIndex ()
 Creates a spatial index on the datasource (if supported by the provider type). More...
 
virtual QString dataComment () const
 Return a short comment for the data that this provider is providing access to (e.g. More...
 
virtual QVariant defaultValue (int fieldIndex) const
 Returns any literal default values which are present at the provider for a specified field index. More...
 
virtual QString defaultValueClause (int fieldIndex) const
 Returns any default value clauses which are present at the provider for a specified field index. More...
 
virtual bool deleteAttributes (const QgsAttributeIds &attributes)
 Deletes existing attributes. More...
 
virtual bool deleteFeatures (const QgsFeatureIds &id)
 Deletes one or more features. More...
 
virtual QSet< QgsMapLayerDependencydependencies () const
 Get the list of layer ids on which this layer depends. More...
 
virtual QList< QgsRelationdiscoverRelations (const QgsVectorLayer *self, const QList< QgsVectorLayer *> &layers) const
 Discover the available relations with the given layers. More...
 
virtual bool doesStrictFeatureTypeCheck () const
 Returns true if the provider is strict about the type of inserted features (e.g. More...
 
QString encoding () const
 Get encoding which is used for accessing data. More...
 
virtual void enumValues (int index, QStringList &enumList) const
 Returns the possible enum values of an attribute. More...
 
QStringList errors () const
 Get recorded errors. More...
 
virtual long featureCount () const =0
 Number of features in the layer. More...
 
virtual QgsAbstractFeatureSourcefeatureSource () const =0
 Return feature source object that can be used for querying provider's data. More...
 
QgsFieldConstraints::Constraints fieldConstraints (int fieldIndex) const
 Returns any constraints which are present at the provider for a specified field index. More...
 
int fieldNameIndex (const QString &fieldName) const
 Returns the index of a field name or -1 if the field does not exist. More...
 
QMap< QString, int > fieldNameMap () const
 Return a map where the key is the name of the field and the value is its index. More...
 
virtual QgsFields fields () const =0
 Returns the fields associated with this data provider. More...
 
virtual void forceReload ()
 Forces a reload of the underlying datasource if the provider implements this method. More...
 
virtual QgsFeatureIterator getFeatures (const QgsFeatureRequest &request=QgsFeatureRequest()) const =0
 Query the provider for features specified in request. More...
 
bool hasErrors () const
 Provider has errors to report. More...
 
virtual bool isSaveAndLoadStyleToDBSupported () const
 It returns false by default. More...
 
virtual QVariant maximumValue (int index) const
 Returns the maximum value of an attribute. More...
 
virtual QVariantMap metadata () const
 Get metadata, dependent on the provider type, that will be display in the metadata tab of the layer properties. More...
 
virtual QVariant minimumValue (int index) const
 Returns the minimum value of an attribute. More...
 
const QList< NativeType > & nativeTypes () const
 Returns the names of the supported types. More...
 
virtual QgsAttrPalIndexNameHash palAttributeIndexNames () const
 Return list of indexes to names for QgsPalLabeling fix. More...
 
virtual QgsAttributeList pkAttributeIndexes () const
 Return list of indexes of fields that make up the primary key. More...
 
virtual bool renameAttributes (const QgsFieldNameMap &renamedAttributes)
 Renames existing attributes. More...
 
virtual void setEncoding (const QString &e)
 Set encoding used for accessing data from layer. More...
 
virtual bool skipConstraintCheck (int fieldIndex, QgsFieldConstraints::Constraint constraint, const QVariant &value=QVariant()) const
 Returns true if a constraint check should be skipped for a specified field (eg if the value returned by defaultValue() is trusted implicitly. More...
 
virtual QString storageType () const
 Returns the permanent storage type for this layer as a friendly name. More...
 
bool supportedType (const QgsField &field) const
 check if provider supports type of field More...
 
virtual QgsTransactiontransaction () const
 Returns the transaction this data provider is included in, if any. More...
 
virtual QString translateMetadataKey (const QString &mdKey) const
 Get the translated metadata key. More...
 
virtual QString translateMetadataValue (const QString &mdKey, const QVariant &value) const
 Get the translated metadata value. More...
 
virtual QStringList uniqueStringsMatching (int index, const QString &substring, int limit=-1, QgsFeedback *feedback=nullptr) const
 Returns unique string values of an attribute which contain a specified subset string. More...
 
virtual void uniqueValues (int index, QList< QVariant > &uniqueValues, int limit=-1) const
 Return unique values of an attribute. More...
 
virtual QgsWkbTypes::Type wkbType () const =0
 Returns the geometry type which is returned by this layer. More...
 
- Public Member Functions inherited from QgsDataProvider
 QgsDataProvider (QString const &uri="")
 
virtual ~QgsDataProvider ()
 We need this so the subclass destructors get called. More...
 
virtual QgsCoordinateReferenceSystem crs () const =0
 Returns the coordinate system for the data source. More...
 
virtual QString dataSourceUri (bool expandAuthConfig=false) const
 Get the data source specification. More...
 
virtual QDateTime dataTimestamp () const
 Current time stamp of data source. More...
 
virtual QString description () const =0
 Return description. More...
 
virtual bool enterUpdateMode ()
 Enter update mode. More...
 
virtual QgsError error () const
 Get current status error. More...
 
virtual QgsRectangle extent () const =0
 Returns the extent of the layer. More...
 
virtual QString fileRasterFilters () const
 Return raster file filter string. More...
 
virtual QString fileVectorFilters () const
 Return vector file filter string. More...
 
virtual void invalidateConnections (const QString &connection)
 Invalidate connections corresponding to specified name. More...
 
virtual bool isValid () const =0
 Returns true if this is a valid layer. More...
 
virtual bool leaveUpdateMode ()
 Leave update mode. More...
 
virtual QString name () const =0
 Return a provider name. More...
 
QVariant providerProperty (ProviderProperty property, const QVariant &defaultValue=QVariant()) const
 Get the current value of a certain provider property. More...
 
QVariant providerProperty (int property, const QVariant &defaultValue) const
 Get the current value of a certain provider property. More...
 
virtual void reloadData ()
 Reloads the data from the source. More...
 
virtual void setDataSourceUri (const QString &uri)
 Set the data source specification. More...
 
virtual void setLayerOrder (const QStringList &layers)
 Reorder the list of layer names to be rendered by this provider (in order from bottom to top) More...
 
void setProviderProperty (ProviderProperty property, const QVariant &value)
 Allows setting arbitrary properties on the provider. More...
 
void setProviderProperty (int property, const QVariant &value)
 Allows setting arbitrary properties on the provider. More...
 
virtual void setSubLayerVisibility (const QString &name, bool vis)
 Set the visibility of the given sublayer name. More...
 
virtual bool setSubsetString (const QString &subset, bool updateFeatureCount=true)
 Set the subset string used to create a subset of features in the layer. More...
 
virtual uint subLayerCount () const
 return the number of layers for the current data source More...
 
virtual QStringList subLayers () const
 Sub-layers handled by this provider, in order from bottom to top. More...
 
virtual QStringList subLayerStyles () const
 Sub-layer styles for each sub-layer handled by this provider, in order from bottom to top. More...
 
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. More...
 
virtual bool supportsSubsetString () const
 Returns true if the provider supports setting of subset strings. More...
 
virtual QDateTime timestamp () const
 Time stamp of data source in the moment when data/metadata were loaded by provider. More...
 
virtual void updateExtents ()
 Update the extents of the layer. More...
 

Static Public Member Functions

static QStringList availableEncodings ()
 Returns a list of available encodings. More...
 
static QVariant convertValue (QVariant::Type type, const QString &value)
 

Static Public Attributes

static const int EditingCapabilities
 Bitmask of all provider's editing capabilities. More...
 

Protected Member Functions

void clearMinMaxCache ()
 Invalidates the min/max cache. More...
 
QgsGeometryconvertToProviderType (const QgsGeometry &geom) const
 Converts the geometry to the provider type if possible / necessary. More...
 
void fillMinMaxCache () const
 Populates the cache of minimum and maximum attribute values. More...
 
void pushError (const QString &msg) const
 Push a notification about errors that happened in this providers scope. More...
 
void setNativeTypes (const QList< NativeType > &nativeTypes)
 Set the list of native types supported by this provider. More...
 
QTextCodec * textEncoding () const
 Get this providers encoding. More...
 
- Protected Member Functions inherited from QgsDataProvider
void appendError (const QgsErrorMessage &theMessage)
 Add error message. More...
 
void setError (const QgsError &theError)
 Set error message. More...
 

Friends

class QgsTransaction
 

Additional Inherited Members

- Protected Attributes inherited from QgsDataProvider
QgsError mError
 Error. More...
 
QDateTime mTimestamp
 Timestamp of data in the moment when the data were loaded by provider. More...
 

Detailed Description

This is the base class for vector data providers.

Data providers abstract the retrieval and writing (where supported) of feature and attribute information from a spatial datasource.

Definition at line 51 of file qgsvectordataprovider.h.

Member Enumeration Documentation

§ Capability

enumeration with capabilities that providers might implement

Enumerator
NoCapabilities 

Provider has no capabilities.

AddFeatures 

Allows adding features.

DeleteFeatures 

Allows deletion of features.

ChangeAttributeValues 

Allows modification of attribute values.

AddAttributes 

Allows addition of new attributes (fields)

DeleteAttributes 

Allows deletion of attributes (fields)

CreateSpatialIndex 

Allows creation of spatial index.

SelectAtId 

Fast access to features using their ID.

ChangeGeometries 

Allows modifications of geometries.

SelectEncoding 

Allows user to select encoding.

CreateAttributeIndex 

Can create indexes on provider's fields.

SimplifyGeometries 

Supports simplification of geometries on provider side according to a distance tolerance.

SimplifyGeometriesWithTopologicalValidation 

Supports topological simplification of geometries on provider side according to a distance tolerance.

TransactionSupport 

Supports transactions.

CircularGeometries 

Supports circular geometry types (circularstring, compoundcurve, curvepolygon)

ChangeFeatures 

Supports joint updates for attributes and geometry Providers supporting this should still define ChangeGeometries | ChangeAttributeValues.

RenameAttributes 

Supports renaming attributes (fields). Added in QGIS 2.16.

Definition at line 64 of file qgsvectordataprovider.h.

Constructor & Destructor Documentation

§ QgsVectorDataProvider()

QgsVectorDataProvider::QgsVectorDataProvider ( const QString &  uri = QString())

Constructor of the vector provider.

Parameters
uriuniform resource locator (URI) for a dataset

Definition at line 37 of file qgsvectordataprovider.cpp.

§ ~QgsVectorDataProvider()

QgsVectorDataProvider::~QgsVectorDataProvider ( )
virtual

Destructor.

Definition at line 46 of file qgsvectordataprovider.cpp.

Member Function Documentation

§ addAttributes()

bool QgsVectorDataProvider::addAttributes ( const QList< QgsField > &  attributes)
virtual

Adds new attributes.

Parameters
attributeslist of new attributes
Returns
true in case of success and false in case of failure

Definition at line 72 of file qgsvectordataprovider.cpp.

§ addFeatures()

bool QgsVectorDataProvider::addFeatures ( QgsFeatureList flist)
virtual

Adds a list of features.

Returns
true in case of success and false in case of failure

Definition at line 60 of file qgsvectordataprovider.cpp.

§ aggregate()

QVariant QgsVectorDataProvider::aggregate ( QgsAggregateCalculator::Aggregate  aggregate,
int  index,
const QgsAggregateCalculator::AggregateParameters parameters,
QgsExpressionContext context,
bool &  ok 
) const
virtual

Calculates an aggregated value from the layer's features.

The base implementation does nothing, but subclasses can override this method to handoff calculation of aggregates to the provider.

Parameters
aggregateaggregate to calculate
indexthe index of the attribute to calculate aggregate over
parametersparameters controlling aggregate calculation
contextexpression context for filter
okwill be set to true if calculation was successfully performed by the data provider
Returns
calculated aggregate value
Note
added in QGIS 2.16

Definition at line 472 of file qgsvectordataprovider.cpp.

§ attributeIndexes()

QgsAttributeList QgsVectorDataProvider::attributeIndexes ( ) const
virtual

Return list of indexes to fetch all attributes in nextFeature()

Definition at line 298 of file qgsvectordataprovider.cpp.

§ availableEncodings()

QStringList QgsVectorDataProvider::availableEncodings ( )
static

Returns a list of available encodings.

Definition at line 602 of file qgsvectordataprovider.cpp.

§ capabilities()

QgsVectorDataProvider::Capabilities QgsVectorDataProvider::capabilities ( ) const
virtual

Returns flags containing the supported capabilities.

Note
, some capabilities may change depending on whether a spatial filter is active on this provider, so it may be prudent to check this value per intended operation.

Definition at line 147 of file qgsvectordataprovider.cpp.

§ capabilitiesString()

QString QgsVectorDataProvider::capabilitiesString ( ) const

Returns the above in friendly format.

Definition at line 179 of file qgsvectordataprovider.cpp.

§ changeAttributeValues()

bool QgsVectorDataProvider::changeAttributeValues ( const QgsChangedAttributesMap attr_map)
virtual

Changes attribute values of existing features.

Parameters
attr_mapa map containing changed attributes
Returns
true in case of success and false in case of failure

Definition at line 90 of file qgsvectordataprovider.cpp.

§ changeFeatures()

bool QgsVectorDataProvider::changeFeatures ( const QgsChangedAttributesMap attr_map,
const QgsGeometryMap geometry_map 
)
virtual

Changes attribute values and geometries of existing features.

Parameters
attr_mapa map containing changed attributes
geometry_mapA QgsGeometryMap whose index contains the feature IDs that will have their geometries changed. The second map parameter being the new geometries themselves
Returns
true in case of success and false in case of failure

Definition at line 128 of file qgsvectordataprovider.cpp.

§ changeGeometryValues()

bool QgsVectorDataProvider::changeGeometryValues ( const QgsGeometryMap geometry_map)
virtual

Changes geometries of existing features.

Parameters
geometry_mapA QgsGeometryMap whose index contains the feature IDs that will have their geometries changed. The second map parameter being the new geometries themselves
Returns
True in case of success and false in case of failure

Definition at line 122 of file qgsvectordataprovider.cpp.

§ clearErrors()

void QgsVectorDataProvider::clearErrors ( )

Clear recorded errors.

Definition at line 665 of file qgsvectordataprovider.cpp.

§ clearMinMaxCache()

void QgsVectorDataProvider::clearMinMaxCache ( )
protected

Invalidates the min/max cache.

This will force the provider to recalculate the cache the next time it is requested.

Definition at line 485 of file qgsvectordataprovider.cpp.

§ convertToProviderType()

QgsGeometry * QgsVectorDataProvider::convertToProviderType ( const QgsGeometry geom) const
protected

Converts the geometry to the provider type if possible / necessary.

Returns
the converted geometry or nullptr if no conversion was necessary or possible

Definition at line 697 of file qgsvectordataprovider.cpp.

§ convertValue()

QVariant QgsVectorDataProvider::convertValue ( QVariant::Type  type,
const QString &  value 
)
static

Definition at line 577 of file qgsvectordataprovider.cpp.

§ createAttributeIndex()

bool QgsVectorDataProvider::createAttributeIndex ( int  field)
virtual

Create an attribute index on the datasource.

Definition at line 141 of file qgsvectordataprovider.cpp.

§ createSpatialIndex()

bool QgsVectorDataProvider::createSpatialIndex ( )
virtual

Creates a spatial index on the datasource (if supported by the provider type).

Returns
true in case of success

Definition at line 136 of file qgsvectordataprovider.cpp.

§ dataComment()

QString QgsVectorDataProvider::dataComment ( ) const
virtual

Return a short comment for the data that this provider is providing access to (e.g.

the comment for postgres table).

Definition at line 55 of file qgsvectordataprovider.cpp.

§ defaultValue()

QVariant QgsVectorDataProvider::defaultValue ( int  fieldIndex) const
virtual

Returns any literal default values which are present at the provider for a specified field index.

Important - this should ONLY be called when creating an attribute to insert directly into the database. Do not call this method for non-feature creation or modification, eg when validating an attribute or to compare it against an existing value, as calling it can cause changes to the underlying data source (eg Postgres provider where the default value is calculated as a result of a sequence). It is recommended that you instead use the methods in QgsVectorLayerUtils such as QgsVectorLayerUtils::createFeature() so that default value handling and validation is automatically carried out.

See also
defaultValueClause()

Definition at line 96 of file qgsvectordataprovider.cpp.

§ defaultValueClause()

QString QgsVectorDataProvider::defaultValueClause ( int  fieldIndex) const
virtual

Returns any default value clauses which are present at the provider for a specified field index.

These clauses are usually SQL fragments which must be evaluated by the provider, eg sequence values.

See also
defaultValue()
Note
added in QGIS 3.0

Definition at line 102 of file qgsvectordataprovider.cpp.

§ deleteAttributes()

bool QgsVectorDataProvider::deleteAttributes ( const QgsAttributeIds attributes)
virtual

Deletes existing attributes.

Parameters
attributesa set containing indices of attributes
Returns
true in case of success and false in case of failure

Definition at line 78 of file qgsvectordataprovider.cpp.

§ deleteFeatures()

bool QgsVectorDataProvider::deleteFeatures ( const QgsFeatureIds id)
virtual

Deletes one or more features.

Parameters
idlist containing feature ids to delete
Returns
true in case of success and false in case of failure

Definition at line 66 of file qgsvectordataprovider.cpp.

§ dependencies()

QSet< QgsMapLayerDependency > QgsVectorDataProvider::dependencies ( ) const
virtual

Get the list of layer ids on which this layer depends.

This in particular determines the order of layer loading.

Definition at line 692 of file qgsvectordataprovider.cpp.

§ discoverRelations()

QList< QgsRelation > QgsVectorDataProvider::discoverRelations ( const QgsVectorLayer self,
const QList< QgsVectorLayer *> &  layers 
) const
virtual

Discover the available relations with the given layers.

Parameters
selfthe layer using this data provider.
layersthe other layers.
Returns
the list of N-1 relations from this provider.
Note
added in QGIS 3.0

Definition at line 808 of file qgsvectordataprovider.cpp.

§ doesStrictFeatureTypeCheck()

virtual bool QgsVectorDataProvider::doesStrictFeatureTypeCheck ( ) const
inlinevirtual

Returns true if the provider is strict about the type of inserted features (e.g.

no multipolygon in a polygon layer)

Definition at line 435 of file qgsvectordataprovider.h.

§ encoding()

QString QgsVectorDataProvider::encoding ( ) const

Get encoding which is used for accessing data.

Definition at line 169 of file qgsvectordataprovider.cpp.

§ enumValues()

virtual void QgsVectorDataProvider::enumValues ( int  index,
QStringList &  enumList 
) const
inlinevirtual

Returns the possible enum values of an attribute.

Returns an empty stringlist if a provider does not support enum types or if the given attribute is not an enum type.

Parameters
indexthe index of the attribute
enumListreference to the list to fill

Definition at line 239 of file qgsvectordataprovider.h.

§ errors()

QStringList QgsVectorDataProvider::errors ( ) const

Get recorded errors.

Definition at line 675 of file qgsvectordataprovider.cpp.

§ featureCount()

virtual long QgsVectorDataProvider::featureCount ( ) const
pure virtual

Number of features in the layer.

Returns
long containing number of features

§ featureSource()

virtual QgsAbstractFeatureSource* QgsVectorDataProvider::featureSource ( ) const
pure virtual

Return feature source object that can be used for querying provider's data.

The returned feature source is independent from provider - any changes to provider's state (e.g. change of subset string) will not be reflected in the feature source, therefore it can be safely used for processing in background without having to care about possible changes within provider that may happen concurrently. Also, even in the case of provider being deleted, any feature source obtained from the provider will be kept alive and working (they are independent and owned by the caller).

Sometimes there are cases when some data needs to be shared between vector data provider and its feature source. In such cases, the implementation must ensure that the data is not susceptible to run condition. For example, if it is possible that both feature source and provider may need reading/writing to some shared data at the same time, some synchronization mechanisms must be used (e.g. mutexes) to prevent data corruption.

Note
added in 2.4
Returns
new instance of QgsAbstractFeatureSource (caller is responsible for deleting it)

§ fieldConstraints()

QgsFieldConstraints::Constraints QgsVectorDataProvider::fieldConstraints ( int  fieldIndex) const

Returns any constraints which are present at the provider for a specified field index.

Note
added in QGIS 3.0
See also
skipConstraintCheck()

Definition at line 108 of file qgsvectordataprovider.cpp.

§ fieldNameIndex()

int QgsVectorDataProvider::fieldNameIndex ( const QString &  fieldName) const

Returns the index of a field name or -1 if the field does not exist.

Definition at line 280 of file qgsvectordataprovider.cpp.

§ fieldNameMap()

QMap< QString, int > QgsVectorDataProvider::fieldNameMap ( ) const

Return a map where the key is the name of the field and the value is its index.

Definition at line 285 of file qgsvectordataprovider.cpp.

§ fields()

virtual QgsFields QgsVectorDataProvider::fields ( ) const
pure virtual

Returns the fields associated with this data provider.

§ fillMinMaxCache()

void QgsVectorDataProvider::fillMinMaxCache ( ) const
protected

Populates the cache of minimum and maximum attribute values.

Definition at line 490 of file qgsvectordataprovider.cpp.

§ forceReload()

void QgsVectorDataProvider::forceReload ( )
virtual

Forces a reload of the underlying datasource if the provider implements this method.

In particular on the OGR provider, a pooled connection will be invalidated. This forces QGIS to reopen a file or connection. This can be required if the underlying file is replaced.

Definition at line 592 of file qgsvectordataprovider.cpp.

§ getFeatures()

virtual QgsFeatureIterator QgsVectorDataProvider::getFeatures ( const QgsFeatureRequest request = QgsFeatureRequest()) const
pure virtual

Query the provider for features specified in request.

Parameters
requestfeature request describing parameters of features to return
Returns
iterator for matching features from provider

§ hasErrors()

bool QgsVectorDataProvider::hasErrors ( ) const

Provider has errors to report.

Definition at line 670 of file qgsvectordataprovider.cpp.

§ isSaveAndLoadStyleToDBSupported()

bool QgsVectorDataProvider::isSaveAndLoadStyleToDBSupported ( ) const
virtual

It returns false by default.

Must be implemented by providers that support saving and loading styles to db returning true

Definition at line 680 of file qgsvectordataprovider.cpp.

§ maximumValue()

QVariant QgsVectorDataProvider::maximumValue ( int  index) const
virtual

Returns the maximum value of an attribute.

Parameters
indexthe index of the attribute

Default implementation walks all numeric attributes and caches minimal and maximal values. If provider has facilities to retrieve maximal value directly, override this function.

Definition at line 402 of file qgsvectordataprovider.cpp.

§ metadata()

virtual QVariantMap QgsVectorDataProvider::metadata ( ) const
inlinevirtual

Get metadata, dependent on the provider type, that will be display in the metadata tab of the layer properties.

Returns
The provider metadata

Definition at line 495 of file qgsvectordataprovider.h.

§ minimumValue()

QVariant QgsVectorDataProvider::minimumValue ( int  index) const
virtual

Returns the minimum value of an attribute.

Parameters
indexthe index of the attribute

Default implementation walks all numeric attributes and caches minimal and maximal values. If provider has facilities to retrieve minimal value directly, override this function.

Definition at line 386 of file qgsvectordataprovider.cpp.

§ nativeTypes()

const QList< QgsVectorDataProvider::NativeType > & QgsVectorDataProvider::nativeTypes ( ) const

Returns the names of the supported types.

Definition at line 308 of file qgsvectordataprovider.cpp.

§ palAttributeIndexNames()

QgsAttrPalIndexNameHash QgsVectorDataProvider::palAttributeIndexNames ( ) const
virtual

Return list of indexes to names for QgsPalLabeling fix.

Definition at line 313 of file qgsvectordataprovider.cpp.

§ pkAttributeIndexes()

QgsAttributeList QgsVectorDataProvider::pkAttributeIndexes ( ) const
virtual

Return list of indexes of fields that make up the primary key.

Definition at line 303 of file qgsvectordataprovider.cpp.

§ pushError()

void QgsVectorDataProvider::pushError ( const QString &  msg) const
protected

Push a notification about errors that happened in this providers scope.

Errors should be translated strings that require the users immediate attention.

For general debug information use QgsMessageLog::logMessage() instead.

Note
Added in QGIS 3.0

Definition at line 685 of file qgsvectordataprovider.cpp.

§ raiseError

void QgsVectorDataProvider::raiseError ( const QString &  msg) const
signal

Signals an error in this provider.

Note
Added const in QGIS 3.0

§ renameAttributes()

bool QgsVectorDataProvider::renameAttributes ( const QgsFieldNameMap renamedAttributes)
virtual

Renames existing attributes.

Parameters
renamedAttributesmap of attribute index to new attribute name
Returns
true in case of success and false in case of failure
Note
added in QGIS 2.16

Definition at line 84 of file qgsvectordataprovider.cpp.

§ setEncoding()

void QgsVectorDataProvider::setEncoding ( const QString &  e)
virtual

Set encoding used for accessing data from layer.

Definition at line 153 of file qgsvectordataprovider.cpp.

§ setNativeTypes()

void QgsVectorDataProvider::setNativeTypes ( const QList< NativeType > &  nativeTypes)
protected

Set the list of native types supported by this provider.

Usually done in the constructor.

Note
Added in QGIS 3.0

Definition at line 796 of file qgsvectordataprovider.cpp.

§ skipConstraintCheck()

bool QgsVectorDataProvider::skipConstraintCheck ( int  fieldIndex,
QgsFieldConstraints::Constraint  constraint,
const QVariant &  value = QVariant() 
) const
virtual

Returns true if a constraint check should be skipped for a specified field (eg if the value returned by defaultValue() is trusted implicitly.

An optional attribute value can be passed which can help refine the skip constraint check.

Note
added in QGIS 3.0
See also
fieldConstraints()

Definition at line 117 of file qgsvectordataprovider.cpp.

§ storageType()

QString QgsVectorDataProvider::storageType ( ) const
virtual

Returns the permanent storage type for this layer as a friendly name.

Definition at line 50 of file qgsvectordataprovider.cpp.

§ supportedType()

bool QgsVectorDataProvider::supportedType ( const QgsField field) const

check if provider supports type of field

Definition at line 318 of file qgsvectordataprovider.cpp.

§ textEncoding()

QTextCodec * QgsVectorDataProvider::textEncoding ( ) const
protected

Get this providers encoding.

Note
Added in QGIS 3.0

Definition at line 801 of file qgsvectordataprovider.cpp.

§ transaction()

QgsTransaction * QgsVectorDataProvider::transaction ( ) const
virtual

Returns the transaction this data provider is included in, if any.

Definition at line 587 of file qgsvectordataprovider.cpp.

§ translateMetadataKey()

virtual QString QgsVectorDataProvider::translateMetadataKey ( const QString &  mdKey) const
inlinevirtual

Get the translated metadata key.

Parameters
mdKeyThe metadata key
Returns
The translated metadata value

Definition at line 502 of file qgsvectordataprovider.h.

§ translateMetadataValue()

virtual QString QgsVectorDataProvider::translateMetadataValue ( const QString &  mdKey,
const QVariant &  value 
) const
inlinevirtual

Get the translated metadata value.

Parameters
mdKeyThe metadata key
valueThe metadata value
Returns
The translated metadata value

Definition at line 510 of file qgsvectordataprovider.h.

§ uniqueStringsMatching()

QStringList QgsVectorDataProvider::uniqueStringsMatching ( int  index,
const QString &  substring,
int  limit = -1,
QgsFeedback feedback = nullptr 
) const
virtual

Returns unique string values of an attribute which contain a specified subset string.

Subset matching is done in a case-insensitive manner.

Parameters
indexthe index of the attribute
substringsubstring to match (case insensitive)
limitmaxmum number of the values to return, or -1 to return all unique values
feedbackoptional feedback object for cancelling request
Returns
list of unique strings containing substring

Definition at line 441 of file qgsvectordataprovider.cpp.

§ uniqueValues()

void QgsVectorDataProvider::uniqueValues ( int  index,
QList< QVariant > &  uniqueValues,
int  limit = -1 
) const
virtual

Return unique values of an attribute.

Parameters
indexthe index of the attribute
uniqueValuesvalues reference to the list to fill
limitmaxmum number of the values to return

Default implementation simply iterates the features

Definition at line 418 of file qgsvectordataprovider.cpp.

§ wkbType()

virtual QgsWkbTypes::Type QgsVectorDataProvider::wkbType ( ) const
pure virtual

Returns the geometry type which is returned by this layer.

Friends And Related Function Documentation

§ QgsTransaction

friend class QgsTransaction
friend

Definition at line 55 of file qgsvectordataprovider.h.

Member Data Documentation

§ EditingCapabilities

const int QgsVectorDataProvider::EditingCapabilities
static
Initial value:

Bitmask of all provider's editing capabilities.

Definition at line 108 of file qgsvectordataprovider.h.


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