mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-15 22:52:31 +00:00
Add a temporary name filter for the main view.
By using 'F' in the main view you can enter a regex
that will be used to filter the view based on the torrent name.
To remove the filter set the input to empty.
This is adding a 'view.temp_filter' property and a 'match{}' function.
For example with Ctrl+X you could do:
command> view.temp_filter=main,"match={d.name=,.*linux.*iso}"
This commit is contained in:
@@ -262,6 +262,10 @@ DownloadList::receive_view_input(Input type) {
|
||||
title = "command";
|
||||
break;
|
||||
|
||||
case INPUT_FILTER:
|
||||
title = "filter";
|
||||
break;
|
||||
|
||||
default:
|
||||
throw torrent::internal_error("DownloadList::receive_view_input(...) Invalid input type.");
|
||||
}
|
||||
@@ -325,6 +329,25 @@ DownloadList::receive_exit_input(Input type) {
|
||||
input->str());
|
||||
break;
|
||||
|
||||
case INPUT_FILTER:
|
||||
if (input->str().empty()) {
|
||||
control->core()->push_log_std("Clear temporary filter.");
|
||||
current_view()->set_temp_filter(torrent::Object());
|
||||
current_view()->filter();
|
||||
} else {
|
||||
std::string pattern = input->str();
|
||||
if (pattern.back() != '$')
|
||||
pattern = pattern + ".*";
|
||||
if (pattern.front() != '^')
|
||||
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: " + pattern);
|
||||
current_view()->set_temp_filter(tempFilter);
|
||||
current_view()->filter();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw torrent::internal_error("DownloadList::receive_exit_input(...) Invalid input type.");
|
||||
}
|
||||
@@ -346,6 +369,7 @@ DownloadList::setup_keys() {
|
||||
m_bindings[KEY_ENTER] = std::bind(&DownloadList::receive_view_input, this, INPUT_LOAD_MODIFIED);
|
||||
m_bindings['\x0F'] = std::bind(&DownloadList::receive_view_input, this, INPUT_CHANGE_DIRECTORY);
|
||||
m_bindings['X' - '@'] = std::bind(&DownloadList::receive_view_input, this, INPUT_COMMAND);
|
||||
m_bindings['F'] = std::bind(&DownloadList::receive_view_input, this, INPUT_FILTER);
|
||||
|
||||
m_uiArray[DISPLAY_LOG]->bindings()[KEY_LEFT] =
|
||||
m_uiArray[DISPLAY_LOG]->bindings()['B' - '@'] =
|
||||
|
||||
@@ -86,7 +86,8 @@ public:
|
||||
INPUT_LOAD_DEFAULT,
|
||||
INPUT_LOAD_MODIFIED,
|
||||
INPUT_CHANGE_DIRECTORY,
|
||||
INPUT_COMMAND
|
||||
INPUT_COMMAND,
|
||||
INPUT_FILTER
|
||||
} Input;
|
||||
|
||||
DownloadList();
|
||||
|
||||
Reference in New Issue
Block a user