From 0d98da52610161ecbafd50afacbff20996756264 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Wed, 1 Aug 2018 10:47:09 +0200 Subject: Dive list: remember selected dives Don't delesect dives, when unregistering them from the backend. If a previously selected dive is added, select it in the dive-list. For this purpose introduce a SELECTED_ROLE to query the DiveTripModel for selected dives. Unfortunately, when adding multiple selected dives, current_dive_changed is called for each of them, making this very slow. This will have to be fixed in subsequent commits. Signed-off-by: Berthold Stoeger --- qt-models/divetripmodel.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'qt-models/divetripmodel.cpp') diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp index 7a2c6d68d..f8b5e0deb 100644 --- a/qt-models/divetripmodel.cpp +++ b/qt-models/divetripmodel.cpp @@ -297,16 +297,18 @@ QVariant DiveItem::data(int column, int role) const break; } break; - } - - if (role == DiveTripModel::STAR_ROLE) { + case DiveTripModel::STAR_ROLE: retVal = d->rating; - } - if (role == DiveTripModel::DIVE_ROLE) { + break; + case DiveTripModel::DIVE_ROLE: retVal = QVariant::fromValue(d); - } - if (role == DiveTripModel::DIVE_IDX) { + break; + case DiveTripModel::DIVE_IDX: retVal = get_divenr(d); + break; + case DiveTripModel::SELECTED_ROLE: + retVal = d->selected; + break; } return retVal; } -- cgit v1.2.3-70-g09d2