Skip to content

Commit

Permalink
action mapping for duplicate feature
Browse files Browse the repository at this point in the history
  • Loading branch information
signedav committed Dec 20, 2017
1 parent bf45d0b commit e1b6daa
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -1258,6 +1258,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh

setupLayoutManagerConnections();

setupDuplicateFeaturesAction();

// update windows
qApp->processEvents();

Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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();
}
3 changes: 3 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -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;
};

Expand Down

0 comments on commit e1b6daa

Please sign in to comment.