From 66795d533a7eb9bfcab2b74042f53b1e5c352173 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 9 Oct 2022 00:09:43 +0800 Subject: [PATCH] Show 'N/A' when there is no hash This is to follow 'General' tab which show 'N/A' when there is no hash. --- src/gui/transferlistmodel.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gui/transferlistmodel.cpp b/src/gui/transferlistmodel.cpp index 96ef1c44a..05a3b2118 100644 --- a/src/gui/transferlistmodel.cpp +++ b/src/gui/transferlistmodel.cpp @@ -374,6 +374,13 @@ QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, cons : m_statusStrings[state]; }; + const auto hashString = [hideValues](const auto &hash) -> QString + { + if (hideValues && !hash.isValid()) + return {}; + return hash.isValid() ? hash.toString() : tr("N/A"); + }; + switch (column) { case TR_NAME: @@ -441,9 +448,9 @@ QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, cons case TR_TOTAL_SIZE: return unitString(torrent->totalSize()); case TR_INFOHASH_V1: - return torrent->infoHash().v1().toString(); + return hashString(torrent->infoHash().v1()); case TR_INFOHASH_V2: - return torrent->infoHash().v2().toString(); + return hashString(torrent->infoHash().v2()); } return {};