Changeset 1042 for trunk/rtorrent/src/core/view.cc
- Timestamp:
- 03/16/08 09:55:40 (4 years ago)
- Files:
-
- 1 modified
-
trunk/rtorrent/src/core/view.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/rtorrent/src/core/view.cc
r992 r1042 40 40 #include <functional> 41 41 #include <rak/functional.h> 42 #include <rpc/parse_commands.h> 42 43 #include <sigc++/adaptors/bind.h> 43 44 #include <torrent/download.h> … … 129 130 130 131 struct view_downloads_filter : std::unary_function<Download*, bool> { 131 view_downloads_filter(const View::filter_list& s) : m_filter(s) {}132 view_downloads_filter(const std::string& cmd) : m_command(cmd) {} 132 133 133 134 bool operator () (Download* d1) const { 134 for (View::filter_list::const_iterator itr = m_filter.begin(), last = m_filter.end(); itr != last; ++itr) 135 if (!(**itr)(d1)) 136 return false; 137 138 // The default filter action is to return true, to not filter the 139 // download out. 140 return true; 135 try { 136 torrent::Object result = rpc::parse_command_single(rpc::make_target(d1), m_command); 137 138 switch (result.type()) { 139 case torrent::Object::TYPE_NONE: return false; 140 case torrent::Object::TYPE_VALUE: return result.as_value(); 141 case torrent::Object::TYPE_STRING: return !result.as_string().empty(); 142 case torrent::Object::TYPE_LIST: return !result.as_list().empty(); 143 case torrent::Object::TYPE_MAP: return !result.as_map().empty(); 144 } 145 146 // The default filter action is to return true, to not filter 147 // the download out. 148 return true; 149 150 } catch (torrent::input_error& e) { 151 return false; 152 } 141 153 } 142 154 143 const View::filter_list& m_filter;155 const std::string& m_command; 144 156 }; 145 157 … … 233 245 // Erase even if it is in visible so that the download is 234 246 // re-sorted. 247 // 248 // Do we really want to do this? 235 249 erase(itr); 236 250 insert_visible(download);
