Skip to content

Commit 643a763

Browse files
committed
fix updating vertex selection
1 parent e8e2258 commit 643a763

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

src/app/vertextool/qgslockedfeature.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
* *
1414
***************************************************************************/
1515

16-
#include "vertextool/qgslockedfeature.h"
17-
#include "vertextool/qgsvertexentry.h"
16+
#include "qgslockedfeature.h"
17+
#include "qgsvertexeditor.h"
1818

1919
#include "qgsfeatureiterator.h"
2020
#include "qgspoint.h"
@@ -283,7 +283,7 @@ void QgsLockedFeature::selectVertex( int vertexNr )
283283
return;
284284

285285
QgsVertexEntry *entry = mVertexMap.at( vertexNr );
286-
entry->setSelected();
286+
entry->setSelected( true );
287287

288288
emit selectionChanged();
289289
}

src/app/vertextool/qgsvertexeditor.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -396,30 +396,33 @@ void QgsVertexEditor::updateTableSelection()
396396
}
397397
}
398398
disconnect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
399+
disconnect( mTableView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QgsVertexEditor::updateVertexSelection );
399400
mTableView->selectionModel()->select( selection, QItemSelectionModel::ClearAndSelect );
400401
connect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
402+
connect( mTableView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QgsVertexEditor::updateVertexSelection );
401403

402404
if ( firstSelectedRow >= 0 )
403405
mTableView->scrollTo( mVertexModel->index( firstSelectedRow, 0 ), QAbstractItemView::PositionAtTop );
404406

405407
mUpdatingTableSelection = false;
406408
}
407409

408-
void QgsVertexEditor::updateVertexSelection( const QItemSelection &selected, const QItemSelection & )
410+
void QgsVertexEditor::updateVertexSelection( const QItemSelection &, const QItemSelection & )
409411
{
410412
if ( !mLockedFeature || mUpdatingTableSelection )
411413
return;
412414

413415
mUpdatingVertexSelection = true;
416+
disconnect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
414417

415418
mLockedFeature->deselectAllVertices();
416419

417420
QgsCoordinateTransform t( mLockedFeature->layer()->crs(), mCanvas->mapSettings().destinationCrs(), QgsProject::instance() );
418421
std::unique_ptr<QgsRectangle> bbox;
419-
QModelIndexList indexList = selected.indexes();
420-
for ( int i = 0; i < indexList.length(); ++i )
422+
const QModelIndexList indexList = mTableView->selectionModel()->selectedRows();
423+
for ( const QModelIndex &index : indexList )
421424
{
422-
int vertexIdx = indexList.at( i ).row();
425+
int vertexIdx = index.row();
423426
mLockedFeature->selectVertex( vertexIdx );
424427

425428
// create a bounding box of selected vertices
@@ -447,6 +450,7 @@ void QgsVertexEditor::updateVertexSelection( const QItemSelection &selected, con
447450
}
448451

449452
mUpdatingVertexSelection = false;
453+
connect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
450454
}
451455

452456
void QgsVertexEditor::keyPressEvent( QKeyEvent *e )

src/app/vertextool/qgsvertexeditor.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,13 @@ class QgsVertexEditor : public QgsDockWidget
8181
void deleteSelectedRequested();
8282
void editorClosed();
8383

84-
public slots:
85-
void updateTableSelection();
86-
8784
protected:
8885
void keyPressEvent( QKeyEvent *event ) override;
8986
void closeEvent( QCloseEvent *event ) override;
9087

9188
private slots:
92-
void updateVertexSelection( const QItemSelection &selected, const QItemSelection &deselected );
89+
void updateTableSelection();
90+
void updateVertexSelection( const QItemSelection &, const QItemSelection &deselected );
9391

9492
private:
9593

src/app/vertextool/qgsvertextool.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -2328,9 +2328,6 @@ void QgsVertexTool::setHighlightedVertices( const QList<Vertex> &listVertices, H
23282328
mLockedFeature->selectVertex( vertex.vertexId );
23292329
}
23302330

2331-
// if ( mVertexEditor )
2332-
// mVertexEditor->updateTableSelection();
2333-
23342331
connect( mLockedFeature.get(), &QgsLockedFeature::selectionChanged, this, &QgsVertexTool::lockedFeatureSelectionChanged );
23352332
}
23362333
}

0 commit comments

Comments
 (0)