aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-01-26 21:57:41 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-02-13 13:02:54 -0800
commit1797b59c102eaa5b2091504d96616433aaf0a239 (patch)
treec403a0760f4384eae5bc4f89bd130d213bc9ae41
parentb7e62307c55449de9a6e76fa55c095420dc6c9e7 (diff)
downloadsubsurface-1797b59c102eaa5b2091504d96616433aaf0a239.tar.gz
statistics: replot stats if dives added / removed
It is crucial to replot the statistics when dives are added / removed, to avoid stale pointers. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--stats/scatterseries.cpp14
-rw-r--r--stats/statsview.cpp5
2 files changed, 9 insertions, 10 deletions
diff --git a/stats/scatterseries.cpp b/stats/scatterseries.cpp
index 791bb81ca..03763c118 100644
--- a/stats/scatterseries.cpp
+++ b/stats/scatterseries.cpp
@@ -130,16 +130,10 @@ bool ScatterSeries::hover(QPointF pos)
const dive *d = items[idx].d;
if (!text.empty())
text.push_back(QString(" ")); // Argh. Empty strings are filtered away.
- // We don't listen to undo-command signals, therefore we have to check whether that dive actually exists!
- // TODO: fix this.
- if (get_divenr(d) < 0) {
- text.push_back(StatsTranslations::tr("Removed dive"));
- } else {
- text.push_back(StatsTranslations::tr("Dive #%1").arg(d->number));
- text.push_back(get_dive_date_string(d->when));
- text.push_back(dataInfo(varX, d));
- text.push_back(dataInfo(varY, d));
- }
+ text.push_back(StatsTranslations::tr("Dive #%1").arg(d->number));
+ text.push_back(get_dive_date_string(d->when));
+ text.push_back(dataInfo(varX, d));
+ text.push_back(dataInfo(varY, d));
if (++shown >= show && shown < (int)highlighted.size()) {
text.push_back(" ");
text.push_back(StatsTranslations::tr("and %1 more").arg((int)highlighted.size() - shown));
diff --git a/stats/statsview.cpp b/stats/statsview.cpp
index 133f39219..464339a9c 100644
--- a/stats/statsview.cpp
+++ b/stats/statsview.cpp
@@ -18,6 +18,7 @@
#include "zvalues.h"
#include "core/divefilter.h"
#include "core/subsurface-qt/divelistnotifier.h"
+#include "core/trip.h"
#include <cmath>
#include <QQuickItem>
@@ -41,6 +42,10 @@ StatsView::StatsView(QQuickItem *parent) : QQuickItem(parent),
setFlag(ItemHasContents, true);
connect(&diveListNotifier, &DiveListNotifier::numShownChanged, this, &StatsView::replotIfVisible);
+ connect(&diveListNotifier, &DiveListNotifier::divesAdded, this, &StatsView::replotIfVisible);
+ connect(&diveListNotifier, &DiveListNotifier::divesDeleted, this, &StatsView::replotIfVisible);
+ connect(&diveListNotifier, &DiveListNotifier::dataReset, this, &StatsView::replotIfVisible);
+ connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &StatsView::replotIfVisible);
setAcceptHoverEvents(true);
setAcceptedMouseButtons(Qt::LeftButton);