Skip to content
Permalink
Browse files

action mapping for duplicate feature

  • Loading branch information
signedav committed Dec 4, 2017
1 parent bf45d0b commit e1b6daa4749f225f466fdedd7dd6916832eacef5
Showing with 52 additions and 0 deletions.
  1. +49 −0 src/app/qgisapp.cpp
  2. +3 −0 src/app/qgisapp.h
@@ -1258,6 +1258,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh

setupLayoutManagerConnections();

setupDuplicateFeaturesAction();

// update windows
qApp->processEvents();

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

void QgisApp::setupDuplicateFeaturesAction()
{
QgsMapLayerAction *action = new QgsMapLayerAction( QString( tr( "Duplicate feature" ) ),
this, QgsMapLayerAction::AllActions,
QgsApplication::getThemeIcon( QStringLiteral( "/mIconAtlas.svg" ) ) );

QgsGui::mapLayerActionRegistry()->addMapLayerAction( action );
connect( action, &QgsMapLayerAction::triggeredForFeature, this, [this]( QgsMapLayer * layer, const QgsFeature & feat )
{
duplicateFeatures( layer, feat );
}
);
}

void QgisApp::setupAtlasMapLayerAction( QgsComposition *composition, bool enableAction )
{
QgsMapLayerAction *action = mAtlasFeatureActions.value( composition );
@@ -13301,3 +13317,36 @@ void QgisApp::transactionGroupCommitError( const QString &error )
{
displayMessage( tr( "Transaction" ), error, QgsMessageBar::CRITICAL );
}

QgsFeature QgisApp::duplicateFeatures( QgsMapLayer *mlayer, const QgsFeature &feature )
{
if ( mlayer->type() != QgsMapLayer::VectorLayer )
return QgsFeature();
/*
QgsVectorLayer *layer=qobject_cast<QgsVectorLayer *>(mlayer);

layer->startEditing();

QgsFeatureList featureList;

if( feature )
{
featureList.append( feature );
}
else
{
for ( const QgsFeature &f : layer->selectedFeatures() )
{
featureList.append( f );
}
}

int featureCount=0;

for ( const QgsFeature &f : featureList )
{
//QgsVectorLayerUtils::duplicateFeature( layer, feature, QgsProject::instance(), 0 );
}
*/
return QgsFeature();
}
@@ -2208,6 +2208,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow

QgsBrowserModel *mBrowserModel = nullptr;

void setupDuplicateFeaturesAction();
QgsFeature duplicateFeatures( QgsMapLayer *mlayer, const QgsFeature &feature );

friend class TestQgisAppPython;
};

0 comments on commit e1b6daa

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