Changeset 10077


Ignore:
Timestamp:
Feb 2, 2010, 5:34:26 AM (12 years ago)
Author:
charles
Message:

(trunk GTK+, Qt) #2645 "add torrent availability to Properties->Information" -- added for 1.90

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/details.c

    r10066 r10077  
    6666    GtkWidget * state_lb;
    6767    GtkWidget * have_lb;
     68    GtkWidget * availability_lb;
    6869    GtkWidget * dl_lb;
    6970    GtkWidget * ul_lb;
     
    625626    const char * mixed = _( "Mixed" );
    626627    char buf[512];
     628    double available = 0;
     629    double sizeWhenDone = 0;
    627630    const tr_stat ** stats = g_new( const tr_stat*, n );
    628631    const tr_info ** infos = g_new( const tr_info*, n );
     
    801804        str = none;
    802805    else {
    803         double sizeWhenDone = 0;
    804806        double leftUntilDone = 0;
    805807        double haveUnchecked = 0;
     
    807809        double verifiedPieces = 0;
    808810        for( i=0; i<n; ++i ) {
    809             const double v = stats[i]->haveValid;
    810             haveUnchecked += stats[i]->haveUnchecked;
     811            const tr_stat * st = stats[i];
     812            const double v = st->haveValid;
     813            haveUnchecked += st->haveUnchecked;
    811814            haveValid += v;
    812815            verifiedPieces += v / tr_torrentInfo(torrents[i])->pieceSize;
    813             sizeWhenDone += stats[i]->sizeWhenDone;
    814             leftUntilDone += stats[i]->leftUntilDone;
     816            sizeWhenDone += st->sizeWhenDone;
     817            leftUntilDone += st->leftUntilDone;
     818            available += st->sizeWhenDone - st->leftUntilDone + st->desiredAvailable;
    815819        }
    816820        if( !haveValid && !haveUnchecked )
     
    830834    gtr_label_set_text( GTK_LABEL( di->have_lb ), str );
    831835
     836    /* availability_lb */
     837    if( sizeWhenDone  )
     838        str = none;
     839    else {
     840        const double d = ( 100.0 * available ) / sizeWhenDone;
     841        g_snprintf( buf, sizeof( buf ), _( "%1$.1f%%" ),  d );
     842        str = buf;
     843    }
     844    gtr_label_set_text( GTK_LABEL( di->availability_lb ), str );
    832845
    833846    /* dl_lb */
     
    949962        l = di->have_lb = gtk_label_new( NULL );
    950963        hig_workarea_add_row( t, &row, _( "Have:" ), l, NULL );
     964
     965        /* availability */
     966        l = di->availability_lb = gtk_label_new( NULL );
     967        hig_workarea_add_row( t, &row, _( "Availability:" ), l, NULL );
    951968
    952969        /* downloaded */
  • trunk/qt/details.cc

    r9890 r10077  
    250250    double sizeWhenDone = 0;
    251251    double leftUntilDone = 0;
     252    double available = 0;
    252253    int64_t haveTotal = 0;
    253254    int64_t haveVerified = 0;
     
    263264            sizeWhenDone += t->sizeWhenDone( );
    264265            leftUntilDone += t->leftUntilDone( );
     266            available += t->sizeWhenDone() - t->leftUntilDone() + t->desiredAvailable();
    265267        }
    266268    }
     
    281283    }
    282284    myHaveLabel->setText( string );
     285
     286    // myAvailabilityLabel
     287    if( sizeWhenDone < 1 )
     288        string = none;
     289    else
     290        string.sprintf( "%'.1f%%", ( 100.0 * available ) / sizeWhenDone );
     291    myAvailabilityLabel->setText( string );
    283292
    284293    // myDownloadedLabel
     
    810819    hig->addRow( tr( "Torrent size:" ), mySizeLabel = new SqueezeLabel );
    811820    hig->addRow( tr( "Have:" ), myHaveLabel = new SqueezeLabel );
     821    hig->addRow( tr( "Availability:" ), myAvailabilityLabel = new SqueezeLabel );
    812822    hig->addRow( tr( "Downloaded:" ), myDownloadedLabel = new SqueezeLabel );
    813823    hig->addRow( tr( "Uploaded:" ), myUploadedLabel = new SqueezeLabel );
  • trunk/qt/details.h

    r9868 r10077  
    7272        QLabel * myStateLabel;
    7373        QLabel * myHaveLabel;
     74        QLabel * myAvailabilityLabel;
    7475        QLabel * myDownloadedLabel;
    7576        QLabel * myUploadedLabel;
  • trunk/qt/torrent.cc

    r9890 r10077  
    6565    { HAVE_UNCHECKED, "haveUnchecked", QVariant::ULongLong, STAT },
    6666    { HAVE_VERIFIED, "haveValid", QVariant::ULongLong, STAT },
     67    { DESIRED_AVAILABLE, "desiredAvailable", QVariant::ULongLong, STAT },
    6768    { TOTAL_SIZE, "totalSize", QVariant::ULongLong, INFO },
    6869    { PIECE_SIZE, "pieceSize", QVariant::ULongLong, INFO },
  • trunk/qt/torrent.h

    r9868 r10077  
    9595            HAVE_UNCHECKED,
    9696            HAVE_VERIFIED,
     97            DESIRED_AVAILABLE,
    9798            TOTAL_SIZE,
    9899            PIECE_SIZE,
     
    219220        uint64_t haveVerified( ) const { return getSize( HAVE_VERIFIED ); }
    220221        uint64_t haveUnverified( ) const { return getSize( HAVE_UNCHECKED ); }
     222        uint64_t desiredAvailable( ) const { return getSize( DESIRED_AVAILABLE ); }
    221223        uint64_t haveTotal( ) const { return haveVerified( ) + haveUnverified(); }
    222224        uint64_t totalSize( ) const { return getSize( TOTAL_SIZE ); }
Note: See TracChangeset for help on using the changeset viewer.