Skip to content

Commit e1b6daa

Browse files
committedDec 20, 2017
action mapping for duplicate feature
1 parent bf45d0b commit e1b6daa

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
12581258

12591259
setupLayoutManagerConnections();
12601260

1261+
setupDuplicateFeaturesAction();
1262+
12611263
// update windows
12621264
qApp->processEvents();
12631265

@@ -7607,6 +7609,20 @@ void QgisApp::setupLayoutManagerConnections()
76077609
} );
76087610
}
76097611

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+
76107626
void QgisApp::setupAtlasMapLayerAction( QgsComposition *composition, bool enableAction )
76117627
{
76127628
QgsMapLayerAction *action = mAtlasFeatureActions.value( composition );
@@ -13301,3 +13317,36 @@ void QgisApp::transactionGroupCommitError( const QString &error )
1330113317
{
1330213318
displayMessage( tr( "Transaction" ), error, QgsMessageBar::CRITICAL );
1330313319
}
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+
}

‎src/app/qgisapp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,6 +2208,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
22082208

22092209
QgsBrowserModel *mBrowserModel = nullptr;
22102210

2211+
void setupDuplicateFeaturesAction();
2212+
QgsFeature duplicateFeatures( QgsMapLayer *mlayer, const QgsFeature &feature );
2213+
22112214
friend class TestQgisAppPython;
22122215
};
22132216

0 commit comments

Comments
 (0)
Please sign in to comment.