Skip to content

Commit 77fa229

Browse files
committed
fix updating vertex selection
1 parent 06f92d2 commit 77fa229

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

src/app/vertextool/qgslockedfeature.cpp

Lines changed: 3 additions & 3 deletions
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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,30 +374,33 @@ void QgsVertexEditor::updateTableSelection()
374374
}
375375
}
376376
disconnect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
377+
disconnect( mTableView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QgsVertexEditor::updateVertexSelection );
377378
mTableView->selectionModel()->select( selection, QItemSelectionModel::ClearAndSelect );
378379
connect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
380+
connect( mTableView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QgsVertexEditor::updateVertexSelection );
379381

380382
if ( firstSelectedRow >= 0 )
381383
mTableView->scrollTo( mVertexModel->index( firstSelectedRow, 0 ), QAbstractItemView::PositionAtTop );
382384

383385
mUpdatingTableSelection = false;
384386
}
385387

386-
void QgsVertexEditor::updateVertexSelection( const QItemSelection &selected, const QItemSelection & )
388+
void QgsVertexEditor::updateVertexSelection( const QItemSelection &, const QItemSelection & )
387389
{
388390
if ( !mLockedFeature || mUpdatingTableSelection )
389391
return;
390392

391393
mUpdatingVertexSelection = true;
394+
disconnect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
392395

393396
mLockedFeature->deselectAllVertices();
394397

395398
QgsCoordinateTransform t( mLockedFeature->layer()->crs(), mCanvas->mapSettings().destinationCrs(), QgsProject::instance() );
396399
std::unique_ptr<QgsRectangle> bbox;
397-
QModelIndexList indexList = selected.indexes();
398-
for ( int i = 0; i < indexList.length(); ++i )
400+
const QModelIndexList indexList = mTableView->selectionModel()->selectedRows();
401+
for ( const QModelIndex &index : indexList )
399402
{
400-
int vertexIdx = indexList.at( i ).row();
403+
int vertexIdx = index.row();
401404
mLockedFeature->selectVertex( vertexIdx );
402405

403406
// create a bounding box of selected vertices
@@ -425,6 +428,7 @@ void QgsVertexEditor::updateVertexSelection( const QItemSelection &selected, con
425428
}
426429

427430
mUpdatingVertexSelection = false;
431+
connect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
428432
}
429433

430434
void QgsVertexEditor::keyPressEvent( QKeyEvent *e )

src/app/vertextool/qgsvertexeditor.h

Lines changed: 2 additions & 4 deletions
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

Lines changed: 0 additions & 3 deletions
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)