Changeset 11234
- Timestamp:
- Sep 19, 2010, 5:33:25 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gtk/details.c
r11216 r11234 65 65 GtkWidget * dl_lb; 66 66 GtkWidget * ul_lb; 67 GtkWidget * ratio_lb;68 67 GtkWidget * error_lb; 69 68 GtkWidget * date_started_lb; … … 861 860 str = no_torrent; 862 861 else { 863 uint64_t sum = 0;864 for( i=0; i<n; ++i ) sum += stats[i]->uploadedEver;865 str = tr_strlsize( buf, sum, sizeof( buf ) );866 }867 gtr_label_set_text( GTK_LABEL( di->ul_lb ), str );868 869 870 /* ratio */871 if( n <= 0 )872 str = no_torrent;873 else {874 862 uint64_t up = 0; 875 863 uint64_t down = 0; 864 char upstr[64]; 865 char ratiostr[64]; 876 866 for( i=0; i<n; ++i ) { 877 867 up += stats[i]->uploadedEver; 878 868 down += stats[i]->downloadedEver; 879 869 } 880 str = tr_strlratio( buf, tr_getRatio( up, down ), sizeof( buf ) ); 881 } 882 gtr_label_set_text( GTK_LABEL( di->ratio_lb ), str ); 870 tr_strlsize( upstr, up, sizeof( upstr ) ); 871 tr_strlratio( ratiostr, tr_getRatio( up, down ), sizeof( ratiostr ) ); 872 g_snprintf( buf, sizeof( buf ), _( "%s (Ratio: %s)" ), upstr, ratiostr ); 873 str = buf; 874 } 875 gtr_label_set_text( GTK_LABEL( di->ul_lb ), str ); 883 876 884 877 /* hash_lb */ … … 962 955 l = di->ul_lb = gtk_label_new( NULL ); 963 956 hig_workarea_add_row( t, &row, _( "Uploaded:" ), l, NULL ); 964 965 /* ratio */966 l = di->ratio_lb = gtk_label_new( NULL );967 hig_workarea_add_row( t, &row, _( "Ratio:" ), l, NULL );968 957 969 958 /* state */ -
trunk/qt/details.cc
r11222 r11234 46 46 #include <libtransmission/transmission.h> 47 47 #include <libtransmission/bencode.h> 48 #include <libtransmission/utils.h> // tr_getRatio() 48 49 49 50 #include "details.h" … … 427 428 myDownloadedLabel->setText( string ); 428 429 429 uint64_t u = 0; 430 if( torrents.empty( ) ) 431 string = none; 432 else { 433 foreach( const Torrent * t, torrents ) u += t->uploadedEver( ); 434 string = QString( Formatter::sizeToString( u ) ); 430 if( torrents.empty( ) ) 431 string = none; 432 else { 433 uint64_t u = 0; 434 uint64_t d = 0; 435 foreach( const Torrent * t, torrents ) { 436 u += t->uploadedEver( ); 437 d += t->downloadedEver( ); 438 } 439 string = tr( "%1 (Ratio: %2)" ) 440 .arg( Formatter::sizeToString( u ) ) 441 .arg( Formatter::ratioToString( tr_getRatio( u, d ) ) ); 435 442 } 436 443 myUploadedLabel->setText( string ); 437 438 if( torrents.empty( ) )439 string = none;440 else if( torrents.count() == 1 )441 string = Formatter::ratioToString( torrents.first()->ratio() );442 else {443 bool isMixed = false;444 int ratioType = (int) torrents.first()->ratio();445 if( ratioType > 0 ) ratioType = 0;446 foreach( const Torrent *t, torrents )447 {448 if( ratioType != ( t->ratio() >= 0 ? 0 : t->ratio() ) )449 {450 isMixed = true;451 break;452 }453 }454 if( isMixed )455 string = mixed;456 else if( ratioType < 0 )457 string = Formatter::ratioToString( ratioType );458 else459 string = Formatter::ratioToString( (double)u / d );460 }461 myRatioLabel->setText( string );462 444 463 445 const QDateTime qdt_now = QDateTime::currentDateTime( ); … … 861 843 hig->addRow( tr( "Downloaded:" ), myDownloadedLabel = new SqueezeLabel ); 862 844 hig->addRow( tr( "Uploaded:" ), myUploadedLabel = new SqueezeLabel ); 863 hig->addRow( tr( "Ratio:" ), myRatioLabel = new SqueezeLabel );864 845 hig->addRow( tr( "State:" ), myStateLabel = new SqueezeLabel ); 865 846 hig->addRow( tr( "Running time:" ), myRunTimeLabel = new SqueezeLabel ); -
trunk/qt/details.h
r11092 r11234 84 84 QLabel * myDownloadedLabel; 85 85 QLabel * myUploadedLabel; 86 QLabel * myRatioLabel;87 86 QLabel * myErrorLabel; 88 87 QLabel * myRunTimeLabel;
Note: See TracChangeset
for help on using the changeset viewer.