Changeset 8221


Ignore:
Timestamp:
Apr 12, 2009, 9:15:35 PM (13 years ago)
Author:
charles
Message:

(trunk qt) first stab at getting the properties dialog's "options" controls operational.

Location:
trunk/qt
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/details.cc

    r8188 r8221  
    5757namespace
    5858{
    59     const int REFRESH_INTERVAL_MSEC = 3500;
     59    const int REFRESH_INTERVAL_MSEC = 4000;
    6060
    6161    enum // peer columns
     
    244244    myLeechersLabel->setText( locale.toString( myTorrent.leechers( ) ) );
    245245    myTimesCompletedLabel->setText( locale.toString( myTorrent.timesCompleted( ) ) );
    246     //const PeerList peers( myTorrent.peers( ) );
    247     PeerList peers( myTorrent.peers( ) );
    248 #if 0
    249 static double progress = 0.01;
    250 {
    251 Peer peer;
    252 peer.address = "127.0.0.1";
    253 peer.isEncrypted = true;
    254 peer.progress = progress;
    255 peer.rateToPeer = Speed::fromKbps(20);
    256 peers << peer;
    257 progress += 0.01;
    258 }
    259 #endif
     246    const PeerList peers( myTorrent.peers( ) );
    260247    QMap<QString,QTreeWidgetItem*> peers2;
    261248    QList<QTreeWidgetItem*> newItems;
    262249    static const QIcon myEncryptionIcon( ":/icons/encrypted.png" );
    263250    static const QIcon myEmptyIcon;
    264     foreach( Peer peer, peers )
     251    foreach( const Peer& peer, peers )
    265252    {
    266253        PeerItem * item = (PeerItem*) myPeers.value( peer.address, 0 );
     
    373360
    374361void
    375 Details :: onSessionLimitsToggled( bool b )
    376 {
    377     mySession.torrentSet( myTorrent.id(), "honorsSessionLimits", b );
     362Details :: onHonorsSessionLimitsToggled( bool val )
     363{
     364    mySession.torrentSet( myTorrent.id(), "honorsSessionLimits", val );
     365}
     366void
     367Details :: onDownloadLimitedToggled( bool val )
     368{
     369    mySession.torrentSet( myTorrent.id(), "downloadLimited", val );
     370}
     371void
     372Details :: onDownloadLimitChanged( int val )
     373{
     374    mySession.torrentSet( myTorrent.id(), "downloadLimit", val );
     375}
     376void
     377Details :: onUploadLimitedToggled( bool val )
     378{
     379    mySession.torrentSet( myTorrent.id(), "uploadLimited", val );
     380}
     381void
     382Details :: onUploadLimitChanged( int val )
     383{
     384    mySession.torrentSet( myTorrent.id(), "uploadLimit", val );
     385}
     386
     387#define RATIO_KEY "seedRatioMode"
     388
     389void
     390Details :: onSeedUntilChanged( bool b )
     391{
     392    if( b )
     393        mySession.torrentSet( myTorrent.id(), RATIO_KEY, sender()->property(RATIO_KEY).toInt() );
     394}
     395
     396void
     397Details :: onSeedRatioLimitChanged( double val )
     398{
     399    mySession.torrentSet( myTorrent.id(), "seedRatioLimit", val );
     400}
     401
     402void
     403Details :: onMaxPeersChanged( int val )
     404{
     405    mySession.torrentSet( myTorrent.id(), "peer-limit", val );
    378406}
    379407
     
    394422    mySessionLimitCheck = c;
    395423    hig->addWideControl( c );
    396     connect( c, SIGNAL(toggled(bool)), this, SLOT(onSessionLimitsToggled(bool)) );
     424    connect( c, SIGNAL(toggled(bool)), this, SLOT(onHonorsSessionLimitsToggled(bool)) );
    397425
    398426    c = new QCheckBox( tr( "Limit &download speed (KB/s)" ) );
     
    403431    hig->addRow( c, s );
    404432    enableWhenChecked( c, s );
     433    connect( c, SIGNAL(toggled(bool)), this, SLOT(onDownloadLimitedToggled(bool)) );
     434    connect( s, SIGNAL(valueChanged(int)), this, SLOT(onDownloadLimitChanged(int)));
    405435
    406436    c = new QCheckBox( tr( "Limit &upload speed (KB/s)" ) );
     
    411441    hig->addRow( c, s );
    412442    enableWhenChecked( c, s );
     443    connect( c, SIGNAL(toggled(bool)), this, SLOT(onUploadLimitedToggled(bool)) );
     444    connect( s, SIGNAL(valueChanged(int)), this, SLOT(onUploadLimitChanged(int)));
    413445
    414446    hig->addSectionDivider( );
     
    416448
    417449    r = new QRadioButton( tr( "Use &global setting" ) );
     450    r->setProperty( RATIO_KEY, TR_RATIOLIMIT_GLOBAL );
     451    connect( r, SIGNAL(toggled(bool)), this, SLOT(onSeedUntilChanged(bool)));
    418452    mySeedGlobalRadio = r;
    419453    hig->addWideControl( r );
    420454
    421455    r = new QRadioButton( tr( "Seed &regardless of ratio" ) );
     456    r->setProperty( RATIO_KEY, TR_RATIOLIMIT_UNLIMITED );
     457    connect( r, SIGNAL(toggled(bool)), this, SLOT(onSeedUntilChanged(bool)));
    422458    mySeedForeverRadio = r;
    423459    hig->addWideControl( r );
     
    426462    h->setSpacing( HIG :: PAD );
    427463    r = new QRadioButton( tr( "&Stop seeding when a torrent's ratio reaches" ) );
     464    r->setProperty( RATIO_KEY, TR_RATIOLIMIT_SINGLE );
     465    connect( r, SIGNAL(toggled(bool)), this, SLOT(onSeedUntilChanged(bool)));
    428466    mySeedCustomRadio = r;
    429467    h->addWidget( r );
    430468    ds = new QDoubleSpinBox( );
    431469    ds->setRange( 0.5, INT_MAX );
     470    connect( ds, SIGNAL(valueChanged(double)), this, SLOT(onSeedRatioLimitChanged(double)));
    432471    mySeedCustomSpin = ds;
    433472    h->addWidget( ds );
     
    439478    s = new QSpinBox( );
    440479    s->setRange( 1, 300 );
     480    connect( s, SIGNAL(valueChanged(int)), this, SLOT(onMaxPeersChanged(int)));
    441481    myPeerLimitSpin = s;
    442482    hig->addRow( tr( "&Maximum Peers" ), s );
  • trunk/qt/details.h

    r8188 r8221  
    115115
    116116    private slots:
    117         void onSessionLimitsToggled( bool );
    118117        void onFilePriorityChanged( const QSet<int>& fileIndices, int );
    119118        void onFileWantedChanged( const QSet<int>& fileIndices, bool );
    120 
    121 
     119        void onHonorsSessionLimitsToggled( bool );
     120        void onDownloadLimitedToggled( bool );
     121        void onDownloadLimitChanged( int );
     122        void onUploadLimitedToggled( bool );
     123        void onUploadLimitChanged( int );
     124        void onSeedUntilChanged( bool );
     125        void onSeedRatioLimitChanged( double );
     126        void onMaxPeersChanged( int );
    122127};
    123128
  • trunk/qt/session.cc

    r8216 r8221  
    2121#include <QSet>
    2222#include <QStyle>
     23#include <QTextStream>
    2324
    2425#include <libtransmission/transmission.h>
     
    8788        default: assert( "unknown type" );
    8889    }
     90std::cerr << tr_bencToJSON(&top) << std::endl;
    8991    exec( &top );
    9092    tr_bencFree( &top );
     
    276278
    277279void
     280Session :: torrentSet( int id, const QString& key, double value )
     281{
     282    QString s;
     283    QTextStream( &s ) << "{ \"method\": \"torrent-set\", \"arguments\": { \"ids\": "<<id<<", \""<<key<<"\": "<<value<<" } }";
     284std::cerr << qPrintable(s) << std::endl;
     285    exec( s.toUtf8().constData() );
     286    refreshExtraStats( id );
     287}
     288
     289void
     290Session :: torrentSet( int id, const QString& key, int value )
     291{
     292    QString s;
     293    QTextStream( &s ) << "{ \"method\": \"torrent-set\", \"arguments\": { \"ids\": "<<id<<", \""<<key<<"\": "<<value<<" } }";
     294std::cerr << qPrintable(s) << std::endl;
     295    exec( s.toUtf8().constData() );
     296    refreshExtraStats( id );
     297}
     298
     299void
    278300Session :: torrentSet( int id, const QString& key, bool value )
    279301{
    280     tr_benc top;
    281     tr_bencInitDict( &top, 2 );
    282     tr_bencDictAddStr( &top, "method", "torrent-set" );
    283     tr_benc * args( tr_bencDictAddDict( &top, "arguments", 2 ) );
    284     tr_bencDictAddInt( args, key.toUtf8(), value );
    285     tr_bencListAddInt( tr_bencDictAddList( args, "ids", 1 ), id );
    286     exec( &top );
    287     tr_bencFree( &top );
     302    QString s;
     303    QTextStream( &s ) << "{ \"method\": \"torrent-set\", \"arguments\": { \"ids\": "<<id<<", \""<<key<<"\": "<<(value?"true":"false")<<" } }";
     304std::cerr << qPrintable(s) << std::endl;
     305    exec( s.toUtf8().constData() );
     306    refreshExtraStats( id );
    288307}
    289308
     
    296315    tr_benc * args( tr_bencDictAddDict( &top, "arguments", 2 ) );
    297316    tr_bencListAddInt( tr_bencDictAddList( args, "ids", 1 ), id );
    298     tr_benc * list( tr_bencDictAddList( args, key.toUtf8(), value.size( ) ) );
     317    tr_benc * list( tr_bencDictAddList( args, key.toUtf8().constData(), value.size( ) ) );
    299318    foreach( int i, value )
    300319        tr_bencListAddInt( list, i );
    301320    exec( &top );
    302321    tr_bencFree( &top );
     322    refreshExtraStats( id );
    303323}
    304324
  • trunk/qt/session.h

    r8188 r8221  
    7575    public:
    7676        void torrentSet( int id, const QString& key, bool val );
     77        void torrentSet( int id, const QString& key, int val );
     78        void torrentSet( int id, const QString& key, double val );
    7779        void torrentSet( int id, const QString& key, const QList<int>& val );
    7880
  • trunk/qt/torrent-filter.cc

    r8216 r8221  
    2525    // listen for changes to the preferences to know when to refilter / resort
    2626    connect( &myPrefs, SIGNAL(changed(int)), this, SLOT(refreshPref(int)));
     27
     28    setDynamicSortFilter( true );
    2729
    2830    // initialize our state from the current prefs
Note: See TracChangeset for help on using the changeset viewer.