mirror of
https://github.com/transmission/transmission
synced 2025-03-09 21:54:09 +00:00
(trunk qt) first stab at getting the properties dialog's "options" controls operational.
This commit is contained in:
parent
cf552651f7
commit
c5aa896d83
5 changed files with 100 additions and 31 deletions
|
@ -56,7 +56,7 @@ class Session;
|
|||
|
||||
namespace
|
||||
{
|
||||
const int REFRESH_INTERVAL_MSEC = 3500;
|
||||
const int REFRESH_INTERVAL_MSEC = 4000;
|
||||
|
||||
enum // peer columns
|
||||
{
|
||||
|
@ -243,25 +243,12 @@ Details :: onTorrentChanged( )
|
|||
mySeedersLabel->setText( locale.toString( myTorrent.seeders( ) ) );
|
||||
myLeechersLabel->setText( locale.toString( myTorrent.leechers( ) ) );
|
||||
myTimesCompletedLabel->setText( locale.toString( myTorrent.timesCompleted( ) ) );
|
||||
//const PeerList peers( myTorrent.peers( ) );
|
||||
PeerList peers( myTorrent.peers( ) );
|
||||
#if 0
|
||||
static double progress = 0.01;
|
||||
{
|
||||
Peer peer;
|
||||
peer.address = "127.0.0.1";
|
||||
peer.isEncrypted = true;
|
||||
peer.progress = progress;
|
||||
peer.rateToPeer = Speed::fromKbps(20);
|
||||
peers << peer;
|
||||
progress += 0.01;
|
||||
}
|
||||
#endif
|
||||
const PeerList peers( myTorrent.peers( ) );
|
||||
QMap<QString,QTreeWidgetItem*> peers2;
|
||||
QList<QTreeWidgetItem*> newItems;
|
||||
static const QIcon myEncryptionIcon( ":/icons/encrypted.png" );
|
||||
static const QIcon myEmptyIcon;
|
||||
foreach( Peer peer, peers )
|
||||
foreach( const Peer& peer, peers )
|
||||
{
|
||||
PeerItem * item = (PeerItem*) myPeers.value( peer.address, 0 );
|
||||
if( item == 0 ) { // new peer has connected
|
||||
|
@ -372,9 +359,50 @@ Details :: createActivityTab( )
|
|||
***/
|
||||
|
||||
void
|
||||
Details :: onSessionLimitsToggled( bool b )
|
||||
Details :: onHonorsSessionLimitsToggled( bool val )
|
||||
{
|
||||
mySession.torrentSet( myTorrent.id(), "honorsSessionLimits", b );
|
||||
mySession.torrentSet( myTorrent.id(), "honorsSessionLimits", val );
|
||||
}
|
||||
void
|
||||
Details :: onDownloadLimitedToggled( bool val )
|
||||
{
|
||||
mySession.torrentSet( myTorrent.id(), "downloadLimited", val );
|
||||
}
|
||||
void
|
||||
Details :: onDownloadLimitChanged( int val )
|
||||
{
|
||||
mySession.torrentSet( myTorrent.id(), "downloadLimit", val );
|
||||
}
|
||||
void
|
||||
Details :: onUploadLimitedToggled( bool val )
|
||||
{
|
||||
mySession.torrentSet( myTorrent.id(), "uploadLimited", val );
|
||||
}
|
||||
void
|
||||
Details :: onUploadLimitChanged( int val )
|
||||
{
|
||||
mySession.torrentSet( myTorrent.id(), "uploadLimit", val );
|
||||
}
|
||||
|
||||
#define RATIO_KEY "seedRatioMode"
|
||||
|
||||
void
|
||||
Details :: onSeedUntilChanged( bool b )
|
||||
{
|
||||
if( b )
|
||||
mySession.torrentSet( myTorrent.id(), RATIO_KEY, sender()->property(RATIO_KEY).toInt() );
|
||||
}
|
||||
|
||||
void
|
||||
Details :: onSeedRatioLimitChanged( double val )
|
||||
{
|
||||
mySession.torrentSet( myTorrent.id(), "seedRatioLimit", val );
|
||||
}
|
||||
|
||||
void
|
||||
Details :: onMaxPeersChanged( int val )
|
||||
{
|
||||
mySession.torrentSet( myTorrent.id(), "peer-limit", val );
|
||||
}
|
||||
|
||||
QWidget *
|
||||
|
@ -393,7 +421,7 @@ Details :: createOptionsTab( )
|
|||
c = new QCheckBox( tr( "Honor global &limits" ) );
|
||||
mySessionLimitCheck = c;
|
||||
hig->addWideControl( c );
|
||||
connect( c, SIGNAL(toggled(bool)), this, SLOT(onSessionLimitsToggled(bool)) );
|
||||
connect( c, SIGNAL(toggled(bool)), this, SLOT(onHonorsSessionLimitsToggled(bool)) );
|
||||
|
||||
c = new QCheckBox( tr( "Limit &download speed (KB/s)" ) );
|
||||
mySingleDownCheck = c;
|
||||
|
@ -402,6 +430,8 @@ Details :: createOptionsTab( )
|
|||
s->setRange( 0, INT_MAX );
|
||||
hig->addRow( c, s );
|
||||
enableWhenChecked( c, s );
|
||||
connect( c, SIGNAL(toggled(bool)), this, SLOT(onDownloadLimitedToggled(bool)) );
|
||||
connect( s, SIGNAL(valueChanged(int)), this, SLOT(onDownloadLimitChanged(int)));
|
||||
|
||||
c = new QCheckBox( tr( "Limit &upload speed (KB/s)" ) );
|
||||
mySingleUpCheck = c;
|
||||
|
@ -410,25 +440,34 @@ Details :: createOptionsTab( )
|
|||
s->setRange( 0, INT_MAX );
|
||||
hig->addRow( c, s );
|
||||
enableWhenChecked( c, s );
|
||||
connect( c, SIGNAL(toggled(bool)), this, SLOT(onUploadLimitedToggled(bool)) );
|
||||
connect( s, SIGNAL(valueChanged(int)), this, SLOT(onUploadLimitChanged(int)));
|
||||
|
||||
hig->addSectionDivider( );
|
||||
hig->addSectionTitle( tr( "Seed-Until Ratio" ) );
|
||||
|
||||
r = new QRadioButton( tr( "Use &global setting" ) );
|
||||
r->setProperty( RATIO_KEY, TR_RATIOLIMIT_GLOBAL );
|
||||
connect( r, SIGNAL(toggled(bool)), this, SLOT(onSeedUntilChanged(bool)));
|
||||
mySeedGlobalRadio = r;
|
||||
hig->addWideControl( r );
|
||||
|
||||
r = new QRadioButton( tr( "Seed ®ardless of ratio" ) );
|
||||
r->setProperty( RATIO_KEY, TR_RATIOLIMIT_UNLIMITED );
|
||||
connect( r, SIGNAL(toggled(bool)), this, SLOT(onSeedUntilChanged(bool)));
|
||||
mySeedForeverRadio = r;
|
||||
hig->addWideControl( r );
|
||||
|
||||
h = new QHBoxLayout( );
|
||||
h->setSpacing( HIG :: PAD );
|
||||
r = new QRadioButton( tr( "&Stop seeding when a torrent's ratio reaches" ) );
|
||||
r->setProperty( RATIO_KEY, TR_RATIOLIMIT_SINGLE );
|
||||
connect( r, SIGNAL(toggled(bool)), this, SLOT(onSeedUntilChanged(bool)));
|
||||
mySeedCustomRadio = r;
|
||||
h->addWidget( r );
|
||||
ds = new QDoubleSpinBox( );
|
||||
ds->setRange( 0.5, INT_MAX );
|
||||
connect( ds, SIGNAL(valueChanged(double)), this, SLOT(onSeedRatioLimitChanged(double)));
|
||||
mySeedCustomSpin = ds;
|
||||
h->addWidget( ds );
|
||||
hig->addWideControl( h );
|
||||
|
@ -438,6 +477,7 @@ Details :: createOptionsTab( )
|
|||
|
||||
s = new QSpinBox( );
|
||||
s->setRange( 1, 300 );
|
||||
connect( s, SIGNAL(valueChanged(int)), this, SLOT(onMaxPeersChanged(int)));
|
||||
myPeerLimitSpin = s;
|
||||
hig->addRow( tr( "&Maximum Peers" ), s );
|
||||
|
||||
|
|
11
qt/details.h
11
qt/details.h
|
@ -114,11 +114,16 @@ class Details: public QDialog
|
|||
FileTreeView * myFileTreeView;
|
||||
|
||||
private slots:
|
||||
void onSessionLimitsToggled( bool );
|
||||
void onFilePriorityChanged( const QSet<int>& fileIndices, int );
|
||||
void onFileWantedChanged( const QSet<int>& fileIndices, bool );
|
||||
|
||||
|
||||
void onHonorsSessionLimitsToggled( bool );
|
||||
void onDownloadLimitedToggled( bool );
|
||||
void onDownloadLimitChanged( int );
|
||||
void onUploadLimitedToggled( bool );
|
||||
void onUploadLimitChanged( int );
|
||||
void onSeedUntilChanged( bool );
|
||||
void onSeedRatioLimitChanged( double );
|
||||
void onMaxPeersChanged( int );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <QMessageBox>
|
||||
#include <QSet>
|
||||
#include <QStyle>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <libtransmission/transmission.h>
|
||||
#include <libtransmission/bencode.h>
|
||||
|
@ -86,6 +87,7 @@ Session :: sessionSet( const char * key, const QVariant& value )
|
|||
case QVariant::String: tr_bencDictAddStr ( args, key, value.toString().toUtf8() ); break;
|
||||
default: assert( "unknown type" );
|
||||
}
|
||||
std::cerr << tr_bencToJSON(&top) << std::endl;
|
||||
exec( &top );
|
||||
tr_bencFree( &top );
|
||||
}
|
||||
|
@ -274,17 +276,34 @@ namespace
|
|||
|
||||
const int Session :: ADD_TORRENT_TAG = TAG_ADD_TORRENT;
|
||||
|
||||
void
|
||||
Session :: torrentSet( int id, const QString& key, double value )
|
||||
{
|
||||
QString s;
|
||||
QTextStream( &s ) << "{ \"method\": \"torrent-set\", \"arguments\": { \"ids\": "<<id<<", \""<<key<<"\": "<<value<<" } }";
|
||||
std::cerr << qPrintable(s) << std::endl;
|
||||
exec( s.toUtf8().constData() );
|
||||
refreshExtraStats( id );
|
||||
}
|
||||
|
||||
void
|
||||
Session :: torrentSet( int id, const QString& key, int value )
|
||||
{
|
||||
QString s;
|
||||
QTextStream( &s ) << "{ \"method\": \"torrent-set\", \"arguments\": { \"ids\": "<<id<<", \""<<key<<"\": "<<value<<" } }";
|
||||
std::cerr << qPrintable(s) << std::endl;
|
||||
exec( s.toUtf8().constData() );
|
||||
refreshExtraStats( id );
|
||||
}
|
||||
|
||||
void
|
||||
Session :: torrentSet( int id, const QString& key, bool value )
|
||||
{
|
||||
tr_benc top;
|
||||
tr_bencInitDict( &top, 2 );
|
||||
tr_bencDictAddStr( &top, "method", "torrent-set" );
|
||||
tr_benc * args( tr_bencDictAddDict( &top, "arguments", 2 ) );
|
||||
tr_bencDictAddInt( args, key.toUtf8(), value );
|
||||
tr_bencListAddInt( tr_bencDictAddList( args, "ids", 1 ), id );
|
||||
exec( &top );
|
||||
tr_bencFree( &top );
|
||||
QString s;
|
||||
QTextStream( &s ) << "{ \"method\": \"torrent-set\", \"arguments\": { \"ids\": "<<id<<", \""<<key<<"\": "<<(value?"true":"false")<<" } }";
|
||||
std::cerr << qPrintable(s) << std::endl;
|
||||
exec( s.toUtf8().constData() );
|
||||
refreshExtraStats( id );
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -295,11 +314,12 @@ Session :: torrentSet( int id, const QString& key, const QList<int>& value )
|
|||
tr_bencDictAddStr( &top, "method", "torrent-set" );
|
||||
tr_benc * args( tr_bencDictAddDict( &top, "arguments", 2 ) );
|
||||
tr_bencListAddInt( tr_bencDictAddList( args, "ids", 1 ), id );
|
||||
tr_benc * list( tr_bencDictAddList( args, key.toUtf8(), value.size( ) ) );
|
||||
tr_benc * list( tr_bencDictAddList( args, key.toUtf8().constData(), value.size( ) ) );
|
||||
foreach( int i, value )
|
||||
tr_bencListAddInt( list, i );
|
||||
exec( &top );
|
||||
tr_bencFree( &top );
|
||||
refreshExtraStats( id );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -74,6 +74,8 @@ class Session: public QObject
|
|||
|
||||
public:
|
||||
void torrentSet( int id, const QString& key, bool val );
|
||||
void torrentSet( int id, const QString& key, int val );
|
||||
void torrentSet( int id, const QString& key, double val );
|
||||
void torrentSet( int id, const QString& key, const QList<int>& val );
|
||||
|
||||
public slots:
|
||||
|
|
|
@ -25,6 +25,8 @@ TorrentFilter :: TorrentFilter( Prefs& prefs ):
|
|||
// listen for changes to the preferences to know when to refilter / resort
|
||||
connect( &myPrefs, SIGNAL(changed(int)), this, SLOT(refreshPref(int)));
|
||||
|
||||
setDynamicSortFilter( true );
|
||||
|
||||
// initialize our state from the current prefs
|
||||
QList<int> initKeys;
|
||||
initKeys << Prefs :: SORT_MODE
|
||||
|
|
Loading…
Add table
Reference in a new issue