Skip to content

Commit

Permalink
added a test if the digitizing tool matches the vector layer type
Browse files Browse the repository at this point in the history
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 35d8cb3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
23 changes: 23 additions & 0 deletions src/gui/qgsmaptoolcapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down Expand Up @@ -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);
Expand Down
6 changes: 0 additions & 6 deletions src/legend/qgslegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 35d8cb3

Please sign in to comment.