diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-08-19 20:59:34 -0500 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-08-19 21:18:26 -0500 |
commit | f7119bdccfb2c8777d96a53b3f389cd31d605f2d (patch) | |
tree | d9a604c0013190dda4e9067b60255d6cac5e19f3 /qt-ui/profile | |
parent | d45a991460e3ae95144c240d5d90ec574e0f6e1b (diff) | |
download | subsurface-f7119bdccfb2c8777d96a53b3f389cd31d605f2d.tar.gz |
Planner: make sure no old handles are around when entering Add/Plan
In some cases we don't appear to remove all of the old handles from the
scene and end up showing a handle from a previous instance of the planner
in the upper right corner of the profile.
This patch makes sure that we remove any stray handles that might still be
around before entereing plan or add mode.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile')
-rw-r--r-- | qt-ui/profile/profilewidget2.cpp | 12 | ||||
-rw-r--r-- | qt-ui/profile/profilewidget2.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 409328918..7a5722082 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -854,12 +854,23 @@ void ProfileWidget2::setProfileState() mouseFollowerVertical->setVisible(false); } +void ProfileWidget2::clearHandlers() +{ + if (handles.count()) { + foreach (DiveHandler *handle, handles) { + scene()->removeItem(handle); + } + handles.clear(); + } +} + void ProfileWidget2::setAddState() { if (currentState == ADD) return; setProfileState(); + clearHandlers(); mouseFollowerHorizontal->setVisible(true); mouseFollowerVertical->setVisible(true); mouseFollowerHorizontal->setLine(timeAxis->line()); @@ -893,6 +904,7 @@ void ProfileWidget2::setPlanState() return; setProfileState(); + clearHandlers(); mouseFollowerHorizontal->setVisible(true); mouseFollowerVertical->setVisible(true); mouseFollowerHorizontal->setLine(timeAxis->line()); diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h index fa5e53e26..dc08be3d7 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/qt-ui/profile/profilewidget2.h @@ -175,6 +175,7 @@ private: QList<DivePictureItem*> pictures; void repositionDiveHandlers(); int fixHandlerIndex(DiveHandler *activeHandler); + void clearHandlers(); friend class DiveHandler; QHash<Qt::Key, QAction *> actionsForKeys; bool shouldCalculateMaxTime; |