39 int browsedFeatureCount = 0;
40 int couldNotWriteCount = 0;
41 int noGeometryCount = 0;
47 browsedFeatureCount++;
64 QgsDebugMsg( QStringLiteral(
"Could not add new feature. Original copied feature id: %1" ).arg( fid ) );
68 fidList.insert( newFeature.
id() );
80 if ( !couldNotWriteCount && !noGeometryCount )
86 errorMsg =
new QString( QString( tr(
"Only %1 out of %2 features were copied." ) )
87 .arg( browsedFeatureCount - couldNotWriteCount - noGeometryCount, browsedFeatureCount ) );
88 if ( noGeometryCount )
90 errorMsg->append(
" " );
91 errorMsg->append( tr(
"Some features have no geometry." ) );
93 if ( couldNotWriteCount )
95 errorMsg->append(
" " );
96 errorMsg->append( tr(
"Some could not be created on the layer." ) );
Wrapper for iterator of features from vector data provider or vector layer.
QSet< QgsFeatureId > QgsFeatureIds
A geometry is the spatial representation of a feature.
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 isEditable() const FINAL
Returns true if the provider is in editing mode.
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.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsAttributeMap toMap() const
Returns a QgsAttributeMap of the attribute values.
QgsFeatureRequest & setFilterFids(const QgsFeatureIds &fids)
Sets feature IDs that should be fetched.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=nullptr) FINAL
Adds a single feature to the sink.
OperationResult translate(double dx, double dy, double dz=0.0, double dm=0.0)
Translates this geometry by dx, dy, dz and dm.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Query the layer for features specified in request.
bool nextFeature(QgsFeature &f)
Represents a vector layer which manages a vector based data sets.