diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-05-27 15:02:45 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-27 15:12:41 -0700 |
commit | d1cd1eb933418282942b5cdacd1df46b75729f44 (patch) | |
tree | 002a76eb825cc06a104435a57922cbe70a4d69d9 /qt-ui/mainwindow.cpp | |
parent | 7feea7ccfa48c66f71c260fbb4adab889cd988ce (diff) | |
download | subsurface-d1cd1eb933418282942b5cdacd1df46b75729f44.tar.gz |
Planner: better handle the temporary dive used for planning
This still crashes when you abort the plan.
And when you accept the plan, the profile stays stuck in PLAN mode.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/mainwindow.cpp')
-rw-r--r-- | qt-ui/mainwindow.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 9d8a0643c..8a637ff6b 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -58,7 +58,8 @@ MainWindow::MainWindow() : QMainWindow(), yearlyStats(0), yearlyStatsModel(0), state(VIEWALL), - updateManager(0) + updateManager(0), + fakeDiveId(0) { Q_ASSERT_X(m_Instance == NULL, "MainWindow", "MainWindow recreated!"); m_Instance = this; @@ -372,6 +373,7 @@ void MainWindow::createFakeDiveForAddAndPlan() // now cheat - create one dive that we use to store the info tab data in //TODO: C-function create_temporary_dive ? struct dive *dive = alloc_dive(); + fakeDiveId = dive->id; dive->when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset(); dive->dc.model = "manually added dive"; // don't translate! this is stored in the XML file @@ -386,6 +388,16 @@ void MainWindow::createFakeDiveForAddAndPlan() ui.InfoWidget->updateDiveInfo(selected_dive); } +void MainWindow::removeFakeDiveForAddAndPlan() +{ + int idx; + + if (!fakeDiveId || + (idx = get_idx_by_uniq_id(fakeDiveId)) == dive_table.nr) + return; + delete_single_dive(idx); +} + void MainWindow::on_actionDivePlanner_triggered() { if(!plannerStateClean()) @@ -409,7 +421,8 @@ void MainWindow::on_actionDivePlanner_triggered() createFakeDiveForAddAndPlan(); DivePlannerPointsModel::instance()->createSimpleDive(true); - // disable the dive list + // reload and then disable the dive list + ui.ListWidget->reload(DiveTripModel::CURRENT); ui.ListWidget->setEnabled(false); } |