Skip to content
Permalink
Browse files

fixes #13668 (Delete does not work in the Vertex Editor)

  • Loading branch information
PeterPetrik authored and nyalldawson committed Feb 26, 2016
1 parent 300785b commit 0b136af4966b31268d9bdd1b2fa3a7017a5908e3
@@ -254,6 +254,7 @@ void QgsMapToolNodeTool::canvasPressEvent( QgsMapMouseEvent* e )
mIsPoint = vlayer->geometryType() == QGis::Point;
mNodeEditor = new QgsNodeEditor( vlayer, mSelectedFeature, mCanvas );
QgisApp::instance()->addDockWidget( Qt::LeftDockWidgetArea, mNodeEditor );
connect( mNodeEditor, SIGNAL( deleteSelectedRequested() ), this, SLOT( deleteNodeSelection() ) );
}
else
{
@@ -646,9 +647,9 @@ void QgsMapToolNodeTool::canvasDoubleClickEvent( QgsMapMouseEvent* e )
mCanvas->refresh();
}

void QgsMapToolNodeTool::keyPressEvent( QKeyEvent* e )
void QgsMapToolNodeTool::deleteNodeSelection()
{
if ( mSelectedFeature && ( e->key() == Qt::Key_Backspace || e->key() == Qt::Key_Delete ) )
if ( mSelectedFeature )
{
int firstSelectedIndex = firstSelectedVertex();
if ( firstSelectedIndex == -1 )
@@ -672,29 +673,40 @@ void QgsMapToolNodeTool::keyPressEvent( QKeyEvent* e )
safeSelectVertex( nextVertexToSelect );
}
mCanvas->refresh();

// Override default shortcut management in MapCanvas
e->ignore();
}
else if ( mSelectedFeature && ( e->key() == Qt::Key_Less || e->key() == Qt::Key_Comma ) )
{
int firstSelectedIndex = firstSelectedVertex();
if ( firstSelectedIndex == -1 )
return;
}

mSelectedFeature->deselectAllVertexes();
safeSelectVertex( firstSelectedIndex - 1 );
e->ignore();
}
else if ( mSelectedFeature && ( e->key() == Qt::Key_Greater || e->key() == Qt::Key_Period ) )
void QgsMapToolNodeTool::keyPressEvent( QKeyEvent* e )
{
if ( mSelectedFeature )
{
int firstSelectedIndex = firstSelectedVertex();
if ( firstSelectedIndex == -1 )
return;
if ( e->key() == Qt::Key_Backspace || e->key() == Qt::Key_Delete )
{
this->deleteNodeSelection();

mSelectedFeature->deselectAllVertexes();
safeSelectVertex( firstSelectedIndex + 1 );
e->ignore();
// Override default shortcut management in MapCanvas
e->ignore();
}
else if ( e->key() == Qt::Key_Less || e->key() == Qt::Key_Comma )
{
int firstSelectedIndex = firstSelectedVertex();
if ( firstSelectedIndex == -1 )
return;

mSelectedFeature->deselectAllVertexes();
safeSelectVertex( firstSelectedIndex - 1 );
e->ignore();
}
else if ( e->key() == Qt::Key_Greater || e->key() == Qt::Key_Period )
{
int firstSelectedIndex = firstSelectedVertex();
if ( firstSelectedIndex == -1 )
return;

mSelectedFeature->deselectAllVertexes();
safeSelectVertex( firstSelectedIndex + 1 );
e->ignore();
}
}
}

@@ -65,6 +65,11 @@ class QgsMapToolNodeTool: public QgsMapToolEdit
*/
void editingToggled();

/*
* delete all selected nodes and select next available node
*/
void deleteNodeSelection();

private:
/**
* Get the feature on the mouse click
@@ -27,6 +27,7 @@
#include <QHeaderView>
#include <QVBoxLayout>
#include <QStyledItemDelegate>
#include <QKeyEvent>
#include <QLineEdit>
#include <QVector2D>

@@ -379,6 +380,16 @@ void QgsNodeEditor::zoomToNode( int idx )
}
}

void QgsNodeEditor::keyPressEvent( QKeyEvent * e )
{
if ( e->key() == Qt::Key_Backspace || e->key() == Qt::Key_Delete )
{
emit deleteSelectedRequested();

// Override default shortcut management in MapCanvas
e->ignore();
}
}

//
// CoordinateItemDelegate
@@ -84,6 +84,12 @@ class QgsNodeEditor : public QDockWidget
QTableView* mTableView;
QgsNodeEditorModel* mNodeModel;

signals:
void deleteSelectedRequested( );

protected:
void keyPressEvent( QKeyEvent * event );

private slots:
void updateTableSelection();
void updateNodeSelection( const QItemSelection& selected, const QItemSelection& deselected );

0 comments on commit 0b136af

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