mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-18 23:26:17 +00:00
* Added an info screen to the file list and added more information to
the list. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@833 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -82,12 +82,14 @@ TextElementValueBase::print(char* first, char* last, Canvas::attributes_list* at
|
|||||||
|
|
||||||
} else if (m_flags & flag_xb) {
|
} else if (m_flags & flag_xb) {
|
||||||
|
|
||||||
if (val < (int64_t(1) << 30))
|
if (val < (int64_t(1) << 20))
|
||||||
first += std::max(snprintf(first, last - first + 1, "%5.1f MB", (double)val / (int64_t(1) << 20)), 0);
|
first += std::max(snprintf(first, last - first + 1, "%5.1f Kb", (double)val / (int64_t(1) << 10)), 0);
|
||||||
|
else if (val < (int64_t(1) << 30))
|
||||||
|
first += std::max(snprintf(first, last - first + 1, "%5.1f Mb", (double)val / (int64_t(1) << 20)), 0);
|
||||||
else if (val < (int64_t(1) << 40))
|
else if (val < (int64_t(1) << 40))
|
||||||
first += std::max(snprintf(first, last - first + 1, "%5.1f GB", (double)val / (int64_t(1) << 30)), 0);
|
first += std::max(snprintf(first, last - first + 1, "%5.1f Gb", (double)val / (int64_t(1) << 30)), 0);
|
||||||
else
|
else
|
||||||
first += std::max(snprintf(first, last - first + 1, "%5.1f TB", (double)val / (int64_t(1) << 40)), 0);
|
first += std::max(snprintf(first, last - first + 1, "%5.1f Tb", (double)val / (int64_t(1) << 40)), 0);
|
||||||
|
|
||||||
} else if (m_flags & flag_timer) {
|
} else if (m_flags & flag_timer) {
|
||||||
if (val == 0)
|
if (val == 0)
|
||||||
|
|||||||
@@ -97,19 +97,19 @@ WindowFileList::redraw() {
|
|||||||
|
|
||||||
while (pos != m_canvas->height() && itr != iterator(fl->end())) {
|
while (pos != m_canvas->height() && itr != iterator(fl->end())) {
|
||||||
if (itr.is_empty()) {
|
if (itr.is_empty()) {
|
||||||
m_canvas->print(0, pos, "EMPTY");
|
m_canvas->print(12, pos, "EMPTY");
|
||||||
|
|
||||||
} else if (itr.is_entering()) {
|
} else if (itr.is_entering()) {
|
||||||
m_canvas->print(itr.depth(), pos, "\\ %s",
|
m_canvas->print(12 + itr.depth(), pos, "\\ %s",
|
||||||
itr.depth() < (*itr)->path()->size() ? (*itr)->path()->at(itr.depth()).c_str() : "UNKNOWN");
|
itr.depth() < (*itr)->path()->size() ? (*itr)->path()->at(itr.depth()).c_str() : "UNKNOWN");
|
||||||
|
|
||||||
} else if (itr.is_leaving()) {
|
} else if (itr.is_leaving()) {
|
||||||
m_canvas->print(itr.depth(), pos, "/");
|
m_canvas->print(12 + itr.depth() - 1, pos, "/");
|
||||||
|
|
||||||
} else if (itr.is_file()) {
|
} else if (itr.is_file()) {
|
||||||
torrent::File* e = *itr;
|
torrent::File* e = *itr;
|
||||||
|
|
||||||
std::string priority;
|
const char* priority;
|
||||||
|
|
||||||
switch (e->priority()) {
|
switch (e->priority()) {
|
||||||
case torrent::PRIORITY_OFF:
|
case torrent::PRIORITY_OFF:
|
||||||
@@ -129,7 +129,18 @@ WindowFileList::redraw() {
|
|||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
m_canvas->print(itr.depth(), pos, "| %s",
|
m_canvas->print(0, pos, "%3d", done_percentage(e));
|
||||||
|
|
||||||
|
int64_t val = e->size_bytes();
|
||||||
|
|
||||||
|
if (val < (int64_t(1) << 30))
|
||||||
|
m_canvas->print(4, pos, "%5.1fMb", (double)val / (int64_t(1) << 20));
|
||||||
|
else if (val < (int64_t(1) << 40))
|
||||||
|
m_canvas->print(4, pos, "%5.1fGb", (double)val / (int64_t(1) << 30));
|
||||||
|
else
|
||||||
|
m_canvas->print(4, pos, "%5.1fTb", (double)val / (int64_t(1) << 40));
|
||||||
|
|
||||||
|
m_canvas->print(12 + itr.depth(), pos, "| %s",
|
||||||
itr.depth() < (*itr)->path()->size() ? (*itr)->path()->at(itr.depth()).c_str() : "UNKNOWN");
|
itr.depth() < (*itr)->path()->size() ? (*itr)->path()->at(itr.depth()).c_str() : "UNKNOWN");
|
||||||
|
|
||||||
// %6.1f %s %3d %9s",
|
// %6.1f %s %3d %9s",
|
||||||
@@ -138,13 +149,13 @@ WindowFileList::redraw() {
|
|||||||
// done_percentage(e),
|
// done_percentage(e),
|
||||||
// e->path()->encoding().c_str());
|
// e->path()->encoding().c_str());
|
||||||
|
|
||||||
m_canvas->print(104, pos, "%i - %i %c%c %u %u",
|
// m_canvas->print(104, pos, "%i - %i %c%c %u %u",
|
||||||
e->range().first,
|
// e->range().first,
|
||||||
e->range().first != e->range().second ? (e->range().second - 1) : e->range().second,
|
// e->range().first != e->range().second ? (e->range().second - 1) : e->range().second,
|
||||||
e->is_created() ? 'E' : 'M',
|
// e->is_created() ? 'E' : 'M',
|
||||||
e->is_correct_size() ? 'C' : 'W',
|
// e->is_correct_size() ? 'C' : 'W',
|
||||||
e->match_depth_prev(),
|
// e->match_depth_prev(),
|
||||||
e->match_depth_next());
|
// e->match_depth_next());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
m_canvas->print(0, pos, "BORK BORK");
|
m_canvas->print(0, pos, "BORK BORK");
|
||||||
|
|||||||
+103
-13
@@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <sigc++/bind.h>
|
||||||
#include <rak/algorithm.h>
|
#include <rak/algorithm.h>
|
||||||
#include <torrent/exceptions.h>
|
#include <torrent/exceptions.h>
|
||||||
#include <torrent/data/file.h>
|
#include <torrent/data/file.h>
|
||||||
@@ -43,20 +44,28 @@
|
|||||||
|
|
||||||
#include "display/frame.h"
|
#include "display/frame.h"
|
||||||
#include "display/manager.h"
|
#include "display/manager.h"
|
||||||
|
#include "display/text_element_helpers.h"
|
||||||
|
#include "display/text_element_lambda.h"
|
||||||
#include "display/window_file_list.h"
|
#include "display/window_file_list.h"
|
||||||
#include "input/manager.h"
|
#include "input/manager.h"
|
||||||
|
|
||||||
#include "control.h"
|
#include "control.h"
|
||||||
#include "element_file_list.h"
|
#include "element_file_list.h"
|
||||||
|
#include "element_text.h"
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
ElementFileList::ElementFileList(core::Download* d) :
|
ElementFileList::ElementFileList(core::Download* d) :
|
||||||
m_download(d),
|
m_download(d),
|
||||||
|
|
||||||
|
m_state(DISPLAY_MAX_SIZE),
|
||||||
m_window(NULL),
|
m_window(NULL),
|
||||||
|
m_elementInfo(NULL),
|
||||||
|
|
||||||
m_selected(iterator(d->download()->file_list()->begin())) {
|
m_selected(iterator(d->download()->file_list()->begin())) {
|
||||||
|
|
||||||
m_bindings[KEY_LEFT] = m_bindings['B' - '@'] = sigc::mem_fun(&m_slotExit, &slot_type::operator());
|
m_bindings[KEY_LEFT] = m_bindings['B' - '@'] = sigc::mem_fun(&m_slotExit, &slot_type::operator());
|
||||||
|
m_bindings[KEY_RIGHT] = m_bindings['F' - '@'] = sigc::bind(sigc::mem_fun(this, &ElementFileList::activate_display), DISPLAY_INFO);
|
||||||
|
|
||||||
m_bindings[' '] = sigc::mem_fun(*this, &ElementFileList::receive_priority);
|
m_bindings[' '] = sigc::mem_fun(*this, &ElementFileList::receive_priority);
|
||||||
m_bindings['*'] = sigc::mem_fun(*this, &ElementFileList::receive_change_all);
|
m_bindings['*'] = sigc::mem_fun(*this, &ElementFileList::receive_change_all);
|
||||||
@@ -67,6 +76,42 @@ ElementFileList::ElementFileList(core::Download* d) :
|
|||||||
m_bindings[KEY_UP] = m_bindings['P' - '@'] = sigc::mem_fun(*this, &ElementFileList::receive_prev);
|
m_bindings[KEY_UP] = m_bindings['P' - '@'] = sigc::mem_fun(*this, &ElementFileList::receive_prev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char*
|
||||||
|
element_file_list_filename(const torrent::File* file) {
|
||||||
|
if (file->path()->empty())
|
||||||
|
return "EMPTY";
|
||||||
|
|
||||||
|
return file->path()->rbegin()->c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ElementText*
|
||||||
|
element_file_list_create_info() {
|
||||||
|
using namespace display::helpers;
|
||||||
|
|
||||||
|
ElementText* element = new ElementText(NULL);
|
||||||
|
|
||||||
|
element->set_column(1);
|
||||||
|
element->set_interval(1);
|
||||||
|
|
||||||
|
element->push_back("File info:");
|
||||||
|
element->push_back("");
|
||||||
|
|
||||||
|
element->push_column("Filename:", display::text_element_string_slot(std::ptr_fun(&element_file_list_filename)));
|
||||||
|
element->push_back("");
|
||||||
|
|
||||||
|
element->push_column("Size:", display::text_element_value_slot(std::mem_fun(&torrent::File::size_bytes), value_base::flag_xb));
|
||||||
|
element->push_column("Chunks:",
|
||||||
|
display::text_element_value_slot(std::mem_fun(&torrent::File::completed_chunks)), " / ",
|
||||||
|
display::text_element_value_slot(std::mem_fun(&torrent::File::size_chunks)));
|
||||||
|
element->push_column("Range:",
|
||||||
|
display::text_element_value_slot(std::mem_fun(&torrent::File::range_first)), " - ",
|
||||||
|
display::text_element_value_slot(std::mem_fun(&torrent::File::range_second)));
|
||||||
|
|
||||||
|
element->set_column_width(element->column_width() + 1);
|
||||||
|
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ElementFileList::activate(display::Frame* frame, bool focus) {
|
ElementFileList::activate(display::Frame* frame, bool focus) {
|
||||||
if (m_window != NULL)
|
if (m_window != NULL)
|
||||||
@@ -79,10 +124,11 @@ ElementFileList::activate(display::Frame* frame, bool focus) {
|
|||||||
m_window->set_active(true);
|
m_window->set_active(true);
|
||||||
m_window->set_focused(focus);
|
m_window->set_focused(focus);
|
||||||
|
|
||||||
m_frame = frame;
|
m_elementInfo = element_file_list_create_info();
|
||||||
m_frame->initialize_window(m_window);
|
m_elementInfo->slot_exit(sigc::bind(sigc::mem_fun(this, &ElementFileList::activate_display), DISPLAY_LIST));
|
||||||
|
|
||||||
// control->display()->adjust_layout();
|
m_frame = frame;
|
||||||
|
activate_display(DISPLAY_LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -92,16 +138,54 @@ ElementFileList::disable() {
|
|||||||
|
|
||||||
control->input()->erase(&m_bindings);
|
control->input()->erase(&m_bindings);
|
||||||
|
|
||||||
|
activate_display(DISPLAY_MAX_SIZE);
|
||||||
|
|
||||||
m_frame->clear();
|
m_frame->clear();
|
||||||
m_frame = NULL;
|
m_frame = NULL;
|
||||||
|
|
||||||
delete m_window;
|
delete m_window;
|
||||||
m_window = NULL;
|
m_window = NULL;
|
||||||
|
|
||||||
|
delete m_elementInfo;
|
||||||
|
m_elementInfo = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
display::Window*
|
void
|
||||||
ElementFileList::window() {
|
ElementFileList::activate_display(Display display) {
|
||||||
return m_window;
|
if (display == m_state)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (m_state) {
|
||||||
|
case DISPLAY_INFO:
|
||||||
|
m_elementInfo->disable();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DISPLAY_LIST:
|
||||||
|
m_window->set_active(false);
|
||||||
|
m_frame->clear();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DISPLAY_MAX_SIZE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_state = display;
|
||||||
|
|
||||||
|
switch (m_state) {
|
||||||
|
case DISPLAY_INFO:
|
||||||
|
m_elementInfo->activate(m_frame, true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DISPLAY_LIST:
|
||||||
|
m_window->set_active(true);
|
||||||
|
m_frame->initialize_window(m_window);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DISPLAY_MAX_SIZE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
control->display()->adjust_layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -111,7 +195,7 @@ ElementFileList::receive_next() {
|
|||||||
if (m_selected == iterator(fl->end()) || ++m_selected == iterator(fl->end()))
|
if (m_selected == iterator(fl->end()) || ++m_selected == iterator(fl->end()))
|
||||||
m_selected = iterator(fl->begin());
|
m_selected = iterator(fl->begin());
|
||||||
|
|
||||||
m_window->mark_dirty();
|
update_itr();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -122,7 +206,7 @@ ElementFileList::receive_prev() {
|
|||||||
m_selected = iterator(fl->end());
|
m_selected = iterator(fl->end());
|
||||||
|
|
||||||
m_selected--;
|
m_selected--;
|
||||||
m_window->mark_dirty();
|
update_itr();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -139,7 +223,7 @@ ElementFileList::receive_pagenext() {
|
|||||||
m_selected = --iterator(fl->end());
|
m_selected = --iterator(fl->end());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_window->mark_dirty();
|
update_itr();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -154,7 +238,7 @@ ElementFileList::receive_pageprev() {
|
|||||||
else
|
else
|
||||||
m_selected = rak::advance_backward(m_selected, iterator(fl->begin()), (m_window->height() - 1) / 2);
|
m_selected = rak::advance_backward(m_selected, iterator(fl->begin()), (m_window->height() - 1) / 2);
|
||||||
|
|
||||||
m_window->mark_dirty();
|
update_itr();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -174,7 +258,7 @@ ElementFileList::receive_priority() {
|
|||||||
// file->set_priority(next_priority(file->priority()));
|
// file->set_priority(next_priority(file->priority()));
|
||||||
|
|
||||||
m_download->download()->update_priorities();
|
m_download->download()->update_priorities();
|
||||||
m_window->mark_dirty();
|
update_itr();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -193,7 +277,7 @@ ElementFileList::receive_change_all() {
|
|||||||
// (*itr)->set_priority(p);
|
// (*itr)->set_priority(p);
|
||||||
|
|
||||||
m_download->download()->update_priorities();
|
m_download->download()->update_priorities();
|
||||||
m_window->mark_dirty();
|
update_itr();
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementFileList::Priority
|
ElementFileList::Priority
|
||||||
@@ -215,4 +299,10 @@ ElementFileList::next_priority(Priority p) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ElementFileList::update_itr() {
|
||||||
|
m_window->mark_dirty();
|
||||||
|
m_elementInfo->set_object(*m_selected.base());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ namespace display {
|
|||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
|
class ElementText;
|
||||||
|
|
||||||
class ElementFileList : public ElementBase {
|
class ElementFileList : public ElementBase {
|
||||||
public:
|
public:
|
||||||
typedef torrent::priority_t Priority;
|
typedef torrent::priority_t Priority;
|
||||||
@@ -59,12 +61,18 @@ public:
|
|||||||
|
|
||||||
typedef torrent::FileListIterator iterator;
|
typedef torrent::FileListIterator iterator;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
DISPLAY_LIST,
|
||||||
|
DISPLAY_INFO,
|
||||||
|
DISPLAY_MAX_SIZE
|
||||||
|
} Display;
|
||||||
|
|
||||||
ElementFileList(core::Download* d);
|
ElementFileList(core::Download* d);
|
||||||
|
|
||||||
void activate(display::Frame* frame, bool focus = true);
|
void activate(display::Frame* frame, bool focus = true);
|
||||||
void disable();
|
void disable();
|
||||||
|
|
||||||
display::Window* window();
|
void activate_display(Display display);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void receive_next();
|
void receive_next();
|
||||||
@@ -77,8 +85,13 @@ private:
|
|||||||
|
|
||||||
Priority next_priority(Priority p);
|
Priority next_priority(Priority p);
|
||||||
|
|
||||||
|
void update_itr();
|
||||||
|
|
||||||
core::Download* m_download;
|
core::Download* m_download;
|
||||||
|
|
||||||
|
Display m_state;
|
||||||
WFileList* m_window;
|
WFileList* m_window;
|
||||||
|
ElementText* m_elementInfo;
|
||||||
|
|
||||||
// Change to unsigned, please.
|
// Change to unsigned, please.
|
||||||
iterator m_selected;
|
iterator m_selected;
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ ElementPeerList::receive_next() {
|
|||||||
else
|
else
|
||||||
m_listItr = m_list.begin();
|
m_listItr = m_list.begin();
|
||||||
|
|
||||||
updated_itr();
|
update_itr();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -219,7 +219,7 @@ ElementPeerList::receive_prev() {
|
|||||||
else
|
else
|
||||||
m_listItr = m_list.end();
|
m_listItr = m_list.end();
|
||||||
|
|
||||||
updated_itr();
|
update_itr();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -247,7 +247,7 @@ ElementPeerList::receive_peer_disconnected(torrent::Peer p) {
|
|||||||
else
|
else
|
||||||
m_list.erase(itr);
|
m_list.erase(itr);
|
||||||
|
|
||||||
updated_itr();
|
update_itr();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -257,11 +257,11 @@ ElementPeerList::receive_snub_peer() {
|
|||||||
|
|
||||||
m_listItr->set_snubbed(!m_listItr->is_snubbed());
|
m_listItr->set_snubbed(!m_listItr->is_snubbed());
|
||||||
|
|
||||||
updated_itr();
|
update_itr();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ElementPeerList::updated_itr() {
|
ElementPeerList::update_itr() {
|
||||||
m_windowList->mark_dirty();
|
m_windowList->mark_dirty();
|
||||||
m_elementInfo->set_object(m_listItr != m_list.end() ? &*m_listItr : NULL);
|
m_elementInfo->set_object(m_listItr != m_list.end() ? &*m_listItr : NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ private:
|
|||||||
|
|
||||||
void receive_snub_peer();
|
void receive_snub_peer();
|
||||||
|
|
||||||
void updated_itr();
|
void update_itr();
|
||||||
|
|
||||||
core::Download* m_download;
|
core::Download* m_download;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user