summaryrefslogtreecommitdiffstats
path: root/qt-ui/profile/profilewidget2.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-05-23 20:51:30 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-24 07:28:39 -0700
commitea4d4ac020319dee0e1d74ff793ef50ab8c47508 (patch)
treefd2562b39c4c4e1f098944f050d3b7c018510ae6 /qt-ui/profile/profilewidget2.cpp
parente1dcd8eac32e2e7d606f5bc82106cde07984b42a (diff)
downloadsubsurface-ea4d4ac020319dee0e1d74ff793ef50ab8c47508.tar.gz
Make the planner actually work.
This commit makes the planner actually work. There ar still a few edges, but oh, joy - the new Profile gave a very unexpected and nice addition to it - Grab the last handler of the initial dive, and move it to the right, or get any handler, and move it to the bottom to see what I mean. 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.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 81ed98619..dd4ecca85 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -964,6 +964,7 @@ void ProfileWidget2::pointInserted(const QModelIndex &parent, int start, int end
scene()->addItem(item);
handles << item;
+ connect(item, SIGNAL(moved()), this, SLOT(recreatePlannedDive()));
QGraphicsSimpleTextItem *gasChooseBtn = new QGraphicsSimpleTextItem();
scene()->addItem(gasChooseBtn);
gasChooseBtn->setZValue(10);
@@ -1007,3 +1008,26 @@ void ProfileWidget2::repositionDiveHandlers()
last = i;
}
}
+
+void ProfileWidget2::recreatePlannedDive()
+{
+ DiveHandler *activeHandler = qobject_cast<DiveHandler*>(sender());
+ DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
+ int index = handles.indexOf(activeHandler);
+
+ int mintime = 0, maxtime = (timeAxis->maximum() + 10) * 60;
+ if (index > 0)
+ mintime = plannerModel->at(index - 1).time;
+ if (index < plannerModel->size() - 1)
+ maxtime = plannerModel->at(index + 1).time;
+
+ int minutes = rint(timeAxis->valueAt(activeHandler->pos()) / 60);
+ if (minutes * 60 <= mintime || minutes * 60 >= maxtime)
+ return;
+
+ divedatapoint data = plannerModel->at(index);
+ data.depth = rint(profileYAxis->valueAt(activeHandler->pos()) / M_OR_FT(1, 1)) * M_OR_FT(1, 1);;
+ data.time = rint(timeAxis->valueAt(activeHandler->pos()));
+
+ plannerModel->editStop(index, data);
+}