Skip to content

Commit bec5d20

Browse files
author
mhugent
committed
added toolbar buttons for start/stop editing
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5396 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 3bff720 commit bec5d20

File tree

4 files changed

+59
-0
lines changed

4 files changed

+59
-0
lines changed
959 Bytes
Loading
875 Bytes
Loading

src/gui/qgisapp.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
33953434
void 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);

src/gui/qgisapp.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,10 @@ public slots:
300300
void refreshMapCanvas();
301301
//! returns pointer to map legend
302302
QgsLegend *legend() { return mMapLegend; }
303+
//! enables the editing mode of the current layer
304+
void startEditing();
305+
//! disables the editing mode of the current layer
306+
void stopEditing();
303307

304308
public slots:
305309
void showProgress(int theProgress, int theTotalSteps);
@@ -449,6 +453,8 @@ public slots:
449453
QAction *mActionQgisSourceForgePage;
450454
QAction *mActionHelpAbout;
451455
QAction *mArawAction;
456+
QAction *mActionStartEditing;
457+
QAction *mActionStopEditing;
452458
QAction *mActionCapturePoint;
453459
QAction *mActionCaptureLine;
454460
QAction *mActionCapturePolygon;

0 commit comments

Comments
 (0)