Skip to content
Permalink
Browse files

using a lambda signal and dialog show for fixing up attributes, so e.…

…g. parent features can be created in between
  • Loading branch information
signedav committed Jul 3, 2020
1 parent a360f53 commit 83ec606326b316ece45044cf8e2a6502f035535e
Showing with 26 additions and 11 deletions.
  1. +23 −11 src/app/qgisapp.cpp
  2. +3 −0 src/app/qgisapp.h
@@ -10222,21 +10222,33 @@ void QgisApp::pasteFromClipboard( QgsMapLayer *destinationLayer )
context.setMapCanvas( mMapCanvas );

QgsFixAttributeDialog *dialog = new QgsFixAttributeDialog( pasteVectorLayer, invalidFeatures, this, context );
int feedback = dialog->exec();

switch ( feedback )
connect( dialog, &QgsFixAttributeDialog::finished, this, [ = ]( int feedback )
{
case QgsFixAttributeDialog::PasteValid:
//paste valid and fixed, vanish unfixed
newFeatures << validFeatures << dialog->fixedFeatures();
break;
case QgsFixAttributeDialog::PasteAll:
//paste all, even unfixed
newFeatures << validFeatures << dialog->fixedFeatures() << dialog->unfixedFeatures();
break;
}
QgsFeatureList features = newFeatures;
switch ( feedback )
{
case QgsFixAttributeDialog::PasteValid:
//paste valid and fixed, vanish unfixed
features << validFeatures << dialog->fixedFeatures();
break;
case QgsFixAttributeDialog::PasteAll:
//paste all, even unfixed
features << validFeatures << dialog->fixedFeatures() << dialog->unfixedFeatures();
break;
}
pasteFeatures( pasteVectorLayer, invalidGeometriesCount, nTotalFeatures, features );
} );
dialog->show();
return;
}
}

pasteFeatures( pasteVectorLayer, invalidGeometriesCount, nTotalFeatures, newFeatures );
}

void QgisApp::pasteFeatures( QgsVectorLayer *pasteVectorLayer, int invalidGeometriesCount, int nTotalFeatures, QgsFeatureList &newFeatures )
{
pasteVectorLayer->addFeatures( newFeatures );
QgsFeatureIds newIds;
newIds.reserve( newFeatures.size() );
@@ -927,6 +927,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
(defaults to the active layer on the legend)
*/
void pasteFromClipboard( QgsMapLayer *destinationLayer = nullptr );

void pasteFeatures( QgsVectorLayer *pasteVectorLayer, int invalidGeometriesCount, int nTotalFeatures, QgsFeatureList &newFeatures );

//! copies features on the clipboard to a new vector layer
void pasteAsNewVector();
//! copies features on the clipboard to a new memory vector layer

0 comments on commit 83ec606

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