diff options
author | Doug Junkins <junkins@foghead.com> | 2019-03-09 18:27:51 -0800 |
---|---|---|
committer | bstoeger <32835590+bstoeger@users.noreply.github.com> | 2019-03-12 00:53:51 +0100 |
commit | a0f9957bcea2c2dc497cce1d78cc5f45bc8c682b (patch) | |
tree | 98069e9635fbae4a39e8f6cfb9d7c2c94dbad457 /qt-models | |
parent | 4613321e3e4c8dac659df2ec537f2978cee56c64 (diff) | |
download | subsurface-a0f9957bcea2c2dc497cce1d78cc5f45bc8c682b.tar.gz |
Display statistics by depth and temperature in Yearly statistics
Create a label for each line added for the depth and temperature
statistics buckets
Add line to statistics widget for each bucket to be displayed
Signed-off-by: Doug Junkins <junkins@foghead.com>
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/yearlystatisticsmodel.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/qt-models/yearlystatisticsmodel.cpp b/qt-models/yearlystatisticsmodel.cpp index fa86cffbe..a820a23aa 100644 --- a/qt-models/yearlystatisticsmodel.cpp +++ b/qt-models/yearlystatisticsmodel.cpp @@ -185,6 +185,8 @@ void YearlyStatisticsModel::update_yearly_stats() int i, month = 0; unsigned int j, combined_months; stats_summary_auto_free stats; + QString label; + temperature_t t_range_min,t_range_max; calculate_stats_summary(&stats, false); for (i = 0; stats.stats_yearly != NULL && stats.stats_yearly[i].period; ++i) { @@ -225,4 +227,38 @@ void YearlyStatisticsModel::update_yearly_stats() rootItem->children.append(item); item->parent = rootItem.get(); } + + /* Show the statistic sorted by dive depth */ + if (stats.stats_by_depth != NULL && stats.stats_by_depth[0].selection_size) { + YearStatisticsItem *item = new YearStatisticsItem(stats.stats_by_depth[0]); + for (i = 1; stats.stats_by_depth[i].is_trip; ++i) + if (stats.stats_by_depth[i].selection_size) { + label = QString(tr("%1 - %2")).arg(get_depth_string((i - 1) * (STATS_DEPTH_BUCKET * 1000), true, false), + get_depth_string(i * (STATS_DEPTH_BUCKET * 1000), true, false)); + stats.stats_by_depth[i].location = strdup(label.toUtf8().data()); + YearStatisticsItem *iChild = new YearStatisticsItem(stats.stats_by_depth[i]); + item->children.append(iChild); + iChild->parent = item; + } + rootItem->children.append(item); + item->parent = rootItem.get(); + } + + /* Show the statistic sorted by dive temperature */ + if (stats.stats_by_temp != NULL && stats.stats_by_temp[0].selection_size) { + YearStatisticsItem *item = new YearStatisticsItem(stats.stats_by_temp[0]); + for (i = 1; stats.stats_by_temp[i].is_trip; ++i) + if (stats.stats_by_temp[i].selection_size) { + t_range_min.mkelvin = C_to_mkelvin((i - 1) * STATS_TEMP_BUCKET); + t_range_max.mkelvin = C_to_mkelvin(i * STATS_TEMP_BUCKET); + label = QString(tr("%1 - %2")).arg(get_temperature_string(t_range_min, true), + get_temperature_string(t_range_max, true)); + stats.stats_by_temp[i].location = strdup(label.toUtf8().data()); + YearStatisticsItem *iChild = new YearStatisticsItem(stats.stats_by_temp[i]); + item->children.append(iChild); + iChild->parent = item; + } + rootItem->children.append(item); + item->parent = rootItem.get(); + } } |