Focus iterators moved out of Window*.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@254 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-02-05 20:36:22 +00:00
parent e02974571a
commit ecb2fc7d57
12 changed files with 122 additions and 59 deletions
+41 -9
View File
@@ -2,10 +2,12 @@
#include <stdexcept>
#include <torrent/torrent.h>
#include <sigc++/bind.h>
#include "input/bindings.h"
#include "display/window_title.h"
#include "display/window_download_list.h"
#include "display/window_statusbar.h"
#include "control.h"
#include "download.h"
@@ -14,25 +16,38 @@
namespace ui {
DownloadList::DownloadList(core::DownloadList* l, Control* c) :
m_window(new WList(l)),
m_title(new WTitle("rtorrent " VERSION " - " + torrent::get(torrent::LIBRARY_NAME))),
m_status(new WStatus),
m_download(NULL),
m_list(l),
m_focus(l->end()),
m_control(c),
m_bindings(new input::Bindings) {
m_window = new WList(m_list, &m_focus);
(*m_bindings)[KEY_UP] = sigc::mem_fun(*this, &DownloadList::receive_prev);
(*m_bindings)[KEY_DOWN] = sigc::mem_fun(*this, &DownloadList::receive_next);
(*m_bindings)[KEY_RIGHT] = sigc::mem_fun(*this, &DownloadList::receive_view_download);
(*m_bindings)['a'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), 1);
(*m_bindings)['z'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), -1);
(*m_bindings)['s'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), 5);
(*m_bindings)['x'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), -5);
(*m_bindings)['d'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), 50);
(*m_bindings)['c'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), -50);
}
DownloadList::~DownloadList() {
delete m_window;
delete m_title;
delete m_status;
delete m_bindings;
}
void
DownloadList::activate() {
m_control->get_display().push_back(m_status);
m_control->get_display().push_front(m_window);
m_control->get_display().push_front(m_title);
m_control->get_input().push_front(m_bindings);
@@ -42,33 +57,38 @@ void
DownloadList::disable() {
m_control->get_display().erase(m_title);
m_control->get_display().erase(m_window);
m_control->get_display().erase(m_status);
m_control->get_input().erase(m_bindings);
}
void
DownloadList::receive_next() {
if (m_window->get_focus() == m_window->get_list().end())
m_window->set_focus(m_window->get_list().begin());
if (m_focus != m_list->end())
++m_focus;
else
m_window->set_focus(++m_window->get_focus());
m_focus = m_list->begin();
mark_dirty();
}
void
DownloadList::receive_prev() {
if (m_window->get_focus() == m_window->get_list().begin())
m_window->set_focus(m_window->get_list().end());
if (m_focus != m_list->begin())
--m_focus;
else
m_window->set_focus(--m_window->get_focus());
m_focus = m_list->end();
mark_dirty();
}
void
DownloadList::receive_view_download() {
if (m_window->get_focus() == m_window->get_list().end())
if (m_focus == m_list->end())
return;
disable();
m_download = new Download(m_window->get_focus(), m_control);
m_download = new Download(m_focus, m_control);
m_download->get_bindings()[KEY_LEFT] = sigc::mem_fun(*this, &DownloadList::receive_exit_download);
m_download->activate();
@@ -90,4 +110,16 @@ DownloadList::receive_exit_download() {
m_control->get_display().adjust_layout();
}
void
DownloadList::receive_throttle(int t) {
m_status->mark_dirty();
torrent::set(torrent::THROTTLE_ROOT_CONST_RATE, torrent::get(torrent::THROTTLE_ROOT_CONST_RATE) + t * 1024);
}
void
DownloadList::mark_dirty() {
m_window->mark_dirty();
}
}