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 <j.bygdell@gmail.com>
This commit is contained in:
jbygdell 2017-01-29 17:32:13 +01:00 committed by Dirk Hohndel
parent f5a4838519
commit 0e57033042
2 changed files with 5 additions and 8 deletions

View file

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

View file

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