Revert "transmission: update from 2.13 to 2.22"
[tomato.git] / release / src / router / transmission / qt / formatter.h
blob37330142054558b54d06bd6ff3d88a29449f73d1
1 /*
2 * This file Copyright (C) Mnemosyne LLC
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2
6 * as published by the Free Software Foundation.
8 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10 * $Id: formatter.h 11092 2010-08-01 20:36:13Z charles $
13 #ifndef QTR_UNITS
14 #define QTR_UNITS
16 #include <inttypes.h> /* uint64_t */
18 #include <QString>
19 #include <QObject>
20 #include <QIcon>
22 class Speed;
24 class Formatter: public QObject
26 Q_OBJECT
28 public:
30 Formatter( ) { }
31 virtual ~Formatter( ) { }
33 public:
35 static QString memToString( uint64_t bytes );
36 static QString sizeToString( uint64_t bytes );
37 static QString speedToString( const Speed& speed );
38 static QString percentToString( double x );
39 static QString ratioToString( double ratio );
40 static QString timeToString( int seconds );
42 public:
44 typedef enum { B, KB, MB, GB, TB } Size;
45 typedef enum { SPEED, SIZE, MEM } Type;
46 static QString unitStr( Type t, Size s ) { return unitStrings[t][s]; }
47 static void initUnits( );
49 private:
51 static QString unitStrings[3][5];
54 #endif