Changeset 11047


Ignore:
Timestamp:
Jul 24, 2010, 4:14:43 AM (13 years ago)
Author:
charles
Message:

(trunk qt) #2560 "idle seeding time limit" -- Qt support

Location:
trunk/qt
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/details.cc

    r11044 r11047  
    647647        myPeerLimitSpin->setValue( tor->peerLimit() );
    648648        myPeerLimitSpin->blockSignals( false );
    649 
    650         // ratio radios
     649    }
     650
     651    {
     652        const Torrent * tor;
     653
     654        // ratio
     655        bool uniform = true;
     656        int baselineInt = torrents[0]->seedRatioMode( );
     657        foreach( tor, torrents ) if( baselineInt != tor->seedRatioMode( ) ) { uniform = false; break; }
     658
     659        myRatioCombo->blockSignals( true );
     660        myRatioCombo->setCurrentIndex( uniform ? myRatioCombo->findData( baselineInt ) : -1 );
     661        myRatioSpin->setVisible( uniform && ( baselineInt == TR_RATIOLIMIT_SINGLE ) );
     662        myRatioCombo->blockSignals( false );
     663
     664        myRatioSpin->blockSignals( true );
     665        myRatioSpin->setValue( tor->seedRatioLimit( ) );
     666        myRatioSpin->blockSignals( false );
     667
     668        // idle
    651669        uniform = true;
    652         baselineInt = tor->seedRatioMode( );
    653         foreach( tor, torrents ) if( baselineInt != tor->seedRatioMode( ) ) { uniform = false; break; }
    654         if( !uniform ) {
    655             mySeedGlobalRadio->setChecked( false );
    656             mySeedCustomRadio->setChecked( false );
    657             mySeedForeverRadio->setChecked( false );
    658         } else {
    659             QRadioButton * rb;
    660             switch( baselineInt ) {
    661                 case TR_RATIOLIMIT_GLOBAL:    rb = mySeedGlobalRadio; break;
    662                 case TR_RATIOLIMIT_SINGLE:    rb = mySeedCustomRadio; break;
    663                 case TR_RATIOLIMIT_UNLIMITED: rb = mySeedForeverRadio; break;
    664             }
    665             rb->setChecked( true );
    666         }
    667 
    668         mySeedCustomSpin->blockSignals( true );
    669         mySeedCustomSpin->setValue( tor->seedRatioLimit( ) );
    670         mySeedCustomSpin->blockSignals( false );
     670        baselineInt = torrents[0]->seedIdleMode( );
     671        foreach( tor, torrents ) if( baselineInt != tor->seedIdleMode( ) ) { uniform = false; break; }
     672
     673        myIdleCombo->blockSignals( true );
     674        myIdleCombo->setCurrentIndex( uniform ? myIdleCombo->findData( baselineInt ) : -1 );
     675        myIdleSpin->setVisible( uniform && ( baselineInt == TR_RATIOLIMIT_SINGLE ) );
     676        myIdleCombo->blockSignals( false );
     677
     678        myIdleSpin->blockSignals( true );
     679        myIdleSpin->setValue( tor->seedIdleLimit( ) );
     680        myIdleSpin->blockSignals( false );
    671681    }
    672682
     
    10271037}
    10281038
    1029 #define RATIO_KEY "seedRatioMode"
    1030 
    1031 void
    1032 Details :: onSeedUntilChanged( bool b )
    1033 {
    1034     if( b )
    1035         mySession.torrentSet( myIds, RATIO_KEY, sender()->property(RATIO_KEY).toInt() );
    1036 }
    1037 
    1038 void
    1039 Details :: onSeedRatioLimitChanged( double val )
    1040 {
    1041     QSet<int> ids;
    1042 
    1043     foreach( int id, myIds ) {
    1044         const Torrent * tor = myModel.getTorrentFromId( id );
    1045         if( tor && tor->seedRatioLimit( ) )
    1046             ids.insert( id );
    1047     }
    1048 
    1049     if( !ids.empty( ) )
    1050         mySession.torrentSet( ids, "seedRatioLimit", val );
     1039void
     1040Details :: onIdleModeChanged( int index )
     1041{
     1042    const int val = myIdleCombo->itemData( index ).toInt( );
     1043    mySession.torrentSet( myIds, "seedIdleMode", val );
     1044}
     1045
     1046void
     1047Details :: onIdleLimitChanged( int val )
     1048{
     1049    mySession.torrentSet( myIds, "seedIdleLimit", val );
     1050}
     1051
     1052void
     1053Details :: onRatioModeChanged( int index )
     1054{
     1055    const int val = myRatioCombo->itemData( index ).toInt( );
     1056    mySession.torrentSet( myIds, "seedRatioMode", val );
     1057}
     1058
     1059void
     1060Details :: onRatioLimitChanged( double val )
     1061{
     1062    mySession.torrentSet( myIds, "seedRatioLimit", val );
    10511063}
    10521064
     
    11841196Details :: createOptionsTab( )
    11851197{
    1186     //QWidget * l;
    11871198    QSpinBox * s;
    11881199    QCheckBox * c;
    11891200    QComboBox * m;
    11901201    QHBoxLayout * h;
    1191     QRadioButton * r;
    11921202    QDoubleSpinBox * ds;
    11931203    const QString speed_K_str = Formatter::unitStr( Formatter::SPEED, Formatter::KB );
     
    12321242    hig->addSectionTitle( tr( "Seeding Limits" ) );
    12331243
    1234     r = new QRadioButton( tr( "Use &global settings" ) );
    1235     r->setProperty( RATIO_KEY, TR_RATIOLIMIT_GLOBAL );
    1236     connect( r, SIGNAL(clicked(bool)), this, SLOT(onSeedUntilChanged(bool)));
    1237     mySeedGlobalRadio = r;
    1238     hig->addWideControl( r );
    1239 
    1240     r = new QRadioButton( tr( "Seed &regardless of ratio" ) );
    1241     r->setProperty( RATIO_KEY, TR_RATIOLIMIT_UNLIMITED );
    1242     connect( r, SIGNAL(clicked(bool)), this, SLOT(onSeedUntilChanged(bool)));
    1243     mySeedForeverRadio = r;
    1244     hig->addWideControl( r );
    1245 
    12461244    h = new QHBoxLayout( );
    12471245    h->setSpacing( HIG :: PAD );
    1248     r = new QRadioButton( tr( "&Seed torrent until its ratio reaches:" ) );
    1249     r->setProperty( RATIO_KEY, TR_RATIOLIMIT_SINGLE );
    1250     connect( r, SIGNAL(clicked(bool)), this, SLOT(onSeedUntilChanged(bool)));
    1251     mySeedCustomRadio = r;
    1252     h->addWidget( r );
     1246    m = new QComboBox;
     1247    m->addItem( tr( "Use Global Settings" ),      TR_RATIOLIMIT_GLOBAL );
     1248    m->addItem( tr( "Seed regardless of ratio" ), TR_RATIOLIMIT_UNLIMITED );
     1249    m->addItem( tr( "Stop seeding at ratio:" ),   TR_RATIOLIMIT_SINGLE );
     1250    connect( m, SIGNAL(currentIndexChanged(int)), this, SLOT(onRatioModeChanged(int)));
     1251    h->addWidget( myRatioCombo = m );
    12531252    ds = new QDoubleSpinBox( );
    12541253    ds->setRange( 0.5, INT_MAX );
    1255     connect( ds, SIGNAL(valueChanged(double)), this, SLOT(onSeedRatioLimitChanged(double)));
    1256     mySeedCustomSpin = ds;
    1257     h->addWidget( ds );
    1258     hig->addWideControl( h );
     1254    connect( ds, SIGNAL(valueChanged(double)), this, SLOT(onRatioLimitChanged(double)));
     1255    h->addWidget( myRatioSpin = ds );
     1256    hig->addRow( tr( "&Ratio:" ), h, m );
     1257
     1258    h = new QHBoxLayout( );
     1259    h->setSpacing( HIG :: PAD );
     1260    m = new QComboBox;
     1261    m->addItem( tr( "Use Global Settings" ),                 TR_IDLELIMIT_GLOBAL );
     1262    m->addItem( tr( "Seed regardless of activity" ),         TR_IDLELIMIT_UNLIMITED );
     1263    m->addItem( tr( "Stop seeding if idle for N minutes:" ), TR_IDLELIMIT_SINGLE );
     1264    connect( m, SIGNAL(currentIndexChanged(int)), this, SLOT(onIdleModeChanged(int)));
     1265    h->addWidget( myIdleCombo = m );
     1266    s = new QSpinBox( );
     1267    s->setRange( 1, 9999 );
     1268    connect( s, SIGNAL(valueChanged(int)), this, SLOT(onIdleLimitChanged(int)));
     1269    h->addWidget( myIdleSpin = s );
     1270    hig->addRow( tr( "&Idle:" ), h, m );
     1271
    12591272
    12601273    hig->addSectionDivider( );
  • trunk/qt/details.h

    r10908 r11047  
    104104        QSpinBox * mySingleDownSpin;
    105105        QSpinBox * mySingleUpSpin;
    106         QRadioButton * mySeedGlobalRadio;
    107         QRadioButton * mySeedForeverRadio;
    108         QRadioButton * mySeedCustomRadio;
    109         QDoubleSpinBox * mySeedCustomSpin;
     106        QComboBox * myRatioCombo;
     107        QDoubleSpinBox * myRatioSpin;
     108        QComboBox * myIdleCombo;
     109        QSpinBox * myIdleSpin;
    110110        QSpinBox * myPeerLimitSpin;
    111111        QComboBox * myBandwidthPriorityCombo;
     
    145145        void onUploadLimitedToggled( bool );
    146146        void onUploadLimitChanged( int );
    147         void onSeedUntilChanged( bool );
    148         void onSeedRatioLimitChanged( double );
     147        void onRatioModeChanged( int );
     148        void onRatioLimitChanged( double );
     149        void onIdleModeChanged( int );
     150        void onIdleLimitChanged( int );
    149151        void onShowTrackerScrapesToggled( bool );
    150152        void onTrackerSelectionChanged( );
  • trunk/qt/torrent.cc

    r10937 r11047  
    9090    { SEED_RATIO_LIMIT, "seedRatioLimit", QVariant::Double, STAT },
    9191    { SEED_RATIO_MODE, "seedRatioMode", QVariant::Int, STAT },
     92    { SEED_IDLE_LIMIT, "seedIdleLimit", QVariant::Int, STAT_EXTRA },
     93    { SEED_IDLE_MODE, "seedIdleMode", QVariant::Int, STAT_EXTRA },
    9294    { DOWN_LIMIT, "downloadLimit", QVariant::Int, STAT_EXTRA }, /* KB/s */
    9395    { DOWN_LIMITED, "downloadLimited", QVariant::Bool, STAT_EXTRA },
  • trunk/qt/torrent.h

    r10937 r11047  
    154154            SEED_RATIO_LIMIT,
    155155            SEED_RATIO_MODE,
     156            SEED_IDLE_LIMIT,
     157            SEED_IDLE_MODE,
    156158            DOWN_LIMIT,
    157159            DOWN_LIMITED,
     
    293295        double seedRatioLimit( ) const { return getDouble( SEED_RATIO_LIMIT ); }
    294296        tr_ratiolimit seedRatioMode( ) const { return (tr_ratiolimit) getInt( SEED_RATIO_MODE ); }
     297        int seedIdleLimit( ) const { return getInt( SEED_IDLE_LIMIT ); }
     298        tr_idlelimit seedIdleMode( ) const { return (tr_idlelimit) getInt( SEED_IDLE_MODE ); }
    295299        TrackerStatsList trackerStats( ) const{ return myValues[TRACKERSTATS].value<TrackerStatsList>(); }
    296300        PeerList peers( ) const{ return myValues[PEERS].value<PeerList>(); }
Note: See TracChangeset for help on using the changeset viewer.