mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-14 06:02:31 +00:00
* Changed ViewSort::less(...) to operator().
* Added a "last changed" paramter to ViewManager::sort(...) which is checked, if the ViewDownloads's last_changed timer was poked withing that timeframe it won't update. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@676 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+34
-3
@@ -83,12 +83,15 @@ DownloadList::DownloadList(Control* c) :
|
||||
m_control(c),
|
||||
m_bindings(new input::Bindings)
|
||||
{
|
||||
m_view = *c->view_manager()->find_throw("main");
|
||||
|
||||
m_uiArray[DISPLAY_DOWNLOAD_LIST] = new ElementDownloadList(m_view);
|
||||
m_uiArray[DISPLAY_DOWNLOAD_LIST] = new ElementDownloadList();
|
||||
m_uiArray[DISPLAY_LOG] = new ElementLogComplete(&m_control->core()->get_log_complete());
|
||||
m_windowLog = new WLog(&m_control->core()->get_log_important());
|
||||
|
||||
receive_change_view("main");
|
||||
|
||||
if (m_view == NULL)
|
||||
throw torrent::internal_error("View \"main\" must be present to initialize the main display.");
|
||||
|
||||
m_taskUpdate.set_slot(rak::mem_fn(this, &DownloadList::task_update)),
|
||||
|
||||
setup_keys();
|
||||
@@ -183,11 +186,13 @@ DownloadList::disable_display() {
|
||||
void
|
||||
DownloadList::receive_next() {
|
||||
m_view->next_focus();
|
||||
m_view->set_last_changed();
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_prev() {
|
||||
m_view->prev_focus();
|
||||
m_view->set_last_changed();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -365,6 +370,26 @@ DownloadList::receive_download_erased(core::Download* d) {
|
||||
receive_next();
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_change_view(const std::string& name) {
|
||||
core::ViewManager::iterator itr = m_control->view_manager()->find(name);
|
||||
|
||||
if (itr == m_control->view_manager()->end()) {
|
||||
m_control->core()->push_log("Could not find view \"" + name + "\".");
|
||||
return;
|
||||
}
|
||||
|
||||
m_view = *itr;
|
||||
m_view->sort();
|
||||
|
||||
ElementDownloadList* ui = dynamic_cast<ElementDownloadList*>(m_uiArray[DISPLAY_DOWNLOAD_LIST]);
|
||||
|
||||
if (ui == NULL)
|
||||
throw torrent::internal_error("DownloadList::receive_change_view(...) could not cast ui.");
|
||||
|
||||
ui->set_view(m_view);
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::task_update() {
|
||||
m_windowLog->receive_update();
|
||||
@@ -393,6 +418,12 @@ DownloadList::setup_keys() {
|
||||
(*m_bindings)[KEY_RIGHT] = sigc::mem_fun(*this, &DownloadList::receive_view_download);
|
||||
(*m_bindings)['l'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change), DISPLAY_LOG);
|
||||
|
||||
(*m_bindings)['1'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "main");
|
||||
(*m_bindings)['2'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "started");
|
||||
(*m_bindings)['3'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "stopped");
|
||||
(*m_bindings)['4'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "finished");
|
||||
(*m_bindings)['5'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "incomplete");
|
||||
|
||||
m_uiArray[DISPLAY_LOG]->get_bindings()[' '] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change), DISPLAY_DOWNLOAD_LIST);
|
||||
}
|
||||
|
||||
|
||||
@@ -137,6 +137,8 @@ private:
|
||||
|
||||
void receive_download_erased(core::Download* d);
|
||||
|
||||
void receive_change_view(const std::string& name);
|
||||
|
||||
void task_update();
|
||||
|
||||
void setup_keys();
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "display/window_download_list.h"
|
||||
#include "input/manager.h"
|
||||
|
||||
#include "control.h"
|
||||
@@ -46,11 +45,6 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
ElementDownloadList::ElementDownloadList(core::ViewDownloads* l) :
|
||||
m_window(NULL),
|
||||
m_view(l) {
|
||||
}
|
||||
|
||||
void
|
||||
ElementDownloadList::activate(Control* c, MItr mItr) {
|
||||
if (m_window != NULL)
|
||||
@@ -58,7 +52,10 @@ ElementDownloadList::activate(Control* c, MItr mItr) {
|
||||
|
||||
c->input()->push_front(&m_bindings);
|
||||
|
||||
*mItr = m_window = new WDownloadList(m_view);
|
||||
m_window = new WDownloadList();
|
||||
m_window->set_view(m_view);
|
||||
|
||||
*mItr = m_window;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -72,4 +69,15 @@ ElementDownloadList::disable(Control* c) {
|
||||
m_window = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
ElementDownloadList::set_view(core::ViewDownloads* l) {
|
||||
m_view = l;
|
||||
|
||||
if (m_window == NULL)
|
||||
return;
|
||||
|
||||
m_window->set_view(l);
|
||||
m_window->mark_dirty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#define RTORRENT_UI_ELEMENT_DOWNLOAD_LIST_H
|
||||
|
||||
#include "core/download_list.h"
|
||||
#include "display/window_download_list.h"
|
||||
|
||||
#include "element_base.h"
|
||||
|
||||
@@ -47,21 +48,19 @@ namespace core {
|
||||
class ViewDownloads;
|
||||
}
|
||||
|
||||
namespace display {
|
||||
class WindowDownloadList;
|
||||
}
|
||||
|
||||
namespace ui {
|
||||
|
||||
class ElementDownloadList : public ElementBase {
|
||||
public:
|
||||
typedef display::WindowDownloadList WDownloadList;
|
||||
|
||||
ElementDownloadList(core::ViewDownloads* l);
|
||||
ElementDownloadList() : m_window(NULL), m_view(NULL) {}
|
||||
|
||||
void activate(Control* c, MItr mItr);
|
||||
void disable(Control* c);
|
||||
|
||||
void set_view(core::ViewDownloads* l);
|
||||
|
||||
private:
|
||||
WDownloadList* m_window;
|
||||
core::ViewDownloads* m_view;
|
||||
|
||||
Reference in New Issue
Block a user