Skip to content
Permalink
Browse files

use bool variables instead of connecting/disconnecting signals

also move simple QgsVertexEntry to qgsvertexeditor.h
  • Loading branch information
3nids committed Feb 23, 2019
1 parent 4c1f08c commit 57ac4e67c9121efae4b2d57e5ad1b2aeaa0f1b60
@@ -126,7 +126,6 @@ SET(QGIS_APP_SRCS
decorations/qgsdecorationgriddialog.cpp

vertextool/qgslockedfeature.cpp
vertextool/qgsvertexentry.cpp
vertextool/qgsvertexeditor.cpp
vertextool/qgsvertextool.cpp

@@ -16,11 +16,11 @@
#ifndef QGSLOCKEDFEATURE_H
#define QGSLOCKEDFEATURE_H

#include <QObject>

#include "qgsgeometry.h"
#include "qgsfeatureid.h"

#include <QObject>

class QgsMapCanvas;
class QgsVectorLayer;
class QgsMapLayer;
@@ -20,7 +20,6 @@
#include "qgsmapcanvas.h"
#include "qgsmessagelog.h"
#include "qgslockedfeature.h"
#include "qgsvertexentry.h"
#include "qgsvectorlayer.h"
#include "qgsgeometryutils.h"
#include "qgsproject.h"
@@ -357,7 +356,7 @@ void QgsVertexEditor::updateEditor( QgsLockedFeature *lockedFeature )

void QgsVertexEditor::updateTableSelection()
{
if ( !mLockedFeature || mUpdatingVertexSelection )
if ( !mLockedFeature || mUpdatingVertexSelection || mUpdatingTableSelection )
return;

mUpdatingTableSelection = true;
@@ -373,11 +372,7 @@ void QgsVertexEditor::updateTableSelection()
selection.select( mVertexModel->index( i, 0 ), mVertexModel->index( i, mVertexModel->columnCount() - 1 ) );
}
}
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 );
@@ -387,11 +382,10 @@ void QgsVertexEditor::updateTableSelection()

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

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

mLockedFeature->deselectAllVertices();

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

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

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


@@ -19,19 +19,48 @@
#ifndef QGSVERTEXEDITOR_H
#define QGSVERTEXEDITOR_H

#include "qgsdockwidget.h"
#include <QAbstractTableModel>
#include <QItemSelection>
#include <QStyledItemDelegate>

#include "qgis_app.h"
#include "qgsdockwidget.h"
#include "qgspoint.h"

class QLabel;
class QTableView;

class QgsMapCanvas;
class QgsLockedFeature;
class QgsVectorLayer;

class QLabel;
class QTableView;

class QgsVertexEditorModel : public QAbstractTableModel
class APP_EXPORT QgsVertexEntry
{
public:
QgsVertexEntry( const QgsPoint &p,
QgsVertexId vertexId )
: mSelected( false )
, mPoint( p )
, mVertexId( vertexId )
{
}

QgsVertexEntry( const QgsVertexEntry &rh ) = delete;
QgsVertexEntry &operator=( const QgsVertexEntry &rh ) = delete;

const QgsPoint &point() const { return mPoint; }
QgsVertexId vertexId() const { return mVertexId; }
bool isSelected() const { return mSelected; }
void setSelected( bool selected ) { mSelected = selected; }

private:
bool mSelected;
QgsPoint mPoint;
QgsVertexId mVertexId;
};

class APP_EXPORT QgsVertexEditorModel : public QAbstractTableModel
{
Q_OBJECT
public:
@@ -65,7 +94,7 @@ class QgsVertexEditorModel : public QAbstractTableModel

};

class QgsVertexEditor : public QgsDockWidget
class APP_EXPORT QgsVertexEditor : public QgsDockWidget
{
Q_OBJECT
public:
@@ -98,7 +127,7 @@ class QgsVertexEditor : public QgsDockWidget
};


class CoordinateItemDelegate : public QStyledItemDelegate
class APP_EXPORT CoordinateItemDelegate : public QStyledItemDelegate
{
Q_OBJECT

This file was deleted.

This file was deleted.

@@ -37,7 +37,6 @@
#include "qgisapp.h"
#include "qgslockedfeature.h"
#include "qgsvertexeditor.h"
#include "qgsvertexentry.h"
#include "qgsmapmouseevent.h"

#include <QMenu>

0 comments on commit 57ac4e6

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