Much simplified indexToString() using a QTime object.
This commit is contained in:
parent
352bfd4864
commit
45dd277e99
@ -30,7 +30,7 @@
|
|||||||
#define VER_LAMEXP_MINOR_LO 2
|
#define VER_LAMEXP_MINOR_LO 2
|
||||||
#define VER_LAMEXP_TYPE Beta
|
#define VER_LAMEXP_TYPE Beta
|
||||||
#define VER_LAMEXP_PATCH 1
|
#define VER_LAMEXP_PATCH 1
|
||||||
#define VER_LAMEXP_BUILD 532
|
#define VER_LAMEXP_BUILD 533
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Tools versions
|
// Tools versions
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
|
#include <QTime>
|
||||||
|
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
@ -796,22 +797,16 @@ double CueSheetModel::parseTimeIndex(const QString &index)
|
|||||||
|
|
||||||
QString CueSheetModel::indexToString(const double index) const
|
QString CueSheetModel::indexToString(const double index) const
|
||||||
{
|
{
|
||||||
if(!_finite(index) || (index < 0.0))
|
if(!_finite(index) || (index < 0.0) || (index > 86400.0))
|
||||||
{
|
{
|
||||||
return QString("??:??.???");
|
return QString("??:??.???");
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int temp = static_cast<unsigned int>(floor(0.5 + (index * 1000.0)));
|
|
||||||
|
|
||||||
unsigned int msec = temp % 1000;
|
|
||||||
unsigned int secs = temp / 1000;
|
|
||||||
unsigned int mins = secs / 60;
|
|
||||||
|
|
||||||
secs = secs % 60;
|
QTime time = QTime().addMSecs(static_cast<int>(floor(0.5 + (index * 1000.0))));
|
||||||
|
|
||||||
if(mins < 100)
|
if(time.minute() < 100)
|
||||||
{
|
{
|
||||||
return QString().sprintf("%02u:%02u.%03u", mins, secs, msec);
|
return time.toString("mm:ss.zzz");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -56,13 +56,13 @@ CueSplitter::CueSplitter(const QString &outputDir, const QString &baseName, CueS
|
|||||||
m_decompressedFiles.clear();
|
m_decompressedFiles.clear();
|
||||||
m_tempFiles.clear();
|
m_tempFiles.clear();
|
||||||
|
|
||||||
qDebug("\n[CueSplitter::CueSplitter]");
|
qDebug("\n[CueSplitter]");
|
||||||
|
|
||||||
int nInputFiles = inputFilesInfo.count();
|
int nInputFiles = inputFilesInfo.count();
|
||||||
for(int i = 0; i < nInputFiles; i++)
|
for(int i = 0; i < nInputFiles; i++)
|
||||||
{
|
{
|
||||||
m_inputFilesInfo.insert(inputFilesInfo[i].filePath(), inputFilesInfo[i]);
|
m_inputFilesInfo.insert(inputFilesInfo[i].filePath(), inputFilesInfo[i]);
|
||||||
qDebug("%02d <%s>", i, inputFilesInfo[i].filePath().toUtf8().constData());
|
qDebug("File %02d: <%s>", i, inputFilesInfo[i].filePath().toUtf8().constData());
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("All input files added.");
|
qDebug("All input files added.");
|
||||||
@ -380,33 +380,13 @@ void CueSplitter::splitFile(const QString &output, const int trackNo, const QStr
|
|||||||
|
|
||||||
QString CueSplitter::indexToString(const double index) const
|
QString CueSplitter::indexToString(const double index) const
|
||||||
{
|
{
|
||||||
if(!_finite(index) || (index < 0.0))
|
if(!_finite(index) || (index < 0.0) || (index > 86400.0))
|
||||||
{
|
{
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int temp = static_cast<unsigned int>(floor(0.5 + (index * 1000.0)));
|
|
||||||
|
|
||||||
unsigned int msec = temp % 1000;
|
|
||||||
unsigned int secs = temp / 1000;
|
|
||||||
unsigned int mins = secs / 60;
|
|
||||||
unsigned int hour = mins / 60;
|
|
||||||
|
|
||||||
secs = secs % 60;
|
QTime time = QTime().addMSecs(static_cast<int>(floor(0.5 + (index * 1000.0))));
|
||||||
mins = mins % 60;
|
return time.toString(time.hour() ? "H:mm:ss.zzz" : "m:ss.zzz");
|
||||||
|
|
||||||
if(hour > 0)
|
|
||||||
{
|
|
||||||
return QString().sprintf("%u:%02u:%02u.%03u", hour, mins, secs, msec);
|
|
||||||
}
|
|
||||||
else if(mins > 0)
|
|
||||||
{
|
|
||||||
return QString().sprintf("%u:%02u.%03u", mins, secs, msec);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return QString().sprintf("%u.%03u", secs, msec);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user