Skip to content
Permalink
Browse files

duplicate child feature in relationwidget

beside add and delete child in the relationwidget of an attributeform, there is the new functionality duplicate feature. this duplicates the selected child feature and (if the child has a relation with the strength composition too) the grad child features.
  • Loading branch information
signedav committed Dec 20, 2017
1 parent 67daecd commit 7d4290d92446b823284143b86402589f4d6513b2
Showing with 5 additions and 11 deletions.
  1. +5 −11 src/gui/qgsrelationeditorwidget.cpp
@@ -436,20 +436,14 @@ void QgsRelationEditorWidget::linkFeature()

void QgsRelationEditorWidget::duplicateFeature()
{
QgsVectorLayer *layer = nullptr;

layer = mNmRelation.referencingLayer();

const QgsFeatureIds fids = mFeatureSelectionMgr->selectedFeatureIds();
QgsVectorLayer *layer = mRelation.referencingLayer();

for ( const QgsFeatureId &fid : fids )
QgsFeatureIterator fit = layer->getFeatures( QgsFeatureRequest().setFilterFids( mFeatureSelectionMgr->selectedFeatureIds() ) );
QgsFeature f;
while ( fit.nextFeature( f ) )
{
QgsVectorLayerUtils::QgsDuplicateFeatureContext duplicatedFeatureContext;
QgsFeature feature; //= layer->getFeature( fid );
QgsFeatureRequest freq;
freq.setFilterFid( fid );
layer->getFeatures( freq ).nextFeature( feature );
QgsVectorLayerUtils::duplicateFeature( layer, feature, QgsProject::instance(), 1, duplicatedFeatureContext );
QgsVectorLayerUtils::duplicateFeature( layer, f, QgsProject::instance(), 0, duplicatedFeatureContext );
}
}

0 comments on commit 7d4290d

Please sign in to comment.
You can’t perform that action at this time.