mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-07 06:39:23 +00:00
* Moved handling of events from DownloadList into ElementDownloadList
and WindowLog. * Added bindings to input::TextInput and disabled other bindings while it is active. * ^K now sets ignore_commands. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@750 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+1
-1
@@ -99,7 +99,7 @@ Download::activate(display::Frame* frame) {
|
||||
if (is_active())
|
||||
throw torrent::client_error("ui::Download::activate() called on an already activated object.");
|
||||
|
||||
control->input()->push_front(&m_bindings);
|
||||
control->input()->push_back(&m_bindings);
|
||||
|
||||
m_frame = frame;
|
||||
activate_display(DISPLAY_PEER_LIST);
|
||||
|
||||
+17
-190
@@ -77,13 +77,6 @@ DownloadList::DownloadList() :
|
||||
|
||||
m_windowLog = new WLog(&control->core()->get_log_important());
|
||||
|
||||
receive_change_view("main");
|
||||
|
||||
if (m_view == NULL)
|
||||
throw torrent::client_error("View \"main\" must be present to initialize the main display.");
|
||||
|
||||
m_taskUpdate.set_slot(rak::mem_fn(this, &DownloadList::task_update)),
|
||||
|
||||
setup_keys();
|
||||
}
|
||||
|
||||
@@ -101,11 +94,9 @@ DownloadList::activate(display::Frame* frame) {
|
||||
if (is_active())
|
||||
throw torrent::client_error("ui::DownloadList::activate() called on an already activated object");
|
||||
|
||||
priority_queue_insert(&taskScheduler, &m_taskUpdate, cachedTime);
|
||||
|
||||
m_frame = frame;
|
||||
|
||||
control->input()->push_front(&m_bindings);
|
||||
control->input()->push_back(&m_bindings);
|
||||
control->core()->download_list()->slot_map_erase()["0_download_list"] = sigc::mem_fun(this, &DownloadList::receive_download_erased);
|
||||
|
||||
activate_display(DISPLAY_DOWNLOAD_LIST);
|
||||
@@ -121,10 +112,14 @@ DownloadList::disable() {
|
||||
|
||||
m_frame = NULL;
|
||||
|
||||
priority_queue_erase(&taskScheduler, &m_taskUpdate);
|
||||
control->input()->erase(&m_bindings);
|
||||
}
|
||||
|
||||
core::View*
|
||||
DownloadList::current_view() {
|
||||
return dynamic_cast<ElementDownloadList*>(m_uiArray[DISPLAY_DOWNLOAD_LIST])->view();
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::activate_display(Display displayType) {
|
||||
if (!is_active())
|
||||
@@ -144,7 +139,6 @@ DownloadList::activate_display(Display displayType) {
|
||||
delete m_uiArray[m_state];
|
||||
m_uiArray[m_state] = NULL;
|
||||
|
||||
control->input()->push_front(&m_bindings);
|
||||
break;
|
||||
|
||||
case DISPLAY_DOWNLOAD_LIST:
|
||||
@@ -171,16 +165,14 @@ DownloadList::activate_display(Display displayType) {
|
||||
switch (displayType) {
|
||||
case DISPLAY_DOWNLOAD:
|
||||
// If no download has the focus, just return to the download list.
|
||||
if (m_view->focus() == m_view->end_visible()) {
|
||||
if (current_view()->focus() == current_view()->end_visible()) {
|
||||
m_state = DISPLAY_MAX_SIZE;
|
||||
|
||||
activate_display(DISPLAY_DOWNLOAD_LIST);
|
||||
return;
|
||||
|
||||
} else {
|
||||
control->input()->erase(&m_bindings);
|
||||
|
||||
Download* download = new Download(*m_view->focus());
|
||||
Download* download = new Download(*current_view()->focus());
|
||||
|
||||
download->activate(m_frame);
|
||||
download->bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_DOWNLOAD_LIST);
|
||||
@@ -196,6 +188,7 @@ DownloadList::activate_display(Display displayType) {
|
||||
|
||||
m_frame->frame(1)->initialize_window(m_windowLog);
|
||||
m_windowLog->set_active(true);
|
||||
m_windowLog->receive_update();
|
||||
break;
|
||||
|
||||
case DISPLAY_LOG:
|
||||
@@ -217,108 +210,6 @@ DownloadList::activate_display(Display displayType) {
|
||||
control->display()->adjust_layout();
|
||||
}
|
||||
|
||||
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
|
||||
DownloadList::receive_start_download() {
|
||||
if (m_view->focus() == m_view->end_visible())
|
||||
return;
|
||||
|
||||
control->core()->download_list()->start_normal(*m_view->focus());
|
||||
m_view->set_last_changed();
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_stop_download() {
|
||||
if (m_view->focus() == m_view->end_visible())
|
||||
return;
|
||||
|
||||
if ((*m_view->focus())->variable()->get_value("state") == 1)
|
||||
control->core()->download_list()->stop_normal(*m_view->focus());
|
||||
else
|
||||
control->core()->download_list()->erase(*m_view->focus());
|
||||
|
||||
m_view->set_last_changed();
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_close_download() {
|
||||
if (m_view->focus() == m_view->end_visible())
|
||||
return;
|
||||
|
||||
core::Download* download = *m_view->focus();
|
||||
|
||||
control->core()->download_list()->stop_normal(download);
|
||||
control->core()->download_list()->close(download);
|
||||
m_view->set_last_changed();
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_next_priority() {
|
||||
if (m_view->focus() == m_view->end_visible())
|
||||
return;
|
||||
|
||||
(*m_view->focus())->set_priority(((*m_view->focus())->priority() + 1) % 4);
|
||||
// (*m_window)->mark_dirty();
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_prev_priority() {
|
||||
if (m_view->focus() == m_view->end_visible())
|
||||
return;
|
||||
|
||||
(*m_view->focus())->set_priority(((*m_view->focus())->priority() - 1) % 4);
|
||||
// (*m_window)->mark_dirty();
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_check_hash() {
|
||||
if (m_view->focus() == m_view->end_visible())
|
||||
return;
|
||||
|
||||
// Catch here?
|
||||
control->core()->download_list()->check_hash(*m_view->focus());
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_ignore_ratio() {
|
||||
if (m_view->focus() == m_view->end_visible())
|
||||
return;
|
||||
|
||||
if ((*m_view->focus())->variable()->get_value("ignore_commands") != 0) {
|
||||
(*m_view->focus())->variable()->set("ignore_commands", (int64_t)0);
|
||||
control->core()->push_log("Torrent set to heed commands.");
|
||||
} else {
|
||||
(*m_view->focus())->variable()->set("ignore_commands", (int64_t)1);
|
||||
control->core()->push_log("Torrent set to ignore commands.");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_clear_tied() {
|
||||
if (m_view->focus() == m_view->end_visible())
|
||||
return;
|
||||
|
||||
const std::string& tiedFile = (*m_view->focus())->variable()->get_string("tied_to_file");
|
||||
|
||||
if (!tiedFile.empty()) {
|
||||
// Move this into core?
|
||||
control->core()->delete_tied(*m_view->focus());
|
||||
|
||||
control->core()->push_log("Cleared tied to file association for download.");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_view_input(Input type) {
|
||||
if (control->ui()->current_input() != NULL)
|
||||
@@ -365,7 +256,6 @@ DownloadList::receive_view_input(Input type) {
|
||||
input->bindings()[KEY_ENTER] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_exit_input), type);
|
||||
input->bindings()['\x07'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_exit_input), INPUT_NONE);
|
||||
|
||||
m_bindings.disable();
|
||||
control->ui()->enable_input(title, input);
|
||||
}
|
||||
|
||||
@@ -378,7 +268,6 @@ DownloadList::receive_exit_input(Input type) {
|
||||
return;
|
||||
|
||||
control->ui()->disable_input();
|
||||
m_bindings.enable();
|
||||
|
||||
try {
|
||||
|
||||
@@ -392,11 +281,11 @@ DownloadList::receive_exit_input(Input type) {
|
||||
break;
|
||||
|
||||
case INPUT_CHANGE_DIRECTORY:
|
||||
if (m_view->focus() == m_view->end_visible())
|
||||
if (current_view()->focus() == current_view()->end_visible())
|
||||
throw torrent::input_error("No download in focus to change root directory.");
|
||||
|
||||
(*m_view->focus())->variable()->set("directory", rak::trim(input->str()));
|
||||
control->core()->push_log("New root directory \"" + (*m_view->focus())->variable()->get_string("directory") + "\" for torrent.");
|
||||
(*current_view()->focus())->variable()->set("directory", rak::trim(input->str()));
|
||||
control->core()->push_log("New root directory \"" + (*current_view()->focus())->variable()->get_string("directory") + "\" for torrent.");
|
||||
break;
|
||||
|
||||
case INPUT_COMMAND:
|
||||
@@ -418,51 +307,14 @@ DownloadList::receive_exit_input(Input type) {
|
||||
|
||||
void
|
||||
DownloadList::receive_download_erased(core::Download* d) {
|
||||
if (m_view->focus() == m_view->end_visible() || *m_view->focus() != d)
|
||||
if (m_state != DISPLAY_DOWNLOAD || current_view()->focus() == current_view()->end_visible() || *current_view()->focus() != d)
|
||||
return;
|
||||
|
||||
activate_display(DISPLAY_DOWNLOAD_LIST);
|
||||
receive_next();
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_change_view(const std::string& name) {
|
||||
core::ViewManager::iterator itr = control->view_manager()->find(name);
|
||||
|
||||
if (itr == control->view_manager()->end()) {
|
||||
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::client_error("DownloadList::receive_change_view(...) could not cast ui.");
|
||||
|
||||
ui->set_view(m_view);
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::task_update() {
|
||||
m_windowLog->receive_update();
|
||||
|
||||
priority_queue_insert(&taskScheduler, &m_taskUpdate, (cachedTime + rak::timer::from_seconds(1)).round_seconds());
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::setup_keys() {
|
||||
m_bindings['\x13'] = sigc::mem_fun(*this, &DownloadList::receive_start_download);
|
||||
m_bindings['\x04'] = sigc::mem_fun(*this, &DownloadList::receive_stop_download);
|
||||
m_bindings['\x0B'] = sigc::mem_fun(*this, &DownloadList::receive_close_download);
|
||||
m_bindings['\x12'] = sigc::mem_fun(*this, &DownloadList::receive_check_hash);
|
||||
m_bindings['+'] = sigc::mem_fun(*this, &DownloadList::receive_next_priority);
|
||||
m_bindings['-'] = sigc::mem_fun(*this, &DownloadList::receive_prev_priority);
|
||||
m_bindings['I'] = sigc::mem_fun(*this, &DownloadList::receive_ignore_ratio);
|
||||
m_bindings['U'] = sigc::mem_fun(*this, &DownloadList::receive_clear_tied);
|
||||
|
||||
m_bindings['\x7f'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), INPUT_LOAD_DEFAULT);
|
||||
m_bindings[KEY_BACKSPACE] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), INPUT_LOAD_DEFAULT);
|
||||
m_bindings['\n'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), INPUT_LOAD_MODIFIED);
|
||||
@@ -470,36 +322,11 @@ DownloadList::setup_keys() {
|
||||
m_bindings['\x0F'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), INPUT_CHANGE_DIRECTORY);
|
||||
m_bindings['\x10'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), INPUT_COMMAND);
|
||||
|
||||
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::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_DOWNLOAD);
|
||||
m_bindings['l'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_LOG);
|
||||
m_uiArray[DISPLAY_LOG]->bindings()[' '] = sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_DOWNLOAD_LIST);
|
||||
m_uiArray[DISPLAY_LOG]->bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_DOWNLOAD_LIST);
|
||||
|
||||
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), "name");
|
||||
m_bindings['3'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "started");
|
||||
m_bindings['4'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "stopped");
|
||||
m_bindings['5'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "complete");
|
||||
m_bindings['6'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "incomplete");
|
||||
m_bindings['7'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "hashing");
|
||||
|
||||
m_uiArray[DISPLAY_LOG]->bindings()[' '] = sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_DOWNLOAD_LIST);
|
||||
m_uiArray[DISPLAY_LOG]->bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_DOWNLOAD_LIST);
|
||||
m_uiArray[DISPLAY_DOWNLOAD_LIST]->bindings()[KEY_RIGHT] = sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_DOWNLOAD);
|
||||
m_uiArray[DISPLAY_DOWNLOAD_LIST]->bindings()['l'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_LOG);
|
||||
}
|
||||
|
||||
// void
|
||||
// DownloadList::setup_input() {
|
||||
// input::PathInput* p = new input::PathInput;
|
||||
// m_windowTextInput = new WInput(p);
|
||||
|
||||
// p->slot_dirty(sigc::mem_fun(*m_windowTextInput, &WInput::mark_dirty));
|
||||
|
||||
// p->signal_show_next().connect(sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_STRING_LIST));
|
||||
// p->signal_show_next().connect(sigc::mem_fun(*esl, &ElementStringList::next_screen));
|
||||
|
||||
// p->signal_show_range().connect(sigc::hide(sigc::hide(sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_STRING_LIST))));
|
||||
// p->signal_show_range().connect(sigc::mem_fun(*esl, &ElementStringList::set_range<utils::Directory::iterator>));
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
+1
-24
@@ -100,7 +100,7 @@ public:
|
||||
|
||||
void activate_display(Display d);
|
||||
|
||||
display::Window* window() { return NULL; }
|
||||
core::View* current_view();
|
||||
|
||||
void slot_open_uri(SlotOpenUri s) { m_slotOpenUri = s; }
|
||||
|
||||
@@ -108,30 +108,11 @@ private:
|
||||
DownloadList(const DownloadList&);
|
||||
void operator = (const DownloadList&);
|
||||
|
||||
void receive_next();
|
||||
void receive_prev();
|
||||
|
||||
void receive_start_download();
|
||||
void receive_stop_download();
|
||||
void receive_close_download();
|
||||
|
||||
void receive_next_priority();
|
||||
void receive_prev_priority();
|
||||
|
||||
void receive_check_hash();
|
||||
|
||||
void receive_ignore_ratio();
|
||||
void receive_clear_tied();
|
||||
|
||||
void receive_view_input(Input type);
|
||||
void receive_exit_input(Input type);
|
||||
|
||||
void receive_download_erased(core::Download* d);
|
||||
|
||||
void receive_change_view(const std::string& name);
|
||||
|
||||
void task_update();
|
||||
|
||||
void setup_keys();
|
||||
void setup_input();
|
||||
|
||||
@@ -140,10 +121,6 @@ private:
|
||||
ElementBase* m_uiArray[DISPLAY_MAX_SIZE];
|
||||
WLog* m_windowLog;
|
||||
|
||||
core::View* m_view;
|
||||
|
||||
rak::priority_item m_taskUpdate;
|
||||
|
||||
SlotOpenUri m_slotOpenUri;
|
||||
};
|
||||
|
||||
|
||||
@@ -58,8 +58,6 @@ public:
|
||||
virtual void activate(display::Frame* frame) = 0;
|
||||
virtual void disable() = 0;
|
||||
|
||||
virtual display::Window* window() = 0;
|
||||
|
||||
protected:
|
||||
display::Frame* m_frame;
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ ElementChunksSeen::activate(display::Frame* frame) {
|
||||
if (is_active())
|
||||
throw torrent::client_error("ui::ElementChunksSeen::activate(...) is_active().");
|
||||
|
||||
control->input()->push_front(&m_bindings);
|
||||
control->input()->push_back(&m_bindings);
|
||||
|
||||
m_window = new WChunksSeen(m_download, &m_focus);
|
||||
m_window->set_active(true);
|
||||
|
||||
@@ -36,8 +36,13 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sigc++/bind.h>
|
||||
#include <torrent/exceptions.h>
|
||||
|
||||
#include "core/download.h"
|
||||
#include "core/manager.h"
|
||||
#include "core/view.h"
|
||||
#include "core/view_manager.h"
|
||||
#include "display/frame.h"
|
||||
#include "display/manager.h"
|
||||
#include "input/manager.h"
|
||||
@@ -47,12 +52,42 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
ElementDownloadList::ElementDownloadList() :
|
||||
m_window(NULL),
|
||||
m_view(NULL) {
|
||||
|
||||
receive_change_view("main");
|
||||
|
||||
if (m_view == NULL)
|
||||
throw torrent::client_error("View \"main\" must be present to initialize the main display.");
|
||||
|
||||
m_bindings['\x13'] = sigc::mem_fun(*this, &ElementDownloadList::receive_start_download);
|
||||
m_bindings['\x04'] = sigc::mem_fun(*this, &ElementDownloadList::receive_stop_download);
|
||||
m_bindings['\x0B'] = sigc::mem_fun(*this, &ElementDownloadList::receive_close_download);
|
||||
m_bindings['\x12'] = sigc::mem_fun(*this, &ElementDownloadList::receive_check_hash);
|
||||
m_bindings['+'] = sigc::mem_fun(*this, &ElementDownloadList::receive_next_priority);
|
||||
m_bindings['-'] = sigc::mem_fun(*this, &ElementDownloadList::receive_prev_priority);
|
||||
m_bindings['I'] = sigc::mem_fun(*this, &ElementDownloadList::receive_ignore_ratio);
|
||||
m_bindings['U'] = sigc::mem_fun(*this, &ElementDownloadList::receive_clear_tied);
|
||||
|
||||
m_bindings['1'] = sigc::bind(sigc::mem_fun(*this, &ElementDownloadList::receive_change_view), "main");
|
||||
m_bindings['2'] = sigc::bind(sigc::mem_fun(*this, &ElementDownloadList::receive_change_view), "name");
|
||||
m_bindings['3'] = sigc::bind(sigc::mem_fun(*this, &ElementDownloadList::receive_change_view), "started");
|
||||
m_bindings['4'] = sigc::bind(sigc::mem_fun(*this, &ElementDownloadList::receive_change_view), "stopped");
|
||||
m_bindings['5'] = sigc::bind(sigc::mem_fun(*this, &ElementDownloadList::receive_change_view), "complete");
|
||||
m_bindings['6'] = sigc::bind(sigc::mem_fun(*this, &ElementDownloadList::receive_change_view), "incomplete");
|
||||
m_bindings['7'] = sigc::bind(sigc::mem_fun(*this, &ElementDownloadList::receive_change_view), "hashing");
|
||||
|
||||
m_bindings[KEY_UP] = sigc::mem_fun(*this, &ElementDownloadList::receive_prev);
|
||||
m_bindings[KEY_DOWN] = sigc::mem_fun(*this, &ElementDownloadList::receive_next);
|
||||
}
|
||||
|
||||
void
|
||||
ElementDownloadList::activate(display::Frame* frame) {
|
||||
if (is_active())
|
||||
throw torrent::client_error("ui::ElementDownloadList::activate(...) is_active().");
|
||||
|
||||
control->input()->push_front(&m_bindings);
|
||||
control->input()->push_back(&m_bindings);
|
||||
|
||||
m_window = new WDownloadList();
|
||||
m_window->set_active(true);
|
||||
@@ -60,8 +95,6 @@ ElementDownloadList::activate(display::Frame* frame) {
|
||||
|
||||
m_frame = frame;
|
||||
m_frame->initialize_window(m_window);
|
||||
|
||||
control->display()->schedule(m_window, cachedTime);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -81,6 +114,7 @@ ElementDownloadList::disable() {
|
||||
void
|
||||
ElementDownloadList::set_view(core::View* l) {
|
||||
m_view = l;
|
||||
m_view->sort();
|
||||
|
||||
if (m_window == NULL)
|
||||
return;
|
||||
@@ -89,4 +123,120 @@ ElementDownloadList::set_view(core::View* l) {
|
||||
m_window->mark_dirty();
|
||||
}
|
||||
|
||||
void
|
||||
ElementDownloadList::receive_next() {
|
||||
m_view->next_focus();
|
||||
m_view->set_last_changed();
|
||||
}
|
||||
|
||||
void
|
||||
ElementDownloadList::receive_prev() {
|
||||
m_view->prev_focus();
|
||||
m_view->set_last_changed();
|
||||
}
|
||||
|
||||
void
|
||||
ElementDownloadList::receive_start_download() {
|
||||
if (m_view->focus() == m_view->end_visible())
|
||||
return;
|
||||
|
||||
control->core()->download_list()->start_normal(*m_view->focus());
|
||||
m_view->set_last_changed();
|
||||
}
|
||||
|
||||
void
|
||||
ElementDownloadList::receive_stop_download() {
|
||||
if (m_view->focus() == m_view->end_visible())
|
||||
return;
|
||||
|
||||
if ((*m_view->focus())->variable()->get_value("state") == 1)
|
||||
control->core()->download_list()->stop_normal(*m_view->focus());
|
||||
else
|
||||
control->core()->download_list()->erase(*m_view->focus());
|
||||
|
||||
m_view->set_last_changed();
|
||||
}
|
||||
|
||||
void
|
||||
ElementDownloadList::receive_close_download() {
|
||||
if (m_view->focus() == m_view->end_visible())
|
||||
return;
|
||||
|
||||
core::Download* download = *m_view->focus();
|
||||
|
||||
download->variable()->set("ignore_commands", (int64_t)1);
|
||||
|
||||
control->core()->download_list()->stop_normal(download);
|
||||
control->core()->download_list()->close(download);
|
||||
m_view->set_last_changed();
|
||||
}
|
||||
|
||||
void
|
||||
ElementDownloadList::receive_next_priority() {
|
||||
if (m_view->focus() == m_view->end_visible())
|
||||
return;
|
||||
|
||||
(*m_view->focus())->set_priority(((*m_view->focus())->priority() + 1) % 4);
|
||||
m_window->mark_dirty();
|
||||
}
|
||||
|
||||
void
|
||||
ElementDownloadList::receive_prev_priority() {
|
||||
if (m_view->focus() == m_view->end_visible())
|
||||
return;
|
||||
|
||||
(*m_view->focus())->set_priority(((*m_view->focus())->priority() - 1) % 4);
|
||||
m_window->mark_dirty();
|
||||
}
|
||||
|
||||
void
|
||||
ElementDownloadList::receive_check_hash() {
|
||||
if (m_view->focus() == m_view->end_visible())
|
||||
return;
|
||||
|
||||
// Catch here?
|
||||
control->core()->download_list()->check_hash(*m_view->focus());
|
||||
}
|
||||
|
||||
void
|
||||
ElementDownloadList::receive_ignore_ratio() {
|
||||
if (m_view->focus() == m_view->end_visible())
|
||||
return;
|
||||
|
||||
if ((*m_view->focus())->variable()->get_value("ignore_commands") != 0) {
|
||||
(*m_view->focus())->variable()->set("ignore_commands", (int64_t)0);
|
||||
control->core()->push_log("Torrent set to heed commands.");
|
||||
} else {
|
||||
(*m_view->focus())->variable()->set("ignore_commands", (int64_t)1);
|
||||
control->core()->push_log("Torrent set to ignore commands.");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ElementDownloadList::receive_clear_tied() {
|
||||
if (m_view->focus() == m_view->end_visible())
|
||||
return;
|
||||
|
||||
const std::string& tiedFile = (*m_view->focus())->variable()->get_string("tied_to_file");
|
||||
|
||||
if (!tiedFile.empty()) {
|
||||
// Move this into core?
|
||||
control->core()->delete_tied(*m_view->focus());
|
||||
|
||||
control->core()->push_log("Cleared tied to file association for download.");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ElementDownloadList::receive_change_view(const std::string& name) {
|
||||
core::ViewManager::iterator itr = control->view_manager()->find(name);
|
||||
|
||||
if (itr == control->view_manager()->end()) {
|
||||
control->core()->push_log("Could not find view \"" + name + "\".");
|
||||
return;
|
||||
}
|
||||
|
||||
set_view(*itr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,18 +54,34 @@ class ElementDownloadList : public ElementBase {
|
||||
public:
|
||||
typedef display::WindowDownloadList WDownloadList;
|
||||
|
||||
ElementDownloadList() : m_window(NULL), m_view(NULL) {}
|
||||
ElementDownloadList();
|
||||
|
||||
void activate(display::Frame* frame);
|
||||
void disable();
|
||||
|
||||
display::Window* window() { return m_window; }
|
||||
|
||||
core::View* view() { return m_view; }
|
||||
void set_view(core::View* l);
|
||||
|
||||
void receive_next();
|
||||
void receive_prev();
|
||||
|
||||
void receive_start_download();
|
||||
void receive_stop_download();
|
||||
void receive_close_download();
|
||||
|
||||
void receive_next_priority();
|
||||
void receive_prev_priority();
|
||||
|
||||
void receive_check_hash();
|
||||
|
||||
void receive_ignore_ratio();
|
||||
void receive_clear_tied();
|
||||
|
||||
void receive_change_view(const std::string& name);
|
||||
|
||||
private:
|
||||
WDownloadList* m_window;
|
||||
core::View* m_view;
|
||||
WDownloadList* m_window;
|
||||
core::View* m_view;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ ElementFileList::activate(display::Frame* frame) {
|
||||
if (m_window != NULL)
|
||||
throw torrent::client_error("ui::ElementFileList::activate(...) is_active().");
|
||||
|
||||
control->input()->push_front(&m_bindings);
|
||||
control->input()->push_back(&m_bindings);
|
||||
|
||||
m_window = new WFileList(m_download, &m_focus);
|
||||
m_window->set_active(true);
|
||||
|
||||
@@ -58,7 +58,7 @@ ElementLogComplete::activate(display::Frame* frame) {
|
||||
if (is_active())
|
||||
throw torrent::client_error("ui::ElementLogComplete::activate(...) is_active().");
|
||||
|
||||
control->input()->push_front(&m_bindings);
|
||||
control->input()->push_back(&m_bindings);
|
||||
|
||||
m_window = new WLogComplete(m_log);
|
||||
m_window->set_active(true);
|
||||
|
||||
@@ -60,7 +60,7 @@ ElementPeerInfo::activate(display::Frame* frame) {
|
||||
if (is_active())
|
||||
throw torrent::client_error("ui::ElementPeerInfo::activate(...) is_active().");
|
||||
|
||||
control->input()->push_front(&m_bindings);
|
||||
control->input()->push_back(&m_bindings);
|
||||
|
||||
m_window = new WPeerInfo(m_download, m_list, m_focus);
|
||||
m_window->set_active(true);
|
||||
|
||||
@@ -59,7 +59,7 @@ ElementPeerList::activate(display::Frame* frame) {
|
||||
if (is_active())
|
||||
throw torrent::client_error("ui::ElementPeerList::activate(...) is_active().");
|
||||
|
||||
control->input()->push_front(&m_bindings);
|
||||
control->input()->push_back(&m_bindings);
|
||||
|
||||
m_window = new WPeerList(m_download, m_list, m_focus);
|
||||
m_window->set_active(true);
|
||||
|
||||
@@ -55,7 +55,7 @@ ElementStringList::activate(display::Frame* frame) {
|
||||
if (is_active())
|
||||
throw torrent::client_error("ui::ElementStringList::activate(...) is_active().");
|
||||
|
||||
control->input()->push_front(&m_bindings);
|
||||
control->input()->push_back(&m_bindings);
|
||||
|
||||
m_window = new WStringList();
|
||||
m_window->set_active(true);
|
||||
|
||||
@@ -65,7 +65,7 @@ ElementTrackerList::activate(display::Frame* frame) {
|
||||
if (m_window != NULL)
|
||||
throw torrent::client_error("ui::ElementTrackerList::activate(...) is_active().");
|
||||
|
||||
control->input()->push_front(&m_bindings);
|
||||
control->input()->push_back(&m_bindings);
|
||||
|
||||
m_window = new WTrackerList(m_download, &m_focus);
|
||||
m_window->set_active(true);
|
||||
|
||||
@@ -65,7 +65,7 @@ ElementTransferList::activate(display::Frame* frame) {
|
||||
if (is_active())
|
||||
throw torrent::client_error("ui::ElementTransferList::activate(...) is_active().");
|
||||
|
||||
control->input()->push_front(&m_bindings);
|
||||
control->input()->push_back(&m_bindings);
|
||||
|
||||
m_window = new WTransferList(m_download, &m_focus);
|
||||
m_window->set_active(true);
|
||||
|
||||
@@ -198,6 +198,9 @@ Root::enable_input(const std::string& title, input::TextInput* input) {
|
||||
m_windowInput->set_title(title);
|
||||
m_windowInput->set_focus(true);
|
||||
|
||||
input->bindings()['\x0C'] = sigc::mem_fun(m_control->display(), &display::Manager::force_redraw); // ^L
|
||||
input->bindings()['\x11'] = sigc::mem_fun(m_control, &Control::receive_normal_shutdown); // ^Q
|
||||
|
||||
control->input()->set_text_input(input);
|
||||
control->display()->adjust_layout();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user