diff --git a/src/FinishedListDelegate.h b/src/FinishedListDelegate.h index db0bed26e..44bcefb1a 100644 --- a/src/FinishedListDelegate.h +++ b/src/FinishedListDelegate.h @@ -44,10 +44,11 @@ #define F_NAME 0 #define F_SIZE 1 #define F_UPSPEED 2 -#define F_LEECH 3 -#define F_UPLOAD 4 -#define F_RATIO 5 -#define F_HASH 6 +#define F_SWARM 3 +#define F_PEERS 4 +#define F_UPLOAD 5 +#define F_RATIO 6 +#define F_HASH 7 class FinishedListDelegate: public QItemDelegate { Q_OBJECT diff --git a/src/FinishedTorrents.cpp b/src/FinishedTorrents.cpp index 3755d27cd..75c0c3721 100644 --- a/src/FinishedTorrents.cpp +++ b/src/FinishedTorrents.cpp @@ -40,17 +40,19 @@ #include #include #include +#include #include FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : parent(parent), BTSession(BTSession), nbFinished(0){ setupUi(this); actionStart->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/play.png"))); actionPause->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/pause.png"))); - finishedListModel = new QStandardItemModel(0,7); + finishedListModel = new QStandardItemModel(0,8); finishedListModel->setHeaderData(F_NAME, Qt::Horizontal, tr("Name", "i.e: file name")); finishedListModel->setHeaderData(F_SIZE, Qt::Horizontal, tr("Size", "i.e: file size")); finishedListModel->setHeaderData(F_UPSPEED, Qt::Horizontal, tr("UP Speed", "i.e: Upload speed")); - finishedListModel->setHeaderData(F_LEECH, Qt::Horizontal, tr("Leechers", "i.e: full/partial sources")); + finishedListModel->setHeaderData(F_SWARM, Qt::Horizontal, tr("Seeds / Leechers")); + finishedListModel->setHeaderData(F_PEERS, Qt::Horizontal, tr("Connected peers")); finishedListModel->setHeaderData(F_UPLOAD, Qt::Horizontal, tr("Total uploaded", "i.e: Total amount of uploaded data")); finishedListModel->setHeaderData(F_RATIO, Qt::Horizontal, tr("Ratio")); finishedList->setModel(finishedListModel); @@ -89,18 +91,37 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : par connect(actionHOSColName, SIGNAL(triggered()), this, SLOT(hideOrShowColumnName())); connect(actionHOSColSize, SIGNAL(triggered()), this, SLOT(hideOrShowColumnSize())); connect(actionHOSColUpSpeed, SIGNAL(triggered()), this, SLOT(hideOrShowColumnUpSpeed())); - connect(actionHOSColLeechers, SIGNAL(triggered()), this, SLOT(hideOrShowColumnLeechers())); + connect(actionHOSColSwarm, SIGNAL(triggered()), this, SLOT(hideOrShowColumnSwarm())); + connect(actionHOSColPeers, SIGNAL(triggered()), this, SLOT(hideOrShowColumnPeers())); connect(actionHOSColUpload, SIGNAL(triggered()), this, SLOT(hideOrShowColumnUpload())); connect(actionHOSColRatio, SIGNAL(triggered()), this, SLOT(hideOrShowColumnRatio())); + + scrapeTimer = new QTimer(this); + connect(scrapeTimer, SIGNAL(timeout()), this, SLOT(scrapeTrackers())); + scrapeTimer->start(20000); } FinishedTorrents::~FinishedTorrents(){ saveColWidthFinishedList(); saveHiddenColumns(); + scrapeTimer->stop(); + delete scrapeTimer; delete finishedListDelegate; delete finishedListModel; } +void FinishedTorrents::scrapeTrackers() { + std::vector torrents = BTSession->getTorrents(); + std::vector::iterator torrentIT; + for(torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) { + QTorrentHandle h = QTorrentHandle(*torrentIT); + if(!h.is_valid()) continue; + if(h.is_seed()) { + h.scrape_tracker(); + } + } +} + void FinishedTorrents::notifyTorrentDoubleClicked(const QModelIndex& index) { unsigned int row = index.row(); QString hash = getHashFromRow(row); @@ -117,7 +138,8 @@ void FinishedTorrents::addTorrent(QString hash){ finishedListModel->setData(finishedListModel->index(row, F_NAME), QVariant(h.name())); finishedListModel->setData(finishedListModel->index(row, F_SIZE), QVariant((qlonglong)h.actual_size())); finishedListModel->setData(finishedListModel->index(row, F_UPSPEED), QVariant((double)0.)); - finishedListModel->setData(finishedListModel->index(row, F_LEECH), QVariant("0")); + finishedListModel->setData(finishedListModel->index(row, F_SWARM), QVariant("-1/-1")); + finishedListModel->setData(finishedListModel->index(row, F_PEERS), QVariant("0")); finishedListModel->setData(finishedListModel->index(row, F_UPLOAD), QVariant((qlonglong)h.all_time_upload())); finishedListModel->setData(finishedListModel->index(row, F_RATIO), QVariant(QString::fromUtf8(misc::toString(BTSession->getRealRatio(hash)).c_str()))); finishedListModel->setData(finishedListModel->index(row, F_HASH), QVariant(hash)); @@ -248,6 +270,9 @@ void FinishedTorrents::updateTorrent(QTorrentHandle h) { row = getRowFromHash(hash); } Q_ASSERT(row != -1); + if(!finishedList->isColumnHidden(F_SWARM)) { + finishedListModel->setData(finishedListModel->index(row, F_SWARM), misc::toQString(h.num_complete())+QString("/")+misc::toQString(h.num_incomplete())); + } if(h.is_paused()) return; // Update queued torrent if(BTSession->isQueueingEnabled() && h.is_queued()) { @@ -258,7 +283,7 @@ void FinishedTorrents::updateTorrent(QTorrentHandle h) { } // Reset upload speed and seeds/leech finishedListModel->setData(finishedListModel->index(row, F_UPSPEED), 0.); - finishedListModel->setData(finishedListModel->index(row, F_LEECH), "0"); + finishedListModel->setData(finishedListModel->index(row, F_PEERS), "0"); setRowColor(row, QString::fromUtf8("grey")); return; } @@ -272,8 +297,8 @@ void FinishedTorrents::updateTorrent(QTorrentHandle h) { if(!finishedList->isColumnHidden(F_UPSPEED)) { finishedListModel->setData(finishedListModel->index(row, F_UPSPEED), QVariant((double)h.upload_payload_rate())); } - if(!finishedList->isColumnHidden(F_LEECH)) { - finishedListModel->setData(finishedListModel->index(row, F_LEECH), misc::toQString(h.num_peers() - h.num_seeds(), true)); + if(!finishedList->isColumnHidden(F_PEERS)) { + finishedListModel->setData(finishedListModel->index(row, F_PEERS), misc::toQString(h.num_peers() - h.num_seeds(), true)); } if(!finishedList->isColumnHidden(F_UPLOAD)) { finishedListModel->setData(finishedListModel->index(row, F_UPLOAD), QVariant((double)h.all_time_upload())); @@ -300,7 +325,7 @@ void FinishedTorrents::pauseTorrent(QString hash) { return; finishedListModel->setData(finishedListModel->index(row, F_UPSPEED), QVariant((double)0.0)); finishedListModel->setData(finishedListModel->index(row, F_NAME), QIcon(QString::fromUtf8(":/Icons/skin/paused.png")), Qt::DecorationRole); - finishedListModel->setData(finishedListModel->index(row, F_LEECH), QVariant(QString::fromUtf8("0"))); + finishedListModel->setData(finishedListModel->index(row, F_PEERS), QVariant(QString::fromUtf8("0"))); setRowColor(row, QString::fromUtf8("red")); } @@ -470,8 +495,12 @@ void FinishedTorrents::hideOrShowColumnUpSpeed() { hideOrShowColumn(F_UPSPEED); } -void FinishedTorrents::hideOrShowColumnLeechers() { - hideOrShowColumn(F_LEECH); +void FinishedTorrents::hideOrShowColumnSwarm() { + hideOrShowColumn(F_SWARM); +} + +void FinishedTorrents::hideOrShowColumnPeers() { + hideOrShowColumn(F_PEERS); } void FinishedTorrents::hideOrShowColumnUpload() { @@ -537,8 +566,11 @@ QAction* FinishedTorrents::getActionHoSCol(int index) { case F_UPSPEED : return actionHOSColUpSpeed; break; - case F_LEECH : - return actionHOSColLeechers; + case F_SWARM : + return actionHOSColSwarm; + break; + case F_PEERS : + return actionHOSColPeers; break; case F_UPLOAD : return actionHOSColUpload; diff --git a/src/FinishedTorrents.h b/src/FinishedTorrents.h index b997b72fd..1096fa8f6 100644 --- a/src/FinishedTorrents.h +++ b/src/FinishedTorrents.h @@ -37,6 +37,7 @@ class QStandardItemModel; class bittorrent; class FinishedListDelegate; +class QTimer; using namespace libtorrent; @@ -52,6 +53,7 @@ class FinishedTorrents : public QWidget, public Ui::seeding { bool loadHiddenColumns(); void saveHiddenColumns(); QAction* getActionHoSCol(int index); + QTimer *scrapeTimer; public: FinishedTorrents(QObject *parent, bittorrent *BTSession); @@ -79,9 +81,11 @@ class FinishedTorrents : public QWidget, public Ui::seeding { void hideOrShowColumnName(); void hideOrShowColumnSize(); void hideOrShowColumnUpSpeed(); - void hideOrShowColumnLeechers(); + void hideOrShowColumnSwarm(); + void hideOrShowColumnPeers(); void hideOrShowColumnUpload(); void hideOrShowColumnRatio(); + void scrapeTrackers(); void forceRecheck(); public slots: diff --git a/src/qtorrenthandle.cpp b/src/qtorrenthandle.cpp index 3c6c57cf2..f99b265dd 100644 --- a/src/qtorrenthandle.cpp +++ b/src/qtorrenthandle.cpp @@ -142,6 +142,21 @@ int QTorrentHandle::num_seeds() const { return h.status().num_seeds; } +int QTorrentHandle::num_complete() const { + Q_ASSERT(h.is_valid()); + return h.status().num_complete; +} + +void QTorrentHandle::scrape_tracker() const { + Q_ASSERT(h.is_valid()); + h.scrape_tracker(); +} + +int QTorrentHandle::num_incomplete() const { + Q_ASSERT(h.is_valid()); + return h.status().num_incomplete; +} + QString QTorrentHandle::save_path() const { Q_ASSERT(h.is_valid()); return misc::toQString(h.save_path().string()); diff --git a/src/qtorrenthandle.h b/src/qtorrenthandle.h index a3edce6a3..c73ca75eb 100644 --- a/src/qtorrenthandle.h +++ b/src/qtorrenthandle.h @@ -77,6 +77,9 @@ class QTorrentHandle { float upload_payload_rate() const; int num_peers() const; int num_seeds() const; + int num_complete() const; + int num_incomplete() const; + void scrape_tracker() const; QString save_path() const; fs::path save_path_boost() const; QStringList url_seeds() const; diff --git a/src/seeding.ui b/src/seeding.ui index 9e36b0ac2..0fc070030 100644 --- a/src/seeding.ui +++ b/src/seeding.ui @@ -102,9 +102,12 @@ Upload Speed - + - Leechers + Connected peers + + + Peers @@ -135,6 +138,14 @@ Total uploaded + + + Seeds / Leechers + + + Seeds / Leechers + + diff --git a/src/src.pro b/src/src.pro index d60fc9711..de067c687 100644 --- a/src/src.pro +++ b/src/src.pro @@ -14,7 +14,7 @@ CONFIG += qt \ network # Update this VERSION for each release -DEFINES += VERSION=\\\"v1.4.0beta2\\\" +DEFINES += VERSION=\\\"v1.4.0beta3\\\" DEFINES += VERSION_MAJOR=1 DEFINES += VERSION_MINOR=4 DEFINES += VERSION_BUGFIX=0