1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
From c2af9e6eeb469718b9aa069b90a719fac80dd0d9 Mon Sep 17 00:00:00 2001
From: Uwe Klotz <uwe_klotz@web.de>
Date: Fri, 8 Jan 2016 19:25:58 +0100
Subject: [PATCH] Move definition of Time::formatSeconds() into .cpp file
---
src/util/time.cpp | 30 ++++++++++++++++++++++++++++++
src/util/time.h | 29 +----------------------------
2 files changed, 31 insertions(+), 28 deletions(-)
diff --git a/src/util/time.cpp b/src/util/time.cpp
index 998fa73..d8a122b 100644
--- a/src/util/time.cpp
+++ b/src/util/time.cpp
@@ -6,3 +6,33 @@ LLTIMER Time::s_timer;
bool Time::s_testMode = false;
// static
qint64 Time::s_testElapsed_nsecs = 0;
+
+// static
+QString Time::formatSeconds(double dSeconds, bool showCentis) {
+ if (dSeconds < 0) {
+ return "?";
+ }
+
+ const int days = static_cast<int>(dSeconds) / kSecondsPerDay;
+ dSeconds -= days * kSecondsPerDay;
+
+ // NOTE(uklotzde): Time() constructs a 'null' object, but
+ // we need 'zero' here.
+ QTime t = QTime(0, 0).addMSecs(dSeconds * kMillisPerSecond);
+
+ QString formatString =
+ (days > 0 ? (QString::number(days) %
+ QLatin1String("'d', ")) : QString()) %
+ QLatin1String(days > 0 || t.hour() > 0 ? "hh:mm:ss" : "mm:ss") %
+ QLatin1String(showCentis ? ".zzz" : "");
+
+ QString timeString = t.toString(formatString);
+
+ // The format string gives us milliseconds but we want
+ // centiseconds. Slice one character off.
+ if (showCentis) {
+ timeString = timeString.left(timeString.length() - 1);
+ }
+
+ return timeString;
+}
diff --git a/src/util/time.h b/src/util/time.h
index 7b38eb4..b4e2c2d 100644
--- a/src/util/time.h
+++ b/src/util/time.h
@@ -67,34 +67,7 @@ class Time {
// The standard way of formatting a time in seconds. Used for display of
// track duration, etc. showCentis indicates whether to include
// centisecond-precision or to round to the nearest second.
- static QString formatSeconds(double dSeconds, bool showCentis) {
- if (dSeconds < 0) {
- return "?";
- }
-
- const int days = static_cast<int>(dSeconds) / kSecondsPerDay;
- dSeconds -= days * kSecondsPerDay;
-
- // NOTE(uklotzde): Time() constructs a 'null' object, but
- // we need 'zero' here.
- QTime t = QTime(0, 0).addMSecs(dSeconds * kMillisPerSecond);
-
- QString formatString =
- (days > 0 ? (QString::number(days) %
- QLatin1String("'d', ")) : QString()) %
- QLatin1String(days > 0 || t.hour() > 0 ? "hh:mm:ss" : "mm:ss") %
- QLatin1String(showCentis ? ".zzz" : "");
-
- QString timeString = t.toString(formatString);
-
- // The format string gives us milliseconds but we want
- // centiseconds. Slice one character off.
- if (showCentis) {
- timeString = timeString.left(timeString.length() - 1);
- }
-
- return timeString;
- }
+ static QString formatSeconds(double dSeconds, bool showCentis);
private:
static LLTIMER s_timer;
|