diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-11-30 15:51:34 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-12-03 20:55:58 -0800 |
commit | a6fa6cdb410514ba61b8886d3acadd4500c1d86e (patch) | |
tree | 017877ddaa99ce88023e2c8a07bd222ad19b00b9 /desktop-widgets/tab-widgets | |
parent | 7c024f12d2123e08c272cefb2991623bc1da107a (diff) | |
download | subsurface-a6fa6cdb410514ba61b8886d3acadd4500c1d86e.tar.gz |
Undo: make profile-editing undoable
Recently, undo of dive-replanning was introduced. Therefore,
it appears logical to do the same thing for editing of the
profile of manually added dives.
For now, use the same undo-command, just change the displayed
text from "replan dive" to "edit profile". Move the fixup dive
call into the undo-command.
Eventually, every action on the profile should be made undoable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/tab-widgets')
-rw-r--r-- | desktop-widgets/tab-widgets/maintab.cpp | 19 |
1 files changed, 1 insertions, 18 deletions
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp index 3e6de0f39..82e7e4fa5 100644 --- a/desktop-widgets/tab-widgets/maintab.cpp +++ b/desktop-widgets/tab-widgets/maintab.cpp @@ -529,8 +529,6 @@ void MainTab::refreshDisplayedDiveSite() void MainTab::acceptChanges() { - int addedId = -1; - if (ui.location->hasFocus()) stealFocus(); @@ -541,33 +539,18 @@ void MainTab::acceptChanges() ui.dateEdit->setEnabled(true); hideMessage(); - if (lastMode == MANUALLY_ADDED_DIVE) { - // preserve any changes to the profile - free(current_dive->dc.sample); - copy_samples(&displayed_dive.dc, ¤t_dive->dc); - addedId = displayed_dive.id; - } - // TODO: This is a temporary hack until the equipment tab is included in the undo system: // The equipment tab is hardcoded at the first place of the "extra widgets". ((TabDiveEquipment *)extraWidgets[0])->acceptChanges(); if (lastMode == MANUALLY_ADDED_DIVE) { - // we just added or edited the dive, let fixup_dive() make - // sure we get the max. depth right - current_dive->maxdepth.mm = current_dc->maxdepth.mm = 0; - fixup_dive(current_dive); - set_dive_nr_for_current_dive(); MainWindow::instance()->showProfile(); - mark_divelist_changed(true); DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::NOTHING); + Command::editProfile(&displayed_dive); } int scrolledBy = MainWindow::instance()->diveList->verticalScrollBar()->sliderPosition(); if (lastMode == MANUALLY_ADDED_DIVE) { MainWindow::instance()->diveList->reload(); - int newDiveNr = get_divenr(get_dive_by_uniq_id(addedId)); - MainWindow::instance()->diveList->unselectDives(); - MainWindow::instance()->diveList->selectDive(newDiveNr, true); MainWindow::instance()->refreshDisplay(); MainWindow::instance()->graphics->replot(); } else { |