diff --git a/src/webui/www/private/index.html b/src/webui/www/private/index.html
index 47fa063e9..e51eff5fc 100644
--- a/src/webui/www/private/index.html
+++ b/src/webui/www/private/index.html
@@ -269,6 +269,7 @@
QBT_TR(Normal)QBT_TR[CONTEXT=PropListDelegate]
QBT_TR(High)QBT_TR[CONTEXT=PropListDelegate]
QBT_TR(Maximum)QBT_TR[CONTEXT=PropListDelegate]
+ QBT_TR(By shown file order)QBT_TR[CONTEXT=PropListDelegate]
diff --git a/src/webui/www/private/scripts/dynamicTable.js b/src/webui/www/private/scripts/dynamicTable.js
index 032a79a1e..02988cbb6 100644
--- a/src/webui/www/private/scripts/dynamicTable.js
+++ b/src/webui/www/private/scripts/dynamicTable.js
@@ -3034,14 +3034,6 @@ window.qBittorrent.DynamicTable ??= (() => {
return rows;
}
- setIgnored(rowId, ignore) {
- const row = this.rows.get(rowId.toString());
- if (ignore)
- row.full_data.remaining = 0;
- else
- row.full_data.remaining = (row.full_data.size * (1.0 - (row.full_data.progress / 100)));
- }
-
setupCommonEvents() {
super.setupCommonEvents();
this.dynamicTableDiv.addEventListener("keydown", (e) => {
diff --git a/src/webui/www/private/scripts/prop-files.js b/src/webui/www/private/scripts/prop-files.js
index b0242a9aa..a5e0eac71 100644
--- a/src/webui/www/private/scripts/prop-files.js
+++ b/src/webui/www/private/scripts/prop-files.js
@@ -47,6 +47,7 @@ window.qBittorrent.PropFiles ??= (() => {
const TriState = window.qBittorrent.FileTree.TriState;
let is_seed = true;
let current_hash = "";
+ const BY_SHOWN_ORDER = -2;
const normalizePriority = (priority) => {
switch (priority) {
@@ -105,7 +106,7 @@ window.qBittorrent.PropFiles ??= (() => {
const rows = getAllChildren(id, fileId);
- setFilePriority(rows.rowIds, rows.fileIds, priority);
+ setFilePriority(rows.fileIds, priority);
updateGlobalCheckbox();
};
@@ -117,7 +118,7 @@ window.qBittorrent.PropFiles ??= (() => {
const rows = getAllChildren(id, fileId);
- setFilePriority(rows.rowIds, rows.fileIds, priority);
+ setFilePriority(rows.fileIds, priority);
updateGlobalCheckbox();
};
@@ -241,7 +242,7 @@ window.qBittorrent.PropFiles ??= (() => {
}
if (rowIds.length > 0)
- setFilePriority(rowIds, fileIds, priority);
+ setFilePriority(fileIds, priority);
};
const updateGlobalCheckbox = () => {
@@ -271,7 +272,7 @@ window.qBittorrent.PropFiles ??= (() => {
checkbox.indeterminate = true;
};
- const setFilePriority = (ids, fileIds, priority) => {
+ const setFilePriority = (fileIds, priority) => {
if (current_hash === "")
return;
@@ -292,15 +293,6 @@ window.qBittorrent.PropFiles ??= (() => {
loadTorrentFilesDataTimer = loadTorrentFilesData.delay(1000);
});
-
- const ignore = (priority === FilePriority.Ignored);
- ids.forEach((id) => {
- torrentFilesTable.setIgnored(id, ignore);
-
- const combobox = document.getElementById(`comboPrio${id}`);
- if (combobox !== null)
- selectComboboxPriority(combobox, priority);
- });
};
let loadTorrentFilesDataTimer = -1;
@@ -459,26 +451,64 @@ window.qBittorrent.PropFiles ??= (() => {
if (selectedRows.length === 0)
return;
- const rowIds = [];
const fileIds = [];
+ const fillInChildren = (rowId, fileId) => {
+ const children = getAllChildren(rowId, fileId);
+ children.fileIds.forEach((childFileId, index) => {
+ if (fileId === -1) {
+ fillInChildren(children.rowIds[index], childFileId);
+ return;
+ }
+ if (!fileIds.includes(childFileId))
+ fileIds.push(childFileId);
+ });
+ };
+
selectedRows.forEach((rowId) => {
- rowIds.push(rowId);
- fileIds.push(torrentFilesTable.getRowFileId(rowId));
+ const fileId = torrentFilesTable.getRowFileId(rowId);
+ if (fileId !== -1)
+ fileIds.push(fileId);
+ fillInChildren(rowId, fileId);
});
- const uniqueRowIds = {};
- const uniqueFileIds = {};
- for (let i = 0; i < rowIds.length; ++i) {
- const rows = getAllChildren(rowIds[i], fileIds[i]);
- rows.rowIds.forEach((rowId) => {
- uniqueRowIds[rowId] = true;
- });
- rows.fileIds.forEach((fileId) => {
- uniqueFileIds[fileId] = true;
- });
+ // Will be used both in general case and ByShownOrder case
+ const priorityList = {};
+ Object.values(FilePriority).forEach((p) => {
+ priorityList[p] = [];
+ });
+ const groupsNum = 3;
+ const priorityGroupSize = Math.max(Math.floor(fileIds.length / groupsNum), 1);
+
+ // Will be altered only if we select ByShownOrder, use whatever is passed otherwise
+ let priorityGroup = priority;
+ let fileId = 0;
+ for (let i = 0; i < fileIds.length; ++i) {
+ fileId = fileIds[i];
+ if (priority === BY_SHOWN_ORDER) {
+ switch (Math.floor(i / priorityGroupSize)) {
+ case 0:
+ priorityGroup = FilePriority.Maximum;
+ break;
+ case 1:
+ priorityGroup = FilePriority.High;
+ break;
+ default:
+ case 2:
+ priorityGroup = FilePriority.Normal;
+ break;
+ }
+ }
+ priorityList[priorityGroup].push(fileId);
}
- setFilePriority(Object.keys(uniqueRowIds), Object.keys(uniqueFileIds), priority);
+ Object.entries(priorityList).forEach(([groupPriority, groupedFiles]) => {
+ if (groupedFiles.length === 0)
+ return;
+ setFilePriority(
+ groupedFiles,
+ groupPriority
+ );
+ });
};
const singleFileRename = (hash) => {
@@ -553,6 +583,9 @@ window.qBittorrent.PropFiles ??= (() => {
},
FilePrioMaximum: (element, ref) => {
filesPriorityMenuClicked(FilePriority.Maximum);
+ },
+ FilePrioByShownOrder: (element, ref) => {
+ filesPriorityMenuClicked(BY_SHOWN_ORDER);
}
},
offsets: {