diff --git a/src/core/bittorrent/session.cpp b/src/core/bittorrent/session.cpp index 281dbddac..847f4d7ed 100644 --- a/src/core/bittorrent/session.cpp +++ b/src/core/bittorrent/session.cpp @@ -2387,6 +2387,8 @@ void Session::handleStateUpdateAlert(libt::state_update_alert *p) ++m_torrentStatusReport.nbActive; if (torrent->isInactive()) ++m_torrentStatusReport.nbInactive; + if (torrent->isErrored()) + ++m_torrentStatusReport.nbErrored; } emit torrentsUpdated(); diff --git a/src/core/bittorrent/session.h b/src/core/bittorrent/session.h index 33ed8a5d2..f2bf587e5 100644 --- a/src/core/bittorrent/session.h +++ b/src/core/bittorrent/session.h @@ -134,6 +134,7 @@ namespace BitTorrent uint nbInactive = 0; uint nbPaused = 0; uint nbResumed = 0; + uint nbErrored = 0; }; class Session : public QObject diff --git a/src/core/bittorrent/torrenthandle.cpp b/src/core/bittorrent/torrenthandle.cpp index 633d663d4..8995e8cb0 100644 --- a/src/core/bittorrent/torrenthandle.cpp +++ b/src/core/bittorrent/torrenthandle.cpp @@ -626,9 +626,7 @@ bool TorrentHandle::isDownloading() const || m_state == TorrentState::CheckingDownloading || m_state == TorrentState::PausedDownloading || m_state == TorrentState::QueuedDownloading - || m_state == TorrentState::ForcedDownloading - || m_state == TorrentState::MissingFiles - || m_state == TorrentState::Error; + || m_state == TorrentState::ForcedDownloading; } bool TorrentHandle::isUploading() const @@ -667,6 +665,12 @@ bool TorrentHandle::isInactive() const return !isActive(); } +bool TorrentHandle::isErrored() const +{ + return m_state == TorrentState::MissingFiles + || m_state == TorrentState::Error; +} + bool TorrentHandle::isSeed() const { // Affected by bug http://code.rasterbar.com/libtorrent/ticket/402 diff --git a/src/core/bittorrent/torrenthandle.h b/src/core/bittorrent/torrenthandle.h index 7eb65a4c6..73a3d5f2d 100644 --- a/src/core/bittorrent/torrenthandle.h +++ b/src/core/bittorrent/torrenthandle.h @@ -252,6 +252,7 @@ namespace BitTorrent bool isCompleted() const; bool isActive() const; bool isInactive() const; + bool isErrored() const; bool isSequentialDownload() const; bool hasFirstLastPiecePriority() const; TorrentState state() const; diff --git a/src/core/torrentfilter.cpp b/src/core/torrentfilter.cpp index 01f87b6eb..02f9eea5d 100644 --- a/src/core/torrentfilter.cpp +++ b/src/core/torrentfilter.cpp @@ -39,6 +39,7 @@ const TorrentFilter TorrentFilter::PausedTorrent(TorrentFilter::Paused); const TorrentFilter TorrentFilter::ResumedTorrent(TorrentFilter::Resumed); const TorrentFilter TorrentFilter::ActiveTorrent(TorrentFilter::Active); const TorrentFilter TorrentFilter::InactiveTorrent(TorrentFilter::Inactive); +const TorrentFilter TorrentFilter::ErroredTorrent(TorrentFilter::Errored); using BitTorrent::TorrentHandle; using BitTorrent::TorrentState; @@ -91,6 +92,8 @@ bool TorrentFilter::setTypeByName(const QString &filter) type = Active; else if (filter == "inactive") type = Inactive; + else if (filter == "errored") + type = Errored; return setType(type); } @@ -144,6 +147,8 @@ bool TorrentFilter::matchState(BitTorrent::TorrentHandle *const torrent) const return torrent->isActive(); case Inactive: return torrent->isInactive(); + case Errored: + return torrent->isErrored(); default: // All return true; } diff --git a/src/core/torrentfilter.h b/src/core/torrentfilter.h index 88eea589a..c02ba176b 100644 --- a/src/core/torrentfilter.h +++ b/src/core/torrentfilter.h @@ -54,7 +54,8 @@ public: Resumed, Paused, Active, - Inactive + Inactive, + Errored }; static const QString AnyLabel; @@ -67,6 +68,7 @@ public: static const TorrentFilter ResumedTorrent; static const TorrentFilter ActiveTorrent; static const TorrentFilter InactiveTorrent; + static const TorrentFilter ErroredTorrent; TorrentFilter(); // label: pass empty string for "no label" or null string (QString()) for "any label" diff --git a/src/gui/transferlistfilterswidget.cpp b/src/gui/transferlistfilterswidget.cpp index e7d2b39c3..f70c9d84f 100644 --- a/src/gui/transferlistfilterswidget.cpp +++ b/src/gui/transferlistfilterswidget.cpp @@ -137,6 +137,9 @@ StatusFiltersWidget::StatusFiltersWidget(QWidget *parent, TransferListWidget *tr QListWidgetItem *inactive = new QListWidgetItem(this); inactive->setData(Qt::DisplayRole, QVariant(tr("Inactive (0)"))); inactive->setData(Qt::DecorationRole, QIcon(":/icons/skin/filterinactive.png")); + QListWidgetItem *errored = new QListWidgetItem(this); + errored->setData(Qt::DisplayRole, QVariant(tr("Errored (0)"))); + errored->setData(Qt::DecorationRole, QIcon(":/icons/skin/error.png")); const Preferences* const pref = Preferences::instance(); setCurrentRow(pref->getTransSelFilter(), QItemSelectionModel::SelectCurrent); @@ -160,6 +163,7 @@ void StatusFiltersWidget::updateTorrentNumbers() item(TorrentFilter::Resumed)->setData(Qt::DisplayRole, QVariant(tr("Resumed (%1)").arg(report.nbResumed))); item(TorrentFilter::Active)->setData(Qt::DisplayRole, QVariant(tr("Active (%1)").arg(report.nbActive))); item(TorrentFilter::Inactive)->setData(Qt::DisplayRole, QVariant(tr("Inactive (%1)").arg(report.nbInactive))); + item(TorrentFilter::Errored)->setData(Qt::DisplayRole, QVariant(tr("Errored (%1)").arg(report.nbErrored))); } void StatusFiltersWidget::showMenu(QPoint) {}