Skip to content

Commit 57ac4e6

Browse files
committed
use bool variables instead of connecting/disconnecting signals
also move simple QgsVertexEntry to qgsvertexeditor.h
1 parent 4c1f08c commit 57ac4e6

7 files changed

+41
-103
lines changed

src/app/CMakeLists.txt

-1
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

+2-2
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

+4-9
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"
@@ -357,7 +356,7 @@ void QgsVertexEditor::updateEditor( QgsLockedFeature *lockedFeature )
357356

358357
void QgsVertexEditor::updateTableSelection()
359358
{
360-
if ( !mLockedFeature || mUpdatingVertexSelection )
359+
if ( !mLockedFeature || mUpdatingVertexSelection || mUpdatingTableSelection )
361360
return;
362361

363362
mUpdatingTableSelection = true;
@@ -373,11 +372,7 @@ void QgsVertexEditor::updateTableSelection()
373372
selection.select( mVertexModel->index( i, 0 ), mVertexModel->index( i, mVertexModel->columnCount() - 1 ) );
374373
}
375374
}
376-
disconnect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
377-
disconnect( mTableView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QgsVertexEditor::updateVertexSelection );
378375
mTableView->selectionModel()->select( selection, QItemSelectionModel::ClearAndSelect );
379-
connect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
380-
connect( mTableView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QgsVertexEditor::updateVertexSelection );
381376

382377
if ( firstSelectedRow >= 0 )
383378
mTableView->scrollTo( mVertexModel->index( firstSelectedRow, 0 ), QAbstractItemView::PositionAtTop );
@@ -387,11 +382,10 @@ void QgsVertexEditor::updateTableSelection()
387382

388383
void QgsVertexEditor::updateVertexSelection( const QItemSelection &, const QItemSelection & )
389384
{
390-
if ( !mLockedFeature || mUpdatingTableSelection )
385+
if ( !mLockedFeature || mUpdatingVertexSelection || mUpdatingTableSelection )
391386
return;
392387

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

396390
mLockedFeature->deselectAllVertices();
397391

@@ -428,7 +422,6 @@ void QgsVertexEditor::updateVertexSelection( const QItemSelection &, const QItem
428422
}
429423

430424
mUpdatingVertexSelection = false;
431-
connect( mLockedFeature, &QgsLockedFeature::selectionChanged, this, &QgsVertexEditor::updateTableSelection );
432425
}
433426

434427
void QgsVertexEditor::keyPressEvent( QKeyEvent *e )
@@ -482,3 +475,5 @@ void CoordinateItemDelegate::setModelData( QWidget *editor, QAbstractItemModel *
482475
QStyledItemDelegate::setModelData( editor, model, index );
483476
}
484477
}
478+
479+

src/app/vertextool/qgsvertexeditor.h

+35-6
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

-37
This file was deleted.

src/app/vertextool/qgsvertexentry.h

-47
This file was deleted.

src/app/vertextool/qgsvertextool.cpp

-1
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)