mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-23 01:36:15 +03:00
parent
64fef21a86
commit
53c2fe4a60
7 changed files with 86 additions and 20 deletions
|
@ -44,10 +44,11 @@
|
||||||
#define F_NAME 0
|
#define F_NAME 0
|
||||||
#define F_SIZE 1
|
#define F_SIZE 1
|
||||||
#define F_UPSPEED 2
|
#define F_UPSPEED 2
|
||||||
#define F_LEECH 3
|
#define F_SWARM 3
|
||||||
#define F_UPLOAD 4
|
#define F_PEERS 4
|
||||||
#define F_RATIO 5
|
#define F_UPLOAD 5
|
||||||
#define F_HASH 6
|
#define F_RATIO 6
|
||||||
|
#define F_HASH 7
|
||||||
|
|
||||||
class FinishedListDelegate: public QItemDelegate {
|
class FinishedListDelegate: public QItemDelegate {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
@ -40,17 +40,19 @@
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
#include <QTimer>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : parent(parent), BTSession(BTSession), nbFinished(0){
|
FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : parent(parent), BTSession(BTSession), nbFinished(0){
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
actionStart->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/play.png")));
|
actionStart->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/play.png")));
|
||||||
actionPause->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/pause.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_NAME, Qt::Horizontal, tr("Name", "i.e: file name"));
|
||||||
finishedListModel->setHeaderData(F_SIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
|
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_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_UPLOAD, Qt::Horizontal, tr("Total uploaded", "i.e: Total amount of uploaded data"));
|
||||||
finishedListModel->setHeaderData(F_RATIO, Qt::Horizontal, tr("Ratio"));
|
finishedListModel->setHeaderData(F_RATIO, Qt::Horizontal, tr("Ratio"));
|
||||||
finishedList->setModel(finishedListModel);
|
finishedList->setModel(finishedListModel);
|
||||||
|
@ -89,18 +91,37 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : par
|
||||||
connect(actionHOSColName, SIGNAL(triggered()), this, SLOT(hideOrShowColumnName()));
|
connect(actionHOSColName, SIGNAL(triggered()), this, SLOT(hideOrShowColumnName()));
|
||||||
connect(actionHOSColSize, SIGNAL(triggered()), this, SLOT(hideOrShowColumnSize()));
|
connect(actionHOSColSize, SIGNAL(triggered()), this, SLOT(hideOrShowColumnSize()));
|
||||||
connect(actionHOSColUpSpeed, SIGNAL(triggered()), this, SLOT(hideOrShowColumnUpSpeed()));
|
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(actionHOSColUpload, SIGNAL(triggered()), this, SLOT(hideOrShowColumnUpload()));
|
||||||
connect(actionHOSColRatio, SIGNAL(triggered()), this, SLOT(hideOrShowColumnRatio()));
|
connect(actionHOSColRatio, SIGNAL(triggered()), this, SLOT(hideOrShowColumnRatio()));
|
||||||
|
|
||||||
|
scrapeTimer = new QTimer(this);
|
||||||
|
connect(scrapeTimer, SIGNAL(timeout()), this, SLOT(scrapeTrackers()));
|
||||||
|
scrapeTimer->start(20000);
|
||||||
}
|
}
|
||||||
|
|
||||||
FinishedTorrents::~FinishedTorrents(){
|
FinishedTorrents::~FinishedTorrents(){
|
||||||
saveColWidthFinishedList();
|
saveColWidthFinishedList();
|
||||||
saveHiddenColumns();
|
saveHiddenColumns();
|
||||||
|
scrapeTimer->stop();
|
||||||
|
delete scrapeTimer;
|
||||||
delete finishedListDelegate;
|
delete finishedListDelegate;
|
||||||
delete finishedListModel;
|
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) {
|
void FinishedTorrents::notifyTorrentDoubleClicked(const QModelIndex& index) {
|
||||||
unsigned int row = index.row();
|
unsigned int row = index.row();
|
||||||
QString hash = getHashFromRow(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_NAME), QVariant(h.name()));
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_SIZE), QVariant((qlonglong)h.actual_size()));
|
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_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_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_RATIO), QVariant(QString::fromUtf8(misc::toString(BTSession->getRealRatio(hash)).c_str())));
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_HASH), QVariant(hash));
|
finishedListModel->setData(finishedListModel->index(row, F_HASH), QVariant(hash));
|
||||||
|
@ -248,6 +270,9 @@ void FinishedTorrents::updateTorrent(QTorrentHandle h) {
|
||||||
row = getRowFromHash(hash);
|
row = getRowFromHash(hash);
|
||||||
}
|
}
|
||||||
Q_ASSERT(row != -1);
|
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;
|
if(h.is_paused()) return;
|
||||||
// Update queued torrent
|
// Update queued torrent
|
||||||
if(BTSession->isQueueingEnabled() && h.is_queued()) {
|
if(BTSession->isQueueingEnabled() && h.is_queued()) {
|
||||||
|
@ -258,7 +283,7 @@ void FinishedTorrents::updateTorrent(QTorrentHandle h) {
|
||||||
}
|
}
|
||||||
// Reset upload speed and seeds/leech
|
// Reset upload speed and seeds/leech
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_UPSPEED), 0.);
|
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"));
|
setRowColor(row, QString::fromUtf8("grey"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -272,8 +297,8 @@ void FinishedTorrents::updateTorrent(QTorrentHandle h) {
|
||||||
if(!finishedList->isColumnHidden(F_UPSPEED)) {
|
if(!finishedList->isColumnHidden(F_UPSPEED)) {
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_UPSPEED), QVariant((double)h.upload_payload_rate()));
|
finishedListModel->setData(finishedListModel->index(row, F_UPSPEED), QVariant((double)h.upload_payload_rate()));
|
||||||
}
|
}
|
||||||
if(!finishedList->isColumnHidden(F_LEECH)) {
|
if(!finishedList->isColumnHidden(F_PEERS)) {
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_LEECH), misc::toQString(h.num_peers() - h.num_seeds(), true));
|
finishedListModel->setData(finishedListModel->index(row, F_PEERS), misc::toQString(h.num_peers() - h.num_seeds(), true));
|
||||||
}
|
}
|
||||||
if(!finishedList->isColumnHidden(F_UPLOAD)) {
|
if(!finishedList->isColumnHidden(F_UPLOAD)) {
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_UPLOAD), QVariant((double)h.all_time_upload()));
|
finishedListModel->setData(finishedListModel->index(row, F_UPLOAD), QVariant((double)h.all_time_upload()));
|
||||||
|
@ -300,7 +325,7 @@ void FinishedTorrents::pauseTorrent(QString hash) {
|
||||||
return;
|
return;
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_UPSPEED), QVariant((double)0.0));
|
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_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"));
|
setRowColor(row, QString::fromUtf8("red"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -470,8 +495,12 @@ void FinishedTorrents::hideOrShowColumnUpSpeed() {
|
||||||
hideOrShowColumn(F_UPSPEED);
|
hideOrShowColumn(F_UPSPEED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FinishedTorrents::hideOrShowColumnLeechers() {
|
void FinishedTorrents::hideOrShowColumnSwarm() {
|
||||||
hideOrShowColumn(F_LEECH);
|
hideOrShowColumn(F_SWARM);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FinishedTorrents::hideOrShowColumnPeers() {
|
||||||
|
hideOrShowColumn(F_PEERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FinishedTorrents::hideOrShowColumnUpload() {
|
void FinishedTorrents::hideOrShowColumnUpload() {
|
||||||
|
@ -537,8 +566,11 @@ QAction* FinishedTorrents::getActionHoSCol(int index) {
|
||||||
case F_UPSPEED :
|
case F_UPSPEED :
|
||||||
return actionHOSColUpSpeed;
|
return actionHOSColUpSpeed;
|
||||||
break;
|
break;
|
||||||
case F_LEECH :
|
case F_SWARM :
|
||||||
return actionHOSColLeechers;
|
return actionHOSColSwarm;
|
||||||
|
break;
|
||||||
|
case F_PEERS :
|
||||||
|
return actionHOSColPeers;
|
||||||
break;
|
break;
|
||||||
case F_UPLOAD :
|
case F_UPLOAD :
|
||||||
return actionHOSColUpload;
|
return actionHOSColUpload;
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
class QStandardItemModel;
|
class QStandardItemModel;
|
||||||
class bittorrent;
|
class bittorrent;
|
||||||
class FinishedListDelegate;
|
class FinishedListDelegate;
|
||||||
|
class QTimer;
|
||||||
|
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
|
|
||||||
|
@ -52,6 +53,7 @@ class FinishedTorrents : public QWidget, public Ui::seeding {
|
||||||
bool loadHiddenColumns();
|
bool loadHiddenColumns();
|
||||||
void saveHiddenColumns();
|
void saveHiddenColumns();
|
||||||
QAction* getActionHoSCol(int index);
|
QAction* getActionHoSCol(int index);
|
||||||
|
QTimer *scrapeTimer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FinishedTorrents(QObject *parent, bittorrent *BTSession);
|
FinishedTorrents(QObject *parent, bittorrent *BTSession);
|
||||||
|
@ -79,9 +81,11 @@ class FinishedTorrents : public QWidget, public Ui::seeding {
|
||||||
void hideOrShowColumnName();
|
void hideOrShowColumnName();
|
||||||
void hideOrShowColumnSize();
|
void hideOrShowColumnSize();
|
||||||
void hideOrShowColumnUpSpeed();
|
void hideOrShowColumnUpSpeed();
|
||||||
void hideOrShowColumnLeechers();
|
void hideOrShowColumnSwarm();
|
||||||
|
void hideOrShowColumnPeers();
|
||||||
void hideOrShowColumnUpload();
|
void hideOrShowColumnUpload();
|
||||||
void hideOrShowColumnRatio();
|
void hideOrShowColumnRatio();
|
||||||
|
void scrapeTrackers();
|
||||||
void forceRecheck();
|
void forceRecheck();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
@ -142,6 +142,21 @@ int QTorrentHandle::num_seeds() const {
|
||||||
return h.status().num_seeds;
|
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 {
|
QString QTorrentHandle::save_path() const {
|
||||||
Q_ASSERT(h.is_valid());
|
Q_ASSERT(h.is_valid());
|
||||||
return misc::toQString(h.save_path().string());
|
return misc::toQString(h.save_path().string());
|
||||||
|
|
|
@ -77,6 +77,9 @@ class QTorrentHandle {
|
||||||
float upload_payload_rate() const;
|
float upload_payload_rate() const;
|
||||||
int num_peers() const;
|
int num_peers() const;
|
||||||
int num_seeds() const;
|
int num_seeds() const;
|
||||||
|
int num_complete() const;
|
||||||
|
int num_incomplete() const;
|
||||||
|
void scrape_tracker() const;
|
||||||
QString save_path() const;
|
QString save_path() const;
|
||||||
fs::path save_path_boost() const;
|
fs::path save_path_boost() const;
|
||||||
QStringList url_seeds() const;
|
QStringList url_seeds() const;
|
||||||
|
|
|
@ -102,9 +102,12 @@
|
||||||
<string>Upload Speed</string>
|
<string>Upload Speed</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionHOSColLeechers">
|
<action name="actionHOSColPeers">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Leechers</string>
|
<string>Connected peers</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Peers</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionHOSColRatio">
|
<action name="actionHOSColRatio">
|
||||||
|
@ -135,6 +138,14 @@
|
||||||
<string>Total uploaded</string>
|
<string>Total uploaded</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionHOSColSwarm">
|
||||||
|
<property name="text">
|
||||||
|
<string>Seeds / Leechers</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Seeds / Leechers</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="icons.qrc"/>
|
<include location="icons.qrc"/>
|
||||||
|
|
|
@ -14,7 +14,7 @@ CONFIG += qt \
|
||||||
network
|
network
|
||||||
|
|
||||||
# Update this VERSION for each release
|
# Update this VERSION for each release
|
||||||
DEFINES += VERSION=\\\"v1.4.0beta2\\\"
|
DEFINES += VERSION=\\\"v1.4.0beta3\\\"
|
||||||
DEFINES += VERSION_MAJOR=1
|
DEFINES += VERSION_MAJOR=1
|
||||||
DEFINES += VERSION_MINOR=4
|
DEFINES += VERSION_MINOR=4
|
||||||
DEFINES += VERSION_BUGFIX=0
|
DEFINES += VERSION_BUGFIX=0
|
||||||
|
|
Loading…
Reference in a new issue