Skip to content

Commit 21fb442

Browse files
committed
synchronize selection from the editor to the tool
1 parent 5427392 commit 21fb442

File tree

3 files changed

+55
-5
lines changed

3 files changed

+55
-5
lines changed

src/app/vertextool/qgsvertexeditor.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,24 @@ void QgsVertexEditor::updateEditor( QgsLockedFeature *lockedFeature )
339339

340340
mVertexModel->setFeature( mLockedFeature );
341341

342+
updateTableSelection();
343+
344+
// QItemSelectionModel *selectionModel = mTableView->selectionModel();
345+
// QItemSelection selection;
346+
// if ( mLockedFeature )
347+
// {
348+
// QList<QgsVertexEntry *> &vertexMap = mLockedFeature->vertexMap();
349+
// for ( int i = 0, n = vertexMap.size(); i < n; ++i )
350+
// {
351+
// if ( vertexMap[i]->isSelected() )
352+
// {
353+
// QModelIndex index = mVertexModel->index( i, 0 );
354+
// selection.select( index, index );
355+
// }
356+
// }
357+
// }
358+
// selectionModel->select( selection, QItemSelectionModel::ClearAndSelect );
359+
342360
if ( mLockedFeature )
343361
{
344362
mHintLabel->setVisible( false );

src/app/vertextool/qgsvertextool.cpp

+33
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,8 @@ void QgsVertexTool::updateVertexEditor( QgsVectorLayer *layer, QgsFeatureId fid
13371337
mLockedFeature->selectVertex( mSelectedVertices.at( i ).vertexId );
13381338
}
13391339
}
1340+
1341+
connect( mLockedFeature.get(), &QgsLockedFeature::selectionChanged, this, &QgsVertexTool::lockedFeatureSelectionChanged );
13401342
}
13411343

13421344
// make sure the vertex editor is alive and visible
@@ -1372,6 +1374,25 @@ void QgsVertexTool::cleanupVertexEditor()
13721374
mVertexEditor.reset();
13731375
}
13741376

1377+
void QgsVertexTool::lockedFeatureSelectionChanged()
1378+
{
1379+
Q_ASSERT( mLockedFeature );
1380+
QList<QgsVertexEntry *> &vertexMap = mLockedFeature->vertexMap();
1381+
QList<Vertex> vertices;
1382+
for ( int i = 0, n = vertexMap.size(); i < n; ++i )
1383+
{
1384+
if ( vertexMap[i]->isSelected() )
1385+
{
1386+
vertices << Vertex( mLockedFeature->layer(), mLockedFeature->featureId(), i );
1387+
}
1388+
}
1389+
1390+
disconnect( mLockedFeature.get(), &QgsLockedFeature::selectionChanged, this, &QgsVertexTool::lockedFeatureSelectionChanged );
1391+
setHighlightedVertices( vertices, ModeReset );
1392+
connect( mLockedFeature.get(), &QgsLockedFeature::selectionChanged, this, &QgsVertexTool::lockedFeatureSelectionChanged );
1393+
1394+
}
1395+
13751396
static int _firstSelectedVertex( QgsLockedFeature &selectedFeature )
13761397
{
13771398
QList<QgsVertexEntry *> &vertexMap = selectedFeature.vertexMap();
@@ -2288,6 +2309,18 @@ void QgsVertexTool::setHighlightedVertices( const QList<Vertex> &listVertices, H
22882309
createMarkerForVertex( vertex );
22892310
}
22902311
}
2312+
2313+
if ( mLockedFeature )
2314+
{
2315+
for ( const Vertex &vertex : qgis::as_const( mSelectedVertices ) )
2316+
{
2317+
if ( mLockedFeature->featureId() != vertex.fid || mLockedFeature->layer() != vertex.layer )
2318+
continue;
2319+
2320+
if ( mVertexEditor )
2321+
mVertexEditor->updateEditor( mLockedFeature.get() );
2322+
}
2323+
}
22912324
}
22922325

22932326
void QgsVertexTool::setHighlightedVerticesVisible( bool visible )

src/app/vertextool/qgsvertextool.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing
6565
public:
6666

6767
enum VertexToolMode
68-
68+
{
69+
ActiveLayer,
6970
AllLayers
7071
};
7172
Q_ENUM( VertexToolMode )
@@ -116,6 +117,8 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing
116117

117118
void cleanEditor( QgsFeatureId id );
118119

120+
void lockedFeatureSelectionChanged();
121+
119122
private:
120123

121124
void buildDragBandsForVertices( const QSet<Vertex> &movingVertices, const QgsPointXY &dragVertexMapPoint );
@@ -452,11 +455,7 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing
452455
};
453456

454457
//! Keeps information about other possible features to select with right click. Null if no info is currently held.
455-
<<<<<<< HEAD
456458
std::unique_ptr<LockedFeatureAlternatives> mLockedFeatureAlternatives;
457-
=======
458-
std::unique_ptr<SelectedFeatureAlternatives> mLockedFeatureAlternatives;
459-
>>>>>>> remove vertex highlighting from editor
460459

461460
// support for validation of geometries
462461

0 commit comments

Comments
 (0)