@@ -13348,7 +13348,8 @@ QgsFeature QgisApp::duplicateFeatures( QgsMapLayer *mlayer, const QgsFeature &fe
13348
13348
}
13349
13349
else
13350
13350
{
13351
- for ( const QgsFeature &f : layer->selectedFeatures() )
13351
+ const auto selectedFeatures = layer->selectedFeatures();
13352
+ for ( const QgsFeature &f : selectedFeatures )
13352
13353
{
13353
13354
featureList.append( f );
13354
13355
}
@@ -13365,13 +13366,14 @@ QgsFeature QgisApp::duplicateFeatures( QgsMapLayer *mlayer, const QgsFeature &fe
13365
13366
QgsVectorLayerUtils::duplicateFeature( layer, f, QgsProject::instance(), 0, duplicateFeatureContext );
13366
13367
featureCount += 1;
13367
13368
13368
- for ( QgsVectorLayer *chl : duplicateFeatureContext.layers() )
13369
+ const auto duplicatedFeatureContextLayers = duplicateFeatureContext.layers();
13370
+ for ( QgsVectorLayer *chl : duplicatedFeatureContextLayers )
13369
13371
{
13370
- childrenInfo += ( tr( "%1 children on layer %2 duplicated" ).arg( duplicateFeatureContext.duplicatedFeatures( chl ).size() ).arg( chl->name() ) );
13372
+ childrenInfo += ( tr( "%1 children on layer %2 duplicated" ).arg( QString::number( duplicateFeatureContext.duplicatedFeatures( chl ).size() ), chl->name() ) );
13371
13373
}
13372
13374
}
13373
13375
13374
- messageBar()->pushMessage( tr( "%1 features on layer %2 duplicated\n%3" ).arg( featureCount ).arg( layer->name() ).arg( childrenInfo ), QgsMessageBar::SUCCESS, 5 );
13376
+ messageBar()->pushMessage( tr( "%1 features on layer %2 duplicated\n%3" ).arg( QString::number( featureCount ), layer->name(), childrenInfo ), QgsMessageBar::SUCCESS, 5 );
13375
13377
13376
13378
return QgsFeature();
13377
13379
}
@@ -13386,19 +13388,17 @@ QgsFeature QgisApp::duplicateFeatureDigitized( QgsMapLayer *mlayer, const QgsFea
13386
13388
13387
13389
layer->startEditing();
13388
13390
13389
- QgsMapToolDigitizeFeature *digiFeature = nullptr;
13390
- digiFeature = new QgsMapToolDigitizeFeature( mMapCanvas, QgsMapToolCapture::CaptureNone );
13391
+ QgsMapToolDigitizeFeature *digitizeFeature = new QgsMapToolDigitizeFeature( mMapCanvas, QgsMapToolCapture::CaptureNone );
13391
13392
13392
- mMapCanvas->setMapTool( digiFeature );
13393
+ mMapCanvas->setMapTool( digitizeFeature );
13393
13394
mMapCanvas->window()->raise();
13394
13395
mMapCanvas->activateWindow();
13395
13396
mMapCanvas->setFocus();
13396
13397
13397
13398
QString msg = tr( "Digitize the duplicate, please." ).arg( layer->name() );
13398
13399
messageBar()->pushMessage( msg, QgsMessageBar::INFO, 3 );
13399
13400
13400
- QMetaObject::Connection *connDigitizingFinished = new QMetaObject::Connection();
13401
- *connDigitizingFinished = connect( digiFeature, static_cast<void ( QgsMapToolDigitizeFeature::* )( const QgsFeature & )>( &QgsMapToolDigitizeFeature::digitizingFinished ), this, [this, layer, feature, connDigitizingFinished, digiFeature]( const QgsFeature & digitizedFeature )
13401
+ connect( digitizeFeature, static_cast<void ( QgsMapToolDigitizeFeature::* )( const QgsFeature & )>( &QgsMapToolDigitizeFeature::digitizingFinished ), this, [this, layer, feature, digitizeFeature]( const QgsFeature & digitizedFeature )
13402
13402
{
13403
13403
QString msg = tr( "Duplicate digitized" );
13404
13404
messageBar()->pushMessage( msg, QgsMessageBar::INFO, 1 );
@@ -13410,24 +13410,28 @@ QgsFeature QgisApp::duplicateFeatureDigitized( QgsMapLayer *mlayer, const QgsFea
13410
13410
QgsVectorLayerUtils::duplicateFeature( layer, newFeature, QgsProject::instance(), 0, duplicateFeatureContext );
13411
13411
13412
13412
QString childrenInfo;
13413
- for ( QgsVectorLayer *chl : duplicateFeatureContext.layers() )
13413
+ const auto duplicateFeatureContextLayers = duplicateFeatureContext.layers();
13414
+ for ( QgsVectorLayer *chl : duplicateFeatureContextLayers )
13414
13415
{
13415
13416
childrenInfo += ( tr( "%1 children on layer %2 duplicated" ).arg( duplicateFeatureContext.duplicatedFeatures( chl ).size() ).arg( chl->name() ) );
13416
13417
}
13417
13418
13418
13419
messageBar()->pushMessage( tr( "Feature on layer %2 duplicated\n%3" ).arg( layer->name() ).arg( childrenInfo ), QgsMessageBar::SUCCESS, 5 );
13419
- mMapCanvas->unsetMapTool( digiFeature );
13420
- //disconnect( *connDigitizingFinished );
13421
- //delete digiFeature;
13420
+
13421
+ }
13422
+ );
13423
+
13424
+ connect( digitizeFeature, static_cast<void ( QgsMapToolDigitizeFeature::* )()>( &QgsMapToolDigitizeFeature::digitizingFinalized ), this, [this, digitizeFeature]()
13425
+ {
13426
+ mMapCanvas->unsetMapTool( digitizeFeature );
13422
13427
}
13423
- );
13428
+ );
13424
13429
13425
- QMetaObject::Connection *connDigitizingAborted = new QMetaObject::Connection();
13426
- *connDigitizingAborted = connect( digiFeature, static_cast<void ( QgsMapToolDigitizeFeature::* )()>( &QgsMapToolDigitizeFeature::deactivate ), this, [this, layer, feature, connDigitizingFinished, digiFeature]()
13430
+ connect( digitizeFeature, static_cast<void ( QgsMapToolDigitizeFeature::* )()>( &QgsMapToolDigitizeFeature::digitizingAborted ), this, [this, digitizeFeature]()
13427
13431
{
13428
- delete digiFeature ;
13432
+ delete digitizeFeature ;
13429
13433
}
13430
- );
13434
+ );
13431
13435
13432
13436
return QgsFeature();
13433
13437
}
0 commit comments