1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-28 10:38:45 +00:00
transmission/qt/Formatter.h

59 lines
1.1 KiB
C
Raw Normal View History

/*
* This file Copyright (C) 2012-2015 Mnemosyne LLC
*
* It may be used under the GNU GPL versions 2 or 3
* or any future license endorsed by Mnemosyne LLC.
*
*/
#pragma once
#include <cstdint> // int64_t
2015-06-12 22:12:12 +00:00
#include <QCoreApplication>
#include <QString>
class Speed;
2015-06-12 22:12:12 +00:00
class Formatter
{
Q_DECLARE_TR_FUNCTIONS(Formatter)
public:
2015-06-12 22:12:12 +00:00
enum Size
{
B,
KB,
MB,
GB,
TB
2015-06-12 22:12:12 +00:00
};
enum Type
{
SPEED,
SIZE,
MEM
2015-06-12 22:12:12 +00:00
};
public:
static QString memToString(int64_t bytes);
static QString sizeToString(int64_t bytes);
static QString speedToString(Speed const& speed);
static QString percentToString(double x);
static QString ratioToString(double ratio);
static QString timeToString(int seconds);
static QString uploadSpeedToString(Speed const& up);
static QString downloadSpeedToString(Speed const& down);
static QString unitStr(Type t, Size s)
{
return unitStrings[t][s];
}
static void initUnits();
private:
static QString unitStrings[3][5];
};