mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-06 13:11:25 -07:00
parent
e06b7f8f4d
commit
6df1f68ead
3 changed files with 50 additions and 31 deletions
|
@ -483,14 +483,10 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const all = torrentsTable.getRowIds().length;
|
const all = torrentsTable.rows.size;
|
||||||
let uncategorized = 0;
|
let uncategorized = 0;
|
||||||
for (const key in torrentsTable.rows) {
|
for (const { full_data: { category } } of torrentsTable.rows.values()) {
|
||||||
if (!Object.hasOwn(torrentsTable.rows, key))
|
if (category.length === 0)
|
||||||
continue;
|
|
||||||
|
|
||||||
const row = torrentsTable.rows[key];
|
|
||||||
if (row["full_data"].category.length === 0)
|
|
||||||
uncategorized += 1;
|
uncategorized += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -585,12 +581,13 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||||
return tagFilterItem;
|
return tagFilterItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
const torrentsCount = torrentsTable.getRowIds().length;
|
const torrentsCount = torrentsTable.rows.size;
|
||||||
let untagged = 0;
|
let untagged = 0;
|
||||||
for (const key in torrentsTable.rows) {
|
for (const { full_data: { tags } } of torrentsTable.rows.values()) {
|
||||||
if (Object.hasOwn(torrentsTable.rows, key) && (torrentsTable.rows[key]["full_data"].tags.length === 0))
|
if (tags.length === 0)
|
||||||
untagged += 1;
|
untagged += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tagFilterList.appendChild(createLink(TAGS_ALL, "QBT_TR(All)QBT_TR[CONTEXT=TagFilterModel]", torrentsCount));
|
tagFilterList.appendChild(createLink(TAGS_ALL, "QBT_TR(All)QBT_TR[CONTEXT=TagFilterModel]", torrentsCount));
|
||||||
tagFilterList.appendChild(createLink(TAGS_UNTAGGED, "QBT_TR(Untagged)QBT_TR[CONTEXT=TagFilterModel]", untagged));
|
tagFilterList.appendChild(createLink(TAGS_UNTAGGED, "QBT_TR(Untagged)QBT_TR[CONTEXT=TagFilterModel]", untagged));
|
||||||
|
|
||||||
|
@ -637,13 +634,14 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||||
return trackerFilterItem;
|
return trackerFilterItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
const torrentsCount = torrentsTable.getRowIds().length;
|
const torrentsCount = torrentsTable.rows.size;
|
||||||
trackerFilterList.appendChild(createLink(TRACKERS_ALL, "QBT_TR(All (%1))QBT_TR[CONTEXT=TrackerFiltersList]", torrentsCount));
|
|
||||||
let trackerlessTorrentsCount = 0;
|
let trackerlessTorrentsCount = 0;
|
||||||
for (const key in torrentsTable.rows) {
|
for (const { full_data: { trackers_count: trackersCount } } of torrentsTable.rows.values()) {
|
||||||
if (Object.hasOwn(torrentsTable.rows, key) && (torrentsTable.rows[key]["full_data"].trackers_count === 0))
|
if (trackersCount === 0)
|
||||||
trackerlessTorrentsCount += 1;
|
trackerlessTorrentsCount += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trackerFilterList.appendChild(createLink(TRACKERS_ALL, "QBT_TR(All (%1))QBT_TR[CONTEXT=TrackerFiltersList]", torrentsCount));
|
||||||
trackerFilterList.appendChild(createLink(TRACKERS_TRACKERLESS, "QBT_TR(Trackerless (%1))QBT_TR[CONTEXT=TrackerFiltersList]", trackerlessTorrentsCount));
|
trackerFilterList.appendChild(createLink(TRACKERS_TRACKERLESS, "QBT_TR(Trackerless (%1))QBT_TR[CONTEXT=TrackerFiltersList]", trackerlessTorrentsCount));
|
||||||
|
|
||||||
// Sort trackers by hostname
|
// Sort trackers by hostname
|
||||||
|
|
|
@ -898,6 +898,11 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
const TorrentsTable = new Class({
|
const TorrentsTable = new Class({
|
||||||
Extends: DynamicTable,
|
Extends: DynamicTable,
|
||||||
|
|
||||||
|
setup: function(dynamicTableDivId, dynamicTableFixedHeaderDivId, contextMenu) {
|
||||||
|
this.parent(dynamicTableDivId, dynamicTableFixedHeaderDivId, contextMenu);
|
||||||
|
this.rows = new Map();
|
||||||
|
},
|
||||||
|
|
||||||
initColumns: function() {
|
initColumns: function() {
|
||||||
this.newColumn("priority", "", "#", 30, true);
|
this.newColumn("priority", "", "#", 30, true);
|
||||||
this.newColumn("state_icon", "cursor: default", "", 22, true);
|
this.newColumn("state_icon", "cursor: default", "", 22, true);
|
||||||
|
@ -1504,12 +1509,30 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
removeRow: function(rowId) {
|
||||||
|
this.selectedRows.erase(rowId);
|
||||||
|
this.rows.delete(rowId);
|
||||||
|
const tr = this.getTrByRowId(rowId);
|
||||||
|
tr?.destroy();
|
||||||
|
},
|
||||||
|
|
||||||
|
clear: function() {
|
||||||
|
this.deselectAll();
|
||||||
|
this.rows.clear();
|
||||||
|
const trs = this.tableBody.getElements("tr");
|
||||||
|
while (trs.length > 0)
|
||||||
|
trs.pop().destroy();
|
||||||
|
},
|
||||||
|
|
||||||
|
getRowIds: function() {
|
||||||
|
return this.rows.keys();
|
||||||
|
},
|
||||||
|
|
||||||
getFilteredTorrentsNumber: function(filterName, categoryHash, tagHash, trackerHash) {
|
getFilteredTorrentsNumber: function(filterName, categoryHash, tagHash, trackerHash) {
|
||||||
let cnt = 0;
|
let cnt = 0;
|
||||||
const rows = this.rows.getValues();
|
|
||||||
|
|
||||||
for (let i = 0; i < rows.length; ++i) {
|
for (const row of this.rows.values()) {
|
||||||
if (this.applyFilter(rows[i], filterName, categoryHash, tagHash, trackerHash, null))
|
if (this.applyFilter(row, filterName, categoryHash, tagHash, trackerHash, null))
|
||||||
++cnt;
|
++cnt;
|
||||||
}
|
}
|
||||||
return cnt;
|
return cnt;
|
||||||
|
@ -1517,11 +1540,10 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
|
|
||||||
getFilteredTorrentsHashes: function(filterName, categoryHash, tagHash, trackerHash) {
|
getFilteredTorrentsHashes: function(filterName, categoryHash, tagHash, trackerHash) {
|
||||||
const rowsHashes = [];
|
const rowsHashes = [];
|
||||||
const rows = this.rows.getValues();
|
|
||||||
|
|
||||||
for (let i = 0; i < rows.length; ++i) {
|
for (const row of this.rows.values()) {
|
||||||
if (this.applyFilter(rows[i], filterName, categoryHash, tagHash, trackerHash, null))
|
if (this.applyFilter(row, filterName, categoryHash, tagHash, trackerHash, null))
|
||||||
rowsHashes.push(rows[i]["rowId"]);
|
rowsHashes.push(row["rowId"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rowsHashes;
|
return rowsHashes;
|
||||||
|
@ -1542,11 +1564,10 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
return filteredRows;
|
return filteredRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rows = this.rows.getValues();
|
for (const row of this.rows.values()) {
|
||||||
for (let i = 0; i < rows.length; ++i) {
|
if (this.applyFilter(row, selectedStatus, selectedCategory, selectedTag, selectedTracker, filterTerms)) {
|
||||||
if (this.applyFilter(rows[i], selectedStatus, selectedCategory, selectedTag, selectedTracker, filterTerms)) {
|
filteredRows.push(row);
|
||||||
filteredRows.push(rows[i]);
|
filteredRows[row.rowId] = row;
|
||||||
filteredRows[rows[i].rowId] = rows[i];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -295,7 +295,7 @@ const initializeWindows = function() {
|
||||||
// check if all selected torrents have same share ratio
|
// check if all selected torrents have same share ratio
|
||||||
for (let i = 0; i < hashes.length; ++i) {
|
for (let i = 0; i < hashes.length; ++i) {
|
||||||
const hash = hashes[i];
|
const hash = hashes[i];
|
||||||
const row = torrentsTable.rows[hash].full_data;
|
const row = torrentsTable.rows.get(hash).full_data;
|
||||||
const origValues = row.ratio_limit + "|" + row.seeding_time_limit + "|" + row.inactive_seeding_time_limit + "|"
|
const origValues = row.ratio_limit + "|" + row.seeding_time_limit + "|" + row.inactive_seeding_time_limit + "|"
|
||||||
+ row.max_ratio + "|" + row.max_seeding_time + "|" + row.max_inactive_seeding_time;
|
+ row.max_ratio + "|" + row.max_seeding_time + "|" + row.max_inactive_seeding_time;
|
||||||
|
|
||||||
|
@ -522,7 +522,7 @@ const initializeWindows = function() {
|
||||||
if (hashes.length) {
|
if (hashes.length) {
|
||||||
let enable = false;
|
let enable = false;
|
||||||
hashes.each((hash, index) => {
|
hashes.each((hash, index) => {
|
||||||
const row = torrentsTable.rows[hash];
|
const row = torrentsTable.rows.get(hash);
|
||||||
if (!row.full_data.auto_tmm)
|
if (!row.full_data.auto_tmm)
|
||||||
enable = true;
|
enable = true;
|
||||||
});
|
});
|
||||||
|
@ -570,7 +570,7 @@ const initializeWindows = function() {
|
||||||
const hashes = torrentsTable.selectedRowsIds();
|
const hashes = torrentsTable.selectedRowsIds();
|
||||||
if (hashes.length) {
|
if (hashes.length) {
|
||||||
const hash = hashes[0];
|
const hash = hashes[0];
|
||||||
const row = torrentsTable.rows[hash];
|
const row = torrentsTable.rows.get(hash);
|
||||||
|
|
||||||
new MochaUI.Window({
|
new MochaUI.Window({
|
||||||
id: "setLocationPage",
|
id: "setLocationPage",
|
||||||
|
@ -593,7 +593,7 @@ const initializeWindows = function() {
|
||||||
const hashes = torrentsTable.selectedRowsIds();
|
const hashes = torrentsTable.selectedRowsIds();
|
||||||
if (hashes.length === 1) {
|
if (hashes.length === 1) {
|
||||||
const hash = hashes[0];
|
const hash = hashes[0];
|
||||||
const row = torrentsTable.rows[hash];
|
const row = torrentsTable.rows.get(hash);
|
||||||
if (row) {
|
if (row) {
|
||||||
new MochaUI.Window({
|
new MochaUI.Window({
|
||||||
id: "renamePage",
|
id: "renamePage",
|
||||||
|
@ -617,7 +617,7 @@ const initializeWindows = function() {
|
||||||
const hashes = torrentsTable.selectedRowsIds();
|
const hashes = torrentsTable.selectedRowsIds();
|
||||||
if (hashes.length === 1) {
|
if (hashes.length === 1) {
|
||||||
const hash = hashes[0];
|
const hash = hashes[0];
|
||||||
const row = torrentsTable.rows[hash];
|
const row = torrentsTable.rows.get(hash);
|
||||||
if (row) {
|
if (row) {
|
||||||
new MochaUI.Window({
|
new MochaUI.Window({
|
||||||
id: "multiRenamePage",
|
id: "multiRenamePage",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue