Changeset 92d24a2 in subsurface for qt-models


Ignore:
Timestamp:
May 6, 2017, 5:43:32 PM (6 months ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
25cec35d
Parents:
876b479
Message:

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 <dirk@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • qt-models/divetripmodel.cpp

    r5372f12 r92d24a2  
    343343QString DiveItem::displayDuration() const
    344344{
    345         int hrs, mins, fullmins, secs;
    346         struct dive *dive = get_dive_by_uniq_id(diveId);
    347         mins = (dive->duration.seconds + 59) / 60;
    348         fullmins = dive->duration.seconds / 60;
    349         secs = dive->duration.seconds - 60 * fullmins;
    350         hrs = mins / 60;
    351         mins -= hrs * 60;
    352 
    353         QString displayTime;
    354         if (hrs)
    355                 displayTime = QString("%1:%2").arg(hrs).arg(mins, 2, 10, QChar('0'));
    356         else if (mins < 15 || dive->dc.divemode == FREEDIVE)
    357                 displayTime = QString("%1m%2s").arg(fullmins).arg(secs, 2, 10, QChar('0'));
    358         else
    359                 displayTime = QString("%1").arg(mins);
    360         return displayTime;
     345        struct dive *dive = get_dive_by_uniq_id(diveId);
     346        return get_dive_duration_string(dive->duration.seconds, ":", "m", "s", dive->dc.divemode == FREEDIVE);
    361347}
    362348
Note: See TracChangeset for help on using the changeset viewer.