From eaa1a5126bc0f50ba1e7ae59a895385b6d4e6614 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 22 Feb 2020 14:05:13 -0800 Subject: [PATCH] mobile: add ability to update trip details This creates up to two undo events. This seems like such a small issue that it's not worth creating yet another undo command for this. Signed-off-by: Dirk Hohndel --- mobile-widgets/qmlmanager.cpp | 21 +++++++++++++++++++++ mobile-widgets/qmlmanager.h | 1 + 2 files changed, 22 insertions(+) diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index a55bdb7e2..1e0717adb 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -1282,6 +1282,27 @@ void QMLManager::commitChanges(QString diveId, QString number, QString date, QSt } } +void QMLManager::updateTripDetails(QString tripIdString, QString tripLocation, QString tripNotes) +{ + int tripId = tripIdString.toInt(); + dive_trip_t *trip = get_trip_by_uniq_id(tripId); + if (!trip) { + qDebug() << "updateTripData: cannot find trip for tripId" << tripIdString; + return; + } + bool changed = false; + if (tripLocation != trip->location) { + changed = true; + Command::editTripLocation(trip, tripLocation); + } + if (tripNotes != trip->notes) { + changed = true; + Command::editTripNotes(trip, tripNotes); + } + if (changed) + changesNeedSaving(); +} + void QMLManager::removeDiveFromTrip(int id) { struct dive *d = get_dive_by_uniq_id(id); diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h index 45c32664f..969d95076 100644 --- a/mobile-widgets/qmlmanager.h +++ b/mobile-widgets/qmlmanager.h @@ -177,6 +177,7 @@ public slots: QString watertemp, QString suit, QString buddy, QString diveMaster, QString weight, QString notes, QStringList startpressure, QStringList endpressure, QStringList gasmix, QStringList usedCylinder, int rating, int visibility, QString state); + void updateTripDetails(QString tripIdString, QString tripLocation, QString tripNotes); void removeDiveFromTrip(int id); void addDiveToTrip(int id, int tripId); void changesNeedSaving();