mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-01-06 15:04:34 +08:00
WebUI: Implement removing categories
This commit is contained in:
parent
a4dca52617
commit
50f2437ac3
@ -116,6 +116,7 @@ QMap<QString, QMap<QString, WebApplication::Action> > WebApplication::initialize
|
||||
ADD_ACTION(command, recheck);
|
||||
ADD_ACTION(command, setCategory);
|
||||
ADD_ACTION(command, addCategory);
|
||||
ADD_ACTION(command, removeCategory);
|
||||
ADD_ACTION(command, getSavePath);
|
||||
ADD_ACTION(version, api);
|
||||
ADD_ACTION(version, api_min);
|
||||
@ -744,6 +745,15 @@ void WebApplication::action_command_addCategory()
|
||||
BitTorrent::Session::instance()->addCategory(category);
|
||||
}
|
||||
|
||||
void WebApplication::action_command_removeCategory()
|
||||
{
|
||||
CHECK_URI(0);
|
||||
CHECK_PARAMETERS("category");
|
||||
|
||||
QString category = request().posts["category"].trimmed();
|
||||
BitTorrent::Session::instance()->removeCategory(category);
|
||||
}
|
||||
|
||||
void WebApplication::action_command_getSavePath()
|
||||
{
|
||||
CHECK_URI(0);
|
||||
|
@ -89,6 +89,7 @@ private:
|
||||
void action_command_recheck();
|
||||
void action_command_setCategory();
|
||||
void action_command_addCategory();
|
||||
void action_command_removeCategory();
|
||||
void action_command_getSavePath();
|
||||
void action_version_api();
|
||||
void action_version_api_min();
|
||||
|
@ -127,6 +127,7 @@
|
||||
</ul>
|
||||
<ul id="categoriesFilterMenu" class="contextMenu">
|
||||
<li><a href="#CreateCategory"><img src="theme/list-add" alt="QBT_TR(Add category...)QBT_TR"/> QBT_TR(Add category...)QBT_TR</a></li>
|
||||
<li><a href="#DeleteCategory"><img src="theme/list-remove" alt="QBT_TR(Remove category)QBT_TR"/> QBT_TR(Remove category)QBT_TR</a></li>
|
||||
</ul>
|
||||
<div id="desktopFooterWrapper">
|
||||
<div id="desktopFooter">
|
||||
|
@ -22,6 +22,9 @@
|
||||
actions : {
|
||||
CreateCategory : function (element, ref) {
|
||||
createCategoryFN();
|
||||
},
|
||||
DeleteCategory : function (element, ref) {
|
||||
removeCategoryFN(element.id);
|
||||
}
|
||||
},
|
||||
offsets : {
|
||||
|
@ -315,5 +315,12 @@ var TorrentsTableContextMenu = new Class({
|
||||
});
|
||||
|
||||
var CategoriesFilterContextMenu = new Class({
|
||||
Extends: ContextMenu
|
||||
Extends: ContextMenu,
|
||||
updateMenuItems: function () {
|
||||
var id = this.options.element.id;
|
||||
if (id != CATEGORIES_ALL && id != CATEGORIES_UNCATEGORIZED)
|
||||
this.showItem('DeleteCategory');
|
||||
else
|
||||
this.hideItem('DeleteCategory');
|
||||
}
|
||||
});
|
||||
|
@ -357,6 +357,18 @@ initializeWindows = function() {
|
||||
updateMainData();
|
||||
};
|
||||
|
||||
removeCategoryFN = function (categoryHash) {
|
||||
var categoryName = category_list[categoryHash].name;
|
||||
new Request({
|
||||
url: 'command/removeCategory',
|
||||
method: 'post',
|
||||
data: {
|
||||
category: categoryName
|
||||
}
|
||||
}).send();
|
||||
setCategoryFilter(CATEGORIES_ALL);
|
||||
};
|
||||
|
||||
['pauseAll', 'resumeAll'].each(function(item) {
|
||||
addClickEvent(item, function(e) {
|
||||
new Event(e).stop();
|
||||
|
Loading…
Reference in New Issue
Block a user