mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 23:53:23 +00:00
mobile/dive-list: add ability to create trip
This adds a context menu entry for top level dives that allows the user to create a trip for that dive. Unfortunately this creates a new string to translate right before a release... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
241d378f14
commit
66fd93c9cc
3 changed files with 28 additions and 1 deletions
|
@ -271,6 +271,15 @@ Kirigami.ScrollablePage {
|
||||||
manager.addDiveToTrip(currentItem.myData.id, currentItem.myData.tripBelow)
|
manager.addDiveToTrip(currentItem.myData.id, currentItem.myData.tripBelow)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
property QtObject createTripForDiveAction: Kirigami.Action {
|
||||||
|
text: visible ? qsTr("Create trip with dive %1").arg(currentItem.myData.number) : ""
|
||||||
|
icon { name: ":/icons/list-add" }
|
||||||
|
visible: currentItem && currentItem.myData && !currentItem.myData.isTrip && currentItem.myData.isTopLevel
|
||||||
|
onTriggered: {
|
||||||
|
manager.addTripForDive(currentItem.myData.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
property QtObject toggleInvalidAction: Kirigami.Action {
|
property QtObject toggleInvalidAction: Kirigami.Action {
|
||||||
text: currentItem && currentItem.myData && currentItem.myData.isInvalid ? qsTr("Mark dive as valid") : qsTr("Mark dive as invalid")
|
text: currentItem && currentItem.myData && currentItem.myData.isInvalid ? qsTr("Mark dive as valid") : qsTr("Mark dive as invalid")
|
||||||
// icon: { name: "TBD" }
|
// icon: { name: "TBD" }
|
||||||
|
@ -316,7 +325,7 @@ Kirigami.ScrollablePage {
|
||||||
enabled: manager.redoText !== ""
|
enabled: manager.redoText !== ""
|
||||||
onTriggered: manager.redo()
|
onTriggered: manager.redo()
|
||||||
}
|
}
|
||||||
property variant contextactions: [ removeDiveFromTripAction, addDiveToTripAboveAction, addDiveToTripBelowAction, toggleInvalidAction, deleteAction, mapAction, tripDetailsEdit, undoAction, redoAction ]
|
property variant contextactions: [ removeDiveFromTripAction, createTripForDiveAction, addDiveToTripAboveAction, addDiveToTripBelowAction, toggleInvalidAction, deleteAction, mapAction, tripDetailsEdit, undoAction, redoAction ]
|
||||||
|
|
||||||
function setupActions() {
|
function setupActions() {
|
||||||
if (Backend.cloud_verification_status === Enums.CS_VERIFIED || Backend.cloud_verification_status === Enums.CS_NOCLOUD) {
|
if (Backend.cloud_verification_status === Enums.CS_VERIFIED || Backend.cloud_verification_status === Enums.CS_NOCLOUD) {
|
||||||
|
|
|
@ -1231,6 +1231,23 @@ void QMLManager::removeDiveFromTrip(int id)
|
||||||
changesNeedSaving();
|
changesNeedSaving();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QMLManager::addTripForDive(int id)
|
||||||
|
{
|
||||||
|
struct dive *d = get_dive_by_uniq_id(id);
|
||||||
|
if (!d) {
|
||||||
|
appendTextToLog(QString("Asked to create trip for non-existing dive with id %1").arg(id));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (d->divetrip) {
|
||||||
|
appendTextToLog(QString("Asked to create trip for dive %1 with id %2 but it's already part of a trip with location %3.").arg(d->number).arg(id).arg(d->divetrip->location));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QVector <dive *> dives;
|
||||||
|
dives.append(d);
|
||||||
|
Command::createTrip(dives);
|
||||||
|
changesNeedSaving();
|
||||||
|
}
|
||||||
|
|
||||||
void QMLManager::addDiveToTrip(int id, int tripId)
|
void QMLManager::addDiveToTrip(int id, int tripId)
|
||||||
{
|
{
|
||||||
struct dive *d = get_dive_by_uniq_id(id);
|
struct dive *d = get_dive_by_uniq_id(id);
|
||||||
|
|
|
@ -178,6 +178,7 @@ public slots:
|
||||||
QStringList endpressure, QStringList gasmix, QStringList usedCylinder, int rating, int visibility, QString state);
|
QStringList endpressure, QStringList gasmix, QStringList usedCylinder, int rating, int visibility, QString state);
|
||||||
void updateTripDetails(QString tripIdString, QString tripLocation, QString tripNotes);
|
void updateTripDetails(QString tripIdString, QString tripLocation, QString tripNotes);
|
||||||
void removeDiveFromTrip(int id);
|
void removeDiveFromTrip(int id);
|
||||||
|
void addTripForDive(int id);
|
||||||
void addDiveToTrip(int id, int tripId);
|
void addDiveToTrip(int id, int tripId);
|
||||||
void changesNeedSaving();
|
void changesNeedSaving();
|
||||||
void openNoCloudRepo();
|
void openNoCloudRepo();
|
||||||
|
|
Loading…
Add table
Reference in a new issue