aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2008-04-18 19:13:21 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2008-04-18 19:13:21 +0000
commit1ebcb405edc1e0341adb8f134215a5be1e45aef6 (patch)
tree57a44ebcbe13b04cf75799a37b4c858d2c7929b9
parentd3ff118ab36af60f4d09e725864d6aab1577d609 (diff)
downloadqmmp-1ebcb405edc1e0341adb8f134215a5be1e45aef6.tar.gz
qmmp-1ebcb405edc1e0341adb8f134215a5be1e45aef6.tar.bz2
qmmp-1ebcb405edc1e0341adb8f134215a5be1e45aef6.zip
fixed playlist format parsing
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@347 90c681e8-e032-0410-971d-27865f9a5e38
-rw-r--r--src/ui/mediafile.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/ui/mediafile.cpp b/src/ui/mediafile.cpp
index 1c8c1c996..2d48a335a 100644
--- a/src/ui/mediafile.cpp
+++ b/src/ui/mediafile.cpp
@@ -132,6 +132,7 @@ void MediaFile::updateTags()
void MediaFile::readMetadata()
{
+ m_title.clear();
if (m_use_meta && m_tag && !m_tag->isEmpty())
{
m_year = m_tag->year();
@@ -146,7 +147,7 @@ void MediaFile::readMetadata()
m_title = printTag(m_title, "%F", m_path);
m_title = printTag(m_title, "%y", QString("%1").arg(m_tag->year ()));
}
- else
+ if (m_title.isEmpty())
m_title = m_path.startsWith("http://") ? m_path: m_path.section('/',-1);
}
@@ -168,32 +169,33 @@ MediaFile::FLAGS MediaFile::flag() const
FileTag *MediaFile::tag()
{
- if(m_tag && m_tag->isEmpty())
+ if (m_tag && m_tag->isEmpty())
return 0;
return m_tag;
}
QString MediaFile::printTag(QString str, QString regExp, QString tagStr)
{
- if(!tagStr.isEmpty())
+ if (!tagStr.isEmpty())
str.replace(regExp, tagStr);
else
{
- //remove unused separators
- int regExpPos = str.indexOf(regExp);
- if(regExpPos < 0)
- return str;
- int nextPos = str.indexOf("%", regExpPos + 1);
- if(nextPos < 0)
- {
- //last separator
- regExpPos = m_format.lastIndexOf(regExp);
- nextPos = m_format.lastIndexOf("%", regExpPos - 1);
- QString lastSep = m_format.right (m_format.size() - nextPos - 2);
- str.remove(lastSep);
- }
- else
- str.remove ( regExpPos, nextPos - regExpPos);
+ //remove unused separators
+ int regExpPos = str.indexOf(regExp);
+ if (regExpPos < 0)
+ return str;
+ int nextPos = str.indexOf("%", regExpPos + 1);
+ if (nextPos < 0)
+ {
+ //last separator
+ regExpPos = m_format.lastIndexOf(regExp);
+ nextPos = m_format.lastIndexOf("%", regExpPos - 1);
+ QString lastSep = m_format.right (m_format.size() - nextPos - 2);
+ str.remove(lastSep);
+ str.remove(regExp);
+ }
+ else
+ str.remove ( regExpPos, nextPos - regExpPos);
}
return str;
}