New log window available through 'l'.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@343 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-03-12 19:16:30 +00:00
parent ab69ae3fe6
commit c36ee96550
13 changed files with 230 additions and 64 deletions
+75 -44
View File
@@ -13,6 +13,7 @@
#include "display/window_http_queue.h"
#include "display/window_input.h"
#include "display/window_log.h"
#include "display/window_log_complete.h"
#include "display/window_statusbar.h"
#include "display/window_title.h"
@@ -23,34 +24,35 @@
namespace ui {
DownloadList::DownloadList(Control* c) :
m_title(new WTitle("rtorrent " VERSION " - " + torrent::get(torrent::LIBRARY_NAME))),
m_status(new WStatus(&c->get_core())),
m_textInput(new WInput(new input::TextInput)),
m_windowTitle(new WTitle("rtorrent " VERSION " - " + torrent::get(torrent::LIBRARY_NAME))),
m_windowStatus(new WStatus(&c->get_core())),
m_windowTextInput(new WInput(new input::TextInput)),
m_windowHttpQueue(new WHttp(&c->get_core().get_http_queue())),
m_taskUpdate(sigc::mem_fun(*this, &DownloadList::task_update)),
m_download(NULL),
m_uiDownload(NULL),
m_focus(c->get_core().get_download_list().end()),
m_control(c),
m_bindings(new input::Bindings) {
m_window = new WList(&m_control->get_core().get_download_list(), &m_focus);
m_windowLog = new WLog(&m_control->get_core().get_log());
m_windowDownloadList = new WList(&m_control->get_core().get_download_list(), &m_focus);
m_windowLog = new WLog(&m_control->get_core().get_log_important());
m_windowLogComplete = NULL;
bind_keys(m_bindings);
m_textInput->get_input()->slot_dirty(sigc::mem_fun(*m_textInput, &WInput::mark_dirty));
m_windowTextInput->get_input()->slot_dirty(sigc::mem_fun(*m_windowTextInput, &WInput::mark_dirty));
}
DownloadList::~DownloadList() {
delete m_window;
delete m_title;
delete m_status;
delete m_windowDownloadList;
delete m_windowTitle;
delete m_windowStatus;
delete m_bindings;
delete m_windowLog;
delete m_textInput->get_input();
delete m_textInput;
delete m_windowTextInput->get_input();
delete m_windowTextInput;
delete m_windowHttpQueue;
}
@@ -58,33 +60,36 @@ void
DownloadList::activate() {
m_taskUpdate.insert(utils::Timer::cache() + 1000000);
m_textInput->set_active(false);
m_windowTextInput->set_active(false);
m_control->get_input().push_front(m_bindings);
m_control->get_display().push_back(m_windowLog);
m_control->get_display().push_back(m_windowHttpQueue);
m_control->get_display().push_back(m_textInput);
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_display().push_back(m_windowTextInput);
m_control->get_display().push_back(m_windowStatus);
m_control->get_display().push_front(m_windowDownloadList);
m_control->get_display().push_front(m_windowTitle);
}
void
DownloadList::disable() {
m_taskUpdate.remove();
if (m_textInput->is_active()) {
m_textInput->get_input()->clear();
if (m_windowTextInput->is_active()) {
m_windowTextInput->get_input()->clear();
receive_exit_input();
}
if (m_windowLogComplete != NULL)
receive_toggle_log();
m_control->get_input().erase(m_bindings);
m_control->get_display().erase(m_title);
m_control->get_display().erase(m_window);
m_control->get_display().erase(m_status);
m_control->get_display().erase(m_textInput);
m_control->get_display().erase(m_windowTitle);
m_control->get_display().erase(m_windowDownloadList);
m_control->get_display().erase(m_windowStatus);
m_control->get_display().erase(m_windowTextInput);
m_control->get_display().erase(m_windowLog);
m_control->get_display().erase(m_windowHttpQueue);
}
@@ -111,7 +116,7 @@ DownloadList::receive_prev() {
void
DownloadList::receive_throttle(int t) {
m_status->mark_dirty();
m_windowStatus->mark_dirty();
torrent::set(torrent::THROTTLE_ROOT_CONST_RATE, torrent::get(torrent::THROTTLE_ROOT_CONST_RATE) + t * 1024);
}
@@ -140,25 +145,25 @@ DownloadList::receive_view_download() {
if (m_focus == m_control->get_core().get_download_list().end())
return;
if (m_download != NULL)
throw std::logic_error("DownloadList::receive_view_download() called but m_download != NULL");
if (m_uiDownload != NULL)
throw std::logic_error("DownloadList::receive_view_download() called but m_uiDownload != NULL");
disable();
m_download = new Download(*m_focus, m_control);
m_uiDownload = new Download(*m_focus, m_control);
m_download->activate();
m_download->get_bindings()[KEY_LEFT] = sigc::mem_fun(*this, &DownloadList::receive_exit_download);
m_uiDownload->activate();
m_uiDownload->get_bindings()[KEY_LEFT] = sigc::mem_fun(*this, &DownloadList::receive_exit_download);
}
void
DownloadList::receive_exit_download() {
if (m_download == NULL)
throw std::logic_error("DownloadList::receive_exit_download() called but m_download == NULL");
if (m_uiDownload == NULL)
throw std::logic_error("DownloadList::receive_exit_download() called but m_uiDownload == NULL");
m_download->disable();
delete m_download;
m_download = NULL;
m_uiDownload->disable();
delete m_uiDownload;
m_uiDownload = NULL;
activate();
@@ -167,13 +172,13 @@ DownloadList::receive_exit_download() {
void
DownloadList::receive_view_input() {
m_status->set_active(false);
m_textInput->set_active(true);
m_windowStatus->set_active(false);
m_windowTextInput->set_active(true);
m_control->get_display().adjust_layout();
m_control->get_input().set_text_input(m_textInput->get_input());
m_control->get_input().set_text_input(m_windowTextInput->get_input());
m_textInput->set_focus(true);
m_windowTextInput->set_focus(true);
(*m_bindings)['\n'] = sigc::mem_fun(*this, &DownloadList::receive_exit_input);
(*m_bindings)[KEY_ENTER] = sigc::mem_fun(*this, &DownloadList::receive_exit_input);
@@ -181,21 +186,46 @@ DownloadList::receive_view_input() {
void
DownloadList::receive_exit_input() {
m_status->set_active(true);
m_textInput->set_active(false);
m_windowStatus->set_active(true);
m_windowTextInput->set_active(false);
m_control->get_display().adjust_layout();
m_control->get_input().set_text_input();
m_slotOpenUri(m_textInput->get_input()->str());
m_slotOpenUri(m_windowTextInput->get_input()->str());
m_textInput->get_input()->clear();
m_textInput->set_focus(false);
m_windowTextInput->get_input()->clear();
m_windowTextInput->set_focus(false);
m_bindings->erase('\n');
m_bindings->erase(KEY_ENTER);
}
void
DownloadList::receive_toggle_log() {
if (m_windowLogComplete == NULL) {
display::Manager::iterator itr = m_control->get_display().find(m_windowDownloadList);
if (itr == m_control->get_display().end())
throw std::logic_error("ui::DownloadList::receive_toggle_log() could not find download list");
*itr = m_windowLogComplete = new WLogComplete(&m_control->get_core().get_log_complete());
} else {
display::Manager::iterator itr = m_control->get_display().find(m_windowLogComplete);
if (itr == m_control->get_display().end())
throw std::logic_error("ui::DownloadList::receive_toggle_log() could not find download list");
*itr = m_windowDownloadList;
delete m_windowLogComplete;
m_windowLogComplete = NULL;
}
m_control->get_display().adjust_layout();
}
void
DownloadList::task_update() {
m_windowLog->receive_update();
@@ -218,6 +248,7 @@ DownloadList::bind_keys(input::Bindings* b) {
(*b)[KEY_UP] = sigc::mem_fun(*this, &DownloadList::receive_prev);
(*b)[KEY_DOWN] = sigc::mem_fun(*this, &DownloadList::receive_next);
(*b)[KEY_RIGHT] = sigc::mem_fun(*this, &DownloadList::receive_view_download);
(*b)['l'] = sigc::mem_fun(*this, &DownloadList::receive_toggle_log);
(*b)['\x7f'] = sigc::mem_fun(*this, &DownloadList::receive_view_input);
(*b)[KEY_BACKSPACE] = sigc::mem_fun(*this, &DownloadList::receive_view_input);
@@ -225,7 +256,7 @@ DownloadList::bind_keys(input::Bindings* b) {
void
DownloadList::mark_dirty() {
m_window->mark_dirty();
m_windowDownloadList->mark_dirty();
}
}
+12 -6
View File
@@ -15,6 +15,7 @@ namespace display {
class WindowHttpQueue;
class WindowInput;
class WindowLog;
class WindowLogComplete;
class WindowStatusbar;
class WindowTitle;
}
@@ -30,6 +31,7 @@ public:
typedef display::WindowHttpQueue WHttp;
typedef display::WindowInput WInput;
typedef display::WindowLog WLog;
typedef display::WindowLogComplete WLogComplete;
typedef display::WindowStatusbar WStatus;
typedef display::WindowTitle WTitle;
@@ -41,7 +43,7 @@ public:
DownloadList(Control* c);
~DownloadList();
WList& get_window() { return *m_window; }
WList& get_window_download_list() { return *m_windowDownloadList; }
input::Bindings& get_bindings() { return *m_bindings; }
void activate();
@@ -67,22 +69,26 @@ private:
void receive_view_input();
void receive_exit_input();
void receive_toggle_log();
void task_update();
void bind_keys(input::Bindings* b);
void mark_dirty();
WList* m_window;
WTitle* m_title;
WStatus* m_status;
WList* m_windowDownloadList;
WTitle* m_windowTitle;
WStatus* m_windowStatus;
WLog* m_windowLog;
WInput* m_textInput;
WInput* m_windowTextInput;
WHttp* m_windowHttpQueue;
WLogComplete* m_windowLogComplete;
utils::Task m_taskUpdate;
Download* m_download;
Download* m_uiDownload;
DList* m_list;
DList::iterator m_focus;