aboutsummaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qmlmanager.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-11-14 21:38:30 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-03-09 12:41:11 -0700
commitc0095f690fe2a0b56a6c5d52e03a3b3130e9f6b6 (patch)
tree40b53faf3bfc396edaf9c2fe307ec2adf9e76aad /mobile-widgets/qmlmanager.cpp
parent5601104ba52e61a09dac822f52090f83e591253e (diff)
downloadsubsurface-c0095f690fe2a0b56a6c5d52e03a3b3130e9f6b6.tar.gz
mobile/undo: compile undo commands and call undo command for deletion.
First steps towards full undo on mobile. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets/qmlmanager.cpp')
-rw-r--r--mobile-widgets/qmlmanager.cpp25
1 files changed, 2 insertions, 23 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 81f203bdb..3e3fb7a0c 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -49,7 +49,7 @@
#include "core/worldmap-save.h"
#include "core/uploadDiveLogsDE.h"
#include "core/uploadDiveShare.h"
-
+#include "commands/command.h"
QMLManager *QMLManager::m_instance = NULL;
bool noCloudToCloud = false;
@@ -1429,28 +1429,7 @@ void QMLManager::deleteDive(int id)
appendTextToLog("trying to delete non-existing dive");
return;
}
- // create the storage for the deleted dive and trip (if applicable)
- if (!deletedDive)
- deletedDive = alloc_dive();
- copy_dive(d, deletedDive);
- if (!deletedTrip) {
- deletedTrip = alloc_trip();
- } else {
- free(deletedTrip->location);
- free(deletedTrip->notes);
- memset(deletedTrip, 0, sizeof(struct dive_trip));
- }
- // if this is the last dive in that trip, remember the trip as well
- if (d->divetrip && d->divetrip->dives.nr == 1) {
- *deletedTrip = *d->divetrip;
- deletedTrip->location = copy_string(d->divetrip->location);
- deletedTrip->notes = copy_string(d->divetrip->notes);
- deletedTrip->dives.nr = 0;
- deletedDive->divetrip = deletedTrip;
- }
- DiveListModel::instance()->removeDiveById(id);
- delete_single_dive(get_idx_by_uniq_id(id));
- DiveListModel::instance()->resetInternalData();
+ Command::deleteDive(QVector<dive *>{ d });
changesNeedSaving();
}