diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-07-20 20:26:06 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-10-11 16:22:27 -0700 |
commit | 302f6adb79681da3fe53336f1e4c7525f46fd47d (patch) | |
tree | ce752cf002ec01cd9c26a804e49b2ee5b516d6ac /profile-widget | |
parent | 12df9faaa2037b5155ebb84a7f6f6102491a0091 (diff) | |
download | subsurface-302f6adb79681da3fe53336f1e4c7525f46fd47d.tar.gz |
Undo: implement rudimentary support for undo of dive-splitting
For this, the core functionality of the split_dive() and
split_dive_at_time() functions were split out into new
split_dive_dont_insert() and split_dive_at_time_dont_insert(),
which do not add the new dives to the log. Thus, the undo-command
can take ownership of these dives, without having to remove them
first.
The split-dive functionality is temporarily made desktop-only
until mobile also supports "UndoObjects".
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget')
-rw-r--r-- | profile-widget/profilewidget2.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index 793c6d950..79b70d719 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -23,6 +23,7 @@ #include "desktop-widgets/diveplanner.h" #include "desktop-widgets/simplewidgets.h" #include "desktop-widgets/divepicturewidget.h" +#include "desktop-widgets/undocommands.h" #include "desktop-widgets/mainwindow.h" #include "core/qthelper.h" #include "core/gettextfromc.h" @@ -1675,16 +1676,19 @@ void ProfileWidget2::addSetpointChange() void ProfileWidget2::splitDive() { +#ifndef SUBSURFACE_MOBILE + // Make sure that this is an actual dive and we're not in add mode + dive *d = get_dive_by_uniq_id(displayed_dive.id); + if (!d) + return; QAction *action = qobject_cast<QAction *>(sender()); QPointF scenePos = mapToScene(mapFromGlobal(action->data().toPoint())); duration_t time; - time.seconds = lrint(timeAxis->valueAt((scenePos))); - split_dive_at_time(&displayed_dive, time); + time.seconds = lrint(timeAxis->valueAt(scenePos)); + UndoSplitDives *undoCommand = new UndoSplitDives(d, time); + MainWindow::instance()->undoStack->push(undoCommand); emit updateDiveInfo(false); - mark_divelist_changed(true); - replot(); - MainWindow::instance()->refreshProfile(); - MainWindow::instance()->refreshDisplay(); +#endif } void ProfileWidget2::changeGas() |