undo: split replanDive and editProfile commands

These two actions were using the same command with a flag
controlling the name of the command, which is shown in
the undo menu.

However, the replanDive does much more (such as changing
the notes) and in the future we may want to be more
fine-grained with respect to profile editing. Therefore,
split these commands into two separate ones.

Moreover, make the editProfile command more flexible.
Pass an enum describing the action instead and also
a counter indicating how many points have been
moved or removed.

Finally, don't consume the input dive in the editProfile
command, because we will want to keep the original dive
while editing the profile.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2022-02-13 19:32:19 +01:00
parent 2368a183e1
commit ea0c030770
5 changed files with 102 additions and 10 deletions

View file

@ -498,7 +498,7 @@ void MainTab::acceptChanges()
MainWindow::instance()->showProfile();
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::NOTHING);
Command::editProfile(&displayed_dive);
Command::editProfile(&displayed_dive, Command::EditProfileType::MOVE, 0);
int scrolledBy = MainWindow::instance()->diveList->verticalScrollBar()->sliderPosition();
MainWindow::instance()->diveList->reload();