From d76058a1304149d67ef5bb64ddd78fd29119f394 Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 25 May 2016 23:29:11 +0200 Subject: [PATCH] Changed: Moved qBytesToHumanReadable to utils.h/cpp --HG-- branch : develop --- .../tools/client/ryzom_installer/src/utils.cpp | 17 +++++++++++++++++ .../tools/client/ryzom_installer/src/utils.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/code/ryzom/tools/client/ryzom_installer/src/utils.cpp b/code/ryzom/tools/client/ryzom_installer/src/utils.cpp index b5a85e3b0..4cc50f7f0 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/utils.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/utils.cpp @@ -17,6 +17,23 @@ #include "stdpch.h" #include "utils.h" +QString qBytesToHumanReadable(qint64 bytes) +{ + static std::vector units; + + if (units.empty()) + { + units.push_back(QObject::tr("B").toUtf8().constData()); + units.push_back(QObject::tr("KiB").toUtf8().constData()); + units.push_back(QObject::tr("MiB").toUtf8().constData()); + units.push_back(QObject::tr("GiB").toUtf8().constData()); + units.push_back(QObject::tr("TiB").toUtf8().constData()); + units.push_back(QObject::tr("PiB").toUtf8().constData()); + } + + return QString::fromUtf8(NLMISC::bytesToHumanReadable(bytes).c_str()); +} + QString qFromUtf8(const std::string &str) { return QString::fromUtf8(str.c_str()); diff --git a/code/ryzom/tools/client/ryzom_installer/src/utils.h b/code/ryzom/tools/client/ryzom_installer/src/utils.h index 179adae4d..a20c93260 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/utils.h +++ b/code/ryzom/tools/client/ryzom_installer/src/utils.h @@ -28,6 +28,8 @@ * \date 2016 */ +QString qBytesToHumanReadable(qint64 bytes); + // Convert a UTF-8 string to QString QString qFromUtf8(const std::string &str);