mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
UI restructure: cleanup the code when canceling an edit
This was way too complicated because we used to edit a "live" dive that was on the dive list. All we really need to do is systematically make sure that all the widgets are in the correct state. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d97c49ba39
commit
cd5b2a372f
3 changed files with 15 additions and 61 deletions
|
@ -908,13 +908,6 @@ void DivePlannerPointsModel::cancelPlan()
|
||||||
setPlanMode(NOTHING);
|
setPlanMode(NOTHING);
|
||||||
diveplan.dp = NULL;
|
diveplan.dp = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// somewhere, somehow we need to make sure that the current_dive is displayed again
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
emit planCanceled();
|
emit planCanceled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -839,64 +839,25 @@ void MainTab::rejectChanges()
|
||||||
editMode = NONE;
|
editMode = NONE;
|
||||||
tabBar()->setTabIcon(0, QIcon()); // Notes
|
tabBar()->setTabIcon(0, QIcon()); // Notes
|
||||||
tabBar()->setTabIcon(1, QIcon()); // Equipment
|
tabBar()->setTabIcon(1, QIcon()); // Equipment
|
||||||
|
hideMessage();
|
||||||
if (MainWindow::instance() && MainWindow::instance()->dive_list()->selectedTrips().count() != 1) {
|
resetPallete();
|
||||||
if (lastMode == ADD) {
|
// no harm done to call cancelPlan even if we were not in ADD or PLAN mode...
|
||||||
// clean up
|
|
||||||
DivePlannerPointsModel::instance()->cancelPlan();
|
DivePlannerPointsModel::instance()->cancelPlan();
|
||||||
hideMessage();
|
|
||||||
resetPallete();
|
// now make sure that the correct dive is displayed
|
||||||
return;
|
if (selected_dive >= 0)
|
||||||
} else if (lastMode == MANUALLY_ADDED_DIVE) {
|
|
||||||
// when we tried to edit a manually added dive, we destroyed
|
|
||||||
// the dive we edited, so let's just restore it from backup
|
|
||||||
DivePlannerPointsModel::instance()->restoreBackupDive();
|
|
||||||
}
|
|
||||||
if (selected_dive >= 0) {
|
|
||||||
copy_dive(current_dive, &displayed_dive);
|
copy_dive(current_dive, &displayed_dive);
|
||||||
cylindersModel->updateDive();
|
else
|
||||||
weightModel->updateDive();
|
clear_dive(&displayed_dive);
|
||||||
} else {
|
updateDiveInfo(selected_dive < 0);
|
||||||
cylindersModel->clear();
|
|
||||||
weightModel->clear();
|
|
||||||
setEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#if 0 // this makes no sense anymore - but let's make sure I think this through
|
|
||||||
// now let's avoid memory leaks
|
|
||||||
if (MainWindow::instance() && MainWindow::instance()->dive_list()->selectedTrips().count() == 1) {
|
|
||||||
if (displayed_dive.location != current_dive->divetrip->location)
|
|
||||||
free(displayed_dive.location);
|
|
||||||
if (displayed_dive.notes != current_dive->divetrip->notes)
|
|
||||||
free(displayed_dive.notes);
|
|
||||||
} else {
|
|
||||||
struct dive *cd = current_dive;
|
|
||||||
FREE_IF_DIFFERENT(tag_list);
|
|
||||||
FREE_IF_DIFFERENT(location);
|
|
||||||
FREE_IF_DIFFERENT(buddy);
|
|
||||||
FREE_IF_DIFFERENT(divemaster);
|
|
||||||
FREE_IF_DIFFERENT(notes);
|
|
||||||
FREE_IF_DIFFERENT(suit);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
hideMessage();
|
|
||||||
MainWindow::instance()->dive_list()->setEnabled(true);
|
|
||||||
ui.dateEdit->setEnabled(true);
|
|
||||||
resetPallete();
|
|
||||||
MainWindow::instance()->globe()->reload();
|
|
||||||
if (lastMode == MANUALLY_ADDED_DIVE) {
|
|
||||||
// more clean up
|
|
||||||
updateDiveInfo();
|
|
||||||
MainWindow::instance()->showProfile();
|
|
||||||
// we already reloaded the divelist above, so don't recreate it or we'll lose the selection
|
|
||||||
MainWindow::instance()->refreshDisplay(false);
|
|
||||||
}
|
|
||||||
MainWindow::instance()->dive_list()->setFocus();
|
|
||||||
// the user could have edited the location and then canceled the edit
|
// the user could have edited the location and then canceled the edit
|
||||||
// let's get the correct location back in view
|
// let's get the correct location back in view
|
||||||
MainWindow::instance()->globe()->centerOnCurrentDive();
|
MainWindow::instance()->globe()->centerOnCurrentDive();
|
||||||
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::NOTHING);
|
MainWindow::instance()->globe()->reload();
|
||||||
updateDiveInfo();
|
// show the profile and dive info
|
||||||
|
MainWindow::instance()->graphics()->replot();
|
||||||
|
cylindersModel->updateDive();
|
||||||
|
weightModel->updateDive();
|
||||||
}
|
}
|
||||||
#undef EDIT_TEXT2
|
#undef EDIT_TEXT2
|
||||||
|
|
||||||
|
|
|
@ -394,7 +394,7 @@ bool MainWindow::plannerStateClean()
|
||||||
void MainWindow::planCanceled()
|
void MainWindow::planCanceled()
|
||||||
{
|
{
|
||||||
showProfile();
|
showProfile();
|
||||||
refreshDisplay();
|
refreshDisplay(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::planCreated()
|
void MainWindow::planCreated()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue