Skip to content
Permalink
Browse files

fix updating vertex selection

  • Loading branch information
3nids committed Feb 25, 2019
1 parent 06f92d2 commit 77fa229b7b606f7d308a4b08de03775feb2f98e4
@@ -13,8 +13,8 @@
* *
***************************************************************************/

#include "vertextool/qgslockedfeature.h"
#include "vertextool/qgsvertexentry.h"
#include "qgslockedfeature.h"
#include "qgsvertexeditor.h"

#include "qgsfeatureiterator.h"
#include "qgspoint.h"
@@ -283,7 +283,7 @@ void QgsLockedFeature::selectVertex( int vertexNr )
return;

QgsVertexEntry *entry = mVertexMap.at( vertexNr );
entry->setSelected();
entry->setSelected( true );

emit selectionChanged();
}
@@ -374,30 +374,33 @@ void QgsVertexEditor::updateTableSelection()
}
}
disconnect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
disconnect( mTableView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QgsVertexEditor::updateVertexSelection );
mTableView->selectionModel()->select( selection, QItemSelectionModel::ClearAndSelect );
connect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
connect( mTableView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QgsVertexEditor::updateVertexSelection );

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

mUpdatingTableSelection = false;
}

void QgsVertexEditor::updateVertexSelection( const QItemSelection &selected, const QItemSelection & )
void QgsVertexEditor::updateVertexSelection( const QItemSelection &, const QItemSelection & )
{
if ( !mLockedFeature || mUpdatingTableSelection )
return;

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

mLockedFeature->deselectAllVertices();

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

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

mUpdatingVertexSelection = false;
connect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
}

void QgsVertexEditor::keyPressEvent( QKeyEvent *e )
@@ -81,15 +81,13 @@ 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 updateVertexSelection( const QItemSelection &selected, const QItemSelection &deselected );
void updateTableSelection();
void updateVertexSelection( const QItemSelection &, const QItemSelection &deselected );

private:

@@ -2328,9 +2328,6 @@ void QgsVertexTool::setHighlightedVertices( const QList<Vertex> &listVertices, H
mLockedFeature->selectVertex( vertex.vertexId );
}

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

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

0 comments on commit 77fa229

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