mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-17 06:01:33 -06:00
WebUI: Select multiple files to rename with Shift
Convenience feature in the "Rename Files" menu in the WebUI. If you click one file's checkbox, and then click another with Shift held, all the checkboxes between those two will be selected/unselected based on the state of the first checkbox. It's based on what the Windows file explorer does when holding Ctrl and Shift Closes #22455. PR #22610.
This commit is contained in:
@@ -2185,6 +2185,7 @@ window.qBittorrent.DynamicTable ??= (() => {
|
|||||||
prevFilteredRows = [];
|
prevFilteredRows = [];
|
||||||
prevSortedColumn = null;
|
prevSortedColumn = null;
|
||||||
prevReverseSort = null;
|
prevReverseSort = null;
|
||||||
|
prevCheckboxNum = null;
|
||||||
fileTree = new window.qBittorrent.FileTree.FileTree();
|
fileTree = new window.qBittorrent.FileTree.FileTree();
|
||||||
|
|
||||||
setupVirtualList() {
|
setupVirtualList() {
|
||||||
@@ -2344,13 +2345,41 @@ window.qBittorrent.DynamicTable ??= (() => {
|
|||||||
checkbox.type = "checkbox";
|
checkbox.type = "checkbox";
|
||||||
checkbox.className = "RenamingCB";
|
checkbox.className = "RenamingCB";
|
||||||
checkbox.addEventListener("click", (e) => {
|
checkbox.addEventListener("click", (e) => {
|
||||||
const id = e.target.dataset.id;
|
e.stopPropagation();
|
||||||
|
const targetId = e.target.dataset.id;
|
||||||
|
const ids = [];
|
||||||
|
// when holding shift, set all files between the previously selected one and the clicked one
|
||||||
|
if (e.shiftKey && (that.prevCheckboxNum !== null) && (targetId !== that.prevCheckboxNum)) {
|
||||||
|
const targetState = that.tableBody.querySelector(`.RenamingCB[data-id="${that.prevCheckboxNum}"]`).checked;
|
||||||
|
const checkboxes = that.tableBody.getElementsByClassName("RenamingCB");
|
||||||
|
let started = false;
|
||||||
|
for (const cb of checkboxes) {
|
||||||
|
const currId = cb.dataset.id;
|
||||||
|
if ((currId === targetId) || (currId === that.prevCheckboxNum)) {
|
||||||
|
if (started) {
|
||||||
|
ids.push(currId);
|
||||||
|
cb.checked = targetState;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
started = true;
|
||||||
|
}
|
||||||
|
if (started) {
|
||||||
|
ids.push(currId);
|
||||||
|
cb.checked = targetState;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ids.push(targetId);
|
||||||
|
}
|
||||||
|
for (const id of ids) {
|
||||||
const node = that.getNode(id);
|
const node = that.getNode(id);
|
||||||
node.checked = e.target.checked ? 0 : 1;
|
node.checked = e.target.checked ? 0 : 1;
|
||||||
node.full_data.checked = node.checked;
|
node.full_data.checked = node.checked;
|
||||||
|
}
|
||||||
that.updateGlobalCheckbox();
|
that.updateGlobalCheckbox();
|
||||||
that.onRowSelectionChange(node);
|
that.onRowSelectionChange(that.getNode(targetId));
|
||||||
e.stopPropagation();
|
that.prevCheckboxNum = targetId;
|
||||||
});
|
});
|
||||||
checkbox.indeterminate = false;
|
checkbox.indeterminate = false;
|
||||||
td.append(checkbox);
|
td.append(checkbox);
|
||||||
|
|||||||
Reference in New Issue
Block a user