2017-05-22 09:01:45 +02:00
|
|
|
/************************************************************************
|
|
|
|
* This file has been generated automatically from *
|
|
|
|
* *
|
|
|
|
* src/core/qgsvectorlayerutils.h *
|
|
|
|
* *
|
|
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-25 16:05:34 +10:00
|
|
|
|
|
|
|
class QgsVectorLayerUtils
|
|
|
|
{
|
2017-05-22 09:01:45 +02:00
|
|
|
%Docstring
|
2018-05-26 14:10:30 +10:00
|
|
|
Contains utility methods for working with QgsVectorLayers.
|
2017-05-22 09:01:45 +02:00
|
|
|
|
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
|
|
|
|
2016-10-25 16:05:34 +10:00
|
|
|
%TypeHeaderCode
|
2017-05-22 09:01:45 +02:00
|
|
|
#include "qgsvectorlayerutils.h"
|
2016-10-25 16:05:34 +10:00
|
|
|
%End
|
|
|
|
public:
|
|
|
|
|
2017-10-25 17:04:48 +02:00
|
|
|
class QgsDuplicateFeatureContext
|
|
|
|
{
|
|
|
|
%Docstring
|
2018-05-26 14:10:30 +10:00
|
|
|
Contains mainly the QMap with QgsVectorLayer and QgsFeatureIds do list all the duplicated features
|
2017-10-25 17:04:48 +02:00
|
|
|
|
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
|
|
|
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsvectorlayerutils.h"
|
|
|
|
%End
|
|
|
|
public:
|
|
|
|
|
|
|
|
QgsDuplicateFeatureContext();
|
2017-11-11 15:22:19 +10:00
|
|
|
%Docstring
|
|
|
|
Constructor for QgsDuplicateFeatureContext
|
|
|
|
%End
|
2017-10-25 17:04:48 +02:00
|
|
|
|
|
|
|
QList<QgsVectorLayer *> layers() const;
|
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Returns all the layers on which features have been duplicated
|
|
|
|
|
2017-10-25 17:04:48 +02:00
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
|
|
|
|
|
|
|
QgsFeatureIds duplicatedFeatures( QgsVectorLayer *layer ) const;
|
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Returns the duplicated features in the given layer
|
|
|
|
|
2017-10-25 17:04:48 +02:00
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-02-06 11:38:04 +07:00
|
|
|
static QgsFeatureIterator getValuesIterator( const QgsVectorLayer *layer, const QString &fieldOrExpression, bool &ok, bool selectedOnly );
|
|
|
|
%Docstring
|
|
|
|
Create a feature iterator for a specified field name or expression.
|
|
|
|
|
|
|
|
:param layer: vector layer to retrieve values from
|
|
|
|
:param fieldOrExpression: field name or an expression string
|
|
|
|
:param ok: will be set to false if field or expression is invalid, otherwise true
|
|
|
|
:param selectedOnly: set to true to get values from selected features only
|
|
|
|
|
|
|
|
:return: feature iterator
|
|
|
|
|
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
|
|
|
|
|
|
|
static QList< QVariant > getValues( const QgsVectorLayer *layer, const QString &fieldOrExpression, bool &ok, bool selectedOnly = false, QgsFeedback *feedback = 0 );
|
|
|
|
%Docstring
|
|
|
|
Fetches all values from a specified field name or expression.
|
|
|
|
|
|
|
|
:param layer: vector layer to retrieve values from
|
|
|
|
:param fieldOrExpression: field name or an expression string
|
|
|
|
:param ok: will be set to false if field or expression is invalid, otherwise true
|
|
|
|
:param selectedOnly: set to true to get values from selected features only
|
|
|
|
:param feedback: optional feedback object to allow cancelation
|
|
|
|
|
|
|
|
:return: list of fetched values
|
|
|
|
|
|
|
|
.. seealso:: :py:func:`getDoubleValues`
|
2018-05-28 11:31:08 -04:00
|
|
|
|
|
|
|
.. versionadded:: 3.0
|
2018-02-06 11:38:04 +07:00
|
|
|
%End
|
|
|
|
|
|
|
|
static QList< double > getDoubleValues( const QgsVectorLayer *layer, const QString &fieldOrExpression, bool &ok, bool selectedOnly = false, int *nullCount = 0, QgsFeedback *feedback = 0 );
|
|
|
|
%Docstring
|
|
|
|
Fetches all double values from a specified field name or expression. Null values or
|
|
|
|
invalid expression results are skipped.
|
|
|
|
|
|
|
|
:param layer: vector layer to retrieve values from
|
|
|
|
:param fieldOrExpression: field name or an expression string evaluating to a double value
|
|
|
|
:param ok: will be set to false if field or expression is invalid, otherwise true
|
|
|
|
:param selectedOnly: set to true to get values from selected features only
|
|
|
|
:param nullCount: optional pointer to integer to store number of null values encountered in
|
|
|
|
:param feedback: optional feedback object to allow cancelation
|
|
|
|
|
|
|
|
:return: list of fetched values
|
|
|
|
|
|
|
|
.. seealso:: :py:func:`getValues`
|
2018-05-28 11:31:08 -04:00
|
|
|
|
|
|
|
.. versionadded:: 3.0
|
2018-02-06 11:38:04 +07:00
|
|
|
%End
|
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
static bool valueExists( const QgsVectorLayer *layer, int fieldIndex, const QVariant &value, const QgsFeatureIds &ignoreIds = QgsFeatureIds() );
|
2017-05-22 09:01:45 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
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.
|
|
|
|
|
2018-01-09 17:26:37 -04:00
|
|
|
.. seealso:: :py:func:`createUniqueValue`
|
2017-05-22 09:01:45 +02:00
|
|
|
%End
|
2016-10-25 16:05:34 +10:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
static QVariant createUniqueValue( const QgsVectorLayer *layer, int fieldIndex, const QVariant &seed = QVariant() );
|
2017-05-22 09:01:45 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
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.
|
|
|
|
|
2018-01-09 17:26:37 -04:00
|
|
|
.. seealso:: :py:func:`valueExists`
|
2017-05-22 09:01:45 +02:00
|
|
|
%End
|
2016-11-08 15:44:25 +10:00
|
|
|
|
2017-05-22 09:01:45 +02:00
|
|
|
static bool validateAttribute( const QgsVectorLayer *layer, const QgsFeature &feature, int attributeIndex, QStringList &errors /Out/,
|
2016-11-02 13:39:07 +10:00
|
|
|
QgsFieldConstraints::ConstraintStrength strength = QgsFieldConstraints::ConstraintStrengthNotSet,
|
2016-11-01 18:41:22 +10:00
|
|
|
QgsFieldConstraints::ConstraintOrigin origin = QgsFieldConstraints::ConstraintOriginNotSet );
|
2017-05-22 09:01:45 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
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.
|
2017-05-22 09:01:45 +02:00
|
|
|
%End
|
2016-10-26 10:35:07 +10:00
|
|
|
|
2017-05-22 09:01:45 +02:00
|
|
|
static QgsFeature createFeature( QgsVectorLayer *layer,
|
|
|
|
const QgsGeometry &geometry = QgsGeometry(),
|
|
|
|
const QgsAttributeMap &attributes = QgsAttributeMap(),
|
2017-05-02 07:21:20 +02:00
|
|
|
QgsExpressionContext *context = 0 );
|
2017-05-22 09:01:45 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
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.
|
2017-05-22 09:01:45 +02:00
|
|
|
%End
|
2016-11-08 16:59:07 +10:00
|
|
|
|
2017-10-25 17:04:48 +02:00
|
|
|
static QgsFeature duplicateFeature( QgsVectorLayer *layer, const QgsFeature &feature, QgsProject *project, int depth, QgsDuplicateFeatureContext &duplicateFeatureContext /Out/ );
|
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
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)
|
|
|
|
|
2017-10-25 17:04:48 +02:00
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
|
|
|
|
2016-10-25 16:05:34 +10:00
|
|
|
};
|
2017-05-22 09:01:45 +02:00
|
|
|
|
2017-10-25 17:04:48 +02:00
|
|
|
|
2017-05-22 09:01:45 +02:00
|
|
|
/************************************************************************
|
|
|
|
* This file has been generated automatically from *
|
|
|
|
* *
|
|
|
|
* src/core/qgsvectorlayerutils.h *
|
|
|
|
* *
|
|
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
|
|
************************************************************************/
|