diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2020-02-20 13:24:38 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-03-10 09:25:57 -0700 |
commit | a4043401c90c41322aa257cec7dee70592db59d8 (patch) | |
tree | cfdbb457629bc64deeb25c3030934ffc1bea3d9b | |
parent | ccf5bf6445e4a0897a6b4141881a3f61d96b9b45 (diff) | |
download | subsurface-a4043401c90c41322aa257cec7dee70592db59d8.tar.gz |
mobile/trip-handling: add helper to add dive to a trip
This again uses an undo command and should be completely symmetrical to removing
a dive from a trip.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 18 | ||||
-rw-r--r-- | mobile-widgets/qmlmanager.h | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index c4ddac44e..81990efe8 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -1299,6 +1299,24 @@ void QMLManager::removeDiveFromTrip(int id) changesNeedSaving(); } +void QMLManager::addDiveToTrip(int id, int tripId) +{ + struct dive *d = get_dive_by_uniq_id(id); + if (!d) { + appendTextToLog(QString("Asked to add non-existing dive with id %1 to trip %2.").arg(id).arg(tripId)); + return; + } + struct dive_trip *dt = get_trip_by_uniq_id(tripId); + if (!dt) { + appendTextToLog(QString("Asked to add dive with id %1 to trip with id %2 which cannot be found.").arg(id).arg(tripId)); + return; + } + QVector <dive *> dives; + dives.append(d); + Command::addDivesToTrip(dives, dt); + changesNeedSaving(); +} + void QMLManager::changesNeedSaving() { // we no longer save right away on iOS because file access is so slow; on the other hand, diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h index f368ea99d..45c32664f 100644 --- a/mobile-widgets/qmlmanager.h +++ b/mobile-widgets/qmlmanager.h @@ -178,6 +178,7 @@ public slots: QString diveMaster, QString weight, QString notes, QStringList startpressure, QStringList endpressure, QStringList gasmix, QStringList usedCylinder, int rating, int visibility, QString state); void removeDiveFromTrip(int id); + void addDiveToTrip(int id, int tripId); void changesNeedSaving(); void openNoCloudRepo(); void saveChangesLocal(); |