source: subsurface/desktop-widgets/tab-widgets/TabDiveStatistics.cpp @ cd27c1c

Last change on this file since cd27c1c was cd27c1c, checked in by Dirk Hohndel <dirk@…>, 8 months ago

Hide avg max depth thingie

We don't set it so just hide it.

Signed-off-by: Anton Lundin <glance@…>

  • Property mode set to 100644
File size: 4.9 KB
Line 
1#include "TabDiveStatistics.h"
2#include "ui_TabDiveStatistics.h"
3
4#include <core/helpers.h>
5#include <core/display.h>
6#include <core/statistics.h>
7
8TabDiveStatistics::TabDiveStatistics(QWidget *parent) : TabBase(parent), ui(new Ui::TabDiveStatistics())
9{
10        ui->setupUi(this);
11        ui->sacLimits->overrideMaxToolTipText(tr("Highest total SAC of a dive"));
12        ui->sacLimits->overrideMinToolTipText(tr("Lowest total SAC of a dive"));
13        ui->sacLimits->overrideAvgToolTipText(tr("Average total SAC of all selected dives"));
14        ui->tempLimits->overrideMaxToolTipText(tr("Highest temperature"));
15        ui->tempLimits->overrideMinToolTipText(tr("Lowest temperature"));
16        ui->tempLimits->overrideAvgToolTipText(tr("Average temperature of all selected dives"));
17        ui->depthLimits->overrideMaxToolTipText(tr("Deepest dive"));
18        ui->depthLimits->overrideMinToolTipText(tr("Shallowest dive"));
19        ui->timeLimits->overrideMaxToolTipText(tr("Longest dive"));
20        ui->timeLimits->overrideMinToolTipText(tr("Shortest dive"));
21        ui->timeLimits->overrideAvgToolTipText(tr("Average length of all selected dives"));
22
23        Q_FOREACH (QObject *obj, children()) {
24                if (QLabel *label = qobject_cast<QLabel *>(obj))
25                        label->setAlignment(Qt::AlignHCenter);
26        }
27}
28
29TabDiveStatistics::~TabDiveStatistics()
30{
31        delete ui;
32}
33
34void TabDiveStatistics::clear()
35{
36        ui->depthLimits->clear();
37        ui->sacLimits->clear();
38        ui->divesAllText->clear();
39        ui->tempLimits->clear();
40        ui->totalTimeAllText->clear();
41        ui->timeLimits->clear();
42}
43
44void TabDiveStatistics::updateData()
45{
46        clear();
47        ui->depthLimits->setMaximum(get_depth_string(stats_selection.max_depth, true));
48        ui->depthLimits->setMinimum(get_depth_string(stats_selection.min_depth, true));
49        // the overall average depth is really confusing when listed between the
50        // deepest and shallowest dive - let's just not set it
51        // ui->depthLimits->setAverage(get_depth_string(stats_selection.avg_depth, true));
52
53        // Also hide the avgIco, so its clear that its not there.
54        ui->depthLimits->overrideAvgToolTipText("");
55        ui->depthLimits->setAvgVisibility(false);
56
57        if (stats_selection.max_sac.mliter)
58                ui->sacLimits->setMaximum(get_volume_string(stats_selection.max_sac, true).append(tr("/min")));
59        else
60                ui->sacLimits->setMaximum("");
61        if (stats_selection.min_sac.mliter)
62                ui->sacLimits->setMinimum(get_volume_string(stats_selection.min_sac, true).append(tr("/min")));
63        else
64                ui->sacLimits->setMinimum("");
65        if (stats_selection.avg_sac.mliter)
66                ui->sacLimits->setAverage(get_volume_string(stats_selection.avg_sac, true).append(tr("/min")));
67        else
68                ui->sacLimits->setAverage("");
69
70        temperature_t temp;
71        temp.mkelvin = stats_selection.max_temp;
72        ui->tempLimits->setMaximum(get_temperature_string(temp, true));
73        temp.mkelvin = stats_selection.min_temp;
74        ui->tempLimits->setMinimum(get_temperature_string(temp, true));
75        if (stats_selection.combined_temp && stats_selection.combined_count) {
76                const char *unit;
77                get_temp_units(0, &unit);
78                ui->tempLimits->setAverage(QString("%1%2").arg(stats_selection.combined_temp / stats_selection.combined_count, 0, 'f', 1).arg(unit));
79        }
80
81
82        ui->divesAllText->setText(QString::number(stats_selection.selection_size));
83        ui->totalTimeAllText->setText(get_time_string_s(stats_selection.total_time.seconds, 0, (displayed_dive.dc.divemode == FREEDIVE)));
84        int seconds = stats_selection.total_time.seconds;
85        if (stats_selection.selection_size)
86                seconds /= stats_selection.selection_size;
87        ui->timeLimits->setAverage(get_time_string_s(seconds, 0,(displayed_dive.dc.divemode == FREEDIVE)));
88        if (amount_selected > 1) {
89                ui->timeLimits->setMaximum(get_time_string_s(stats_selection.longest_time.seconds, 0, (displayed_dive.dc.divemode == FREEDIVE)));
90                ui->timeLimits->setMinimum(get_time_string_s(stats_selection.shortest_time.seconds, 0, (displayed_dive.dc.divemode == FREEDIVE)));
91        } else {
92                ui->timeLimits->setMaximum("");
93                ui->timeLimits->setMinimum("");
94        }
95
96        QVector<QPair<QString, int> > gasUsed;
97        QString gasUsedString;
98        volume_t vol;
99        selectedDivesGasUsed(gasUsed);
100        for (int j = 0; j < 20; j++) {
101                if (gasUsed.isEmpty())
102                        break;
103                QPair<QString, int> gasPair = gasUsed.last();
104                gasUsed.pop_back();
105                vol.mliter = gasPair.second;
106                gasUsedString.append(gasPair.first).append(": ").append(get_volume_string(vol, true)).append("\n");
107        }
108        if (!gasUsed.isEmpty())
109                gasUsedString.append("...");
110        volume_t o2_tot = {}, he_tot = {};
111        selected_dives_gas_parts(&o2_tot, &he_tot);
112
113        /* No need to show the gas mixing information if diving
114                * with pure air, and only display the he / O2 part when
115                * it is used.
116                */
117        if (he_tot.mliter || o2_tot.mliter) {
118                gasUsedString.append(tr("These gases could be\nmixed from Air and using:\n"));
119                if (he_tot.mliter)
120                        gasUsedString.append(QString("He: %1").arg(get_volume_string(he_tot, true)));
121                if (he_tot.mliter && o2_tot.mliter)
122                        gasUsedString.append(tr(" and "));
123                if (o2_tot.mliter)
124                        gasUsedString.append(QString("O2: %2\n").arg(get_volume_string(o2_tot, true)));
125        }
126        ui->gasConsumption->setText(gasUsedString);
127}
128
Note: See TracBrowser for help on using the repository browser.