Skip to content

Commit f7ef54e

Browse files
committed
only select vertices from locked feature again
1 parent 9750868 commit f7ef54e

File tree

3 files changed

+16
-30
lines changed

3 files changed

+16
-30
lines changed

src/app/vertextool/qgsvertexeditor.cpp

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -363,28 +363,12 @@ void QgsVertexEditor::updateEditor( QgsLockedFeature *lockedFeature )
363363

364364
updateTableSelection();
365365

366-
// QItemSelectionModel *selectionModel = mTableView->selectionModel();
367-
// QItemSelection selection;
368-
// if ( mLockedFeature )
369-
// {
370-
// QList<QgsVertexEntry *> &vertexMap = mLockedFeature->vertexMap();
371-
// for ( int i = 0, n = vertexMap.size(); i < n; ++i )
372-
// {
373-
// if ( vertexMap[i]->isSelected() )
374-
// {
375-
// QModelIndex index = mVertexModel->index( i, 0 );
376-
// selection.select( index, index );
377-
// }
378-
// }
379-
// }
380-
// selectionModel->select( selection, QItemSelectionModel::ClearAndSelect );
381-
382366
if ( mLockedFeature )
383367
{
384368
mHintLabel->setVisible( false );
385369
mTableView->setVisible( true );
386370

387-
connect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
371+
//connect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
388372
}
389373
else
390374
{
@@ -399,7 +383,6 @@ void QgsVertexEditor::updateTableSelection()
399383
return;
400384

401385
mUpdatingTableSelection = true;
402-
mTableView->selectionModel()->clearSelection();
403386
const QList<QgsVertexEntry *> &vertexMap = mLockedFeature->vertexMap();
404387
int firstSelectedRow = -1;
405388
QItemSelection selection;
@@ -412,7 +395,9 @@ void QgsVertexEditor::updateTableSelection()
412395
selection.select( mVertexModel->index( i, 0 ), mVertexModel->index( i, mVertexModel->columnCount() - 1 ) );
413396
}
414397
}
415-
mTableView->selectionModel()->select( selection, QItemSelectionModel::Select );
398+
//disconnect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
399+
mTableView->selectionModel()->select( selection, QItemSelectionModel::ClearAndSelect );
400+
//connect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
416401

417402
if ( firstSelectedRow >= 0 )
418403
mTableView->scrollTo( mVertexModel->index( firstSelectedRow, 0 ), QAbstractItemView::PositionAtTop );

src/app/vertextool/qgsvertexeditor.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ class QgsVertexEditor : public QgsDockWidget
7171
public:
7272
QgsVertexEditor( QgsMapCanvas *canvas );
7373

74-
public:
7574
void updateEditor( QgsLockedFeature *lockedFeature );
7675
QgsLockedFeature *mLockedFeature = nullptr;
7776
QgsMapCanvas *mCanvas = nullptr;
@@ -82,12 +81,14 @@ class QgsVertexEditor : public QgsDockWidget
8281
void deleteSelectedRequested();
8382
void editorClosed();
8483

84+
public slots:
85+
void updateTableSelection();
86+
8587
protected:
8688
void keyPressEvent( QKeyEvent *event ) override;
8789
void closeEvent( QCloseEvent *event ) override;
8890

8991
private slots:
90-
void updateTableSelection();
9192
void updateVertexSelection( const QItemSelection &selected, const QItemSelection &deselected );
9293

9394
private:

src/app/vertextool/qgsvertextool.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -994,12 +994,12 @@ void QgsVertexTool::tryToSelectFeature( QgsMapMouseEvent *e )
994994
{
995995
// there's really nothing under the cursor or while cycling through the list of available features
996996
// we got to the end of the list - let's deselect any feature we may have had selected
997+
setHighlightedVertices( QList<Vertex>(), ModeReset );
997998
mLockedFeature.reset();
998999
if ( mVertexEditor )
9991000
{
10001001
mVertexEditor->updateEditor( nullptr );
10011002
}
1002-
setHighlightedVertices( QList<Vertex>(), ModeReset );
10031003
}
10041004

10051005
// we have either locked ourselves to a feature or unlocked again
@@ -1396,10 +1396,7 @@ void QgsVertexTool::lockedFeatureSelectionChanged()
13961396
}
13971397
}
13981398

1399-
disconnect( mLockedFeature.get(), &QgsLockedFeature::selectionChanged, this, &QgsVertexTool::lockedFeatureSelectionChanged );
14001399
setHighlightedVertices( vertices, ModeReset );
1401-
connect( mLockedFeature.get(), &QgsLockedFeature::selectionChanged, this, &QgsVertexTool::lockedFeatureSelectionChanged );
1402-
14031400
}
14041401

14051402
static int _firstSelectedVertex( QgsLockedFeature &selectedFeature )
@@ -2321,14 +2318,17 @@ void QgsVertexTool::setHighlightedVertices( const QList<Vertex> &listVertices, H
23212318

23222319
if ( mLockedFeature )
23232320
{
2321+
disconnect( mLockedFeature.get(), &QgsLockedFeature::selectionChanged, this, &QgsVertexTool::lockedFeatureSelectionChanged );
23242322
for ( const Vertex &vertex : qgis::as_const( mSelectedVertices ) )
23252323
{
2326-
if ( mLockedFeature->featureId() != vertex.fid || mLockedFeature->layer() != vertex.layer )
2327-
continue;
2328-
2329-
if ( mVertexEditor )
2330-
mVertexEditor->updateEditor( mLockedFeature.get() );
2324+
// we should never be able to select vertices that are not from the locked feature
2325+
Q_ASSERT( mLockedFeature->featureId() == vertex.fid && mLockedFeature->layer() == vertex.layer );
2326+
mLockedFeature->selectVertex( vertex.vertexId );
23312327
}
2328+
connect( mLockedFeature.get(), &QgsLockedFeature::selectionChanged, this, &QgsVertexTool::lockedFeatureSelectionChanged );
2329+
2330+
if ( mVertexEditor )
2331+
mVertexEditor->updateTableSelection();
23322332
}
23332333
}
23342334

0 commit comments

Comments
 (0)