16 #include <QRegularExpression>
48 std::unique_ptr<QgsExpression> expression;
58 if ( expression->hasParserError() || !expression->prepare( &context ) )
67 lst.insert( fieldOrExpression );
69 lst = expression->referencedColumns();
72 .
setFlags( ( expression && expression->needsGeometry() ) ?
90 QList<QVariant> values;
94 std::unique_ptr<QgsExpression> expression;
111 QVariant v = expression->evaluate( &context );
130 QList<double> values;
135 QList<QVariant> variantValues =
getValues( layer, fieldOrExpression, ok, selectedOnly, feedback );
140 const auto constVariantValues = variantValues;
141 for (
const QVariant &value : constVariantValues )
143 double val = value.toDouble( &convertOk );
146 else if ( value.isNull() )
167 if ( fieldIndex < 0 || fieldIndex >= fields.
count() )
171 if ( fields.
fieldOrigin( fieldIndex ) == QgsFields::FieldOrigin::OriginJoin )
179 fieldIndex = srcFieldIndex;
180 layer = joinInfo->joinLayer();
188 QString fieldName = fields.
at( fieldIndex ).
name();
196 int limit = ignoreIds.size() + 1;
206 if ( ignoreIds.contains( feat.
id() ) )
222 if ( fieldIndex < 0 || fieldIndex >= fields.
count() )
230 QVariant newVar( maxVal.toLongLong() + 1 );
240 case QVariant::String:
243 if ( seed.isValid() )
244 base = seed.toString();
246 if ( !base.isEmpty() )
249 QRegularExpression rx( QStringLiteral(
"(.*)_\\d+" ) );
250 QRegularExpressionMatch match = rx.match( base );
251 if ( match.hasMatch() )
253 base = match.captured( 1 );
265 base = f.
attribute( fieldIndex ).toString();
272 if ( !base.isEmpty() && !vals.contains( base ) )
275 for (
int i = 1; i < 10000; ++i )
277 QString testVal = base +
'_' + QString::number( i );
278 if ( !vals.contains( testVal ) )
302 if ( fieldIndex < 0 || fieldIndex >= fields.
count() )
309 QVariant maxVal = existingValues.isEmpty() ? 0 : *std::max_element( existingValues.begin(), existingValues.end(), [](
const QVariant & a,
const QVariant & b ) { return a.toLongLong() < b.toLongLong(); } );
310 QVariant newVar( maxVal.toLongLong() + 1 );
320 case QVariant::String:
323 if ( seed.isValid() )
324 base = seed.toString();
326 if ( !base.isEmpty() )
329 QRegularExpression rx( QStringLiteral(
"(.*)_\\d+" ) );
330 QRegularExpressionMatch match = rx.match( base );
331 if ( match.hasMatch() )
333 base = match.captured( 1 );
340 base = existingValues.isEmpty() ? QString() : existingValues.values().first().toString();
345 for (
const auto &v : std::as_const( existingValues ) )
347 if ( v.toString().startsWith( base ) )
348 vals.push_back( v.toString() );
352 if ( !base.isEmpty() && !vals.contains( base ) )
355 for (
int i = 1; i < 10000; ++i )
357 QString testVal = base +
'_' + QString::number( i );
358 if ( !vals.contains( testVal ) )
382 if ( attributeIndex < 0 || attributeIndex >= layer->
fields().
count() )
387 QVariant value = feature.
attribute( attributeIndex );
402 valid = expr.
evaluate( &context ).toBool();
410 errors << QObject::tr(
"evaluation error: %1" ).arg( expr.
evalErrorString() );
418 bool notNullConstraintViolated {
false };
434 valid = valid && !value.isNull();
436 if ( value.isNull() )
438 errors << QObject::tr(
"value is NULL" );
439 notNullConstraintViolated =
true;
445 if ( ! notNullConstraintViolated )
464 valid = valid && !alreadyExists;
468 errors << QObject::tr(
"value is not unique" );
481 return features.isEmpty() ?
QgsFeature() : features.first();
490 result.reserve( featuresData.length() );
493 std::unique_ptr< QgsExpressionContext > tempContext;
498 evalContext = tempContext.get();
504 QMap<int, QSet<QVariant>> uniqueValueCache;
506 auto checkUniqueValue = [ & ](
const int fieldIdx,
const QVariant & value )
508 if ( ! uniqueValueCache.contains( fieldIdx ) )
513 std::unique_ptr<QgsVectorLayer> unfilteredClone { layer->
clone( ) };
515 uniqueValueCache[ fieldIdx ] = unfilteredClone->uniqueValues( fieldIdx );
519 uniqueValueCache[ fieldIdx ] = layer->
uniqueValues( fieldIdx );
522 return uniqueValueCache[ fieldIdx ].contains( value );
525 for (
const auto &fd : std::as_const( featuresData ) )
534 for (
int idx = 0; idx < fields.
count(); ++idx )
537 bool checkUnique =
true;
542 if ( fd.attributes().contains( idx ) )
544 v = fd.attributes().value( idx );
550 if ( ( v.isNull() || ( hasUniqueConstraint
551 && checkUniqueValue( idx, v ) )
553 && defaultValueDefinition.
isValid() )
558 v = layer->
defaultValue( idx, newFeature, evalContext );
563 if ( ( v.isNull() || ( hasUniqueConstraint
564 && checkUniqueValue( idx, v ) ) )
569 if ( !providerDefault.isEmpty() )
578 if ( ( v.isNull() || ( checkUnique
579 && hasUniqueConstraint
580 && checkUniqueValue( idx, v ) ) )
594 if ( v.isNull() && fd.attributes().contains( idx ) )
596 v = fd.attributes().value( idx );
604 if ( checkUnique && hasUniqueConstraint )
606 if ( checkUniqueValue( idx, v ) )
610 if ( uniqueValue.isValid() )
614 if ( hasUniqueConstraint )
616 uniqueValueCache[ idx ].insert( v );
621 result.append( newFeature );
643 const int effectiveMaxDepth = maxDepth > 0 ? maxDepth : 100;
648 if ( relation.strength() ==
QgsRelation::Composition && !referencedLayersBranch.contains( relation.referencedLayer() ) && depth < effectiveMaxDepth )
651 referencedLayersBranch << layer;
657 while ( relatedFeaturesIt.
nextFeature( childFeature ) )
660 relation.referencingLayer()->startEditing();
662 const auto pairs = relation.fieldPairs();
668 childFeatureIds.insert(
duplicateFeature( relation.referencingLayer(), childFeature, project, duplicateFeatureContext, maxDepth, depth, referencedLayersBranch ).
id() );
672 duplicateFeatureContext.setDuplicatedFeatures( relation.referencingLayer(), childFeatureIds );
682 std::unique_ptr<QgsVectorLayerFeatureSource> featureSource;
686 Q_ASSERT( QThread::currentThread() == qApp->thread() || feedback );
697 return featureSource;
705 attributes.reserve( fields.
size() );
710 attributes.append( index >= 0 ? feature.
attribute( index ) : QVariant(
field.
type() ) );
718 if ( lengthDiff > 0 )
724 else if ( lengthDiff < 0 )
728 attributes.reserve( fields.
count() );
731 attributes.append( QVariant( fields.
at( i ).
type() ) );
751 for (
int index : pkIndexes )
760 bool newFHasGeom = newFGeomType !=
761 QgsWkbTypes::GeometryType::UnknownGeometry &&
762 newFGeomType != QgsWkbTypes::GeometryType::NullGeometry;
763 bool layerHasGeom = inputWkbType !=
764 QgsWkbTypes::Type::NoGeometry &&
765 inputWkbType != QgsWkbTypes::Type::Unknown;
767 if ( ( newFHasGeom && !layerHasGeom ) || !newFHasGeom )
771 resultFeatures.append( _f );
778 if ( geometries.count() != 1 )
781 for (
int j = 0; j < newF.
fields().count(); j++ )
785 resultFeatures.reserve( geometries.size() );
789 resultFeatures.append( _f );
795 resultFeatures.append( newF );
798 return resultFeatures;
807 for (
const auto &_f : features )
809 resultFeatures.append( _f );
812 return resultFeatures;
817 QList<QgsVectorLayer *>
layers;
818 QMap<QgsVectorLayer *, QgsFeatureIds>::const_iterator i;
819 for ( i = mDuplicatedFeatures.begin(); i != mDuplicatedFeatures.end(); ++i )
826 return mDuplicatedFeatures[layer];
831 if ( mDuplicatedFeatures.contains( layer ) )
832 mDuplicatedFeatures[layer] += ids;
834 mDuplicatedFeatures.insert( layer, ids );
844 mGeometry( geometry ),
845 mAttributes( attributes )
932 if ( !joinedFeature.
isValid() )
962 if ( labelSettingsEntity->settings().format().mask().enabled() )
964 for (
const auto &r : labelSettingsEntity->settings().format().mask().maskedSymbolLayers() )
966 masks[currentRule][r.layerId()].insert( r.symbolLayerId() );
973 QHash<QString, QHash<QString, QSet<QgsSymbolLayerId>>> masks;
981 LabelMasksVisitor visitor;
983 return std::move( visitor.masks );
999 void visitSymbol(
const QgsSymbol *symbol )
1004 for (
const auto &mask : sl->
masks() )
1006 masks[mask.layerId()].insert( mask.symbolLayerId() );
1011 visitSymbol( subSymbol );
1020 if ( symbolEntity->symbol() )
1021 visitSymbol( symbolEntity->symbol() );
1025 QHash<QString, QSet<QgsSymbolLayerId>> masks;
1028 SymbolLayerVisitor visitor;
1030 return visitor.masks;
1040 QString displayString = exp.
evaluate( &context ).toString();
1042 return displayString;
1057 const auto constFids = fids;
1063 while ( relatedFeaturesIt.
nextFeature( childFeature ) )
1065 childFeatureIds.insert( childFeature.
id() );
1069 if ( childFeatureIds.count() > 0 )
1071 if ( context.
layers().contains( relation.referencingLayer() ) )
1075 handledFeatureIds.unite( childFeatureIds );
1076 context.setDuplicatedFeatures( relation.referencingLayer(), handledFeatureIds );
1081 context.setDuplicatedFeatures( relation.referencingLayer(), childFeatureIds );
1095 if ( info.isEditable() && info.hasCascadedDelete() )
1098 const auto constFids = fids;
1103 joinFeatureIds.insert( joinFeature.
id() );
1106 if ( joinFeatureIds.count() > 0 )
1108 if ( context.
layers().contains( info.joinLayer() ) )
1112 handledFeatureIds.unite( joinFeatureIds );
1113 context.setDuplicatedFeatures( info.joinLayer(), handledFeatureIds );
1118 context.setDuplicatedFeatures( info.joinLayer(), joinFeatureIds );
1125 return !context.
layers().isEmpty();
1140 static QStringList sCandidates{ QStringLiteral(
"name" ),
1141 QStringLiteral(
"title" ),
1142 QStringLiteral(
"heibt" ),
1143 QStringLiteral(
"desc" ),
1144 QStringLiteral(
"nom" ),
1145 QStringLiteral(
"street" ),
1146 QStringLiteral(
"road" ) };
1153 static QStringList sAntiCandidates{ QStringLiteral(
"type" ),
1154 QStringLiteral(
"class" ),
1155 QStringLiteral(
"cat" )
1158 QString bestCandidateName;
1159 QString bestCandidateNameWithAntiCandidate;
1161 for (
const QString &candidate : sCandidates )
1166 if ( fldName.contains( candidate, Qt::CaseInsensitive ) )
1168 bool isAntiCandidate =
false;
1169 for (
const QString &antiCandidate : sAntiCandidates )
1171 if ( fldName.contains( antiCandidate, Qt::CaseInsensitive ) )
1173 isAntiCandidate =
true;
1178 if ( isAntiCandidate )
1180 if ( bestCandidateNameWithAntiCandidate.isEmpty() )
1182 bestCandidateNameWithAntiCandidate = fldName;
1187 bestCandidateName = fldName;
1193 if ( !bestCandidateName.isEmpty() )
1197 const QString candidateName = bestCandidateName.isEmpty() ? bestCandidateNameWithAntiCandidate : bestCandidateName;
1198 if ( !candidateName.isEmpty() )
1200 return candidateName;
1212 return fields.at( 0 ).name();
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified symbology visitor, causing it to visit all symbols associated with the labeling...
CORE_EXPORT QgsAttributeMap toMap() const
Returns a QgsAttributeMap of the attribute values.
The QgsDefaultValue class provides a container for managing client side default values for fields.
bool isValid() const
Returns if this default value should be applied.
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
void appendScopes(const QList< QgsExpressionContextScope * > &scopes)
Appends a list of scopes to the end of the context.
Class for parsing and evaluation of expressions (formerly called "search strings").
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
static QString quotedValue(const QVariant &value)
Returns a string representation of a literal value, including appropriate quotations where required.
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
QString evalErrorString() const
Returns evaluation error.
QString parserErrorString() const
Returns parser error.
static QString quotedColumnRef(QString name)
Returns a quoted column reference (in double quotes)
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
QVariant evaluate()
Evaluate the feature and return the result.
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
This class wraps a request for features to a vector layer (or directly its vector data provider).
QgsFeatureRequest & setLimit(long long limit)
Set the maximum number of features to request.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
@ NoGeometry
Geometry is not required. It may still be returned if e.g. required for a filter condition.
QgsFeatureRequest & setNoAttributes()
Set that no attributes will be fetched.
@ RegeneratePrimaryKey
This flag indicates, that a primary key field cannot be guaranteed to be unique and the sink should i...
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
bool setAttribute(int field, const QVariant &attr)
Sets an attribute's value by field index.
void initAttributes(int fieldCount)
Initialize this feature with the given number of fields.
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
void setFields(const QgsFields &fields, bool initAttributes=false)
Assigns a field map with the feature to allow attribute access by attribute name.
void setValid(bool validity)
Sets the validity of the feature.
bool isValid() const
Returns the validity of this feature.
QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
bool isCanceled() const SIP_HOLDGIL
Tells whether the operation has been canceled already.
Stores information about constraints which may be present on a field.
ConstraintStrength
Strength of constraints.
@ ConstraintStrengthNotSet
Constraint is not set.
ConstraintOrigin
Origin of constraints.
@ ConstraintOriginNotSet
Constraint is not set.
@ ConstraintOriginProvider
Constraint was set at data provider.
ConstraintStrength constraintStrength(Constraint constraint) const
Returns the strength of a field constraint, or ConstraintStrengthNotSet if the constraint is not pres...
ConstraintOrigin constraintOrigin(Constraint constraint) const
Returns the origin of a field constraint, or ConstraintOriginNotSet if the constraint is not present ...
QString constraintExpression() const
Returns the constraint expression for the field, if set.
@ ConstraintNotNull
Field may not be null.
@ ConstraintUnique
Field must have a unique value.
@ ConstraintExpression
Field has an expression constraint set. See constraintExpression().
QString constraintDescription() const
Returns the descriptive name for the constraint expression.
Q_GADGET Constraints constraints
Encapsulate a field in an attribute table or data source.
bool convertCompatible(QVariant &v, QString *errorMessage=nullptr) const
Converts the provided variant to a compatible format.
QgsFieldConstraints constraints
Container of fields for a vector layer.
@ OriginJoin
Field comes from a joined layer (originIndex / 1000 = index of the join, originIndex % 1000 = index w...
@ OriginProvider
Field comes from the underlying data provider of the vector layer (originIndex = index in provider's ...
int count() const
Returns number of items.
FieldOrigin fieldOrigin(int fieldIdx) const
Returns the field's origin (value from an enumeration).
bool isEmpty() const
Checks whether the container is empty.
int size() const
Returns number of items.
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
int fieldOriginIndex(int fieldIdx) const
Returns the field's origin index (its meaning is specific to each type of origin).
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
A geometry is the spatial representation of a feature.
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
QVector< QgsGeometry > coerceToType(QgsWkbTypes::Type type) const
Attempts to coerce this geometry into the specified destination type.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
QgsRelationManager * relationManager
QList< QgsRelation > referencedRelations(const QgsVectorLayer *layer=nullptr) const
Gets all relations where this layer is the referenced part (i.e.
Defines a relation between matching fields of the two involved tables of a relation.
@ Composition
Fix relation, related elements are part of the parent and a parent copy will copy any children or del...
virtual QgsStyle::StyleEntity type() const =0
Returns the type of style entity.
An interface for classes which can visit style entity (e.g.
@ SymbolRule
Rule based symbology or label child rule.
A label settings entity for QgsStyle databases.
A symbol entity for QgsStyle databases.
@ LabelSettingsEntity
Label settings.
virtual QList< QgsSymbolLayerReference > masks() const
Returns masks defined by this symbol layer.
Abstract base class for all rendered symbols.
QgsSymbolLayer * symbolLayer(int layer)
Returns the symbol layer at the specified index.
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
static bool runOnMainThread(const Func &func, QgsFeedback *feedback=nullptr)
Guarantees that func is executed on the main thread.
@ ChangeAttributeValues
Allows modification of attribute values.
@ AddFeatures
Allows adding features.
virtual QgsAttributeList pkAttributeIndexes() const
Returns list of indexes of fields that make up the primary key.
virtual QString defaultValueClause(int fieldIndex) const
Returns any default value clauses which are present at the provider for a 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.
virtual Q_INVOKABLE QgsVectorDataProvider::Capabilities capabilities() const
Returns flags containing the supported capabilities.
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...
Partial snapshot of vector layer's state (only the members necessary for access to features)
const QgsVectorJoinList & vectorJoins() const
const QgsVectorLayerJoinInfo * joinForFieldIndex(int index, const QgsFields &fields, int &sourceFieldIndex) const
Finds the vector join for a layer field index.
bool containsJoins() const
Quick way to test if there is any join at all.
QgsFeature joinedFeatureOf(const QgsVectorLayerJoinInfo *info, const QgsFeature &feature) const
Returns the joined feature corresponding to the feature.
Defines left outer join from our vector layer to some other vector layer.
bool hasUpsertOnEdit() const
Returns whether a feature created on the target layer has to impact the joined layer by creating a ne...
bool isEditable() const
Returns whether joined fields may be edited through the form of the target layer.
QgsVectorLayer * joinLayer() const
Returns joined layer (may be nullptr if the reference was set by layer ID and not resolved yet)
Contains mainly the QMap with QgsVectorLayer and QgsFeatureIds do list all the duplicated features.
QgsFeatureIds duplicatedFeatures(QgsVectorLayer *layer) const
Returns the duplicated features in the given layer.
QList< QgsVectorLayer * > layers() const
Returns all the layers on which features have been duplicated.
Encapsulate geometry and attributes for new features, to be passed to createFeatures.
QgsGeometry geometry() const
Returns geometry.
QgsAttributeMap attributes() const
Returns attributes.
QgsFeatureData(const QgsGeometry &geometry=QgsGeometry(), const QgsAttributeMap &attributes=QgsAttributeMap())
Constructs a new QgsFeatureData with given geometry and attributes.
static QString guessFriendlyIdentifierField(const QgsFields &fields)
Given a set of fields, attempts to pick the "most useful" field for user-friendly identification of f...
static QgsFeature duplicateFeature(QgsVectorLayer *layer, const QgsFeature &feature, QgsProject *project, QgsDuplicateFeatureContext &duplicateFeatureContext, const int maxDepth=0, int depth=0, QList< QgsVectorLayer * > referencedLayersBranch=QList< QgsVectorLayer * >())
Duplicates a feature and it's children (one level deep).
QList< QgsVectorLayerUtils::QgsFeatureData > QgsFeaturesDataList
Alias for list of QgsFeatureData.
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.
static QgsFeatureList makeFeatureCompatible(const QgsFeature &feature, const QgsVectorLayer *layer, QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags())
Converts input feature to be compatible with the given layer.
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 bool fieldEditabilityDependsOnFeature(const QgsVectorLayer *layer, int fieldIndex)
Returns true if the editability of the field at index fieldIndex from layer may vary feature by featu...
static QgsFeatureList makeFeaturesCompatible(const QgsFeatureList &features, const QgsVectorLayer *layer, QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags())
Converts input features to be compatible with the given layer.
static std::unique_ptr< QgsVectorLayerFeatureSource > getFeatureSource(QPointer< QgsVectorLayer > layer, QgsFeedback *feedback=nullptr)
Gets the feature source from a QgsVectorLayer pointer.
static QString getFeatureDisplayString(const QgsVectorLayer *layer, const QgsFeature &feature)
static QHash< QString, QHash< QString, QSet< QgsSymbolLayerId > > > labelMasks(const QgsVectorLayer *)
Returns masks defined in labeling options of a layer.
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.
static bool fieldIsEditable(const QgsVectorLayer *layer, int fieldIndex, const QgsFeature &feature)
Tests whether a field is editable for a particular feature.
static QHash< QString, QSet< QgsSymbolLayerId > > symbolLayerMasks(const QgsVectorLayer *)
Returns all masks that may be defined on symbol layers for a given vector layer.
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.
static bool fieldIsReadOnly(const QgsVectorLayer *layer, int fieldIndex)
static QgsFeatureList createFeatures(const QgsVectorLayer *layer, const QgsFeaturesDataList &featuresData, QgsExpressionContext *context=nullptr)
Creates a set of new features ready for insertion into a layer.
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.
static bool impactsCascadeFeatures(const QgsVectorLayer *layer, const QgsFeatureIds &fids, const QgsProject *project, QgsDuplicateFeatureContext &context, QgsVectorLayerUtils::CascadedFeatureFlags flags=QgsVectorLayerUtils::CascadedFeatureFlags())
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.
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...
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...
static void matchAttributesToFields(QgsFeature &feature, const QgsFields &fields)
Matches the attributes in feature to the specified fields.
@ IgnoreAuxiliaryLayers
Ignore auxiliary layers.
Represents a vector layer which manages a vector based data sets.
Q_INVOKABLE QgsWkbTypes::Type wkbType() const FINAL
Returns the WKBType or WKBUnknown in case of error.
QVariant maximumValue(int index) const FINAL
Returns the maximum value for an attribute column or an invalid variant in case of error.
QgsDefaultValue defaultValueDefinition(int index) const
Returns the definition of the expression used when calculating the default value for a field.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
QgsExpressionContext createExpressionContext() const FINAL
This method needs to be reimplemented in all classes which implement this interface and return an exp...
QgsVectorLayerJoinBuffer * joinBuffer()
Returns the join buffer object.
bool isEditable() const FINAL
Returns true if the provider is in editing mode.
QString displayExpression
QgsFeatureIterator getSelectedFeatures(QgsFeatureRequest request=QgsFeatureRequest()) const
Returns an iterator of the selected features.
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr.
QgsVectorLayer * clone() const override
Returns a new instance equivalent to this one.
QgsFeature getFeature(QgsFeatureId fid) const
Queries the layer for the feature with the given id.
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.
bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) FINAL
Adds a single feature to the sink.
virtual bool setSubsetString(const QString &subset)
Sets the string (typically sql) used to define a subset of the layer.
QVariant defaultValue(int index, const QgsFeature &feature=QgsFeature(), QgsExpressionContext *context=nullptr) const
Returns the calculated default value for the specified field index.
const QgsAbstractVectorLayerLabeling * labeling() const
Access to const labeling configuration.
QgsEditFormConfig editFormConfig
QSet< QVariant > uniqueValues(int fieldIndex, int limit=-1) const FINAL
Calculates a list of unique values contained within an attribute in the layer.
QgsFeatureRenderer * renderer()
Returns the feature renderer used for rendering the features in the layer in 2D map views.
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...
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Type
The WKB type describes the number of dimensions a geometry has.
QMap< int, QVariant > QgsAttributeMap
QList< QgsFeature > QgsFeatureList
QSet< QgsFeatureId > QgsFeatureIds
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
QList< int > QgsAttributeList
QList< QgsVectorLayerJoinInfo > QgsVectorJoinList
bool _fieldIsEditable(const QgsVectorLayer *layer, int fieldIndex, const QgsFeature &feature)
Contains information relating to a node (i.e.
QString identifier
A string identifying the node.
QgsStyleEntityVisitorInterface::NodeType type
Node type.
Contains information relating to the style entity currently being visited.
const QgsStyleEntityInterface * entity
Reference to style entity being visited.