Skip to content
Permalink
Browse files

synchronize selection from the editor to the tool

  • Loading branch information
3nids committed Feb 21, 2019
1 parent dcb2bea commit 9a08a7dcf856ccbe2b818d47dbc669e1069c3ef6
@@ -361,6 +361,24 @@ void QgsVertexEditor::updateEditor( QgsLockedFeature *lockedFeature )

mVertexModel->setFeature( mLockedFeature );

updateTableSelection();

// QItemSelectionModel *selectionModel = mTableView->selectionModel();
// QItemSelection selection;
// if ( mLockedFeature )
// {
// QList<QgsVertexEntry *> &vertexMap = mLockedFeature->vertexMap();
// for ( int i = 0, n = vertexMap.size(); i < n; ++i )
// {
// if ( vertexMap[i]->isSelected() )
// {
// QModelIndex index = mVertexModel->index( i, 0 );
// selection.select( index, index );
// }
// }
// }
// selectionModel->select( selection, QItemSelectionModel::ClearAndSelect );

if ( mLockedFeature )
{
mHintLabel->setVisible( false );
@@ -1337,6 +1337,8 @@ void QgsVertexTool::updateVertexEditor( QgsVectorLayer *layer, QgsFeatureId fid
mLockedFeature->selectVertex( mSelectedVertices.at( i ).vertexId );
}
}

connect( mLockedFeature.get(), &QgsLockedFeature::selectionChanged, this, &QgsVertexTool::lockedFeatureSelectionChanged );
}

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

void QgsVertexTool::lockedFeatureSelectionChanged()
{
Q_ASSERT( mLockedFeature );
QList<QgsVertexEntry *> &vertexMap = mLockedFeature->vertexMap();
QList<Vertex> vertices;
for ( int i = 0, n = vertexMap.size(); i < n; ++i )
{
if ( vertexMap[i]->isSelected() )
{
vertices << Vertex( mLockedFeature->layer(), mLockedFeature->featureId(), i );
}
}

disconnect( mLockedFeature.get(), &QgsLockedFeature::selectionChanged, this, &QgsVertexTool::lockedFeatureSelectionChanged );
setHighlightedVertices( vertices, ModeReset );
connect( mLockedFeature.get(), &QgsLockedFeature::selectionChanged, this, &QgsVertexTool::lockedFeatureSelectionChanged );

}

static int _firstSelectedVertex( QgsLockedFeature &selectedFeature )
{
QList<QgsVertexEntry *> &vertexMap = selectedFeature.vertexMap();
@@ -2288,6 +2309,18 @@ void QgsVertexTool::setHighlightedVertices( const QList<Vertex> &listVertices, H
createMarkerForVertex( vertex );
}
}

if ( mLockedFeature )
{
for ( const Vertex &vertex : qgis::as_const( mSelectedVertices ) )
{
if ( mLockedFeature->featureId() != vertex.fid || mLockedFeature->layer() != vertex.layer )
continue;

if ( mVertexEditor )
mVertexEditor->updateEditor( mLockedFeature.get() );
}
}
}

void QgsVertexTool::setHighlightedVerticesVisible( bool visible )
@@ -65,7 +65,8 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing
public:

enum VertexToolMode

{
ActiveLayer,
AllLayers
};
Q_ENUM( VertexToolMode )
@@ -116,6 +117,8 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing

void cleanEditor( QgsFeatureId id );

void lockedFeatureSelectionChanged();

private:

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

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

// support for validation of geometries

0 comments on commit 9a08a7d

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