* Added pageup/down to chunks seen and file list. Patch by Josef

Drexler, all future patches to lib/rtorrent will be under public
domain.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@712 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2006-06-04 23:37:39 +00:00
parent 46dd41e956
commit d0f6719e50
7 changed files with 151 additions and 18 deletions
+67 -4
View File
@@ -48,10 +48,13 @@ namespace ui {
ElementChunksSeen::ElementChunksSeen(core::Download* d) :
m_download(d),
m_window(NULL) {
m_window(NULL),
m_focus(0) {
// m_bindings[KEY_DOWN] = sigc::mem_fun(*this, &ElementChunksSeen::receive_next);
// m_bindings[KEY_UP] = sigc::mem_fun(*this, &ElementChunksSeen::receive_prev);
m_bindings[KEY_DOWN] = sigc::mem_fun(*this, &ElementChunksSeen::receive_next);
m_bindings[KEY_UP] = sigc::mem_fun(*this, &ElementChunksSeen::receive_prev);
m_bindings[KEY_NPAGE] = sigc::mem_fun(*this, &ElementChunksSeen::receive_pagenext);
m_bindings[KEY_PPAGE] = sigc::mem_fun(*this, &ElementChunksSeen::receive_pageprev);
// m_bindings[' '] = sigc::mem_fun(*this, &ElementChunksSeen::receive_cycle_group);
// m_bindings['*'] = sigc::mem_fun(*this, &ElementChunksSeen::receive_disable);
}
@@ -63,7 +66,7 @@ ElementChunksSeen::activate(Control* c, MItr mItr) {
c->input()->push_front(&m_bindings);
*mItr = m_window = new WChunksSeen(m_download);
*mItr = m_window = new WChunksSeen(m_download, &m_focus);
}
void
@@ -90,4 +93,64 @@ ElementChunksSeen::disable(Control* c) {
// m_window->mark_dirty();
// }
void
ElementChunksSeen::receive_next() {
if (m_window == NULL)
throw torrent::client_error("ui::ElementChunksSeen::receive_next(...) called on a disabled object");
if (++m_focus > m_window->max_focus())
m_focus = 0;
m_window->mark_dirty();
}
void
ElementChunksSeen::receive_prev() {
if (m_window == NULL)
throw torrent::client_error("ui::ElementChunksSeen::receive_prev(...) called on a disabled object");
if (m_focus > 0)
--m_focus;
else
m_focus = m_window->max_focus();
m_window->mark_dirty();
}
void
ElementChunksSeen::receive_pagenext() {
if (m_window == NULL)
throw torrent::client_error("ui::ElementChunksSeen::receive_pagenext(...) called on a disabled object");
unsigned int visible = m_window->get_height() - 1;
unsigned int scrollable = std::max<int>(m_window->rows() - visible, 0);
if (scrollable == 0 || m_focus == scrollable)
m_focus = 0;
else if (m_focus + visible / 2 < scrollable)
m_focus += visible / 2;
else
m_focus = scrollable;
m_window->mark_dirty();
}
void
ElementChunksSeen::receive_pageprev() {
if (m_window == NULL)
throw torrent::client_error("ui::ElementChunksSeen::receive_pageprev(...) called on a disabled object");
unsigned int visible = m_window->get_height() - 1;
unsigned int scrollable = std::max<int>(m_window->rows() - visible, 0);
if (m_focus > visible / 2)
m_focus -= visible / 2;
else if (scrollable > 0 && m_focus == 0)
m_focus = scrollable;
else
m_focus = 0;
m_window->mark_dirty();
}
}
+7
View File
@@ -60,9 +60,16 @@ public:
private:
// void receive_disable();
void receive_next();
void receive_prev();
void receive_pagenext();
void receive_pageprev();
core::Download* m_download;
WChunksSeen* m_window;
unsigned int m_focus;
};
}
+41
View File
@@ -56,6 +56,8 @@ ElementFileList::ElementFileList(core::Download* d) :
m_bindings['*'] = sigc::mem_fun(*this, &ElementFileList::receive_change_all);
m_bindings[KEY_DOWN] = sigc::mem_fun(*this, &ElementFileList::receive_next);
m_bindings[KEY_UP] = sigc::mem_fun(*this, &ElementFileList::receive_prev);
m_bindings[KEY_NPAGE] = sigc::mem_fun(*this, &ElementFileList::receive_pagenext);
m_bindings[KEY_PPAGE] = sigc::mem_fun(*this, &ElementFileList::receive_pageprev);
}
void
@@ -108,6 +110,45 @@ ElementFileList::receive_prev() {
m_window->mark_dirty();
}
void
ElementFileList::receive_pagenext() {
if (m_window == NULL)
throw torrent::client_error("ui::ElementFileList::receive_pagenext(...) called on a disabled object");
unsigned int count = (m_window->get_height() - 1) / 2;
if (m_focus + count < m_download->download()->file_list().size())
m_focus += count;
else if (m_focus == m_download->download()->file_list().size() - 1)
m_focus = 0;
else
m_focus = m_download->download()->file_list().size() - 1;
m_window->mark_dirty();
}
void
ElementFileList::receive_pageprev() {
if (m_window == NULL)
throw torrent::client_error("ui::ElementFileList::receive_pageprev(...) called on a disabled object");
torrent::FileList fl = m_download->download()->file_list();
if (fl.size() == 0)
return;
unsigned int count = (m_window->get_height() - 1) / 2;
if (m_focus > count)
m_focus -= count;
else if (m_focus == 0)
m_focus = fl.size() - 1;
else
m_focus = 0;
m_window->mark_dirty();
}
void
ElementFileList::receive_priority() {
if (m_window == NULL)
+2
View File
@@ -64,6 +64,8 @@ public:
private:
void receive_next();
void receive_prev();
void receive_pagenext();
void receive_pageprev();
void receive_priority();
void receive_change_all();