diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-06-26 19:14:55 -0300 |
---|---|---|
committer | Tomaz Canabrava <tcanabrava@kde.org> | 2013-06-26 19:14:55 -0300 |
commit | 03572e233dd25b5eef5b977d19c1fd2bd3af6bae (patch) | |
tree | dbfc8738ae87425aeef465521e6519ce97246b57 /qt-ui/diveplanner.cpp | |
parent | f3b04a88dffcda6cbe10be81d5c9613e0ab00c37 (diff) | |
download | subsurface-03572e233dd25b5eef5b977d19c1fd2bd3af6bae.tar.gz |
Remove the bogus time/depth, and fix the positioning of the Handler after updateTicks.
Remove the bogus time/depth that was duplicated in the
Handler - dirk didn't realized that I already created the
same data that he put on it later, but mine was double and
his his was int, I choosed his implementation since he knows
a bit more than I do about subsurface internals.
Besides that, I worked a bit on the logic that called update ticks,
because it was calling it for every mouseMoveEvent, it created
sooooo many ticks that it made the app unusable ( and slow. )
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r-- | qt-ui/diveplanner.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 5b603cfc0..e1396798f 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -106,8 +106,6 @@ void DivePlannerGraphics::mouseDoubleClickEvent(QMouseEvent* event) scene()->addItem(line); createDecoStops(); } - item->time = (timeLine->valueAt(mappedPos)); - item->depth = (depthLine->valueAt(mappedPos)); } void DivePlannerGraphics::clearGeneratedDeco() @@ -162,13 +160,13 @@ void DivePlannerGraphics::createDecoStops() // when we change the maximum and things accelerate from there // BAD // - // timeLine->setMaximum(dp->time / 60.0 + 5); + timeLine->setMaximum(dp->time / 60.0 + 5); + timeLine->updateTicks(); } + // Re-position the user generated dive handlers - Q_FOREACH(DiveHandler *h, handles) { - // uncomment this as soon as the posAtValue is implemented. - // h->setPos(timeLine->posAtValue(h->time), - // depthLine->posAtValue(h->depth)); + Q_FOREACH(DiveHandler *h, handles){ + h->setPos(timeLine->posAtValue(h->sec / 60), depthLine->posAtValue(h->mm) / 1000); } // Create all 'deco' GraphicsLineItems and put it on the canvas. @@ -270,11 +268,6 @@ void DivePlannerGraphics::moveActiveHandler(const QPointF& pos) QLineF f = activeDraggedHandler->to->line(); activeDraggedHandler->to->setLine(newPos.x(), newPos.y(), f.x2(), f.y2()); } - - if (activeDraggedHandler == handles.last()) { - clearGeneratedDeco(); - createDecoStops(); - } activeDraggedHandler->sec = sec; activeDraggedHandler->mm = mm; } @@ -311,9 +304,15 @@ void DivePlannerGraphics::mouseReleaseEvent(QMouseEvent* event) { if (activeDraggedHandler) { QPointF mappedPos = mapToScene(event->pos()); - activeDraggedHandler->time = (timeLine->valueAt(mappedPos)); - activeDraggedHandler->depth = (depthLine->valueAt(mappedPos)); + activeDraggedHandler->sec = rint(timeLine->valueAt(mappedPos)) * 60; + activeDraggedHandler->mm = rint(depthLine->valueAt(mappedPos)) * 1000; activeDraggedHandler->setBrush(QBrush()); + + if (activeDraggedHandler == handles.last()) { + clearGeneratedDeco(); + createDecoStops(); + } + activeDraggedHandler = 0; } } @@ -351,7 +350,6 @@ void Ruler::updateTicks() double stepSize = (m.x2() - m.x1()) / steps; for (qreal pos = m.x1(); pos < m.x2(); pos += stepSize) { ticks.push_back(new QGraphicsLineItem(pos, m.y1(), pos, m.y1() + 1, this)); - } } else { double steps = (max - min) / interval; |