diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-11-26 00:08:35 +0100 |
---|---|---|
committer | bstoeger <32835590+bstoeger@users.noreply.github.com> | 2019-12-04 13:00:23 +0100 |
commit | a431840075fbba6f882627496f18a0fb80630e4f (patch) | |
tree | 3c7fb27b2ef10e8ab0f08039188a08ec4213166f /qt-models/divetripmodel.cpp | |
parent | 755f185cfcbd3d61457df6fdff32bcf2118f0ab5 (diff) | |
download | subsurface-a431840075fbba6f882627496f18a0fb80630e4f.tar.gz |
Selection: move initialization of selection from view to model
The goal here is to unify desktop and mobile by moving
selection code from the desktop-only view.
Currently, initialization of the selection still has to be
called from the view after connecting the appropriate signals.
This is due to the weird way in which create completely new
models when resetting them.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/divetripmodel.cpp')
-rw-r--r-- | qt-models/divetripmodel.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp index 04af9c47f..ee0620c5e 100644 --- a/qt-models/divetripmodel.cpp +++ b/qt-models/divetripmodel.cpp @@ -3,6 +3,7 @@ #include "core/divefilter.h" #include "core/gettextfromc.h" #include "core/metrics.h" +#include "core/selection.h" #include "core/trip.h" #include "core/qthelper.h" #include "core/divesite.h" @@ -372,6 +373,19 @@ void DiveTripModelBase::resetModel(DiveTripModelBase::Layout layout) currentModel.reset(new DiveTripModelList); } +// After resetting the model, the higher up model or view may call this +// function to get informed on the current selection. +// TODO: Currently, this reads and resets the selection. Make this more +// efficient by maintaining a list of selected dives. +void DiveTripModelBase::initSelection() +{ + std::vector<dive *> dives = getDiveSelection(); + if (!dives.empty()) + setSelection(dives, current_dive); + else + select_newest_visible_dive(); +} + void DiveTripModelBase::clear() { beginResetModel(); |