diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-07-04 07:14:16 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-07-04 07:24:52 -0700 |
commit | 3c4439ee27bfb794c69de801caed50353e6719b7 (patch) | |
tree | 468bcff00dc9d9b2d8239cdbfddbf7c2768d9d3e | |
parent | 0cfea5205d54a374170a4a7aeb32641aab00cf90 (diff) | |
download | subsurface-3c4439ee27bfb794c69de801caed50353e6719b7.tar.gz |
UI restructure: simplify setup of add and plan mode
Recreate the helper function (which now does something fairly different)
to share the common code between the two modes.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-ui/mainwindow.cpp | 33 | ||||
-rw-r--r-- | qt-ui/mainwindow.h | 2 |
2 files changed, 16 insertions, 19 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 5be757d47..9efeafa12 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -426,6 +426,18 @@ void MainWindow::printPlan() #endif } +void MainWindow::setupForAddAndPlan(const char *model) +{ + // clean out the dive and give it an id and the correct dc model + clear_dive(&displayed_dive); + displayed_dive.id = dive_getUniqID(&displayed_dive); + displayed_dive.when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset() + 3600; + displayed_dive.dc.model = model; // don't translate! this is stored in the XML file + // setup the dive cylinders + DivePlannerPointsModel::instance()->clear(); + DivePlannerPointsModel::instance()->setupCylinders(); +} + void MainWindow::on_actionDivePlanner_triggered() { if(!plannerStateClean()) @@ -435,19 +447,11 @@ void MainWindow::on_actionDivePlanner_triggered() // put us in PLAN mode DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN); - // clean out the dive and give it an id and the correct dc model - clear_dive(&displayed_dive); - displayed_dive.id = dive_getUniqID(&displayed_dive); - displayed_dive.dc.model = "planned dive"; // don't translate! this is stored in the XML file - ui.newProfile->setPlanState(); ui.infoPane->setCurrentIndex(PLANNERWIDGET); - // setup the staging dive cylinders from the selected dive - DivePlannerPointsModel::instance()->clear(); - DivePlannerPointsModel::instance()->setupCylinders(); - // create a simple starting dive, using the first gas from the just copied cylidners + setupForAddAndPlan("planned dive"); // don't translate, stored in XML file DivePlannerPointsModel::instance()->setupStartTime(); DivePlannerPointsModel::instance()->createSimpleDive(); @@ -466,15 +470,8 @@ void MainWindow::on_actionAddDive_triggered() ui.ListWidget->endSearch(); DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD); - clear_dive(&displayed_dive); - // but wait - we need a valid id... and a start time and an appropriatae dc model - displayed_dive.id = dive_getUniqID(&displayed_dive); - displayed_dive.when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset() + 3600; - displayed_dive.dc.model = "manually added dive"; // don't translate! this is stored in the XML file - - // setup the dive cylinders - DivePlannerPointsModel::instance()->clear(); - DivePlannerPointsModel::instance()->setupCylinders(); + // setup things so we can later create our starting dive + setupForAddAndPlan("manually added dive"); // don't translate, stored in the XML file // now show the mostly empty main tab ui.InfoWidget->updateDiveInfo(); diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index d0406ff15..014fbb488 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -183,7 +183,7 @@ private: UpdateManager *updateManager; bool plannerStateClean(); - void createFakeDiveForAddAndPlan(); + void setupForAddAndPlan(const char *model); QDialog *survey; }; |