transmission 2.83
[tomato.git] / release / src-rt-6.x.4708 / router / transmission / qt / formatter.h
blobce7f462ab1844b7b01625d18fb325390aa9509dd
1 /*
2 * This file Copyright (C) 2012-2014 Mnemosyne LLC
4 * It may be used under the GNU GPL versions 2 or 3
5 * or any future license endorsed by Mnemosyne LLC.
7 * $Id: formatter.h 14241 2014-01-21 03:10:30Z jordan $
8 */
10 #ifndef QTR_UNITS
11 #define QTR_UNITS
13 #include <QString>
14 #include <QObject>
15 #include <QIcon>
17 #include <stdint.h> // int64_t
19 class Speed;
21 class Formatter: public QObject
23 Q_OBJECT
25 public:
27 Formatter() {}
28 virtual ~Formatter() {}
30 public:
32 static QString memToString (int64_t bytes);
33 static QString sizeToString (int64_t bytes);
34 static QString speedToString (const Speed& speed);
35 static QString percentToString (double x);
36 static QString ratioToString (double ratio);
37 static QString timeToString (int seconds);
38 static QString uploadSpeedToString(const Speed& up);
39 static QString downloadSpeedToString(const Speed& down);
41 public:
43 typedef enum { B, KB, MB, GB, TB } Size;
44 typedef enum { SPEED, SIZE, MEM } Type;
45 static QString unitStr (Type t, Size s) { return unitStrings[t][s]; }
46 static void initUnits ();
48 private:
50 static QString unitStrings[3][5];
53 #endif