diff --git a/src/gui/transferlistsortmodel.cpp b/src/gui/transferlistsortmodel.cpp index ff0ad35a1..45199553d 100644 --- a/src/gui/transferlistsortmodel.cpp +++ b/src/gui/transferlistsortmodel.cpp @@ -208,7 +208,6 @@ 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: @@ -243,6 +242,9 @@ int TransferListSortModel::compare(const QModelIndex &left, const QModelIndex &r return threeWayCompare(totalL, totalR); } + case TransferListModel::TR_PERCENT_SELECTED: + return customCompare(leftValue.toFloat(), rightValue.toFloat()); + default: Q_ASSERT_X(false, Q_FUNC_INFO, "Missing comparison case"); break; diff --git a/src/webui/api/serialize/serialize_torrent.cpp b/src/webui/api/serialize/serialize_torrent.cpp index 94c83a934..1515b55c7 100644 --- a/src/webui/api/serialize/serialize_torrent.cpp +++ b/src/webui/api/serialize/serialize_torrent.cpp @@ -178,6 +178,14 @@ QVariantMap serialize(const BitTorrent::Torrent &torrent) {KEY_TORRENT_LAST_ACTIVITY_TIME, getLastActivityTime()}, {KEY_TORRENT_AVAILABILITY, torrent.distributedCopies()}, {KEY_TORRENT_REANNOUNCE, torrent.nextAnnounce()}, +<<<<<<< HEAD {KEY_TORRENT_COMMENT, torrent.comment()} +======= + {KEY_TORRENT_COMMENT, torrent.comment()}, + {KEY_TORRENT_PRIVATE, (torrent.hasMetadata() ? torrent.isPrivate() : QVariant())}, + {KEY_TORRENT_TOTAL_SIZE, torrent.totalSize()}, + {KEY_TORRENT_HAS_METADATA, torrent.hasMetadata()}, + {KEY_TORRENT_PERCENT_SELECTED, torrent.hasMetadata() ? (torrent.wantedSize() * 100) / torrent.totalSize() : -1}, +>>>>>>> ba7b726ce (Pass number to WebUI instead of text and use float when comparing.) }; } diff --git a/src/webui/www/private/scripts/dynamicTable.js b/src/webui/www/private/scripts/dynamicTable.js index 3c7a828c4..6173942ce 100644 --- a/src/webui/www/private/scripts/dynamicTable.js +++ b/src/webui/www/private/scripts/dynamicTable.js @@ -1555,6 +1555,18 @@ window.qBittorrent.DynamicTable ??= (() => { td.textContent = string; td.title = string; }; + + // percent_selected + this.columns["percent_selected"].updateTd = function(td, row) { + if (this.getRowValue(row) === -1) { + td.textContent = "QBT_TR(N/A)QBT_TR[CONTEXT=TrackerListWidget]"; + td.title = "QBT_TR(N/A)QBT_TR[CONTEXT=TrackerListWidget]"; + return; + } + const value = window.qBittorrent.Misc.toFixedPointString(this.getRowValue(row), 2) + "%"; + td.textContent = value; + td.title = value; + }; } applyFilter(row, filterName, category, tag, trackerHost, filterTerms) {