Added changed signal to list_focus and connected it to

WindowDownloadList.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@361 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-03-18 16:09:49 +00:00
parent 2eb534e423
commit a16a88ebeb
8 changed files with 117 additions and 75 deletions
+14 -9
View File
@@ -31,10 +31,15 @@
namespace display {
WindowDownloadList::WindowDownloadList(DList* l, DList::iterator* f) :
WindowDownloadList::WindowDownloadList(DList* l) :
Window(new Canvas, true),
m_list(l),
m_focus(f) {
m_list(l) {
m_connChanged = m_list->signal_changed().connect(sigc::mem_fun(*this, &Window::mark_dirty));
}
WindowDownloadList::~WindowDownloadList() {
m_connChanged.disconnect();
}
void
@@ -43,13 +48,13 @@ WindowDownloadList::redraw() {
m_canvas->erase();
if (m_list->empty())
if (m_list->base().empty())
return;
typedef std::pair<DList::iterator, DList::iterator> Range;
Range range = rak::advance_bidirectional(m_list->begin(),
*m_focus != m_list->end() ? *m_focus : m_list->begin(),
m_list->get_focus() != m_list->end() ? m_list->get_focus() : m_list->begin(),
m_list->end(),
m_canvas->get_height() / 3);
@@ -65,19 +70,19 @@ WindowDownloadList::redraw() {
torrent::Download& d = (*range.first)->get_download();
m_canvas->print(0, pos++, "%c %s",
range.first == *m_focus ? '*' : ' ',
range.first == m_list->get_focus() ? '*' : ' ',
d.get_name().c_str());
if ((*range.first)->is_open() && (*range.first)->is_done())
m_canvas->print(0, pos++, "%c Torrent: Done %10.1f MiB Rate: %5.1f / %5.1f KiB Uploaded: %.1f MiB",
range.first == *m_focus ? '*' : ' ',
range.first == m_list->get_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: %6.1f / %6.1f MiB Rate: %5.1f / %5.1f KiB Uploaded: %.1f MiB",
range.first == *m_focus ? '*' : ' ',
range.first == m_list->get_focus() ? '*' : ' ',
(double)d.get_bytes_done() / (double)(1 << 20),
(double)d.get_bytes_total() / (double)(1 << 20),
(double)d.get_rate_up() / 1024.0,
@@ -85,7 +90,7 @@ WindowDownloadList::redraw() {
(double)d.get_bytes_up() / (double)(1 << 20));
m_canvas->print(0, pos++, "%c %s",
range.first == *m_focus ? '*' : ' ',
range.first == m_list->get_focus() ? '*' : ' ',
print_download_status(*range.first).c_str());
++range.first;
+11 -5
View File
@@ -23,22 +23,28 @@
#ifndef RTORRENT_DISPLAY_WINDOW_DOWNLOAD_LIST_H
#define RTORRENT_DISPLAY_WINDOW_DOWNLOAD_LIST_H
#include <sigc++/connection.h>
#include "window.h"
#include "core/download_list.h"
#include "utils/list_focus.h"
namespace display {
class WindowDownloadList : public Window {
public:
typedef core::DownloadList DList;
typedef utils::ListFocus<core::DownloadList> DList;
WindowDownloadList(DList* l, DList::iterator* focus);
WindowDownloadList(DList* l);
~WindowDownloadList();
virtual void redraw();
virtual void redraw();
private:
DList* m_list;
DList::iterator* m_focus;
DList* m_list;
sigc::connection m_connChanged;
};
}