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

This commit is contained in:
Charles Kerr 2010-07-24 04:14:43 +00:00
parent 8bee7fa23c
commit 6692699072
4 changed files with 84 additions and 63 deletions

View File

@ -646,28 +646,38 @@ Details :: refresh( )
myPeerLimitSpin->blockSignals( true ); myPeerLimitSpin->blockSignals( true );
myPeerLimitSpin->setValue( tor->peerLimit() ); myPeerLimitSpin->setValue( tor->peerLimit() );
myPeerLimitSpin->blockSignals( false ); myPeerLimitSpin->blockSignals( false );
}
// ratio radios {
uniform = true; const Torrent * tor;
baselineInt = tor->seedRatioMode( );
// ratio
bool uniform = true;
int baselineInt = torrents[0]->seedRatioMode( );
foreach( tor, torrents ) if( baselineInt != tor->seedRatioMode( ) ) { uniform = false; break; } foreach( tor, torrents ) if( baselineInt != tor->seedRatioMode( ) ) { uniform = false; break; }
if( !uniform ) {
mySeedGlobalRadio->setChecked( false );
mySeedCustomRadio->setChecked( false );
mySeedForeverRadio->setChecked( false );
} else {
QRadioButton * rb;
switch( baselineInt ) {
case TR_RATIOLIMIT_GLOBAL: rb = mySeedGlobalRadio; break;
case TR_RATIOLIMIT_SINGLE: rb = mySeedCustomRadio; break;
case TR_RATIOLIMIT_UNLIMITED: rb = mySeedForeverRadio; break;
}
rb->setChecked( true );
}
mySeedCustomSpin->blockSignals( true ); myRatioCombo->blockSignals( true );
mySeedCustomSpin->setValue( tor->seedRatioLimit( ) ); myRatioCombo->setCurrentIndex( uniform ? myRatioCombo->findData( baselineInt ) : -1 );
mySeedCustomSpin->blockSignals( false ); myRatioSpin->setVisible( uniform && ( baselineInt == TR_RATIOLIMIT_SINGLE ) );
myRatioCombo->blockSignals( false );
myRatioSpin->blockSignals( true );
myRatioSpin->setValue( tor->seedRatioLimit( ) );
myRatioSpin->blockSignals( false );
// idle
uniform = true;
baselineInt = torrents[0]->seedIdleMode( );
foreach( tor, torrents ) if( baselineInt != tor->seedIdleMode( ) ) { uniform = false; break; }
myIdleCombo->blockSignals( true );
myIdleCombo->setCurrentIndex( uniform ? myIdleCombo->findData( baselineInt ) : -1 );
myIdleSpin->setVisible( uniform && ( baselineInt == TR_RATIOLIMIT_SINGLE ) );
myIdleCombo->blockSignals( false );
myIdleSpin->blockSignals( true );
myIdleSpin->setValue( tor->seedIdleLimit( ) );
myIdleSpin->blockSignals( false );
} }
// tracker tab // tracker tab
@ -1026,28 +1036,30 @@ Details :: onUploadLimitChanged( int val )
mySession.torrentSet( myIds, "uploadLimit", val ); mySession.torrentSet( myIds, "uploadLimit", val );
} }
#define RATIO_KEY "seedRatioMode"
void void
Details :: onSeedUntilChanged( bool b ) Details :: onIdleModeChanged( int index )
{ {
if( b ) const int val = myIdleCombo->itemData( index ).toInt( );
mySession.torrentSet( myIds, RATIO_KEY, sender()->property(RATIO_KEY).toInt() ); mySession.torrentSet( myIds, "seedIdleMode", val );
} }
void void
Details :: onSeedRatioLimitChanged( double val ) Details :: onIdleLimitChanged( int val )
{ {
QSet<int> ids; mySession.torrentSet( myIds, "seedIdleLimit", val );
}
foreach( int id, myIds ) { void
const Torrent * tor = myModel.getTorrentFromId( id ); Details :: onRatioModeChanged( int index )
if( tor && tor->seedRatioLimit( ) ) {
ids.insert( id ); const int val = myRatioCombo->itemData( index ).toInt( );
} mySession.torrentSet( myIds, "seedRatioMode", val );
}
if( !ids.empty( ) ) void
mySession.torrentSet( ids, "seedRatioLimit", val ); Details :: onRatioLimitChanged( double val )
{
mySession.torrentSet( myIds, "seedRatioLimit", val );
} }
void void
@ -1183,12 +1195,10 @@ Details :: onRemoveTrackerPushed( )
QWidget * QWidget *
Details :: createOptionsTab( ) Details :: createOptionsTab( )
{ {
//QWidget * l;
QSpinBox * s; QSpinBox * s;
QCheckBox * c; QCheckBox * c;
QComboBox * m; QComboBox * m;
QHBoxLayout * h; QHBoxLayout * h;
QRadioButton * r;
QDoubleSpinBox * ds; QDoubleSpinBox * ds;
const QString speed_K_str = Formatter::unitStr( Formatter::SPEED, Formatter::KB ); const QString speed_K_str = Formatter::unitStr( Formatter::SPEED, Formatter::KB );
@ -1231,31 +1241,34 @@ Details :: createOptionsTab( )
hig->addSectionDivider( ); hig->addSectionDivider( );
hig->addSectionTitle( tr( "Seeding Limits" ) ); hig->addSectionTitle( tr( "Seeding Limits" ) );
r = new QRadioButton( tr( "Use &global settings" ) ); h = new QHBoxLayout( );
r->setProperty( RATIO_KEY, TR_RATIOLIMIT_GLOBAL ); h->setSpacing( HIG :: PAD );
connect( r, SIGNAL(clicked(bool)), this, SLOT(onSeedUntilChanged(bool))); m = new QComboBox;
mySeedGlobalRadio = r; m->addItem( tr( "Use Global Settings" ), TR_RATIOLIMIT_GLOBAL );
hig->addWideControl( r ); m->addItem( tr( "Seed regardless of ratio" ), TR_RATIOLIMIT_UNLIMITED );
m->addItem( tr( "Stop seeding at ratio:" ), TR_RATIOLIMIT_SINGLE );
r = new QRadioButton( tr( "Seed &regardless of ratio" ) ); connect( m, SIGNAL(currentIndexChanged(int)), this, SLOT(onRatioModeChanged(int)));
r->setProperty( RATIO_KEY, TR_RATIOLIMIT_UNLIMITED ); h->addWidget( myRatioCombo = m );
connect( r, SIGNAL(clicked(bool)), this, SLOT(onSeedUntilChanged(bool))); ds = new QDoubleSpinBox( );
mySeedForeverRadio = r; ds->setRange( 0.5, INT_MAX );
hig->addWideControl( r ); connect( ds, SIGNAL(valueChanged(double)), this, SLOT(onRatioLimitChanged(double)));
h->addWidget( myRatioSpin = ds );
hig->addRow( tr( "&Ratio:" ), h, m );
h = new QHBoxLayout( ); h = new QHBoxLayout( );
h->setSpacing( HIG :: PAD ); h->setSpacing( HIG :: PAD );
r = new QRadioButton( tr( "&Seed torrent until its ratio reaches:" ) ); m = new QComboBox;
r->setProperty( RATIO_KEY, TR_RATIOLIMIT_SINGLE ); m->addItem( tr( "Use Global Settings" ), TR_IDLELIMIT_GLOBAL );
connect( r, SIGNAL(clicked(bool)), this, SLOT(onSeedUntilChanged(bool))); m->addItem( tr( "Seed regardless of activity" ), TR_IDLELIMIT_UNLIMITED );
mySeedCustomRadio = r; m->addItem( tr( "Stop seeding if idle for N minutes:" ), TR_IDLELIMIT_SINGLE );
h->addWidget( r ); connect( m, SIGNAL(currentIndexChanged(int)), this, SLOT(onIdleModeChanged(int)));
ds = new QDoubleSpinBox( ); h->addWidget( myIdleCombo = m );
ds->setRange( 0.5, INT_MAX ); s = new QSpinBox( );
connect( ds, SIGNAL(valueChanged(double)), this, SLOT(onSeedRatioLimitChanged(double))); s->setRange( 1, 9999 );
mySeedCustomSpin = ds; connect( s, SIGNAL(valueChanged(int)), this, SLOT(onIdleLimitChanged(int)));
h->addWidget( ds ); h->addWidget( myIdleSpin = s );
hig->addWideControl( h ); hig->addRow( tr( "&Idle:" ), h, m );
hig->addSectionDivider( ); hig->addSectionDivider( );
hig->addSectionTitle( tr( "Peer Connections" ) ); hig->addSectionTitle( tr( "Peer Connections" ) );

View File

@ -103,10 +103,10 @@ class Details: public QDialog
QPushButton * myRemoveTrackerButton; QPushButton * myRemoveTrackerButton;
QSpinBox * mySingleDownSpin; QSpinBox * mySingleDownSpin;
QSpinBox * mySingleUpSpin; QSpinBox * mySingleUpSpin;
QRadioButton * mySeedGlobalRadio; QComboBox * myRatioCombo;
QRadioButton * mySeedForeverRadio; QDoubleSpinBox * myRatioSpin;
QRadioButton * mySeedCustomRadio; QComboBox * myIdleCombo;
QDoubleSpinBox * mySeedCustomSpin; QSpinBox * myIdleSpin;
QSpinBox * myPeerLimitSpin; QSpinBox * myPeerLimitSpin;
QComboBox * myBandwidthPriorityCombo; QComboBox * myBandwidthPriorityCombo;
@ -144,8 +144,10 @@ class Details: public QDialog
void onDownloadLimitChanged( int ); void onDownloadLimitChanged( int );
void onUploadLimitedToggled( bool ); void onUploadLimitedToggled( bool );
void onUploadLimitChanged( int ); void onUploadLimitChanged( int );
void onSeedUntilChanged( bool ); void onRatioModeChanged( int );
void onSeedRatioLimitChanged( double ); void onRatioLimitChanged( double );
void onIdleModeChanged( int );
void onIdleLimitChanged( int );
void onShowTrackerScrapesToggled( bool ); void onShowTrackerScrapesToggled( bool );
void onTrackerSelectionChanged( ); void onTrackerSelectionChanged( );
void onAddTrackerPushed( ); void onAddTrackerPushed( );

View File

@ -89,6 +89,8 @@ Torrent :: myProperties[] =
{ MIME_ICON, "ccc", QVariant::Icon, DERIVED }, { MIME_ICON, "ccc", QVariant::Icon, DERIVED },
{ SEED_RATIO_LIMIT, "seedRatioLimit", QVariant::Double, STAT }, { SEED_RATIO_LIMIT, "seedRatioLimit", QVariant::Double, STAT },
{ SEED_RATIO_MODE, "seedRatioMode", QVariant::Int, STAT }, { SEED_RATIO_MODE, "seedRatioMode", QVariant::Int, STAT },
{ SEED_IDLE_LIMIT, "seedIdleLimit", QVariant::Int, STAT_EXTRA },
{ SEED_IDLE_MODE, "seedIdleMode", QVariant::Int, STAT_EXTRA },
{ DOWN_LIMIT, "downloadLimit", QVariant::Int, STAT_EXTRA }, /* KB/s */ { DOWN_LIMIT, "downloadLimit", QVariant::Int, STAT_EXTRA }, /* KB/s */
{ DOWN_LIMITED, "downloadLimited", QVariant::Bool, STAT_EXTRA }, { DOWN_LIMITED, "downloadLimited", QVariant::Bool, STAT_EXTRA },
{ UP_LIMIT, "uploadLimit", QVariant::Int, STAT_EXTRA }, /* KB/s */ { UP_LIMIT, "uploadLimit", QVariant::Int, STAT_EXTRA }, /* KB/s */

View File

@ -153,6 +153,8 @@ class Torrent: public QObject
MIME_ICON, MIME_ICON,
SEED_RATIO_LIMIT, SEED_RATIO_LIMIT,
SEED_RATIO_MODE, SEED_RATIO_MODE,
SEED_IDLE_LIMIT,
SEED_IDLE_MODE,
DOWN_LIMIT, DOWN_LIMIT,
DOWN_LIMITED, DOWN_LIMITED,
UP_LIMIT, UP_LIMIT,
@ -292,6 +294,8 @@ class Torrent: public QObject
int peerLimit( ) const { return getInt( PEER_LIMIT ); } int peerLimit( ) const { return getInt( PEER_LIMIT ); }
double seedRatioLimit( ) const { return getDouble( SEED_RATIO_LIMIT ); } double seedRatioLimit( ) const { return getDouble( SEED_RATIO_LIMIT ); }
tr_ratiolimit seedRatioMode( ) const { return (tr_ratiolimit) getInt( SEED_RATIO_MODE ); } tr_ratiolimit seedRatioMode( ) const { return (tr_ratiolimit) getInt( SEED_RATIO_MODE ); }
int seedIdleLimit( ) const { return getInt( SEED_IDLE_LIMIT ); }
tr_idlelimit seedIdleMode( ) const { return (tr_idlelimit) getInt( SEED_IDLE_MODE ); }
TrackerStatsList trackerStats( ) const{ return myValues[TRACKERSTATS].value<TrackerStatsList>(); } TrackerStatsList trackerStats( ) const{ return myValues[TRACKERSTATS].value<TrackerStatsList>(); }
PeerList peers( ) const{ return myValues[PEERS].value<PeerList>(); } PeerList peers( ) const{ return myValues[PEERS].value<PeerList>(); }
const FileList& files( ) const { return myFiles; } const FileList& files( ) const { return myFiles; }