Adding some tracker msg related stuff, download status bar.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@262 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-02-08 22:06:57 +00:00
parent b01cd17a72
commit f7144a333f
12 changed files with 197 additions and 38 deletions
+2
View File
@@ -7,6 +7,8 @@ libsub_display_a_SOURCES = \
manager.h \
window.cc \
window.h \
window_download_statusbar.cc \
window_download_statusbar.h \
window_download_list.cc \
window_download_list.h \
window_peer_info.cc \
+31 -7
View File
@@ -20,11 +20,35 @@ WindowDownloadList::redraw() {
m_canvas->erase();
int pos = 0;
if (m_list->empty())
return;
// Remember to check for end of screen too.
DList::iterator itr, last;
int pos = 0, y = 0;
for (DList::iterator itr = m_list->begin(); itr != m_list->end(); ++itr) {
if (*m_focus != m_list->end()) {
int i = 0;
itr = last = *m_focus;
while (i < m_canvas->get_height() - y && !(itr == m_list->begin() && last == m_list->end())) {
if (last != m_list->end()) {
++last;
i += 3;
}
if (itr != m_list->begin() && i < m_canvas->get_height() - y) {
--itr;
i += 3;
}
}
} else {
itr = m_list->begin();
last = m_list->end();
}
while (itr != m_list->end() && y < m_canvas->get_height()) {
m_canvas->print(0, pos++, "%c %s",
itr == *m_focus ? '*' : ' ',
itr->get_download().get_name().c_str());
@@ -46,11 +70,11 @@ WindowDownloadList::redraw() {
(double)itr->get_download().get_rate_down() / 1024.0,
(double)itr->get_download().get_bytes_up() / (double)(1 << 20));
m_canvas->print(0, pos++, "%c Tracker: [%c:%i] %s",
m_canvas->print(0, pos++, "%c Tracker: %s",
itr == *m_focus ? '*' : ' ',
itr->get_download().is_tracker_busy() ? 'C' : ' ',
(int)(itr->get_download().get_tracker_timeout() / 1000000),
"");
itr->get_download().is_tracker_busy() ? "Connecting" : itr->get_tracker_msg().c_str());
++itr;
}
}
+45
View File
@@ -0,0 +1,45 @@
#include "config.h"
#include "canvas.h"
#include "window_download_statusbar.h"
#include "core/download.h"
namespace display {
WindowDownloadStatusbar::WindowDownloadStatusbar(core::Download* d) :
Window(new Canvas, false, 2),
m_download(d) {
}
void
WindowDownloadStatusbar::redraw() {
if (Timer::cache() - m_lastDraw < 1000000)
return;
m_lastDraw = Timer::cache();
m_canvas->erase();
if (m_download->get_download().get_chunks_done() != m_download->get_download().get_chunks_total() || !m_download->get_download().is_open())
m_canvas->print(0, 0, "Torrent: %.1f / %.1f MiB Rate:%5.1f /%5.1f KiB Uploaded: %.1f MiB",
(double)m_download->get_download().get_bytes_done() / (double)(1 << 20),
(double)m_download->get_download().get_bytes_total() / (double)(1 << 20),
(double)m_download->get_download().get_rate_up() / 1024.0,
(double)m_download->get_download().get_rate_down() / 1024.0,
(double)m_download->get_download().get_bytes_up() / (double)(1 << 20));
else
m_canvas->print(0, 0, "Torrent: Done %.1f MiB Rate:%5.1f /%5.1f KiB Uploaded: %.1f MiB",
(double)m_download->get_download().get_bytes_total() / (double)(1 << 20),
(double)m_download->get_download().get_rate_up() / 1024.0,
(double)m_download->get_download().get_rate_down() / 1024.0,
(double)m_download->get_download().get_bytes_up() / (double)(1 << 20));
m_canvas->print(0, 1, "Tracker: [%c:%i] %s",
m_download->get_download().is_tracker_busy() ? 'C' : ' ',
(int)(m_download->get_download().get_tracker_timeout() / 1000000),
m_download->get_tracker_msg().c_str());
}
}
+24
View File
@@ -0,0 +1,24 @@
#ifndef RTORRENT_WINDOW_DOWNLOAD_STATUSBAR_H
#define RTORRENT_WINDOW_DOWNLOAD_STATUSBAR_H
#include "window.h"
namespace core {
class Download;
}
namespace display {
class WindowDownloadStatusbar : public Window {
public:
WindowDownloadStatusbar(core::Download* d);
virtual void redraw();
private:
core::Download* m_download;
};
}
#endif
+4 -1
View File
@@ -33,8 +33,11 @@ WindowPeerInfo::redraw() {
m_download->get_download().get_chunks_total(),
m_download->get_download().get_chunks_size());
if (*m_focus == m_list->end())
if (*m_focus == m_list->end()) {
m_canvas->print(0, y++, "No peer in focus");
return;
}
y++;