QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
16 #include <QRegularExpression>
47 std::unique_ptr<QgsExpression> expression;
57 if ( expression->hasParserError() || !expression->prepare( &context ) )
66 lst.insert( fieldOrExpression );
68 lst = expression->referencedColumns();
71 .
setFlags( ( expression && expression->needsGeometry() ) ?
89 QList<QVariant> values;
93 std::unique_ptr<QgsExpression> expression;
110 QVariant v = expression->evaluate( &context );
129 QList<double> values;
134 QList<QVariant> variantValues =
getValues( layer, fieldOrExpression, ok, selectedOnly, feedback );
139 const auto constVariantValues = variantValues;
140 for (
const QVariant &value : constVariantValues )
142 double val = value.toDouble( &convertOk );
145 else if ( value.isNull() )
166 if ( fieldIndex < 0 || fieldIndex >= fields.
count() )
170 if ( fields.
fieldOrigin( fieldIndex ) == QgsFields::FieldOrigin::OriginJoin )
178 fieldIndex = srcFieldIndex;
179 layer = joinInfo->joinLayer();
187 QString fieldName = fields.
at( fieldIndex ).
name();
195 int limit = ignoreIds.size() + 1;
205 if ( ignoreIds.contains( feat.
id() ) )
221 if ( fieldIndex < 0 || fieldIndex >= fields.
count() )
229 QVariant newVar( maxVal.toLongLong() + 1 );
239 case QVariant::String:
242 if ( seed.isValid() )
243 base = seed.toString();
245 if ( !base.isEmpty() )
248 QRegularExpression rx( QStringLiteral(
"(.*)_\\d+" ) );
249 QRegularExpressionMatch match = rx.match( base );
250 if ( match.hasMatch() )
252 base = match.captured( 1 );
264 base = f.
attribute( fieldIndex ).toString();
271 if ( !base.isEmpty() && !vals.contains( base ) )
274 for (
int i = 1; i < 10000; ++i )
276 QString testVal = base +
'_' + QString::number( i );
277 if ( !vals.contains( testVal ) )
301 if ( fieldIndex < 0 || fieldIndex >= fields.
count() )
308 QVariant maxVal = existingValues.isEmpty() ? 0 : *std::max_element( existingValues.begin(), existingValues.end() );
309 QVariant newVar( maxVal.toLongLong() + 1 );
319 case QVariant::String:
322 if ( seed.isValid() )
323 base = seed.toString();
325 if ( !base.isEmpty() )
328 QRegularExpression rx( QStringLiteral(
"(.*)_\\d+" ) );
329 QRegularExpressionMatch match = rx.match( base );
330 if ( match.hasMatch() )
332 base = match.captured( 1 );
339 base = existingValues.isEmpty() ? QString() : existingValues.values().first().toString();
344 for (
const auto &v : qgis::as_const( existingValues ) )
346 if ( v.toString().startsWith( base ) )
347 vals.push_back( v.toString() );
351 if ( !base.isEmpty() && !vals.contains( base ) )
354 for (
int i = 1; i < 10000; ++i )
356 QString testVal = base +
'_' + QString::number( i );
357 if ( !vals.contains( testVal ) )
381 if ( attributeIndex < 0 || attributeIndex >= layer->
fields().
count() )
386 QVariant value = feature.
attribute( attributeIndex );
401 valid = expr.
evaluate( &context ).toBool();
409 errors << QObject::tr(
"evaluation error: %1" ).arg( expr.
evalErrorString() );
417 bool notNullConstraintViolated {
false };
433 valid = valid && !value.isNull();
435 if ( value.isNull() )
437 errors << QObject::tr(
"value is NULL" );
438 notNullConstraintViolated =
true;
444 if ( ! notNullConstraintViolated )
463 valid = valid && !alreadyExists;
467 errors << QObject::tr(
"value is not unique" );
480 return features.isEmpty() ?
QgsFeature() : features.first();
489 result.reserve( featuresData.length() );
492 std::unique_ptr< QgsExpressionContext > tempContext;
497 evalContext = tempContext.get();
503 QMap<int, QSet<QVariant>> uniqueValueCache;
505 auto checkUniqueValue = [ & ](
const int fieldIdx,
const QVariant & value )
507 if ( ! uniqueValueCache.contains( fieldIdx ) )
512 std::unique_ptr<QgsVectorLayer> unfilteredClone { layer->
clone( ) };
514 uniqueValueCache[ fieldIdx ] = unfilteredClone->uniqueValues( fieldIdx );
518 uniqueValueCache[ fieldIdx ] = layer->
uniqueValues( fieldIdx );
521 return uniqueValueCache[ fieldIdx ].contains( value );
524 for (
const auto &fd : qgis::as_const( featuresData ) )
533 for (
int idx = 0; idx < fields.
count(); ++idx )
536 bool checkUnique =
true;
541 if ( fd.attributes().contains( idx ) )
543 v = fd.attributes().value( idx );
549 if ( ( v.isNull() || ( hasUniqueConstraint
550 && checkUniqueValue( idx, v ) )
552 && defaultValueDefinition.
isValid() )
557 v = layer->
defaultValue( idx, newFeature, evalContext );
562 if ( ( v.isNull() || ( hasUniqueConstraint
563 && checkUniqueValue( idx, v ) ) )
568 if ( !providerDefault.isEmpty() )
577 if ( ( v.isNull() || ( checkUnique
578 && hasUniqueConstraint
579 && checkUniqueValue( idx, v ) ) )
593 if ( v.isNull() && fd.attributes().contains( idx ) )
595 v = fd.attributes().value( idx );
603 if ( checkUnique && hasUniqueConstraint )
605 if ( checkUniqueValue( idx, v ) )
609 if ( uniqueValue.isValid() )
613 if ( hasUniqueConstraint )
615 uniqueValueCache[ idx ].insert( v );
620 result.append( newFeature );
652 while ( relatedFeaturesIt.
nextFeature( childFeature ) )
655 relation.referencingLayer()->startEditing();
657 const auto pairs = relation.fieldPairs();
663 childFeatureIds.insert(
duplicateFeature( relation.referencingLayer(), childFeature, project, depth, duplicateFeatureContext ).
id() );
667 duplicateFeatureContext.setDuplicatedFeatures( relation.referencingLayer(), childFeatureIds );
677 std::unique_ptr<QgsVectorLayerFeatureSource> featureSource;
681 #if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 )
682 Q_ASSERT( QThread::currentThread() == qApp->thread() || feedback );
696 return featureSource;
704 attributes.reserve( fields.
size() );
709 attributes.append( index >= 0 ? feature.
attribute( index ) : QVariant(
field.
type() ) );
717 if ( lengthDiff > 0 )
723 else if ( lengthDiff < 0 )
727 attributes.reserve( fields.
count() );
730 attributes.append( QVariant( fields.
at( i ).
type() ) );
750 for (
int index : pkIndexes )
759 bool newFHasGeom = newFGeomType !=
760 QgsWkbTypes::GeometryType::UnknownGeometry &&
761 newFGeomType != QgsWkbTypes::GeometryType::NullGeometry;
762 bool layerHasGeom = inputWkbType !=
763 QgsWkbTypes::Type::NoGeometry &&
764 inputWkbType != QgsWkbTypes::Type::Unknown;
766 if ( ( newFHasGeom && !layerHasGeom ) || !newFHasGeom )
770 resultFeatures.append( _f );
777 if ( geometries.count() != 1 )
780 for (
int j = 0; j < newF.
fields().count(); j++ )
784 resultFeatures.reserve( geometries.size() );
788 resultFeatures.append( _f );
794 resultFeatures.append( newF );
797 return resultFeatures;
806 for (
const auto &_f : features )
808 resultFeatures.append( _f );
811 return resultFeatures;
816 QList<QgsVectorLayer *>
layers;
817 QMap<QgsVectorLayer *, QgsFeatureIds>::const_iterator i;
818 for ( i = mDuplicatedFeatures.begin(); i != mDuplicatedFeatures.end(); ++i )
825 return mDuplicatedFeatures[layer];
830 mDuplicatedFeatures.insert( layer, ids );
840 mGeometry( geometry ),
841 mAttributes( attributes )
875 if ( !joinedFeature.
isValid() )
904 if ( labelSettingsEntity->settings().format().mask().enabled() )
906 for (
const auto &r : labelSettingsEntity->settings().format().mask().maskedSymbolLayers() )
908 masks[currentRule][r.layerId()].insert( r.symbolLayerId() );
915 QHash<QString, QHash<QString, QSet<QgsSymbolLayerId>>> masks;
923 LabelMasksVisitor visitor;
925 return std::move( visitor.masks );
941 void visitSymbol(
const QgsSymbol *symbol )
946 for (
const auto &mask : sl->
masks() )
948 masks[mask.layerId()].insert( mask.symbolLayerId() );
953 visitSymbol( subSymbol );
962 if ( symbolEntity->symbol() )
963 visitSymbol( symbolEntity->symbol() );
967 QHash<QString, QSet<QgsSymbolLayerId>> masks;
972 return visitor.masks;
982 QString displayString = exp.
evaluate( &context ).toString();
984 return displayString;
999 const auto constFids = fids;
1005 while ( relatedFeaturesIt.
nextFeature( childFeature ) )
1007 childFeatureIds.insert( childFeature.
id() );
1011 if ( childFeatureIds.count() > 0 )
1013 if ( context.
layers().contains( relation.referencingLayer() ) )
1017 handledFeatureIds.unite( childFeatureIds );
1018 context.setDuplicatedFeatures( relation.referencingLayer(), handledFeatureIds );
1023 context.setDuplicatedFeatures( relation.referencingLayer(), childFeatureIds );
1037 if ( info.isEditable() && info.hasCascadedDelete() )
1040 const auto constFids = fids;
1045 joinFeatureIds.insert( joinFeature.
id() );
1048 if ( joinFeatureIds.count() > 0 )
1050 if ( context.
layers().contains( info.joinLayer() ) )
1054 handledFeatureIds.unite( joinFeatureIds );
1055 context.setDuplicatedFeatures( info.joinLayer(), handledFeatureIds );
1060 context.setDuplicatedFeatures( info.joinLayer(), joinFeatureIds );
1067 return context.
layers().count();
@ OriginProvider
Field comes from the underlying data provider of the vector layer (originIndex = index in provider's ...
@ NoGeometry
Geometry is not required. It may still be returned if e.g. required for a filter condition.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QgsRelationManager * relationManager
void appendScopes(const QList< QgsExpressionContextScope * > &scopes)
Appends a list of scopes to the end of the context.
Q_INVOKABLE QgsWkbTypes::Type wkbType() const FINAL
Returns the WKBType or WKBUnknown in case of error.
virtual QgsAttributeList pkAttributeIndexes() const
Returns list of indexes of fields that make up the primary key.
The QgsDefaultValue class provides a container for managing client side default values for fields.
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.
static QgsFeatureList makeFeatureCompatible(const QgsFeature &feature, const QgsVectorLayer *layer, QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags())
Converts input feature to be compatible with the given layer.
QString evalErrorString() const
Returns evaluation error.
void initAttributes(int fieldCount)
Initialize this feature with the given number of fields.
bool isEmpty() const
Checks whether the container is empty.
static QgsFeature duplicateFeature(QgsVectorLayer *layer, const QgsFeature &feature, QgsProject *project, int depth, QgsDuplicateFeatureContext &duplicateFeatureContext)
Duplicates a feature and it's children (one level deep).
A symbol entity for QgsStyle databases.
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
Stores information about constraints which may be present on a field.
QgsAttributeMap attributes() const
Returns attributes.
int count() const
Returns number of items.
Container of fields for a vector layer.
Generic visitor that collects symbol layers of a vector layer's renderer and call a callback function...
QString constraintExpression() const
Returns the constraint expression for the field, if set.
void setValid(bool validity)
Sets the validity of the feature.
const QgsVectorLayerJoinInfo * joinForFieldIndex(int index, const QgsFields &fields, int &sourceFieldIndex) const
Finds the vector join for a layer field index.
@ Composition
Fix relation, related elements are part of the parent and a parent copy will copy any children or del...
An interface for classes which can visit style entity (e.g.
bool isValid() const
Returns if this default value should be applied.
static QgsFeatureIterator getValuesIterator(const QgsVectorLayer *layer, const QString &fieldOrExpression, bool &ok, bool selectedOnly)
Create a feature iterator for a specified field name or expression.
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
QgsFeatureData(const QgsGeometry &geometry=QgsGeometry(), const QgsAttributeMap &attributes=QgsAttributeMap())
Constructs a new QgsFeatureData with given geometry and attributes.
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 (e.g., if the value return...
Type
The WKB type describes the number of dimensions a geometry has.
static QHash< QString, QSet< QgsSymbolLayerId > > symbolLayerMasks(const QgsVectorLayer *)
Returns all masks that may be defined on symbol layers for a given vector layer.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
Encapsulate geometry and attributes for new features, to be passed to createFeatures.
Abstract base class for all rendered symbols.
QgsSymbolLayer * symbolLayer(int layer)
Returns the symbol layer at the specified index.
QList< int > QgsAttributeList
QVector< QgsGeometry > coerceToType(QgsWkbTypes::Type type) const
Attempts to coerce this geometry into the specified destination type.
@ ConstraintNotNull
Field may not be null.
Contains information relating to the style entity currently being visited.
QVariant defaultValue(int index, const QgsFeature &feature=QgsFeature(), QgsExpressionContext *context=nullptr) const
Returns the calculated default value for the specified field index.
virtual QVariant defaultValue(int fieldIndex) const
Returns any literal default values which are present at the provider for a specified field index.
static QHash< QString, QHash< QString, QSet< QgsSymbolLayerId > > > labelMasks(const QgsVectorLayer *)
Returns masks defined in labeling options of a layer.
bool isEditable() const FINAL
Returns true if the provider is in editing mode.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
@ LabelSettingsEntity
Label settings.
QList< QgsVectorLayerJoinInfo > QgsVectorJoinList
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
static QString quotedValue(const QVariant &value)
Returns a string representation of a literal value, including appropriate quotations where required.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
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.
This class wraps a request for features to a vector layer (or directly its vector data provider).
virtual QgsVectorDataProvider::Capabilities capabilities() const
Returns flags containing the supported capabilities.
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
QList< QgsVectorLayer * > layers() const
Returns all the layers on which features have been duplicated.
bool _fieldIsEditable(const QgsVectorLayer *layer, int fieldIndex, const QgsFeature &feature)
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
QList< QgsRelation > referencedRelations(const QgsVectorLayer *layer=nullptr) const
Gets all relations where this layer is the referenced part (i.e.
QList< QgsVectorLayerUtils::QgsFeatureData > QgsFeaturesDataList
Alias for list of QgsFeatureData.
QString parserErrorString() const
Returns parser error.
bool isValid() const
Returns the validity of this feature.
void setFields(const QgsFields &fields, bool initAttributes=false)
Assign a field map with the feature to allow attribute access by attribute name.
ConstraintOrigin
Origin of constraints.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
const QgsAbstractVectorLayerLabeling * labeling() const
Access to const labeling configuration.
bool hasUpsertOnEdit() const
Returns whether a feature created on the target layer has to impact the joined layer by creating a ne...
Contains mainly the QMap with QgsVectorLayer and QgsFeatureIds do list all the duplicated features.
QSet< QVariant > uniqueValues(int fieldIndex, int limit=-1) const FINAL
Calculates a list of unique values contained within an attribute in the layer.
int size() const
Returns number of items.
FieldOrigin fieldOrigin(int fieldIdx) const
Gets field's origin (value from an enumeration)
QList< QgsFeature > QgsFeatureList
QMap< int, QVariant > QgsAttributeMap
bool isEditable() const
Returns whether joined fields may be edited through the form of the target layer.
@ ConstraintUnique
Field must have a unique value.
@ IgnoreAuxiliaryLayers
Ignore auxiliary layers.
const QgsVectorJoinList & vectorJoins() const
virtual QgsStyle::StyleEntity type() const =0
Returns the type of style entity.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QVariant maximumValue(int index) const FINAL
Returns the maximum value for an attribute column or an invalid variant in case of error.
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.
@ ConstraintStrengthNotSet
Constraint is not set.
@ SymbolRule
Rule based symbology or label child rule.
Defines left outer join from our vector layer to some other vector layer.
Contains information relating to a node (i.e.
ConstraintStrength constraintStrength(Constraint constraint) const
Returns the strength of a field constraint, or ConstraintStrengthNotSet if the constraint is not pres...
QString constraintDescription() const
Returns the descriptive name for the constraint expression.
QgsAttributeMap toMap() const
Returns a QgsAttributeMap of the attribute values.
QgsGeometry geometry() const
Returns geometry.
QgsFeatureRequest & setNoAttributes()
Set that no attributes will be fetched.
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
QSet< QgsFeatureId > QgsFeatureIds
static std::unique_ptr< QgsVectorLayerFeatureSource > getFeatureSource(QPointer< QgsVectorLayer > layer, QgsFeedback *feedback=nullptr)
Gets the feature source from a QgsVectorLayer pointer.
@ RegeneratePrimaryKey
This flag indicates, that a primary key field cannot be guaranteed to be unique and the sink should i...
Defines a relation between matching fields of the two involved tables of a relation.
QgsDefaultValue defaultValueDefinition(int index) const
Returns the definition of the expression used when calculating the default value for a field.
A label settings entity for QgsStyle databases.
QVariant evaluate()
Evaluate the feature and return the result.
static QgsFeature createFeature(const QgsVectorLayer *layer, const QgsGeometry &geometry=QgsGeometry(), const QgsAttributeMap &attributes=QgsAttributeMap(), QgsExpressionContext *context=nullptr)
Creates a new feature ready for insertion into a layer.
const QgsStyleEntityInterface * entity
Reference to style entity being visited.
QgsFeatureIterator getSelectedFeatures(QgsFeatureRequest request=QgsFeatureRequest()) const
Returns an iterator of the selected features.
bool isCanceled() const
Tells whether the operation has been canceled already.
bool setAttribute(int field, const QVariant &attr)
Set an attribute's value by field index.
@ ConstraintOriginNotSet
Constraint is not set.
virtual QgsSymbolLayerReferenceList masks() const
Returns masks defined by this symbol layer.
static void matchAttributesToFields(QgsFeature &feature, const QgsFields &fields)
Matches the attributes in feature to the specified fields.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
bool nextFeature(QgsFeature &f)
A geometry is the spatial representation of a feature.
static bool runOnMainThread(const Func &func, QgsFeedback *feedback=nullptr)
Guarantees that func is executed on the main thread.
@ ChangeAttributeValues
Allows modification of attribute values.
Represents a vector layer which manages a vector based data sets.
QgsFeatureRequest & setLimit(long limit)
Set the maximum number of features to request.
QgsEditFormConfig editFormConfig
QgsFeature joinedFeatureOf(const QgsVectorLayerJoinInfo *info, const QgsFeature &feature) const
Returns the joined feature corresponding to the feature.
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 correspo...
Partial snapshot of vector layer's state (only the members necessary for access to features)
static bool fieldIsEditable(const QgsVectorLayer *layer, int fieldIndex, const QgsFeature &feature)
QgsVectorLayer * joinLayer() const
Returns joined layer (may be nullptr if the reference was set by layer ID and not resolved yet)
@ ConstraintExpression
Field has an expression constraint set. See constraintExpression().
static QgsFeatureList makeFeaturesCompatible(const QgsFeatureList &features, const QgsVectorLayer *layer, QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags())
Converts input features to be compatible with the given layer.
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr.
QgsFieldConstraints constraints
static QString quotedColumnRef(QString name)
Returns a quoted column reference (in double quotes)
int fieldOriginIndex(int fieldIdx) const
Gets field's origin index (its meaning is specific to each type of origin)
static GeometryType geometryType(Type type) SIP_HOLDGIL
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
bool containsJoins() const
Quick way to test if there is any join at all.
static bool impactsCascadeFeatures(const QgsVectorLayer *layer, const QgsFeatureIds &fids, const QgsProject *project, QgsDuplicateFeatureContext &context, QgsVectorLayerUtils::CascadedFeatureFlags flags=QgsVectorLayerUtils::CascadedFeatureFlags())
static QgsFeatureList createFeatures(const QgsVectorLayer *layer, const QgsFeaturesDataList &featuresData, QgsExpressionContext *context=nullptr)
Creates a set of new features ready for insertion into a layer.
virtual QString defaultValueClause(int fieldIndex) const
Returns any default value clauses which are present at the provider for a specified field index.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Q_GADGET Constraints constraints
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
QgsFeature getFeature(QgsFeatureId fid) const
Queries the layer for the feature with the given id.
@ ConstraintOriginProvider
Constraint was set at data provider.
ConstraintStrength
Strength of constraints.
QgsFeatureIds duplicatedFeatures(QgsVectorLayer *layer) const
Returns the duplicated features in the given layer.
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
static QVariant createUniqueValueFromCache(const QgsVectorLayer *layer, int fieldIndex, const QSet< QVariant > &existingValues, const QVariant &seed=QVariant())
Returns a new attribute value for the specified field index which is guaranteed to be unique within r...
QgsExpressionContext createExpressionContext() const FINAL
This method needs to be reimplemented in all classes which implement this interface and return an exp...
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1)
Class for parsing and evaluation of expressions (formerly called "search strings").
QString displayExpression
QString identifier
A string identifying the node.
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.
Wrapper for iterator of features from vector data provider or vector layer.
QgsVectorLayer * clone() const override
Returns a new instance equivalent to this one.
bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) FINAL
Adds a single feature to the sink.
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified symbology visitor, causing it to visit all symbols associated with the labeling...
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
bool convertCompatible(QVariant &v, QString *errorMessage=nullptr) const
Converts the provided variant to a compatible format.
QgsStyleEntityVisitorInterface::NodeType type
Node type.
@ OriginJoin
Field comes from a joined layer (originIndex / 1000 = index of the join, originIndex % 1000 = index w...
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
QgsVectorLayerJoinBuffer * joinBuffer()
Returns the join buffer object.
ConstraintOrigin constraintOrigin(Constraint constraint) const
Returns the origin of a field constraint, or ConstraintOriginNotSet if the constraint is not present ...
virtual bool setSubsetString(const QString &subset)
Sets the string (typically sql) used to define a subset of the layer.
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
QgsFeatureRenderer * renderer()
Returns renderer.
static QString getFeatureDisplayString(const QgsVectorLayer *layer, const QgsFeature &feature)
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.
Encapsulate a field in an attribute table or data source.