Commit 69f937fc authored by Urs Fleisch's avatar Urs Fleisch
Browse files

convert track numbers of the form "track/total number of tracks" to numbers...

convert track numbers of the form "track/total number of tracks" to numbers before use for copy of format
parent 96f23974
......@@ -194,6 +194,22 @@ void Frame::setFieldListFromValue()
}
}
/**
* Convert string (e.g. "track/total number of tracks") to number.
*
* @param str string to convert
* @param ok if not 0, true is returned here if conversion is ok
*
* @return number in string ignoring total after slash.
*/
int Frame::numberWithoutTotal(const QString& str, bool* ok)
{
int slashPos = str.QCM_indexOf("/");
return slashPos == -1 ?
str.toInt(ok) :
str.left(slashPos).toInt(ok);
}
/**
* Set values which are different inactive.
......@@ -567,7 +583,7 @@ QString FrameFormatReplacer::getReplacement(const QString& code) const
if (name.QCM_toLower() == "track") {
bool ok;
int nr = result.toInt(&ok);
int nr = Frame::numberWithoutTotal(result, &ok);
if (ok) {
result.sprintf("%02d", nr);
}
......
......@@ -295,6 +295,16 @@ public:
*/
static char stringListSeparator() { return '|'; }
/**
* Convert string (e.g. "track/total number of tracks") to number.
*
* @param str string to convert
* @param ok if not 0, true is returned here if conversion is ok
*
* @return number in string ignoring total after slash.
*/
static int numberWithoutTotal(const QString& str, bool* ok = 0);
private:
friend class TaggedFile;
Type m_type;
......
......@@ -768,10 +768,7 @@ bool TaggedFile::setFrameV1(const Frame& frame)
} else if (frame.isEmpty()) {
n = 0;
} else {
int slashPos = frame.m_value.QCM_indexOf("/");
n = slashPos == -1 ?
frame.m_value.toInt() :
frame.m_value.left(slashPos).toInt();
n = Frame::numberWithoutTotal(frame.m_value);
}
}
switch (frame.m_type) {
......@@ -874,10 +871,7 @@ bool TaggedFile::setFrameV2(const Frame& frame)
} else if (frame.isEmpty()) {
n = 0;
} else {
int slashPos = frame.m_value.QCM_indexOf("/");
n = slashPos == -1 ?
frame.m_value.toInt() :
frame.m_value.left(slashPos).toInt();
n = Frame::numberWithoutTotal(frame.m_value);
}
}
switch (frame.m_type) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment