summaryrefslogtreecommitdiffstats
path: root/profile-widget
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2016-04-20 15:12:53 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-04-20 15:36:25 -0700
commite0ac1c9a26c6f82a42dea3d25bd0c8bd2a68ceb6 (patch)
tree2fa7fa8677d41b8d1e285a079839d5f7abab4f4c /profile-widget
parentd7103f97f70417476468608b1535758dd4b344b7 (diff)
downloadsubsurface-e0ac1c9a26c6f82a42dea3d25bd0c8bd2a68ceb6.tar.gz
Fix 3-, 6- and 9-minute min/max calculations
Make them use indices into the plot-info, fix calculation of average depth, and fix and add comments. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile-widget')
-rw-r--r--profile-widget/diveprofileitem.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/profile-widget/diveprofileitem.cpp b/profile-widget/diveprofileitem.cpp
index d62c35f93..9ea90ea2f 100644
--- a/profile-widget/diveprofileitem.cpp
+++ b/profile-widget/diveprofileitem.cpp
@@ -225,17 +225,21 @@ void DiveProfileItem::modelDataChanged(const QModelIndex &topLeft, const QModelI
int last = -1;
for (int i = 0, count = dataModel->rowCount(); i < count; i++) {
+ struct plot_data *pd = dataModel->data().entry;
+ struct plot_data *entry = pd + i;
+ // "min/max[2]" are the 9-minute window min/max indices
+ struct plot_data *min_entry = pd + entry->min[2];
+ struct plot_data *max_entry = pd + entry->max[2];
- struct plot_data *entry = dataModel->data().entry + i;
if (entry->depth < 2000)
continue;
- if ((entry == entry->max[2]) && entry->depth / 100 != last) {
+ if ((entry == max_entry) && entry->depth / 100 != last) {
plot_depth_sample(entry, Qt::AlignHCenter | Qt::AlignBottom, getColor(SAMPLE_DEEP));
last = entry->depth / 100;
}
- if ((entry == entry->min[2]) && entry->depth / 100 != last) {
+ if ((entry == min_entry) && entry->depth / 100 != last) {
plot_depth_sample(entry, Qt::AlignHCenter | Qt::AlignTop, getColor(SAMPLE_SHALLOW));
last = entry->depth / 100;
}