Skip to content

Commit

Permalink
Modify slightly backport temp filter patch only for git version (See #63
Browse files Browse the repository at this point in the history
)
  • Loading branch information
chros authored and chros committed Jan 8, 2017
1 parent 9cf05c1 commit 7890382
Showing 1 changed file with 46 additions and 29 deletions.
75 changes: 46 additions & 29 deletions patches/backport_0.9.7_add_temp_filter.patch
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
</variablelist>

</refsect2>
--- src/command_ui.cc
+++ src/command_ui.cc
--- src/command_ui.cc 2016-11-04 21:58:44.000000000 +0000
+++ src/command_ui.cc 2017-01-08 14:50:09.628730147 +0000
@@ -39,6 +39,8 @@
#include <sys/types.h>

Expand All @@ -37,7 +37,7 @@
#include <rak/functional.h>
#include <rak/functional_fun.h>

@@ -282,6 +284,53 @@ torrent::Object apply_equal(rpc::target_type target, const torrent::Object::list
@@ -282,6 +284,53 @@ torrent::Object apply_equal(rpc::target_
return result.is_value() ? result.as_value() == 0 : (int64_t)false;
}

Expand Down Expand Up @@ -107,9 +107,9 @@

CMD2_ANY_VALUE("convert.gm_time", std::bind(&apply_to_time, std::placeholders::_2, 0));
CMD2_ANY_VALUE("convert.gm_date", std::bind(&apply_to_time, std::placeholders::_2, 0x2));
--- src/core/view.cc
+++ src/core/view.cc
@@ -89,17 +89,21 @@ struct view_downloads_compare : std::binary_function<Download*, Download*, bool>
--- src/core/view.cc 2016-11-04 21:58:44.000000000 +0000
+++ src/core/view.cc 2017-01-08 14:50:09.628730147 +0000
@@ -89,17 +89,21 @@ struct view_downloads_compare : std::bin
};

