mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Planner: clean up the logic for starting up the planner
The existing code had no chance of every working - on so many levels. First unselect all dives, then extract data from a selected dive? Set up the cylinder data (which didn't work), and then clear the data again? What the heck. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
4e3793c053
commit
12b9c75676
1 changed files with 17 additions and 23 deletions
|
@ -377,9 +377,11 @@ void MainWindow::createFakeDiveForAddAndPlan()
|
||||||
dive->latitude.udeg = 0;
|
dive->latitude.udeg = 0;
|
||||||
dive->longitude.udeg = 0;
|
dive->longitude.udeg = 0;
|
||||||
record_dive(dive);
|
record_dive(dive);
|
||||||
// this isn't in the UI yet, so let's call the C helper function - we'll fix this up when
|
// select this new dive (but remember the old selection
|
||||||
// accepting the dive
|
ui.ListWidget->reload(DiveTripModel::CURRENT);
|
||||||
select_dive(get_divenr(dive));
|
ui.ListWidget->rememberSelection();
|
||||||
|
ui.ListWidget->unselectDives();
|
||||||
|
ui.ListWidget->selectDives(QList<int>() << dive_table.nr - 1);
|
||||||
ui.InfoWidget->updateDiveInfo(selected_dive);
|
ui.InfoWidget->updateDiveInfo(selected_dive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,31 +390,23 @@ void MainWindow::on_actionDivePlanner_triggered()
|
||||||
if(!plannerStateClean())
|
if(!plannerStateClean())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dive_list()->rememberSelection();
|
// put us in PLAN mode
|
||||||
dive_list()->unselectDives();
|
|
||||||
|
|
||||||
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
|
||||||
DivePlannerPointsModel::instance()->clear();
|
|
||||||
CylindersModel::instance()->clear();
|
|
||||||
int i;
|
|
||||||
struct dive *dive;
|
|
||||||
for_each_dive (i, dive) {
|
|
||||||
if (dive->selected) {
|
|
||||||
DivePlannerPointsModel::instance()->copyCylindersFrom(dive);
|
|
||||||
CylindersModel::instance()->copyFromDive(dive);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
createFakeDiveForAddAndPlan();
|
|
||||||
|
|
||||||
ui.InfoWidget->setCurrentIndex(0);
|
|
||||||
ui.infoPane->setCurrentIndex(MAINTAB);
|
|
||||||
|
|
||||||
ui.newProfile->setPlanState();
|
ui.newProfile->setPlanState();
|
||||||
ui.infoPane->setCurrentIndex(PLANNERWIDGET);
|
ui.infoPane->setCurrentIndex(PLANNERWIDGET);
|
||||||
|
|
||||||
|
// set up the staging dive and clean up the widgets
|
||||||
DivePlannerPointsModel::instance()->clear();
|
DivePlannerPointsModel::instance()->clear();
|
||||||
|
|
||||||
|
// setup the staging dive cylinders from the selected dive
|
||||||
|
if (current_dive) {
|
||||||
|
DivePlannerPointsModel::instance()->copyCylindersFrom(current_dive);
|
||||||
|
CylindersModel::instance()->copyFromDive(current_dive);
|
||||||
|
}
|
||||||
|
|
||||||
|
// create a simple starting dive, using the first gas from the just copied cylidners
|
||||||
|
createFakeDiveForAddAndPlan();
|
||||||
DivePlannerPointsModel::instance()->createSimpleDive(true);
|
DivePlannerPointsModel::instance()->createSimpleDive(true);
|
||||||
ui.ListWidget->reload(DiveTripModel::CURRENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionAddDive_triggered()
|
void MainWindow::on_actionAddDive_triggered()
|
||||||
|
|
Loading…
Add table
Reference in a new issue