mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-11 12:42:31 +00:00
Added file view.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@322 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -6,6 +6,8 @@ libsub_ui_a_SOURCES = \
|
||||
download.h \
|
||||
download_list.cc \
|
||||
download_list.h \
|
||||
file_list.cc \
|
||||
file_list.h \
|
||||
root.cc \
|
||||
root.h
|
||||
|
||||
|
||||
+29
-9
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "control.h"
|
||||
#include "download.h"
|
||||
#include "file_list.h"
|
||||
|
||||
namespace ui {
|
||||
|
||||
@@ -21,6 +22,8 @@ Download::Download(DPtr d, Control* c) :
|
||||
m_download(d),
|
||||
m_state(DISPLAY_NONE),
|
||||
|
||||
m_uiFileList(NULL),
|
||||
|
||||
m_title(c->get_display().end()),
|
||||
m_window(c->get_display().end()),
|
||||
m_downloadStatus(c->get_display().end()),
|
||||
@@ -57,6 +60,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_control->get_input().push_front(m_bindings);
|
||||
|
||||
activate_display(DISPLAY_MAIN);
|
||||
@@ -69,15 +74,19 @@ Download::disable() {
|
||||
|
||||
disable_display();
|
||||
|
||||
delete *m_title;
|
||||
delete *m_downloadStatus;
|
||||
delete *m_mainStatus;
|
||||
|
||||
m_control->get_display().erase(m_window);
|
||||
m_control->get_display().erase(m_title);
|
||||
m_control->get_display().erase(m_downloadStatus);
|
||||
m_control->get_display().erase(m_mainStatus);
|
||||
|
||||
delete *m_title;
|
||||
delete *m_downloadStatus;
|
||||
delete *m_mainStatus;
|
||||
|
||||
delete m_uiFileList;
|
||||
|
||||
m_uiFileList = NULL;
|
||||
|
||||
m_window = m_title = m_downloadStatus = m_mainStatus = m_control->get_display().end();
|
||||
|
||||
m_control->get_input().erase(m_bindings);
|
||||
@@ -93,21 +102,24 @@ Download::activate_display(Display d) {
|
||||
|
||||
switch (d) {
|
||||
case DISPLAY_MAIN:
|
||||
*m_window = wpl = new WPeerList(&m_peers, &m_focus);
|
||||
|
||||
wpl->slot_chunks_total(sigc::mem_fun(m_download->get_download(), &torrent::Download::get_chunks_total));
|
||||
*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);
|
||||
break;
|
||||
|
||||
case DISPLAY_PEER:
|
||||
*m_window = wpi = new WPeerInfo(m_download, &m_peers, &m_focus);
|
||||
|
||||
wpi->slot_chunks_total(sigc::mem_fun(m_download->get_download(), &torrent::Download::get_chunks_total));
|
||||
|
||||
(*m_bindings)[' '] = sigc::bind(sigc::mem_fun(*this, &Download::receive_change), DISPLAY_MAIN);
|
||||
break;
|
||||
|
||||
case DISPLAY_FILE_LIST:
|
||||
m_uiFileList->activate(m_window);
|
||||
|
||||
(*m_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");
|
||||
}
|
||||
@@ -131,10 +143,18 @@ Download::disable_display() {
|
||||
|
||||
break;
|
||||
|
||||
case DISPLAY_FILE_LIST:
|
||||
m_uiFileList->disable();
|
||||
m_bindings->erase(' ');
|
||||
*m_window = NULL;
|
||||
|
||||
return;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// urgh, get ui's for the rest too.
|
||||
delete *m_window;
|
||||
|
||||
*m_window = NULL;
|
||||
|
||||
+6
-2
@@ -8,8 +8,8 @@
|
||||
namespace display {
|
||||
class WindowTitle;
|
||||
class WindowPeerInfo;
|
||||
class WindowPeerList;
|
||||
class WindowStatusbar;
|
||||
class WindowPeerList;
|
||||
class WindowDownloadStatusbar;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace core {
|
||||
namespace ui {
|
||||
|
||||
class Control;
|
||||
class FileList;
|
||||
|
||||
class Download {
|
||||
public:
|
||||
@@ -37,7 +38,8 @@ public:
|
||||
typedef enum {
|
||||
DISPLAY_NONE,
|
||||
DISPLAY_MAIN,
|
||||
DISPLAY_PEER
|
||||
DISPLAY_PEER,
|
||||
DISPLAY_FILE_LIST
|
||||
} Display;
|
||||
|
||||
// We own 'window'.
|
||||
@@ -79,6 +81,8 @@ private:
|
||||
|
||||
Display m_state;
|
||||
|
||||
FileList* m_uiFileList;
|
||||
|
||||
MItr m_title;
|
||||
MItr m_window;
|
||||
MItr m_downloadStatus;
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "display/window_file_list.h"
|
||||
|
||||
#include "control.h"
|
||||
#include "file_list.h"
|
||||
|
||||
namespace ui {
|
||||
|
||||
FileList::FileList(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, &FileList::receive_next);
|
||||
m_bindings[KEY_UP] = sigc::mem_fun(*this, &FileList::receive_prev);
|
||||
}
|
||||
|
||||
void
|
||||
FileList::activate(MItr mItr) {
|
||||
if (m_window != NULL)
|
||||
throw std::logic_error("ui::FileList::activate(...) called on an object in the wrong state");
|
||||
|
||||
m_control->get_input().push_front(&m_bindings);
|
||||
|
||||
*mItr = m_window = new WFileList(m_download, &m_focus);
|
||||
}
|
||||
|
||||
void
|
||||
FileList::disable() {
|
||||
if (m_window == NULL)
|
||||
throw std::logic_error("ui::FileList::disable(...) called on an object in the wrong state");
|
||||
|
||||
m_control->get_input().erase(&m_bindings);
|
||||
|
||||
delete m_window;
|
||||
m_window = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
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())
|
||||
m_focus = 0;
|
||||
|
||||
m_window->mark_dirty();
|
||||
}
|
||||
|
||||
void
|
||||
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);
|
||||
|
||||
m_window->mark_dirty();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
#ifndef RTORRENT_UI_FILE_LIST_H
|
||||
#define RTORRENT_UI_FILE_LIST_H
|
||||
|
||||
#include "core/download.h"
|
||||
#include "display/manager.h"
|
||||
#include "input/bindings.h"
|
||||
|
||||
namespace display {
|
||||
class WindowFileList;
|
||||
}
|
||||
|
||||
namespace ui {
|
||||
|
||||
class Control;
|
||||
|
||||
class FileList {
|
||||
public:
|
||||
typedef display::WindowFileList WFileList;
|
||||
typedef display::Manager::iterator MItr;
|
||||
|
||||
FileList(Control* c, core::Download* d);
|
||||
|
||||
void activate(MItr mItr);
|
||||
void disable();
|
||||
|
||||
private:
|
||||
void receive_next();
|
||||
void receive_prev();
|
||||
|
||||
core::Download* m_download;
|
||||
WFileList* m_window;
|
||||
|
||||
Control* m_control;
|
||||
input::Bindings m_bindings;
|
||||
|
||||
// Change to unsigned, please.
|
||||
int m_focus;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user