From b8f1cb37ed1bcf2b9949196ab29fff9577780bea Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Fri, 22 Feb 2019 09:44:18 -0500 Subject: [PATCH] correctly keep/clear vertices selection when switching locked feature --- src/app/vertextool/qgsvertextool.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/app/vertextool/qgsvertextool.cpp b/src/app/vertextool/qgsvertextool.cpp index b09d761aeaa2..7164175617ac 100644 --- a/src/app/vertextool/qgsvertextool.cpp +++ b/src/app/vertextool/qgsvertextool.cpp @@ -436,7 +436,7 @@ void QgsVertexTool::cadCanvasPressEvent( QgsMapMouseEvent *e ) } } - if ( !clickedOnHighlightedVertex ) + if ( !clickedOnHighlightedVertex && e->button() == Qt::LeftButton ) setHighlightedVertices( QList() ); // reset selection } @@ -980,6 +980,14 @@ void QgsVertexTool::tryToSelectFeature( QgsMapMouseEvent *e ) { // we have a feature to select QPair alternative = mLockedFeatureAlternatives->alternatives.at( mLockedFeatureAlternatives->index ); + // keep only corrsesponding vertices + // todo: it might be nice to keep other vertices in memory, so we could select them when switching lokcked feature + QList vertices; + for ( const Vertex &v : qgis::as_const( mSelectedVertices ) ) + if ( v.layer == alternative.first && v.fid == alternative.second ) + vertices << v; + setHighlightedVertices( vertices, ModeReset ); + updateVertexEditor( alternative.first, alternative.second ); } else @@ -991,6 +999,7 @@ void QgsVertexTool::tryToSelectFeature( QgsMapMouseEvent *e ) { mVertexEditor->updateEditor( nullptr ); } + setHighlightedVertices( QList(), ModeReset ); } // we have either locked ourselves to a feature or unlocked again