mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-12 21:22:31 +00:00
Adding view of tracker list.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@338 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+3
-1
@@ -9,6 +9,8 @@ libsub_ui_a_SOURCES = \
|
||||
file_list.cc \
|
||||
file_list.h \
|
||||
root.cc \
|
||||
root.h
|
||||
root.h \
|
||||
tracker_list.cc \
|
||||
tracker_list.h
|
||||
|
||||
INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir)
|
||||
|
||||
+21
-3
@@ -15,6 +15,7 @@
|
||||
#include "control.h"
|
||||
#include "download.h"
|
||||
#include "file_list.h"
|
||||
#include "tracker_list.h"
|
||||
|
||||
namespace ui {
|
||||
|
||||
@@ -23,6 +24,7 @@ Download::Download(DPtr d, Control* c) :
|
||||
m_state(DISPLAY_NONE),
|
||||
|
||||
m_uiFileList(NULL),
|
||||
m_uiTrackerList(NULL),
|
||||
|
||||
m_title(c->get_display().end()),
|
||||
m_window(c->get_display().end()),
|
||||
@@ -60,7 +62,8 @@ Download::activate() {
|
||||
m_downloadStatus = m_control->get_display().insert(m_control->get_display().end(), new WDownloadStatus(m_download));
|
||||
m_mainStatus = m_control->get_display().insert(m_control->get_display().end(), new WMainStatus(&m_control->get_core()));
|
||||
|
||||
m_uiFileList = new FileList(m_control, m_download);
|
||||
m_uiFileList = new FileList(m_control, m_download);
|
||||
m_uiTrackerList = new TrackerList(m_control, m_download);
|
||||
|
||||
m_control->get_input().push_front(m_bindings);
|
||||
|
||||
@@ -84,8 +87,10 @@ Download::disable() {
|
||||
delete *m_mainStatus;
|
||||
|
||||
delete m_uiFileList;
|
||||
delete m_uiTrackerList;
|
||||
|
||||
m_uiFileList = NULL;
|
||||
m_uiTrackerList = NULL;
|
||||
|
||||
m_window = m_title = m_downloadStatus = m_mainStatus = m_control->get_display().end();
|
||||
|
||||
@@ -104,8 +109,9 @@ Download::activate_display(Display d) {
|
||||
case DISPLAY_MAIN:
|
||||
*m_window = wpl = new WPeerList(m_download, &m_peers, &m_focus);
|
||||
|
||||
(*m_bindings)['p'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_change), DISPLAY_PEER);
|
||||
(*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);
|
||||
(*m_bindings)['o'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_change), DISPLAY_TRACKER_LIST);
|
||||
break;
|
||||
|
||||
case DISPLAY_PEER:
|
||||
@@ -120,6 +126,12 @@ Download::activate_display(Display d) {
|
||||
|
||||
break;
|
||||
|
||||
case DISPLAY_TRACKER_LIST:
|
||||
m_uiTrackerList->activate(m_window);
|
||||
m_uiTrackerList->get_bindings()[' '] = sigc::bind(sigc::mem_fun(*this, &Download::receive_change), DISPLAY_MAIN);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw std::logic_error("ui::Download::activate_display(...) got wrong state");
|
||||
}
|
||||
@@ -134,7 +146,7 @@ void
|
||||
Download::disable_display() {
|
||||
switch (m_state) {
|
||||
case DISPLAY_MAIN:
|
||||
m_bindings->erase(KEY_RIGHT);
|
||||
//m_bindings->erase(KEY_RIGHT);
|
||||
|
||||
break;
|
||||
|
||||
@@ -149,6 +161,12 @@ Download::disable_display() {
|
||||
|
||||
return;
|
||||
|
||||
case DISPLAY_TRACKER_LIST:
|
||||
m_uiTrackerList->disable();
|
||||
*m_window = NULL;
|
||||
|
||||
return;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
+4
-1
@@ -21,6 +21,7 @@ namespace ui {
|
||||
|
||||
class Control;
|
||||
class FileList;
|
||||
class TrackerList;
|
||||
|
||||
class Download {
|
||||
public:
|
||||
@@ -39,7 +40,8 @@ public:
|
||||
DISPLAY_NONE,
|
||||
DISPLAY_MAIN,
|
||||
DISPLAY_PEER,
|
||||
DISPLAY_FILE_LIST
|
||||
DISPLAY_FILE_LIST,
|
||||
DISPLAY_TRACKER_LIST
|
||||
} Display;
|
||||
|
||||
// We own 'window'.
|
||||
@@ -82,6 +84,7 @@ private:
|
||||
Display m_state;
|
||||
|
||||
FileList* m_uiFileList;
|
||||
TrackerList* m_uiTrackerList;
|
||||
|
||||
MItr m_title;
|
||||
MItr m_window;
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "display/window_tracker_list.h"
|
||||
|
||||
#include "control.h"
|
||||
#include "tracker_list.h"
|
||||
|
||||
namespace ui {
|
||||
|
||||
TrackerList::TrackerList(Control* c, core::Download* d) :
|
||||
m_download(d),
|
||||
m_window(NULL),
|
||||
m_control(c),
|
||||
m_focus(0) {
|
||||
|
||||
m_bindings[KEY_DOWN] = sigc::mem_fun(*this, &TrackerList::receive_next);
|
||||
m_bindings[KEY_UP] = sigc::mem_fun(*this, &TrackerList::receive_prev);
|
||||
}
|
||||
|
||||
void
|
||||
TrackerList::activate(MItr mItr) {
|
||||
if (m_window != NULL)
|
||||
throw std::logic_error("ui::TrackerList::activate(...) called on an object in the wrong state");
|
||||
|
||||
m_control->get_input().push_front(&m_bindings);
|
||||
|
||||
*mItr = m_window = new WTrackerList(m_download, &m_focus);
|
||||
}
|
||||
|
||||
void
|
||||
TrackerList::disable() {
|
||||
if (m_window == NULL)
|
||||
throw std::logic_error("ui::TrackerList::disable(...) called on an object in the wrong state");
|
||||
|
||||
m_control->get_input().erase(&m_bindings);
|
||||
|
||||
delete m_window;
|
||||
m_window = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
TrackerList::receive_next() {
|
||||
if (m_window == NULL)
|
||||
throw std::logic_error("ui::TrackerList::receive_next(...) called on a disabled object");
|
||||
|
||||
if (++m_focus >= m_download->get_download().get_tracker_size())
|
||||
m_focus = 0;
|
||||
|
||||
m_window->mark_dirty();
|
||||
}
|
||||
|
||||
void
|
||||
TrackerList::receive_prev() {
|
||||
if (m_window == NULL)
|
||||
throw std::logic_error("ui::TrackerList::receive_prev(...) called on a disabled object");
|
||||
|
||||
if (m_download->get_download().get_tracker_size() == 0)
|
||||
return;
|
||||
|
||||
if (m_focus != 0)
|
||||
--m_focus;
|
||||
else
|
||||
m_focus = m_download->get_download().get_tracker_size() - 1;
|
||||
|
||||
m_window->mark_dirty();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef RTORRENT_UI_TRACKER_LIST_H
|
||||
#define RTORRENT_UI_TRACKER_LIST_H
|
||||
|
||||
#include "core/download.h"
|
||||
#include "display/manager.h"
|
||||
#include "input/bindings.h"
|
||||
|
||||
namespace display {
|
||||
class WindowTrackerList;
|
||||
}
|
||||
|
||||
namespace ui {
|
||||
|
||||
class Control;
|
||||
|
||||
class TrackerList {
|
||||
public:
|
||||
typedef display::WindowTrackerList WTrackerList;
|
||||
typedef display::Manager::iterator MItr;
|
||||
|
||||
TrackerList(Control* c, core::Download* d);
|
||||
|
||||
void activate(MItr mItr);
|
||||
void disable();
|
||||
|
||||
input::Bindings& get_bindings() { return m_bindings; }
|
||||
|
||||
private:
|
||||
void receive_next();
|
||||
void receive_prev();
|
||||
|
||||
core::Download* m_download;
|
||||
WTrackerList* m_window;
|
||||
|
||||
Control* m_control;
|
||||
input::Bindings m_bindings;
|
||||
|
||||
// Change to unsigned, please.
|
||||
unsigned int m_focus;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user