aboutsummaryrefslogtreecommitdiffstats
path: root/mobile-widgets
diff options
context:
space:
mode:
authorGravatar Jocke <j.bygdell@gmail.com>2018-11-13 21:28:18 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-11-15 18:10:13 +0800
commit03143f1ef1a3b290c7e721ee5109e0ef275f6cec (patch)
treeccad6a459bf11cda119704f38d0ed8e288576914 /mobile-widgets
parent15c7ee5db0d61bd12f66cea942b89cc1ef6bad6f (diff)
downloadsubsurface-03143f1ef1a3b290c7e721ee5109e0ef275f6cec.tar.gz
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>
Diffstat (limited to 'mobile-widgets')
-rw-r--r--mobile-widgets/qml/DiveDetails.qml7
-rw-r--r--mobile-widgets/qmlmanager.cpp3
2 files changed, 9 insertions, 1 deletions
diff --git a/mobile-widgets/qml/DiveDetails.qml b/mobile-widgets/qml/DiveDetails.qml
index fbffa5303..3b2fd2c1c 100644
--- a/mobile-widgets/qml/DiveDetails.qml
+++ b/mobile-widgets/qml/DiveDetails.qml
@@ -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
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 81c8f324f..8ce1a4616 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -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);