QML UI: deal with multiple buddies correctly

When editing adive in Subsurface-mobile we can only handle one buddy
due to the limitations of the combobox. To prevent loss of data when editing
a dive with more than one buddy we display "Multiple Buddies" in the buddy
field. This creates a special case where no changes are written to the buddy field
unless the user changes buddy for that dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Joakim Bygdell 2016-09-12 20:30:07 +02:00 committed by Dirk Hohndel
parent ed11dab7fb
commit 1219dc6931
3 changed files with 17 additions and 4 deletions

View file

@ -869,9 +869,17 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q
d->suit = strdup(qPrintable(suit));
}
if (myDive->buddy() != buddy) {
diveChanged = true;
free(d->buddy);
d->buddy = strdup(qPrintable(buddy));
if (myDive->buddy().contains(",")) {
if (!buddy.contains("Multiple Buddies")) {
diveChanged = true;
free(d->buddy);
d->buddy = strdup(qPrintable(buddy));
}
} else {
diveChanged = true;
free(d->buddy);
d->buddy = strdup(qPrintable(buddy));
}
}
if (myDive->divemaster() != diveMaster) {
diveChanged = true;