@@ -597,6 +597,11 @@ void QgisApp::createActions()
597597 //
598598 // Digitising Toolbar Items
599599 //
600+
601+ mActionStartEditing = new QAction (QIcon (myIconPath+" /mActionStartEditing.png" ), tr (" Start Editing" ), this );
602+ connect (mActionStartEditing , SIGNAL (triggered ()), this , SLOT (startEditing ()));
603+ mActionStopEditing = new QAction (QIcon (myIconPath+" /mActionStopEditing.png" ), tr (" Stop Editing" ), this );
604+ connect (mActionStopEditing , SIGNAL (triggered ()), this , SLOT (stopEditing ()));
600605 mActionCapturePoint = new QAction (QIcon (myIconPath+" /mActionCapturePoint.png" ), tr (" Capture Point" ), this );
601606 mActionCapturePoint ->setShortcut (tr (" ." ));
602607 mActionCapturePoint ->setStatusTip (tr (" Capture Points" ));
@@ -787,6 +792,8 @@ void QgisApp::createToolBars()
787792 mDigitizeToolBar = addToolBar (tr (" Digitizing" ));
788793 mDigitizeToolBar ->setIconSize (QSize (24 ,24 ));
789794 mDigitizeToolBar ->setObjectName (" Digitizing" );
795+ mDigitizeToolBar ->addAction (mActionStartEditing );
796+ mDigitizeToolBar ->addAction (mActionStopEditing );
790797 mDigitizeToolBar ->addAction (mActionCapturePoint );
791798 mDigitizeToolBar ->addAction (mActionCaptureLine );
792799 mDigitizeToolBar ->addAction (mActionCapturePolygon );
@@ -3392,6 +3399,38 @@ void QgisApp::refreshMapCanvas()
33923399 mMapCanvas ->refresh ();
33933400}
33943401
3402+ void QgisApp::startEditing ()
3403+ {
3404+ QgsMapLayer* theLayer = mMapLegend ->currentLayer ();
3405+ if (!theLayer)
3406+ {
3407+ return ;
3408+ }
3409+ // only vectorlayers can be edited
3410+ QgsVectorLayer* theVectorLayer = dynamic_cast <QgsVectorLayer*>(theLayer);
3411+ if (!theVectorLayer)
3412+ {
3413+ return ;
3414+ }
3415+ theVectorLayer->startEditing ();
3416+ }
3417+
3418+ void QgisApp::stopEditing ()
3419+ {
3420+ QgsMapLayer* theLayer = mMapLegend ->currentLayer ();
3421+ if (!theLayer)
3422+ {
3423+ return ;
3424+ }
3425+ // only vectorlayers can be edited
3426+ QgsVectorLayer* theVectorLayer = dynamic_cast <QgsVectorLayer*>(theLayer);
3427+ if (!theVectorLayer)
3428+ {
3429+ return ;
3430+ }
3431+ theVectorLayer->stopEditing ();
3432+ }
3433+
33953434void QgisApp::showMouseCoordinate (QgsPoint & p)
33963435{
33973436 mCoordsLabel ->setText (p.stringRep (mMousePrecisionDecimalPlaces ));
@@ -4559,6 +4598,18 @@ void QgisApp::activateDeactivateLayerRelatedActions(const QgsMapLayer* layer)
45594598
45604599 if (dprovider)
45614600 {
4601+ // start editing/stop editing
4602+ if (dprovider->capabilities () & QgsVectorDataProvider::AddFeatures)
4603+ {
4604+ mActionStartEditing ->setEnabled (true );
4605+ mActionStopEditing ->setEnabled (true );
4606+ }
4607+ else
4608+ {
4609+ mActionStartEditing ->setEnabled (false );
4610+ mActionStopEditing ->setEnabled (false );
4611+ }
4612+
45624613 // does provider allow deleting of features?
45634614 if (dprovider->capabilities () & QgsVectorDataProvider::DeleteFeatures)
45644615 {
@@ -4635,6 +4686,8 @@ void QgisApp::activateDeactivateLayerRelatedActions(const QgsMapLayer* layer)
46354686 {
46364687 mActionSelect ->setEnabled (false );
46374688 mActionOpenTable ->setEnabled (false );
4689+ mActionStartEditing ->setEnabled (false );
4690+ mActionStopEditing ->setEnabled (false );
46384691 mActionCapturePoint ->setEnabled (false );
46394692 mActionCaptureLine ->setEnabled (false );
46404693 mActionCapturePolygon ->setEnabled (false );
0 commit comments