2009-04-09 18:55:47 +00:00
|
|
|
/*
|
|
|
|
* This file Copyright (C) 2009 Charles Kerr <charles@transmissionbt.com>
|
|
|
|
*
|
|
|
|
* This file is licensed by the GPL version 2. Works owned by the
|
|
|
|
* Transmission project are granted a special exemption to clause 2(b)
|
|
|
|
* so that the bulk of its code can remain under the MIT license.
|
|
|
|
* This exemption does not extend to derived works not owned by
|
|
|
|
* the Transmission project.
|
|
|
|
*
|
2009-05-31 19:33:48 +00:00
|
|
|
* $Id$
|
2009-04-09 18:55:47 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <cassert>
|
|
|
|
#include <ctime>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include <QCheckBox>
|
2009-04-18 23:18:28 +00:00
|
|
|
#include <QComboBox>
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QEvent>
|
|
|
|
#include <QHeaderView>
|
|
|
|
#include <QResizeEvent>
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
#include <QDoubleSpinBox>
|
|
|
|
#include <QFont>
|
|
|
|
#include <QFontMetrics>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QLocale>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QSpinBox>
|
|
|
|
#include <QRadioButton>
|
|
|
|
#include <QStyle>
|
|
|
|
#include <QTabWidget>
|
|
|
|
#include <QTreeView>
|
|
|
|
#include <QTextBrowser>
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QTreeWidget>
|
|
|
|
#include <QTreeWidgetItem>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
2009-04-13 18:21:22 +00:00
|
|
|
#include <libtransmission/transmission.h>
|
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
#include "details.h"
|
|
|
|
#include "file-tree.h"
|
|
|
|
#include "hig.h"
|
|
|
|
#include "session.h"
|
|
|
|
#include "squeezelabel.h"
|
|
|
|
#include "torrent.h"
|
2009-04-18 23:18:28 +00:00
|
|
|
#include "torrent-model.h"
|
2009-04-09 18:55:47 +00:00
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
class Prefs;
|
|
|
|
class Session;
|
|
|
|
|
|
|
|
/****
|
|
|
|
*****
|
|
|
|
****/
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
2009-04-12 21:15:35 +00:00
|
|
|
const int REFRESH_INTERVAL_MSEC = 4000;
|
2009-04-09 18:55:47 +00:00
|
|
|
|
|
|
|
enum // peer columns
|
|
|
|
{
|
|
|
|
COL_LOCK,
|
|
|
|
COL_UP,
|
|
|
|
COL_DOWN,
|
|
|
|
COL_PERCENT,
|
|
|
|
COL_STATUS,
|
|
|
|
COL_ADDRESS,
|
|
|
|
COL_CLIENT,
|
|
|
|
N_COLUMNS
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
|
|
|
class PeerItem: public QTreeWidgetItem
|
|
|
|
{
|
|
|
|
Peer peer;
|
2009-04-16 16:35:00 +00:00
|
|
|
QString collatedAddress;
|
2009-04-09 18:55:47 +00:00
|
|
|
QString status;
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~PeerItem( ) { }
|
2009-05-04 02:58:05 +00:00
|
|
|
PeerItem( const Peer& p ) {
|
2009-04-09 18:55:47 +00:00
|
|
|
peer = p;
|
2009-04-26 15:41:04 +00:00
|
|
|
int q[4];
|
|
|
|
if( sscanf( p.address.toUtf8().constData(), "%d.%d.%d.%d", q+0, q+1, q+2, q+3 ) == 4 )
|
|
|
|
collatedAddress.sprintf( "%03d.%03d.%03d.%03d", q[0], q[1], q[2], q[3] );
|
2009-04-16 16:35:00 +00:00
|
|
|
else
|
|
|
|
collatedAddress = p.address;
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
2009-05-04 02:58:05 +00:00
|
|
|
public:
|
|
|
|
void refresh( const Peer& p ) { peer = p; }
|
|
|
|
void setStatus( const QString& s ) { status = s; }
|
2009-04-09 18:55:47 +00:00
|
|
|
virtual bool operator< ( const QTreeWidgetItem & other ) const {
|
2009-04-26 15:41:04 +00:00
|
|
|
const PeerItem * i = dynamic_cast<const PeerItem*>(&other);
|
2009-04-09 18:55:47 +00:00
|
|
|
QTreeWidget * tw( treeWidget( ) );
|
|
|
|
const int column = tw ? tw->sortColumn() : 0;
|
|
|
|
switch( column ) {
|
2009-04-26 15:41:04 +00:00
|
|
|
case COL_UP: return peer.rateToPeer < i->peer.rateToPeer;
|
|
|
|
case COL_DOWN: return peer.rateToClient < i->peer.rateToClient;
|
|
|
|
case COL_PERCENT: return peer.progress < i->peer.progress;
|
|
|
|
case COL_STATUS: return status < i->status;
|
|
|
|
case COL_CLIENT: return peer.clientName < i->peer.clientName;
|
|
|
|
case COL_LOCK: return peer.isEncrypted && !i->peer.isEncrypted;
|
|
|
|
default: return collatedAddress < i->collatedAddress;
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2009-04-18 23:18:28 +00:00
|
|
|
Details :: Details( Session& session, TorrentModel& model, QWidget * parent ):
|
2009-04-09 18:55:47 +00:00
|
|
|
QDialog( parent, Qt::Dialog ),
|
|
|
|
mySession( session ),
|
2009-04-18 23:18:28 +00:00
|
|
|
myModel( model ),
|
|
|
|
myHavePendingRefresh( false )
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
|
|
|
QVBoxLayout * layout = new QVBoxLayout( this );
|
|
|
|
|
2009-04-18 23:18:28 +00:00
|
|
|
setWindowTitle( tr( "Torrent Properties" ) );
|
2009-04-09 18:55:47 +00:00
|
|
|
|
|
|
|
QTabWidget * t = new QTabWidget( this );
|
2009-04-18 23:18:28 +00:00
|
|
|
QWidget * w;
|
2009-06-23 00:24:37 +00:00
|
|
|
t->addTab( w = createInfoTab( ), tr( "Information" ) );
|
2009-04-18 23:18:28 +00:00
|
|
|
myWidgets << w;
|
|
|
|
t->addTab( w = createPeersTab( ), tr( "Peers" ) );
|
|
|
|
myWidgets << w;
|
|
|
|
t->addTab( w = createTrackerTab( ), tr( "Tracker" ) );
|
|
|
|
myWidgets << w;
|
|
|
|
t->addTab( w = createFilesTab( ), tr( "Files" ) );
|
|
|
|
myWidgets << w;
|
|
|
|
t->addTab( w = createOptionsTab( ), tr( "Options" ) );
|
|
|
|
myWidgets << w;
|
2009-04-09 18:55:47 +00:00
|
|
|
layout->addWidget( t );
|
|
|
|
|
|
|
|
QDialogButtonBox * buttons = new QDialogButtonBox( QDialogButtonBox::Close, Qt::Horizontal, this );
|
2009-04-26 15:41:04 +00:00
|
|
|
connect( buttons, SIGNAL(rejected()), this, SLOT(deleteLater()));
|
2009-04-09 18:55:47 +00:00
|
|
|
layout->addWidget( buttons );
|
|
|
|
|
2009-04-26 15:41:04 +00:00
|
|
|
connect( &myTimer, SIGNAL(timeout()), this, SLOT(onTimer()));
|
2009-04-09 18:55:47 +00:00
|
|
|
|
|
|
|
onTimer( );
|
|
|
|
myTimer.setSingleShot( false );
|
|
|
|
myTimer.start( REFRESH_INTERVAL_MSEC );
|
|
|
|
}
|
|
|
|
|
|
|
|
Details :: ~Details( )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-04-18 23:18:28 +00:00
|
|
|
void
|
|
|
|
Details :: setIds( const QSet<int>& ids )
|
|
|
|
{
|
|
|
|
if( ids == myIds )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// stop listening to the old torrents
|
|
|
|
foreach( int id, myIds ) {
|
|
|
|
const Torrent * tor = myModel.getTorrentFromId( id );
|
|
|
|
if( tor )
|
|
|
|
disconnect( tor, SIGNAL(torrentChanged(int)), this, SLOT(onTorrentChanged()) );
|
|
|
|
}
|
|
|
|
|
2009-05-02 14:33:10 +00:00
|
|
|
myFileTreeView->clear( );
|
|
|
|
|
2009-04-18 23:18:28 +00:00
|
|
|
myIds = ids;
|
|
|
|
|
|
|
|
// listen to the new torrents
|
|
|
|
foreach( int id, myIds ) {
|
|
|
|
const Torrent * tor = myModel.getTorrentFromId( id );
|
|
|
|
if( tor )
|
|
|
|
connect( tor, SIGNAL(torrentChanged(int)), this, SLOT(onTorrentChanged()) );
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach( QWidget * w, myWidgets )
|
|
|
|
w->setEnabled( false );
|
|
|
|
|
|
|
|
onTimer( );
|
|
|
|
}
|
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
|
|
|
void
|
|
|
|
Details :: onTimer( )
|
|
|
|
{
|
2009-04-18 23:18:28 +00:00
|
|
|
if( !myIds.empty( ) )
|
|
|
|
mySession.refreshExtraStats( myIds );
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Details :: onTorrentChanged( )
|
|
|
|
{
|
2009-04-18 23:18:28 +00:00
|
|
|
if( !myHavePendingRefresh ) {
|
|
|
|
myHavePendingRefresh = true;
|
|
|
|
QTimer::singleShot( 100, this, SLOT(refresh()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
Details :: refresh( )
|
|
|
|
{
|
2009-04-09 18:55:47 +00:00
|
|
|
QLocale locale;
|
2009-04-18 23:18:28 +00:00
|
|
|
const int n = myIds.size( );
|
|
|
|
const bool single = n == 1;
|
|
|
|
const QString blank;
|
2009-04-09 18:55:47 +00:00
|
|
|
const QFontMetrics fm( fontMetrics( ) );
|
2009-04-26 15:41:04 +00:00
|
|
|
QList<const Torrent*> torrents;
|
2009-04-18 23:18:28 +00:00
|
|
|
QString string;
|
2009-04-26 15:41:04 +00:00
|
|
|
const QString none = tr( "None" );
|
|
|
|
const QString mixed = tr( "Mixed" );
|
|
|
|
const QString unknown = tr( "Unknown" );
|
2009-04-18 23:18:28 +00:00
|
|
|
|
|
|
|
// build a list of torrents
|
|
|
|
foreach( int id, myIds ) {
|
|
|
|
const Torrent * tor = myModel.getTorrentFromId( id );
|
|
|
|
if( tor )
|
|
|
|
torrents << tor;
|
|
|
|
}
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2009-04-18 23:18:28 +00:00
|
|
|
///
|
|
|
|
/// activity tab
|
|
|
|
///
|
|
|
|
|
|
|
|
// myStateLabel
|
|
|
|
if( torrents.empty( ) )
|
2009-04-26 15:41:04 +00:00
|
|
|
string = none;
|
2009-04-18 23:18:28 +00:00
|
|
|
else {
|
2009-04-26 15:41:04 +00:00
|
|
|
string = torrents[0]->activityString( );
|
|
|
|
foreach( const Torrent* t, torrents ) {
|
|
|
|
if( string != t->activityString( ) ) {
|
|
|
|
string = mixed;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-04-18 23:18:28 +00:00
|
|
|
}
|
|
|
|
myStateLabel->setText( string );
|
|
|
|
|
|
|
|
// myHaveLabel
|
2009-06-23 00:24:37 +00:00
|
|
|
double sizeWhenDone = 0;
|
|
|
|
double leftUntilDone = 0;
|
2009-04-18 23:18:28 +00:00
|
|
|
int64_t haveTotal = 0;
|
|
|
|
int64_t haveVerified = 0;
|
2009-06-23 00:24:37 +00:00
|
|
|
int64_t haveUnverified = 0;
|
2009-04-18 23:18:28 +00:00
|
|
|
int64_t verifiedPieces = 0;
|
2009-04-26 15:41:04 +00:00
|
|
|
foreach( const Torrent * t, torrents ) {
|
|
|
|
haveTotal += t->haveTotal( );
|
2009-06-23 00:24:37 +00:00
|
|
|
haveUnverified += t->haveUnverified( );
|
2009-04-26 15:41:04 +00:00
|
|
|
const uint64_t v = t->haveVerified( );
|
|
|
|
haveVerified += v;
|
|
|
|
verifiedPieces += v / t->pieceSize( );
|
2009-06-23 00:24:37 +00:00
|
|
|
sizeWhenDone += t->sizeWhenDone( );
|
|
|
|
leftUntilDone += t->leftUntilDone( );
|
|
|
|
}
|
|
|
|
if( !haveVerified && !haveUnverified )
|
|
|
|
string = none;
|
|
|
|
else {
|
2009-06-30 22:27:22 +00:00
|
|
|
const double d = 100.0 * ( sizeWhenDone ? ( sizeWhenDone - leftUntilDone ) / sizeWhenDone : 1 );
|
|
|
|
QString pct = locale.toString( d, 'f', 2 );
|
2009-06-23 00:24:37 +00:00
|
|
|
if( !haveUnverified )
|
2009-06-28 16:21:47 +00:00
|
|
|
string = tr( "%1 (%2%)" )
|
|
|
|
.arg( Utils :: sizeToString( haveVerified + haveUnverified ) )
|
|
|
|
.arg( pct );
|
2009-06-23 00:24:37 +00:00
|
|
|
else
|
2009-06-28 16:21:47 +00:00
|
|
|
string = tr( "%1 (%2%); %3 Unverified" )
|
|
|
|
.arg( Utils :: sizeToString( haveVerified + haveUnverified ) )
|
|
|
|
.arg( pct )
|
|
|
|
.arg( Utils :: sizeToString( haveUnverified ) );
|
2009-04-18 23:18:28 +00:00
|
|
|
}
|
2009-06-23 00:24:37 +00:00
|
|
|
myHaveLabel->setText( string );
|
2009-04-18 23:18:28 +00:00
|
|
|
|
2009-06-23 00:24:37 +00:00
|
|
|
// myDownloadedLabel
|
|
|
|
if( torrents.empty( ) )
|
|
|
|
string = none;
|
|
|
|
else {
|
|
|
|
uint64_t d=0, f=0;
|
|
|
|
foreach( const Torrent * t, torrents ) {
|
|
|
|
d += t->downloadedEver( );
|
|
|
|
f += t->failedEver( );
|
|
|
|
}
|
|
|
|
const QString dstr = Utils::sizeToString( d );
|
|
|
|
const QString fstr = Utils::sizeToString( f );
|
|
|
|
if( f )
|
2009-06-29 03:12:30 +00:00
|
|
|
string = tr( "%1 (+%2 corrupt)" ).arg( dstr ).arg( fstr );
|
2009-06-23 00:24:37 +00:00
|
|
|
else
|
|
|
|
string = dstr;
|
|
|
|
}
|
|
|
|
myDownloadedLabel->setText( string );
|
2009-04-18 23:18:28 +00:00
|
|
|
|
2009-06-23 00:24:37 +00:00
|
|
|
uint64_t sum = 0;
|
2009-04-26 15:41:04 +00:00
|
|
|
foreach( const Torrent * t, torrents ) sum += t->uploadedEver( );
|
|
|
|
myUploadedLabel->setText( Utils::sizeToString( sum ) );
|
2009-04-18 23:18:28 +00:00
|
|
|
|
|
|
|
double d = 0;
|
2009-04-26 15:41:04 +00:00
|
|
|
foreach( const Torrent *t, torrents ) d += t->ratio( );
|
2009-04-18 23:18:28 +00:00
|
|
|
myRatioLabel->setText( Utils :: ratioToString( d / n ) );
|
|
|
|
|
2009-06-23 00:24:37 +00:00
|
|
|
const QDateTime qdt_now = QDateTime::currentDateTime( );
|
2009-04-18 23:18:28 +00:00
|
|
|
|
2009-06-23 00:24:37 +00:00
|
|
|
// myRunTimeLabel
|
2009-04-26 15:41:04 +00:00
|
|
|
if( torrents.empty( ) )
|
|
|
|
string = none;
|
|
|
|
else {
|
2009-06-23 00:24:37 +00:00
|
|
|
bool allPaused = true;
|
|
|
|
QDateTime baseline = torrents[0]->lastStarted( );
|
2009-04-26 15:41:04 +00:00
|
|
|
foreach( const Torrent * t, torrents ) {
|
2009-06-23 00:24:37 +00:00
|
|
|
if( baseline != t->lastStarted( ) )
|
|
|
|
baseline = QDateTime( );
|
|
|
|
if( !t->isPaused( ) )
|
|
|
|
allPaused = false;
|
2009-04-26 15:41:04 +00:00
|
|
|
}
|
2009-06-23 00:24:37 +00:00
|
|
|
if( allPaused )
|
|
|
|
string = tr( "Stopped" );
|
|
|
|
else if( baseline.isNull( ) )
|
|
|
|
string = mixed;
|
|
|
|
else
|
|
|
|
string = Utils::timeToString( baseline.secsTo( qdt_now ) );
|
2009-04-26 15:41:04 +00:00
|
|
|
}
|
2009-06-23 00:24:37 +00:00
|
|
|
myRunTimeLabel->setText( string );
|
2009-04-18 23:18:28 +00:00
|
|
|
|
2009-04-26 15:41:04 +00:00
|
|
|
|
2009-06-23 00:24:37 +00:00
|
|
|
// myLastActivityLabel
|
2009-04-26 15:41:04 +00:00
|
|
|
if( torrents.empty( ) )
|
|
|
|
string = none;
|
|
|
|
else {
|
|
|
|
QDateTime latest = torrents[0]->lastActivity( );
|
|
|
|
foreach( const Torrent * t, torrents ) {
|
|
|
|
const QDateTime dt = t->lastActivity( );
|
|
|
|
if( latest < dt )
|
|
|
|
latest = dt;
|
|
|
|
}
|
2009-06-23 00:24:37 +00:00
|
|
|
const int seconds = latest.secsTo( qdt_now );
|
|
|
|
if( seconds < 5 )
|
|
|
|
string = tr( "Active now" );
|
|
|
|
else
|
|
|
|
string = tr( "%1 ago" ).arg( Utils::timeToString( seconds ) );
|
2009-04-18 23:18:28 +00:00
|
|
|
}
|
2009-06-23 00:24:37 +00:00
|
|
|
myLastActivityLabel->setText( string );
|
2009-04-18 23:18:28 +00:00
|
|
|
|
2009-04-26 15:41:04 +00:00
|
|
|
|
2009-04-18 23:18:28 +00:00
|
|
|
if( torrents.empty( ) )
|
2009-04-26 15:41:04 +00:00
|
|
|
string = none;
|
2009-04-18 23:18:28 +00:00
|
|
|
else {
|
2009-04-26 15:41:04 +00:00
|
|
|
string = torrents[0]->getError( );
|
|
|
|
foreach( const Torrent * t, torrents ) {
|
|
|
|
if( string != t->getError( ) ) {
|
|
|
|
string = mixed;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-04-18 23:18:28 +00:00
|
|
|
}
|
2009-06-23 00:24:37 +00:00
|
|
|
if( string.isEmpty( ) )
|
|
|
|
string = none;
|
2009-04-18 23:18:28 +00:00
|
|
|
myErrorLabel->setText( string );
|
|
|
|
|
2009-04-26 15:41:04 +00:00
|
|
|
|
2009-04-18 23:18:28 +00:00
|
|
|
///
|
|
|
|
/// information tab
|
|
|
|
///
|
|
|
|
|
2009-06-23 00:24:37 +00:00
|
|
|
// mySizeLabel
|
2009-04-26 15:41:04 +00:00
|
|
|
if( torrents.empty( ) )
|
|
|
|
string = none;
|
|
|
|
else {
|
2009-06-23 00:24:37 +00:00
|
|
|
int pieces = 0;
|
|
|
|
uint64_t size = 0;
|
|
|
|
uint32_t pieceSize = torrents[0]->pieceSize( );
|
2009-04-26 15:41:04 +00:00
|
|
|
foreach( const Torrent * t, torrents ) {
|
2009-06-23 00:24:37 +00:00
|
|
|
pieces += t->pieceCount( );
|
|
|
|
size += t->totalSize( );
|
|
|
|
if( pieceSize != t->pieceSize( ) )
|
|
|
|
pieceSize = 0;
|
2009-04-26 15:41:04 +00:00
|
|
|
}
|
2009-06-23 00:24:37 +00:00
|
|
|
if( !size )
|
|
|
|
string = none;
|
|
|
|
else if( pieceSize > 0 )
|
|
|
|
string = tr( "%1 (%Ln pieces @ %2)", "", pieces )
|
|
|
|
.arg( Utils::sizeToString( size ) )
|
|
|
|
.arg( Utils::sizeToString( pieceSize ) );
|
2009-04-26 15:41:04 +00:00
|
|
|
else
|
2009-06-23 00:24:37 +00:00
|
|
|
string = tr( "%1 (%Ln pieces)", "", pieces )
|
|
|
|
.arg( Utils::sizeToString( size ) );
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
2009-06-23 00:24:37 +00:00
|
|
|
mySizeLabel->setText( string );
|
2009-04-18 23:18:28 +00:00
|
|
|
|
|
|
|
// myHashLabel
|
2009-04-26 15:41:04 +00:00
|
|
|
if( torrents.empty( ) )
|
|
|
|
string = none;
|
|
|
|
else {
|
|
|
|
string = torrents[0]->hashString( );
|
|
|
|
foreach( const Torrent * t, torrents ) {
|
|
|
|
if( string != t->hashString( ) ) {
|
|
|
|
string = mixed;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-04-18 23:18:28 +00:00
|
|
|
myHashLabel->setText( string );
|
|
|
|
|
|
|
|
// myPrivacyLabel
|
2009-04-26 15:41:04 +00:00
|
|
|
if( torrents.empty( ) )
|
|
|
|
string = none;
|
|
|
|
else {
|
|
|
|
bool b = torrents[0]->isPrivate( );
|
2009-06-23 00:24:37 +00:00
|
|
|
string = b ? tr( "Private to this tracker -- DHT and PEX disabled" )
|
2009-04-26 15:41:04 +00:00
|
|
|
: tr( "Public torrent" );
|
|
|
|
foreach( const Torrent * t, torrents ) {
|
|
|
|
if( b != t->isPrivate( ) ) {
|
|
|
|
string = mixed;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-04-18 23:18:28 +00:00
|
|
|
myPrivacyLabel->setText( string );
|
|
|
|
|
|
|
|
// myCommentBrowser
|
2009-04-26 15:41:04 +00:00
|
|
|
if( torrents.empty( ) )
|
|
|
|
string = none;
|
|
|
|
else {
|
|
|
|
string = torrents[0]->comment( );
|
|
|
|
foreach( const Torrent * t, torrents ) {
|
|
|
|
if( string != t->comment( ) ) {
|
|
|
|
string = mixed;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-04-18 23:18:28 +00:00
|
|
|
myCommentBrowser->setText( string );
|
|
|
|
|
2009-06-23 00:24:37 +00:00
|
|
|
// myOriginLabel
|
2009-04-26 15:41:04 +00:00
|
|
|
if( torrents.empty( ) )
|
|
|
|
string = none;
|
|
|
|
else {
|
2009-06-23 00:24:37 +00:00
|
|
|
bool mixed_creator=false, mixed_date=false;
|
|
|
|
const QString creator = torrents[0]->creator();
|
|
|
|
const QString date = torrents[0]->dateCreated().toString();
|
2009-04-26 15:41:04 +00:00
|
|
|
foreach( const Torrent * t, torrents ) {
|
2009-06-23 00:24:37 +00:00
|
|
|
mixed_creator |= ( creator != t->creator() );
|
|
|
|
mixed_date |= ( date != t->dateCreated().toString() );
|
2009-04-26 15:41:04 +00:00
|
|
|
}
|
2009-06-23 00:24:37 +00:00
|
|
|
if( mixed_creator && mixed_date )
|
|
|
|
string = mixed;
|
|
|
|
else if( mixed_date )
|
|
|
|
string = tr( "Created by %1" ).arg( creator );
|
|
|
|
else if( mixed_creator || creator.isEmpty( ) )
|
|
|
|
string = tr( "Created on %1" ).arg( date );
|
|
|
|
else
|
|
|
|
string = tr( "Created by %1 on %2" ).arg( creator ).arg( date );
|
2009-04-26 15:41:04 +00:00
|
|
|
}
|
2009-06-23 00:24:37 +00:00
|
|
|
myOriginLabel->setText( string );
|
|
|
|
|
|
|
|
|
|
|
|
// myLocationLabel
|
2009-04-26 15:41:04 +00:00
|
|
|
if( torrents.empty( ) )
|
|
|
|
string = none;
|
|
|
|
else {
|
|
|
|
string = torrents[0]->getPath( );
|
|
|
|
foreach( const Torrent * t, torrents ) {
|
|
|
|
if( string != t->getPath( ) ) {
|
|
|
|
string = mixed;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-06-23 00:24:37 +00:00
|
|
|
myLocationLabel->setText( string );
|
2009-04-18 23:18:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
/// Options Tab
|
|
|
|
///
|
|
|
|
|
|
|
|
if( !torrents.empty( ) )
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const Torrent * baseline = *torrents.begin();
|
2009-04-26 15:41:04 +00:00
|
|
|
const Torrent * tor;
|
2009-04-18 23:18:28 +00:00
|
|
|
bool uniform;
|
|
|
|
bool baselineFlag;
|
|
|
|
int baselineInt;
|
|
|
|
|
|
|
|
// mySessionLimitCheck
|
|
|
|
uniform = true;
|
|
|
|
baselineFlag = baseline->honorsSessionLimits( );
|
|
|
|
foreach( tor, torrents ) if( baselineFlag != tor->honorsSessionLimits( ) ) { uniform = false; break; }
|
|
|
|
mySessionLimitCheck->setChecked( uniform && baselineFlag );
|
|
|
|
|
|
|
|
// mySingleDownCheck
|
|
|
|
uniform = true;
|
|
|
|
baselineFlag = baseline->downloadIsLimited( );
|
|
|
|
foreach( tor, torrents ) if( baselineFlag != tor->downloadIsLimited( ) ) { uniform = false; break; }
|
|
|
|
mySingleDownCheck->setChecked( uniform && baselineFlag );
|
|
|
|
|
|
|
|
// mySingleUpCheck
|
|
|
|
uniform = true;
|
|
|
|
baselineFlag = baseline->uploadIsLimited( );
|
|
|
|
foreach( tor, torrents ) if( baselineFlag != tor->uploadIsLimited( ) ) { uniform = false; break; }
|
|
|
|
mySingleUpCheck->setChecked( uniform && baselineFlag );
|
|
|
|
|
|
|
|
// myBandwidthPriorityCombo
|
|
|
|
uniform = true;
|
|
|
|
baselineInt = baseline->getBandwidthPriority( );
|
|
|
|
foreach( tor, torrents ) if ( baselineInt != tor->getBandwidthPriority( ) ) { uniform = false; break; }
|
|
|
|
if( uniform )
|
|
|
|
i = myBandwidthPriorityCombo->findData( baselineInt );
|
|
|
|
else
|
|
|
|
i = -1;
|
|
|
|
myBandwidthPriorityCombo->blockSignals( true );
|
|
|
|
myBandwidthPriorityCombo->setCurrentIndex( i );
|
|
|
|
myBandwidthPriorityCombo->blockSignals( false );
|
|
|
|
|
|
|
|
mySingleDownSpin->blockSignals( true );
|
2009-05-01 14:40:14 +00:00
|
|
|
mySingleDownSpin->setValue( int(tor->downloadLimit().kbps()) );
|
2009-04-18 23:18:28 +00:00
|
|
|
mySingleDownSpin->blockSignals( false );
|
|
|
|
|
|
|
|
mySingleUpSpin->blockSignals( true );
|
2009-05-01 14:40:14 +00:00
|
|
|
mySingleUpSpin->setValue( int(tor->uploadLimit().kbps()) );
|
2009-04-18 23:18:28 +00:00
|
|
|
mySingleUpSpin->blockSignals( false );
|
|
|
|
|
|
|
|
myPeerLimitSpin->blockSignals( true );
|
|
|
|
myPeerLimitSpin->setValue( tor->peerLimit() );
|
|
|
|
myPeerLimitSpin->blockSignals( false );
|
|
|
|
|
|
|
|
// ratio radios
|
|
|
|
uniform = true;
|
|
|
|
baselineInt = tor->seedRatioMode( );
|
|
|
|
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 );
|
|
|
|
}
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2009-04-19 02:48:55 +00:00
|
|
|
mySeedCustomSpin->blockSignals( true );
|
2009-04-18 23:18:28 +00:00
|
|
|
mySeedCustomSpin->setValue( tor->seedRatioLimit( ) );
|
2009-04-19 02:48:55 +00:00
|
|
|
mySeedCustomSpin->blockSignals( false );
|
2009-04-18 23:18:28 +00:00
|
|
|
}
|
2009-04-09 18:55:47 +00:00
|
|
|
|
|
|
|
// tracker tab
|
2009-04-26 15:41:04 +00:00
|
|
|
//
|
2009-04-09 18:55:47 +00:00
|
|
|
const time_t now( time( 0 ) );
|
2009-04-26 15:41:04 +00:00
|
|
|
|
|
|
|
// myScrapeTimePrevLabel
|
|
|
|
if( torrents.empty( ) )
|
|
|
|
string = none;
|
|
|
|
else {
|
|
|
|
QDateTime latest = torrents[0]->lastScrapeTime();
|
|
|
|
foreach( const Torrent * t, torrents ) {
|
|
|
|
const QDateTime e = t->lastScrapeTime();
|
|
|
|
if( latest < e )
|
|
|
|
latest = e;
|
|
|
|
}
|
|
|
|
string = latest.toString();
|
|
|
|
}
|
|
|
|
myScrapeTimePrevLabel->setText( string );
|
|
|
|
|
|
|
|
// myScrapeResponseLabel
|
|
|
|
if( torrents.empty( ) )
|
|
|
|
string = none;
|
|
|
|
else {
|
|
|
|
string = torrents[0]->scrapeResponse( );
|
|
|
|
foreach( const Torrent * t, torrents ) {
|
|
|
|
if( string != t->scrapeResponse( ) ) {
|
|
|
|
string = mixed;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
myScrapeResponseLabel->setText( string );
|
|
|
|
|
|
|
|
// myScrapeTimeNextLabel
|
|
|
|
if( torrents.empty( ) )
|
|
|
|
string = none;
|
|
|
|
else {
|
|
|
|
QDateTime soonest = torrents[0]->nextScrapeTime( );
|
|
|
|
foreach( const Torrent * t, torrents ) {
|
|
|
|
const QDateTime e = t->nextScrapeTime( );
|
|
|
|
if( soonest > e )
|
|
|
|
soonest = e;
|
|
|
|
}
|
|
|
|
string = Utils::timeToString( soonest.toTime_t() - now );
|
|
|
|
}
|
|
|
|
myScrapeTimeNextLabel->setText( string );
|
|
|
|
|
|
|
|
// myAnnounceTimePrevLabel
|
|
|
|
if( torrents.empty( ) )
|
|
|
|
string = none;
|
|
|
|
else {
|
|
|
|
QDateTime latest = torrents[0]->lastAnnounceTime();
|
|
|
|
foreach( const Torrent * t, torrents ) {
|
|
|
|
const QDateTime e = t->lastAnnounceTime();
|
|
|
|
if( latest < e )
|
|
|
|
latest = e;
|
|
|
|
}
|
|
|
|
string = latest.toString();
|
|
|
|
}
|
|
|
|
myAnnounceTimePrevLabel->setText( string );
|
|
|
|
|
|
|
|
// myAnnounceTimeNextLabel
|
|
|
|
if( torrents.empty( ) )
|
|
|
|
string = none;
|
|
|
|
else {
|
|
|
|
QDateTime soonest = torrents[0]->nextAnnounceTime( );
|
|
|
|
foreach( const Torrent * t, torrents ) {
|
|
|
|
const QDateTime e = t->nextAnnounceTime( );
|
|
|
|
if( soonest > e )
|
|
|
|
soonest = e;
|
|
|
|
}
|
|
|
|
string = Utils::timeToString( soonest.toTime_t() - now );
|
|
|
|
}
|
|
|
|
myAnnounceTimeNextLabel->setText( string );
|
|
|
|
|
|
|
|
// myAnnounceManualLabel
|
|
|
|
if( torrents.empty( ) )
|
|
|
|
string = none;
|
|
|
|
else {
|
|
|
|
QDateTime soonest = torrents[0]->nextAnnounceTime( );
|
|
|
|
foreach( const Torrent * t, torrents ) {
|
|
|
|
const QDateTime e = t->nextAnnounceTime( );
|
|
|
|
if( soonest > e )
|
|
|
|
soonest = e;
|
|
|
|
}
|
|
|
|
if( soonest <= QDateTime::currentDateTime( ) )
|
|
|
|
string = tr( "Now" );
|
|
|
|
else
|
|
|
|
string = Utils::timeToString( soonest.toTime_t() - now );
|
|
|
|
}
|
|
|
|
myAnnounceManualLabel->setText( string );
|
|
|
|
|
|
|
|
// myAnnounceResponseLabel
|
|
|
|
if( torrents.empty( ) )
|
|
|
|
string = none;
|
|
|
|
else {
|
|
|
|
string = torrents[0]->announceResponse( );
|
|
|
|
foreach( const Torrent * t, torrents ) {
|
|
|
|
if( string != t->announceResponse( ) ) {
|
|
|
|
string = mixed;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
myAnnounceResponseLabel->setText( string );
|
2009-04-18 23:18:28 +00:00
|
|
|
|
|
|
|
// myTrackerLabel
|
2009-04-26 15:41:04 +00:00
|
|
|
if( torrents.empty( ) )
|
|
|
|
string = none;
|
|
|
|
else {
|
|
|
|
string = QUrl(torrents[0]->announceUrl()).host();
|
|
|
|
foreach( const Torrent * t, torrents ) {
|
|
|
|
if( string != QUrl(t->announceUrl()).host() ) {
|
|
|
|
string = mixed;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-04-18 23:18:28 +00:00
|
|
|
myTrackerLabel->setText( string );
|
|
|
|
|
|
|
|
///
|
|
|
|
/// Peers tab
|
|
|
|
///
|
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
QMap<QString,QTreeWidgetItem*> peers2;
|
|
|
|
QList<QTreeWidgetItem*> newItems;
|
2009-05-04 02:58:05 +00:00
|
|
|
foreach( const Torrent * t, torrents )
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2009-05-04 02:58:05 +00:00
|
|
|
const QString idStr( QString::number( t->id( ) ) );
|
|
|
|
PeerList peers = t->peers( );
|
|
|
|
|
|
|
|
foreach( const Peer& peer, peers )
|
|
|
|
{
|
|
|
|
const QString key = idStr + ":" + peer.address;
|
|
|
|
PeerItem * item = (PeerItem*) myPeers.value( key, 0 );
|
|
|
|
|
|
|
|
if( item == 0 ) // new peer has connected
|
|
|
|
{
|
|
|
|
static const QIcon myEncryptionIcon( ":/icons/encrypted.png" );
|
|
|
|
static const QIcon myEmptyIcon;
|
|
|
|
item = new PeerItem( peer );
|
|
|
|
item->setTextAlignment( COL_UP, Qt::AlignRight );
|
|
|
|
item->setTextAlignment( COL_DOWN, Qt::AlignRight );
|
|
|
|
item->setTextAlignment( COL_PERCENT, Qt::AlignRight );
|
|
|
|
item->setIcon( COL_LOCK, peer.isEncrypted ? myEncryptionIcon : myEmptyIcon );
|
|
|
|
item->setToolTip( COL_LOCK, peer.isEncrypted ? tr( "Encrypted connection" ) : "" );
|
|
|
|
item->setText( COL_ADDRESS, peer.address );
|
|
|
|
item->setText( COL_CLIENT, peer.clientName );
|
|
|
|
newItems << item;
|
|
|
|
}
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2009-05-04 02:58:05 +00:00
|
|
|
QString code;
|
|
|
|
if( peer.isDownloadingFrom ) { code += 'D'; }
|
|
|
|
else if( peer.clientIsInterested ) { code += 'd'; }
|
|
|
|
if( peer.isUploadingTo ) { code += 'U'; }
|
|
|
|
else if( peer.peerIsInterested ) { code += 'u'; }
|
|
|
|
if( !peer.clientIsChoked && !peer.clientIsInterested ) { code += 'K'; }
|
|
|
|
if( !peer.peerIsChoked && !peer.peerIsInterested ) { code += '?'; }
|
|
|
|
if( peer.isEncrypted ) { code += 'E'; }
|
|
|
|
if( peer.isIncoming ) { code += 'I'; }
|
|
|
|
item->setStatus( code );
|
|
|
|
item->refresh( peer );
|
|
|
|
|
|
|
|
QString codeTip;
|
|
|
|
foreach( QChar ch, code ) {
|
|
|
|
QString txt;
|
|
|
|
switch( ch.toAscii() ) {
|
|
|
|
case 'O': txt = tr( "Optimistic unchoke" ); break;
|
|
|
|
case 'D': txt = tr( "Downloading from this peer" ); break;
|
|
|
|
case 'd': txt = tr( "We would download from this peer if they would let us" ); break;
|
|
|
|
case 'U': txt = tr( "Uploading to peer" ); break;
|
|
|
|
case 'u': txt = tr( "We would upload to this peer if they asked" ); break;
|
|
|
|
case 'K': txt = tr( "Peer has unchoked us, but we're not interested" ); break;
|
|
|
|
case '?': txt = tr( "We unchoked this peer, but they're not interested" ); break;
|
|
|
|
case 'E': txt = tr( "Encrypted connection" ); break;
|
|
|
|
case 'X': txt = tr( "Peer was discovered through Peer Exchange (PEX)" ); break;
|
|
|
|
case 'I': txt = tr( "Peer is an incoming connection" ); break;
|
|
|
|
}
|
|
|
|
if( !txt.isEmpty( ) )
|
|
|
|
codeTip += QString("%1: %2\n").arg(ch).arg(txt);
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
2009-05-04 02:58:05 +00:00
|
|
|
|
|
|
|
if( !codeTip.isEmpty() )
|
|
|
|
codeTip.resize( codeTip.size()-1 ); // eat the trailing linefeed
|
|
|
|
|
|
|
|
item->setText( COL_UP, peer.rateToPeer.isZero() ? "" : Utils::speedToString( peer.rateToPeer ) );
|
|
|
|
item->setText( COL_DOWN, peer.rateToClient.isZero() ? "" : Utils::speedToString( peer.rateToClient ) );
|
|
|
|
item->setText( COL_PERCENT, peer.progress > 0 ? QString( "%1%" ).arg( locale.toString((int)(peer.progress*100.0))) : "" );
|
|
|
|
item->setText( COL_STATUS, code );
|
|
|
|
item->setToolTip( COL_STATUS, codeTip );
|
|
|
|
|
|
|
|
peers2.insert( key, item );
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
myPeerTree->addTopLevelItems( newItems );
|
|
|
|
foreach( QString key, myPeers.keys() ) {
|
|
|
|
if( !peers2.contains( key ) ) { // old peer has disconnected
|
|
|
|
QTreeWidgetItem * item = myPeers.value( key, 0 );
|
|
|
|
myPeerTree->takeTopLevelItem( myPeerTree->indexOfTopLevelItem( item ) );
|
|
|
|
delete item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
myPeers = peers2;
|
|
|
|
|
2009-04-26 15:41:04 +00:00
|
|
|
if( single )
|
|
|
|
myFileTreeView->update( torrents[0]->files( ) );
|
|
|
|
else
|
2009-04-18 23:18:28 +00:00
|
|
|
myFileTreeView->clear( );
|
|
|
|
|
|
|
|
myHavePendingRefresh = false;
|
|
|
|
foreach( QWidget * w, myWidgets )
|
|
|
|
w->setEnabled( true );
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Details :: enableWhenChecked( QCheckBox * box, QWidget * w )
|
|
|
|
{
|
|
|
|
connect( box, SIGNAL(toggled(bool)), w, SLOT(setEnabled(bool)) );
|
|
|
|
w->setEnabled( box->isChecked( ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
|
|
|
QWidget *
|
2009-06-23 00:24:37 +00:00
|
|
|
Details :: createInfoTab( )
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
|
|
|
HIG * hig = new HIG( this );
|
|
|
|
|
2009-06-23 04:49:00 +00:00
|
|
|
hig->addSectionTitle( tr( "Activity" ) );
|
2009-06-23 00:24:37 +00:00
|
|
|
hig->addRow( tr( "Torrent size:" ), mySizeLabel = new SqueezeLabel );
|
2009-04-09 18:55:47 +00:00
|
|
|
hig->addRow( tr( "Have:" ), myHaveLabel = new SqueezeLabel );
|
|
|
|
hig->addRow( tr( "Downloaded:" ), myDownloadedLabel = new SqueezeLabel );
|
|
|
|
hig->addRow( tr( "Uploaded:" ), myUploadedLabel = new SqueezeLabel );
|
|
|
|
hig->addRow( tr( "Ratio:" ), myRatioLabel = new SqueezeLabel );
|
2009-06-23 00:24:37 +00:00
|
|
|
hig->addRow( tr( "State:" ), myStateLabel = new SqueezeLabel );
|
|
|
|
hig->addRow( tr( "Running time:" ), myRunTimeLabel = new SqueezeLabel );
|
|
|
|
hig->addRow( tr( "Last activity:" ), myLastActivityLabel = new SqueezeLabel );
|
2009-04-09 18:55:47 +00:00
|
|
|
hig->addRow( tr( "Error:" ), myErrorLabel = new SqueezeLabel );
|
|
|
|
hig->addSectionDivider( );
|
|
|
|
|
2009-06-23 00:24:37 +00:00
|
|
|
hig->addSectionDivider( );
|
|
|
|
hig->addSectionTitle( tr( "Details" ) );
|
|
|
|
hig->addRow( tr( "Location:" ), myLocationLabel = new SqueezeLabel );
|
|
|
|
hig->addRow( tr( "Hash:" ), myHashLabel = new SqueezeLabel );
|
|
|
|
hig->addRow( tr( "Privacy:" ), myPrivacyLabel = new SqueezeLabel );
|
|
|
|
hig->addRow( tr( "Origin:" ), myOriginLabel = new SqueezeLabel );
|
|
|
|
hig->addRow( tr( "Comment:" ), myCommentBrowser = new QTextBrowser );
|
|
|
|
const int h = QFontMetrics(myCommentBrowser->font()).lineSpacing() * 4;
|
|
|
|
myCommentBrowser->setMinimumHeight( h );
|
|
|
|
myCommentBrowser->setMaximumHeight( h );
|
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
hig->finish( );
|
|
|
|
|
|
|
|
return hig;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
|
|
|
void
|
2009-04-12 21:15:35 +00:00
|
|
|
Details :: onHonorsSessionLimitsToggled( bool val )
|
|
|
|
{
|
2009-04-18 23:18:28 +00:00
|
|
|
mySession.torrentSet( myIds, "honorsSessionLimits", val );
|
2009-04-12 21:15:35 +00:00
|
|
|
}
|
|
|
|
void
|
|
|
|
Details :: onDownloadLimitedToggled( bool val )
|
|
|
|
{
|
2009-04-18 23:18:28 +00:00
|
|
|
mySession.torrentSet( myIds, "downloadLimited", val );
|
2009-04-12 21:15:35 +00:00
|
|
|
}
|
|
|
|
void
|
|
|
|
Details :: onDownloadLimitChanged( int val )
|
|
|
|
{
|
2009-04-18 23:18:28 +00:00
|
|
|
mySession.torrentSet( myIds, "downloadLimit", val );
|
2009-04-12 21:15:35 +00:00
|
|
|
}
|
|
|
|
void
|
|
|
|
Details :: onUploadLimitedToggled( bool val )
|
|
|
|
{
|
2009-04-18 23:18:28 +00:00
|
|
|
mySession.torrentSet( myIds, "uploadLimited", val );
|
2009-04-12 21:15:35 +00:00
|
|
|
}
|
|
|
|
void
|
|
|
|
Details :: onUploadLimitChanged( int val )
|
|
|
|
{
|
2009-04-18 23:18:28 +00:00
|
|
|
mySession.torrentSet( myIds, "uploadLimit", val );
|
2009-04-12 21:15:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define RATIO_KEY "seedRatioMode"
|
|
|
|
|
|
|
|
void
|
|
|
|
Details :: onSeedUntilChanged( bool b )
|
|
|
|
{
|
|
|
|
if( b )
|
2009-04-18 23:18:28 +00:00
|
|
|
mySession.torrentSet( myIds, RATIO_KEY, sender()->property(RATIO_KEY).toInt() );
|
2009-04-12 21:15:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Details :: onSeedRatioLimitChanged( double val )
|
|
|
|
{
|
2009-04-19 02:48:55 +00:00
|
|
|
QSet<int> ids;
|
|
|
|
|
|
|
|
foreach( int id, myIds ) {
|
|
|
|
const Torrent * tor = myModel.getTorrentFromId( id );
|
|
|
|
if( tor && tor->seedRatioLimit( ) )
|
|
|
|
ids.insert( id );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !ids.empty( ) )
|
|
|
|
mySession.torrentSet( ids, "seedRatioLimit", val );
|
2009-04-12 21:15:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Details :: onMaxPeersChanged( int val )
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2009-04-18 23:18:28 +00:00
|
|
|
mySession.torrentSet( myIds, "peer-limit", val );
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Details :: onBandwidthPriorityChanged( int index )
|
|
|
|
{
|
|
|
|
if( index != -1 )
|
|
|
|
{
|
|
|
|
const int priority = myBandwidthPriorityCombo->itemData(index).toInt( );
|
|
|
|
mySession.torrentSet( myIds, "bandwidthPriority", priority );
|
|
|
|
}
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QWidget *
|
|
|
|
Details :: createOptionsTab( )
|
|
|
|
{
|
|
|
|
//QWidget * l;
|
|
|
|
QSpinBox * s;
|
|
|
|
QCheckBox * c;
|
2009-04-18 23:18:28 +00:00
|
|
|
QComboBox * m;
|
2009-04-09 18:55:47 +00:00
|
|
|
QHBoxLayout * h;
|
|
|
|
QRadioButton * r;
|
|
|
|
QDoubleSpinBox * ds;
|
|
|
|
|
|
|
|
HIG * hig = new HIG( this );
|
2009-04-18 23:18:28 +00:00
|
|
|
hig->addSectionTitle( tr( "Speed" ) );
|
2009-04-09 18:55:47 +00:00
|
|
|
|
|
|
|
c = new QCheckBox( tr( "Honor global &limits" ) );
|
|
|
|
mySessionLimitCheck = c;
|
|
|
|
hig->addWideControl( c );
|
2009-04-18 23:18:28 +00:00
|
|
|
connect( c, SIGNAL(clicked(bool)), this, SLOT(onHonorsSessionLimitsToggled(bool)) );
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2009-06-23 04:49:00 +00:00
|
|
|
c = new QCheckBox( tr( "Limit &download speed (KB/s):" ) );
|
2009-04-09 18:55:47 +00:00
|
|
|
mySingleDownCheck = c;
|
|
|
|
s = new QSpinBox( );
|
|
|
|
mySingleDownSpin = s;
|
|
|
|
s->setRange( 0, INT_MAX );
|
|
|
|
hig->addRow( c, s );
|
|
|
|
enableWhenChecked( c, s );
|
2009-04-18 23:18:28 +00:00
|
|
|
connect( c, SIGNAL(clicked(bool)), this, SLOT(onDownloadLimitedToggled(bool)) );
|
2009-04-12 21:15:35 +00:00
|
|
|
connect( s, SIGNAL(valueChanged(int)), this, SLOT(onDownloadLimitChanged(int)));
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2009-06-23 04:49:00 +00:00
|
|
|
c = new QCheckBox( tr( "Limit &upload speed (KB/s):" ) );
|
2009-04-09 18:55:47 +00:00
|
|
|
mySingleUpCheck = c;
|
|
|
|
s = new QSpinBox( );
|
|
|
|
mySingleUpSpin = s;
|
|
|
|
s->setRange( 0, INT_MAX );
|
|
|
|
hig->addRow( c, s );
|
|
|
|
enableWhenChecked( c, s );
|
2009-04-18 23:18:28 +00:00
|
|
|
connect( c, SIGNAL(clicked(bool)), this, SLOT(onUploadLimitedToggled(bool)) );
|
2009-04-12 21:15:35 +00:00
|
|
|
connect( s, SIGNAL(valueChanged(int)), this, SLOT(onUploadLimitChanged(int)));
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2009-04-18 23:18:28 +00:00
|
|
|
m = new QComboBox;
|
|
|
|
m->addItem( tr( "High" ), TR_PRI_HIGH );
|
2009-06-29 06:49:35 +00:00
|
|
|
m->addItem( tr( "Normal" ), TR_PRI_NORMAL );
|
|
|
|
m->addItem( tr( "Low" ), TR_PRI_LOW );
|
2009-04-18 23:18:28 +00:00
|
|
|
connect( m, SIGNAL(currentIndexChanged(int)), this, SLOT(onBandwidthPriorityChanged(int)));
|
2009-06-23 00:24:37 +00:00
|
|
|
hig->addRow( tr( "Torrent &priority:" ), m );
|
2009-04-18 23:18:28 +00:00
|
|
|
myBandwidthPriorityCombo = m;
|
|
|
|
|
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
hig->addSectionDivider( );
|
|
|
|
hig->addSectionTitle( tr( "Seed-Until Ratio" ) );
|
|
|
|
|
2009-06-23 03:40:32 +00:00
|
|
|
r = new QRadioButton( tr( "Use &global settings" ) );
|
2009-04-12 21:15:35 +00:00
|
|
|
r->setProperty( RATIO_KEY, TR_RATIOLIMIT_GLOBAL );
|
2009-04-18 23:18:28 +00:00
|
|
|
connect( r, SIGNAL(clicked(bool)), this, SLOT(onSeedUntilChanged(bool)));
|
2009-04-09 18:55:47 +00:00
|
|
|
mySeedGlobalRadio = r;
|
|
|
|
hig->addWideControl( r );
|
|
|
|
|
|
|
|
r = new QRadioButton( tr( "Seed ®ardless of ratio" ) );
|
2009-04-12 21:15:35 +00:00
|
|
|
r->setProperty( RATIO_KEY, TR_RATIOLIMIT_UNLIMITED );
|
2009-04-18 23:18:28 +00:00
|
|
|
connect( r, SIGNAL(clicked(bool)), this, SLOT(onSeedUntilChanged(bool)));
|
2009-04-09 18:55:47 +00:00
|
|
|
mySeedForeverRadio = r;
|
|
|
|
hig->addWideControl( r );
|
|
|
|
|
|
|
|
h = new QHBoxLayout( );
|
|
|
|
h->setSpacing( HIG :: PAD );
|
2009-06-23 00:24:37 +00:00
|
|
|
r = new QRadioButton( tr( "&Seed torrent until its ratio reaches:" ) );
|
2009-04-12 21:15:35 +00:00
|
|
|
r->setProperty( RATIO_KEY, TR_RATIOLIMIT_SINGLE );
|
2009-04-18 23:18:28 +00:00
|
|
|
connect( r, SIGNAL(clicked(bool)), this, SLOT(onSeedUntilChanged(bool)));
|
2009-04-09 18:55:47 +00:00
|
|
|
mySeedCustomRadio = r;
|
|
|
|
h->addWidget( r );
|
|
|
|
ds = new QDoubleSpinBox( );
|
|
|
|
ds->setRange( 0.5, INT_MAX );
|
2009-04-12 21:15:35 +00:00
|
|
|
connect( ds, SIGNAL(valueChanged(double)), this, SLOT(onSeedRatioLimitChanged(double)));
|
2009-04-09 18:55:47 +00:00
|
|
|
mySeedCustomSpin = ds;
|
|
|
|
h->addWidget( ds );
|
|
|
|
hig->addWideControl( h );
|
|
|
|
|
|
|
|
hig->addSectionDivider( );
|
|
|
|
hig->addSectionTitle( tr( "Peer Connections" ) );
|
|
|
|
|
|
|
|
s = new QSpinBox( );
|
|
|
|
s->setRange( 1, 300 );
|
2009-04-12 21:15:35 +00:00
|
|
|
connect( s, SIGNAL(valueChanged(int)), this, SLOT(onMaxPeersChanged(int)));
|
2009-04-09 18:55:47 +00:00
|
|
|
myPeerLimitSpin = s;
|
2009-06-23 04:49:00 +00:00
|
|
|
hig->addRow( tr( "&Maximum peers:" ), s );
|
2009-04-09 18:55:47 +00:00
|
|
|
|
|
|
|
hig->finish( );
|
|
|
|
|
|
|
|
return hig;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
|
|
|
QWidget *
|
|
|
|
Details :: createTrackerTab( )
|
|
|
|
{
|
|
|
|
HIG * hig = new HIG( );
|
|
|
|
|
|
|
|
hig->addSectionTitle( tr( "Scrape" ) );
|
|
|
|
hig->addRow( tr( "Last scrape at:" ), myScrapeTimePrevLabel = new SqueezeLabel );
|
|
|
|
hig->addRow( tr( "Tracker responded:" ), myScrapeResponseLabel = new SqueezeLabel );
|
|
|
|
hig->addRow( tr( "Next scrape in:" ), myScrapeTimeNextLabel = new SqueezeLabel );
|
|
|
|
hig->addSectionDivider( );
|
|
|
|
hig->addSectionTitle( tr( "Announce" ) );
|
|
|
|
hig->addRow( tr( "Tracker:" ), myTrackerLabel = new SqueezeLabel );
|
|
|
|
hig->addRow( tr( "Last announce at:" ), myAnnounceTimePrevLabel = new SqueezeLabel );
|
|
|
|
hig->addRow( tr( "Tracker responded:" ), myAnnounceResponseLabel = new SqueezeLabel );
|
|
|
|
hig->addRow( tr( "Next announce in:" ), myAnnounceTimeNextLabel = new SqueezeLabel );
|
|
|
|
hig->addRow( tr( "Manual announce allowed in:" ), myAnnounceManualLabel = new SqueezeLabel );
|
|
|
|
hig->finish( );
|
|
|
|
|
|
|
|
myTrackerLabel->setScaledContents( true );
|
|
|
|
|
|
|
|
return hig;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
|
|
|
QWidget *
|
|
|
|
Details :: createPeersTab( )
|
|
|
|
{
|
|
|
|
QWidget * top = new QWidget;
|
|
|
|
QVBoxLayout * v = new QVBoxLayout( top );
|
|
|
|
v->setSpacing( HIG :: PAD_BIG );
|
|
|
|
v->setContentsMargins( HIG::PAD_BIG, HIG::PAD_BIG, HIG::PAD_BIG, HIG::PAD_BIG );
|
|
|
|
|
|
|
|
QStringList headers;
|
|
|
|
headers << QString() << tr("Up") << tr("Down") << tr("%") << tr("Status") << tr("Address") << tr("Client");
|
|
|
|
myPeerTree = new QTreeWidget;
|
|
|
|
myPeerTree->setUniformRowHeights( true );
|
|
|
|
myPeerTree->setHeaderLabels( headers );
|
|
|
|
myPeerTree->setColumnWidth( 0, 20 );
|
|
|
|
myPeerTree->setSortingEnabled( true );
|
|
|
|
myPeerTree->setRootIsDecorated( false );
|
|
|
|
myPeerTree->setTextElideMode( Qt::ElideRight );
|
|
|
|
v->addWidget( myPeerTree, 1 );
|
|
|
|
|
|
|
|
const QFontMetrics m( font( ) );
|
|
|
|
QSize size = m.size( 0, "1024 MB/s" );
|
|
|
|
myPeerTree->setColumnWidth( COL_UP, size.width( ) );
|
|
|
|
myPeerTree->setColumnWidth( COL_DOWN, size.width( ) );
|
|
|
|
size = m.size( 0, " 100% " );
|
|
|
|
myPeerTree->setColumnWidth( COL_PERCENT, size.width( ) );
|
|
|
|
size = m.size( 0, "ODUK?EXI" );
|
|
|
|
myPeerTree->setColumnWidth( COL_STATUS, size.width( ) );
|
|
|
|
size = m.size( 0, "888.888.888.888" );
|
|
|
|
myPeerTree->setColumnWidth( COL_ADDRESS, size.width( ) );
|
|
|
|
size = m.size( 0, "Some BitTorrent Client" );
|
|
|
|
myPeerTree->setColumnWidth( COL_CLIENT, size.width( ) );
|
|
|
|
myPeerTree->setAlternatingRowColors( true );
|
|
|
|
|
|
|
|
return top;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
|
|
|
QWidget *
|
|
|
|
Details :: createFilesTab( )
|
|
|
|
{
|
|
|
|
myFileTreeView = new FileTreeView( );
|
|
|
|
|
|
|
|
connect( myFileTreeView, SIGNAL( priorityChanged(const QSet<int>&, int)),
|
|
|
|
this, SLOT( onFilePriorityChanged(const QSet<int>&, int)));
|
|
|
|
|
|
|
|
connect( myFileTreeView, SIGNAL( wantedChanged(const QSet<int>&, bool)),
|
|
|
|
this, SLOT( onFileWantedChanged(const QSet<int>&, bool)));
|
|
|
|
|
|
|
|
return myFileTreeView;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Details :: onFilePriorityChanged( const QSet<int>& indices, int priority )
|
|
|
|
{
|
|
|
|
QString key;
|
|
|
|
switch( priority ) {
|
|
|
|
case TR_PRI_LOW: key = "priority-low"; break;
|
|
|
|
case TR_PRI_HIGH: key = "priority-high"; break;
|
|
|
|
default: key = "priority-normal"; break;
|
|
|
|
}
|
2009-04-18 23:18:28 +00:00
|
|
|
mySession.torrentSet( myIds, key, indices.toList( ) );
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Details :: onFileWantedChanged( const QSet<int>& indices, bool wanted )
|
|
|
|
{
|
|
|
|
QString key( wanted ? "files-wanted" : "files-unwanted" );
|
2009-04-18 23:18:28 +00:00
|
|
|
mySession.torrentSet( myIds, key, indices.toList( ) );
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|