23 , mSelectedOnly( selectedOnly )
41 featureIds.insert( feature.
id() );
45 featureIds.remove( feature.
id() );
55 features.append( feature );
59 auto addFeatureSynchronized = [
this, &features, &res ]()
71 feature.
setId( features.front().id() );
80 selectedFeatureIds.insert( feature.
id() );
97 auto addFeatureSynchronized = [
this, &features, &res ]()
117 for (
const QgsFeature &feature : qgis::as_const( features ) )
118 selectedFeatureIds.insert( feature.id() );
124 for (
const QgsFeature &feature : qgis::as_const( features ) )
136 geometryMap.insert( feature.
id(), feature.
geometry() );
139 for (
int i = 0, n = feature.
attributes().size(); i < n; ++i )
141 attribMap.insert( i, feature.
attributes().at( i ) );
143 changedAttributesMap.insert( feature.
id(), attribMap );
Wrapper for iterator of features from vector data provider or vector layer.
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
QSet< QgsFeatureId > QgsFeatureIds
bool getFeature(QgsFeatureId id, QgsFeature &feature, QgsFeedback *feedback=nullptr)
Retrieves the feature with the specified id into feature.
bool addFeatures(QgsFeatureList &flist, QgsFeatureSink::Flags flags=nullptr) override
Adds a list of features to the sink.
QList< QgsFeature > QgsFeatureList
virtual bool deleteFeatures(const QgsFeatureIds &id)
Deletes one or more features from the provider.
void selectByIds(const QgsFeatureIds &ids, SelectBehavior behavior=SetSelection)
Select matching features using a list of feature IDs.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
bool hasGeometry() const
Returns true if the feature has an associated geometry.
bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=nullptr) override
Adds a single feature to the sink.
QgsVectorLayer * layer() const
Gets a pointer to the underlying layer.
void insertFeature(const QgsFeature &feature)
Inserts a feature into the cache and the spatial index.
const QgsFeatureIds & selectedFeatureIds() const
Returns a list of the selected features IDs in this layer.
virtual bool changeAttributeValues(const QgsChangedAttributesMap &attr_map)
Changes attribute values of existing features.
void refreshCache(const QgsFeature &feature)
Changes a feature in the cache and the spatial index.
void updateFeature(QgsFeature &feature) override
Updates a feature in this pool.
QMap< int, QVariant > QgsAttributeMap
This class wraps a request for features to a vector layer (or directly its vector data provider)...
void setId(QgsFeatureId id)
Sets the feature ID for this feature.
virtual bool changeGeometryValues(const QgsGeometryMap &geometry_map)
Changes geometries of existing features.
static bool runOnMainThread(const Func &func, QgsFeedback *feedback=nullptr)
Guarantees that func is executed on the main thread.
QgsFeatureRequest & setFilterFids(const QgsFeatureIds &fids)
Sets feature IDs that should be fetched.
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
A feature pool is based on a vector layer and caches features.
void setFeatureIds(const QgsFeatureIds &ids)
Sets all the feature ids governed by this feature pool.
void deleteFeature(QgsFeatureId fid) override
Removes a feature from this pool.
QgsVectorDataProviderFeaturePool(QgsVectorLayer *layer, bool selectedOnly=false)
Creates a new feature pool for the data provider of layer.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Query the layer for features specified in request.
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be null.
bool addFeatures(QgsFeatureList &features, QgsFeatureSink::Flags flags=nullptr) override
Adds a list of features to the sink.
bool nextFeature(QgsFeature &f)
Represents a vector layer which manages a vector based data sets.
void removeFeature(const QgsFeatureId featureId)
Removes a feature from the cache and the spatial index.