From ce525bd28518cc3c625b5e005bc7eb5e3c460c29 Mon Sep 17 00:00:00 2001 From: Miika Turkia Date: Sun, 24 Nov 2013 03:09:34 +0200 Subject: Adding trip based statistics This adds trip based statistics to the Yearly Statistics view. Signed-off-by: Miika Turkia Signed-off-by: Dirk Hohndel --- qt-ui/models.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'qt-ui/models.cpp') diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index ae156cbbc..8dfdb5c1f 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -1364,7 +1364,13 @@ QVariant YearStatisticsItem::data(int column, int role) const return ret; } switch(column) { - case YEAR: ret = stats_interval.period; break; + case YEAR: + if (stats_interval.is_trip) { + ret = stats_interval.location; + } else { + ret = stats_interval.period; + } + break; case DIVES: ret = stats_interval.selection_size; break; case TOTAL_TIME: ret = get_time_string(stats_interval.total_time.seconds, 0); break; case AVERAGE_TIME: ret = get_minutes(stats_interval.total_time.seconds / stats_interval.selection_size); break; @@ -1409,7 +1415,7 @@ QVariant YearlyStatisticsModel::headerData(int section, Qt::Orientation orientat if (role == Qt::DisplayRole && orientation == Qt::Horizontal) { switch(section) { - case YEAR: val = tr("Year \n > Month"); break; + case YEAR: val = tr("Year \n > Month / Trip"); break; case DIVES: val = tr("#"); break; case TOTAL_TIME: val = tr("Duration \n Total"); break; case AVERAGE_TIME: val = tr("\nAverage"); break; @@ -1447,6 +1453,18 @@ void YearlyStatisticsModel::update_yearly_stats() rootItem->children.append(item); item->parent = rootItem; } + + + if (stats_by_trip != NULL ) { + YearStatisticsItem *item = new YearStatisticsItem(stats_by_trip[0]); + for (i = 1; stats_by_trip != NULL && stats_by_trip[i].is_trip; ++i) { + YearStatisticsItem *iChild = new YearStatisticsItem(stats_by_trip[i]); + item->children.append(iChild); + iChild->parent = item; + } + rootItem->children.append(item); + item->parent = rootItem; + } } /*################################################################# -- cgit v1.2.3-70-g09d2