From bf7841cdb9b4422d782f76ac99f421e4438e90f4 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sat, 7 Nov 2009 20:00:38 +0000 Subject: [PATCH] - Improved list refreshing code --- src/TransferListWidget.cpp | 15 +++++---------- src/TransferListWidget.h | 5 ++--- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/TransferListWidget.cpp b/src/TransferListWidget.cpp index 34f516436..458400773 100644 --- a/src/TransferListWidget.cpp +++ b/src/TransferListWidget.cpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include @@ -89,8 +89,9 @@ TransferListWidget::TransferListWidget(QWidget *parent, bittorrent *_BTSession): connect(header(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayDLHoSMenu(const QPoint&))); // Refresh timer - refreshTimer = new QBasicTimer(); - refreshTimer->start(settings.value("Preferences/General/RefreshInterval", 1500).toInt(), this); + refreshTimer = new QTimer(); + refreshTimer->start(settings.value("Preferences/General/RefreshInterval", 1500).toInt()); + connect(refreshTimer, SIGNAL(timeout()), this, SLOT(refreshList())); } TransferListWidget::~TransferListWidget() { @@ -101,10 +102,6 @@ TransferListWidget::~TransferListWidget() { delete listDelegate; } -void TransferListWidget::timerEvent(QTimerEvent*) { - refreshList(); -} - void TransferListWidget::addTorrent(QTorrentHandle& h) { if(!h.is_valid()) return; int row = listModel->rowCount(); @@ -146,7 +143,6 @@ void TransferListWidget::pauseTorrent(QString hash) { } void TransferListWidget::pauseTorrent(int row) { - qDebug("Torrent visibly paused"); 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, ETA), QVariant((qlonglong)-1)); @@ -263,7 +259,7 @@ void TransferListWidget::setFinished(QTorrentHandle &h) { } void TransferListWidget::setRefreshInterval(int t) { - refreshTimer->start(t, this); + refreshTimer->start(t); } void TransferListWidget::refreshList() { @@ -343,7 +339,6 @@ void TransferListWidget::pauseSelectedTorrents() { QTorrentHandle h = BTSession->getTorrentHandle(hash); if(h.is_valid() && !h.is_paused()) { h.pause(); - qDebug("row: %d", index.row()); pauseTorrent(index.row()); } } diff --git a/src/TransferListWidget.h b/src/TransferListWidget.h index 5f463ac36..4fa25d882 100644 --- a/src/TransferListWidget.h +++ b/src/TransferListWidget.h @@ -38,7 +38,7 @@ class TransferListDelegate; class QStandardItemModel; class QSortFilterProxyModel; class bittorrent; -class QBasicTimer; +class QTimer; class TransferListWidget: public QTreeView { Q_OBJECT @@ -48,14 +48,13 @@ private: QStandardItemModel *listModel; QSortFilterProxyModel *proxyModel; bittorrent* BTSession; - QBasicTimer *refreshTimer; + QTimer *refreshTimer; public: TransferListWidget(QWidget *parent, bittorrent* BTSession); ~TransferListWidget(); protected: - void timerEvent(QTimerEvent*); int getRowFromHash(QString hash) const; QString getHashFromRow(int row) const;