aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-06-20 17:34:42 -0300
committerGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-06-20 17:34:42 -0300
commit2d683b66a8a7d514c8cd766303832876ccbab9bb (patch)
tree7373aa8d921f20909b0b912e57e975d09a439270 /qt-ui
parentf129024fc7ad17638cfa9fc7c3948dbc791bd4ca (diff)
downloadsubsurface-2d683b66a8a7d514c8cd766303832876ccbab9bb.tar.gz
Added the code to set the Depth / Time on the user Handlers.
Added the code to set the Depth / Time on the user handlers, I think this finishes the difficult part. ( well, not really ) the depth and time is being set when handler is added or moved, but as soon as the deco calculations enters on the code, the handlers will need to be repositioned - and this code is not ready yet. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/diveplanner.cpp26
-rw-r--r--qt-ui/diveplanner.h6
2 files changed, 31 insertions, 1 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 42c3bda80..fa7be75b3 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -74,6 +74,18 @@ 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;
}
void DivePlanner::clear_generated_deco()
@@ -200,8 +212,12 @@ void DivePlanner::mousePressEvent(QMouseEvent* event)
void DivePlanner::mouseReleaseEvent(QMouseEvent* event)
{
- if (activeDraggedHandler)
+ if (activeDraggedHandler){
+ QPointF mappedPos = mapToScene(event->pos());
+ activeDraggedHandler ->setTime(timeLine->valueAt(mappedPos));
+ activeDraggedHandler ->setDepth(depthLine->valueAt(mappedPos));
activeDraggedHandler = 0;
+ }
}
DiveHandler::DiveHandler(): QGraphicsEllipseItem(), from(0), to(0)
@@ -251,3 +267,11 @@ void Ruler::setTickInterval(double i)
{
interval = i;
}
+
+qreal Ruler::valueAt(const QPointF& p)
+{
+ QLineF m = line();
+ return orientation == Qt::Horizontal
+ ? max * (p.x() - m.x1()) / (m.x2() - m.x1())
+ : max * (p.y() - m.y1()) / (m.y2() - m.y1());
+}
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h
index 5557a7b56..f7af25113 100644
--- a/qt-ui/diveplanner.h
+++ b/qt-ui/diveplanner.h
@@ -7,9 +7,14 @@
class DiveHandler : public QGraphicsEllipseItem{
public:
DiveHandler();
+ void setTime(qreal t);
+ void setDepth(qreal d);
QGraphicsLineItem *from;
QGraphicsLineItem *to;
+private:
+ qreal time;
+ qreal depth;
};
class Ruler : public QGraphicsLineItem{
@@ -20,6 +25,7 @@ public:
void setTickInterval(double interval);
void setOrientation(Qt::Orientation orientation);
void updateTicks();
+ qreal valueAt(const QPointF& p);
private:
Qt::Orientation orientation;