mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-07 14:49:21 +00:00
* Cleanup of the file list.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@834 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
#include <rak/socket_address.h>
|
||||
#include <torrent/bitfield.h>
|
||||
#include <torrent/torrent.h>
|
||||
#include <torrent/data/file_list_iterator.h>
|
||||
|
||||
#include "core/download.h"
|
||||
|
||||
@@ -102,6 +103,12 @@ te_value(Return (torrent::FileList::*fptr)() const, int flags = TextElementValue
|
||||
return display::text_element_value_slot(rak::on(std::mem_fun(&core::Download::c_file_list), std::mem_fun(fptr)), flags, attributes);
|
||||
}
|
||||
|
||||
template <typename Return>
|
||||
inline TextElementValueBase*
|
||||
te_value(Return (torrent::File::*fptr)() const, int flags = TextElementValueBase::flag_normal, int attributes = Attributes::a_invalid) {
|
||||
return display::text_element_value_slot(rak::on(std::mem_fun(&torrent::FileListIterator::file), std::mem_fun(fptr)), flags, attributes);
|
||||
}
|
||||
|
||||
inline TextElementValueBase*
|
||||
te_variable_value(const std::string& variable, int flags = TextElementValueBase::flag_normal, int attributes = Attributes::a_invalid) {
|
||||
return display::text_element_value_slot(rak::bind2nd(std::mem_fun(&core::Download::variable_value), variable), flags, attributes);
|
||||
|
||||
@@ -83,28 +83,20 @@ WindowFileList::redraw() {
|
||||
return;
|
||||
|
||||
unsigned int pos = 0;
|
||||
iterator itr = rak::advance_bidirectional<iterator>(iterator(fl->begin()), *m_selected, iterator(fl->end()), m_canvas->height() - 1).first;
|
||||
|
||||
m_canvas->print( 2, pos, "File");
|
||||
m_canvas->print(55, pos, "Size");
|
||||
m_canvas->print(63, pos, "Pri");
|
||||
m_canvas->print(68, pos, "Cmpl");
|
||||
m_canvas->print(74, pos, "Encoding");
|
||||
m_canvas->print(84, pos, "Chunks");
|
||||
|
||||
++pos;
|
||||
|
||||
iterator itr = rak::advance_bidirectional<iterator>(iterator(fl->begin()), *m_selected, iterator(fl->end()), m_canvas->height() - pos).first;
|
||||
m_canvas->print(0, pos++, "Cmp Pri Size Filename");
|
||||
|
||||
while (pos != m_canvas->height() && itr != iterator(fl->end())) {
|
||||
if (itr.is_empty()) {
|
||||
m_canvas->print(12, pos, "EMPTY");
|
||||
m_canvas->print(16, pos, "EMPTY");
|
||||
|
||||
} else if (itr.is_entering()) {
|
||||
m_canvas->print(12 + itr.depth(), pos, "\\ %s",
|
||||
m_canvas->print(16 + itr.depth(), pos, "\\ %s",
|
||||
itr.depth() < (*itr)->path()->size() ? (*itr)->path()->at(itr.depth()).c_str() : "UNKNOWN");
|
||||
|
||||
} else if (itr.is_leaving()) {
|
||||
m_canvas->print(12 + itr.depth() - 1, pos, "/");
|
||||
m_canvas->print(16 + itr.depth() - 1, pos, "/");
|
||||
|
||||
} else if (itr.is_file()) {
|
||||
torrent::File* e = *itr;
|
||||
@@ -112,35 +104,24 @@ WindowFileList::redraw() {
|
||||
const char* priority;
|
||||
|
||||
switch (e->priority()) {
|
||||
case torrent::PRIORITY_OFF:
|
||||
priority = "off";
|
||||
break;
|
||||
|
||||
case torrent::PRIORITY_NORMAL:
|
||||
priority = " ";
|
||||
break;
|
||||
|
||||
case torrent::PRIORITY_HIGH:
|
||||
priority = "hig";
|
||||
break;
|
||||
|
||||
default:
|
||||
priority = "BUG";
|
||||
break;
|
||||
case torrent::PRIORITY_OFF: priority = "off"; break;
|
||||
case torrent::PRIORITY_NORMAL: priority = " "; break;
|
||||
case torrent::PRIORITY_HIGH: priority = "hig"; break;
|
||||
default: priority = "BUG"; break;
|
||||
};
|
||||
|
||||
m_canvas->print(0, pos, "%3d", done_percentage(e));
|
||||
m_canvas->print(0, pos, "%3d %s", done_percentage(e), priority);
|
||||
|
||||
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));
|
||||
m_canvas->print(8, 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));
|
||||
m_canvas->print(8, 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(8, pos, "%5.1fTb", (double)val / (int64_t(1) << 40));
|
||||
|
||||
m_canvas->print(12 + itr.depth(), pos, "| %s",
|
||||
m_canvas->print(16 + itr.depth(), pos, "| %s",
|
||||
itr.depth() < (*itr)->path()->size() ? (*itr)->path()->at(itr.depth()).c_str() : "UNKNOWN");
|
||||
|
||||
// %6.1f %s %3d %9s",
|
||||
|
||||
+18
-28
@@ -77,11 +77,14 @@ ElementFileList::ElementFileList(core::Download* d) :
|
||||
}
|
||||
|
||||
const char*
|
||||
element_file_list_filename(const torrent::File* file) {
|
||||
if (file->path()->empty())
|
||||
element_file_list_filename(const torrent::FileListIterator* itr) {
|
||||
if ((**itr)->path()->empty())
|
||||
return "EMPTY";
|
||||
|
||||
return file->path()->rbegin()->c_str();
|
||||
if (itr->depth() >= (**itr)->path()->size())
|
||||
return "ERROR";
|
||||
|
||||
return (**itr)->path()->at(itr->depth()).c_str();
|
||||
}
|
||||
|
||||
inline ElementText*
|
||||
@@ -99,13 +102,9 @@ element_file_list_create_info() {
|
||||
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->push_column("Size:", te_value(&torrent::File::size_bytes, value_base::flag_xb));
|
||||
element->push_column("Chunks:", te_value(&torrent::File::completed_chunks), " / ", te_value(&torrent::File::size_chunks));
|
||||
element->push_column("Range:", te_value(&torrent::File::range_first), " - ", te_value(&torrent::File::range_second));
|
||||
|
||||
element->set_column_width(element->column_width() + 1);
|
||||
|
||||
@@ -126,8 +125,10 @@ ElementFileList::activate(display::Frame* frame, bool focus) {
|
||||
|
||||
m_elementInfo = element_file_list_create_info();
|
||||
m_elementInfo->slot_exit(sigc::bind(sigc::mem_fun(this, &ElementFileList::activate_display), DISPLAY_LIST));
|
||||
m_elementInfo->set_object(&m_selected);
|
||||
|
||||
m_frame = frame;
|
||||
|
||||
activate_display(DISPLAY_LIST);
|
||||
}
|
||||
|
||||
@@ -246,16 +247,9 @@ ElementFileList::receive_priority() {
|
||||
if (m_window == NULL)
|
||||
throw torrent::internal_error("ui::ElementFileList::receive_prev(...) called on a disabled object");
|
||||
|
||||
// Fix priorities.
|
||||
// Check if we're focused on a directory.
|
||||
|
||||
// torrent::FileList* fl = m_download->download()->file_list();
|
||||
|
||||
// if (m_selected >= fl->size_files())
|
||||
// return;
|
||||
|
||||
// torrent::File* file = *(fl->begin() + m_selected);
|
||||
|
||||
// file->set_priority(next_priority(file->priority()));
|
||||
m_selected.file()->set_priority(next_priority(m_selected.file()->priority()));
|
||||
|
||||
m_download->download()->update_priorities();
|
||||
update_itr();
|
||||
@@ -266,15 +260,11 @@ ElementFileList::receive_change_all() {
|
||||
if (m_window == NULL)
|
||||
throw torrent::internal_error("ui::ElementFileList::receive_prev(...) called on a disabled object");
|
||||
|
||||
// torrent::FileList* fl = m_download->download()->file_list();
|
||||
Priority p = next_priority(m_selected.file()->priority());
|
||||
torrent::FileList* fl = m_download->download()->file_list();
|
||||
|
||||
// if (m_selected >= fl->size_files())
|
||||
// return;
|
||||
|
||||
// Priority p = next_priority((*(fl->begin() + m_selected))->priority());
|
||||
|
||||
// for (torrent::FileList::iterator itr = fl->begin(), last = fl->end(); itr != last; ++itr)
|
||||
// (*itr)->set_priority(p);
|
||||
for (torrent::FileList::iterator itr = fl->begin(), last = fl->end(); itr != last; ++itr)
|
||||
(*itr)->set_priority(p);
|
||||
|
||||
m_download->download()->update_priorities();
|
||||
update_itr();
|
||||
@@ -302,7 +292,7 @@ ElementFileList::next_priority(Priority p) {
|
||||
void
|
||||
ElementFileList::update_itr() {
|
||||
m_window->mark_dirty();
|
||||
m_elementInfo->set_object(*m_selected.base());
|
||||
m_elementInfo->mark_dirty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -72,6 +72,8 @@ public:
|
||||
void activate(display::Frame* frame, bool focus = false);
|
||||
void disable();
|
||||
|
||||
void mark_dirty() { m_window->mark_dirty(); }
|
||||
|
||||
// Consider returning a pointer that can be used to manipulate
|
||||
// entries, f.ex disabling them.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user