40 int browsedFeatureCount = 0;
41 int couldNotWriteCount = 0;
42 int noGeometryCount = 0;
46 QMap<QString, int> duplicateFeatureCount;
49 browsedFeatureCount++;
65 QgsDebugError( QStringLiteral(
"Could not add new feature. Original copied feature id: %1" ).arg( f.
id() ) );
69 fidList.insert( newFeature.
id() );
72 const auto duplicateFeatureContextLayers = duplicateFeatureContext.
layers();
75 if ( duplicateFeatureCount.contains( chl->name() ) )
77 duplicateFeatureCount[chl->name()] += duplicateFeatureContext.
duplicatedFeatures( chl ).size();
81 duplicateFeatureCount[chl->name()] = duplicateFeatureContext.
duplicatedFeatures( chl ).size();
91 QgsDebugError( QStringLiteral(
"Could not add new feature. Original copied feature id: %1" ).arg( f.
id() ) );
95 fidList.insert( newFeature.
id() );
103 if ( topologicalEditing )
105 if ( topologicalLayer )
118 QString childrenInfo;
119 for (
auto it = duplicateFeatureCount.constBegin(); it != duplicateFeatureCount.constEnd(); ++it )
121 childrenInfo += ( tr(
"\n%n children on layer %1 duplicated",
nullptr, it.value() ).arg( it.key() ) );
127 if ( childrenInfoMsg && !childrenInfo.isEmpty() )
129 childrenInfoMsg->append( childrenInfo );
132 if ( !couldNotWriteCount && !noGeometryCount )
138 errorMsg =
new QString( tr(
"Only %1 out of %2 features were copied." )
139 .arg( browsedFeatureCount - couldNotWriteCount - noGeometryCount, browsedFeatureCount ) );
140 if ( noGeometryCount )
142 errorMsg->append(
" " );
143 errorMsg->append( tr(
"Some features have no geometry." ) );
145 if ( couldNotWriteCount )
147 errorMsg->append(
" " );
148 errorMsg->append( tr(
"Some could not be created on the layer." ) );
156 return mForceSuppressFormPopup;
CORE_EXPORT QgsAttributeMap toMap() const
Returns a QgsAttributeMap of the attribute values.
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
This class wraps a request for features to a vector layer (or directly its vector data provider).
QgsFeatureRequest & setFilterFids(const QgsFeatureIds &fids)
Sets the feature IDs that should be fetched.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
bool hasGeometry() const
Returns true if the feature has an associated geometry.
bool isValid() const
Returns the validity of this feature.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
A geometry is the spatial representation of a feature.
Qgis::GeometryOperationResult translate(double dx, double dy, double dz=0.0, double dm=0.0)
Translates this geometry by dx, dy, dz and dm.
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.
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).
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.
Represents a vector layer which manages a vector based data sets.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
bool isEditable() const FINAL
Returns true if the provider is in editing mode.
bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) FINAL
Adds a single feature to the sink.
int addTopologicalPoints(const QgsGeometry &geom)
Adds topological points for every vertex of the geometry.
QSet< QgsFeatureId > QgsFeatureIds
#define QgsDebugError(str)