From 92d24a2912d1e9302b86d74a13a9bc124e7b380c Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 6 May 2017 17:43:32 -0700 Subject: Consistently show dive duration based on preferences We now respect the settings in the preferences and also only show the duration as minutes and seconds if the dive is a free dive. Fixes #361 Fixes #362 Signed-off-by: Dirk Hohndel --- qt-models/divetripmodel.cpp | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'qt-models/divetripmodel.cpp') diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp index dadf81dfd..c57541ccd 100644 --- a/qt-models/divetripmodel.cpp +++ b/qt-models/divetripmodel.cpp @@ -342,22 +342,8 @@ int DiveItem::countPhotos(dive *dive) const QString DiveItem::displayDuration() const { - int hrs, mins, fullmins, secs; struct dive *dive = get_dive_by_uniq_id(diveId); - mins = (dive->duration.seconds + 59) / 60; - fullmins = dive->duration.seconds / 60; - secs = dive->duration.seconds - 60 * fullmins; - hrs = mins / 60; - mins -= hrs * 60; - - QString displayTime; - if (hrs) - displayTime = QString("%1:%2").arg(hrs).arg(mins, 2, 10, QChar('0')); - else if (mins < 15 || dive->dc.divemode == FREEDIVE) - displayTime = QString("%1m%2s").arg(fullmins).arg(secs, 2, 10, QChar('0')); - else - displayTime = QString("%1").arg(mins); - return displayTime; + return get_dive_duration_string(dive->duration.seconds, ":", "m", "s", dive->dc.divemode == FREEDIVE); } QString DiveItem::displayTemperature() const -- cgit v1.2.3-70-g09d2