File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4490,14 +4490,34 @@ void QgisApp::editPaste( QgsMapLayer *destinationLayer )
44904490 if ( pasteVectorLayer != 0 )
44914491 {
44924492 pasteVectorLayer->beginEditCommand ( tr ( " Features pasted" ) );
4493+ QgsFeatureList features;
44934494 if ( mMapCanvas ->mapRenderer ()->hasCrsTransformEnabled () )
44944495 {
4495- pasteVectorLayer-> addFeatures ( clipboard ()->transformedCopyOf ( pasteVectorLayer->srs () ) );
4496+ features = clipboard ()->transformedCopyOf ( pasteVectorLayer->srs () );
44964497 }
44974498 else
44984499 {
4499- pasteVectorLayer-> addFeatures ( clipboard ()->copyOf () );
4500+ features = clipboard ()->copyOf ();
45004501 }
4502+
4503+ QgsAttributeList dstAttr = pasteVectorLayer->pendingAllAttributesList ();
4504+
4505+ for ( int i = 0 ; i < features.size (); i++ )
4506+ {
4507+ QgsFeature &f = features[i];
4508+ QgsAttributeMap srcMap = f.attributeMap ();
4509+ QgsAttributeMap dstMap;
4510+
4511+ int j = 0 ;
4512+ foreach ( int id, srcMap.keys () )
4513+ {
4514+ dstMap[ dstAttr[j++] ] = srcMap[id];
4515+ }
4516+
4517+ f.setAttributeMap ( dstMap );
4518+ }
4519+
4520+ pasteVectorLayer->addFeatures ( features );
45014521 pasteVectorLayer->endEditCommand ();
45024522 mMapCanvas ->refresh ();
45034523 }
You can’t perform that action at this time.
0 commit comments