source: trunk/qt/formatter.h @ 11054

Last change on this file since 11054 was 11054, checked in by charles, 12 years ago

(trunk qt) silence a few compiler warnings

File size: 1.2 KB
Line 
1/*
2 * This file Copyright (C) 2010 Mnemosyne LLC
3 *
4 * This file is licensed by the GPL version 2.  Works owned by the
5 * Transmission project are granted a special exemption to clause 2(b)
6 * so that the bulk of its code can remain under the MIT license.
7 * This exemption does not extend to derived works not owned by
8 * the Transmission project.
9 *
10 * $Id$
11 */
12
13#ifndef QTR_UNITS
14#define QTR_UNITS
15
16#include <QString>
17#include <QObject>
18#include <QIcon>
19
20class Speed;
21
22class Formatter: public QObject
23{
24        Q_OBJECT
25
26    public:
27
28        Formatter( ) { }
29        virtual ~Formatter( ) { }
30
31    public:
32
33        static QString memToString( uint64_t bytes );
34        static QString sizeToString( uint64_t bytes );
35        static QString speedToString( const Speed& speed );
36        static QString percentToString( double x );
37        static QString ratioToString( double ratio );
38        static QString timeToString( int seconds );
39
40    public:
41
42        typedef enum { B, KB, MB, GB, TB } Size;
43        typedef enum { SPEED, SIZE, MEM } Type;
44        static QString unitStr( Type t, Size s ) { return unitStrings[t][s]; }
45        static void initUnits( );
46
47    private:
48
49        static QString unitStrings[3][5];
50};
51
52#endif
Note: See TracBrowser for help on using the repository browser.