diff options
-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(); |