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>
This commit is contained in:
Tomaz Canabrava 2013-06-26 19:14:55 -03:00
parent f3b04a88df
commit 03572e233d
2 changed files with 13 additions and 17 deletions

View file

@ -106,8 +106,6 @@ void DivePlannerGraphics::mouseDoubleClickEvent(QMouseEvent* event)
scene()->addItem(line); scene()->addItem(line);
createDecoStops(); createDecoStops();
} }
item->time = (timeLine->valueAt(mappedPos));
item->depth = (depthLine->valueAt(mappedPos));
} }
void DivePlannerGraphics::clearGeneratedDeco() void DivePlannerGraphics::clearGeneratedDeco()
@ -162,13 +160,13 @@ void DivePlannerGraphics::createDecoStops()
// when we change the maximum and things accelerate from there // when we change the maximum and things accelerate from there
// BAD // BAD
// //
// timeLine->setMaximum(dp->time / 60.0 + 5); timeLine->setMaximum(dp->time / 60.0 + 5);
timeLine->updateTicks();
} }
// Re-position the user generated dive handlers // Re-position the user generated dive handlers
Q_FOREACH(DiveHandler *h, handles){ Q_FOREACH(DiveHandler *h, handles){
// uncomment this as soon as the posAtValue is implemented. h->setPos(timeLine->posAtValue(h->sec / 60), depthLine->posAtValue(h->mm) / 1000);
// h->setPos(timeLine->posAtValue(h->time),
// depthLine->posAtValue(h->depth));
} }
// Create all 'deco' GraphicsLineItems and put it on the canvas. // 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(); QLineF f = activeDraggedHandler->to->line();
activeDraggedHandler->to->setLine(newPos.x(), newPos.y(), f.x2(), f.y2()); activeDraggedHandler->to->setLine(newPos.x(), newPos.y(), f.x2(), f.y2());
} }
if (activeDraggedHandler == handles.last()) {
clearGeneratedDeco();
createDecoStops();
}
activeDraggedHandler->sec = sec; activeDraggedHandler->sec = sec;
activeDraggedHandler->mm = mm; activeDraggedHandler->mm = mm;
} }
@ -311,9 +304,15 @@ void DivePlannerGraphics::mouseReleaseEvent(QMouseEvent* event)
{ {
if (activeDraggedHandler) { if (activeDraggedHandler) {
QPointF mappedPos = mapToScene(event->pos()); QPointF mappedPos = mapToScene(event->pos());
activeDraggedHandler->time = (timeLine->valueAt(mappedPos)); activeDraggedHandler->sec = rint(timeLine->valueAt(mappedPos)) * 60;
activeDraggedHandler->depth = (depthLine->valueAt(mappedPos)); activeDraggedHandler->mm = rint(depthLine->valueAt(mappedPos)) * 1000;
activeDraggedHandler->setBrush(QBrush()); activeDraggedHandler->setBrush(QBrush());
if (activeDraggedHandler == handles.last()) {
clearGeneratedDeco();
createDecoStops();
}
activeDraggedHandler = 0; activeDraggedHandler = 0;
} }
} }
@ -351,7 +350,6 @@ void Ruler::updateTicks()
double stepSize = (m.x2() - m.x1()) / steps; double stepSize = (m.x2() - m.x1()) / steps;
for (qreal pos = m.x1(); pos < m.x2(); pos += stepSize) { for (qreal pos = m.x1(); pos < m.x2(); pos += stepSize) {
ticks.push_back(new QGraphicsLineItem(pos, m.y1(), pos, m.y1() + 1, this)); ticks.push_back(new QGraphicsLineItem(pos, m.y1(), pos, m.y1() + 1, this));
} }
} else { } else {
double steps = (max - min) / interval; double steps = (max - min) / interval;

View file

@ -20,8 +20,6 @@ public:
DiveHandler(); DiveHandler();
QGraphicsLineItem *from; QGraphicsLineItem *from;
QGraphicsLineItem *to; QGraphicsLineItem *to;
qreal time;
qreal depth;
int sec; int sec;
int mm; int mm;
}; };