diff --git a/src/gui/transferlistmodel.cpp b/src/gui/transferlistmodel.cpp index 0298db047..f710dcd4d 100644 --- a/src/gui/transferlistmodel.cpp +++ b/src/gui/transferlistmodel.cpp @@ -194,6 +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_REANNOUNCE: return tr("Reannounce In", "Indicates the time until next trackers reannounce"); case TR_PRIVATE: return tr("Private", "Flags private torrents"); + case TR_PERCENT_SELECTED: return tr("% Selected", "Percentage of torrent selected"); default: return {}; } } @@ -443,8 +444,9 @@ QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, cons return reannounceString(torrent->nextAnnounce()); case TR_PRIVATE: return privateString(torrent->isPrivate(), torrent->hasMetadata()); + case TR_PERCENT_SELECTED: + return QString::number((torrent->wantedSize() * 100) / torrent->totalSize()) + u'%'; } - return {}; } @@ -526,6 +528,8 @@ QVariant TransferListModel::internalValue(const BitTorrent::Torrent *torrent, co return torrent->nextAnnounce(); case TR_PRIVATE: return (torrent->hasMetadata() ? torrent->isPrivate() : QVariant()); + case TR_PERCENT_SELECTED: + return (torrent->wantedSize() * 100) / torrent->totalSize(); } return {}; diff --git a/src/gui/transferlistmodel.h b/src/gui/transferlistmodel.h index 306beee0b..04f0b155d 100644 --- a/src/gui/transferlistmodel.h +++ b/src/gui/transferlistmodel.h @@ -87,6 +87,7 @@ public: TR_INFOHASH_V2, TR_REANNOUNCE, TR_PRIVATE, + TR_PERCENT_SELECTED, NB_COLUMNS }; diff --git a/src/gui/transferlistsortmodel.cpp b/src/gui/transferlistsortmodel.cpp index 782aead74..a097c4e1b 100644 --- a/src/gui/transferlistsortmodel.cpp +++ b/src/gui/transferlistsortmodel.cpp @@ -208,6 +208,7 @@ int TransferListSortModel::compare(const QModelIndex &left, const QModelIndex &r case TransferListModel::TR_RATIO: case TransferListModel::TR_RATIO_LIMIT: case TransferListModel::TR_POPULARITY: + case TransferListModel::TR_PERCENT_SELECTED: return customCompare(leftValue.toReal(), rightValue.toReal()); case TransferListModel::TR_STATUS: @@ -241,7 +242,6 @@ int TransferListSortModel::compare(const QModelIndex &left, const QModelIndex &r const auto totalR = right.data(TransferListModel::AdditionalUnderlyingDataRole).toInt(); return threeWayCompare(totalL, totalR); } - default: Q_ASSERT_X(false, Q_FUNC_INFO, "Missing comparison case"); break; diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index 6fb71bfaa..4f15b34a6 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -192,6 +192,7 @@ TransferListWidget::TransferListWidget(IGUIApplication *app, QWidget *parent) setColumnHidden(TransferListModel::TR_TOTAL_SIZE, true); setColumnHidden(TransferListModel::TR_REANNOUNCE, true); setColumnHidden(TransferListModel::TR_PRIVATE, true); + setColumnHidden(TransferListModel::TR_PERCENT_SELECTED, true); } //Ensure that at least one column is visible at all times diff --git a/src/webui/www/private/scripts/dynamicTable.js b/src/webui/www/private/scripts/dynamicTable.js index b0fa1a02e..3c7a828c4 100644 --- a/src/webui/www/private/scripts/dynamicTable.js +++ b/src/webui/www/private/scripts/dynamicTable.js @@ -1145,6 +1145,7 @@ window.qBittorrent.DynamicTable ??= (() => { this.newColumn("infohash_v2", "", "QBT_TR(Info Hash v2)QBT_TR[CONTEXT=TransferListModel]", 100, false); this.newColumn("reannounce", "", "QBT_TR(Reannounce In)QBT_TR[CONTEXT=TransferListModel]", 100, false); this.newColumn("private", "", "QBT_TR(Private)QBT_TR[CONTEXT=TransferListModel]", 100, false); + this.newColumn("percent_selected", "", "QBT_TR(Percent Selected)QBT_TR[CONTEXT=TransferListModel]", 100, false); this.columns["state_icon"].dataProperties[0] = "state"; this.columns["name"].dataProperties.push("state");