(trunk gtk,qt) #3094 "Show ratio goal for partial seeds" -- implemented in trunk for 2.00, based off Longinus00's patch

This commit is contained in:
Charles Kerr 2010-04-01 06:08:20 +00:00
parent def9a6aba3
commit 0706901e78
2 changed files with 117 additions and 72 deletions

View File

@ -49,12 +49,12 @@ getProgressString( const tr_torrent * tor,
const int isDone = torStat->leftUntilDone == 0;
const uint64_t haveTotal = torStat->haveUnchecked + torStat->haveValid;
const int isSeed = torStat->haveValid >= info->totalSize;
char buf1[32], buf2[32], buf3[32], buf4[32];
char buf1[32], buf2[32], buf3[32], buf4[32], buf5[32];
char * str;
double seedRatio;
gboolean hasSeedRatio = FALSE;
const gboolean hasSeedRatio = tr_torrentGetSeedRatio( tor, &seedRatio );
if( !isDone )
if( !isDone ) /* downloading */
{
str = g_strdup_printf(
/* %1$s is how much we've got,
@ -65,44 +65,67 @@ getProgressString( const tr_torrent * tor,
tr_strlsize( buf2, torStat->sizeWhenDone, sizeof( buf2 ) ),
tr_truncd( torStat->percentDone * 100.0, 2 ) );
}
else if( !isSeed )
else if( !isSeed ) /* partial seeds */
{
str = g_strdup_printf(
/* %1$s is how much we've got,
%2$s is the torrent's total size,
%3$.2f%% is a percentage of the two,
%4$s is how much we've uploaded,
%5$s is our upload-to-download ratio */
_( "%1$s of %2$s (%3$.2f%%), uploaded %4$s (Ratio: %5$s)" ),
tr_strlsize( buf1, haveTotal, sizeof( buf1 ) ),
tr_strlsize( buf2, info->totalSize, sizeof( buf2 ) ),
tr_truncd( torStat->percentComplete * 100.0, 2 ),
tr_strlsize( buf3, torStat->uploadedEver, sizeof( buf3 ) ),
tr_strlratio( buf4, torStat->ratio, sizeof( buf4 ) ) );
if( hasSeedRatio )
{
str = g_strdup_printf(
/* %1$s is how much we've got,
%2$s is the torrent's total size,
%3$.2f%% is a percentage of the two,
%4$s is how much we've uploaded,
%5$s is our upload-to-download ratio,
%6$s is the ratio we want to reach before we stop uploading */
_( "%1$s of %2$s (%3$.2f%%), uploaded %4$s (Ratio: %5$s Goal: %6$s)" ),
tr_strlsize( buf1, haveTotal, sizeof( buf1 ) ),
tr_strlsize( buf2, info->totalSize, sizeof( buf2 ) ),
tr_truncd( torStat->percentComplete * 100.0, 2 ),
tr_strlsize( buf3, torStat->uploadedEver, sizeof( buf3 ) ),
tr_strlratio( buf4, torStat->ratio, sizeof( buf4 ) ),
tr_strlratio( buf5, seedRatio, sizeof( buf5 ) ) );
}
else
{
str = g_strdup_printf(
/* %1$s is how much we've got,
%2$s is the torrent's total size,
%3$.2f%% is a percentage of the two,
%4$s is how much we've uploaded,
%5$s is our upload-to-download ratio */
_( "%1$s of %2$s (%3$.2f%%), uploaded %4$s (Ratio: %5$s)" ),
tr_strlsize( buf1, haveTotal, sizeof( buf1 ) ),
tr_strlsize( buf2, info->totalSize, sizeof( buf2 ) ),
tr_truncd( torStat->percentComplete * 100.0, 2 ),
tr_strlsize( buf3, torStat->uploadedEver, sizeof( buf3 ) ),
tr_strlratio( buf4, torStat->ratio, sizeof( buf4 ) ) );
}
}
else if(( hasSeedRatio = tr_torrentGetSeedRatio( tor, &seedRatio )))
else /* seeding */
{
str = g_strdup_printf(
/* %1$s is the torrent's total size,
%2$s is how much we've uploaded,
%3$s is our upload-to-download ratio,
$4$s is the ratio we want to reach before we stop uploading */
_( "%1$s, uploaded %2$s (Ratio: %3$s Goal: %4$s)" ),
tr_strlsize( buf1, info->totalSize, sizeof( buf1 ) ),
tr_strlsize( buf2, torStat->uploadedEver, sizeof( buf2 ) ),
tr_strlratio( buf3, torStat->ratio, sizeof( buf3 ) ),
tr_strlratio( buf4, seedRatio, sizeof( buf4 ) ) );
}
else /* seeding w/o a ratio */
{
str = g_strdup_printf(
/* %1$s is the torrent's total size,
%2$s is how much we've uploaded,
%3$s is our upload-to-download ratio */
_( "%1$s, uploaded %2$s (Ratio: %3$s)" ),
tr_strlsize( buf1, info->totalSize, sizeof( buf1 ) ),
tr_strlsize( buf2, torStat->uploadedEver, sizeof( buf2 ) ),
tr_strlratio( buf3, torStat->ratio, sizeof( buf3 ) ) );
if( hasSeedRatio )
{
str = g_strdup_printf(
/* %1$s is the torrent's total size,
%2$s is how much we've uploaded,
%3$s is our upload-to-download ratio,
%4$s is the ratio we want to reach before we stop uploading */
_( "%1$s, uploaded %2$s (Ratio: %3$s Goal: %4$s)" ),
tr_strlsize( buf1, info->totalSize, sizeof( buf1 ) ),
tr_strlsize( buf2, torStat->uploadedEver, sizeof( buf2 ) ),
tr_strlratio( buf3, torStat->ratio, sizeof( buf3 ) ),
tr_strlratio( buf4, seedRatio, sizeof( buf4 ) ) );
}
else /* seeding w/o a ratio */
{
str = g_strdup_printf(
/* %1$s is the torrent's total size,
%2$s is how much we've uploaded,
%3$s is our upload-to-download ratio */
_( "%1$s, uploaded %2$s (Ratio: %3$s)" ),
tr_strlsize( buf1, info->totalSize, sizeof( buf1 ) ),
tr_strlsize( buf2, torStat->uploadedEver, sizeof( buf2 ) ),
tr_strlratio( buf3, torStat->ratio, sizeof( buf3 ) ) );
}
}
/* add time when downloading */

View File

@ -67,9 +67,9 @@ TorrentDelegate :: progressString( const Torrent& tor ) const
const uint64_t haveTotal( tor.haveTotal( ) );
QString str;
double seedRatio;
bool hasSeedRatio;
const bool hasSeedRatio( tor.getSeedRatio( seedRatio ) );
if( !isDone )
if( !isDone ) // downloading
{
/* %1 is how much we've got,
%2 is how much we'll have when done,
@ -78,41 +78,63 @@ TorrentDelegate :: progressString( const Torrent& tor ) const
.arg( Utils::sizeToString( tor.sizeWhenDone( ) ) )
.arg( tor.percentDone( ) * 100.0, 0, 'f', 2 );
}
else if( !isSeed )
else if( !isSeed ) // partial seed
{
/* %1 is how much we've got,
%2 is the torrent's total size,
%3 is a percentage of the two,
%4 is how much we've uploaded,
%5 is our upload-to-download ratio */
str = tr( "%1 of %2 (%3%), uploaded %4 (Ratio: %5)" )
.arg( Utils::sizeToString( haveTotal ) )
.arg( Utils::sizeToString( tor.sizeWhenDone( ) ) )
.arg( tor.percentDone( ) * 100.0, 0, 'f', 2 )
.arg( Utils::sizeToString( tor.uploadedEver( ) ) )
.arg( Utils::ratioToString( tor.ratio( ) ) );
if( hasSeedRatio )
{
/* %1 is how much we've got,
%2 is the torrent's total size,
%3 is a percentage of the two,
%4 is how much we've uploaded,
%5 is our upload-to-download ratio
%6 is the ratio we want to reach before we stop uploading */
str = tr( "%1 of %2 (%3%), uploaded %4 (Ratio: %5 Goal: %6)" )
.arg( Utils::sizeToString( haveTotal ) )
.arg( Utils::sizeToString( tor.sizeWhenDone( ) ) )
.arg( tor.percentDone( ) * 100.0, 0, 'f', 2 )
.arg( Utils::sizeToString( tor.uploadedEver( ) ) )
.arg( Utils::ratioToString( tor.ratio( ) )
.arg( Utils::ratioToString( seedRatio ) ) );
}
else
{
/* %1 is how much we've got,
%2 is the torrent's total size,
%3 is a percentage of the two,
%4 is how much we've uploaded,
%5 is our upload-to-download ratio */
str = tr( "%1 of %2 (%3%), uploaded %4 (Ratio: %5)" )
.arg( Utils::sizeToString( haveTotal ) )
.arg( Utils::sizeToString( tor.sizeWhenDone( ) ) )
.arg( tor.percentDone( ) * 100.0, 0, 'f', 2 )
.arg( Utils::sizeToString( tor.uploadedEver( ) ) )
.arg( Utils::ratioToString( tor.ratio( ) ) );
}
}
else if(( hasSeedRatio = tor.getSeedRatio( seedRatio )))
else // seeding
{
/* %1 is the torrent's total size,
%2 is how much we've uploaded,
%3 is our upload-to-download ratio,
$4 is the ratio we want to reach before we stop uploading */
str = tr( "%1, uploaded %2 (Ratio: %3 Goal %4)" )
.arg( Utils::sizeToString( haveTotal ) )
.arg( Utils::sizeToString( tor.uploadedEver( ) ) )
.arg( Utils::ratioToString( tor.ratio( ) ) )
.arg( Utils::ratioToString( seedRatio ) );
}
else /* seeding w/o a ratio */
{
/* %1 is the torrent's total size,
%2 is how much we've uploaded,
%3 is our upload-to-download ratio */
str = tr( "%1, uploaded %2 (Ratio: %3)" )
.arg( Utils::sizeToString( haveTotal ) )
.arg( Utils::sizeToString( tor.uploadedEver( ) ) )
.arg( Utils::ratioToString( tor.ratio( ) ) );
if( hasSeedRatio )
{
/* %1 is the torrent's total size,
%2 is how much we've uploaded,
%3 is our upload-to-download ratio,
%4 is the ratio we want to reach before we stop uploading */
str = tr( "%1, uploaded %2 (Ratio: %3 Goal %4)" )
.arg( Utils::sizeToString( haveTotal ) )
.arg( Utils::sizeToString( tor.uploadedEver( ) ) )
.arg( Utils::ratioToString( tor.ratio( ) ) )
.arg( Utils::ratioToString( seedRatio ) );
}
else /* seeding w/o a ratio */
{
/* %1 is the torrent's total size,
%2 is how much we've uploaded,
%3 is our upload-to-download ratio */
str = tr( "%1, uploaded %2 (Ratio: %3)" )
.arg( Utils::sizeToString( haveTotal ) )
.arg( Utils::sizeToString( tor.uploadedEver( ) ) )
.arg( Utils::ratioToString( tor.ratio( ) ) );
}
}
/* add time when downloading */