Skip to content

Commit

Permalink
duplicate child feature in relationwidget
Browse files Browse the repository at this point in the history
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 7d4290d
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/gui/qgsrelationeditorwidget.cpp
Expand Up @@ -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 );
}
}

Expand Down

0 comments on commit 7d4290d

Please sign in to comment.