mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
0cfea5205d
commit
3c4439ee27
2 changed files with 16 additions and 19 deletions
|
@ -426,6 +426,18 @@ void MainWindow::printPlan()
|
||||||
#endif
|
#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()
|
void MainWindow::on_actionDivePlanner_triggered()
|
||||||
{
|
{
|
||||||
if(!plannerStateClean())
|
if(!plannerStateClean())
|
||||||
|
@ -435,19 +447,11 @@ void MainWindow::on_actionDivePlanner_triggered()
|
||||||
// put us in PLAN mode
|
// put us in PLAN mode
|
||||||
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
|
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.newProfile->setPlanState();
|
||||||
ui.infoPane->setCurrentIndex(PLANNERWIDGET);
|
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
|
// 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()->setupStartTime();
|
||||||
DivePlannerPointsModel::instance()->createSimpleDive();
|
DivePlannerPointsModel::instance()->createSimpleDive();
|
||||||
|
|
||||||
|
@ -466,15 +470,8 @@ void MainWindow::on_actionAddDive_triggered()
|
||||||
ui.ListWidget->endSearch();
|
ui.ListWidget->endSearch();
|
||||||
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
|
||||||
|
|
||||||
clear_dive(&displayed_dive);
|
// setup things so we can later create our starting dive
|
||||||
// but wait - we need a valid id... and a start time and an appropriatae dc model
|
setupForAddAndPlan("manually added dive"); // don't translate, stored in the XML file
|
||||||
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();
|
|
||||||
|
|
||||||
// now show the mostly empty main tab
|
// now show the mostly empty main tab
|
||||||
ui.InfoWidget->updateDiveInfo();
|
ui.InfoWidget->updateDiveInfo();
|
||||||
|
|
|
@ -183,7 +183,7 @@ private:
|
||||||
UpdateManager *updateManager;
|
UpdateManager *updateManager;
|
||||||
|
|
||||||
bool plannerStateClean();
|
bool plannerStateClean();
|
||||||
void createFakeDiveForAddAndPlan();
|
void setupForAddAndPlan(const char *model);
|
||||||
QDialog *survey;
|
QDialog *survey;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue