Changeset 10721
- Timestamp:
- Jun 3, 2010, 11:39:31 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/qt/details.cc
r10720 r10721 282 282 int64_t haveUnverified = 0; 283 283 int64_t verifiedPieces = 0; 284 foreach( const Torrent * t, torrents ) { 285 if( t->hasMetadata( ) ) { 286 haveTotal += t->haveTotal( ); 287 haveUnverified += t->haveUnverified( ); 288 const uint64_t v = t->haveVerified( ); 289 haveVerified += v; 290 verifiedPieces += v / t->pieceSize( ); 291 sizeWhenDone += t->sizeWhenDone( ); 292 leftUntilDone += t->leftUntilDone( ); 293 available += t->sizeWhenDone() - t->leftUntilDone() + t->desiredAvailable(); 294 } 295 } 296 if( !haveVerified && !haveUnverified ) 297 string = none; 298 else { 299 const double d = 100.0 * ( sizeWhenDone ? ( sizeWhenDone - leftUntilDone ) / sizeWhenDone : 1 ); 300 QString pct = locale.toString( d, 'f', 2 ); 301 if( !haveUnverified ) 302 string = tr( "%1 (%2%)" ) 303 .arg( Utils :: sizeToString( haveVerified + haveUnverified ) ) 304 .arg( pct ); 305 else 306 string = tr( "%1 (%2%); %3 Unverified" ) 307 .arg( Utils :: sizeToString( haveVerified + haveUnverified ) ) 308 .arg( pct ) 309 .arg( Utils :: sizeToString( haveUnverified ) ); 284 if( torrents.empty( ) ) 285 string = none; 286 else { 287 foreach( const Torrent * t, torrents ) { 288 if( t->hasMetadata( ) ) { 289 haveTotal += t->haveTotal( ); 290 haveUnverified += t->haveUnverified( ); 291 const uint64_t v = t->haveVerified( ); 292 haveVerified += v; 293 verifiedPieces += v / t->pieceSize( ); 294 sizeWhenDone += t->sizeWhenDone( ); 295 leftUntilDone += t->leftUntilDone( ); 296 available += t->sizeWhenDone() - t->leftUntilDone() + t->desiredAvailable(); 297 } 298 } 299 if( !haveVerified && !haveUnverified ) 300 string = none; 301 else { 302 const double d = 100.0 * ( sizeWhenDone ? ( sizeWhenDone - leftUntilDone ) / sizeWhenDone : 1 ); 303 QString pct = locale.toString( d, 'f', 2 ); 304 if( !haveUnverified ) 305 string = tr( "%1 (%2%)" ) 306 .arg( Utils :: sizeToString( haveVerified + haveUnverified ) ) 307 .arg( pct ); 308 else 309 string = tr( "%1 (%2%); %3 Unverified" ) 310 .arg( Utils :: sizeToString( haveVerified + haveUnverified ) ) 311 .arg( pct ) 312 .arg( Utils :: sizeToString( haveUnverified ) ); 313 } 310 314 } 311 315 myHaveLabel->setText( string ); … … 319 323 320 324 // myDownloadedLabel 321 if( torrents.empty( ) )322 string = none;323 else {324 uint64_t d=0, f=0;325 uint64_t d = 0, f = 0; 326 if( torrents.empty( ) ) 327 string = none; 328 else { 325 329 foreach( const Torrent * t, torrents ) { 326 330 d += t->downloadedEver( ); … … 336 340 myDownloadedLabel->setText( string ); 337 341 338 uint64_t sum = 0; 339 foreach( const Torrent * t, torrents ) sum += t->uploadedEver( ); 340 myUploadedLabel->setText( Utils::sizeToString( sum ) ); 341 342 double d = 0; 343 foreach( const Torrent *t, torrents ) d += t->ratio( ); 344 myRatioLabel->setText( Utils :: ratioToString( d / n ) ); 342 uint64_t u = 0; 343 if( torrents.empty( ) ) 344 string = none; 345 else { 346 foreach( const Torrent * t, torrents ) u += t->uploadedEver( ); 347 string = QString( Utils::sizeToString( u ) ); 348 } 349 myUploadedLabel->setText( string ); 350 351 if( torrents.empty( ) ) 352 string = none; 353 else if( torrents.length() == 1 ) 354 string = QString( Utils :: ratioToString( torrents.first()->ratio() ) ); 355 else { 356 bool isMixed = false; 357 int ratioType = torrents.first()->ratio(); 358 if( ratioType > 0 ) ratioType = 0; 359 foreach( const Torrent *t, torrents ) 360 { 361 if( ratioType != ( t->ratio() >= 0 ? 0 : t->ratio() ) ) 362 { 363 isMixed = true; 364 break; 365 } 366 } 367 if( isMixed ) 368 string = mixed; 369 else if( ratioType < 0 ) 370 string = QString( Utils :: ratioToString( ratioType ) ); 371 else 372 string = QString( Utils :: ratioToString( (double)u / d ) ); 373 } 374 myRatioLabel->setText( string ); 345 375 346 376 const QDateTime qdt_now = QDateTime::currentDateTime( );
Note: See TracChangeset
for help on using the changeset viewer.