39 int browsedFeatureCount = 0;
40 int couldNotWriteCount = 0;
41 int noGeometryCount = 0;
47 browsedFeatureCount++;
49 Q_FOREACH (
auto idx, pkAttrList )
66 QgsDebugMsg( QString(
"Could not add new feature. Original copied feature id: %1" ).arg( fid ) );
70 fidList.insert( f.
id() );
82 if ( !couldNotWriteCount && !noGeometryCount )
88 errorMsg =
new QString( QString( tr(
"Only %1 out of %2 features were copied." ) )
89 .arg( browsedFeatureCount - couldNotWriteCount - noGeometryCount, browsedFeatureCount ) );
90 if ( noGeometryCount )
92 errorMsg->append(
" " );
93 errorMsg->append( tr(
"Some features have no geometry." ) );
95 if ( couldNotWriteCount )
97 errorMsg->append(
" " );
98 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.
bool setAttribute(int field, const QVariant &attr)
Set an attribute's value by field index.
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 override
Returns true if the provider is in editing mode.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsAttributeList primaryKeyAttributes() const
Returns the list of attributes which make up the layer's primary keys.
QgsGeometry geometry() const
Returns the geometry associated with this feature.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const override
Query the layer for features specified in request.
QgsFeatureRequest & setFilterFids(const QgsFeatureIds &fids)
Set feature IDs that should be fetched.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
OperationResult translate(double dx, double dy, double dz=0.0, double dm=0.0)
Translates this geometry by dx, dy, dz and dm.
QList< int > QgsAttributeList
bool nextFeature(QgsFeature &f)
Represents a vector layer which manages a vector based data sets.
bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=nullptr) override
Adds a single feature to the sink.