mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-07 06:39:23 +00:00
* Starting work on ElementText for displaying generic information.
* If a storage error was thrown from make_directory in EntryList::open, it would try to erase a FileMeta that wasn't inserted. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@753 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -20,6 +20,8 @@ libsub_ui_a_SOURCES = \
|
||||
element_peer_list.h \
|
||||
element_string_list.cc \
|
||||
element_string_list.h \
|
||||
element_text.cc \
|
||||
element_text.h \
|
||||
element_tracker_list.cc \
|
||||
element_tracker_list.h \
|
||||
element_transfer_list.cc \
|
||||
|
||||
+52
-25
@@ -38,6 +38,7 @@
|
||||
|
||||
#include <sigc++/bind.h>
|
||||
#include <rak/functional.h>
|
||||
#include <rak/string_manip.h>
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/torrent.h>
|
||||
#include <torrent/tracker_list.h>
|
||||
@@ -47,11 +48,14 @@
|
||||
#include "display/window_title.h"
|
||||
#include "display/window_download_statusbar.h"
|
||||
|
||||
#include "display/text_element_string.h"
|
||||
|
||||
#include "control.h"
|
||||
#include "download.h"
|
||||
#include "root.h"
|
||||
#include "element_file_list.h"
|
||||
#include "element_menu.h"
|
||||
#include "element_text.h"
|
||||
#include "element_peer_list.h"
|
||||
#include "element_tracker_list.h"
|
||||
#include "element_chunks_seen.h"
|
||||
@@ -59,7 +63,7 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
Download::Download(DPtr d) :
|
||||
Download::Download(core::Download* d) :
|
||||
m_download(d),
|
||||
m_state(DISPLAY_MAX_SIZE),
|
||||
m_focusDisplay(false) {
|
||||
@@ -67,31 +71,9 @@ Download::Download(DPtr d) :
|
||||
m_windowDownloadStatus = new WDownloadStatus(d);
|
||||
m_windowDownloadStatus->set_bottom(true);
|
||||
|
||||
ElementMenu* elementMenu = new ElementMenu;
|
||||
|
||||
elementMenu->push_back("Peer List",
|
||||
sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_PEER_LIST),
|
||||
sigc::bind(sigc::mem_fun(this, &Download::activate_display_menu), DISPLAY_PEER_LIST));
|
||||
// elementMenu->push_back("Peer Info",
|
||||
// sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_PEER_INFO),
|
||||
// sigc::bind(sigc::mem_fun(this, &Download::activate_display_menu), DISPLAY_PEER_INFO));
|
||||
elementMenu->push_back("File List",
|
||||
sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_FILE_LIST),
|
||||
sigc::bind(sigc::mem_fun(this, &Download::activate_display_menu), DISPLAY_FILE_LIST));
|
||||
elementMenu->push_back("Tracker List",
|
||||
sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_TRACKER_LIST),
|
||||
sigc::bind(sigc::mem_fun(this, &Download::activate_display_menu), DISPLAY_TRACKER_LIST));
|
||||
elementMenu->push_back("Chunks Seen",
|
||||
sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_CHUNKS_SEEN),
|
||||
sigc::bind(sigc::mem_fun(this, &Download::activate_display_menu), DISPLAY_CHUNKS_SEEN));
|
||||
elementMenu->push_back("Transfer List",
|
||||
sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_TRANSFER_LIST),
|
||||
sigc::bind(sigc::mem_fun(this, &Download::activate_display_menu), DISPLAY_TRANSFER_LIST));
|
||||
|
||||
elementMenu->set_entry(0);
|
||||
|
||||
m_uiArray[DISPLAY_MENU] = elementMenu;
|
||||
m_uiArray[DISPLAY_MENU] = create_menu();
|
||||
m_uiArray[DISPLAY_PEER_LIST] = new ElementPeerList(d);
|
||||
m_uiArray[DISPLAY_INFO] = create_info();
|
||||
m_uiArray[DISPLAY_FILE_LIST] = new ElementFileList(d);
|
||||
m_uiArray[DISPLAY_TRACKER_LIST] = new ElementTrackerList(d);
|
||||
m_uiArray[DISPLAY_CHUNKS_SEEN] = new ElementChunksSeen(d);
|
||||
@@ -99,6 +81,7 @@ Download::Download(DPtr d) :
|
||||
|
||||
m_uiArray[DISPLAY_MENU]->slot_exit(sigc::mem_fun(&m_slotExit, &slot_type::operator()));
|
||||
m_uiArray[DISPLAY_PEER_LIST]->slot_exit(sigc::bind(sigc::mem_fun(this, &Download::activate_display_menu), DISPLAY_PEER_LIST));
|
||||
m_uiArray[DISPLAY_INFO]->slot_exit(sigc::bind(sigc::mem_fun(this, &Download::activate_display_menu), DISPLAY_INFO));
|
||||
m_uiArray[DISPLAY_FILE_LIST]->slot_exit(sigc::bind(sigc::mem_fun(this, &Download::activate_display_menu), DISPLAY_FILE_LIST));
|
||||
m_uiArray[DISPLAY_TRACKER_LIST]->slot_exit(sigc::bind(sigc::mem_fun(this, &Download::activate_display_menu), DISPLAY_TRACKER_LIST));
|
||||
m_uiArray[DISPLAY_CHUNKS_SEEN]->slot_exit(sigc::bind(sigc::mem_fun(this, &Download::activate_display_menu), DISPLAY_CHUNKS_SEEN));
|
||||
@@ -116,6 +99,48 @@ Download::~Download() {
|
||||
delete m_windowDownloadStatus;
|
||||
}
|
||||
|
||||
inline ElementBase*
|
||||
Download::create_menu() {
|
||||
ElementMenu* element = new ElementMenu;
|
||||
|
||||
element->push_back("Peer List",
|
||||
sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_PEER_LIST),
|
||||
sigc::bind(sigc::mem_fun(this, &Download::activate_display_menu), DISPLAY_PEER_LIST));
|
||||
element->push_back("Info",
|
||||
sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_INFO),
|
||||
sigc::bind(sigc::mem_fun(this, &Download::activate_display_menu), DISPLAY_INFO));
|
||||
element->push_back("File List",
|
||||
sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_FILE_LIST),
|
||||
sigc::bind(sigc::mem_fun(this, &Download::activate_display_menu), DISPLAY_FILE_LIST));
|
||||
element->push_back("Tracker List",
|
||||
sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_TRACKER_LIST),
|
||||
sigc::bind(sigc::mem_fun(this, &Download::activate_display_menu), DISPLAY_TRACKER_LIST));
|
||||
element->push_back("Chunks Seen",
|
||||
sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_CHUNKS_SEEN),
|
||||
sigc::bind(sigc::mem_fun(this, &Download::activate_display_menu), DISPLAY_CHUNKS_SEEN));
|
||||
element->push_back("Transfer List",
|
||||
sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_TRANSFER_LIST),
|
||||
sigc::bind(sigc::mem_fun(this, &Download::activate_display_menu), DISPLAY_TRANSFER_LIST));
|
||||
|
||||
element->set_entry(0);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
inline ElementBase*
|
||||
Download::create_info() {
|
||||
ElementText* element = new ElementText(m_download);
|
||||
|
||||
element->set_column(1);
|
||||
|
||||
element->push_column(new display::TextElementCString("Name:"), display::text_element_string_slot(rak::on(std::mem_fun(&core::Download::c_download), std::mem_fun(&torrent::Download::name))));
|
||||
element->push_column(new display::TextElementCString("Info Hash:"), display::text_element_string_slot(std::mem_fun(&core::Download::info_hash_hex)));
|
||||
|
||||
element->set_column_width(element->column_width() + 1);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
void
|
||||
Download::activate(display::Frame* frame, bool focus) {
|
||||
if (is_active())
|
||||
@@ -166,6 +191,7 @@ Download::activate_display(Display displayType, bool focusDisplay) {
|
||||
break;
|
||||
|
||||
case DISPLAY_PEER_LIST:
|
||||
case DISPLAY_INFO:
|
||||
case DISPLAY_FILE_LIST:
|
||||
case DISPLAY_TRACKER_LIST:
|
||||
case DISPLAY_CHUNKS_SEEN:
|
||||
@@ -189,6 +215,7 @@ Download::activate_display(Display displayType, bool focusDisplay) {
|
||||
break;
|
||||
|
||||
case DISPLAY_PEER_LIST:
|
||||
case DISPLAY_INFO:
|
||||
case DISPLAY_FILE_LIST:
|
||||
case DISPLAY_TRACKER_LIST:
|
||||
case DISPLAY_CHUNKS_SEEN:
|
||||
|
||||
+6
-3
@@ -60,12 +60,12 @@ class Download : public ElementBase {
|
||||
public:
|
||||
typedef display::WindowDownloadStatusbar WDownloadStatus;
|
||||
|
||||
typedef core::Download* DPtr;
|
||||
typedef std::list<torrent::Peer> PList;
|
||||
|
||||
typedef enum {
|
||||
DISPLAY_MENU,
|
||||
DISPLAY_PEER_LIST,
|
||||
DISPLAY_INFO,
|
||||
DISPLAY_FILE_LIST,
|
||||
DISPLAY_TRACKER_LIST,
|
||||
DISPLAY_CHUNKS_SEEN,
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
DISPLAY_MAX_SIZE
|
||||
} Display;
|
||||
|
||||
Download(DPtr d);
|
||||
Download(core::Download* d);
|
||||
~Download();
|
||||
|
||||
void activate(display::Frame* frame, bool focus = true);
|
||||
@@ -93,13 +93,16 @@ private:
|
||||
Download(const Download&);
|
||||
void operator = (const Download&);
|
||||
|
||||
inline ElementBase* create_menu();
|
||||
inline ElementBase* create_info();
|
||||
|
||||
void receive_max_uploads(int t);
|
||||
void receive_min_peers(int t);
|
||||
void receive_max_peers(int t);
|
||||
|
||||
void bind_keys();
|
||||
|
||||
DPtr m_download;
|
||||
core::Download* m_download;
|
||||
|
||||
Display m_state;
|
||||
ElementBase* m_uiArray[DISPLAY_MAX_SIZE];
|
||||
|
||||
@@ -49,14 +49,14 @@
|
||||
namespace ui {
|
||||
|
||||
struct ElementMenuEntry {
|
||||
display::TextElementString* m_element;
|
||||
display::TextElementStringBase* m_element;
|
||||
|
||||
ElementMenu::slot_type m_slotFocus;
|
||||
ElementMenu::slot_type m_slotSelect;
|
||||
ElementMenu::slot_type m_slotFocus;
|
||||
ElementMenu::slot_type m_slotSelect;
|
||||
};
|
||||
|
||||
ElementMenu::ElementMenu() :
|
||||
m_window(new WindowText),
|
||||
m_window(new WindowText(NULL, 2)),
|
||||
m_entry(entry_invalid) {
|
||||
|
||||
// Move bindings into a function that defines default bindings.
|
||||
@@ -103,10 +103,10 @@ ElementMenu::disable() {
|
||||
}
|
||||
|
||||
void
|
||||
ElementMenu::push_back(const std::string& name, const slot_type& slotSelect, const slot_type& slotFocus) {
|
||||
ElementMenu::push_back(const char* name, const slot_type& slotSelect, const slot_type& slotFocus) {
|
||||
entry_type* entry = new entry_type;
|
||||
|
||||
entry->m_element = new display::TextElementString(name);
|
||||
entry->m_element = new display::TextElementCString(name);
|
||||
entry->m_slotSelect = slotSelect;
|
||||
entry->m_slotFocus = slotFocus;
|
||||
|
||||
|
||||
@@ -81,7 +81,8 @@ public:
|
||||
// Consider returning a pointer that can be used to manipulate
|
||||
// entries, f.ex disabling them.
|
||||
|
||||
void push_back(const std::string& name,
|
||||
// The c string is not copied nor freed, so it should be constant.
|
||||
void push_back(const char* name,
|
||||
const slot_type& slotSelect = slot_type(),
|
||||
const slot_type& slotFocus = slot_type());
|
||||
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
// 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 <torrent/exceptions.h>
|
||||
|
||||
#include "display/frame.h"
|
||||
#include "display/window_text.h"
|
||||
#include "display/text_element_list.h"
|
||||
#include "display/text_element_string.h"
|
||||
#include "input/manager.h"
|
||||
|
||||
#include "control.h"
|
||||
#include "element_text.h"
|
||||
|
||||
namespace ui {
|
||||
|
||||
ElementText::ElementText(void *object) :
|
||||
m_window(new WindowText(object)),
|
||||
m_column(0),
|
||||
m_columnWidth(0) {
|
||||
|
||||
// Move bindings into a function that defines default bindings.
|
||||
m_bindings[KEY_LEFT] = sigc::mem_fun(&m_slotExit, &slot_type::operator());
|
||||
|
||||
// m_bindings[KEY_UP] = sigc::mem_fun(this, &ElementText::entry_prev);
|
||||
// m_bindings[KEY_DOWN] = sigc::mem_fun(this, &ElementText::entry_next);
|
||||
// m_bindings[KEY_RIGHT] = sigc::mem_fun(this, &ElementText::entry_select);
|
||||
}
|
||||
|
||||
ElementText::~ElementText() {
|
||||
delete m_window;
|
||||
}
|
||||
|
||||
void
|
||||
ElementText::activate(display::Frame* frame, bool focus) {
|
||||
if (is_active())
|
||||
throw torrent::client_error("ui::ElementText::activate(...) is_active().");
|
||||
|
||||
if (focus)
|
||||
control->input()->push_back(&m_bindings);
|
||||
|
||||
m_focus = focus;
|
||||
|
||||
m_frame = frame;
|
||||
m_frame->initialize_window(m_window);
|
||||
|
||||
m_window->set_active(true);
|
||||
}
|
||||
|
||||
void
|
||||
ElementText::disable() {
|
||||
if (!is_active())
|
||||
throw torrent::client_error("ui::ElementText::disable(...) !is_active().");
|
||||
|
||||
control->input()->erase(&m_bindings);
|
||||
|
||||
m_frame->clear();
|
||||
m_frame = NULL;
|
||||
|
||||
m_window->set_active(false);
|
||||
}
|
||||
|
||||
void
|
||||
ElementText::push_back(display::TextElement* entry) {
|
||||
m_window->push_back(entry);
|
||||
|
||||
// For the moment, don't bother doing anything if the window is
|
||||
// already active.
|
||||
m_window->mark_dirty();
|
||||
}
|
||||
|
||||
void
|
||||
ElementText::push_column(display::TextElement* entry1, display::TextElement* entry2) {
|
||||
m_columnWidth = std::max(entry1->max_length(), m_column);
|
||||
|
||||
display::TextElementList* list = new display::TextElementList;
|
||||
list->set_column(m_column);
|
||||
list->set_column_width(&m_columnWidth);
|
||||
|
||||
list->push_back(entry1);
|
||||
list->push_back(entry2);
|
||||
|
||||
push_back(list);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user