From c146cf3f785c7450383bffdde910fe43dd16e449 Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Thu, 21 Mar 2013 15:45:30 +0100 Subject: use humanReadableSize method from ifw lib Change-Id: I9c084e3dd57848852810dfbcce8245bf66646867 Reviewed-by: Karsten Heimrich --- tests/downloadspeed/main.cpp | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) (limited to 'tests/downloadspeed') diff --git a/tests/downloadspeed/main.cpp b/tests/downloadspeed/main.cpp index 6611ec17a..5a5b685aa 100644 --- a/tests/downloadspeed/main.cpp +++ b/tests/downloadspeed/main.cpp @@ -42,6 +42,8 @@ #include #include +#include + #include #include #include @@ -49,26 +51,6 @@ #include -static QString humanReadableSize(quint64 intSize) -{ - QString unit; - double size; - - if (intSize < 1024 * 1024) { - size = 1. + intSize / 1024.; - unit = QObject::tr("kB"); - } else if (intSize < 1024 * 1024 * 1024) { - size = 1. + intSize / 1024. / 1024.; - unit = QObject::tr("MB"); - } else { - size = 1. + intSize / 1024. / 1024. / 1024.; - unit = QObject::tr("GB"); - } - - size = qRound(size * 10) / 10.0; - return QString::fromLatin1("%L1 %2").arg(size, 0, 'g', 4).arg(unit); -} - // -- Receiver class Receiver : public QObject @@ -100,7 +82,8 @@ public slots: void downloadSpeed(qint64 speed) { - qDebug() << "Download speed:" << humanReadableSize(speed) + QLatin1String("/sec"); + qDebug() << "Download speed:" << + QInstaller::humanReadableSize(speed) + QLatin1String("/sec"); } void downloadProgress(double progress) -- cgit v1.2.3