Skip to content
Permalink
Browse files
added a test if the digitizing tool matches the vector layer type
git-svn-id: http://svn.osgeo.org/qgis/trunk@5430 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 9, 2006
1 parent a1f990b commit 35d8cb310cc3d0880d5bce355d98dbac7e459330
Showing with 23 additions and 6 deletions.
  1. +23 −0 src/gui/qgsmaptoolcapture.cpp
  2. +0 −6 src/legend/qgslegend.cpp
@@ -95,6 +95,13 @@ void QgsMapToolCapture::canvasReleaseEvent(QMouseEvent * e)
// POINT CAPTURING
if (mTool == CapturePoint)
{
//check we only use this tool for point/multipoint layers
if(vlayer->vectorType() != QGis::Point)
{
QMessageBox::information(0,"Wrong editing tool", "Cannot apply the 'capture point' tool on this vector layer",\
QMessageBox::Ok);
return;
}

QgsPoint idPoint = toMapCoords(e->pos());

@@ -145,6 +152,22 @@ void QgsMapToolCapture::canvasReleaseEvent(QMouseEvent * e)
{
// LINE & POLYGON CAPTURING

//check we only use the line tool for line/multiline layers
if(mTool == CaptureLine && vlayer->vectorType() != QGis::Line)
{
QMessageBox::information(0,"Wrong editing tool", "Cannot apply the 'capture line' tool on this vector layer",\
QMessageBox::Ok);
return;
}

//check we only use the polygon tool for polygon/multipolygon layers
if(mTool == CapturePolygon && vlayer->vectorType() != QGis::Polygon)
{
QMessageBox::information(0,"Wrong editing tool", "Cannot apply the 'capture polygon' tool on this vector layer",\
QMessageBox::Ok);
return;
}

if (mCaptureList.size() == 0)
{
mRubberBand = new QgsRubberBand(mCanvas, mTool == CapturePolygon);
@@ -97,12 +97,6 @@ void QgsLegend::handleCurrentItemChanged(QTreeWidgetItem* current, QTreeWidgetIt
{
mMapCanvas->setCurrentLayer( layer );
}
//stop editing for the old layer
QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>(mCurrentLayer);
if(vlayer && vlayer->isEditable())
{
vlayer->stopEditing();
}
mCurrentLayer = layer;
}
emit currentLayerChanged ( layer );

0 comments on commit 35d8cb3

Please sign in to comment.