Skip to content
Permalink
Browse files

Fix #8561 - Handle change layer in node tool

  • Loading branch information
NathanW2 committed Sep 3, 2013
1 parent 5329ad5 commit 510f5cb037351e5b19e312457e5f684faac37746
Showing with 19 additions and 0 deletions.
  1. +14 −0 src/app/nodetool/qgsmaptoolnodetool.cpp
  2. +5 −0 src/app/nodetool/qgsmaptoolnodetool.h
@@ -23,6 +23,8 @@
#include "qgsrubberband.h"
#include "qgsvectorlayer.h"
#include "qgslogger.h"
#include "qgisapp.h"
#include "qgslegend.h"

#include <QMouseEvent>
#include <QRubberBand>
@@ -369,6 +371,7 @@ void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
}

mSelectedFeature = new QgsSelectedFeature( snapResults[0].snappedAtGeometry, vlayer, mCanvas );
connect( QgisApp::instance()->legend(), SIGNAL( currentLayerChanged( QgsMapLayer* ) ), this, SLOT( currentLayerChanged( QgsMapLayer* ) ) );
connect( mSelectedFeature, SIGNAL( destroyed() ), this, SLOT( selectedFeatureDestroyed() ) );
mIsPoint = vlayer->geometryType() == QGis::Point;
}
@@ -489,6 +492,17 @@ void QgsMapToolNodeTool::selectedFeatureDestroyed()
mSelectedFeature = 0;
}

void QgsMapToolNodeTool::currentLayerChanged( QgsMapLayer *layer )
{
if ( mSelectedFeature && layer != mSelectedFeature->vlayer() )
{
delete mSelectedFeature;
mSelectedFeature = 0;

removeRubberBands();
}
}

void QgsMapToolNodeTool::canvasReleaseEvent( QMouseEvent * e )
{
if ( !mSelectedFeature )
@@ -55,6 +55,11 @@ class QgsMapToolNodeTool: public QgsMapToolVertexEdit
public slots:
void selectedFeatureDestroyed();

/*
* the current layer changed
*/
void currentLayerChanged( QgsMapLayer *layer );

private:
/**
* Deletes the rubber band pointers and clears mRubberBands

0 comments on commit 510f5cb

Please sign in to comment.
You can’t perform that action at this time.