summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-05-21 21:23:19 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-22 14:31:37 +0900
commite249fe870396e18d53939ca37c9391c858a46d8c (patch)
tree21550b26187d1f4575217372384c5e6c7892af5f /qt-ui
parent27afb338062784bb4b1de16c5a468f5208f3891b (diff)
downloadsubsurface-e249fe870396e18d53939ca37c9391c858a46d8c.tar.gz
Disconnect temporary connections on the Profile.
This code adds the disconnections of temporaries. A temporary connection is a connection that should be active only on a certain state, and we need to clean that for the new state that will enter after. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/profile/profilewidget2.cpp16
-rw-r--r--qt-ui/profile/profilewidget2.h4
2 files changed, 19 insertions, 1 deletions
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index bc540fe22..2ece177a7 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -606,6 +606,7 @@ void ProfileWidget2::setEmptyState()
if (currentState == EMPTY)
return;
+ disconnectTemporaryConnections();
setBackgroundBrush(getColor(::BACKGROUND, isGrayscale));
dataModel->clear();
currentState = EMPTY;
@@ -648,6 +649,7 @@ void ProfileWidget2::setProfileState()
return;
}
+ disconnectTemporaryConnections();
currentState = PROFILE;
MainWindow::instance()->setToolButtonsEnabled(true);
toolTipItem->readPos();
@@ -707,6 +709,7 @@ void ProfileWidget2::setAddState()
if (currentState == ADD)
return;
+ disconnectTemporaryConnections();
/* show the same stuff that the profile shows. */
currentState = ADD; /* enable the add state. */
setBackgroundBrush(QColor(Qt::blue).light());
@@ -717,6 +720,7 @@ void ProfileWidget2::setPlanState()
if (currentState == PLAN)
return;
+ disconnectTemporaryConnections();
/* show the same stuff that the profile shows. */
currentState = PLAN; /* enable the add state. */
setBackgroundBrush(QColor(Qt::green).light());
@@ -920,6 +924,18 @@ void ProfileWidget2::editName()
replot();
}
+void ProfileWidget2::disconnectTemporaryConnections()
+{
+ DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
+ disconnect(plannerModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(replot()));
+ disconnect(plannerModel, SIGNAL(cylinderModelEdited()), this, SLOT(replot()));
+
+ disconnect(plannerModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
+ this, SLOT(pointInserted(const QModelIndex &, int, int)));
+ disconnect(plannerModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
+ this, SLOT(pointsRemoved(const QModelIndex &, int, int)));
+}
+
void ProfileWidget2::pointInserted(const QModelIndex &parent, int start, int end)
{
DiveHandler *item = new DiveHandler();
diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h
index 46c1ee0b6..2ba1cd01a 100644
--- a/qt-ui/profile/profilewidget2.h
+++ b/qt-ui/profile/profilewidget2.h
@@ -67,7 +67,6 @@ public:
ProfileWidget2(QWidget *parent = 0);
void plotDives(QList<dive *> dives);
- void replot();
virtual bool eventFilter(QObject *, QEvent *);
void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis, DivePlotDataModel *model, int vData, int hData, int zValue);
void setPrintMode(bool mode, bool grayscale = false);
@@ -90,6 +89,7 @@ slots: // Necessary to call from QAction's signals.
void makeFirstDC();
void pointInserted(const QModelIndex &parent, int start, int end);
void pointsRemoved(const QModelIndex &, int start, int end);
+ void replot();
protected:
virtual void resizeEvent(QResizeEvent *event);
@@ -105,6 +105,8 @@ private: /*methods*/
void setupItemSizes();
void addItemsToScene();
void setupItemOnScene();
+ void disconnectTemporaryConnections();
+
private:
DivePlotDataModel *dataModel;
int zoomLevel;