diff options
-rw-r--r-- | mobile-widgets/qml/DiveDetails.qml | 9 | ||||
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 17 | ||||
-rw-r--r-- | mobile-widgets/qmlmanager.h | 1 |
3 files changed, 26 insertions, 1 deletions
diff --git a/mobile-widgets/qml/DiveDetails.qml b/mobile-widgets/qml/DiveDetails.qml index 44c64042e..5bed0f5ef 100644 --- a/mobile-widgets/qml/DiveDetails.qml +++ b/mobile-widgets/qml/DiveDetails.qml @@ -59,7 +59,14 @@ Kirigami.Page { background: Rectangle { color: subsurfaceTheme.backgroundColor } width: rootItem.colWidth - property QtObject removeDiveFromTripAction: Kirigami.Action { text: qsTr ("Remove dive from trip <TBD>") } + property QtObject removeDiveFromTripAction: Kirigami.Action { + text: qsTr ("Remove this dive from trip") + enabled: currentItem && currentItem.modelData.diveInTrip + onTriggered: { + manager.appendTextToLog("remove dive #" + currentItem.modelData.number + " from its trip") + manager.removeDiveFromTrip(currentItem.modelData.id) + } + } property QtObject addDiveToTripAction: Kirigami.Action { text: qsTr ("Add dive to trip <TBD>") } property QtObject undoAction: Kirigami.Action { text: qsTr("Undo") + " " + manager.undoText diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index cbd82ade2..c4ddac44e 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -1282,6 +1282,23 @@ void QMLManager::commitChanges(QString diveId, QString number, QString date, QSt } } +void QMLManager::removeDiveFromTrip(int id) +{ + struct dive *d = get_dive_by_uniq_id(id); + if (!d) { + appendTextToLog(QString("Asked to remove non-existing dive with id %1 from its trip.").arg(id)); + return; + } + if (!d->divetrip) { + appendTextToLog(QString("Asked to remove dive with id %1 from its trip (but it's not part of a trip).").arg(id)); + return; + } + QVector <dive *> dives; + dives.append(d); + Command::removeDivesFromTrip(dives); + 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 2548767b4..f368ea99d 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 removeDiveFromTrip(int id); void changesNeedSaving(); void openNoCloudRepo(); void saveChangesLocal(); |