diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2014-05-21 15:52:24 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-22 09:11:50 +0900 |
commit | 3661f291a4d88448c3339bdd3c2d3ad8c6090256 (patch) | |
tree | 11589481d1430d51548d095389dd63ca1daefbed /qt-ui/profile/profilewidget2.cpp | |
parent | d73fdbc84b2b258f06fa8f2745f85545ef414624 (diff) | |
download | subsurface-3661f291a4d88448c3339bdd3c2d3ad8c6090256.tar.gz |
Enable editing the 'Add dive' from the new profile.
This is highly broken in many ways - but it's the right first step.
I ported two of the most important methods from the old profile and now if
you are in add dive mode, double clicking on the new profile will
correctly add a handler on the planned dive. To see and move the handler
around, however, you need to activate the old planner.
Next step: add the handlers on the new profile.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile/profilewidget2.cpp')
-rw-r--r-- | qt-ui/profile/profilewidget2.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 6b44dff18..f0b7bc380 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -540,6 +540,30 @@ void ProfileWidget2::wheelEvent(QWheelEvent *event) toolTipItem->setPos(mapToScene(toolTipPos)); } +void ProfileWidget2::mouseDoubleClickEvent(QMouseEvent *event) +{ + if (currentState == PLAN || currentState == ADD) { + DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); + QPointF mappedPos = mapToScene(event->pos()); + if (isPointOutOfBoundaries(mappedPos)) + return; + + int minutes = rint(timeAxis->valueAt(mappedPos) / 60); + int milimeters = rint(profileYAxis->valueAt(mappedPos) / M_OR_FT(1, 1)) * M_OR_FT(1, 1); + plannerModel->addStop(milimeters, minutes * 60, -1, 0, 0, true); + } +} + +bool ProfileWidget2::isPointOutOfBoundaries(const QPointF &point) const +{ + double xpos = timeAxis->valueAt(point); + double ypos = profileYAxis->valueAt(point); + return (xpos > timeAxis->maximum() || + xpos < timeAxis->minimum() || + ypos > profileYAxis->maximum() || + ypos < profileYAxis->minimum()); +} + void ProfileWidget2::scrollViewTo(const QPoint &pos) { /* since we cannot use translate() directly on the scene we hack on @@ -672,6 +696,26 @@ void ProfileWidget2::setProfileState() rulerItem->setVisible(prefs.rulergraph); } +void ProfileWidget2::setAddState() +{ + if (currentState == ADD) + return; + + /* show the same stuff that the profile shows. */ + currentState = ADD; /* enable the add state. */ + setBackgroundBrush(QColor(Qt::blue).light()); +} + +void ProfileWidget2::setPlanState() +{ + if (currentState == PLAN) + return; + + /* show the same stuff that the profile shows. */ + currentState = PLAN; /* enable the add state. */ + setBackgroundBrush(QColor(Qt::green).light()); +} + extern struct ev_select *ev_namelist; extern int evn_allocated; extern int evn_used; |