(trunk qt) #2050 "properties dialog changes seem to undo themselves" -- fixed.

This commit is contained in:
Charles Kerr 2010-12-08 16:23:21 +00:00
parent ec0a4dd269
commit edd14bd8d6
1 changed files with 40 additions and 26 deletions

View File

@ -296,6 +296,38 @@ Details :: onTorrentChanged( )
} }
} }
namespace
{
void setIfIdle( QComboBox * box, int i )
{
if( !box->hasFocus( ) )
{
box->blockSignals( true );
box->setCurrentIndex( i );
box->blockSignals( false );
}
}
void setIfIdle( QDoubleSpinBox * spin, double value )
{
if( !spin->hasFocus( ) )
{
spin->blockSignals( true );
spin->setValue( value );
spin->blockSignals( false );
}
}
void setIfIdle( QSpinBox * spin, int value )
{
if( !spin->hasFocus( ) )
{
spin->blockSignals( true );
spin->setValue( value );
spin->blockSignals( false );
}
}
}
void void
Details :: refresh( ) Details :: refresh( )
@ -680,21 +712,11 @@ Details :: refresh( )
i = myBandwidthPriorityCombo->findData( baselineInt ); i = myBandwidthPriorityCombo->findData( baselineInt );
else else
i = -1; i = -1;
myBandwidthPriorityCombo->blockSignals( true ); setIfIdle( myBandwidthPriorityCombo, i );
myBandwidthPriorityCombo->setCurrentIndex( i );
myBandwidthPriorityCombo->blockSignals( false );
mySingleDownSpin->blockSignals( true ); setIfIdle( mySingleDownSpin, int(tor->downloadLimit().KBps()) );
mySingleDownSpin->setValue( (int)tor->downloadLimit().KBps() ); setIfIdle( mySingleUpSpin, int(tor->uploadLimit().KBps()) );
mySingleDownSpin->blockSignals( false ); setIfIdle( myPeerLimitSpin, tor->peerLimit() );
mySingleUpSpin->blockSignals( true );
mySingleUpSpin->setValue( (int)tor->uploadLimit().KBps() );
mySingleUpSpin->blockSignals( false );
myPeerLimitSpin->blockSignals( true );
myPeerLimitSpin->setValue( tor->peerLimit() );
myPeerLimitSpin->blockSignals( false );
} }
if( !torrents.empty( ) ) if( !torrents.empty( ) )
@ -706,28 +728,20 @@ Details :: refresh( )
int baselineInt = torrents[0]->seedRatioMode( ); 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; }
myRatioCombo->blockSignals( true ); setIfIdle( myRatioCombo, uniform ? myRatioCombo->findData( baselineInt ) : -1 );
myRatioCombo->setCurrentIndex( uniform ? myRatioCombo->findData( baselineInt ) : -1 );
myRatioSpin->setVisible( uniform && ( baselineInt == TR_RATIOLIMIT_SINGLE ) ); myRatioSpin->setVisible( uniform && ( baselineInt == TR_RATIOLIMIT_SINGLE ) );
myRatioCombo->blockSignals( false );
myRatioSpin->blockSignals( true ); setIfIdle( myRatioSpin, tor->seedRatioLimit( ) );
myRatioSpin->setValue( tor->seedRatioLimit( ) );
myRatioSpin->blockSignals( false );
// idle // idle
uniform = true; uniform = true;
baselineInt = torrents[0]->seedIdleMode( ); baselineInt = torrents[0]->seedIdleMode( );
foreach( tor, torrents ) if( baselineInt != tor->seedIdleMode( ) ) { uniform = false; break; } foreach( tor, torrents ) if( baselineInt != tor->seedIdleMode( ) ) { uniform = false; break; }
myIdleCombo->blockSignals( true ); setIfIdle( myIdleCombo, uniform ? myIdleCombo->findData( baselineInt ) : -1 );
myIdleCombo->setCurrentIndex( uniform ? myIdleCombo->findData( baselineInt ) : -1 );
myIdleSpin->setVisible( uniform && ( baselineInt == TR_RATIOLIMIT_SINGLE ) ); myIdleSpin->setVisible( uniform && ( baselineInt == TR_RATIOLIMIT_SINGLE ) );
myIdleCombo->blockSignals( false );
myIdleSpin->blockSignals( true ); setIfIdle( myIdleSpin, tor->seedIdleLimit( ) );
myIdleSpin->setValue( tor->seedIdleLimit( ) );
myIdleSpin->blockSignals( false );
} }
/// ///