summaryrefslogtreecommitdiffstats
path: root/qt-ui/mainwindow.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-08-19 15:03:53 -0500
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-08-19 21:17:52 -0500
commita85a219df3250e9a4c4336ea4b6f4a59f4ee9963 (patch)
treef3fb6dbf29a50db233489127b04e7eb6938e99ad /qt-ui/mainwindow.cpp
parent76f3c0f028b2eb83fb8cc01cd60488f79752b799 (diff)
downloadsubsurface-a85a219df3250e9a4c4336ea4b6f4a59f4ee9963.tar.gz
Add ability to replan a dive that we planned before
When doing this, all waypoints of the calculated ascent are now waypoints in the plan - so the user has to remove the ascent part of the dive in order to really replan the dive. That's a pain, but we don't keep the data around that would tell us which waypoints are user input and which ones were calculated. Fixes #527 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/mainwindow.cpp')
-rw-r--r--qt-ui/mainwindow.cpp37
1 files changed, 31 insertions, 6 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 74015c73f..92cc67f8f 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -404,11 +404,13 @@ void MainWindow::planCanceled()
void MainWindow::planCreated()
{
// get the new dive selected and assign a number if reasonable
- dive_list()->unselectDives();
- select_dive(dive_table.nr - 1);
- dive_list()->selectDive(selected_dive);
- set_dive_nr_for_current_dive();
-
+ if (displayed_dive.id == 0) {
+ // we might have added a new dive (so displayed_dive was cleared out by clone_dive()
+ dive_list()->unselectDives();
+ select_dive(dive_table.nr - 1);
+ dive_list()->selectDive(selected_dive);
+ set_dive_nr_for_current_dive();
+ }
showProfile();
refreshDisplay();
}
@@ -448,9 +450,32 @@ void MainWindow::setupForAddAndPlan(const char *model)
DivePlannerPointsModel::instance()->setupCylinders();
}
+void MainWindow::on_actionReplanDive_triggered()
+{
+ if (!plannerStateClean())
+ return;
+ if (!current_dive || strcmp(current_dive->dc.model, "planned dive")) {
+ qDebug() << current_dive->dc.model;
+ return;
+ }
+ ui.ListWidget->endSearch();
+ // put us in PLAN mode
+ DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
+
+ ui.newProfile->setPlanState();
+ ui.infoPane->setCurrentIndex(PLANNERWIDGET);
+ DivePlannerPointsModel::instance()->loadFromDive(current_dive);
+ reset_cylinders(&displayed_dive, true);
+ ui.diveListPane->setCurrentIndex(1); // switch to the plan output
+ ui.globePane->setCurrentIndex(1);
+#ifdef NO_MARBLE
+ ui.globePane->show();
+#endif
+}
+
void MainWindow::on_actionDivePlanner_triggered()
{
- if(!plannerStateClean())
+ if (!plannerStateClean())
return;
ui.ListWidget->endSearch();