Changeset 10933


Ignore:
Timestamp:
Jul 3, 2010, 1:10:36 AM (12 years ago)
Author:
charles
Message:

(trunk) rename the Qt client's "Units" class as "Formatter"

Location:
trunk/qt
Files:
9 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/qt/app.cc

    r10931 r10933  
    3232#include "app.h"
    3333#include "dbus-adaptor.h"
     34#include "formatter.h"
    3435#include "mainwin.h"
    3536#include "options.h"
     
    3839#include "session-dialog.h"
    3940#include "torrent-model.h"
    40 #include "units.h"
    4141#include "utils.h"
    4242#include "watchdir.h"
     
    101101
    102102    // initialize the units formatter
    103     tr_formatter_mem_init( Units::mem_K,
    104                            qPrintable( Units::mem_B_str ),
    105                            qPrintable( Units::mem_K_str ),
    106                            qPrintable( Units::mem_M_str ),
    107                            qPrintable( Units::mem_G_str ) );
    108     tr_formatter_size_init( Units::size_K,
    109                             qPrintable( Units::size_B_str ),
    110                             qPrintable( Units::size_K_str ),
    111                             qPrintable( Units::size_M_str ),
    112                             qPrintable( Units::size_G_str ) );
    113     tr_formatter_speed_init( Units::speed_K,
    114                              qPrintable( Units::speed_B_str ),
    115                              qPrintable( Units::speed_K_str ),
    116                              qPrintable( Units::speed_M_str ),
    117                              qPrintable( Units::speed_G_str ) );
     103    tr_formatter_mem_init( Formatter::mem_K,
     104                           qPrintable( Formatter::mem_B_str ),
     105                           qPrintable( Formatter::mem_K_str ),
     106                           qPrintable( Formatter::mem_M_str ),
     107                           qPrintable( Formatter::mem_G_str ) );
     108    tr_formatter_size_init( Formatter::size_K,
     109                            qPrintable( Formatter::size_B_str ),
     110                            qPrintable( Formatter::size_K_str ),
     111                            qPrintable( Formatter::size_M_str ),
     112                            qPrintable( Formatter::size_G_str ) );
     113    tr_formatter_speed_init( Formatter::speed_K,
     114                             qPrintable( Formatter::speed_B_str ),
     115                             qPrintable( Formatter::speed_K_str ),
     116                             qPrintable( Formatter::speed_M_str ),
     117                             qPrintable( Formatter::speed_G_str ) );
    118118
    119119    // set the default icon
  • trunk/qt/details.cc

    r10931 r10933  
    4646#include "details.h"
    4747#include "file-tree.h"
     48#include "formatter.h"
    4849#include "hig.h"
    4950#include "prefs.h"
     
    5354#include "torrent.h"
    5455#include "torrent-model.h"
    55 #include "units.h"
    5656
    5757class Prefs;
     
    215215{
    216216    if( seconds > 60 ) seconds -= ( seconds % 60 );
    217     return Units::timeToString ( seconds );
     217    return Formatter::timeToString ( seconds );
    218218}
    219219
     
    324324        else {
    325325            const double d = 100.0 * ( sizeWhenDone ? ( sizeWhenDone - leftUntilDone ) / sizeWhenDone : 1 );
    326             QString pct = Units::percentToString( d );
     326            QString pct = Formatter::percentToString( d );
    327327            if( !haveUnverified )
    328328                string = tr( "%1 (%2%)" )
    329                              .arg( Units::sizeToString( haveVerified + haveUnverified ) )
     329                             .arg( Formatter::sizeToString( haveVerified + haveUnverified ) )
    330330                             .arg( pct );
    331331            else
    332332                string = tr( "%1 (%2%); %3 Unverified" )
    333                              .arg( Units::sizeToString( haveVerified + haveUnverified ) )
     333                             .arg( Formatter::sizeToString( haveVerified + haveUnverified ) )
    334334                             .arg( pct )
    335                              .arg( Units::sizeToString( haveUnverified ) );
     335                             .arg( Formatter::sizeToString( haveUnverified ) );
    336336        }
    337337    }
     
    345345            string = none;
    346346        else
    347             string = QString( "%1%" ).arg( Units::percentToString( ( 100.0 * available ) / sizeWhenDone ) );
     347            string = QString( "%1%" ).arg( Formatter::percentToString( ( 100.0 * available ) / sizeWhenDone ) );
    348348    }
    349349    myAvailabilityLabel->setText( string );
     
    358358            f += t->failedEver( );
    359359        }
    360         const QString dstr = Units::sizeToString( d );
    361         const QString fstr = Units::sizeToString( f );
     360        const QString dstr = Formatter::sizeToString( d );
     361        const QString fstr = Formatter::sizeToString( f );
    362362        if( f )
    363363            string = tr( "%1 (+%2 corrupt)" ).arg( dstr ).arg( fstr );
     
    372372    else {
    373373        foreach( const Torrent * t, torrents ) u += t->uploadedEver( );
    374         string = QString( Units::sizeToString( u ) );
     374        string = QString( Formatter::sizeToString( u ) );
    375375    }
    376376    myUploadedLabel->setText( string );
     
    379379        string = none;
    380380    else if( torrents.length() == 1 )
    381         string = Units::ratioToString( torrents.first()->ratio() );
     381        string = Formatter::ratioToString( torrents.first()->ratio() );
    382382    else {
    383383        bool isMixed = false;
     
    395395            string = mixed;
    396396        else if( ratioType < 0 )
    397             string = Units::ratioToString( ratioType );
     397            string = Formatter::ratioToString( ratioType );
    398398        else
    399             string = Units::ratioToString( (double)u / d );
     399            string = Formatter::ratioToString( (double)u / d );
    400400    }
    401401    myRatioLabel->setText( string );
     
    420420            string = mixed;
    421421        else
    422             string = Units::timeToString( baseline.secsTo( qdt_now ) );
     422            string = Formatter::timeToString( baseline.secsTo( qdt_now ) );
    423423    }
    424424    myRunTimeLabel->setText( string );
     
    441441                string = tr( "Unknown" );
    442442            else
    443                 string = Units::timeToString( baseline );
     443                string = Formatter::timeToString( baseline );
    444444       }
    445445    }
     
    461461            string = tr( "Active now" );
    462462        else
    463             string = tr( "%1 ago" ).arg( Units::timeToString( seconds ) );
     463            string = tr( "%1 ago" ).arg( Formatter::timeToString( seconds ) );
    464464    }
    465465    myLastActivityLabel->setText( string );
     
    503503        else if( pieceSize > 0 )
    504504            string = tr( "%1 (%Ln pieces @ %2)", "", pieces )
    505                      .arg( Units::sizeToString( size ) )
    506                      .arg( Units::memToString( pieceSize ) );
     505                     .arg( Formatter::sizeToString( size ) )
     506                     .arg( Formatter::memToString( pieceSize ) );
    507507        else
    508508            string = tr( "%1 (%Ln pieces)", "", pieces )
    509                      .arg( Units::sizeToString( size ) );
     509                     .arg( Formatter::sizeToString( size ) );
    510510    }
    511511    mySizeLabel->setText( string );
     
    637637
    638638        mySingleDownSpin->blockSignals( true );
    639         mySingleDownSpin->setValue( tor->downloadLimit().Bps() / Units::speed_K );
     639        mySingleDownSpin->setValue( tor->downloadLimit().Bps() / Formatter::speed_K );
    640640        mySingleDownSpin->blockSignals( false );
    641641
    642642        mySingleUpSpin->blockSignals( true );
    643         mySingleUpSpin->setValue( tor->uploadLimit().Bps() / Units::speed_K );
     643        mySingleUpSpin->setValue( tor->uploadLimit().Bps() / Formatter::speed_K );
    644644        mySingleUpSpin->blockSignals( false );
    645645
     
    911911                codeTip.resize( codeTip.size()-1 ); // eat the trailing linefeed
    912912
    913             item->setText( COL_UP, peer.rateToPeer.isZero() ? "" : Units::speedToString( peer.rateToPeer ) );
    914             item->setText( COL_DOWN, peer.rateToClient.isZero() ? "" : Units::speedToString( peer.rateToClient ) );
     913            item->setText( COL_UP, peer.rateToPeer.isZero() ? "" : Formatter::speedToString( peer.rateToPeer ) );
     914            item->setText( COL_DOWN, peer.rateToClient.isZero() ? "" : Formatter::speedToString( peer.rateToClient ) );
    915915            item->setText( COL_PERCENT, peer.progress > 0 ? QString( "%1%" ).arg( (int)( peer.progress * 100.0 ) ) : "" );
    916916            item->setText( COL_STATUS, code );
     
    10111011Details :: onDownloadLimitChanged( int val )
    10121012{
    1013     mySession.torrentSet( myIds, "downloadLimit", val * Units::speed_K  );
     1013    mySession.torrentSet( myIds, "downloadLimit", val * Formatter::speed_K  );
    10141014}
    10151015void
     
    10211021Details :: onUploadLimitChanged( int val )
    10221022{
    1023     mySession.torrentSet( myIds, "uploadLimit", val * Units::speed_K );
     1023    mySession.torrentSet( myIds, "uploadLimit", val * Formatter::speed_K );
    10241024}
    10251025
     
    11921192    connect( c, SIGNAL(clicked(bool)), this, SLOT(onHonorsSessionLimitsToggled(bool)) );
    11931193
    1194     c = new QCheckBox( tr( "Limit &download speed (%1):" ).arg( Units::speed_K_str ) );
     1194    c = new QCheckBox( tr( "Limit &download speed (%1):" ).arg( Formatter::speed_K_str ) );
    11951195    mySingleDownCheck = c;
    11961196    s = new QSpinBox( );
     
    12021202    connect( s, SIGNAL(valueChanged(int)), this, SLOT(onDownloadLimitChanged(int)));
    12031203
    1204     c = new QCheckBox( tr( "Limit &upload speed (%1):" ).arg( Units::speed_K_str ) );
     1204    c = new QCheckBox( tr( "Limit &upload speed (%1):" ).arg( Formatter::speed_K_str ) );
    12051205    mySingleUpCheck = c;
    12061206    s = new QSpinBox( );
  • trunk/qt/file-tree.cc

    r10931 r10933  
    2323
    2424#include "file-tree.h"
     25#include "formatter.h"
    2526#include "hig.h"
    2627#include "torrent.h" // FileList
    27 #include "units.h"
    2828#include "utils.h" // mime icons
    2929
     
    124124    QString str;
    125125    getSubtreeSize( have, total );
    126     str = QString( name() + " (%1)" ).arg( Units::sizeToString( total ) );
     126    str = QString( name() + " (%1)" ).arg( Formatter::sizeToString( total ) );
    127127    return str;
    128128}
  • trunk/qt/formatter.cc

    r10931 r10933  
    1616#include <libtransmission/utils.h> // tr_formatter
    1717
     18#include "formatter.h"
    1819#include "speed.h"
    19 #include "units.h"
    2020
    2121/***
     
    2323***/
    2424
    25 const int     Units :: speed_K     = 1000;
    26 const QString Units :: speed_B_str = "B/s";
    27 const QString Units :: speed_K_str = "kB/s";
    28 const QString Units :: speed_M_str = "MB/s";
    29 const QString Units :: speed_G_str = "GB/s";
     25const int     Formatter :: speed_K     = 1000;
     26const QString Formatter :: speed_B_str = "B/s";
     27const QString Formatter :: speed_K_str = "kB/s";
     28const QString Formatter :: speed_M_str = "MB/s";
     29const QString Formatter :: speed_G_str = "GB/s";
    3030
    31 const int     Units :: size_K     = 1000;
    32 const QString Units :: size_B_str = "B";
    33 const QString Units :: size_K_str = "kB";
    34 const QString Units :: size_M_str = "MB";
    35 const QString Units :: size_G_str = "GB";
     31const int     Formatter :: size_K     = 1000;
     32const QString Formatter :: size_B_str = "B";
     33const QString Formatter :: size_K_str = "kB";
     34const QString Formatter :: size_M_str = "MB";
     35const QString Formatter :: size_G_str = "GB";
    3636
    37 const int     Units :: mem_K     = 1024;
    38 const QString Units :: mem_B_str = "B";
    39 const QString Units :: mem_K_str = "KiB";
    40 const QString Units :: mem_M_str = "MiB";
    41 const QString Units :: mem_G_str = "GiB";
     37const int     Formatter :: mem_K     = 1024;
     38const QString Formatter :: mem_B_str = "B";
     39const QString Formatter :: mem_K_str = "KiB";
     40const QString Formatter :: mem_M_str = "MiB";
     41const QString Formatter :: mem_G_str = "GiB";
    4242
    4343/***
     
    4646
    4747QString
    48 Units :: memToString( double bytes )
     48Formatter :: memToString( double bytes )
    4949{
    5050    if( !bytes )
     
    5858
    5959QString
    60 Units :: sizeToString( double bytes )
     60Formatter :: sizeToString( double bytes )
    6161{
    6262    if( !bytes )
     
    7070
    7171QString
    72 Units :: speedToString( const Speed& speed )
     72Formatter :: speedToString( const Speed& speed )
    7373{
    7474    if( speed.isZero( ) )
     
    8282
    8383QString
    84 Units :: percentToString( double x )
     84Formatter :: percentToString( double x )
    8585{
    8686    char buf[128];
     
    8989
    9090QString
    91 Units :: ratioToString( double ratio )
     91Formatter :: ratioToString( double ratio )
    9292{
    9393    char buf[128];
     
    9696
    9797QString
    98 Units :: timeToString( int seconds )
     98Formatter :: timeToString( int seconds )
    9999{
    100100    int days, hours, minutes;
  • trunk/qt/formatter.h

    r10931 r10933  
    2020class Speed;
    2121
    22 class Units: public QObject
     22class Formatter: public QObject
    2323{
    2424        Q_OBJECT
     
    2626    public:
    2727
    28         Units( ) { }
    29         virtual ~Units( ) { }
     28        Formatter( ) { }
     29        virtual ~Formatter( ) { }
    3030
    3131    public:
  • trunk/qt/mainwin.cc

    r10931 r10933  
    3535#include "details.h"
    3636#include "filters.h"
     37#include "formatter.h"
    3738#include "hig.h"
    3839#include "mainwin.h"
     
    5253#include "triconpushbutton.h"
    5354#include "ui_mainwin.h"
    54 #include "units.h"
    5555#include "qticonloader.h"
    5656
     
    550550        g->addAction( a );
    551551        connect( a, SIGNAL(triggered(bool)), this, SLOT(onSetPrefs(bool)) );
    552         a = myDlimitOnAction = sub->addAction( tr( "Limited at %1" ).arg( Units::speedToString( Speed::fromBps( currentVal ) ) ) );
     552        a = myDlimitOnAction = sub->addAction( tr( "Limited at %1" ).arg( Formatter::speedToString( Speed::fromBps( currentVal ) ) ) );
    553553        a->setCheckable( true );
    554554        a->setProperty( PREF_VARIANTS_KEY, QVariantList() << Prefs::DSPEED << currentVal << Prefs::DSPEED_ENABLED << true );
     
    557557        sub->addSeparator( );
    558558        foreach( int i, stockSpeeds ) {
    559             const int Bps = i * Units::speed_K;
    560             a = sub->addAction( Units::speedToString( Speed::fromBps( Bps ) ) );
     559            const int Bps = i * Formatter::speed_K;
     560            a = sub->addAction( Formatter::speedToString( Speed::fromBps( Bps ) ) );
    561561            a->setProperty( PREF_VARIANTS_KEY, QVariantList() << Prefs::DSPEED << Bps << Prefs::DSPEED_ENABLED << true );
    562562            connect( a, SIGNAL(triggered(bool)), this, SLOT(onSetPrefs()));
     
    571571        g->addAction( a );
    572572        connect( a, SIGNAL(triggered(bool)), this, SLOT(onSetPrefs(bool)) );
    573         a = myUlimitOnAction = sub->addAction( tr( "Limited at %1" ).arg( Units::speedToString( Speed::fromBps( currentVal ) ) ) );
     573        a = myUlimitOnAction = sub->addAction( tr( "Limited at %1" ).arg( Formatter::speedToString( Speed::fromBps( currentVal ) ) ) );
    574574        a->setCheckable( true );
    575575        a->setProperty( PREF_VARIANTS_KEY, QVariantList() << Prefs::USPEED << currentVal << Prefs::USPEED_ENABLED << true );
     
    578578        sub->addSeparator( );
    579579        foreach( int i, stockSpeeds ) {
    580             const int Bps = i * Units::speed_K;
    581             a = sub->addAction( Units::speedToString( Speed::fromBps( Bps ) ) );
     580            const int Bps = i * Formatter::speed_K;
     581            a = sub->addAction( Formatter::speedToString( Speed::fromBps( Bps ) ) );
    582582            a->setProperty( PREF_VARIANTS_KEY, QVariantList() << Prefs::USPEED << Bps << Prefs::USPEED_ENABLED << true );
    583583            connect( a, SIGNAL(triggered(bool)), this, SLOT(onSetPrefs()));
     
    594594        g->addAction( a );
    595595        connect( a, SIGNAL(triggered(bool)), this, SLOT(onSetPrefs(bool)) );
    596         a = myRatioOnAction = sub->addAction( tr( "Stop at Ratio (%1)" ).arg( Units::ratioToString( d ) ) );
     596        a = myRatioOnAction = sub->addAction( tr( "Stop at Ratio (%1)" ).arg( Formatter::ratioToString( d ) ) );
    597597        a->setCheckable( true );
    598598        a->setProperty( PREF_VARIANTS_KEY, QVariantList() << Prefs::RATIO << d << Prefs::RATIO_ENABLED << true );
     
    601601        sub->addSeparator( );
    602602        foreach( double i, stockRatios ) {
    603             a = sub->addAction( Units::ratioToString( i ) );
     603            a = sub->addAction( Formatter::ratioToString( i ) );
    604604            a->setProperty( PREF_VARIANTS_KEY, QVariantList() << Prefs::RATIO << i << Prefs::RATIO_ENABLED << true );
    605605            connect( a, SIGNAL(triggered(bool)), this, SLOT(onSetPrefs()));
     
    736736    const Speed up( myModel.getUploadSpeed( ) );
    737737    const Speed down( myModel.getDownloadSpeed( ) );
    738     myUploadSpeedLabel->setText( Units :: speedToString( up ) );
    739     myDownloadSpeedLabel->setText( Units :: speedToString( down ) );
     738    myUploadSpeedLabel->setText( Formatter:: speedToString( up ) );
     739    myDownloadSpeedLabel->setText( Formatter:: speedToString( down ) );
    740740
    741741    myNetworkLabel->setVisible( !mySession.isServer( ) );
     
    746746    if( mode == "session-ratio" )
    747747    {
    748         str = tr( "Ratio: %1" ).arg( Units :: ratioToString( mySession.getStats().ratio ) );
     748        str = tr( "Ratio: %1" ).arg( Formatter:: ratioToString( mySession.getStats().ratio ) );
    749749    }
    750750    else if( mode == "session-transfer" )
    751751    {
    752752        const tr_session_stats& stats( mySession.getStats( ) );
    753         str = tr( "Down: %1, Up: %2" ).arg( Units :: sizeToString( stats.downloadedBytes ) )
    754                                       .arg( Units :: sizeToString( stats.uploadedBytes ) );
     753        str = tr( "Down: %1, Up: %2" ).arg( Formatter:: sizeToString( stats.downloadedBytes ) )
     754                                      .arg( Formatter:: sizeToString( stats.uploadedBytes ) );
    755755    }
    756756    else if( mode == "total-transfer" )
    757757    {
    758758        const tr_session_stats& stats( mySession.getCumulativeStats( ) );
    759         str = tr( "Down: %1, Up: %2" ).arg( Units :: sizeToString( stats.downloadedBytes ) )
    760                                       .arg( Units :: sizeToString( stats.uploadedBytes ) );
     759        str = tr( "Down: %1, Up: %2" ).arg( Formatter:: sizeToString( stats.downloadedBytes ) )
     760                                      .arg( Formatter:: sizeToString( stats.uploadedBytes ) );
    761761    }
    762762    else // default is "total-ratio"
    763763    {
    764         str = tr( "Ratio: %1" ).arg( Units :: ratioToString( mySession.getCumulativeStats().ratio ) );
     764        str = tr( "Ratio: %1" ).arg( Formatter:: ratioToString( mySession.getCumulativeStats().ratio ) );
    765765    }
    766766
     
    10141014
    10151015        case Prefs::DSPEED:
    1016             myDlimitOnAction->setText( tr( "Limited at %1" ).arg( Units::speedToString( Speed::fromBps( myPrefs.get<int>(key) ) ) ) );
     1016            myDlimitOnAction->setText( tr( "Limited at %1" ).arg( Formatter::speedToString( Speed::fromBps( myPrefs.get<int>(key) ) ) ) );
    10171017            break;
    10181018
     
    10221022
    10231023        case Prefs::USPEED:
    1024             myUlimitOnAction->setText( tr( "Limited at %1" ).arg( Units::speedToString( Speed::fromBps( myPrefs.get<int>(key) ) ) ) );
     1024            myUlimitOnAction->setText( tr( "Limited at %1" ).arg( Formatter::speedToString( Speed::fromBps( myPrefs.get<int>(key) ) ) ) );
    10251025            break;
    10261026
     
    10301030
    10311031        case Prefs::RATIO:
    1032             myRatioOnAction->setText( tr( "Stop at Ratio (%1)" ).arg( Units::ratioToString( myPrefs.get<double>(key) ) ) );
     1032            myRatioOnAction->setText( tr( "Stop at Ratio (%1)" ).arg( Formatter::ratioToString( myPrefs.get<double>(key) ) ) );
    10331033            break;
    10341034
     
    10901090            const Speed d = Speed::fromBps( myPrefs.getInt( Prefs::ALT_SPEED_LIMIT_DOWN ) );
    10911091            const Speed u = Speed::fromBps( myPrefs.getInt( Prefs::ALT_SPEED_LIMIT_UP ) );
    1092             myAltSpeedButton->setToolTip( fmt.arg( Units::speedToString( d ) )
    1093                                              .arg( Units::speedToString( u ) ) );
     1092            myAltSpeedButton->setToolTip( fmt.arg( Formatter::speedToString( d ) )
     1093                                             .arg( Formatter::speedToString( u ) ) );
    10941094            break;
    10951095        }
     
    12961296    myNetworkLabel->setToolTip( isSending || isReading
    12971297        ? tr( "Transmission server is responding" )
    1298         : tr( "Last response from server was %1 ago" ).arg( Units::timeToString( now-std::max(myLastReadTime,myLastSendTime))));
     1298        : tr( "Last response from server was %1 ago" ).arg( Formatter::timeToString( now-std::max(myLastReadTime,myLastSendTime))));
    12991299}
    13001300
  • trunk/qt/make-dialog.cc

    r10931 r10933  
    3535#include <libtransmission/utils.h>
    3636
     37#include "formatter.h"
    3738#include "hig.h"
    3839#include "make-dialog.h"
    3940#include "session.h"
    40 #include "units.h"
    4141
    4242/***
     
    283283        QString pieces = tr( "%Ln Piece(s)", 0, myBuilder->pieceCount );
    284284        text = tr( "%1 in %2; %3 @ %4" )
    285                  .arg( Units::sizeToString( myBuilder->totalSize ) )
     285                 .arg( Formatter::sizeToString( myBuilder->totalSize ) )
    286286                 .arg( files )
    287287                 .arg( pieces )
    288                  .arg( Units::sizeToString( myBuilder->pieceSize ) );
     288                 .arg( Formatter::sizeToString( myBuilder->pieceSize ) );
    289289    }
    290290
  • trunk/qt/prefs-dialog.cc

    r10931 r10933  
    3737#include <QVBoxLayout>
    3838
     39#include "formatter.h"
    3940#include "hig.h"
    4041#include "prefs.h"
     
    4243#include "qticonloader.h"
    4344#include "session.h"
    44 #include "units.h"
    4545#include "utils.h"
    4646
     
    273273    hig->addSectionTitle( tr( "Speed Limits" ) );
    274274
    275         l = checkBoxNew( tr( "Limit &download speed (%1):" ).arg( Units::speed_K_str ), Prefs::DSPEED_ENABLED );
    276         r = spinBoxNew( Prefs::DSPEED, 0, INT_MAX, 5, Units::speed_K );
     275        l = checkBoxNew( tr( "Limit &download speed (%1):" ).arg( Formatter::speed_K_str ), Prefs::DSPEED_ENABLED );
     276        r = spinBoxNew( Prefs::DSPEED, 0, INT_MAX, 5, Formatter::speed_K );
    277277        hig->addRow( l, r );
    278278        enableBuddyWhenChecked( qobject_cast<QCheckBox*>(l), r );
    279279
    280         l = checkBoxNew( tr( "Limit &upload speed (%1):" ).arg( Units::speed_K_str ), Prefs::USPEED_ENABLED );
    281         r = spinBoxNew( Prefs::USPEED, 0, INT_MAX, 5, Units::speed_K );
     280        l = checkBoxNew( tr( "Limit &upload speed (%1):" ).arg( Formatter::speed_K_str ), Prefs::USPEED_ENABLED );
     281        r = spinBoxNew( Prefs::USPEED, 0, INT_MAX, 5, Formatter::speed_K );
    282282        hig->addRow( l, r );
    283283        enableBuddyWhenChecked( qobject_cast<QCheckBox*>(l), r );
     
    299299        hig->addWideControl( new QLabel( s ) );
    300300
    301         s = tr( "Limit d&ownload speed (%1):" ).arg( Units::speed_K_str );
    302         r = spinBoxNew( Prefs :: ALT_SPEED_LIMIT_DOWN, 0, INT_MAX, 5, Units::speed_K );
     301        s = tr( "Limit d&ownload speed (%1):" ).arg( Formatter::speed_K_str );
     302        r = spinBoxNew( Prefs :: ALT_SPEED_LIMIT_DOWN, 0, INT_MAX, 5, Formatter::speed_K );
    303303        hig->addRow( s, r );
    304304
    305         s = tr( "Limit u&pload speed (%1):" ).arg( Units::speed_K_str );
    306         r = spinBoxNew( Prefs :: ALT_SPEED_LIMIT_UP, 0, INT_MAX, 5, Units::speed_K );
     305        s = tr( "Limit u&pload speed (%1):" ).arg( Formatter::speed_K_str );
     306        r = spinBoxNew( Prefs :: ALT_SPEED_LIMIT_UP, 0, INT_MAX, 5, Formatter::speed_K );
    307307        hig->addRow( s, r );
    308308
  • trunk/qt/qtr.pro

    r10931 r10933  
    3232RESOURCES += application.qrc
    3333SOURCES += about.cc app.cc dbus-adaptor.cc details.cc file-tree.cc filters.cc \
    34            hig.cc license.cc mainwin.cc make-dialog.cc options.cc prefs.cc \
    35            prefs-dialog.cc qticonloader.cc relocate.cc session.cc \
     34           formatter.cc hig.cc license.cc mainwin.cc make-dialog.cc options.cc \
     35           prefs.cc prefs-dialog.cc qticonloader.cc relocate.cc session.cc \
    3636           session-dialog.cc squeezelabel.cc stats-dialog.cc torrent.cc \
    3737           torrent-delegate.cc torrent-delegate-min.cc torrent-filter.cc \
    38            torrent-model.cc triconpushbutton.cc units.cc utils.cc watchdir.cc
     38           torrent-model.cc triconpushbutton.cc utils.cc watchdir.cc
    3939HEADERS += $$replace(SOURCES, .cc, .h)
    4040HEADERS += speed.h types.h
  • trunk/qt/stats-dialog.cc

    r10931 r10933  
    1616#include <QVBoxLayout>
    1717
     18#include "formatter.h"
    1819#include "hig.h"
    1920#include "session.h"
    2021#include "stats-dialog.h"
    21 #include "units.h"
    2222
    2323enum
     
    8686    const struct tr_session_stats& total( mySession.getCumulativeStats( ) );
    8787
    88     myCurrentUp->setText( Units::sizeToString( current.uploadedBytes ) );
    89     myCurrentDown->setText( Units::sizeToString( current.downloadedBytes ) );
    90     myCurrentRatio->setText( Units::ratioToString( current.ratio ) );
    91     myCurrentDuration->setText( Units::timeToString( current.secondsActive ) );
     88    myCurrentUp->setText( Formatter::sizeToString( current.uploadedBytes ) );
     89    myCurrentDown->setText( Formatter::sizeToString( current.downloadedBytes ) );
     90    myCurrentRatio->setText( Formatter::ratioToString( current.ratio ) );
     91    myCurrentDuration->setText( Formatter::timeToString( current.secondsActive ) );
    9292
    93     myTotalUp->setText( Units::sizeToString( total.uploadedBytes ) );
    94     myTotalDown->setText( Units::sizeToString( total.downloadedBytes ) );
    95     myTotalRatio->setText( Units::ratioToString( total.ratio ) );
    96     myTotalDuration->setText( Units::timeToString( total.secondsActive ) );
     93    myTotalUp->setText( Formatter::sizeToString( total.uploadedBytes ) );
     94    myTotalDown->setText( Formatter::sizeToString( total.downloadedBytes ) );
     95    myTotalRatio->setText( Formatter::ratioToString( total.ratio ) );
     96    myTotalDuration->setText( Formatter::timeToString( total.secondsActive ) );
    9797
    9898    myStartCount->setText( tr( "Started %n time(s)", 0, total.sessionCount ) );
  • trunk/qt/torrent-delegate.cc

    r10931 r10933  
    2424#include <QStyleOptionProgressBarV2>
    2525
     26#include "formatter.h"
    2627#include "torrent.h"
    2728#include "torrent-delegate.h"
    2829#include "torrent-model.h"
    29 #include "units.h"
    3030
    3131enum
     
    7575        /* %1 is the percentage of torrent metadata downloaded */
    7676        str = tr( "Magnetized transfer - retrieving metadata (%1%)" )
    77             .arg( Units::percentToString( tor.metadataPercentDone() * 100.0 ) );
     77            .arg( Formatter::percentToString( tor.metadataPercentDone() * 100.0 ) );
    7878    }
    7979    else if( !isDone ) // downloading
     
    8282           %2 is how much we'll have when done,
    8383           %3 is a percentage of the two */
    84         str = tr( "%1 of %2 (%3%)" ).arg( Units::sizeToString( haveTotal ) )
    85                                     .arg( Units::sizeToString( tor.sizeWhenDone( ) ) )
    86                                     .arg( Units::percentToString( tor.percentDone( ) * 100.0 ) );
     84        str = tr( "%1 of %2 (%3%)" ).arg( Formatter::sizeToString( haveTotal ) )
     85                                    .arg( Formatter::sizeToString( tor.sizeWhenDone( ) ) )
     86                                    .arg( Formatter::percentToString( tor.percentDone( ) * 100.0 ) );
    8787    }
    8888    else if( !isSeed ) // partial seed
     
    9797               %6 is the ratio we want to reach before we stop uploading */
    9898            str = tr( "%1 of %2 (%3%), uploaded %4 (Ratio: %5 Goal: %6)" )
    99                   .arg( Units::sizeToString( haveTotal ) )
    100                   .arg( Units::sizeToString( tor.totalSize( ) ) )
    101                   .arg( Units::percentToString( tor.percentComplete( ) * 100.0 ) )
    102                   .arg( Units::sizeToString( tor.uploadedEver( ) ) )
    103                   .arg( Units::ratioToString( tor.ratio( ) ) )
    104                   .arg( Units::ratioToString( seedRatio ) );
     99                  .arg( Formatter::sizeToString( haveTotal ) )
     100                  .arg( Formatter::sizeToString( tor.totalSize( ) ) )
     101                  .arg( Formatter::percentToString( tor.percentComplete( ) * 100.0 ) )
     102                  .arg( Formatter::sizeToString( tor.uploadedEver( ) ) )
     103                  .arg( Formatter::ratioToString( tor.ratio( ) ) )
     104                  .arg( Formatter::ratioToString( seedRatio ) );
    105105        }
    106106        else
     
    112112               %5 is our upload-to-download ratio */
    113113            str = tr( "%1 of %2 (%3%), uploaded %4 (Ratio: %5)" )
    114                   .arg( Units::sizeToString( haveTotal ) )
    115                   .arg( Units::sizeToString( tor.totalSize( ) ) )
    116                   .arg( Units::percentToString( tor.percentComplete( ) * 100.0 ) )
    117                   .arg( Units::sizeToString( tor.uploadedEver( ) ) )
    118                   .arg( Units::ratioToString( tor.ratio( ) ) );
     114                  .arg( Formatter::sizeToString( haveTotal ) )
     115                  .arg( Formatter::sizeToString( tor.totalSize( ) ) )
     116                  .arg( Formatter::percentToString( tor.percentComplete( ) * 100.0 ) )
     117                  .arg( Formatter::sizeToString( tor.uploadedEver( ) ) )
     118                  .arg( Formatter::ratioToString( tor.ratio( ) ) );
    119119        }
    120120    }
     
    128128               %4 is the ratio we want to reach before we stop uploading */
    129129            str = tr( "%1, uploaded %2 (Ratio: %3 Goal %4)" )
    130                   .arg( Units::sizeToString( haveTotal ) )
    131                   .arg( Units::sizeToString( tor.uploadedEver( ) ) )
    132                   .arg( Units::ratioToString( tor.ratio( ) ) )
    133                   .arg( Units::ratioToString( seedRatio ) );
     130                  .arg( Formatter::sizeToString( haveTotal ) )
     131                  .arg( Formatter::sizeToString( tor.uploadedEver( ) ) )
     132                  .arg( Formatter::ratioToString( tor.ratio( ) ) )
     133                  .arg( Formatter::ratioToString( seedRatio ) );
    134134        }
    135135        else /* seeding w/o a ratio */
     
    139139               %3 is our upload-to-download ratio */
    140140            str = tr( "%1, uploaded %2 (Ratio: %3)" )
    141                   .arg( Units::sizeToString( haveTotal ) )
    142                   .arg( Units::sizeToString( tor.uploadedEver( ) ) )
    143                   .arg( Units::ratioToString( tor.ratio( ) ) );
     141                  .arg( Formatter::sizeToString( haveTotal ) )
     142                  .arg( Formatter::sizeToString( tor.uploadedEver( ) ) )
     143                  .arg( Formatter::ratioToString( tor.ratio( ) ) );
    144144        }
    145145    }
     
    150150        str += tr( " - " );
    151151        if( tor.hasETA( ) )
    152             str += tr( "%1 left" ).arg( Units::timeToString( tor.getETA( ) ) );
     152            str += tr( "%1 left" ).arg( Formatter::timeToString( tor.getETA( ) ) );
    153153        else
    154154            str += tr( "Remaining time unknown" );
     
    167167
    168168    if( haveDown )
    169         downStr = Units::speedToString( tor.downloadSpeed( ) );
     169        downStr = Formatter::speedToString( tor.downloadSpeed( ) );
    170170    if( haveUp )
    171         upStr = Units::speedToString( tor.uploadSpeed( ) );
     171        upStr = Formatter::speedToString( tor.uploadSpeed( ) );
    172172
    173173    if( haveDown && haveUp )
     
    191191    {
    192192        case TR_STATUS_CHECK:
    193             str = tr( "Verifying local data (%1% tested)" ).arg( Units::percentToString( tor.getVerifyProgress()*100.0 ) );
     193            str = tr( "Verifying local data (%1% tested)" ).arg( Formatter::percentToString( tor.getVerifyProgress()*100.0 ) );
    194194            break;
    195195
     
    197197        case TR_STATUS_SEED:
    198198            if( !tor.isDownloading( ) )
    199                 str = tr( "Ratio: %1, " ).arg( Units::ratioToString( tor.ratio( ) ) );
     199                str = tr( "Ratio: %1, " ).arg( Formatter::ratioToString( tor.ratio( ) ) );
    200200            str += shortTransferString( tor );
    201201            break;
     
    232232            else
    233233                str = tr( "Downloading metadata from %n peer(s) (%1% done)", 0, tor.peersWeAreDownloadingFrom( ) )
    234                         .arg( Units::percentToString( 100.0 * tor.metadataPercentDone( ) ) );
     234                        .arg( Formatter::percentToString( 100.0 * tor.metadataPercentDone( ) ) );
    235235            break;
    236236
Note: See TracChangeset for help on using the changeset viewer.