Undo: implement undo of dive site editing

This one is a bit more tricky. There are two modes: set dive site
and set newly created dive site. This is realized using an OO model
with derived classed. Quite convoluted - but it seems to work.

Moreover, editing a dive site is not simply setting a value,
but the list of dives in a dive site has to be kept up to date.

Finally, we have to inform the dive site list of the changed
number of dives. Therefore add a new signal diveSiteDivesChanged.
To send only one signal per dive site, hook into the undo() and
redo() functions and call the functions of the base class there.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-03-20 21:46:58 +01:00 committed by Dirk Hohndel
parent 4cb1ceefff
commit 6f574c53a3
10 changed files with 160 additions and 106 deletions

View file

@ -213,7 +213,6 @@ MainWindow::MainWindow() : QMainWindow(),
}
ui.menuFile->insertSeparator(ui.actionQuit);
connect(mainTab, SIGNAL(addDiveFinished()), graphics, SLOT(setProfileState()));
connect(mainTab, SIGNAL(dateTimeChanged()), graphics, SLOT(dateTimeChanged()));
connect(DivePlannerPointsModel::instance(), SIGNAL(planCreated()), this, SLOT(planCreated()));
connect(DivePlannerPointsModel::instance(), SIGNAL(planCanceled()), this, SLOT(planCanceled()));
connect(DivePlannerPointsModel::instance(), SIGNAL(variationsComputed(QString)), this, SLOT(updateVariations(QString)));
@ -387,7 +386,8 @@ void MainWindow::editDiveSite(dive_site *ds)
void MainWindow::startDiveSiteEdit()
{
editDiveSite(get_dive_site_for_dive(&displayed_dive));
if (current_dive)
editDiveSite(get_dive_site_for_dive(current_dive));
}
void MainWindow::enableDisableCloudActions()