* Changed function calls in torrent::Download to be const.

* Cleaned up the code that handles printing of download stats, uses a
char* for buffer for output more flexible concatenation. Closed
torrents are displayed correctly now.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@497 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-07-13 13:05:08 +00:00
parent 568dcc0b91
commit d02ded1d4c
5 changed files with 82 additions and 54 deletions
+22 -14
View File
@@ -57,20 +57,27 @@ WindowDownloadStatusbar::redraw() {
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_write_rate().rate() / 1024.0,
(double)m_download->get_download().get_read_rate().rate() / 1024.0,
(double)m_download->get_download().get_write_rate().total() / (double)(1 << 20));
char buffer[m_canvas->get_width() - 2];
char* position;
char* last = buffer + m_canvas->get_width() - 2;
position = print_download_info(buffer, last - buffer, m_download);
m_canvas->print(0, 0, "%s", buffer);
// 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_write_rate().rate() / 1024.0,
// (double)m_download->get_download().get_read_rate().rate() / 1024.0,
// (double)m_download->get_download().get_write_rate().total() / (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_write_rate().rate() / 1024.0,
(double)m_download->get_download().get_read_rate().rate() / 1024.0,
(double)m_download->get_download().get_write_rate().total() / (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_write_rate().rate() / 1024.0,
// (double)m_download->get_download().get_read_rate().rate() / 1024.0,
// (double)m_download->get_download().get_write_rate().total() / (double)(1 << 20));
m_canvas->print(0, 1, "Peers: %i(%i) Min/Max: %i/%i Uploads: %i",
(int)m_download->get_download().get_peers_connected(),
@@ -79,10 +86,11 @@ WindowDownloadStatusbar::redraw() {
(int)m_download->get_download().get_peers_max(),
(int)m_download->get_download().get_uploads_max());
position = print_download_status(buffer, last - buffer, m_download);
m_canvas->print(0, 2, "[%c:%i] %s",
m_download->get_download().is_tracker_busy() ? 'C' : ' ',
(int)(m_download->get_download().get_tracker_timeout() / 1000000),
print_download_status(m_download).c_str());
buffer);
}
}