mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-12 15:57:57 +00:00
Merge pull request #7997 from Piccirello/webui-content-columns
Add "Remaining" and "Availability" columns to webui Content tab
This commit is contained in:
commit
94b64884f8
@ -182,6 +182,7 @@ static const char KEY_FILE_PROGRESS[] = "progress";
|
|||||||
static const char KEY_FILE_PRIORITY[] = "priority";
|
static const char KEY_FILE_PRIORITY[] = "priority";
|
||||||
static const char KEY_FILE_IS_SEED[] = "is_seed";
|
static const char KEY_FILE_IS_SEED[] = "is_seed";
|
||||||
static const char KEY_FILE_PIECE_RANGE[] = "piece_range";
|
static const char KEY_FILE_PIECE_RANGE[] = "piece_range";
|
||||||
|
static const char KEY_FILE_AVAILABILITY[] = "availability";
|
||||||
|
|
||||||
// TransferInfo keys
|
// TransferInfo keys
|
||||||
static const char KEY_TRANSFER_DLSPEED[] = "dl_info_speed";
|
static const char KEY_TRANSFER_DLSPEED[] = "dl_info_speed";
|
||||||
@ -954,12 +955,14 @@ QByteArray btjson::getFilesForTorrent(const QString& hash)
|
|||||||
|
|
||||||
const QVector<int> priorities = torrent->filePriorities();
|
const QVector<int> priorities = torrent->filePriorities();
|
||||||
const QVector<qreal> fp = torrent->filesProgress();
|
const QVector<qreal> fp = torrent->filesProgress();
|
||||||
|
const QVector<qreal> fileAvailability = torrent->availableFileFractions();
|
||||||
const BitTorrent::TorrentInfo info = torrent->info();
|
const BitTorrent::TorrentInfo info = torrent->info();
|
||||||
for (int i = 0; i < torrent->filesCount(); ++i) {
|
for (int i = 0; i < torrent->filesCount(); ++i) {
|
||||||
QVariantMap fileDict;
|
QVariantMap fileDict;
|
||||||
fileDict[KEY_FILE_PROGRESS] = fp[i];
|
fileDict[KEY_FILE_PROGRESS] = fp[i];
|
||||||
fileDict[KEY_FILE_PRIORITY] = priorities[i];
|
fileDict[KEY_FILE_PRIORITY] = priorities[i];
|
||||||
fileDict[KEY_FILE_SIZE] = torrent->fileSize(i);
|
fileDict[KEY_FILE_SIZE] = torrent->fileSize(i);
|
||||||
|
fileDict[KEY_FILE_AVAILABILITY] = fileAvailability[i];
|
||||||
|
|
||||||
QString fileName = torrent->filePath(i);
|
QString fileName = torrent->filePath(i);
|
||||||
if (fileName.endsWith(QB_EXT, Qt::CaseInsensitive))
|
if (fileName.endsWith(QB_EXT, Qt::CaseInsensitive))
|
||||||
|
@ -105,7 +105,9 @@
|
|||||||
<th>QBT_TR(Name)QBT_TR[CONTEXT=TorrentContentModel]</th>
|
<th>QBT_TR(Name)QBT_TR[CONTEXT=TorrentContentModel]</th>
|
||||||
<th style="width: 150px;">QBT_TR(Size)QBT_TR[CONTEXT=TorrentContentModel]</th>
|
<th style="width: 150px;">QBT_TR(Size)QBT_TR[CONTEXT=TorrentContentModel]</th>
|
||||||
<th style="width: 90px;">QBT_TR(Progress)QBT_TR[CONTEXT=TorrentContentModel]</th>
|
<th style="width: 90px;">QBT_TR(Progress)QBT_TR[CONTEXT=TorrentContentModel]</th>
|
||||||
<th style="width: 150px; border-right: 0">QBT_TR(Download Priority)QBT_TR[CONTEXT=TorrentContentModel]</th>
|
<th style="width: 150px;">QBT_TR(Download Priority)QBT_TR[CONTEXT=TorrentContentModel]</th>
|
||||||
|
<th style="width: 150px;">QBT_TR(Remaining)QBT_TR[CONTEXT=TorrentContentModel]</th>
|
||||||
|
<th style="width: 150px; border-right: 0">QBT_TR(Availability)QBT_TR[CONTEXT=TorrentContentModel]</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="filesTable"></tbody>
|
<tbody id="filesTable"></tbody>
|
||||||
|
@ -30,9 +30,12 @@ function friendlyUnit(value, isSpeed) {
|
|||||||
var ret;
|
var ret;
|
||||||
if (i === 0)
|
if (i === 0)
|
||||||
ret = value + " " + units[i];
|
ret = value + " " + units[i];
|
||||||
else
|
else {
|
||||||
ret = (Math.floor(10 * value) / 10).toFixed(friendlyUnitPrecision(i)) //Don't round up
|
var precision = friendlyUnitPrecision(i);
|
||||||
+ " " + units[i];
|
var offset = Math.pow(10, precision);
|
||||||
|
// Don't round up
|
||||||
|
ret = (Math.floor(offset * value) / offset).toFixed(precision) + " " + units[i];
|
||||||
|
}
|
||||||
|
|
||||||
if (isSpeed)
|
if (isSpeed)
|
||||||
ret += "QBT_TR(/s)QBT_TR[CONTEXT=misc]";
|
ret += "QBT_TR(/s)QBT_TR[CONTEXT=misc]";
|
||||||
@ -64,6 +67,15 @@ function friendlyDuration(seconds) {
|
|||||||
return "∞";
|
return "∞";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function friendlyPercentage(value) {
|
||||||
|
var percentage = (value * 100).round(1);
|
||||||
|
if (isNaN(percentage) || (percentage < 0))
|
||||||
|
percentage = 0;
|
||||||
|
if (percentage > 100)
|
||||||
|
percentage = 100;
|
||||||
|
return percentage.toFixed(1) + "%";
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* From: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
|
* From: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
|
||||||
*/
|
*/
|
||||||
|
@ -78,8 +78,8 @@ function ProgressBar_setValue(value) {
|
|||||||
this.vals.value = value;
|
this.vals.value = value;
|
||||||
this.vals.dark.empty();
|
this.vals.dark.empty();
|
||||||
this.vals.light.empty();
|
this.vals.light.empty();
|
||||||
this.vals.dark.appendText(value + '%');
|
this.vals.dark.appendText(value.round(1).toFixed(1) + '%');
|
||||||
this.vals.light.appendText(value + '%');
|
this.vals.light.appendText(value.round(1).toFixed(1) + '%');
|
||||||
var r = parseInt(this.vals.width * (value / 100));
|
var r = parseInt(this.vals.width * (value / 100));
|
||||||
this.vals.dark.setStyle('clip', 'rect(0,' + r + 'px,' + this.vals.height + 'px,0)');
|
this.vals.dark.setStyle('clip', 'rect(0,' + r + 'px,' + this.vals.height + 'px,0)');
|
||||||
this.vals.light.setStyle('clip', 'rect(0,' + this.vals.width + 'px,' + this.vals.height + 'px,' + r + 'px)');
|
this.vals.light.setStyle('clip', 'rect(0,' + this.vals.width + 'px,' + this.vals.height + 'px,' + r + 'px)');
|
||||||
|
@ -317,6 +317,9 @@ var loadTorrentFilesData = function() {
|
|||||||
if (row[3] == 100.0 && file.progress < 1.0)
|
if (row[3] == 100.0 && file.progress < 1.0)
|
||||||
row[3] = 99.9;
|
row[3] = 99.9;
|
||||||
row[4] = file.priority;
|
row[4] = file.priority;
|
||||||
|
row[5] = friendlyUnit(file.size * (1.0 - file.progress));
|
||||||
|
row[6] = friendlyPercentage(file.availability);
|
||||||
|
|
||||||
fTable.insertRow(i, row);
|
fTable.insertRow(i, row);
|
||||||
i++;
|
i++;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
Loading…
Reference in New Issue
Block a user