From d66273b10a14c985d3a46805aa45e3e6faef2a2d Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Sat, 31 Jan 2015 19:53:38 +0200 Subject: [PATCH] Show error status when a torrent is missing files. --- src/qtlibtorrent/torrentmodel.cpp | 11 +++++++++-- src/qtlibtorrent/torrentmodel.h | 2 +- src/transferlistdelegate.cpp | 3 +++ src/transferlistsortmodel.cpp | 8 +++++--- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/qtlibtorrent/torrentmodel.cpp b/src/qtlibtorrent/torrentmodel.cpp index 985064643..5df8298bc 100644 --- a/src/qtlibtorrent/torrentmodel.cpp +++ b/src/qtlibtorrent/torrentmodel.cpp @@ -100,8 +100,12 @@ void TorrentModelItem::refreshStatus(libtorrent::torrent_status const& status) { TorrentModelItem::State TorrentModelItem::state() const { try { // Pause or Queued - if (m_torrent.is_paused(m_lastStatus)) - return m_torrent.is_seed(m_lastStatus) ? STATE_PAUSED_UP : STATE_PAUSED_DL; + if (m_torrent.is_paused(m_lastStatus)) { + if (TorrentPersistentData::instance()->getHasMissingFiles(misc::toQString(m_lastStatus.info_hash))) + return STATE_PAUSED_MISSING; + else + return m_torrent.is_seed(m_lastStatus) ? STATE_PAUSED_UP : STATE_PAUSED_DL; + } if (m_torrent.is_queued(m_lastStatus) && m_lastStatus.state != torrent_status::queued_for_checking @@ -158,6 +162,7 @@ QIcon TorrentModelItem::getIconByState(State state) { case STATE_QUEUED_FASTCHECK: return get_checking_icon(); case STATE_INVALID: + case STATE_PAUSED_MISSING: return get_error_icon(); default: Q_ASSERT(false); @@ -178,6 +183,7 @@ QColor TorrentModelItem::getColorByState(State state) { return QColor(255, 165, 0); // orange case STATE_PAUSED_DL: case STATE_PAUSED_UP: + case STATE_PAUSED_MISSING: return QColor(255, 0, 0); // red case STATE_QUEUED_DL: case STATE_QUEUED_UP: @@ -551,6 +557,7 @@ TorrentStatusReport TorrentModel::getTorrentStatusReport() const ++report.nb_seeding; break; case TorrentModelItem::STATE_PAUSED_UP: + case TorrentModelItem::STATE_PAUSED_MISSING: ++report.nb_paused; case TorrentModelItem::STATE_STALLED_UP: case TorrentModelItem::STATE_CHECKING_UP: diff --git a/src/qtlibtorrent/torrentmodel.h b/src/qtlibtorrent/torrentmodel.h index 5153b4853..0c8ba7ac0 100644 --- a/src/qtlibtorrent/torrentmodel.h +++ b/src/qtlibtorrent/torrentmodel.h @@ -48,7 +48,7 @@ class TorrentModelItem : public QObject { Q_OBJECT public: - enum State {STATE_DOWNLOADING, STATE_DOWNLOADING_META, STATE_ALLOCATING, STATE_STALLED_DL, STATE_STALLED_UP, STATE_SEEDING, STATE_PAUSED_DL, STATE_PAUSED_UP, STATE_QUEUED_DL, STATE_QUEUED_UP, STATE_CHECKING_UP, STATE_CHECKING_DL, STATE_QUEUED_CHECK, STATE_QUEUED_FASTCHECK, STATE_INVALID}; + enum State {STATE_DOWNLOADING, STATE_DOWNLOADING_META, STATE_ALLOCATING, STATE_STALLED_DL, STATE_STALLED_UP, STATE_SEEDING, STATE_PAUSED_DL, STATE_PAUSED_UP, STATE_PAUSED_MISSING, STATE_QUEUED_DL, STATE_QUEUED_UP, STATE_CHECKING_UP, STATE_CHECKING_DL, STATE_QUEUED_CHECK, STATE_QUEUED_FASTCHECK, STATE_INVALID}; enum Column {TR_NAME, TR_PRIORITY, TR_SIZE, TR_TOTAL_SIZE, TR_PROGRESS, TR_STATUS, TR_SEEDS, TR_PEERS, TR_DLSPEED, TR_UPSPEED, TR_ETA, TR_RATIO, TR_LABEL, TR_ADD_DATE, TR_SEED_DATE, TR_TRACKER, TR_DLLIMIT, TR_UPLIMIT, TR_AMOUNT_DOWNLOADED, TR_AMOUNT_UPLOADED, TR_AMOUNT_LEFT, TR_TIME_ELAPSED, TR_SAVE_PATH, TR_COMPLETED, TR_RATIO_LIMIT, TR_SEEN_COMPLETE_DATE, TR_LAST_ACTIVITY, NB_COLUMNS}; public: diff --git a/src/transferlistdelegate.cpp b/src/transferlistdelegate.cpp index d07407046..a4d306aec 100644 --- a/src/transferlistdelegate.cpp +++ b/src/transferlistdelegate.cpp @@ -101,6 +101,9 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem case TorrentModelItem::STATE_PAUSED_UP: display = tr("Paused"); break; + case TorrentModelItem::STATE_PAUSED_MISSING: + display = tr("Missing Files"); + break; case TorrentModelItem::STATE_QUEUED_DL: case TorrentModelItem::STATE_QUEUED_UP: display = tr("Queued", "i.e. torrent is queued"); diff --git a/src/transferlistsortmodel.cpp b/src/transferlistsortmodel.cpp index f93419d79..fede02c73 100644 --- a/src/transferlistsortmodel.cpp +++ b/src/transferlistsortmodel.cpp @@ -217,13 +217,15 @@ bool TransferListSortModel::matchStatusFilter(int sourceRow, const QModelIndex & case TorrentFilter::COMPLETED: return (state == TorrentModelItem::STATE_SEEDING || state == TorrentModelItem::STATE_STALLED_UP || state == TorrentModelItem::STATE_PAUSED_UP || state == TorrentModelItem::STATE_CHECKING_UP - || state == TorrentModelItem::STATE_QUEUED_UP); + || state == TorrentModelItem::STATE_PAUSED_MISSING || state == TorrentModelItem::STATE_QUEUED_UP); case TorrentFilter::PAUSED: - return (state == TorrentModelItem::STATE_PAUSED_UP || state == TorrentModelItem::STATE_PAUSED_DL); + return (state == TorrentModelItem::STATE_PAUSED_UP || state == TorrentModelItem::STATE_PAUSED_DL + || state == TorrentModelItem::STATE_PAUSED_MISSING); case TorrentFilter::RESUMED: - return (state != TorrentModelItem::STATE_PAUSED_UP && state != TorrentModelItem::STATE_PAUSED_DL); + return (state != TorrentModelItem::STATE_PAUSED_UP && state != TorrentModelItem::STATE_PAUSED_DL + && state != TorrentModelItem::STATE_PAUSED_MISSING); case TorrentFilter::ACTIVE: if (state == TorrentModelItem::STATE_STALLED_DL) {