mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-28 03:40:54 +00:00
Changed: Moved qBytesToHumanReadable to utils.h/cpp
This commit is contained in:
parent
c060ec9249
commit
df5ae58965
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