Skip to content
Permalink
Browse files

only select vertices from locked feature again

  • Loading branch information
3nids committed Feb 23, 2019
1 parent b8f1cb3 commit 1d0ca0867fe0644066eacd4e66d8c825562d60aa
@@ -341,28 +341,12 @@ void QgsVertexEditor::updateEditor( QgsLockedFeature *lockedFeature )

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 );
mTableView->setVisible( true );

connect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
//connect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
}
else
{
@@ -377,7 +361,6 @@ void QgsVertexEditor::updateTableSelection()
return;

mUpdatingTableSelection = true;
mTableView->selectionModel()->clearSelection();
const QList<QgsVertexEntry *> &vertexMap = mLockedFeature->vertexMap();
int firstSelectedRow = -1;
QItemSelection selection;
@@ -390,7 +373,9 @@ void QgsVertexEditor::updateTableSelection()
selection.select( mVertexModel->index( i, 0 ), mVertexModel->index( i, mVertexModel->columnCount() - 1 ) );
}
}
mTableView->selectionModel()->select( selection, QItemSelectionModel::Select );
//disconnect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
mTableView->selectionModel()->select( selection, QItemSelectionModel::ClearAndSelect );
//connect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );

if ( firstSelectedRow >= 0 )
mTableView->scrollTo( mVertexModel->index( firstSelectedRow, 0 ), QAbstractItemView::PositionAtTop );
@@ -71,7 +71,6 @@ class QgsVertexEditor : public QgsDockWidget
public:
QgsVertexEditor( QgsMapCanvas *canvas );

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

public slots:
void updateTableSelection();

protected:
void keyPressEvent( QKeyEvent *event ) override;
void closeEvent( QCloseEvent *event ) override;

private slots:
void updateTableSelection();
void updateVertexSelection( const QItemSelection &selected, const QItemSelection &deselected );

private:
@@ -994,12 +994,12 @@ void QgsVertexTool::tryToSelectFeature( QgsMapMouseEvent *e )
{
// there's really nothing under the cursor or while cycling through the list of available features
// we got to the end of the list - let's deselect any feature we may have had selected
setHighlightedVertices( QList<Vertex>(), ModeReset );
mLockedFeature.reset();
if ( mVertexEditor )
{
mVertexEditor->updateEditor( nullptr );
}
setHighlightedVertices( QList<Vertex>(), ModeReset );
}

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

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

}

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

if ( mLockedFeature )
{
disconnect( mLockedFeature.get(), &QgsLockedFeature::selectionChanged, this, &QgsVertexTool::lockedFeatureSelectionChanged );
for ( const Vertex &vertex : qgis::as_const( mSelectedVertices ) )
{
if ( mLockedFeature->featureId() != vertex.fid || mLockedFeature->layer() != vertex.layer )
continue;

if ( mVertexEditor )
mVertexEditor->updateEditor( mLockedFeature.get() );
// we should never be able to select vertices that are not from the locked feature
Q_ASSERT( mLockedFeature->featureId() == vertex.fid && mLockedFeature->layer() == vertex.layer );
mLockedFeature->selectVertex( vertex.vertexId );
}
connect( mLockedFeature.get(), &QgsLockedFeature::selectionChanged, this, &QgsVertexTool::lockedFeatureSelectionChanged );

if ( mVertexEditor )
mVertexEditor->updateTableSelection();
}
}

0 comments on commit 1d0ca08

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