Changeset 10433


Ignore:
Timestamp:
Apr 1, 2010, 6:08:20 AM (12 years ago)
Author:
charles
Message:

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

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/torrent-cell-renderer.c

    r10404 r10433  
    5050    const uint64_t haveTotal = torStat->haveUnchecked + torStat->haveValid;
    5151    const int      isSeed = torStat->haveValid >= info->totalSize;
    52     char           buf1[32], buf2[32], buf3[32], buf4[32];
     52    char           buf1[32], buf2[32], buf3[32], buf4[32], buf5[32];
    5353    char *         str;
    5454    double         seedRatio;
    55     gboolean       hasSeedRatio = FALSE;
    56 
    57     if( !isDone )
     55    const gboolean hasSeedRatio = tr_torrentGetSeedRatio( tor, &seedRatio );
     56
     57    if( !isDone ) /* downloading */
    5858    {
    5959        str = g_strdup_printf(
     
    6666            tr_truncd( torStat->percentDone * 100.0, 2 ) );
    6767    }
    68     else if( !isSeed )
    69     {
    70         str = g_strdup_printf(
    71             /* %1$s is how much we've got,
    72                %2$s is the torrent's total size,
    73                %3$.2f%% is a percentage of the two,
    74                %4$s is how much we've uploaded,
    75                %5$s is our upload-to-download ratio */
    76             _( "%1$s of %2$s (%3$.2f%%), uploaded %4$s (Ratio: %5$s)" ),
    77             tr_strlsize( buf1, haveTotal, sizeof( buf1 ) ),
    78             tr_strlsize( buf2, info->totalSize, sizeof( buf2 ) ),
    79             tr_truncd( torStat->percentComplete * 100.0, 2 ),
    80             tr_strlsize( buf3, torStat->uploadedEver, sizeof( buf3 ) ),
    81             tr_strlratio( buf4, torStat->ratio, sizeof( buf4 ) ) );
    82     }
    83     else if(( hasSeedRatio = tr_torrentGetSeedRatio( tor, &seedRatio )))
    84     {
    85         str = g_strdup_printf(
    86             /* %1$s is the torrent's total size,
    87                %2$s is how much we've uploaded,
    88                %3$s is our upload-to-download ratio,
    89                $4$s is the ratio we want to reach before we stop uploading */
    90             _( "%1$s, uploaded %2$s (Ratio: %3$s Goal: %4$s)" ),
    91             tr_strlsize( buf1, info->totalSize, sizeof( buf1 ) ),
    92             tr_strlsize( buf2, torStat->uploadedEver, sizeof( buf2 ) ),
    93             tr_strlratio( buf3, torStat->ratio, sizeof( buf3 ) ),
    94             tr_strlratio( buf4, seedRatio, sizeof( buf4 ) ) );
    95     }
    96     else /* seeding w/o a ratio */
    97     {
    98         str = g_strdup_printf(
    99             /* %1$s is the torrent's total size,
    100                %2$s is how much we've uploaded,
    101                %3$s is our upload-to-download ratio */
    102             _( "%1$s, uploaded %2$s (Ratio: %3$s)" ),
    103             tr_strlsize( buf1, info->totalSize, sizeof( buf1 ) ),
    104             tr_strlsize( buf2, torStat->uploadedEver, sizeof( buf2 ) ),
    105             tr_strlratio( buf3, torStat->ratio, sizeof( buf3 ) ) );
     68    else if( !isSeed ) /* partial seeds */
     69    {
     70        if( hasSeedRatio )
     71        {
     72            str = g_strdup_printf(
     73                /* %1$s is how much we've got,
     74                   %2$s is the torrent's total size,
     75                   %3$.2f%% is a percentage of the two,
     76                   %4$s is how much we've uploaded,
     77                   %5$s is our upload-to-download ratio,
     78                   %6$s is the ratio we want to reach before we stop uploading */
     79                _( "%1$s of %2$s (%3$.2f%%), uploaded %4$s (Ratio: %5$s Goal: %6$s)" ),
     80                tr_strlsize( buf1, haveTotal, sizeof( buf1 ) ),
     81                tr_strlsize( buf2, info->totalSize, sizeof( buf2 ) ),
     82                tr_truncd( torStat->percentComplete * 100.0, 2 ),
     83                tr_strlsize( buf3, torStat->uploadedEver, sizeof( buf3 ) ),
     84                tr_strlratio( buf4, torStat->ratio, sizeof( buf4 ) ),
     85                tr_strlratio( buf5, seedRatio, sizeof( buf5 ) ) );
     86        }
     87        else
     88        {
     89            str = g_strdup_printf(
     90                /* %1$s is how much we've got,
     91                   %2$s is the torrent's total size,
     92                   %3$.2f%% is a percentage of the two,
     93                   %4$s is how much we've uploaded,
     94                   %5$s is our upload-to-download ratio */
     95                _( "%1$s of %2$s (%3$.2f%%), uploaded %4$s (Ratio: %5$s)" ),
     96                tr_strlsize( buf1, haveTotal, sizeof( buf1 ) ),
     97                tr_strlsize( buf2, info->totalSize, sizeof( buf2 ) ),
     98                tr_truncd( torStat->percentComplete * 100.0, 2 ),
     99                tr_strlsize( buf3, torStat->uploadedEver, sizeof( buf3 ) ),
     100                tr_strlratio( buf4, torStat->ratio, sizeof( buf4 ) ) );
     101        }
     102    }
     103    else /* seeding */
     104    {
     105        if( hasSeedRatio )
     106        {
     107            str = g_strdup_printf(
     108                /* %1$s is the torrent's total size,
     109                   %2$s is how much we've uploaded,
     110                   %3$s is our upload-to-download ratio,
     111                   %4$s is the ratio we want to reach before we stop uploading */
     112                _( "%1$s, uploaded %2$s (Ratio: %3$s Goal: %4$s)" ),
     113                tr_strlsize( buf1, info->totalSize, sizeof( buf1 ) ),
     114                tr_strlsize( buf2, torStat->uploadedEver, sizeof( buf2 ) ),
     115                tr_strlratio( buf3, torStat->ratio, sizeof( buf3 ) ),
     116                tr_strlratio( buf4, seedRatio, sizeof( buf4 ) ) );
     117        }
     118        else /* seeding w/o a ratio */
     119        {
     120            str = g_strdup_printf(
     121                /* %1$s is the torrent's total size,
     122                   %2$s is how much we've uploaded,
     123                   %3$s is our upload-to-download ratio */
     124                _( "%1$s, uploaded %2$s (Ratio: %3$s)" ),
     125                tr_strlsize( buf1, info->totalSize, sizeof( buf1 ) ),
     126                tr_strlsize( buf2, torStat->uploadedEver, sizeof( buf2 ) ),
     127                tr_strlratio( buf3, torStat->ratio, sizeof( buf3 ) ) );
     128        }
    106129    }
    107130
  • trunk/qt/torrent-delegate.cc

    r10430 r10433  
    6868    QString str;
    6969    double seedRatio;
    70     bool hasSeedRatio;
    71 
    72     if( !isDone )
     70    const bool hasSeedRatio( tor.getSeedRatio( seedRatio ) );
     71
     72    if( !isDone ) // downloading
    7373    {
    7474        /* %1 is how much we've got,
     
    7979                                    .arg( tor.percentDone( ) * 100.0, 0, 'f', 2 );
    8080    }
    81     else if( !isSeed )
    82     {
    83         /* %1 is how much we've got,
    84            %2 is the torrent's total size,
    85            %3 is a percentage of the two,
    86            %4 is how much we've uploaded,
    87            %5 is our upload-to-download ratio */
    88         str = tr( "%1 of %2 (%3%), uploaded %4 (Ratio: %5)" )
    89               .arg( Utils::sizeToString( haveTotal ) )
    90               .arg( Utils::sizeToString( tor.sizeWhenDone( ) ) )
    91               .arg( tor.percentDone( ) * 100.0, 0, 'f', 2 )
    92               .arg( Utils::sizeToString( tor.uploadedEver( ) ) )
    93               .arg( Utils::ratioToString( tor.ratio( ) ) );
    94     }
    95     else if(( hasSeedRatio = tor.getSeedRatio( seedRatio )))
    96     {
    97         /* %1 is the torrent's total size,
    98            %2 is how much we've uploaded,
    99            %3 is our upload-to-download ratio,
    100            $4 is the ratio we want to reach before we stop uploading */
    101         str = tr( "%1, uploaded %2 (Ratio: %3 Goal %4)" )
    102               .arg( Utils::sizeToString( haveTotal ) )
    103               .arg( Utils::sizeToString( tor.uploadedEver( ) ) )
    104               .arg( Utils::ratioToString( tor.ratio( ) ) )
    105               .arg( Utils::ratioToString( seedRatio ) );
    106     }
    107     else /* seeding w/o a ratio */
    108     {
    109         /* %1 is the torrent's total size,
    110            %2 is how much we've uploaded,
    111            %3 is our upload-to-download ratio */
    112         str = tr( "%1, uploaded %2 (Ratio: %3)" )
    113               .arg( Utils::sizeToString( haveTotal ) )
    114               .arg( Utils::sizeToString( tor.uploadedEver( ) ) )
    115               .arg( Utils::ratioToString( tor.ratio( ) ) );
     81    else if( !isSeed ) // partial seed
     82    {
     83        if( hasSeedRatio )
     84        {
     85            /* %1 is how much we've got,
     86               %2 is the torrent's total size,
     87               %3 is a percentage of the two,
     88               %4 is how much we've uploaded,
     89               %5 is our upload-to-download ratio
     90               %6 is the ratio we want to reach before we stop uploading */
     91            str = tr( "%1 of %2 (%3%), uploaded %4 (Ratio: %5 Goal: %6)" )
     92                  .arg( Utils::sizeToString( haveTotal ) )
     93                  .arg( Utils::sizeToString( tor.sizeWhenDone( ) ) )
     94                  .arg( tor.percentDone( ) * 100.0, 0, 'f', 2 )
     95                  .arg( Utils::sizeToString( tor.uploadedEver( ) ) )
     96                  .arg( Utils::ratioToString( tor.ratio( ) )
     97                  .arg( Utils::ratioToString( seedRatio ) ) );
     98        }
     99        else
     100        {
     101            /* %1 is how much we've got,
     102               %2 is the torrent's total size,
     103               %3 is a percentage of the two,
     104               %4 is how much we've uploaded,
     105               %5 is our upload-to-download ratio */
     106            str = tr( "%1 of %2 (%3%), uploaded %4 (Ratio: %5)" )
     107                  .arg( Utils::sizeToString( haveTotal ) )
     108                  .arg( Utils::sizeToString( tor.sizeWhenDone( ) ) )
     109                  .arg( tor.percentDone( ) * 100.0, 0, 'f', 2 )
     110                  .arg( Utils::sizeToString( tor.uploadedEver( ) ) )
     111                  .arg( Utils::ratioToString( tor.ratio( ) ) );
     112        }
     113    }
     114    else // seeding
     115    {
     116        if( hasSeedRatio )
     117        {
     118            /* %1 is the torrent's total size,
     119               %2 is how much we've uploaded,
     120               %3 is our upload-to-download ratio,
     121               %4 is the ratio we want to reach before we stop uploading */
     122            str = tr( "%1, uploaded %2 (Ratio: %3 Goal %4)" )
     123                  .arg( Utils::sizeToString( haveTotal ) )
     124                  .arg( Utils::sizeToString( tor.uploadedEver( ) ) )
     125                  .arg( Utils::ratioToString( tor.ratio( ) ) )
     126                  .arg( Utils::ratioToString( seedRatio ) );
     127        }
     128        else /* seeding w/o a ratio */
     129        {
     130            /* %1 is the torrent's total size,
     131               %2 is how much we've uploaded,
     132               %3 is our upload-to-download ratio */
     133            str = tr( "%1, uploaded %2 (Ratio: %3)" )
     134                  .arg( Utils::sizeToString( haveTotal ) )
     135                  .arg( Utils::sizeToString( tor.uploadedEver( ) ) )
     136                  .arg( Utils::ratioToString( tor.ratio( ) ) );
     137        }
    116138    }
    117139
Note: See TracChangeset for help on using the changeset viewer.