From 16f8dc4bcdbb116e1ddcb383145eb127657601b0 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sun, 1 Apr 2018 15:40:03 +0200 Subject: [PATCH] CueSheetModel: Don't wrap around 'minute' component to zero, if it exceeds 59 minutes. --- src/Config.h | 4 ++-- src/Model_CueSheet.cpp | 30 +++++++++++------------------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/Config.h b/src/Config.h index be245bad..09ced2a3 100644 --- a/src/Config.h +++ b/src/Config.h @@ -34,8 +34,8 @@ #define VER_LAMEXP_MINOR_HI 1 #define VER_LAMEXP_MINOR_LO 6 #define VER_LAMEXP_TYPE Beta -#define VER_LAMEXP_PATCH 9 -#define VER_LAMEXP_BUILD 2104 +#define VER_LAMEXP_PATCH 10 +#define VER_LAMEXP_BUILD 2106 #define VER_LAMEXP_CONFG 2002 /////////////////////////////////////////////////////////////////////////////// diff --git a/src/Model_CueSheet.cpp b/src/Model_CueSheet.cpp index 22c81411..8ca6af22 100644 --- a/src/Model_CueSheet.cpp +++ b/src/Model_CueSheet.cpp @@ -826,16 +826,10 @@ double CueSheetModel::parseTimeIndex(const QString &index) if(rxTimeIndex.indexIn(index) >= 0) { - int min, sec, frm; - bool minOK, secOK, frmOK; - - min = rxTimeIndex.cap(1).toInt(&minOK); - sec = rxTimeIndex.cap(2).toInt(&secOK); - frm = rxTimeIndex.cap(3).toInt(&frmOK); - - if(minOK && secOK && frmOK) + int time[3]; + if(MUtils::regexp_parse_int32(rxTimeIndex, time, 3)) { - return static_cast(60 * min) + static_cast(sec) + (static_cast(frm) / 75.0); + return static_cast(60 * time[0]) + static_cast(time[1]) + (static_cast(time[2]) / 75.0); } } @@ -845,19 +839,17 @@ double CueSheetModel::parseTimeIndex(const QString &index) QString CueSheetModel::indexToString(const double index) const { - if(!_finite(index) || (index < 0.0) || (index > 86400.0)) + if((!_finite(index)) || (index < 0.0) || (index > 86400.0)) { return QString("??:??.???"); } - QTime time = QTime().addMSecs(static_cast(floor(0.5 + (index * 1000.0)))); + const int minutes = static_cast(index / 60.0); + if(minutes < 100) + { + const MUtils::fp_parts_t seconds = MUtils::break_fp(fmod(index, 60.0)); + return QString().sprintf("%02d:%02d.%03d", minutes, static_cast(seconds.intpart), static_cast(seconds.fractpart * 1000.0)); + } - if(time.minute() < 100) - { - return time.toString("mm:ss.zzz"); - } - else - { - return QString("99:99.999"); - } + return QString("99:99.999"); }