@@ -1258,6 +1258,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
1258
1258
1259
1259
setupLayoutManagerConnections ();
1260
1260
1261
+ setupDuplicateFeaturesAction ();
1262
+
1261
1263
// update windows
1262
1264
qApp->processEvents ();
1263
1265
@@ -7607,6 +7609,20 @@ void QgisApp::setupLayoutManagerConnections()
7607
7609
} );
7608
7610
}
7609
7611
7612
+ void QgisApp::setupDuplicateFeaturesAction ()
7613
+ {
7614
+ QgsMapLayerAction *action = new QgsMapLayerAction ( QString ( tr ( " Duplicate feature" ) ),
7615
+ this , QgsMapLayerAction::AllActions,
7616
+ QgsApplication::getThemeIcon ( QStringLiteral ( " /mIconAtlas.svg" ) ) );
7617
+
7618
+ QgsGui::mapLayerActionRegistry ()->addMapLayerAction ( action );
7619
+ connect ( action, &QgsMapLayerAction::triggeredForFeature, this , [this ]( QgsMapLayer * layer, const QgsFeature & feat )
7620
+ {
7621
+ duplicateFeatures ( layer, feat );
7622
+ }
7623
+ );
7624
+ }
7625
+
7610
7626
void QgisApp::setupAtlasMapLayerAction ( QgsComposition *composition, bool enableAction )
7611
7627
{
7612
7628
QgsMapLayerAction *action = mAtlasFeatureActions .value ( composition );
@@ -13301,3 +13317,36 @@ void QgisApp::transactionGroupCommitError( const QString &error )
13301
13317
{
13302
13318
displayMessage ( tr ( " Transaction" ), error, QgsMessageBar::CRITICAL );
13303
13319
}
13320
+
13321
+ QgsFeature QgisApp::duplicateFeatures ( QgsMapLayer *mlayer, const QgsFeature &feature )
13322
+ {
13323
+ if ( mlayer->type () != QgsMapLayer::VectorLayer )
13324
+ return QgsFeature ();
13325
+ /*
13326
+ QgsVectorLayer *layer=qobject_cast<QgsVectorLayer *>(mlayer);
13327
+
13328
+ layer->startEditing();
13329
+
13330
+ QgsFeatureList featureList;
13331
+
13332
+ if( feature )
13333
+ {
13334
+ featureList.append( feature );
13335
+ }
13336
+ else
13337
+ {
13338
+ for ( const QgsFeature &f : layer->selectedFeatures() )
13339
+ {
13340
+ featureList.append( f );
13341
+ }
13342
+ }
13343
+
13344
+ int featureCount=0;
13345
+
13346
+ for ( const QgsFeature &f : featureList )
13347
+ {
13348
+ //QgsVectorLayerUtils::duplicateFeature( layer, feature, QgsProject::instance(), 0 );
13349
+ }
13350
+ */
13351
+ return QgsFeature ();
13352
+ }
0 commit comments