Merge chros73 suggestions (settings to exclude views and hide info logs)

- Certain views can be excluded from subfiltering via view.temp_filter.excluded config option
    - its default value: "default,started,stopped"
    - example usage in config: view.temp_filter.excluded.set="default,started,stopped,leeching"

- Log messages can be displayed when temp filtering occured
    - disabled by default
    - can be enabled with: ui.console.log.tempfilter.set=1
This commit is contained in:
Toff
2017-04-17 14:56:11 +02:00
parent 6ee61ee6b5
commit d5de8a91d1
2 changed files with 24 additions and 7 deletions
+3
View File
@@ -605,6 +605,9 @@ initialize_command_ui() {
CMD2_ANY ("ui.current_view", std::bind(&cmd_ui_current_view));
CMD2_ANY_STRING("ui.current_view.set", std::bind(&cmd_ui_set_view, std::placeholders::_2));
CMD2_VAR_STRING("view.temp_filter.excluded", "default,started,stopped");
CMD2_VAR_BOOL ("ui.console.log.tempfilter", 0);
// TODO: Add 'option_string' for rtorrent-specific options.
CMD2_VAR_STRING("ui.torrent_list.layout", "full");
+21 -7
View File
@@ -36,6 +36,8 @@
#include "config.h"
#include <sstream>
#include <rak/functional.h>
#include <rak/string_manip.h>
#include <torrent/exceptions.h>
@@ -263,12 +265,22 @@ DownloadList::receive_view_input(Input type) {
break;
case INPUT_FILTER:
// STARTED and STOPPED views are not allowed to being filtered: they are special
if (current_view()->name() == "started" || current_view()->name() == "stopped") {
control->core()->push_log_std("View '" + current_view()->name() + "' can't be filtered.");
return;
{
// Do not allow to subfilter the defined excluded views
const std::string excluded_views = rpc::call_command_string("view.temp_filter.excluded");
std::stringstream ss(excluded_views);
std::string view_name_var;
while(ss.good()) {
std::getline(ss, view_name_var, ',');
if (current_view()->name() == rak::trim(view_name_var)) {
control->core()->push_log_std("View '" + current_view()->name() + "' can't be filtered.");
return;
}
}
title = "filter";
}
title = "filter";
break;
default:
@@ -336,7 +348,8 @@ DownloadList::receive_exit_input(Input type) {
case INPUT_FILTER:
if (input->str().empty()) {
control->core()->push_log_std("Clear temporary filter on '" + current_view()->name() + "' view.");
if (rpc::call_command_value("ui.console.log.tempfilter"))
control->core()->push_log_std("Clear temporary filter on '" + current_view()->name() + "' view.");
current_view()->set_temp_filter(torrent::Object());
current_view()->filter();
current_view()->sort();
@@ -348,7 +361,8 @@ DownloadList::receive_exit_input(Input type) {
pattern = ".*" + pattern;
std::transform(pattern.begin(), pattern.end(), pattern.begin(), ::tolower);
std::string tempFilter = "match={d.name=," + pattern + "}";
control->core()->push_log_std("Temporary filter on '" + current_view()->name() + "' view: " + pattern);
if (rpc::call_command_value("ui.console.log.tempfilter"))
control->core()->push_log_std("Temporary filter on '" + current_view()->name() + "' view: " + pattern);
current_view()->set_temp_filter(tempFilter);
current_view()->filter();
}