Add metadata check and address PR comments.

This commit is contained in:
Stiliyan Tonev (Bark) 2025-01-10 10:43:21 +02:00
commit 44b0a59fde

View file

@ -194,7 +194,7 @@ QVariant TransferListModel::headerData(const int section, const Qt::Orientation
case TR_INFOHASH_V2: return tr("Info Hash v2", "i.e: torrent info hash v2"); case TR_INFOHASH_V2: return tr("Info Hash v2", "i.e: torrent info hash v2");
case TR_REANNOUNCE: return tr("Reannounce In", "Indicates the time until next trackers reannounce"); case TR_REANNOUNCE: return tr("Reannounce In", "Indicates the time until next trackers reannounce");
case TR_PRIVATE: return tr("Private", "Flags private torrents"); case TR_PRIVATE: return tr("Private", "Flags private torrents");
case TR_PERCENT_SELECTED: return tr("% Selected", "Percentage of torrent selected"); case TR_PERCENT_SELECTED: return tr("% Selected Data", "Percentage of selected data to download.");
default: return {}; default: return {};
} }
} }
@ -445,6 +445,8 @@ QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, cons
case TR_PRIVATE: case TR_PRIVATE:
return privateString(torrent->isPrivate(), torrent->hasMetadata()); return privateString(torrent->isPrivate(), torrent->hasMetadata());
case TR_PERCENT_SELECTED: case TR_PERCENT_SELECTED:
if (!torrent->hasMetadata())
return tr("N/A");
return QString::number((torrent->wantedSize() * 100) / torrent->totalSize()) + u'%'; return QString::number((torrent->wantedSize() * 100) / torrent->totalSize()) + u'%';
} }
@ -530,6 +532,8 @@ QVariant TransferListModel::internalValue(const BitTorrent::Torrent *torrent, co
case TR_PRIVATE: case TR_PRIVATE:
return (torrent->hasMetadata() ? torrent->isPrivate() : QVariant()); return (torrent->hasMetadata() ? torrent->isPrivate() : QVariant());
case TR_PERCENT_SELECTED: case TR_PERCENT_SELECTED:
if (!torrent->hasMetadata())
return 0;
return (torrent->wantedSize() * 100) / torrent->totalSize(); return (torrent->wantedSize() * 100) / torrent->totalSize();
} }