Browse Source

- Display Swarm infos in seeding list (closes #346955)

- Bump to beta3
adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
53c2fe4a60
  1. 9
      src/FinishedListDelegate.h
  2. 56
      src/FinishedTorrents.cpp
  3. 6
      src/FinishedTorrents.h
  4. 15
      src/qtorrenthandle.cpp
  5. 3
      src/qtorrenthandle.h
  6. 15
      src/seeding.ui
  7. 2
      src/src.pro

9
src/FinishedListDelegate.h

@ -44,10 +44,11 @@ @@ -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

56
src/FinishedTorrents.cpp

@ -40,17 +40,19 @@ @@ -40,17 +40,19 @@
#include <QStandardItemModel>
#include <QHeaderView>
#include <QMenu>
#include <QTimer>
#include <QMessageBox>
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 @@ -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<torrent_handle> torrents = BTSession->getTorrents();
std::vector<torrent_handle>::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){ @@ -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) { @@ -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) { @@ -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) { @@ -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) { @@ -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() { @@ -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) { @@ -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;

6
src/FinishedTorrents.h

@ -37,6 +37,7 @@ @@ -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 { @@ -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 { @@ -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:

15
src/qtorrenthandle.cpp

@ -142,6 +142,21 @@ int QTorrentHandle::num_seeds() const { @@ -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());

3
src/qtorrenthandle.h

@ -77,6 +77,9 @@ class QTorrentHandle { @@ -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;

15
src/seeding.ui

@ -102,9 +102,12 @@ @@ -102,9 +102,12 @@
<string>Upload Speed</string>
</property>
</action>
<action name="actionHOSColLeechers">
<action name="actionHOSColPeers">
<property name="text">
<string>Leechers</string>
<string>Connected peers</string>
</property>
<property name="toolTip">
<string>Peers</string>
</property>
</action>
<action name="actionHOSColRatio">
@ -135,6 +138,14 @@ @@ -135,6 +138,14 @@
<string>Total uploaded</string>
</property>
</action>
<action name="actionHOSColSwarm">
<property name="text">
<string>Seeds / Leechers</string>
</property>
<property name="toolTip">
<string>Seeds / Leechers</string>
</property>
</action>
</widget>
<resources>
<include location="icons.qrc"/>

2
src/src.pro

@ -14,7 +14,7 @@ CONFIG += qt \ @@ -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

Loading…
Cancel
Save