added toolbar buttons for start/stop editing

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5396 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
mhugent 2006-04-29 21:07:29 +00:00
parent 3bff720e1b
commit bec5d201d8
4 changed files with 59 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 959 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 875 B

View File

@ -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"));
@ -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);
@ -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));
@ -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)
{
@ -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);

View File

@ -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);
@ -449,6 +453,8 @@ private:
QAction *mActionQgisSourceForgePage;
QAction *mActionHelpAbout;
QAction *mArawAction;
QAction *mActionStartEditing;
QAction *mActionStopEditing;
QAction *mActionCapturePoint;
QAction *mActionCaptureLine;
QAction *mActionCapturePolygon;