mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-31 00:03:42 -04:00
action mapping for duplicate feature
This commit is contained in:
parent
bf45d0b618
commit
e1b6daa474
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user