From 781d33b869dddc791171f298b5cfb208dc451b6e Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Mon, 24 May 2010 14:19:25 +0000 Subject: [PATCH] FEATURE: Added error state for torrents (error is displayed in a tooltip) --- Changelog | 1 + src/bittorrent.cpp | 2 +- src/eventmanager.cpp | 12 ++++++++---- src/qtorrenthandle.cpp | 7 ++++++- src/qtorrenthandle.h | 1 + src/src.pro | 2 +- src/transferlistwidget.cpp | 15 +++++++++++++-- 7 files changed, 31 insertions(+), 9 deletions(-) diff --git a/Changelog b/Changelog index 90846d6c9..5917ff28d 100644 --- a/Changelog +++ b/Changelog @@ -7,6 +7,7 @@ - FEATURE: User can force tracker reannounce - FEATURE: Added "No action" setting for double-click action - FEATURE: Several torrents can be moved at once + - FEATURE: Added error state for torrents (error is displayed in a tooltip) - COSMETIC: Display peers country name in tooltip - COSMETIC: Display number of torrents in transfers tab label diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index 5b4d840a8..c53b0124b 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -2034,7 +2034,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { addConsoleMessage(tr("Reason: %1").arg(misc::toQString(p->message()))); if(h.is_valid()) { emit fullDiskError(h, misc::toQString(p->message())); - h.pause(); + //h.pause(); emit pausedTorrent(h); } } diff --git a/src/eventmanager.cpp b/src/eventmanager.cpp index 25b27f7a8..0ad62f240 100644 --- a/src/eventmanager.cpp +++ b/src/eventmanager.cpp @@ -364,10 +364,14 @@ void EventManager::modifiedTorrent(QTorrentHandle h) QVariantMap event; event["eta"] = QVariant(QString::fromUtf8("∞")); if(h.is_paused()) { - if(h.is_seed()) - event["state"] = QVariant("pausedUP"); - else - event["state"] = QVariant("pausedDL"); + if(h.has_error()) { + event["state"] = QVariant("error"); + } else { + if(h.is_seed()) + event["state"] = QVariant("pausedUP"); + else + event["state"] = QVariant("pausedDL"); + } } else { if(BTSession->isQueueingEnabled() && h.is_queued()) { if(h.is_seed()) diff --git a/src/qtorrenthandle.cpp b/src/qtorrenthandle.cpp index fce1974ae..c7e6ed4a6 100644 --- a/src/qtorrenthandle.cpp +++ b/src/qtorrenthandle.cpp @@ -460,7 +460,12 @@ QString QTorrentHandle::root_path() const { bool QTorrentHandle::has_error() const { Q_ASSERT(h.is_valid()); - return h.status().error.empty(); + return h.is_paused() && !h.status().error.empty(); +} + +QString QTorrentHandle::error() const { + Q_ASSERT(h.is_valid()); + return misc::toQString(h.status().error); } void QTorrentHandle::downloading_pieces(bitfield &bf) const { diff --git a/src/qtorrenthandle.h b/src/qtorrenthandle.h index b9b1f542a..9f5d6a6d4 100644 --- a/src/qtorrenthandle.h +++ b/src/qtorrenthandle.h @@ -131,6 +131,7 @@ class QTorrentHandle { bool first_last_piece_first() const; QString root_path() const; bool has_error() const; + QString error() const; void downloading_pieces(bitfield &bf) const; // diff --git a/src/src.pro b/src/src.pro index 0ff8d9726..bf7e6b117 100644 --- a/src/src.pro +++ b/src/src.pro @@ -11,7 +11,7 @@ CONFIG += qt \ thread # Update this VERSION for each release -DEFINES += VERSION=\'\"v2.3.0\"\' +DEFINES += VERSION=\'\"v2.3.0beta1\"\' DEFINES += VERSION_MAJOR=2 DEFINES += VERSION_MINOR=3 DEFINES += VERSION_BUGFIX=0 diff --git a/src/transferlistwidget.cpp b/src/transferlistwidget.cpp index 8ee14a35f..adcd9e6cc 100644 --- a/src/transferlistwidget.cpp +++ b/src/transferlistwidget.cpp @@ -249,10 +249,20 @@ void TransferListWidget::pauseTorrent(int row, bool refresh_list) { listModel->setData(listModel->index(row, TR_UPSPEED), QVariant((double)0.0)); if(h.is_seed()) { listModel->setData(listModel->index(row, TR_STATUS), STATE_PAUSED_UP); - listModel->setData(listModel->index(row, TR_NAME), QIcon(QString::fromUtf8(":/Icons/skin/pausedUP.png")), Qt::DecorationRole); + if(h.has_error()) { + listModel->setData(listModel->index(row, TR_NAME), h.error(), Qt::ToolTipRole); + listModel->setData(listModel->index(row, TR_NAME), QIcon(QString::fromUtf8(":/Icons/skin/error.png")), Qt::DecorationRole); + } else { + listModel->setData(listModel->index(row, TR_NAME), QIcon(QString::fromUtf8(":/Icons/skin/pausedUP.png")), Qt::DecorationRole); + } } else { listModel->setData(listModel->index(row, TR_STATUS), STATE_PAUSED_DL); - listModel->setData(listModel->index(row, TR_NAME), QIcon(QString::fromUtf8(":/Icons/skin/pausedDL.png")), Qt::DecorationRole); + if(h.has_error()) { + listModel->setData(listModel->index(row, TR_NAME), h.error(), Qt::ToolTipRole); + listModel->setData(listModel->index(row, TR_NAME), QIcon(QString::fromUtf8(":/Icons/skin/error.png")), Qt::DecorationRole); + } else { + listModel->setData(listModel->index(row, TR_NAME), QIcon(QString::fromUtf8(":/Icons/skin/pausedDL.png")), Qt::DecorationRole); + } listModel->setData(listModel->index(row, TR_ETA), QVariant((qlonglong)MAX_ETA)); } listModel->setData(listModel->index(row, TR_SEEDS), QVariant(0.0)); @@ -282,6 +292,7 @@ void TransferListWidget::resumeTorrent(int row, bool refresh_list) { listModel->setData(listModel->index(row, TR_NAME), QVariant(QIcon(":/Icons/skin/stalledDL.png")), Qt::DecorationRole); listModel->setData(listModel->index(row, TR_STATUS), STATE_STALLED_DL); } + listModel->setData(listModel->index(row, TR_NAME), "", Qt::ToolTipRole); setRowColor(row, QApplication::palette().color(QPalette::WindowText)); if(refresh_list) refreshList();