Changed: Moved qBytesToHumanReadable to utils.h/cpp
--HG-- branch : develop
This commit is contained in:
parent
130b2c3c1a
commit
d76058a130
2 changed files with 19 additions and 0 deletions
|
@ -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());
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
* \date 2016
|
||||
*/
|
||||
|
||||
QString qBytesToHumanReadable(qint64 bytes);
|
||||
|
||||
// Convert a UTF-8 string to QString
|
||||
QString qFromUtf8(const std::string &str);
|
||||
|
||||
|
|
Loading…
Reference in a new issue