]> git.sesse.net Git - kdenlive/blobdiff - src/timecode.cpp
Improved Dvd Wizard (new chapters dialog)
[kdenlive] / src / timecode.cpp
index 40e7b198d3fb2cd4f3ac8bdb165489cb4d45eff7..e2fe09e26a0eb38d0ece6b2ce324e33e6db3a577 100644 (file)
@@ -30,7 +30,7 @@ Timecode::~Timecode()
 {
 }
 
-int Timecode::fps()
+int Timecode::fps() const
 {
     return m_displayedFramesPerSecond;
 }
@@ -96,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)
 {
@@ -161,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));