Mobile: Allow multiple divemasters

While not something that many will use, editing a dive on
Subsurface-mobile should not result in data loss.
This makes the divemaster field behave in the same way as the buddy
field with regards to multiple entries.

Fixes #1853

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Jocke 2018-11-13 21:28:18 +01:00 committed by Dirk Hohndel
parent 15c7ee5db0
commit 03143f1ef1
2 changed files with 9 additions and 1 deletions

View file

@ -258,7 +258,12 @@ Kirigami.Page {
buddyIndex = manager.buddyList.indexOf(currentItem.modelData.dive.buddy)
}
buddyText = currentItem.modelData.dive.buddy;
divemasterIndex = manager.divemasterList.indexOf(currentItem.modelData.dive.divemaster)
if (currentItem.modelData.dive.divemaster.indexOf(",") > 0) {
divemasterIndex = manager.divemasterList.indexOf(currentItem.modelData.dive.divemaster.split(",", 1).toString())
} else {
divemasterIndex = manager.divemasterList.indexOf(currentItem.modelData.dive.divemaster)
}
divemasterText = currentItem.modelData.dive.divemaster
notes = currentItem.modelData.dive.notes
if (currentItem.modelData.dive.singleWeight) {
// we have only one weight, go ahead, have fun and edit it

View file

@ -1093,6 +1093,9 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q
d->buddy = copy_qstring(buddy);
}
if (myDive->divemaster() != diveMaster) {
if (diveMaster.contains(",")){
diveMaster = diveMaster.replace(QRegExp("\\s*,\\s*"), ", ");
}
diveChanged = true;
free(d->divemaster);
d->divemaster = copy_qstring(diveMaster);