summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2020-09-23 10:38:35 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-09-27 14:16:18 -0700
commita469dfa3489673ecb19f88348ffa6c0c23608243 (patch)
tree4275cc930af698cfec69ecec9fbe1ab1e93b24c7 /qt-models
parent927b0087810ee54e1141ae3cb48bfd2fe397dec6 (diff)
downloadsubsurface-a469dfa3489673ecb19f88348ffa6c0c23608243.tar.gz
mobile/dive-list: correctly update view when changing dive date
If the dive timestamp changes, the dive could move in the dive list. But the current dive actually doesn't change (it's still the same dive, right?). Yet we need to update the dive list as well as the shown dive (especially if this is after adding a dive, which is first inserted with the current time and then updated with whatever the user enters). Fixes: #2971 Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/divetripmodel.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp
index 8671a62b6..789fb3b55 100644
--- a/qt-models/divetripmodel.cpp
+++ b/qt-models/divetripmodel.cpp
@@ -538,9 +538,6 @@ static ShownChange updateShownAll()
void DiveTripModelBase::currentChanged()
{
- if (oldCurrent == current_dive)
- return;
-
// On Desktop we use a signal to forward current-dive changed, on mobile we use ROLE_CURRENT.
// TODO: Unify - use the role for both.
#if defined(SUBSURFACE_MOBILE)
@@ -549,11 +546,13 @@ void DiveTripModelBase::currentChanged()
QModelIndex oldIdx = diveToIdx(oldCurrent);
dataChanged(oldIdx, oldIdx, roles);
}
- if (current_dive) {
+ if (current_dive && oldCurrent != current_dive) {
QModelIndex newIdx = diveToIdx(current_dive);
dataChanged(newIdx, newIdx, roles);
}
#else
+ if (oldCurrent == current_dive)
+ return;
if (current_dive) {
QModelIndex newIdx = diveToIdx(current_dive);
emit currentDiveChanged(newIdx);