Adding view of tracker list.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@338 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-03-10 18:59:24 +00:00
parent a4dbdffcb8
commit f664e1ce0c
12 changed files with 240 additions and 10 deletions
+3 -1
View File
@@ -28,6 +28,8 @@ libsub_display_a_SOURCES = \
window_statusbar.cc \
window_statusbar.h \
window_title.cc \
window_title.h
window_title.h \
window_tracker_list.cc \
window_tracker_list.h
INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir)
+2 -2
View File
@@ -47,14 +47,14 @@ WindowDownloadList::redraw() {
d.get_name().c_str());
if ((*range.first)->is_open() && (*range.first)->is_done())
m_canvas->print(0, pos++, "%c Torrent: Done %.1f MiB Rate:%5.1f /%5.1f KiB Uploaded: %.1f MiB",
m_canvas->print(0, pos++, "%c Torrent: Done %10.1f MiB Rate:%5.1f /%5.1f KiB Uploaded: %.1f MiB",
range.first == *m_focus ? '*' : ' ',
(double)d.get_bytes_total() / (double)(1 << 20),
(double)d.get_rate_up() / 1024.0,
(double)d.get_rate_down() / 1024.0,
(double)d.get_bytes_up() / (double)(1 << 20));
else
m_canvas->print(0, pos++, "%c Torrent: %.1f / %.1f MiB Rate:%5.1f /%5.1f KiB Uploaded: %.1f MiB",
m_canvas->print(0, pos++, "%c Torrent: %6.1f / %6.1f MiB Rate:%5.1f /%5.1f KiB Uploaded: %.1f MiB",
range.first == *m_focus ? '*' : ' ',
(double)d.get_bytes_done() / (double)(1 << 20),
(double)d.get_bytes_total() / (double)(1 << 20),
+55
View File
@@ -0,0 +1,55 @@
#include "config.h"
#include <stdexcept>
#include "core/download.h"
#include "rak/algorithm.h"
#include "window_tracker_list.h"
namespace display {
WindowTrackerList::WindowTrackerList(core::Download* d, unsigned int* focus) :
Window(new Canvas, true),
m_download(d),
m_focus(focus) {
}
void
WindowTrackerList::redraw() {
// TODO: Make this depend on tracker signal.
m_nextDraw = utils::Timer::cache().round_seconds() + 10 * 1000000;
m_canvas->erase();
int pos = 0;
m_canvas->print( 2, pos, "Trackers:");
++pos;
if (m_download->get_download().get_tracker_size() == 0)
return;
if (*m_focus >= m_download->get_download().get_tracker_size())
throw std::logic_error("WindowTrackerList::redraw() called on an object with a bad focus value");
typedef std::pair<unsigned int, unsigned int> Range;
Range range = rak::advance_bidirectional<unsigned int>(0,
*m_focus,
m_download->get_download().get_tracker_size(),
m_canvas->get_height());
while (range.first != range.second) {
torrent::Tracker t = m_download->get_download().get_tracker(range.first);
m_canvas->print(0, pos, "%c %s",
range.first == *m_focus ? '*' : ' ',
t.get_url().c_str());
++range.first;
++pos;
}
}
}
+32
View File
@@ -0,0 +1,32 @@
#ifndef RTORRENT_DISPLAY_TRACKER_LIST_H
#define RTORRENT_DISPLAY_TRACKER_LIST_H
#include <list>
#include "window.h"
namespace torrent {
class Tracker;
}
namespace core {
class Download;
}
namespace display {
class WindowTrackerList : public Window {
public:
WindowTrackerList(core::Download* d, unsigned int* focus);
virtual void redraw();
private:
core::Download* m_download;
unsigned int* m_focus;
};
}
#endif