From 1ebcb405edc1e0341adb8f134215a5be1e45aef6 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Fri, 18 Apr 2008 19:13:21 +0000 Subject: fixed playlist format parsing git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@347 90c681e8-e032-0410-971d-27865f9a5e38 --- src/ui/mediafile.cpp | 38 ++++++++++++++++++++------------------ 1 file 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; } -- cgit v1.2.3-13-gbd6f