2009-04-09 18:55:47 +00:00
|
|
|
/*
|
2010-01-04 21:00:47 +00:00
|
|
|
* This file Copyright (C) 2009-2010 Mnemosyne LLC
|
2009-04-09 18:55:47 +00:00
|
|
|
*
|
|
|
|
* 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-10-06 00:27:26 +00:00
|
|
|
#include <QDateTime>
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QDialogButtonBox>
|
|
|
|
#include <QDoubleSpinBox>
|
2009-10-06 00:27:26 +00:00
|
|
|
#include <QEvent>
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QFont>
|
|
|
|
#include <QFontMetrics>
|
|
|
|
#include <QHBoxLayout>
|
2009-10-06 00:27:26 +00:00
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QHeaderView>
|
2010-06-30 05:55:46 +00:00
|
|
|
#include <QInputDialog>
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QLabel>
|
2010-06-30 05:55:46 +00:00
|
|
|
#include <QMessageBox>
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QPushButton>
|
|
|
|
#include <QRadioButton>
|
2009-10-06 00:27:26 +00:00
|
|
|
#include <QResizeEvent>
|
|
|
|
#include <QSpinBox>
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QStyle>
|
|
|
|
#include <QTabWidget>
|
|
|
|
#include <QTextBrowser>
|
2009-10-06 00:27:26 +00:00
|
|
|
#include <QTreeView>
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QTreeWidget>
|
|
|
|
#include <QTreeWidgetItem>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
2009-04-13 18:21:22 +00:00
|
|
|
#include <libtransmission/transmission.h>
|
2010-06-30 05:55:46 +00:00
|
|
|
#include <libtransmission/bencode.h>
|
2009-04-13 18:21:22 +00:00
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
#include "details.h"
|
|
|
|
#include "file-tree.h"
|
2010-07-03 01:10:36 +00:00
|
|
|
#include "formatter.h"
|
2009-04-09 18:55:47 +00:00
|
|
|
#include "hig.h"
|
2010-04-03 14:23:29 +00:00
|
|
|
#include "prefs.h"
|
2010-06-30 05:55:46 +00:00
|
|
|
#include "qticonloader.h"
|
2009-04-09 18:55:47 +00:00
|
|
|
#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
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2010-06-30 05:55:46 +00:00
|
|
|
QIcon
|
|
|
|
Details :: getStockIcon( const QString& freedesktop_name, int fallback )
|
|
|
|
{
|
|
|
|
QIcon fallbackIcon;
|
|
|
|
|
|
|
|
if( fallback > 0 )
|
|
|
|
fallbackIcon = style()->standardIcon( QStyle::StandardPixmap( fallback ), 0, this );
|
|
|
|
|
|
|
|
return QtIconLoader::icon( freedesktop_name, fallbackIcon );
|
|
|
|
}
|
|
|
|
|
2010-04-03 14:23:29 +00:00
|
|
|
Details :: Details( Session& session, Prefs& prefs, TorrentModel& model, QWidget * parent ):
|
2009-04-09 18:55:47 +00:00
|
|
|
QDialog( parent, Qt::Dialog ),
|
|
|
|
mySession( session ),
|
2010-04-03 14:23:29 +00:00
|
|
|
myPrefs( prefs ),
|
2009-04-18 23:18:28 +00:00
|
|
|
myModel( model ),
|
2010-05-05 09:41:14 +00:00
|
|
|
myChangedTorrents( false ),
|
2009-04-18 23:18:28 +00:00
|
|
|
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 );
|
2010-05-06 14:16:17 +00:00
|
|
|
connect( buttons, SIGNAL(rejected()), this, SLOT(close()));
|
2009-04-09 18:55:47 +00:00
|
|
|
layout->addWidget( buttons );
|
2010-05-06 14:16:17 +00:00
|
|
|
QWidget::setAttribute( Qt::WA_DeleteOnClose, true );
|
2009-04-09 18:55:47 +00:00
|
|
|
|
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 );
|
|
|
|
}
|
2010-01-05 23:47:50 +00:00
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
Details :: ~Details( )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-04-18 23:18:28 +00:00
|
|
|
void
|
|
|
|
Details :: setIds( const QSet<int>& ids )
|
|
|
|
{
|
|
|
|
if( ids == myIds )
|
|
|
|
return;
|
|
|
|
|
2010-05-05 09:41:14 +00:00
|
|
|
myChangedTorrents = true;
|
|
|
|
|
2009-04-18 23:18:28 +00:00
|
|
|
// 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 );
|
2010-01-05 23:47:50 +00:00
|
|
|
|
2009-04-18 23:18:28 +00:00
|
|
|
onTimer( );
|
|
|
|
}
|
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2010-04-03 14:23:29 +00:00
|
|
|
QString
|
|
|
|
Details :: timeToStringRounded( int seconds )
|
|
|
|
{
|
|
|
|
if( seconds > 60 ) seconds -= ( seconds % 60 );
|
2010-07-03 01:10:36 +00:00
|
|
|
return Formatter::timeToString ( seconds );
|
2010-04-03 14:23:29 +00:00
|
|
|
}
|
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
void
|
|
|
|
Details :: onTimer( )
|
|
|
|
{
|
2009-04-18 23:18:28 +00:00
|
|
|
if( !myIds.empty( ) )
|
2010-06-16 03:02:17 +00:00
|
|
|
{
|
|
|
|
QSet<int> infos;
|
|
|
|
foreach( int id, myIds ) {
|
|
|
|
const Torrent * tor = myModel.getTorrentFromId( id );
|
|
|
|
if( tor->isMagnet() )
|
|
|
|
infos.insert( tor->id() );
|
|
|
|
}
|
|
|
|
if( !infos.isEmpty() )
|
|
|
|
mySession.initTorrents( infos );
|
2009-04-18 23:18:28 +00:00
|
|
|
mySession.refreshExtraStats( myIds );
|
2010-06-16 03:02:17 +00:00
|
|
|
}
|
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( )
|
|
|
|
{
|
|
|
|
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
|
|
|
///
|
2010-01-05 23:47:50 +00:00
|
|
|
/// activity tab
|
2009-04-18 23:18:28 +00:00
|
|
|
///
|
|
|
|
|
|
|
|
// myStateLabel
|
|
|
|
if( torrents.empty( ) )
|
2009-04-26 15:41:04 +00:00
|
|
|
string = none;
|
2009-04-18 23:18:28 +00:00
|
|
|
else {
|
2010-04-06 04:54:51 +00:00
|
|
|
bool isMixed = false;
|
|
|
|
bool allPaused = true;
|
|
|
|
bool allFinished = true;
|
2010-04-06 03:10:48 +00:00
|
|
|
const tr_torrent_activity activity = torrents[0]->getActivity( );
|
|
|
|
foreach( const Torrent * t, torrents ) {
|
2010-04-06 04:54:51 +00:00
|
|
|
if( activity != t->getActivity( ) )
|
|
|
|
isMixed = true;
|
|
|
|
if( activity != TR_STATUS_STOPPED )
|
|
|
|
allPaused = allFinished = false;
|
|
|
|
if( !t->isFinished( ) )
|
|
|
|
allFinished = false;
|
2009-04-26 15:41:04 +00:00
|
|
|
}
|
2010-04-06 04:54:51 +00:00
|
|
|
if( isMixed )
|
|
|
|
string = mixed;
|
|
|
|
else if( allFinished )
|
|
|
|
string = tr( "Finished" );
|
|
|
|
else if( allPaused )
|
|
|
|
string = tr( "Paused" );
|
|
|
|
else
|
|
|
|
string = torrents[0]->activityString( );
|
2009-04-18 23:18:28 +00:00
|
|
|
}
|
|
|
|
myStateLabel->setText( string );
|
2010-04-06 03:15:42 +00:00
|
|
|
const QString stateString = string;
|
2009-04-18 23:18:28 +00:00
|
|
|
|
|
|
|
// myHaveLabel
|
2009-06-23 00:24:37 +00:00
|
|
|
double sizeWhenDone = 0;
|
|
|
|
double leftUntilDone = 0;
|
2010-02-02 05:34:26 +00:00
|
|
|
double available = 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;
|
2010-06-03 23:39:31 +00:00
|
|
|
if( torrents.empty( ) )
|
2009-06-23 00:24:37 +00:00
|
|
|
string = none;
|
|
|
|
else {
|
2010-06-03 23:39:31 +00:00
|
|
|
foreach( const Torrent * t, torrents ) {
|
|
|
|
if( t->hasMetadata( ) ) {
|
|
|
|
haveTotal += t->haveTotal( );
|
|
|
|
haveUnverified += t->haveUnverified( );
|
|
|
|
const uint64_t v = t->haveVerified( );
|
|
|
|
haveVerified += v;
|
|
|
|
verifiedPieces += v / t->pieceSize( );
|
|
|
|
sizeWhenDone += t->sizeWhenDone( );
|
|
|
|
leftUntilDone += t->leftUntilDone( );
|
|
|
|
available += t->sizeWhenDone() - t->leftUntilDone() + t->desiredAvailable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( !haveVerified && !haveUnverified )
|
|
|
|
string = none;
|
|
|
|
else {
|
|
|
|
const double d = 100.0 * ( sizeWhenDone ? ( sizeWhenDone - leftUntilDone ) / sizeWhenDone : 1 );
|
2010-07-03 01:10:36 +00:00
|
|
|
QString pct = Formatter::percentToString( d );
|
2010-06-03 23:39:31 +00:00
|
|
|
if( !haveUnverified )
|
|
|
|
string = tr( "%1 (%2%)" )
|
2010-07-03 01:10:36 +00:00
|
|
|
.arg( Formatter::sizeToString( haveVerified + haveUnverified ) )
|
2010-06-03 23:39:31 +00:00
|
|
|
.arg( pct );
|
|
|
|
else
|
|
|
|
string = tr( "%1 (%2%); %3 Unverified" )
|
2010-07-03 01:10:36 +00:00
|
|
|
.arg( Formatter::sizeToString( haveVerified + haveUnverified ) )
|
2010-06-03 23:39:31 +00:00
|
|
|
.arg( pct )
|
2010-07-03 01:10:36 +00:00
|
|
|
.arg( Formatter::sizeToString( haveUnverified ) );
|
2010-06-03 23:39:31 +00:00
|
|
|
}
|
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
|
|
|
|
2010-02-02 05:34:26 +00:00
|
|
|
// myAvailabilityLabel
|
2010-06-22 22:30:58 +00:00
|
|
|
if( torrents.empty( ) )
|
2010-02-02 05:34:26 +00:00
|
|
|
string = none;
|
2010-06-22 22:30:58 +00:00
|
|
|
else {
|
|
|
|
if( sizeWhenDone == 0 )
|
|
|
|
string = none;
|
|
|
|
else
|
2010-07-03 01:10:36 +00:00
|
|
|
string = QString( "%1%" ).arg( Formatter::percentToString( ( 100.0 * available ) / sizeWhenDone ) );
|
2010-06-22 22:30:58 +00:00
|
|
|
}
|
2010-02-02 05:34:26 +00:00
|
|
|
myAvailabilityLabel->setText( string );
|
|
|
|
|
2009-06-23 00:24:37 +00:00
|
|
|
// myDownloadedLabel
|
2010-06-03 23:39:31 +00:00
|
|
|
uint64_t d = 0, f = 0;
|
2009-06-23 00:24:37 +00:00
|
|
|
if( torrents.empty( ) )
|
|
|
|
string = none;
|
|
|
|
else {
|
|
|
|
foreach( const Torrent * t, torrents ) {
|
|
|
|
d += t->downloadedEver( );
|
|
|
|
f += t->failedEver( );
|
|
|
|
}
|
2010-07-03 01:10:36 +00:00
|
|
|
const QString dstr = Formatter::sizeToString( d );
|
|
|
|
const QString fstr = Formatter::sizeToString( f );
|
2009-06-23 00:24:37 +00:00
|
|
|
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
|
|
|
|
2010-06-03 23:39:31 +00:00
|
|
|
uint64_t u = 0;
|
|
|
|
if( torrents.empty( ) )
|
|
|
|
string = none;
|
|
|
|
else {
|
|
|
|
foreach( const Torrent * t, torrents ) u += t->uploadedEver( );
|
2010-07-03 01:10:36 +00:00
|
|
|
string = QString( Formatter::sizeToString( u ) );
|
2010-06-03 23:39:31 +00:00
|
|
|
}
|
|
|
|
myUploadedLabel->setText( string );
|
2009-04-18 23:18:28 +00:00
|
|
|
|
2010-06-03 23:39:31 +00:00
|
|
|
if( torrents.empty( ) )
|
|
|
|
string = none;
|
2010-07-06 15:52:32 +00:00
|
|
|
else if( torrents.count() == 1 )
|
2010-07-03 01:10:36 +00:00
|
|
|
string = Formatter::ratioToString( torrents.first()->ratio() );
|
2010-06-03 23:39:31 +00:00
|
|
|
else {
|
|
|
|
bool isMixed = false;
|
|
|
|
int ratioType = torrents.first()->ratio();
|
|
|
|
if( ratioType > 0 ) ratioType = 0;
|
|
|
|
foreach( const Torrent *t, torrents )
|
|
|
|
{
|
|
|
|
if( ratioType != ( t->ratio() >= 0 ? 0 : t->ratio() ) )
|
|
|
|
{
|
|
|
|
isMixed = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( isMixed )
|
|
|
|
string = mixed;
|
|
|
|
else if( ratioType < 0 )
|
2010-07-03 01:10:36 +00:00
|
|
|
string = Formatter::ratioToString( ratioType );
|
2010-06-03 23:39:31 +00:00
|
|
|
else
|
2010-07-03 01:10:36 +00:00
|
|
|
string = Formatter::ratioToString( (double)u / d );
|
2010-06-03 23:39:31 +00:00
|
|
|
}
|
|
|
|
myRatioLabel->setText( string );
|
2009-04-18 23:18:28 +00:00
|
|
|
|
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 )
|
2010-04-06 03:15:42 +00:00
|
|
|
string = stateString; // paused || finished
|
2009-06-23 00:24:37 +00:00
|
|
|
else if( baseline.isNull( ) )
|
|
|
|
string = mixed;
|
|
|
|
else
|
2010-07-03 01:10:36 +00:00
|
|
|
string = Formatter::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-10-10 20:42:23 +00:00
|
|
|
// myETALabel
|
|
|
|
string.clear( );
|
|
|
|
if( torrents.empty( ) )
|
|
|
|
string = none;
|
|
|
|
else {
|
|
|
|
int baseline = torrents[0]->getETA( );
|
|
|
|
foreach( const Torrent * t, torrents ) {
|
|
|
|
if( baseline != t->getETA( ) ) {
|
|
|
|
string = mixed;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( string.isEmpty( ) ) {
|
|
|
|
if( baseline < 0 )
|
|
|
|
string = tr( "Unknown" );
|
|
|
|
else
|
2010-07-03 01:10:36 +00:00
|
|
|
string = Formatter::timeToString( baseline );
|
2010-01-05 23:47:50 +00:00
|
|
|
}
|
2009-10-10 20:42:23 +00:00
|
|
|
}
|
|
|
|
myETALabel->setText( string );
|
|
|
|
|
|
|
|
|
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
|
2010-07-03 01:10:36 +00:00
|
|
|
string = tr( "%1 ago" ).arg( Formatter::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 )
|
2010-07-03 01:10:36 +00:00
|
|
|
.arg( Formatter::sizeToString( size ) )
|
|
|
|
.arg( Formatter::memToString( pieceSize ) );
|
2009-04-26 15:41:04 +00:00
|
|
|
else
|
2009-06-23 00:24:37 +00:00
|
|
|
string = tr( "%1 (%Ln pieces)", "", pieces )
|
2010-07-03 01:10:36 +00:00
|
|
|
.arg( Formatter::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 );
|
2010-06-03 23:22:14 +00:00
|
|
|
myCommentBrowser->setMaximumHeight( QWIDGETSIZE_MAX );
|
2009-04-18 23:18:28 +00:00
|
|
|
|
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 );
|
2010-01-05 23:47:50 +00:00
|
|
|
|
2009-06-23 00:24:37 +00:00
|
|
|
// 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
|
|
|
|
///
|
|
|
|
|
2010-05-05 09:41:14 +00:00
|
|
|
if( myChangedTorrents && !torrents.empty( ) )
|
2009-04-18 23:18:28 +00:00
|
|
|
{
|
|
|
|
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 );
|
2010-07-07 00:30:42 +00:00
|
|
|
mySingleDownSpin->setValue( tor->downloadLimit().KBps() );
|
2009-04-18 23:18:28 +00:00
|
|
|
mySingleDownSpin->blockSignals( false );
|
|
|
|
|
|
|
|
mySingleUpSpin->blockSignals( true );
|
2010-07-07 00:30:42 +00:00
|
|
|
mySingleUpSpin->setValue( 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
|
|
|
//
|
2010-06-30 05:55:46 +00:00
|
|
|
QMap<QString,QTreeWidgetItem*> trackerTiers;
|
|
|
|
QMap<QString,QTreeWidgetItem*> trackerItems;
|
2009-04-09 18:55:47 +00:00
|
|
|
const time_t now( time( 0 ) );
|
2010-04-03 14:23:29 +00:00
|
|
|
const bool showScrape = myPrefs.getBool( Prefs::SHOW_TRACKER_SCRAPES );
|
|
|
|
foreach( const Torrent * t, torrents )
|
|
|
|
{
|
|
|
|
const QString idStr( QString::number( t->id( ) ) );
|
2010-06-30 05:55:46 +00:00
|
|
|
const TrackerStatsList trackerStats = t->trackerStats( );
|
2009-04-26 15:41:04 +00:00
|
|
|
|
2010-04-03 14:23:29 +00:00
|
|
|
foreach( const TrackerStat& trackerStat, trackerStats )
|
|
|
|
{
|
2010-06-30 05:55:46 +00:00
|
|
|
QFont font;
|
2010-04-03 14:23:29 +00:00
|
|
|
QString str;
|
2010-06-30 05:55:46 +00:00
|
|
|
const QString tierKey( QString::number(trackerStat.tier) );
|
|
|
|
QTreeWidgetItem * tier = (QTreeWidgetItem*) myTrackerTiers.value( tierKey, 0 );
|
|
|
|
|
2010-07-03 19:34:36 +00:00
|
|
|
if( tier == 0 ) // check if has tier been created this pass
|
|
|
|
tier = (QTreeWidgetItem*) trackerTiers.value( tierKey, 0 );
|
|
|
|
|
2010-06-30 05:55:46 +00:00
|
|
|
if( tier == 0 ) // new tier
|
|
|
|
{
|
|
|
|
QFont tierFont;
|
|
|
|
tier = new QTreeWidgetItem( myTrackerTree );
|
|
|
|
myTrackerTree->addTopLevelItem( tier );
|
|
|
|
str = "Tier: " + QString::number( trackerStat.tier + 1 );
|
|
|
|
tier->setText( 0, str );
|
|
|
|
tierFont.setBold( true );
|
|
|
|
tier->setFont( 0, tierFont );
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString key( idStr + tierKey + ":" + QString::number( trackerStat.id ) );
|
|
|
|
QTreeWidgetItem * item = (QTreeWidgetItem*) myTrackerItems.value( key, 0 );
|
2009-04-26 15:41:04 +00:00
|
|
|
|
2010-04-03 14:23:29 +00:00
|
|
|
if( item == 0 ) // new tracker
|
|
|
|
{
|
2010-06-30 05:55:46 +00:00
|
|
|
item = new QTreeWidgetItem( tier );
|
|
|
|
tier->addChild( item );
|
|
|
|
if( tier->childCount() == 1 )
|
|
|
|
tier->setExpanded( true );
|
2010-04-03 14:23:29 +00:00
|
|
|
}
|
|
|
|
str = trackerStat.host;
|
2010-06-30 05:55:46 +00:00
|
|
|
|
|
|
|
if( trackerStat.isBackup )
|
2010-04-03 14:23:29 +00:00
|
|
|
{
|
2010-06-30 05:55:46 +00:00
|
|
|
font.setItalic( true );
|
|
|
|
if( showScrape )
|
|
|
|
{
|
|
|
|
str += "\n";
|
|
|
|
str += "Tracker will be used as a backup";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
font.setItalic( false );
|
2010-04-03 14:23:29 +00:00
|
|
|
if( trackerStat.hasAnnounced )
|
|
|
|
{
|
|
|
|
const QString tstr( timeToStringRounded( now - trackerStat.lastAnnounceTime ) );
|
|
|
|
str += "\n";
|
|
|
|
if( trackerStat.lastAnnounceSucceeded )
|
|
|
|
{
|
|
|
|
str += tr( "Got a list of %1 peers %2 ago" )
|
|
|
|
.arg( trackerStat.lastAnnouncePeerCount )
|
|
|
|
.arg( tstr );
|
|
|
|
}
|
|
|
|
else if( trackerStat.lastAnnounceTimedOut )
|
|
|
|
{
|
|
|
|
str += tr( "Peer list request timed out %1 ago; will retry" )
|
|
|
|
.arg( tstr );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
str += tr( "Got an error %1 ago" )
|
|
|
|
.arg( tstr );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch( trackerStat.announceState )
|
|
|
|
{
|
|
|
|
case TR_TRACKER_INACTIVE:
|
|
|
|
if( trackerStat.hasAnnounced )
|
|
|
|
{
|
|
|
|
str += "\n";
|
|
|
|
str += tr( "No updates scheduled" );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TR_TRACKER_WAITING:
|
|
|
|
{
|
|
|
|
const QString tstr( timeToStringRounded( trackerStat.nextAnnounceTime - now ) );
|
|
|
|
str += "\n";
|
|
|
|
str += tr( "Asking for more peers in %1" )
|
|
|
|
.arg( tstr );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TR_TRACKER_QUEUED:
|
|
|
|
str += "\n";
|
|
|
|
str += tr( "Queued to ask for more peers" );
|
|
|
|
break;
|
|
|
|
case TR_TRACKER_ACTIVE:
|
|
|
|
{
|
|
|
|
const QString tstr( timeToStringRounded( now - trackerStat.lastAnnounceStartTime ) );
|
|
|
|
str += "\n";
|
|
|
|
str += tr( "Asking for more peers now... %1" )
|
|
|
|
.arg( tstr );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if( showScrape )
|
|
|
|
{
|
|
|
|
if( trackerStat.hasScraped )
|
|
|
|
{
|
|
|
|
const QString tstr( timeToStringRounded( now - trackerStat.lastScrapeTime ) );
|
|
|
|
str += "\n";
|
|
|
|
if( trackerStat.lastScrapeSucceeded )
|
|
|
|
{
|
|
|
|
str += tr( "Tracker had %1 seeders and %2 leechers %3 ago" )
|
|
|
|
.arg( trackerStat.seederCount )
|
|
|
|
.arg( trackerStat.leecherCount )
|
|
|
|
.arg( tstr );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
str += tr( "Got a scrape error %1 ago" )
|
|
|
|
.arg( tstr );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch( trackerStat.scrapeState )
|
|
|
|
{
|
|
|
|
case TR_TRACKER_INACTIVE:
|
|
|
|
break;
|
|
|
|
case TR_TRACKER_WAITING:
|
|
|
|
{
|
|
|
|
const QString tstr( timeToStringRounded( trackerStat.nextScrapeTime - now ) );
|
|
|
|
str += "\n";
|
|
|
|
str += tr( "Asking for peer counts in %1" )
|
|
|
|
.arg( tstr );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TR_TRACKER_QUEUED:
|
|
|
|
str += "\n";
|
|
|
|
str += tr( "Queued to ask for peer counts" );
|
|
|
|
break;
|
|
|
|
case TR_TRACKER_ACTIVE:
|
|
|
|
{
|
|
|
|
const QString tstr( timeToStringRounded( now - trackerStat.lastScrapeStartTime ) );
|
|
|
|
str += "\n";
|
|
|
|
str += tr( "Asking for peer counts now... %1" )
|
|
|
|
.arg( tstr );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
item->setText( 0, str );
|
2010-06-30 05:55:46 +00:00
|
|
|
item->setFont( 0, font );
|
|
|
|
item->setData( 0, TRACKERID, trackerStat.id );
|
|
|
|
item->setData( 0, TRACKERURL, trackerStat.announce );
|
|
|
|
item->setData( 0, TRACKERTIER, trackerStat.tier );
|
|
|
|
item->setData( 0, TORRENTID, t->id() );
|
|
|
|
|
|
|
|
tier->setData( 0, TRACKERID, -1 );
|
|
|
|
tier->setData( 0, TRACKERURL, QString() );
|
|
|
|
tier->setData( 0, TRACKERTIER, trackerStat.tier );
|
|
|
|
tier->setData( 0, TORRENTID, torrents.count() > 1 ? -1 : t->id() );
|
|
|
|
|
|
|
|
trackerTiers.insert( tierKey, tier );
|
|
|
|
trackerItems.insert( key, item );
|
2009-04-26 15:41:04 +00:00
|
|
|
}
|
|
|
|
}
|
2010-06-30 05:55:46 +00:00
|
|
|
QList<QTreeWidgetItem*> tierList = trackerTiers.values();
|
|
|
|
QList<QTreeWidgetItem*> itemList = trackerItems.values();
|
|
|
|
for( int i = 0; i < myTrackerTree->topLevelItemCount(); ++i )
|
|
|
|
{
|
|
|
|
QTreeWidgetItem * tier = myTrackerTree->topLevelItem( i );
|
|
|
|
for( int j = 0; j < tier->childCount(); ++j )
|
|
|
|
{
|
|
|
|
if( !itemList.contains( tier->child( j ) ) ) // tracker has disappeared
|
|
|
|
delete tier->takeChild( j-- );
|
2009-04-26 15:41:04 +00:00
|
|
|
}
|
2010-06-30 05:55:46 +00:00
|
|
|
if( !tierList.contains( tier ) ) // tier has disappeared
|
|
|
|
delete myTrackerTree->takeTopLevelItem( i-- );
|
2009-04-26 15:41:04 +00:00
|
|
|
}
|
2010-06-30 05:55:46 +00:00
|
|
|
myTrackerTiers = trackerTiers;
|
|
|
|
myTrackerItems = trackerItems;
|
2009-04-18 23:18:28 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
/// 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
|
|
|
|
2010-06-26 17:48:27 +00:00
|
|
|
const QString code = peer.flagStr;
|
2009-05-04 02:58:05 +00:00
|
|
|
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;
|
2010-06-26 17:48:27 +00:00
|
|
|
case 'H': txt = tr( "Peer was discovered through DHT" ); break;
|
2009-05-04 02:58:05 +00:00
|
|
|
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
|
|
|
|
|
2010-07-03 01:10:36 +00:00
|
|
|
item->setText( COL_UP, peer.rateToPeer.isZero() ? "" : Formatter::speedToString( peer.rateToPeer ) );
|
|
|
|
item->setText( COL_DOWN, peer.rateToClient.isZero() ? "" : Formatter::speedToString( peer.rateToClient ) );
|
2010-06-22 22:30:58 +00:00
|
|
|
item->setText( COL_PERCENT, peer.progress > 0 ? QString( "%1%" ).arg( (int)( peer.progress * 100.0 ) ) : "" );
|
2009-05-04 02:58:05 +00:00
|
|
|
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 )
|
2010-05-05 09:41:14 +00:00
|
|
|
myFileTreeView->update( torrents[0]->files( ) , myChangedTorrents );
|
2010-01-05 23:47:50 +00:00
|
|
|
else
|
2009-04-18 23:18:28 +00:00
|
|
|
myFileTreeView->clear( );
|
|
|
|
|
2010-05-05 09:41:14 +00:00
|
|
|
myChangedTorrents = false;
|
2009-04-18 23:18:28 +00:00
|
|
|
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 );
|
2010-02-02 05:34:26 +00:00
|
|
|
hig->addRow( tr( "Availability:" ), myAvailabilityLabel = new SqueezeLabel );
|
2009-04-09 18:55:47 +00:00
|
|
|
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 );
|
2009-10-10 20:42:23 +00:00
|
|
|
hig->addRow( tr( "Remaining time:" ), myETALabel = new SqueezeLabel );
|
2009-06-23 00:24:37 +00:00
|
|
|
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 );
|
2010-06-18 07:34:37 +00:00
|
|
|
myOriginLabel->setMinimumWidth( 325 ); // stop long origin strings from resizing the widgit
|
2009-06-23 00:24:37 +00:00
|
|
|
hig->addRow( tr( "Comment:" ), myCommentBrowser = new QTextBrowser );
|
|
|
|
const int h = QFontMetrics(myCommentBrowser->font()).lineSpacing() * 4;
|
2010-06-03 23:22:14 +00:00
|
|
|
myCommentBrowser->setFixedHeight( h );
|
2009-06-23 00:24:37 +00:00
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
hig->finish( );
|
|
|
|
|
|
|
|
return hig;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2010-04-03 14:23:29 +00:00
|
|
|
void
|
|
|
|
Details :: onShowTrackerScrapesToggled( bool val )
|
|
|
|
{
|
|
|
|
myPrefs.set( Prefs::SHOW_TRACKER_SCRAPES, val );
|
|
|
|
}
|
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
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 )
|
|
|
|
{
|
2010-07-07 00:30:42 +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 )
|
|
|
|
{
|
2010-07-07 00:30:42 +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
|
|
|
}
|
|
|
|
|
2010-06-30 05:55:46 +00:00
|
|
|
void
|
|
|
|
Details :: onTrackerSelectionChanged( )
|
|
|
|
{
|
|
|
|
const QList<QTreeWidgetItem*> items = myTrackerTree->selectedItems();
|
|
|
|
if( items.count() == 1 )
|
|
|
|
myEditTrackerButton->setEnabled( items.first()->data( 0, TRACKERID ).toInt() >= 0 );
|
|
|
|
else
|
|
|
|
myEditTrackerButton->setEnabled( false );
|
|
|
|
myRemoveTrackerButton->setEnabled( !items.isEmpty() );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Details :: findTrackerByURL( const QString& url, int torId )
|
|
|
|
{
|
|
|
|
bool duplicate = false;
|
|
|
|
foreach( QTreeWidgetItem * tracker, myTrackerItems.values() )
|
|
|
|
{
|
|
|
|
if( tracker->data( 0, TRACKERURL ).toString() == url &&
|
|
|
|
( torId == -1 || tracker->data( 0, TORRENTID ).toInt() == torId ) )
|
|
|
|
{
|
|
|
|
duplicate = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return duplicate;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Details :: onAddTrackerPushed( )
|
|
|
|
{
|
|
|
|
const QString urlString = QInputDialog::getText( this,
|
|
|
|
tr( "Add tracker announce URL " ),
|
|
|
|
NULL );
|
|
|
|
if( !urlString.isEmpty() )
|
|
|
|
{
|
|
|
|
if( !findTrackerByURL( urlString, -1 ) )
|
|
|
|
{
|
|
|
|
QByteArray url = urlString.toUtf8();
|
|
|
|
tr_benc top;
|
|
|
|
|
|
|
|
tr_bencInitDict( &top, 1 );
|
|
|
|
tr_bencDictAddStr( &top, "announce", url );
|
|
|
|
|
|
|
|
mySession.torrentSet( myIds, "trackerAdd", &top );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
QMessageBox::warning( this, "Error", "Tracker already exists." );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Details :: onEditTrackerPushed( )
|
|
|
|
{
|
|
|
|
const QTreeWidgetItem * item = myTrackerTree->selectedItems().first();
|
|
|
|
const QString urlString = QInputDialog::getText( this,
|
|
|
|
tr( "Edit tracker announce URL " ),
|
|
|
|
NULL,
|
|
|
|
QLineEdit::Normal,
|
|
|
|
item->data( 0, TRACKERURL ).toString() );
|
|
|
|
if( !urlString.isEmpty() )
|
|
|
|
{
|
|
|
|
const int torId = item->data( 0, TORRENTID ).toInt();
|
|
|
|
if( !findTrackerByURL( urlString, torId ) )
|
|
|
|
{
|
|
|
|
QByteArray url = urlString.toUtf8();
|
|
|
|
QSet<int> ids;
|
|
|
|
tr_benc top;
|
|
|
|
|
|
|
|
ids << torId;
|
|
|
|
tr_bencInitDict( &top, 2 );
|
|
|
|
tr_bencDictAddStr( &top, "announce", item->data( 0, TRACKERURL ).toByteArray() );
|
|
|
|
tr_bencDictAddStr( &top, "announce-new", url );
|
|
|
|
|
|
|
|
mySession.torrentSet( ids, "trackerEdit", &top );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
QMessageBox::warning( this, "Error", "Tracker already exists." );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Details :: removeTracker( const QTreeWidgetItem * item )
|
|
|
|
{
|
|
|
|
QByteArray url = item->data( 0, TRACKERURL ).toByteArray();
|
|
|
|
const int torId = item->data( 0, TORRENTID ).toInt();
|
|
|
|
QSet<int> ids;
|
|
|
|
tr_benc top;
|
|
|
|
|
|
|
|
ids << torId;
|
|
|
|
tr_bencInitDict( &top, 1 );
|
|
|
|
tr_bencDictAddStr( &top, "announce", url );
|
|
|
|
|
|
|
|
mySession.torrentSet( ids, "trackerRemove", &top );
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Details :: onRemoveTrackerPushed( )
|
|
|
|
{
|
2010-07-03 03:46:14 +00:00
|
|
|
const QList<QTreeWidgetItem*> items = myTrackerTree->selectedItems();
|
|
|
|
QSet<int> removedTiers;
|
|
|
|
foreach( const QTreeWidgetItem * item, items ) {
|
|
|
|
const bool isTier = item->data( 0, TRACKERID ).toInt() == -1;
|
|
|
|
const int curTier = item->data( 0, TRACKERTIER ).toInt();
|
|
|
|
if( isTier )
|
|
|
|
{
|
|
|
|
removedTiers << curTier;
|
|
|
|
for( int i = 0; i < item->childCount(); ++i )
|
|
|
|
removeTracker( item->child( i ) );
|
|
|
|
}
|
|
|
|
else if( !removedTiers.contains( curTier ) ) // skip trackers removed by clearing a tier
|
|
|
|
removeTracker( item );
|
2010-06-30 05:55:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
2010-07-07 00:30:42 +00:00
|
|
|
const QString speed_K_str = Formatter::unitStr( Formatter::SPEED, Formatter::KB );
|
2009-04-09 18:55:47 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2010-07-07 00:30:42 +00:00
|
|
|
c = new QCheckBox( tr( "Limit &download speed (%1):" ).arg( speed_K_str ) );
|
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
|
|
|
|
2010-07-07 00:30:42 +00:00
|
|
|
c = new QCheckBox( tr( "Limit &upload speed (%1):" ).arg( speed_K_str ) );
|
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( )
|
|
|
|
{
|
2010-04-03 14:23:29 +00:00
|
|
|
QCheckBox * c;
|
2010-06-30 05:55:46 +00:00
|
|
|
QPushButton * p;
|
2010-04-03 14:23:29 +00:00
|
|
|
QWidget * top = new QWidget;
|
|
|
|
QVBoxLayout * v = new QVBoxLayout( top );
|
2010-06-30 05:55:46 +00:00
|
|
|
QHBoxLayout * h = new QHBoxLayout();
|
|
|
|
QVBoxLayout * v2 = new QVBoxLayout();
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2010-06-30 05:55:46 +00:00
|
|
|
v->setSpacing( HIG::PAD_BIG );
|
2010-04-03 14:23:29 +00:00
|
|
|
v->setContentsMargins( HIG::PAD_BIG, HIG::PAD_BIG, HIG::PAD_BIG, HIG::PAD_BIG );
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2010-06-30 05:55:46 +00:00
|
|
|
h->setSpacing( HIG::PAD );
|
|
|
|
h->setContentsMargins( HIG::PAD_SMALL, HIG::PAD_SMALL, HIG::PAD_SMALL, HIG::PAD_SMALL );
|
|
|
|
|
|
|
|
v2->setSpacing( HIG::PAD );
|
|
|
|
|
2010-04-03 14:23:29 +00:00
|
|
|
QStringList headers;
|
|
|
|
headers << tr("Trackers");
|
|
|
|
myTrackerTree = new QTreeWidget;
|
|
|
|
myTrackerTree->setHeaderLabels( headers );
|
2010-07-03 03:46:14 +00:00
|
|
|
myTrackerTree->setSelectionMode( QTreeWidget::ExtendedSelection );
|
2010-04-03 14:23:29 +00:00
|
|
|
myTrackerTree->setRootIsDecorated( false );
|
2010-06-30 05:55:46 +00:00
|
|
|
myTrackerTree->setIndentation( 2 );
|
|
|
|
myTrackerTree->setItemsExpandable( false );
|
2010-04-03 14:23:29 +00:00
|
|
|
myTrackerTree->setTextElideMode( Qt::ElideRight );
|
|
|
|
myTrackerTree->setAlternatingRowColors( true );
|
2010-06-30 05:55:46 +00:00
|
|
|
connect( myTrackerTree, SIGNAL(itemSelectionChanged()), this, SLOT(onTrackerSelectionChanged()));
|
|
|
|
h->addWidget( myTrackerTree, 1 );
|
|
|
|
|
|
|
|
p = new QPushButton();
|
|
|
|
p->setIcon( getStockIcon( "list-add", QStyle::SP_DialogOpenButton ) );
|
|
|
|
p->setToolTip( "Add Tracker" );
|
|
|
|
myAddTrackerButton = p;
|
|
|
|
v2->addWidget( p, 1 );
|
|
|
|
connect( p, SIGNAL(clicked(bool)), this, SLOT(onAddTrackerPushed()));
|
|
|
|
|
|
|
|
p = new QPushButton();
|
|
|
|
p->setIcon( getStockIcon( "document-properties", QStyle::SP_DesktopIcon ) );
|
|
|
|
p->setToolTip( "Edit Tracker" );
|
|
|
|
myAddTrackerButton = p;
|
|
|
|
p->setEnabled( false );
|
|
|
|
myEditTrackerButton = p;
|
|
|
|
v2->addWidget( p, 1 );
|
|
|
|
connect( p, SIGNAL(clicked(bool)), this, SLOT(onEditTrackerPushed()));
|
|
|
|
|
|
|
|
p = new QPushButton();
|
|
|
|
p->setIcon( getStockIcon( "list-remove", QStyle::SP_TrashIcon ) );
|
|
|
|
p->setToolTip( "Remove Trackers" );
|
|
|
|
p->setEnabled( false );
|
|
|
|
myRemoveTrackerButton = p;
|
|
|
|
v2->addWidget( p, 1 );
|
|
|
|
connect( p, SIGNAL(clicked(bool)), this, SLOT(onRemoveTrackerPushed()));
|
|
|
|
|
|
|
|
v2->addStretch( 1 );
|
|
|
|
|
|
|
|
h->addLayout( v2, 1 );
|
|
|
|
h->setStretch( 1, 0 );
|
|
|
|
|
|
|
|
v->addLayout( h, 1 );
|
2010-04-03 14:23:29 +00:00
|
|
|
|
|
|
|
c = new QCheckBox( tr( "Show &more details" ) );
|
|
|
|
c->setChecked( myPrefs.getBool( Prefs::SHOW_TRACKER_SCRAPES ) );
|
|
|
|
myShowTrackerScrapesCheck = c;
|
|
|
|
v->addWidget( c, 1 );
|
|
|
|
connect( c, SIGNAL(clicked(bool)), this, SLOT(onShowTrackerScrapesToggled(bool)) );
|
|
|
|
|
|
|
|
return top;
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
|
|
|
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 );
|
2010-06-24 16:11:02 +00:00
|
|
|
myPeerTree->sortByColumn( COL_ADDRESS, Qt::AscendingOrder );
|
2009-04-09 18:55:47 +00:00
|
|
|
myPeerTree->setRootIsDecorated( false );
|
|
|
|
myPeerTree->setTextElideMode( Qt::ElideRight );
|
|
|
|
v->addWidget( myPeerTree, 1 );
|
|
|
|
|
|
|
|
const QFontMetrics m( font( ) );
|
2010-04-28 01:26:46 +00:00
|
|
|
QSize size = m.size( 0, "1024 MiB/s" );
|
2009-04-09 18:55:47 +00:00
|
|
|
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
|
|
|
}
|