Changed: Moved qBytesToHumanReadable to utils.h/cpp

This commit is contained in:
kervala 2016-05-25 23:29:11 +02:00
parent c060ec9249
commit df5ae58965
2 changed files with 19 additions and 0 deletions

View file

@ -17,6 +17,23 @@
#include "stdpch.h"
#include "utils.h"
QString qBytesToHumanReadable(qint64 bytes)
{
static std::vector<std::string> 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());

View file

@ -28,6 +28,8 @@
* \date 2016
*/
QString qBytesToHumanReadable(qint64 bytes);
// Convert a UTF-8 string to QString
QString qFromUtf8(const std::string &str);