mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-09 11:42:33 +00:00
* Changing priority of a directory changes the priority for all files
within that directory. * Removed a buggy hack in FileListIterator::operator++(). * Cleaned up display of file sizes. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@835 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -93,7 +93,6 @@ public:
|
||||
void print_char(const chtype ch) { waddch(m_window, ch); }
|
||||
void print_char(unsigned int x, unsigned int y, const chtype ch) { mvwaddch(m_window, y, x, ch); }
|
||||
|
||||
void set_attr(int attr, int color) { wattr_set(m_window, attr, color, NULL); }
|
||||
void set_attr(unsigned int x, unsigned int y, unsigned int n, int attr, int color) { mvwchgat(m_window, y, x, n, attr, color, NULL); }
|
||||
|
||||
// Initialize stdscr.
|
||||
|
||||
@@ -82,14 +82,14 @@ TextElementValueBase::print(char* first, char* last, Canvas::attributes_list* at
|
||||
|
||||
} else if (m_flags & flag_xb) {
|
||||
|
||||
if (val < (int64_t(1) << 20))
|
||||
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))
|
||||
first += std::max(snprintf(first, last - first + 1, "%5.1f Gb", (double)val / (int64_t(1) << 30)), 0);
|
||||
if (val < (int64_t(1000) << 10))
|
||||
first += std::max(snprintf(first, last - first + 1, "%5.1f KB", (double)val / (int64_t(1) << 10)), 0);
|
||||
else if (val < (int64_t(1000) << 20))
|
||||
first += std::max(snprintf(first, last - first + 1, "%5.1f MB", (double)val / (int64_t(1) << 20)), 0);
|
||||
else if (val < (int64_t(1000) << 30))
|
||||
first += std::max(snprintf(first, last - first + 1, "%5.1f GB", (double)val / (int64_t(1) << 30)), 0);
|
||||
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) {
|
||||
if (val == 0)
|
||||
|
||||
@@ -114,22 +114,16 @@ WindowFileList::redraw() {
|
||||
|
||||
int64_t val = e->size_bytes();
|
||||
|
||||
if (val < (int64_t(1) << 30))
|
||||
m_canvas->print(8, pos, "%5.1fMb", (double)val / (int64_t(1) << 20));
|
||||
else if (val < (int64_t(1) << 40))
|
||||
m_canvas->print(8, pos, "%5.1fGb", (double)val / (int64_t(1) << 30));
|
||||
if (val < (int64_t(1000) << 20))
|
||||
m_canvas->print(8, pos, "%5.1f M", (double)val / (int64_t(1) << 20));
|
||||
else if (val < (int64_t(1000) << 30))
|
||||
m_canvas->print(8, pos, "%5.1f G", (double)val / (int64_t(1) << 30));
|
||||
else
|
||||
m_canvas->print(8, pos, "%5.1fTb", (double)val / (int64_t(1) << 40));
|
||||
m_canvas->print(8, pos, "%5.1f T", (double)val / (int64_t(1) << 40));
|
||||
|
||||
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",
|
||||
// (double)e->size_bytes() / (double)(1 << 20),
|
||||
// priority.c_str(),
|
||||
// done_percentage(e),
|
||||
// e->path()->encoding().c_str());
|
||||
|
||||
// m_canvas->print(104, pos, "%i - %i %c%c %u %u",
|
||||
// e->range().first,
|
||||
// e->range().first != e->range().second ? (e->range().second - 1) : e->range().second,
|
||||
|
||||
@@ -242,14 +242,41 @@ ElementFileList::receive_pageprev() {
|
||||
update_itr();
|
||||
}
|
||||
|
||||
// Take a range as input and return the next entry at the same
|
||||
// directory depth as first. If the returned iterator equals 'last' or
|
||||
// is_leaving() == true then the search failed. UHM... wrong...
|
||||
|
||||
torrent::FileListIterator
|
||||
next_current_depth(torrent::FileListIterator first, torrent::FileListIterator last) {
|
||||
if (first == last)
|
||||
return first;
|
||||
|
||||
uint32_t depth = (first++).depth();
|
||||
|
||||
while (first != last && (first.depth() > depth || first.is_leaving()))
|
||||
++first;
|
||||
|
||||
return first;
|
||||
}
|
||||
|
||||
void
|
||||
ElementFileList::receive_priority() {
|
||||
if (m_window == NULL)
|
||||
throw torrent::internal_error("ui::ElementFileList::receive_prev(...) called on a disabled object");
|
||||
|
||||
// Check if we're focused on a directory.
|
||||
torrent::FileList* fl = m_download->download()->file_list();
|
||||
|
||||
m_selected.file()->set_priority(next_priority(m_selected.file()->priority()));
|
||||
iterator first = m_selected;
|
||||
iterator last = next_current_depth(m_selected, iterator(fl->end()));
|
||||
|
||||
Priority priority = next_priority(m_selected.file()->priority());
|
||||
|
||||
while (first != last) {
|
||||
if (first.is_file())
|
||||
first.file()->set_priority(priority);
|
||||
|
||||
first++;
|
||||
}
|
||||
|
||||
m_download->download()->update_priorities();
|
||||
update_itr();
|
||||
|
||||
Reference in New Issue
Block a user