From b6050463f44e38c1cf9623af377b01223cca07e1 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Tue, 26 Nov 2019 02:40:31 +0800 Subject: [PATCH] Show torrent error message in transfer list --- src/gui/transferlistdelegate.cpp | 3 +++ src/gui/transferlistmodel.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/transferlistdelegate.cpp b/src/gui/transferlistdelegate.cpp index ffc2edbf0..cca617a9b 100644 --- a/src/gui/transferlistdelegate.cpp +++ b/src/gui/transferlistdelegate.cpp @@ -100,7 +100,10 @@ void TransferListDelegate::paint(QPainter *painter, const QStyleOptionViewItem & break; case TransferListModel::TR_STATUS: { const auto state = index.data().value(); + const QString errorMsg = index.data(Qt::UserRole).toString(); QString display = getStatusString(state); + if (state == BitTorrent::TorrentState::Error) + display += (": " + errorMsg); QItemDelegate::drawDisplay(painter, opt, opt.rect, display); } break; diff --git a/src/gui/transferlistmodel.cpp b/src/gui/transferlistmodel.cpp index 33fcdeea7..57492b353 100644 --- a/src/gui/transferlistmodel.cpp +++ b/src/gui/transferlistmodel.cpp @@ -184,7 +184,7 @@ QVariant TransferListModel::data(const QModelIndex &index, const int role) const case TR_PROGRESS: return torrent->progress(); case TR_STATUS: - return QVariant::fromValue(torrent->state()); + return (role == Qt::DisplayRole) ? QVariant::fromValue(torrent->state()) : torrent->error(); case TR_SEEDS: return (role == Qt::DisplayRole) ? torrent->seedsCount() : torrent->totalSeedsCount(); case TR_PEERS: