mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-14 14:12:31 +00:00
* Added TransferList to the API.
* Added transfer list view, bound to the 'u' key. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@715 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -17,6 +17,8 @@ libsub_display_a_SOURCES = \
|
||||
window_download_list.h \
|
||||
window_download_statusbar.cc \
|
||||
window_download_statusbar.h \
|
||||
window_download_transfer_list.cc \
|
||||
window_download_transfer_list.h \
|
||||
window_file_list.cc \
|
||||
window_file_list.h \
|
||||
window_http_queue.cc \
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
// rTorrent - BitTorrent client
|
||||
// Copyright (C) 2005-2006, Jari Sundell
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations
|
||||
// including the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for
|
||||
// all of the code used other than OpenSSL. If you modify file(s)
|
||||
// with this exception, you may extend this exception to your version
|
||||
// of the file(s), but you are not obligated to do so. If you do not
|
||||
// wish to do so, delete this exception statement from your version.
|
||||
// If you delete this exception statement from all source files in the
|
||||
// program, then also delete it here.
|
||||
//
|
||||
// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
//
|
||||
// Skomakerveien 33
|
||||
// 3185 Skoppum, NORWAY
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <stdexcept>
|
||||
#include <rak/string_manip.h>
|
||||
#include <torrent/block_list.h>
|
||||
#include <torrent/transfer_list.h>
|
||||
|
||||
#include "core/download.h"
|
||||
|
||||
#include "window_download_transfer_list.h"
|
||||
|
||||
namespace display {
|
||||
|
||||
WindowDownloadTransferList::WindowDownloadTransferList(core::Download* d, unsigned int *focus) :
|
||||
Window(new Canvas, true),
|
||||
m_download(d),
|
||||
m_focus(focus) {
|
||||
}
|
||||
|
||||
void
|
||||
WindowDownloadTransferList::redraw() {
|
||||
// TODO: Make this depend on tracker signal.
|
||||
m_slotSchedule(this, (cachedTime + rak::timer::from_seconds(1)).round_seconds());
|
||||
m_canvas->erase();
|
||||
|
||||
if (m_canvas->get_height() < 3 || m_canvas->get_width() < 18)
|
||||
return;
|
||||
|
||||
const torrent::TransferList* transfers = m_download->download()->transfer_list();
|
||||
|
||||
m_canvas->print(2, 0, "Transfer list: [Size %i]", transfers->size());
|
||||
|
||||
torrent::TransferList::const_iterator itr = transfers->begin();
|
||||
|
||||
// This is just for testing and the layout and included information
|
||||
// is just something i threw in there, someone really should
|
||||
// prettify this. (This is a very subtle hint)
|
||||
|
||||
for (int y = 1; y < m_canvas->get_height() && itr != transfers->end(); ++y, ++itr) {
|
||||
m_canvas->print(0, y, "%5u %3u %s",
|
||||
(*itr)->index(),
|
||||
(*itr)->finished(),
|
||||
(*itr)->is_all_finished() ? "done" : " ");
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int
|
||||
WindowDownloadTransferList::rows() const {
|
||||
if (m_canvas->get_width() < 18)
|
||||
return 0;
|
||||
|
||||
// return (m_download->download()->chunks_total() + chunks_per_row() - 1) / chunks_per_row();
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
// rTorrent - BitTorrent client
|
||||
// Copyright (C) 2005-2006, Jari Sundell
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations
|
||||
// including the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for
|
||||
// all of the code used other than OpenSSL. If you modify file(s)
|
||||
// with this exception, you may extend this exception to your version
|
||||
// of the file(s), but you are not obligated to do so. If you do not
|
||||
// wish to do so, delete this exception statement from your version.
|
||||
// If you delete this exception statement from all source files in the
|
||||
// program, then also delete it here.
|
||||
//
|
||||
// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
//
|
||||
// Skomakerveien 33
|
||||
// 3185 Skoppum, NORWAY
|
||||
|
||||
#ifndef RTORRENT_DISPLAY_WINDOW_DOWNLOAD_TRANSFER_LIST_H
|
||||
#define RTORRENT_DISPLAY_WINDOW_DOWNLOAD_TRANSFER_LIST_H
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "window.h"
|
||||
|
||||
namespace core {
|
||||
class Download;
|
||||
}
|
||||
|
||||
namespace display {
|
||||
|
||||
class WindowDownloadTransferList : public Window {
|
||||
public:
|
||||
WindowDownloadTransferList(core::Download* d, unsigned int* focus);
|
||||
|
||||
virtual void redraw();
|
||||
|
||||
unsigned int rows() const;
|
||||
|
||||
unsigned int max_focus() const { return std::max<int>(rows() - get_height() + 1, 0); }
|
||||
|
||||
private:
|
||||
core::Download* m_download;
|
||||
|
||||
unsigned int* m_focus;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -22,6 +22,8 @@ libsub_ui_a_SOURCES = \
|
||||
element_string_list.h \
|
||||
element_tracker_list.cc \
|
||||
element_tracker_list.h \
|
||||
element_transfer_list.cc \
|
||||
element_transfer_list.h \
|
||||
root.cc \
|
||||
root.h
|
||||
|
||||
|
||||
+8
-5
@@ -55,6 +55,7 @@
|
||||
#include "element_peer_list.h"
|
||||
#include "element_tracker_list.h"
|
||||
#include "element_chunks_seen.h"
|
||||
#include "element_transfer_list.h"
|
||||
|
||||
namespace ui {
|
||||
|
||||
@@ -72,11 +73,12 @@ Download::Download(DPtr d, Control* c) :
|
||||
|
||||
m_focus = m_peers.end();
|
||||
|
||||
m_uiArray[DISPLAY_PEER_LIST] = new ElementPeerList(d, &m_peers, &m_focus);
|
||||
m_uiArray[DISPLAY_PEER_INFO] = new ElementPeerInfo(d, &m_peers, &m_focus);
|
||||
m_uiArray[DISPLAY_FILE_LIST] = new ElementFileList(d);
|
||||
m_uiArray[DISPLAY_TRACKER_LIST] = new ElementTrackerList(d);
|
||||
m_uiArray[DISPLAY_CHUNKS_SEEN] = new ElementChunksSeen(d);
|
||||
m_uiArray[DISPLAY_PEER_LIST] = new ElementPeerList(d, &m_peers, &m_focus);
|
||||
m_uiArray[DISPLAY_PEER_INFO] = new ElementPeerInfo(d, &m_peers, &m_focus);
|
||||
m_uiArray[DISPLAY_FILE_LIST] = new ElementFileList(d);
|
||||
m_uiArray[DISPLAY_TRACKER_LIST] = new ElementTrackerList(d);
|
||||
m_uiArray[DISPLAY_CHUNKS_SEEN] = new ElementChunksSeen(d);
|
||||
m_uiArray[DISPLAY_TRANSFER_LIST] = new ElementTransferList(d);
|
||||
|
||||
bind_keys();
|
||||
|
||||
@@ -271,6 +273,7 @@ Download::bind_keys() {
|
||||
(*m_bindings)['p'] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_PEER_INFO);
|
||||
(*m_bindings)['o'] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_TRACKER_LIST);
|
||||
(*m_bindings)['i'] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_CHUNKS_SEEN);
|
||||
(*m_bindings)['u'] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_TRANSFER_LIST);
|
||||
|
||||
(*m_bindings)[KEY_UP] = sigc::mem_fun(this, &Download::receive_prev);
|
||||
(*m_bindings)[KEY_DOWN] = sigc::mem_fun(this, &Download::receive_next);
|
||||
|
||||
@@ -75,6 +75,7 @@ public:
|
||||
DISPLAY_FILE_LIST,
|
||||
DISPLAY_TRACKER_LIST,
|
||||
DISPLAY_CHUNKS_SEEN,
|
||||
DISPLAY_TRANSFER_LIST,
|
||||
DISPLAY_MAX_SIZE
|
||||
} Display;
|
||||
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
// rTorrent - BitTorrent client
|
||||
// Copyright (C) 2005-2006, Jari Sundell
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations
|
||||
// including the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for
|
||||
// all of the code used other than OpenSSL. If you modify file(s)
|
||||
// with this exception, you may extend this exception to your version
|
||||
// of the file(s), but you are not obligated to do so. If you do not
|
||||
// wish to do so, delete this exception statement from your version.
|
||||
// If you delete this exception statement from all source files in the
|
||||
// program, then also delete it here.
|
||||
//
|
||||
// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
//
|
||||
// Skomakerveien 33
|
||||
// 3185 Skoppum, NORWAY
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "display/window_download_transfer_list.h"
|
||||
#include "input/manager.h"
|
||||
|
||||
#include "control.h"
|
||||
#include "element_transfer_list.h"
|
||||
|
||||
namespace ui {
|
||||
|
||||
ElementTransferList::ElementTransferList(core::Download* d) :
|
||||
m_download(d),
|
||||
m_window(NULL),
|
||||
m_focus(0) {
|
||||
|
||||
m_bindings[KEY_DOWN] = sigc::mem_fun(*this, &ElementTransferList::receive_next);
|
||||
m_bindings[KEY_UP] = sigc::mem_fun(*this, &ElementTransferList::receive_prev);
|
||||
m_bindings[KEY_NPAGE] = sigc::mem_fun(*this, &ElementTransferList::receive_pagenext);
|
||||
m_bindings[KEY_PPAGE] = sigc::mem_fun(*this, &ElementTransferList::receive_pageprev);
|
||||
// m_bindings[' '] = sigc::mem_fun(*this, &ElementTransferList::receive_cycle_group);
|
||||
// m_bindings['*'] = sigc::mem_fun(*this, &ElementTransferList::receive_disable);
|
||||
}
|
||||
|
||||
void
|
||||
ElementTransferList::activate(Control* c, MItr mItr) {
|
||||
if (m_window != NULL)
|
||||
throw std::logic_error("ui::ElementTransferList::activate(...) called on an object in the wrong state");
|
||||
|
||||
c->input()->push_front(&m_bindings);
|
||||
|
||||
*mItr = m_window = new WTransferList(m_download, &m_focus);
|
||||
}
|
||||
|
||||
void
|
||||
ElementTransferList::disable(Control* c) {
|
||||
if (m_window == NULL)
|
||||
throw std::logic_error("ui::ElementTransferList::disable(...) called on an object in the wrong state");
|
||||
|
||||
c->input()->erase(&m_bindings);
|
||||
|
||||
delete m_window;
|
||||
m_window = NULL;
|
||||
}
|
||||
|
||||
// void
|
||||
// ElementTransferList::receive_disable() {
|
||||
// if (m_window == NULL)
|
||||
// throw std::logic_error("ui::ElementTransferList::receive_disable(...) called on a disabled object");
|
||||
|
||||
// if (m_download->download()->tracker(m_focus).is_enabled())
|
||||
// m_download->download()->tracker(m_focus).disable();
|
||||
// else
|
||||
// m_download->download()->tracker(m_focus).enable();
|
||||
|
||||
// m_window->mark_dirty();
|
||||
// }
|
||||
|
||||
void
|
||||
ElementTransferList::receive_next() {
|
||||
// if (m_window == NULL)
|
||||
// throw torrent::client_error("ui::ElementTransferList::receive_next(...) called on a disabled object");
|
||||
|
||||
// if (++m_focus > m_window->max_focus())
|
||||
// m_focus = 0;
|
||||
|
||||
// m_window->mark_dirty();
|
||||
}
|
||||
|
||||
void
|
||||
ElementTransferList::receive_prev() {
|
||||
// if (m_window == NULL)
|
||||
// throw torrent::client_error("ui::ElementTransferList::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
|
||||
ElementTransferList::receive_pagenext() {
|
||||
// if (m_window == NULL)
|
||||
// throw torrent::client_error("ui::ElementTransferList::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
|
||||
ElementTransferList::receive_pageprev() {
|
||||
// if (m_window == NULL)
|
||||
// throw torrent::client_error("ui::ElementTransferList::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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
// rTorrent - BitTorrent client
|
||||
// Copyright (C) 2005-2006, Jari Sundell
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations
|
||||
// including the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for
|
||||
// all of the code used other than OpenSSL. If you modify file(s)
|
||||
// with this exception, you may extend this exception to your version
|
||||
// of the file(s), but you are not obligated to do so. If you do not
|
||||
// wish to do so, delete this exception statement from your version.
|
||||
// If you delete this exception statement from all source files in the
|
||||
// program, then also delete it here.
|
||||
//
|
||||
// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
//
|
||||
// Skomakerveien 33
|
||||
// 3185 Skoppum, NORWAY
|
||||
|
||||
#ifndef RTORRENT_UI_ELEMENT_TRANSFER_LIST_H
|
||||
#define RTORRENT_UI_ELEMENT_TRANSFER_LIST_H
|
||||
|
||||
#include "core/download.h"
|
||||
|
||||
#include "element_base.h"
|
||||
|
||||
class Control;
|
||||
|
||||
namespace display {
|
||||
class WindowDownloadTransferList;
|
||||
}
|
||||
|
||||
namespace ui {
|
||||
|
||||
class ElementTransferList : public ElementBase {
|
||||
public:
|
||||
typedef display::WindowDownloadTransferList WTransferList;
|
||||
|
||||
ElementTransferList(core::Download* d);
|
||||
|
||||
void activate(Control* c, MItr mItr);
|
||||
void disable(Control* c);
|
||||
|
||||
private:
|
||||
// void receive_disable();
|
||||
void receive_next();
|
||||
void receive_prev();
|
||||
void receive_pagenext();
|
||||
void receive_pageprev();
|
||||
|
||||
core::Download* m_download;
|
||||
WTransferList* m_window;
|
||||
|
||||
unsigned int m_focus;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user