mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-09 23:59:22 +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",
|
||||
|
||||
Reference in New Issue
Block a user