QGIS API Documentation
2.18.21-Las Palmas (9fba24a)
|
This is the base class for vector data providers. More...
#include <qgsvectordataprovider.h>
Classes | |
struct | NativeType |
Signals | |
void | raiseError (const QString &msg) |
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 | dataChanged (int changed) |
This is emitted whenever data or metadata (e.g. 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 ¶meters, QgsExpressionContext *context, bool &ok) |
Calculates an aggregated value from the layer's features. More... | |
virtual QgsAttributeList | attributeIndexes () |
Return list of indexes to fetch all attributes in nextFeature() More... | |
virtual int | capabilities () const |
Returns a bitmask 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. 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 fieldId, bool forceLazyEval=false) |
Returns the default value for field specified by fieldId. More... | |
virtual bool | deleteAttributes (const QgsAttributeIds &attributes) |
Deletes existing attributes. More... | |
virtual bool | deleteFeatures (const QgsFeatureIds &id) |
Deletes one or more features. 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) |
Returns the possible enum values of an attribute. More... | |
QStringList | errors () |
Get recorded errors. More... | |
virtual long | featureCount () const =0 |
Number of features in the layer. More... | |
virtual QgsAbstractFeatureSource * | featureSource () const =0 |
Return feature source object that can be used for querying provider's data. 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 const QgsFields & | fields () const =0 |
Return a map of indexes with field names for this layer. More... | |
virtual void | forceReload () |
Forces a reload of the underlying datasource if the provider implements this method. More... | |
virtual QGis::WkbType | geometryType () const =0 |
Get feature type. More... | |
virtual QgsFeatureIterator | getFeatures (const QgsFeatureRequest &request=QgsFeatureRequest())=0 |
Query the provider for features specified in request. More... | |
bool | hasErrors () |
Provider has errors to report. More... | |
virtual bool | isSaveAndLoadStyleToDBSupported () |
It returns false by default. More... | |
virtual QSet< QString > | layerDependencies () const |
Get the list of layer ids on which this layer depends. More... | |
virtual QVariant | maximumValue (int index) |
Returns the maximum value of an attribute. More... | |
virtual QVariant | minimumValue (int index) |
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 () |
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 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 QgsTransaction * | transaction () const |
Returns the transaction this data provider is included in, if any. More... | |
virtual void | uniqueValues (int index, QList< QVariant > &uniqueValues, int limit=-1) |
Return unique values of an attribute. 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 ()=0 |
Get the QgsCoordinateReferenceSystem for this layer. 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 ()=0 |
Get 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 ()=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 () |
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 () |
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... | |
Public Member Functions inherited from QObject | |
QObject (QObject *parent) | |
QObject (QObject *parent, const char *name) | |
virtual | ~QObject () |
bool | blockSignals (bool block) |
QObject * | child (const char *objName, const char *inheritsClass, bool recursiveSearch) const |
const QObjectList & | children () const |
const char * | className () const |
bool | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const QObject *receiver, const char *method) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QByteArray > | dynamicPropertyNames () const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name) const |
QList< T > | findChildren (const QRegExp ®Exp) const |
QList< T > | findChildren (const QString &name) const |
bool | inherits (const char *className) const |
void | insertChild (QObject *object) |
void | installEventFilter (QObject *filterObj) |
bool | isA (const char *className) const |
bool | isWidgetType () const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
const char * | name () const |
const char * | name (const char *defaultName) const |
QString | objectName () const |
QObject * | parent () const |
QVariant | property (const char *name) const |
void | removeChild (QObject *object) |
void | removeEventFilter (QObject *obj) |
void | setName (const char *name) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval) |
QThread * | thread () const |
Static Public Member Functions | |
static const QStringList & | availableEncodings () |
Returns a list of available encodings. More... | |
static QVariant | convertValue (QVariant::Type type, const QString &value) |
Static Public Member Functions inherited from QObject | |
bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
Static Public Attributes | |
static const int | EditingCapabilities |
Bitmask of all provider's editing capabilities. More... | |
Protected Member Functions | |
void | clearMinMaxCache () |
QgsGeometry * | convertToProviderType (const QgsGeometry *geom) const |
Converts the geometry to the provider type if possible / necessary this is the list of possible modifications: More... | |
void | fillMinMaxCache () |
void | pushError (const QString &msg) |
Protected Member Functions inherited from QgsDataProvider | |
void | appendError (const QgsErrorMessage &theMessage) |
Add error message. More... | |
void | setError (const QgsError &theError) |
Set error message. More... | |
Protected Member Functions inherited from QObject | |
bool | checkConnectArgs (const char *signal, const QObject *object, const char *method) |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const char *signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const char *signal) |
int | receivers (const char *signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Protected Attributes | |
QgsAttributeList | mAttributesToFetch |
List of attribute indices to fetch with nextFeature calls. More... | |
QgsAttrPalIndexNameHash | mAttrPalIndexName |
Old-style mapping of index to name for QgsPalLabeling fix. More... | |
QMap< int, QVariant > | mCacheMaxValues |
bool | mCacheMinMaxDirty |
QMap< int, QVariant > | mCacheMinValues |
QTextCodec * | mEncoding |
Encoding. More... | |
QList< NativeType > | mNativeTypes |
The names of the providers native types. More... | |
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... | |
Friends | |
class | QgsTransaction |
class | QgsVectorLayerEditBuffer |
Additional Inherited Members | |
Static Protected Member Functions inherited from QObject | |
QByteArray | normalizeSignalSlot (const char *signalSlot) |
Properties inherited from QObject | |
objectName | |
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 50 of file qgsvectordataprovider.h.
enumeration with capabilities that providers might implement
Definition at line 63 of file qgsvectordataprovider.h.
Constructor of the vector provider.
uri | uniform resource locator (URI) for a dataset |
Definition at line 36 of file qgsvectordataprovider.cpp.
|
virtual |
Destructor.
Definition at line 46 of file qgsvectordataprovider.cpp.
Adds new attributes.
attributes | list of new attributes |
Definition at line 72 of file qgsvectordataprovider.cpp.
|
virtual |
Adds a list of features.
Definition at line 60 of file qgsvectordataprovider.cpp.
|
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.
aggregate | aggregate to calculate |
index | the index of the attribute to calculate aggregate over |
parameters | parameters controlling aggregate calculation |
context | expression context for filter |
ok | will be set to true if calculation was successfully performed by the data provider |
Definition at line 415 of file qgsvectordataprovider.cpp.
|
virtual |
Return list of indexes to fetch all attributes in nextFeature()
Definition at line 282 of file qgsvectordataprovider.cpp.
|
static |
Returns a list of available encodings.
Definition at line 535 of file qgsvectordataprovider.cpp.
|
virtual |
Returns a bitmask 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 128 of file qgsvectordataprovider.cpp.
QString QgsVectorDataProvider::capabilitiesString | ( | ) | const |
Returns the above in friendly format.
Definition at line 163 of file qgsvectordataprovider.cpp.
|
virtual |
Changes attribute values of existing features.
attr_map | a map containing changed attributes |
Definition at line 90 of file qgsvectordataprovider.cpp.
|
virtual |
Changes attribute values and geometries of existing features.
attr_map | a map containing changed attributes |
geometry_map | A QgsGeometryMap whose index contains the feature IDs that will have their geometries changed. The second map parameter being the new geometries themselves |
Definition at line 109 of file qgsvectordataprovider.cpp.
|
virtual |
Changes geometries of existing features.
geometry_map | A QgsGeometryMap whose index contains the feature IDs that will have their geometries changed. The second map parameter being the new geometries themselves |
Definition at line 103 of file qgsvectordataprovider.cpp.
void QgsVectorDataProvider::clearErrors | ( | ) |
Clear recorded errors.
Definition at line 598 of file qgsvectordataprovider.cpp.
|
protected |
Definition at line 428 of file qgsvectordataprovider.cpp.
|
protected |
Converts the geometry to the provider type if possible / necessary this is the list of possible modifications:
geom | Geometry to convert |
Definition at line 625 of file qgsvectordataprovider.cpp.
Definition at line 520 of file qgsvectordataprovider.cpp.
|
virtual |
Create an attribute index on the datasource.
Definition at line 122 of file qgsvectordataprovider.cpp.
|
virtual |
Creates a spatial index on the datasource (if supported by the provider type).
Definition at line 117 of file qgsvectordataprovider.cpp.
|
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.
|
virtual |
Returns the default value for field specified by fieldId.
If forceLazyEval is set to true, the provider the default value will not be evaluated on server side even if specified in the project properties.
Definition at line 96 of file qgsvectordataprovider.cpp.
|
virtual |
Deletes existing attributes.
attributes | a set containing indices of attributes |
Definition at line 78 of file qgsvectordataprovider.cpp.
|
virtual |
Deletes one or more features.
id | list containing feature ids to delete |
Definition at line 66 of file qgsvectordataprovider.cpp.
|
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 395 of file qgsvectordataprovider.h.
QString QgsVectorDataProvider::encoding | ( | ) | const |
Get encoding which is used for accessing data.
Definition at line 153 of file qgsvectordataprovider.cpp.
|
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.
index | the index of the attribute |
enumList | reference to the list to fill |
Definition at line 233 of file qgsvectordataprovider.h.
QStringList QgsVectorDataProvider::errors | ( | ) |
Get recorded errors.
Definition at line 608 of file qgsvectordataprovider.cpp.
|
pure virtual |
Number of features in the layer.
|
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.
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 264 of file qgsvectordataprovider.cpp.
Return a map where the key is the name of the field and the value is its index.
Definition at line 269 of file qgsvectordataprovider.cpp.
|
pure virtual |
|
protected |
Definition at line 433 of file qgsvectordataprovider.cpp.
|
inlinevirtual |
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 436 of file qgsvectordataprovider.h.
|
pure virtual |
Get feature type.
|
pure virtual |
Query the provider for features specified in request.
bool QgsVectorDataProvider::hasErrors | ( | ) |
Provider has errors to report.
Definition at line 603 of file qgsvectordataprovider.cpp.
|
inlinevirtual |
It returns false by default.
Must be implemented by providers that support saving and loading styles to db returning true
Definition at line 420 of file qgsvectordataprovider.h.
Get the list of layer ids on which this layer depends.
This in particular determines the order of layer loading.
Definition at line 620 of file qgsvectordataprovider.cpp.
|
virtual |
Returns the maximum value of an attribute.
index | the 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 376 of file qgsvectordataprovider.cpp.
|
virtual |
Returns the minimum value of an attribute.
index | the 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 360 of file qgsvectordataprovider.cpp.
const QList< QgsVectorDataProvider::NativeType > & QgsVectorDataProvider::nativeTypes | ( | ) | const |
Returns the names of the supported types.
Definition at line 287 of file qgsvectordataprovider.cpp.
|
inlinevirtual |
Return list of indexes to names for QgsPalLabeling fix.
Definition at line 358 of file qgsvectordataprovider.h.
|
inlinevirtual |
Return list of indexes of fields that make up the primary key.
Definition at line 353 of file qgsvectordataprovider.h.
|
protected |
Definition at line 613 of file qgsvectordataprovider.cpp.
|
signal |
Signals an error in this provider.
|
virtual |
Renames existing attributes.
renamedAttributes | map of attribute index to new attribute name |
Definition at line 84 of file qgsvectordataprovider.cpp.
|
virtual |
Set encoding used for accessing data from layer.
Definition at line 134 of file qgsvectordataprovider.cpp.
|
virtual |
Returns the permanent storage type for this layer as a friendly name.
Definition at line 50 of file qgsvectordataprovider.cpp.
bool QgsVectorDataProvider::supportedType | ( | const QgsField & | field | ) | const |
check if provider supports type of field
Definition at line 292 of file qgsvectordataprovider.cpp.
|
inlinevirtual |
Returns the transaction this data provider is included in, if any.
Definition at line 427 of file qgsvectordataprovider.h.
|
virtual |
Return unique values of an attribute.
index | the index of the attribute |
uniqueValues | values reference to the list to fill |
limit | maxmum number of the values to return |
Default implementation simply iterates the features
Definition at line 392 of file qgsvectordataprovider.cpp.
|
friend |
Definition at line 54 of file qgsvectordataprovider.h.
|
friend |
Definition at line 55 of file qgsvectordataprovider.h.
|
static |
Bitmask of all provider's editing capabilities.
Definition at line 112 of file qgsvectordataprovider.h.
|
protected |
List of attribute indices to fetch with nextFeature calls.
Definition at line 461 of file qgsvectordataprovider.h.
|
protected |
Old-style mapping of index to name for QgsPalLabeling fix.
Definition at line 469 of file qgsvectordataprovider.h.
Definition at line 455 of file qgsvectordataprovider.h.
|
protected |
Definition at line 454 of file qgsvectordataprovider.h.
Definition at line 455 of file qgsvectordataprovider.h.
|
protected |
Encoding.
Definition at line 458 of file qgsvectordataprovider.h.
|
protected |
The names of the providers native types.
Definition at line 464 of file qgsvectordataprovider.h.