Skip to content
Permalink
Browse files

initialize map tool in function

  • Loading branch information
signedav committed Dec 20, 2017
1 parent 3b3d304 commit 7b199ed4a90e4fb345f6304e47e489d797b16e2a
Showing with 16 additions and 4 deletions.
  1. +16 −4 src/app/qgisapp.cpp
@@ -13385,7 +13385,11 @@ QgsFeature QgisApp::duplicateFeatureDigitized( QgsMapLayer *mlayer, const QgsFea
QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( mlayer );

layer->startEditing();
mMapCanvas->setMapTool( mMapTools.mDigitizeFeature );

QgsMapToolDigitizeFeature *digiFeature = nullptr;
digiFeature = new QgsMapToolDigitizeFeature( mMapCanvas, QgsMapToolCapture::CaptureNone );

mMapCanvas->setMapTool( digiFeature );
mMapCanvas->window()->raise();
mMapCanvas->activateWindow();
mMapCanvas->setFocus();
@@ -13394,7 +13398,7 @@ QgsFeature QgisApp::duplicateFeatureDigitized( QgsMapLayer *mlayer, const QgsFea
messageBar()->pushMessage( msg, QgsMessageBar::INFO, 3 );

QMetaObject::Connection *connDigitizingFinished = new QMetaObject::Connection();
*connDigitizingFinished = connect( mMapTools.mDigitizeFeature, static_cast<void ( QgsMapToolDigitizeFeature::* )( const QgsFeature & )>( &QgsMapToolDigitizeFeature::digitizingFinished ), this, [this, layer, feature, connDigitizingFinished]( const QgsFeature & digitizedFeature )
*connDigitizingFinished = connect( digiFeature, static_cast<void ( QgsMapToolDigitizeFeature::* )( const QgsFeature & )>( &QgsMapToolDigitizeFeature::digitizingFinished ), this, [this, layer, feature, connDigitizingFinished, digiFeature]( const QgsFeature & digitizedFeature )
{
QString msg = tr( "Duplicate digitized" );
messageBar()->pushMessage( msg, QgsMessageBar::INFO, 1 );
@@ -13412,11 +13416,19 @@ QgsFeature QgisApp::duplicateFeatureDigitized( QgsMapLayer *mlayer, const QgsFea
}

messageBar()->pushMessage( tr( "Feature on layer %2 duplicated\n%3" ).arg( layer->name() ).arg( childrenInfo ), QgsMessageBar::SUCCESS, 5 );
mMapCanvas->unsetMapTool( mMapTools.mDigitizeFeature );
disconnect( *connDigitizingFinished );
mMapCanvas->unsetMapTool( digiFeature );
//disconnect( *connDigitizingFinished );
//delete digiFeature;
}
);

QMetaObject::Connection *connDigitizingAborted = new QMetaObject::Connection();
*connDigitizingAborted = connect( digiFeature, static_cast<void ( QgsMapToolDigitizeFeature::* )()>( &QgsMapToolDigitizeFeature::deactivate ), this, [this, layer, feature, connDigitizingFinished, digiFeature]()
{
delete digiFeature;
}
);

return QgsFeature();
}

0 comments on commit 7b199ed

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