mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-09 14:27:56 +00:00
- Improved list refreshing code
This commit is contained in:
parent
d6e90883cb
commit
bf7841cdb9
@ -37,7 +37,7 @@
|
|||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QBasicTimer>
|
#include <QTimer>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
@ -89,8 +89,9 @@ TransferListWidget::TransferListWidget(QWidget *parent, bittorrent *_BTSession):
|
|||||||
connect(header(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayDLHoSMenu(const QPoint&)));
|
connect(header(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayDLHoSMenu(const QPoint&)));
|
||||||
|
|
||||||
// Refresh timer
|
// Refresh timer
|
||||||
refreshTimer = new QBasicTimer();
|
refreshTimer = new QTimer();
|
||||||
refreshTimer->start(settings.value("Preferences/General/RefreshInterval", 1500).toInt(), this);
|
refreshTimer->start(settings.value("Preferences/General/RefreshInterval", 1500).toInt());
|
||||||
|
connect(refreshTimer, SIGNAL(timeout()), this, SLOT(refreshList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
TransferListWidget::~TransferListWidget() {
|
TransferListWidget::~TransferListWidget() {
|
||||||
@ -101,10 +102,6 @@ TransferListWidget::~TransferListWidget() {
|
|||||||
delete listDelegate;
|
delete listDelegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::timerEvent(QTimerEvent*) {
|
|
||||||
refreshList();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransferListWidget::addTorrent(QTorrentHandle& h) {
|
void TransferListWidget::addTorrent(QTorrentHandle& h) {
|
||||||
if(!h.is_valid()) return;
|
if(!h.is_valid()) return;
|
||||||
int row = listModel->rowCount();
|
int row = listModel->rowCount();
|
||||||
@ -146,7 +143,6 @@ void TransferListWidget::pauseTorrent(QString hash) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::pauseTorrent(int row) {
|
void TransferListWidget::pauseTorrent(int row) {
|
||||||
qDebug("Torrent visibly paused");
|
|
||||||
listModel->setData(listModel->index(row, DLSPEED), QVariant((double)0.0));
|
listModel->setData(listModel->index(row, DLSPEED), QVariant((double)0.0));
|
||||||
listModel->setData(listModel->index(row, UPSPEED), QVariant((double)0.0));
|
listModel->setData(listModel->index(row, UPSPEED), QVariant((double)0.0));
|
||||||
listModel->setData(listModel->index(row, ETA), QVariant((qlonglong)-1));
|
listModel->setData(listModel->index(row, ETA), QVariant((qlonglong)-1));
|
||||||
@ -263,7 +259,7 @@ void TransferListWidget::setFinished(QTorrentHandle &h) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::setRefreshInterval(int t) {
|
void TransferListWidget::setRefreshInterval(int t) {
|
||||||
refreshTimer->start(t, this);
|
refreshTimer->start(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::refreshList() {
|
void TransferListWidget::refreshList() {
|
||||||
@ -343,7 +339,6 @@ void TransferListWidget::pauseSelectedTorrents() {
|
|||||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
||||||
if(h.is_valid() && !h.is_paused()) {
|
if(h.is_valid() && !h.is_paused()) {
|
||||||
h.pause();
|
h.pause();
|
||||||
qDebug("row: %d", index.row());
|
|
||||||
pauseTorrent(index.row());
|
pauseTorrent(index.row());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ class TransferListDelegate;
|
|||||||
class QStandardItemModel;
|
class QStandardItemModel;
|
||||||
class QSortFilterProxyModel;
|
class QSortFilterProxyModel;
|
||||||
class bittorrent;
|
class bittorrent;
|
||||||
class QBasicTimer;
|
class QTimer;
|
||||||
|
|
||||||
class TransferListWidget: public QTreeView {
|
class TransferListWidget: public QTreeView {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -48,14 +48,13 @@ private:
|
|||||||
QStandardItemModel *listModel;
|
QStandardItemModel *listModel;
|
||||||
QSortFilterProxyModel *proxyModel;
|
QSortFilterProxyModel *proxyModel;
|
||||||
bittorrent* BTSession;
|
bittorrent* BTSession;
|
||||||
QBasicTimer *refreshTimer;
|
QTimer *refreshTimer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TransferListWidget(QWidget *parent, bittorrent* BTSession);
|
TransferListWidget(QWidget *parent, bittorrent* BTSession);
|
||||||
~TransferListWidget();
|
~TransferListWidget();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void timerEvent(QTimerEvent*);
|
|
||||||
int getRowFromHash(QString hash) const;
|
int getRowFromHash(QString hash) const;
|
||||||
QString getHashFromRow(int row) const;
|
QString getHashFromRow(int row) const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user