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 $
17 #include <stdint.h> // int64_t
21 class Formatter
: public QObject
28 virtual ~Formatter() {}
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
);
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 ();
50 static QString unitStrings
[3][5];