Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix updating vertex selection
  • Loading branch information
3nids committed Feb 25, 2019
1 parent 06f92d2 commit 77fa229
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/app/vertextool/qgslockedfeature.cpp
Expand Up @@ -13,8 +13,8 @@
* *
***************************************************************************/

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

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

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

emit selectionChanged();
}
Expand Down
12 changes: 8 additions & 4 deletions src/app/vertextool/qgsvertexeditor.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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 )
Expand Down
6 changes: 2 additions & 4 deletions src/app/vertextool/qgsvertexeditor.h
Expand Up @@ -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:

Expand Down
3 changes: 0 additions & 3 deletions src/app/vertextool/qgsvertextool.cpp
Expand Up @@ -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 );
}
}
Expand Down

0 comments on commit 77fa229

Please sign in to comment.