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 <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2020-02-22 14:05:13 -08:00
parent 4b4df28ecd
commit eaa1a5126b
2 changed files with 22 additions and 0 deletions

View file

@ -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);

View file

@ -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();