Use subcategories unconditionally

PR #23585.
This commit is contained in:
Vladimir Golovnev
2025-12-16 21:56:15 +03:00
committed by GitHub
parent 260563d340
commit 93470f2080
17 changed files with 70 additions and 193 deletions

View File

@@ -174,7 +174,6 @@ void AppController::preferencesAction()
data[u"torrent_changed_tmm_enabled"_s] = !session->isDisableAutoTMMWhenCategoryChanged();
data[u"save_path_changed_tmm_enabled"_s] = !session->isDisableAutoTMMWhenDefaultSavePathChanged();
data[u"category_changed_tmm_enabled"_s] = !session->isDisableAutoTMMWhenCategorySavePathChanged();
data[u"use_subcategories"] = session->isSubcategoriesEnabled();
data[u"save_path"_s] = session->savePath().toString();
data[u"temp_path_enabled"_s] = session->isDownloadPathEnabled();
data[u"temp_path"_s] = session->downloadPath().toString();
@@ -593,8 +592,6 @@ void AppController::setPreferencesAction()
session->setDisableAutoTMMWhenDefaultSavePathChanged(!it.value().toBool());
if (hasKey(u"category_changed_tmm_enabled"_s))
session->setDisableAutoTMMWhenCategorySavePathChanged(!it.value().toBool());
if (hasKey(u"use_subcategories"_s))
session->setSubcategoriesEnabled(it.value().toBool());
if (hasKey(u"save_path"_s))
session->setSavePath(Path(it.value().toString()));
if (hasKey(u"temp_path_enabled"_s))

View File