struct view_downloads_filter : std::unary_function<Download*, bool> {
Expand All @@ -135,7 +135,7 @@

// uint32_t flags = tmp_command.flags() & torrent::Object::mask_function;
// tmp_command.unset_flags(torrent::Object::mask_function);
@@ -109,10 +113,10 @@ struct view_downloads_filter : std::unary_function<Download*, bool> {
@@ -109,10 +113,10 @@ struct view_downloads_filter : std::unar
// result = rpc::commands.call_command(tmp_command.as_dict_key().c_str(), tmp_command.as_dict_obj(),
// rpc::make_target(d1));

Expand All @@ -148,7 +148,7 @@
}

switch (result.type()) {
@@ -136,6 +140,7 @@ struct view_downloads_filter : std::unary_function<Download*, bool> {
@@ -136,6 +140,7 @@ struct view_downloads_filter : std::unar
}

const torrent::Object& m_command;
Expand All @@ -167,7 +167,7 @@

base_type changed(splitVisible, splitFiltered);
iterator splitChanged = changed.begin() + std::distance(splitVisible, end_visible());
@@ -302,7 +307,7 @@ View::filter_download(core::Download* download) {
@@ -302,7 +307,7 @@ View::filter_download(core::Download* do
if (itr == base_type::end())
throw torrent::internal_error("View::filter_download(...) could not find download.");

Expand All @@ -176,9 +176,9 @@

if (itr >= end_visible()) {
erase_internal(itr);
--- src/core/view.h
+++ src/core/view.h
@@ -124,6 +124,8 @@ class View : private std::vector<Download*> {
--- src/core/view.h 2016-11-04 21:58:44.000000000 +0000
+++ src/core/view.h 2017-01-08 14:50:09.628730147 +0000
@@ -124,6 +124,8 @@ public:

const torrent::Object& get_filter() const { return m_filter; }
void set_filter(const torrent::Object& s) { m_filter = s; }
Expand All @@ -187,17 +187,17 @@
void set_filter_on_event(const std::string& event);

void clear_filter_on();
@@ -172,6 +174,7 @@ class View : private std::vector<Download*> {
@@ -172,6 +174,7 @@ private:
torrent::Object m_sortCurrent;

torrent::Object m_filter;
+ torrent::Object m_tempFilter; // Temporary view filter (eg: name based filter)

torrent::Object m_event_added;
torrent::Object m_event_removed;
--- src/core/view_manager.cc
+++ src/core/view_manager.cc
@@ -110,6 +110,14 @@ ViewManager::set_filter(const std::string& name, const torrent::Object& cmd) {
--- src/core/view_manager.cc 2016-11-04 21:58:44.000000000 +0000
+++ src/core/view_manager.cc 2017-01-08 14:50:09.628730147 +0000
@@ -110,6 +110,14 @@ ViewManager::set_filter(const std::strin
}

void
Expand All @@ -212,19 +212,30 @@
ViewManager::set_filter_on(const std::string& name, const filter_args& args) {
iterator viewItr = find_throw(name);

--- src/core/view_manager.h
+++ src/core/view_manager.h
@@ -93,6 +93,7 @@ class ViewManager : public rak::unordered_vector<View*> {
--- src/core/view_manager.h 2016-11-04 21:58:44.000000000 +0000
+++ src/core/view_manager.h 2017-01-08 14:50:09.628730147 +0000
@@ -93,6 +93,7 @@ public:
void set_sort_current(const std::string& name, const torrent::Object& cmd) { (*find_throw(name))->set_sort_current(cmd); }

void set_filter(const std::string& name, const torrent::Object& cmd);
+ void set_temp_filter(const std::string& name, const torrent::Object& cmd);
void set_filter_on(const std::string& name, const filter_args& args);

void set_event_added(const std::string& name, const torrent::Object& cmd) { (*find_throw(name))->set_event_added(cmd); }
--- src/ui/download_list.cc
+++ src/ui/download_list.cc
@@ -262,6 +262,10 @@ DownloadList::receive_view_input(Input type) {
--- src/display/window_download_list.cc 2016-11-04 21:58:44.000000000 +0000
+++ src/display/window_download_list.cc 2017-01-08 14:50:09.628730147 +0000
@@ -81,7 +81,7 @@ WindowDownloadList::redraw() {
if (m_view == NULL)
return;

- m_canvas->print(0, 0, "%s", ("[View: " + m_view->name() + "]").c_str());
+ m_canvas->print(0, 0, "%s", ("[View: " + m_view->name() + (m_view->get_temp_filter().is_empty() ? "" : " (filtered)") + "]").c_str());

if (m_view->empty_visible() || m_canvas->width() < 5 || m_canvas->height() < 2)
return;
--- src/ui/download_list.cc 2016-11-04 21:58:44.000000000 +0000
+++ src/ui/download_list.cc 2017-01-08 14:53:02.181128683 +0000
@@ -262,6 +262,10 @@ DownloadList::receive_view_input(Input t
title = "command";
break;

Expand All @@ -235,13 +246,19 @@
default:
throw torrent::internal_error("DownloadList::receive_view_input(...) Invalid input type.");
}
@@ -325,6 +329,25 @@ DownloadList::receive_exit_input(Input type) {
@@ -325,6 +329,31 @@ DownloadList::receive_exit_input(Input t
input->str());
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.");
+ break;
+ }
+
+ if (input->str().empty()) {
+ control->core()->push_log_std("Clear temporary filter.");
+ control->core()->push_log_std("Clear temporary filter on '" + current_view()->name() + "' view.");
+ current_view()->set_temp_filter(torrent::Object());
+ current_view()->filter();
+ } else {
Expand All @@ -252,7 +269,7 @@
+ 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);
+ control->core()->push_log_std("Temporary filter on '" + current_view()->name() + "' view: " + pattern);
+ current_view()->set_temp_filter(tempFilter);
+ current_view()->filter();
+ }
Expand All @@ -261,17 +278,17 @@
default:
throw torrent::internal_error("DownloadList::receive_exit_input(...) Invalid input type.");
}
@@ -346,6 +369,7 @@ DownloadList::setup_keys() {
@@ -346,6 +375,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' - '@'] =
--- src/ui/download_list.h
+++ src/ui/download_list.h
@@ -86,7 +86,8 @@ class DownloadList : public ElementBase {
--- src/ui/download_list.h 2016-11-04 21:58:44.000000000 +0000
+++ src/ui/download_list.h 2017-01-08 14:50:09.628730147 +0000
@@ -86,7 +86,8 @@ public:
INPUT_LOAD_DEFAULT,
INPUT_LOAD_MODIFIED,
INPUT_CHANGE_DIRECTORY,
Expand Down

0 comments on commit 7890382

Please sign in to comment.