Skip to content

Commit 3e7d781

Browse files
committed
use bool variables instead of connecting/disconnecting signals
also move simple QgsVertexEntry to qgsvertexeditor.h
1 parent 643a763 commit 3e7d781

7 files changed

Lines changed: 41 additions & 103 deletions

File tree

‎src/app/CMakeLists.txt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ SET(QGIS_APP_SRCS
126126
decorations/qgsdecorationgriddialog.cpp
127127

128128
vertextool/qgslockedfeature.cpp
129-
vertextool/qgsvertexentry.cpp
130129
vertextool/qgsvertexeditor.cpp
131130
vertextool/qgsvertextool.cpp
132131

‎src/app/vertextool/qgslockedfeature.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
#ifndef QGSLOCKEDFEATURE_H
1717
#define QGSLOCKEDFEATURE_H
1818

19+
#include <QObject>
20+
1921
#include "qgsgeometry.h"
2022
#include "qgsfeatureid.h"
2123

22-
#include <QObject>
23-
2424
class QgsMapCanvas;
2525
class QgsVectorLayer;
2626
class QgsMapLayer;

‎src/app/vertextool/qgsvertexeditor.cpp‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "qgsmapcanvas.h"
2121
#include "qgsmessagelog.h"
2222
#include "qgslockedfeature.h"
23-
#include "qgsvertexentry.h"
2423
#include "qgsvectorlayer.h"
2524
#include "qgsgeometryutils.h"
2625
#include "qgsproject.h"
@@ -379,7 +378,7 @@ void QgsVertexEditor::updateEditor( QgsLockedFeature *lockedFeature )
379378

380379
void QgsVertexEditor::updateTableSelection()
381380
{
382-
if ( !mLockedFeature || mUpdatingVertexSelection )
381+
if ( !mLockedFeature || mUpdatingVertexSelection || mUpdatingTableSelection )
383382
return;
384383

385384
mUpdatingTableSelection = true;
@@ -395,11 +394,7 @@ void QgsVertexEditor::updateTableSelection()
395394
selection.select( mVertexModel->index( i, 0 ), mVertexModel->index( i, mVertexModel->columnCount() - 1 ) );
396395
}
397396
}
398-
disconnect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
399-
disconnect( mTableView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QgsVertexEditor::updateVertexSelection );
400397
mTableView->selectionModel()->select( selection, QItemSelectionModel::ClearAndSelect );
401-
connect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
402-
connect( mTableView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QgsVertexEditor::updateVertexSelection );
403398

404399
if ( firstSelectedRow >= 0 )
405400
mTableView->scrollTo( mVertexModel->index( firstSelectedRow, 0 ), QAbstractItemView::PositionAtTop );
@@ -409,11 +404,10 @@ void QgsVertexEditor::updateTableSelection()
409404

410405
void QgsVertexEditor::updateVertexSelection( const QItemSelection &, const QItemSelection & )
411406
{
412-
if ( !mLockedFeature || mUpdatingTableSelection )
407+
if ( !mLockedFeature || mUpdatingVertexSelection || mUpdatingTableSelection )
413408
return;
414409

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

418412
mLockedFeature->deselectAllVertices();
419413

@@ -450,7 +444,6 @@ void QgsVertexEditor::updateVertexSelection( const QItemSelection &, const QItem
450444
}
451445

452446
mUpdatingVertexSelection = false;
453-
connect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
454447
}
455448

456449
void QgsVertexEditor::keyPressEvent( QKeyEvent *e )
@@ -504,3 +497,5 @@ void CoordinateItemDelegate::setModelData( QWidget *editor, QAbstractItemModel *
504497
QStyledItemDelegate::setModelData( editor, model, index );
505498
}
506499
}
500+
501+

‎src/app/vertextool/qgsvertexeditor.h‎

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,48 @@
1919
#ifndef QGSVERTEXEDITOR_H
2020
#define QGSVERTEXEDITOR_H
2121

22-
#include "qgsdockwidget.h"
2322
#include <QAbstractTableModel>
2423
#include <QItemSelection>
2524
#include <QStyledItemDelegate>
2625

26+
#include "qgis_app.h"
27+
#include "qgsdockwidget.h"
28+
#include "qgspoint.h"
29+
30+
class QLabel;
31+
class QTableView;
32+
2733
class QgsMapCanvas;
2834
class QgsLockedFeature;
2935
class QgsVectorLayer;
3036

31-
class QLabel;
32-
class QTableView;
3337

34-
class QgsVertexEditorModel : public QAbstractTableModel
38+
class APP_EXPORT QgsVertexEntry
39+
{
40+
public:
41+
QgsVertexEntry( const QgsPoint &p,
42+
QgsVertexId vertexId )
43+
: mSelected( false )
44+
, mPoint( p )
45+
, mVertexId( vertexId )
46+
{
47+
}
48+
49+
QgsVertexEntry( const QgsVertexEntry &rh ) = delete;
50+
QgsVertexEntry &operator=( const QgsVertexEntry &rh ) = delete;
51+
52+
const QgsPoint &point() const { return mPoint; }
53+
QgsVertexId vertexId() const { return mVertexId; }
54+
bool isSelected() const { return mSelected; }
55+
void setSelected( bool selected ) { mSelected = selected; }
56+
57+
private:
58+
bool mSelected;
59+
QgsPoint mPoint;
60+
QgsVertexId mVertexId;
61+
};
62+
63+
class APP_EXPORT QgsVertexEditorModel : public QAbstractTableModel
3564
{
3665
Q_OBJECT
3766
public:
@@ -65,7 +94,7 @@ class QgsVertexEditorModel : public QAbstractTableModel
6594

6695
};
6796

68-
class QgsVertexEditor : public QgsDockWidget
97+
class APP_EXPORT QgsVertexEditor : public QgsDockWidget
6998
{
7099
Q_OBJECT
71100
public:
@@ -98,7 +127,7 @@ class QgsVertexEditor : public QgsDockWidget
98127
};
99128

100129

101-
class CoordinateItemDelegate : public QStyledItemDelegate
130+
class APP_EXPORT CoordinateItemDelegate : public QStyledItemDelegate
102131
{
103132
Q_OBJECT
104133

‎src/app/vertextool/qgsvertexentry.cpp‎

Lines changed: 0 additions & 37 deletions
This file was deleted.

‎src/app/vertextool/qgsvertexentry.h‎

Lines changed: 0 additions & 47 deletions
This file was deleted.

‎src/app/vertextool/qgsvertextool.cpp‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#include "qgisapp.h"
3838
#include "qgslockedfeature.h"
3939
#include "qgsvertexeditor.h"
40-
#include "qgsvertexentry.h"
4140
#include "qgsmapmouseevent.h"
4241

4342
#include <QMenu>

0 commit comments

Comments
 (0)