@@ -56,7 +56,6 @@ namespace
const QString KEY_SYNC_MAINDATA_QUEUEING = u"queueing"_s;
const QString KEY_SYNC_MAINDATA_REFRESH_INTERVAL = u"refresh_interval"_s;
const QString KEY_SYNC_MAINDATA_USE_ALT_SPEED_LIMITS = u"use_alt_speed_limits"_s;
const QString KEY_SYNC_MAINDATA_USE_SUBCATEGORIES = u"use_subcategories"_s;
// Sync torrent peers keys
const QString KEY_SYNC_TORRENT_PEERS_SHOW_FLAGS = u"show_flags"_s;
@@ -617,7 +616,6 @@ void SyncController::makeMaindataSnapshot()
m_maindataSnapshot.serverState[KEY_SYNC_MAINDATA_QUEUEING] = session->isQueueingSystemEnabled();
m_maindataSnapshot.serverState[KEY_SYNC_MAINDATA_USE_ALT_SPEED_LIMITS] = session->isAltGlobalSpeedLimitEnabled();
m_maindataSnapshot.serverState[KEY_SYNC_MAINDATA_REFRESH_INTERVAL] = session->refreshInterval();
m_maindataSnapshot.serverState[KEY_SYNC_MAINDATA_USE_SUBCATEGORIES] = session->isSubcategoriesEnabled();
}
QJsonObject SyncController::generateMaindataSyncData(const int id, const bool fullUpdate)
@@ -771,7 +769,6 @@ QJsonObject SyncController::generateMaindataSyncData(const int id, const bool fu
serverState[KEY_SYNC_MAINDATA_QUEUEING] = session->isQueueingSystemEnabled();
serverState[KEY_SYNC_MAINDATA_USE_ALT_SPEED_LIMITS] = session->isAltGlobalSpeedLimitEnabled();
serverState[KEY_SYNC_MAINDATA_REFRESH_INTERVAL] = session->refreshInterval();
serverState[KEY_SYNC_MAINDATA_USE_SUBCATEGORIES] = session->isSubcategoriesEnabled();
if (const QVariantMap syncData = processMap(m_maindataSnapshot.serverState, serverState); !syncData.isEmpty())
{
m_maindataSyncBuf.serverState = syncData;

View File

@@ -57,7 +57,7 @@
using namespace std::chrono_literals;
inline const Utils::Version<3, 2> API_VERSION {2, 14, 1};
inline const Utils::Version<3, 2> API_VERSION {2, 15, 0};
class APIController;
class AuthController;

View File

@@ -222,7 +222,6 @@ let alternativeSpeedLimits = false;
let queueing_enabled = true;
let serverSyncMainDataInterval = 1500;
let customSyncMainDataInterval = null;
let useSubcategories = true;
const useAutoHideZeroStatusFilters = localPreferences.get("hide_zero_status_filters", "false") === "true";
const displayFullURLTrackerColumn = localPreferences.get("full_url_tracker_column", "false") === "true";
@@ -634,7 +633,7 @@ window.addEventListener("DOMContentLoaded", (event) => {
categoryName: category,
categoryCount: categoryData.torrents.size,
nameSegments: category.split("/"),
...(useSubcategories && {
...({
children: [],
isRoot: true,
forceExpand: localPreferences.get(`category_${category}_collapsed`) === null
@@ -659,32 +658,25 @@ window.addEventListener("DOMContentLoaded", (event) => {
categoriesFragment.appendChild(createLink(CATEGORIES_ALL, "QBT_TR(All)QBT_TR[CONTEXT=CategoryFilterModel]", torrentsTable.getRowSize()));
categoriesFragment.appendChild(createLink(CATEGORIES_UNCATEGORIZED, "QBT_TR(Uncategorized)QBT_TR[CONTEXT=CategoryFilterModel]", uncategorized));
if (useSubcategories) {
categoryList.classList.add("subcategories");
for (let i = 0; i < sortedCategories.length; ++i) {
const category = sortedCategories[i];
for (let j = (i + 1);
((j < sortedCategories.length) && sortedCategories[j].categoryName.startsWith(`${category.categoryName}/`)); ++j) {
const subcategory = sortedCategories[j];
category.categoryCount += subcategory.categoryCount;
category.forceExpand ||= subcategory.forceExpand;
categoryList.classList.add("subcategories");
for (let i = 0; i < sortedCategories.length; ++i) {
const category = sortedCategories[i];
for (let j = (i + 1);
((j < sortedCategories.length) && sortedCategories[j].categoryName.startsWith(`${category.categoryName}/`)); ++j) {
const subcategory = sortedCategories[j];
category.categoryCount += subcategory.categoryCount;
category.forceExpand ||= subcategory.forceExpand;
const isDirectSubcategory = (subcategory.nameSegments.length - category.nameSegments.length) === 1;
if (isDirectSubcategory) {
subcategory.isRoot = false;
category.children.push(subcategory);
}
const isDirectSubcategory = (subcategory.nameSegments.length - category.nameSegments.length) === 1;
if (isDirectSubcategory) {
subcategory.isRoot = false;
category.children.push(subcategory);
}
}
for (const category of sortedCategories) {
if (category.isRoot)
createCategoryTree(category);
}
}
else {
categoryList.classList.remove("subcategories");
for (const { categoryName, categoryCount } of sortedCategories)
categoriesFragment.appendChild(createLink(categoryName, categoryName, categoryCount));
for (const category of sortedCategories) {
if (category.isRoot)
createCategoryTree(category);
}
categoryList.appendChild(categoriesFragment);
@@ -1178,11 +1170,6 @@ window.addEventListener("DOMContentLoaded", (event) => {
updateAltSpeedIcon(alternativeSpeedLimits);
}
if (useSubcategories !== serverState.use_subcategories) {
useSubcategories = serverState.use_subcategories;
updateCategoryList();
}
serverSyncMainDataInterval = Math.max(serverState.refresh_interval, 500);
};

View File

@@ -585,10 +585,7 @@ window.qBittorrent.ContextMenu ??= (() => {
if ((id !== CATEGORIES_ALL) && (id !== CATEGORIES_UNCATEGORIZED)) {
this.showItem("editCategory");
this.showItem("deleteCategory");
if (useSubcategories)
this.showItem("createSubcategory");
else
this.hideItem("createSubcategory");
this.showItem("createSubcategory");
}
else {
this.hideItem("editCategory");

View File

@@ -1621,21 +1621,16 @@ window.qBittorrent.DynamicTable ??= (() => {
return false;
break; // do nothing
default:
if (!useSubcategories) {
if (category !== row["full_data"].category)
default: {
const selectedCategory = window.qBittorrent.Client.categoryMap.get(category);
if (selectedCategory !== undefined) {
const selectedCategoryName = `${category}/`;
const torrentCategoryName = `${row["full_data"].category}/`;
if (!torrentCategoryName.startsWith(selectedCategoryName))
return false;
}
else {
const selectedCategory = window.qBittorrent.Client.categoryMap.get(category);
if (selectedCategory !== undefined) {
const selectedCategoryName = `${category}/`;
const torrentCategoryName = `${row["full_data"].category}/`;
if (!torrentCategoryName.startsWith(selectedCategoryName))
return false;
}
}
break;
}
}
switch (tag) {

View File

@@ -229,10 +229,6 @@
</tr>
</tbody>
</table>
<div class="formRow">
<input type="checkbox" id="use_subcategories_checkbox">
<label for="use_subcategories_checkbox">QBT_TR(Use Subcategories)QBT_TR[CONTEXT=OptionsDialog]</label>
</div>
<div class="formRow">
<input type="checkbox" id="categoryPathsManualModeCheckbox" title="QBT_TR(Resolve relative Save Path against appropriate Category path instead of Default one)QBT_TR[CONTEXT=OptionsDialog]">
<label for="categoryPathsManualModeCheckbox">QBT_TR(Use Category paths in Manual Mode)QBT_TR[CONTEXT=OptionsDialog]</label>
@@ -2332,7 +2328,6 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
document.getElementById("torrent_changed_tmm_combobox").value = pref.torrent_changed_tmm_enabled;
document.getElementById("save_path_changed_tmm_combobox").value = pref.save_path_changed_tmm_enabled;
document.getElementById("category_changed_tmm_combobox").value = pref.category_changed_tmm_enabled;
document.getElementById("use_subcategories_checkbox").checked = pref.use_subcategories;
document.getElementById("categoryPathsManualModeCheckbox").checked = pref.use_category_paths_in_manual_mode;
document.getElementById("savepath_text").value = pref.save_path;
document.getElementById("temppath_checkbox").checked = pref.temp_path_enabled;
@@ -2754,7 +2749,6 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
settings["torrent_changed_tmm_enabled"] = (document.getElementById("torrent_changed_tmm_combobox").value === "true");
settings["save_path_changed_tmm_enabled"] = (document.getElementById("save_path_changed_tmm_combobox").value === "true");
settings["category_changed_tmm_enabled"] = (document.getElementById("category_changed_tmm_combobox").value === "true");
settings["use_subcategories"] = document.getElementById("use_subcategories_checkbox").checked;
settings["use_category_paths_in_manual_mode"] = document.getElementById("categoryPathsManualModeCheckbox").checked;
settings["save_path"] = document.getElementById("savepath_text").value;
settings["temp_path_enabled"] = document.getElementById("temppath_checkbox").checked;