Pass number to WebUI instead of text and use float when comparing.

This commit is contained in:
Stiliyan Tonev (Bark) 2025-01-10 14:34:02 +02:00
commit b70d824854
3 changed files with 23 additions and 1 deletions

View file

@ -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;

View file

@ -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.)
};
}

View file

@ -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) {