diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-06-20 18:25:03 -0300 |
---|---|---|
committer | Tomaz Canabrava <tcanabrava@kde.org> | 2013-06-20 18:25:03 -0300 |
commit | 8fcd465a65546efd6dd90c6e4d29ff4e93d7dbe8 (patch) | |
tree | befcc9980eaf63efdf8454b1b0a5ce06e820edda | |
parent | 0539a5fab67a83da223425e6fcbf2d8775be90e3 (diff) | |
download | subsurface-8fcd465a65546efd6dd90c6e4d29ff4e93d7dbe8.tar.gz |
Make skeleton of 'create_deco_stop'.
This is a skeleton of 'create_deco_stop' plus a bit of
code cleanup. I'v commented the create_deco_stop so that
the other developers can help me a bit here - since I don't
know too well the internals of subsurface. In the original
GTK code - a new dive was created every time a user changed
something on the dive, I don't know if this will be needed,
I jusst need two things: the correct time of dive calculated
by the app, and the points to put the decompression lines.
The usability of the widget right now is 'ok', nothing to
be proud of, it's ugly as hell too, and the Rules are in
the wrong position ( they are 'inside' the area where
the lines are being drawn, but htis is easily fixable. )
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
-rw-r--r-- | qt-ui/diveplanner.cpp | 49 | ||||
-rw-r--r-- | qt-ui/diveplanner.h | 5 |
2 files changed, 36 insertions, 18 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 4d9aefcb1..28a5b5590 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -82,18 +82,8 @@ void DivePlanner::mouseDoubleClickEvent(QMouseEvent* event) scene()->addItem(line); create_deco_stop(); } - item->setTime(timeLine->valueAt(mappedPos)); - item->setDepth(depthLine->valueAt(mappedPos)); -} - -void DiveHandler::setDepth(qreal d) -{ - depth = d; -} - -void DiveHandler::setTime(qreal t) -{ - time =t; + item->time = (timeLine->valueAt(mappedPos)); + item->depth = (depthLine->valueAt(mappedPos)); } void DivePlanner::clear_generated_deco() @@ -107,6 +97,30 @@ void DivePlanner::clear_generated_deco() void DivePlanner::create_deco_stop() { + // This needs to be done in the following steps: + // Get the user-input and calculate the dive info + Q_FOREACH(DiveHandler *h, handles){ + // use this somewhere. + h->time; + h->depth; + } + // create the dive info here. + + // set the new 'end time' of the dive. + // note that this is not the user end, + // but the real end of the dive. + timeLine->setMaximum(60); + 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)); + } + + // Create all 'deco' GraphicsLineItems and put it on the canvas.This following three lines will + // most probably need to enter on a loop. QGraphicsLineItem *item = new QGraphicsLineItem(handles.last()->x(), handles.last()->y(), 100, 0); scene()->addItem(item); lines << item; @@ -222,8 +236,8 @@ void DivePlanner::mouseReleaseEvent(QMouseEvent* event) { if (activeDraggedHandler){ QPointF mappedPos = mapToScene(event->pos()); - activeDraggedHandler->setTime(timeLine->valueAt(mappedPos)); - activeDraggedHandler->setDepth(depthLine->valueAt(mappedPos)); + activeDraggedHandler->time = (timeLine->valueAt(mappedPos)); + activeDraggedHandler->depth = (depthLine->valueAt(mappedPos)); activeDraggedHandler->setBrush(QBrush()); activeDraggedHandler = 0; } @@ -284,3 +298,10 @@ qreal Ruler::valueAt(const QPointF& p) ? max * (p.x() - m.x1()) / (m.x2() - m.x1()) : max * (p.y() - m.y1()) / (m.y2() - m.y1()); } + +qreal Ruler::posAtValue(qreal value) +{ + QLineF m = line(); + // I need to finish this later. hungry as hell. + +} diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 0e7f6f4b2..ac0d7ebd9 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -7,12 +7,8 @@ class DiveHandler : public QGraphicsEllipseItem{ public: DiveHandler(); - void setTime(qreal t); - void setDepth(qreal d); - QGraphicsLineItem *from; QGraphicsLineItem *to; -private: qreal time; qreal depth; }; @@ -26,6 +22,7 @@ public: void setOrientation(Qt::Orientation orientation); void updateTicks(); qreal valueAt(const QPointF& p); + qreal posAtValue(qreal value); private: Qt::Orientation orientation; |