diff options
Diffstat (limited to 'tests/downloadspeed/main.cpp')
-rw-r--r-- | tests/downloadspeed/main.cpp | 25 |
1 files changed, 4 insertions, 21 deletions
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 <kdupdaterfiledownloader.h> #include <kdupdaterfiledownloaderfactory.h> +#include <fileutils.h> + #include <QtCore/QCoreApplication> #include <QtCore/QDebug> #include <QtCore/QObject> @@ -49,26 +51,6 @@ #include <QtNetwork/QNetworkProxy> -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) |