Skip to content

Commit

Permalink
added toolbar buttons for start/stop editing
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5396 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Apr 29, 2006
1 parent 3bff720 commit bec5d20
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
Binary file added images/themes/default/mActionStartEditing.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/themes/default/mActionStopEditing.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions src/gui/qgisapp.cpp
Expand Up @@ -597,6 +597,11 @@ void QgisApp::createActions()
//
// Digitising Toolbar Items
//

mActionStartEditing = new QAction(QIcon(myIconPath+"/mActionStartEditing.png"), tr("Start Editing"), this);
connect(mActionStartEditing, SIGNAL(triggered()), this, SLOT(startEditing()));
mActionStopEditing = new QAction(QIcon(myIconPath+"/mActionStopEditing.png"), tr("Stop Editing"), this);
connect(mActionStopEditing, SIGNAL(triggered()), this, SLOT(stopEditing()));
mActionCapturePoint= new QAction(QIcon(myIconPath+"/mActionCapturePoint.png"), tr("Capture Point"), this);
mActionCapturePoint->setShortcut(tr("."));
mActionCapturePoint->setStatusTip(tr("Capture Points"));
Expand Down Expand Up @@ -787,6 +792,8 @@ void QgisApp::createToolBars()
mDigitizeToolBar = addToolBar(tr("Digitizing"));
mDigitizeToolBar->setIconSize(QSize(24,24));
mDigitizeToolBar->setObjectName("Digitizing");
mDigitizeToolBar->addAction(mActionStartEditing);
mDigitizeToolBar->addAction(mActionStopEditing);
mDigitizeToolBar->addAction(mActionCapturePoint);
mDigitizeToolBar->addAction(mActionCaptureLine);
mDigitizeToolBar->addAction(mActionCapturePolygon);
Expand Down Expand Up @@ -3392,6 +3399,38 @@ void QgisApp::refreshMapCanvas()
mMapCanvas->refresh();
}

void QgisApp::startEditing()
{
QgsMapLayer* theLayer = mMapLegend->currentLayer();
if(!theLayer)
{
return;
}
//only vectorlayers can be edited
QgsVectorLayer* theVectorLayer = dynamic_cast<QgsVectorLayer*>(theLayer);
if(!theVectorLayer)
{
return;
}
theVectorLayer->startEditing();
}

void QgisApp::stopEditing()
{
QgsMapLayer* theLayer = mMapLegend->currentLayer();
if(!theLayer)
{
return;
}
//only vectorlayers can be edited
QgsVectorLayer* theVectorLayer = dynamic_cast<QgsVectorLayer*>(theLayer);
if(!theVectorLayer)
{
return;
}
theVectorLayer->stopEditing();
}

void QgisApp::showMouseCoordinate(QgsPoint & p)
{
mCoordsLabel->setText(p.stringRep(mMousePrecisionDecimalPlaces));
Expand Down Expand Up @@ -4559,6 +4598,18 @@ void QgisApp::activateDeactivateLayerRelatedActions(const QgsMapLayer* layer)

if (dprovider)
{
//start editing/stop editing
if(dprovider->capabilities() & QgsVectorDataProvider::AddFeatures)
{
mActionStartEditing->setEnabled(true);
mActionStopEditing->setEnabled(true);
}
else
{
mActionStartEditing->setEnabled(false);
mActionStopEditing->setEnabled(false);
}

//does provider allow deleting of features?
if(dprovider->capabilities() & QgsVectorDataProvider::DeleteFeatures)
{
Expand Down Expand Up @@ -4635,6 +4686,8 @@ void QgisApp::activateDeactivateLayerRelatedActions(const QgsMapLayer* layer)
{
mActionSelect->setEnabled(false);
mActionOpenTable->setEnabled(false);
mActionStartEditing->setEnabled(false);
mActionStopEditing->setEnabled(false);
mActionCapturePoint->setEnabled(false);
mActionCaptureLine->setEnabled(false);
mActionCapturePolygon->setEnabled(false);
Expand Down
6 changes: 6 additions & 0 deletions src/gui/qgisapp.h
Expand Up @@ -300,6 +300,10 @@ public slots:
void refreshMapCanvas();
//! returns pointer to map legend
QgsLegend *legend() { return mMapLegend; }
//! enables the editing mode of the current layer
void startEditing();
//! disables the editing mode of the current layer
void stopEditing();

public slots:
void showProgress(int theProgress, int theTotalSteps);
Expand Down Expand Up @@ -449,6 +453,8 @@ public slots:
QAction *mActionQgisSourceForgePage;
QAction *mActionHelpAbout;
QAction *mArawAction;
QAction *mActionStartEditing;
QAction *mActionStopEditing;
QAction *mActionCapturePoint;
QAction *mActionCaptureLine;
QAction *mActionCapturePolygon;
Expand Down

0 comments on commit bec5d20

Please sign in to comment.