Allow functions and lists of functions to be passed to view.event_{added,removed}.

This commit is contained in:
rakshasa
2012-05-04 21:31:12 +09:00
parent 8d0f9b3300
commit fb75510c0f
8 changed files with 77 additions and 69 deletions
+11 -9
View File
@@ -184,7 +184,7 @@ View::erase(Download* download) {
} else {
erase_internal(itr);
rpc::parse_command_multiple_d_nothrow(download, m_eventRemoved);
rpc::call_object_nothrow(m_event_removed, rpc::make_target(download));
}
}
@@ -200,7 +200,7 @@ View::set_visible(Download* download) {
base_type::erase(itr);
insert_visible(download);
rpc::parse_command_multiple_d_nothrow(download, m_eventAdded);
rpc::call_object_nothrow(m_event_added, rpc::make_target(download));
}
void
@@ -218,7 +218,7 @@ View::set_not_visible(Download* download) {
base_type::erase(itr);
base_type::push_back(download);
rpc::parse_command_multiple_d_nothrow(download, m_eventRemoved);
rpc::call_object_nothrow(m_event_removed, rpc::make_target(download));
}
void
@@ -275,11 +275,13 @@ View::filter() {
// done by using a base_type* member variable, and making sure we
// set the elements to NULL as we trigger commands on them. Or
// perhaps always clear them, thus not throwing anything.
if (!m_eventRemoved.empty())
std::for_each(changed.begin(), splitChanged, rak::bind2nd(std::ptr_fun(&rpc::parse_command_multiple_d_nothrow), m_eventRemoved));
if (!m_event_removed.is_empty())
std::for_each(changed.begin(), splitChanged,
tr1::bind(&rpc::call_object_d_nothrow, m_event_removed, tr1::placeholders::_1));
if (!m_eventAdded.empty())
std::for_each(splitChanged, changed.end(), rak::bind2nd(std::ptr_fun(&rpc::parse_command_multiple_d_nothrow), m_eventAdded));
if (!m_event_added.is_empty())
std::for_each(changed.begin(), splitChanged,
tr1::bind(&rpc::call_object_d_nothrow, m_event_added, tr1::placeholders::_1));
emit_changed();
}
@@ -297,7 +299,7 @@ View::filter_download(core::Download* download) {
erase_internal(itr);
insert_visible(download);
rpc::parse_command_multiple_d_nothrow(download, m_eventAdded);
rpc::call_object_nothrow(m_event_added, rpc::make_target(download));
} else {
// This makes sure the download is sorted even if it is
@@ -315,7 +317,7 @@ View::filter_download(core::Download* download) {
erase_internal(itr);
base_type::push_back(download);
rpc::parse_command_multiple_d_nothrow(download, m_eventRemoved);
rpc::call_object_nothrow(m_event_removed, rpc::make_target(download));
}
emit_changed();