QGIS API Documentation
3.2.0-Bonn (bc43194)
|
Contains utility methods for working with QgsVectorLayers. More...
#include <qgsvectorlayerutils.h>
Classes | |
class | QgsDuplicateFeatureContext |
Contains mainly the QMap with QgsVectorLayer and QgsFeatureIds do list all the duplicated features. More... | |
Static Public Member Functions | |
static QgsFeature | createFeature (QgsVectorLayer *layer, const QgsGeometry &geometry=QgsGeometry(), const QgsAttributeMap &attributes=QgsAttributeMap(), QgsExpressionContext *context=nullptr) |
Creates a new feature ready for insertion into a layer. More... | |
static QVariant | createUniqueValue (const QgsVectorLayer *layer, int fieldIndex, const QVariant &seed=QVariant()) |
Returns a new attribute value for the specified field index which is guaranteed to be unique. More... | |
static QgsFeature | duplicateFeature (QgsVectorLayer *layer, const QgsFeature &feature, QgsProject *project, int depth, QgsDuplicateFeatureContext &duplicateFeatureContext) |
Duplicates a feature and it's children (one level deep). More... | |
static QList< double > | getDoubleValues (const QgsVectorLayer *layer, const QString &fieldOrExpression, bool &ok, bool selectedOnly=false, int *nullCount=nullptr, QgsFeedback *feedback=nullptr) |
Fetches all double values from a specified field name or expression. More... | |
static QList< QVariant > | getValues (const QgsVectorLayer *layer, const QString &fieldOrExpression, bool &ok, bool selectedOnly=false, QgsFeedback *feedback=nullptr) |
Fetches all values from a specified field name or expression. More... | |
static QgsFeatureIterator | getValuesIterator (const QgsVectorLayer *layer, const QString &fieldOrExpression, bool &ok, bool selectedOnly) |
Create a feature iterator for a specified field name or expression. More... | |
static bool | validateAttribute (const QgsVectorLayer *layer, const QgsFeature &feature, int attributeIndex, QStringList &errors, QgsFieldConstraints::ConstraintStrength strength=QgsFieldConstraints::ConstraintStrengthNotSet, QgsFieldConstraints::ConstraintOrigin origin=QgsFieldConstraints::ConstraintOriginNotSet) |
Tests an attribute value to check whether it passes all constraints which are present on the corresponding field. More... | |
static bool | valueExists (const QgsVectorLayer *layer, int fieldIndex, const QVariant &value, const QgsFeatureIds &ignoreIds=QgsFeatureIds()) |
Returns true if the specified value already exists within a field. More... | |
Contains utility methods for working with QgsVectorLayers.
Definition at line 31 of file qgsvectorlayerutils.h.
|
static |
Creates a new feature ready for insertion into a layer.
Default values and constraints (e.g., unique constraints) will automatically be handled. An optional attribute map can be passed for the new feature to copy as many attribute values as possible from the map, assuming that they respect the layer's constraints. Note that the created feature is not automatically inserted into the layer.
Definition at line 349 of file qgsvectorlayerutils.cpp.
|
static |
Returns a new attribute value for the specified field index which is guaranteed to be unique.
The optional seed value can be used as a basis for generated values.
Definition at line 177 of file qgsvectorlayerutils.cpp.
|
static |
Duplicates a feature and it's children (one level deep).
It calls CreateFeature, so default values and constraints (e.g., unique constraints) will automatically be handled. The duplicated feature will be automatically inserted into the layer. depth the higher this number the deeper the level - With depth > 0 the children of the feature are not duplicated duplicateFeatureContext stores all the layers and the featureids of the duplicated features (incl. children)
Definition at line 443 of file qgsvectorlayerutils.cpp.
|
static |
Fetches all double values from a specified field name or expression.
Null values or invalid expression results are skipped.
layer | vector layer to retrieve values from |
fieldOrExpression | field name or an expression string evaluating to a double value |
ok | will be set to false if field or expression is invalid, otherwise true |
selectedOnly | set to true to get values from selected features only |
nullCount | optional pointer to integer to store number of null values encountered in |
feedback | optional feedback object to allow cancelation |
Definition at line 109 of file qgsvectorlayerutils.cpp.
|
static |
Fetches all values from a specified field name or expression.
layer | vector layer to retrieve values from |
fieldOrExpression | field name or an expression string |
ok | will be set to false if field or expression is invalid, otherwise true |
selectedOnly | set to true to get values from selected features only |
feedback | optional feedback object to allow cancelation |
Definition at line 69 of file qgsvectorlayerutils.cpp.
|
static |
Create a feature iterator for a specified field name or expression.
layer | vector layer to retrieve values from |
fieldOrExpression | field name or an expression string |
ok | will be set to false if field or expression is invalid, otherwise true |
selectedOnly | set to true to get values from selected features only |
Definition at line 27 of file qgsvectorlayerutils.cpp.
|
static |
Tests an attribute value to check whether it passes all constraints which are present on the corresponding field.
Returns true if the attribute value is valid for the field. Any constraint failures will be reported in the errors argument. If the strength or origin parameter is set then only constraints with a matching strength/origin will be checked.
Definition at line 257 of file qgsvectorlayerutils.cpp.
|
static |
Returns true if the specified value already exists within a field.
This method can be used to test for uniqueness of values inside a layer's attributes. An optional list of ignored feature IDs can be provided, if so, any features with IDs within this list are ignored when testing for existence of the value.
Definition at line 140 of file qgsvectorlayerutils.cpp.