aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2015-10-17 18:35:12 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2015-10-17 18:35:12 +0000
commit1d87ffad1ce5c939c9e94483c7a762fc0047886c (patch)
tree42879e4bb2fea6bebbfbed0eb760a42df6f00f04 /src
parentb73fba01452d31c6bf13ea6c4662dfc41a47116a (diff)
downloadqmmp-1d87ffad1ce5c939c9e94483c7a762fc0047886c.tar.gz
qmmp-1d87ffad1ce5c939c9e94483c7a762fc0047886c.tar.bz2
qmmp-1d87ffad1ce5c939c9e94483c7a762fc0047886c.zip
improved function MetaDataFormatter::formatLength
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@5700 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src')
-rw-r--r--src/plugins/Ui/qsui/mainwindow.cpp6
-rw-r--r--src/qmmpui/metadataformatter.cpp4
-rw-r--r--src/qmmpui/metadataformatter.h5
3 files changed, 8 insertions, 7 deletions
diff --git a/src/plugins/Ui/qsui/mainwindow.cpp b/src/plugins/Ui/qsui/mainwindow.cpp
index 80f2202f3..b7c44e363 100644
--- a/src/plugins/Ui/qsui/mainwindow.cpp
+++ b/src/plugins/Ui/qsui/mainwindow.cpp
@@ -195,9 +195,7 @@ void MainWindow::updatePosition(qint64 pos)
if(!m_slider->isSliderDown())
m_slider->setValue(pos/1000);
- QString text = MetaDataFormatter::formatLength(pos/1000);
- if(text.isEmpty())
- text = "0:00";
+ QString text = MetaDataFormatter::formatLength(pos/1000, false);
if(m_core->totalTime() > 1000)
{
text.append("/");
@@ -382,7 +380,7 @@ void MainWindow::updateStatus()
.arg(m_core->channels())
.arg(m_core->frequency())
.arg(tracks)
- .arg(MetaDataFormatter::formatLength(length))
+ .arg(MetaDataFormatter::formatLength(length, false))
.arg(m_core->bitrate()));
}
else if(m_core->state() == Qmmp::Stopped)
diff --git a/src/qmmpui/metadataformatter.cpp b/src/qmmpui/metadataformatter.cpp
index 017c0d120..c63938560 100644
--- a/src/qmmpui/metadataformatter.cpp
+++ b/src/qmmpui/metadataformatter.cpp
@@ -105,10 +105,10 @@ QString MetaDataFormatter::format(const QMap<Qmmp::MetaData, QString> &metaData,
return evalute(&m_nodes, &metaData, length, track).trimmed();
}
-QString MetaDataFormatter::formatLength(qint64 length)
+QString MetaDataFormatter::formatLength(qint64 length, bool hideZero)
{
if(length <= 0)
- return QString();
+ return hideZero ? QString() : "0:00";
QString str;
if(length >= 3600)
str = QString("%1:%2").arg(length/3600).arg(length%3600/60, 2, 10, QChar('0'));
diff --git a/src/qmmpui/metadataformatter.h b/src/qmmpui/metadataformatter.h
index 8f841ba9f..967087e4f 100644
--- a/src/qmmpui/metadataformatter.h
+++ b/src/qmmpui/metadataformatter.h
@@ -79,8 +79,11 @@ public:
/*!
* Returns formatted length (example: 05:02:03).
* \param length Length in seconds.
+ * \param hideZero Setting for zero values output.
+ * If \b hideZero is \b true, then the function outputs empty string for zero length,
+ * otherwise outputs "0:00".
*/
- static QString formatLength(qint64 length);
+ static QString formatLength(qint64 length, bool hideZero = true);
private:
struct Node;