Skip to content

Commit

Permalink
[node editor] Improve UX by having right-click bind feature to node e…
Browse files Browse the repository at this point in the history
…ditor (i.e., bye bye menu)
  • Loading branch information
nirvn committed Jan 23, 2019
1 parent 2defe21 commit 8bd997d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/app/vertextool/qgsvertexeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,10 @@ QgsVertexEditor::QgsVertexEditor(

void QgsVertexEditor::updateEditor( QgsVectorLayer *layer, QgsSelectedFeature *selectedFeature )
{
delete mVertexModel;
if ( mSelectedFeature )
{
delete mVertexModel;
}

mLayer = layer;
mSelectedFeature = selectedFeature;
Expand Down
18 changes: 13 additions & 5 deletions src/app/vertextool/qgsvertextool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ void QgsVertexTool::activate()
{
if ( QgisApp::instance() )
{
showVertexEditor();
showVertexEditor(); //#spellok
}
QgsMapToolAdvancedDigitizing::activate();
}
Expand Down Expand Up @@ -445,10 +445,7 @@ void QgsVertexTool::cadCanvasPressEvent( QgsMapMouseEvent *e )
// show popup menu - if we are on top of a feature
if ( mLastMouseMoveMatch.isValid() && mLastMouseMoveMatch.layer() )
{
QMenu menu;
QAction *actionVertexEditor = menu.addAction( tr( "Vertex Editor" ) );
connect( actionVertexEditor, &QAction::triggered, this, &QgsVertexTool::showVertexEditor ); //#spellok
menu.exec( mCanvas->mapToGlobal( e->pos() ) );
showVertexEditor(); //#spellok
}
}
}
Expand Down Expand Up @@ -1058,6 +1055,17 @@ void QgsVertexTool::showVertexEditor() //#spellok
QgsPointLocator::Match m = mLastMouseMoveMatch;
if ( m.isValid() || m.layer() )
{
if ( mSelectedFeature && mSelectedFeature->featureId() == m.featureId() && mSelectedFeature->layer() == m.layer() )
{
// if show feature is called on a feature that's already binded to the vertex editor, toggle it off
mSelectedFeature.reset();
if ( mVertexEditor )
{
mVertexEditor->updateEditor( nullptr, nullptr );
}
return;
}

mSelectedFeature.reset( new QgsSelectedFeature( m.featureId(), m.layer(), mCanvas ) );
for ( int i = 0; i < mSelectedVertices.length(); ++i )
{
Expand Down

0 comments on commit 8bd997d

Please sign in to comment.