Changeset 8221 for trunk/qt/session.cc


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.