summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-08-01 10:47:09 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-11 16:22:27 -0700
commit0d98da52610161ecbafd50afacbff20996756264 (patch)
tree686947161c92eb96329512af1dcc4d4a18af4fef /qt-models
parent96d87273995a6af35d90efb1190ff653e4c03d02 (diff)
downloadsubsurface-0d98da52610161ecbafd50afacbff20996756264.tar.gz
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 <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/divetripmodel.cpp16
-rw-r--r--qt-models/divetripmodel.h3
2 files changed, 11 insertions, 8 deletions
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<void *>(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;
}
diff --git a/qt-models/divetripmodel.h b/qt-models/divetripmodel.h
index a298b1e72..aa2e046d7 100644
--- a/qt-models/divetripmodel.h
+++ b/qt-models/divetripmodel.h
@@ -88,7 +88,8 @@ public:
DIVE_ROLE,
TRIP_ROLE,
SORT_ROLE,
- DIVE_IDX
+ DIVE_IDX,
+ SELECTED_ROLE
};
enum Layout {
TREE,