[PATCH] QML UI: deal with multiple buddies correctly

Dirk Hohndel dirk at hohndel.org
Tue Nov 22 08:03:54 PST 2016


Which platform? IOS or Android?

/D

> On Nov 22, 2016, at 6:25 AM, Martin Long <martin at longhome.co.uk> wrote:
> 
> Hi, 
> 
> Is there any changes of a new daily build with this patch? I've noticed that this has been trashing the data for a load of my dives. 
> 
> Thanks
> 
> Martin
> 
> On Mon, 12 Sep 2016 at 19:30 Joakim Bygdell <j.bygdell at gmail.com <mailto:j.bygdell at gmail.com>> wrote:
> 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.
> ---
>  core/subsurface-qt/DiveObjectHelper.cpp |  1 +
>  mobile-widgets/qml/DiveDetails.qml      |  6 +++++-
>  mobile-widgets/qmlmanager.cpp           | 14 +++++++++++---
>  3 files changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/core/subsurface-qt/DiveObjectHelper.cpp b/core/subsurface-qt/DiveObjectHelper.cpp
> index 37f954c..246e451 100644
> --- a/core/subsurface-qt/DiveObjectHelper.cpp
> +++ b/core/subsurface-qt/DiveObjectHelper.cpp
> @@ -425,6 +425,7 @@ QStringList DiveObjectHelper::buddyList() const
>                         QRegExp sep("(,\\s)");
>                         QStringList tempList = temp.split(sep);
>                         buddies << tempList;
> +                       buddies << "Multiple Buddies";
>                 }
>         }
>         buddies.removeDuplicates();
> diff --git a/mobile-widgets/qml/DiveDetails.qml b/mobile-widgets/qml/DiveDetails.qml
> index 7f6ca81..be34288 100644
> --- a/mobile-widgets/qml/DiveDetails.qml
> +++ b/mobile-widgets/qml/DiveDetails.qml
> @@ -156,7 +156,11 @@ Kirigami.Page {
>                 airtemp = diveDetailsListView.currentItem.modelData.dive.airTemp
>                 watertemp = diveDetailsListView.currentItem.modelData.dive.waterTemp
>                 suitIndex = diveDetailsListView.currentItem.modelData.dive.suitList.indexOf(diveDetailsListView.currentItem.modelData.dive.suit)
> -               buddyIndex = diveDetailsListView.currentItem.modelData.dive.buddyList.indexOf(diveDetailsListView.currentItem.modelData.dive.buddy)
> +               if (diveDetailsListView.currentItem.modelData.dive.buddy.search(",")) {
> +                       buddyIndex = diveDetailsListView.currentItem.modelData.dive.buddyList.indexOf("Multiple Buddies");
> +               } else {
> +                       buddyIndex = diveDetailsListView.currentItem.modelData.dive.buddyList.indexOf(diveDetailsListView.currentItem.modelData.dive.buddy)
> +               }
>                 divemasterIndex = diveDetailsListView.currentItem.modelData.dive.divemasterList.indexOf(diveDetailsListView.currentItem.modelData.dive.divemaster)
>                 notes = diveDetailsListView.currentItem.modelData.dive.notes
>                 if (diveDetailsListView.currentItem.modelData.dive.singleWeight) {
> diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
> index 9de5ac1..1b9aebe 100644
> --- a/mobile-widgets/qmlmanager.cpp
> +++ b/mobile-widgets/qmlmanager.cpp
> @@ -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;
> --
> 2.7.4
> 
> _______________________________________________
> subsurface mailing list
> subsurface at subsurface-divelog.org <mailto:subsurface at subsurface-divelog.org>
> http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface <http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface>
> _______________________________________________
> subsurface mailing list
> subsurface at subsurface-divelog.org
> http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20161122/37433d8e/attachment.html>


More information about the subsurface mailing list