From 0e57033042fea482225f88074ad1778bdf8c6fd8 Mon Sep 17 00:00:00 2001 From: jbygdell Date: Sun, 29 Jan 2017 17:32:13 +0100 Subject: QML UI: Parse multiple buddies when editing a dive This allows the user to enter multiple buddies as a comma separated list, the "Multiple Buddies" entry is still a special case as we can only populate the combobox with a single name for each entry. fixes #168 Signed-off-by: Joakim Bygdell --- mobile-widgets/qml/DiveDetailsEdit.qml | 2 +- mobile-widgets/qmlmanager.cpp | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'mobile-widgets') diff --git a/mobile-widgets/qml/DiveDetailsEdit.qml b/mobile-widgets/qml/DiveDetailsEdit.qml index d6c83d97c..6ab2978f0 100644 --- a/mobile-widgets/qml/DiveDetailsEdit.qml +++ b/mobile-widgets/qml/DiveDetailsEdit.qml @@ -177,7 +177,7 @@ Item { } ComboBox { id: buddyBox - editable: currentText != qsTr("Multiple Buddies") + editable: true model: diveDetailsListView.currentItem.modelData.dive.buddyList inputMethodHints: Qt.ImhNoPredictiveText Layout.fillWidth: true diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 84d3e0add..31936b6ee 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -869,13 +869,10 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q d->suit = strdup(qPrintable(suit)); } if (myDive->buddy() != buddy) { - if (myDive->buddy().contains(",")) { - if (!buddy.contains(tr("Multiple Buddies"))) { - diveChanged = true; - free(d->buddy); - d->buddy = strdup(qPrintable(buddy)); - } - } else { + if (buddy.contains(",")){ + buddy = buddy.replace(QRegExp("\\s*,\\s*"), ", "); + } + if (!buddy.contains("Multiple Buddies")) { diveChanged = true; free(d->buddy); d->buddy = strdup(qPrintable(buddy)); -- cgit v1.2.3-70-g09d2