mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-15 22:52:31 +00:00
Added changing of the file priorities.
Seperated the algorithm extensions from functional. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@326 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+3
-4
@@ -104,8 +104,8 @@ Download::activate_display(Display d) {
|
||||
case DISPLAY_MAIN:
|
||||
*m_window = wpl = new WPeerList(m_download, &m_peers, &m_focus);
|
||||
|
||||
(*m_bindings)[KEY_RIGHT] = sigc::bind(sigc::mem_fun(*this, &Download::receive_change), DISPLAY_PEER);
|
||||
(*m_bindings)['p'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_change), DISPLAY_FILE_LIST);
|
||||
(*m_bindings)['p'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_change), DISPLAY_PEER);
|
||||
(*m_bindings)[KEY_RIGHT] = sigc::bind(sigc::mem_fun(*this, &Download::receive_change), DISPLAY_FILE_LIST);
|
||||
break;
|
||||
|
||||
case DISPLAY_PEER:
|
||||
@@ -116,8 +116,8 @@ Download::activate_display(Display d) {
|
||||
|
||||
case DISPLAY_FILE_LIST:
|
||||
m_uiFileList->activate(m_window);
|
||||
m_uiFileList->get_bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(*this, &Download::receive_change), DISPLAY_MAIN);
|
||||
|
||||
(*m_bindings)[' '] = sigc::bind(sigc::mem_fun(*this, &Download::receive_change), DISPLAY_MAIN);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -145,7 +145,6 @@ Download::disable_display() {
|
||||
|
||||
case DISPLAY_FILE_LIST:
|
||||
m_uiFileList->disable();
|
||||
m_bindings->erase(' ');
|
||||
*m_window = NULL;
|
||||
|
||||
return;
|
||||
|
||||
+40
-3
@@ -15,6 +15,7 @@ FileList::FileList(Control* c, core::Download* d) :
|
||||
m_control(c),
|
||||
m_focus(0) {
|
||||
|
||||
m_bindings[' '] = sigc::mem_fun(*this, &FileList::receive_priority);
|
||||
m_bindings[KEY_DOWN] = sigc::mem_fun(*this, &FileList::receive_next);
|
||||
m_bindings[KEY_UP] = sigc::mem_fun(*this, &FileList::receive_prev);
|
||||
}
|
||||
@@ -45,7 +46,7 @@ FileList::receive_next() {
|
||||
if (m_window == NULL)
|
||||
throw std::logic_error("ui::FileList::receive_next(...) called on a disabled object");
|
||||
|
||||
if (++m_focus >= (int)m_download->get_download().get_entry_size())
|
||||
if (++m_focus >= m_download->get_download().get_entry_size())
|
||||
m_focus = 0;
|
||||
|
||||
m_window->mark_dirty();
|
||||
@@ -56,8 +57,44 @@ FileList::receive_prev() {
|
||||
if (m_window == NULL)
|
||||
throw std::logic_error("ui::FileList::receive_prev(...) called on a disabled object");
|
||||
|
||||
if (--m_focus < 0)
|
||||
m_focus = std::max(0, (int)m_download->get_download().get_entry_size() - 1);
|
||||
if (m_download->get_download().get_entry_size() == 0)
|
||||
return;
|
||||
|
||||
if (m_focus != 0)
|
||||
--m_focus;
|
||||
else
|
||||
m_focus = m_download->get_download().get_entry_size() - 1;
|
||||
|
||||
m_window->mark_dirty();
|
||||
}
|
||||
|
||||
void
|
||||
FileList::receive_priority() {
|
||||
if (m_window == NULL)
|
||||
throw std::logic_error("ui::FileList::receive_prev(...) called on a disabled object");
|
||||
|
||||
if (m_focus >= m_download->get_download().get_entry_size())
|
||||
return;
|
||||
|
||||
torrent::Entry e = m_download->get_download().get_entry(m_focus);
|
||||
|
||||
switch (e.get_priority()) {
|
||||
case torrent::Entry::STOPPED:
|
||||
e.set_priority(torrent::Entry::HIGH);
|
||||
break;
|
||||
|
||||
case torrent::Entry::NORMAL:
|
||||
e.set_priority(torrent::Entry::STOPPED);
|
||||
break;
|
||||
|
||||
case torrent::Entry::HIGH:
|
||||
e.set_priority(torrent::Entry::NORMAL);
|
||||
break;
|
||||
|
||||
default:
|
||||
e.set_priority(torrent::Entry::NORMAL);
|
||||
break;
|
||||
};
|
||||
|
||||
m_window->mark_dirty();
|
||||
}
|
||||
|
||||
+5
-1
@@ -23,10 +23,14 @@ public:
|
||||
void activate(MItr mItr);
|
||||
void disable();
|
||||
|
||||
input::Bindings& get_bindings() { return m_bindings; }
|
||||
|
||||
private:
|
||||
void receive_next();
|
||||
void receive_prev();
|
||||
|
||||
void receive_priority();
|
||||
|
||||
core::Download* m_download;
|
||||
WFileList* m_window;
|
||||
|
||||
@@ -34,7 +38,7 @@ private:
|
||||
input::Bindings m_bindings;
|
||||
|
||||
// Change to unsigned, please.
|
||||
int m_focus;
|
||||
unsigned int m_focus;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user