]> git.sesse.net Git - kdenlive/blobdiff - src/timecode.cpp
Improved Dvd Wizard (new chapters dialog)
[kdenlive] / src / timecode.cpp
index 182f6d9009d17431c3589f4f2881b76645e0c8a6..e2fe09e26a0eb38d0ece6b2ce324e33e6db3a577 100644 (file)
@@ -19,8 +19,9 @@
 #include <kdebug.h>
 #include <klocale.h>
 
-Timecode::Timecode(Formats format, int framesPerSecond,
-                   bool dropFrame): m_format(format), m_dropFrame(dropFrame),
+Timecode::Timecode(Formats format, int framesPerSecond, bool dropFrame) :
+        m_format(format),
+        m_dropFrame(dropFrame),
         m_displayedFramesPerSecond(framesPerSecond)
 {
 }
@@ -29,7 +30,7 @@ Timecode::~Timecode()
 {
 }
 
-int Timecode::fps()
+int Timecode::fps() const
 {
     return m_displayedFramesPerSecond;
 }
@@ -95,6 +96,26 @@ QString Timecode::getTimecodeFromFrames(int frames)
     return getTimecodeHH_MM_SS_FF(frames);
 }
 
+
+//static
+QString Timecode::getStringTimecode(int frames, const double &fps)
+{
+    // Returns the timecode in an hh:mm:ss format
+    int seconds = frames / (int) floor(fps + 0.5);
+    int minutes = seconds / 60;
+    seconds = seconds % 60;
+    int hours = minutes / 60;
+    minutes = minutes % 60;
+    QString text;
+    text.append(QString::number(hours).rightJustified(2, '0', false));
+    text.append(':');
+    text.append(QString::number(minutes).rightJustified(2, '0', false));
+    text.append(':');
+    text.append(QString::number(seconds).rightJustified(2, '0', false));
+    return text;
+}
+
+
 //static
 QString Timecode::getEasyTimecode(const GenTime & time, const double &fps)
 {
@@ -160,7 +181,6 @@ QString Timecode::getTimecodeHH_MM_SS_FF(int frames) const
     minutes = minutes % 60;
 
     QString text;
-
     text.append(QString::number(hours).rightJustified(2, '0', false));
     text.append(':');
     text.append(QString::number(minutes).rightJustified(2, '0', false));