From e14146d9ab7368dbb428b7ea02f4a8ff48a128bf Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Wed, 3 Jul 2013 16:04:52 +0000 Subject: added length format function git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3533 90c681e8-e032-0410-971d-27865f9a5e38 --- src/qmmpui/metadataformatter.cpp | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'src/qmmpui/metadataformatter.cpp') diff --git a/src/qmmpui/metadataformatter.cpp b/src/qmmpui/metadataformatter.cpp index d7da5fb01..fa754efff 100644 --- a/src/qmmpui/metadataformatter.cpp +++ b/src/qmmpui/metadataformatter.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009-2012 by Ilya Kotov * + * Copyright (C) 2009-2013 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -73,22 +73,7 @@ QString MetaDataFormatter::parse(const QMap metaData, q title.replace("%F", metaData[Qmmp::URL]); title.replace("%y", metaData[Qmmp::YEAR]); if(title.contains("l")) - { - if (length) - { - QString time; - int l = length; - if(l > 3600) - time == QString("%1:%2:%3").arg(l/3600,2,10,QChar('0')) - .arg(l%3600/60,2,10,QChar('0')).arg(l%60,2,10,QChar('0')); - else - time = QString("%1:%2").arg(l/60,2,10,QChar('0')).arg(l%60,2,10,QChar('0')); - title.replace("%l",time); - } - else - title.replace("%l",""); - } - + title.replace("%l",formatLength(length)); if(title.contains("%if")) title = processIfKeyWord(title); title.replace("%28", "("); @@ -96,6 +81,19 @@ QString MetaDataFormatter::parse(const QMap metaData, q return title; } +QString MetaDataFormatter::formatLength(qint64 length) const +{ + if(length <= 0) + return QString(); + QString str; + if(length > 3600) + str = QString("%1:%2").arg(length/3600).arg(length%3600/60, 2, 10, QChar('0')); + else + str = QString("%1").arg(length%3600/60); + str += QString(":%1").arg(length%60, 2, 10, QChar('0')); + return str; +} + QString MetaDataFormatter::processIfKeyWord(QString title) { int pos = title.lastIndexOf("%if("); -- cgit v1.2.3-13-gbd6f