New log window available through 'l'.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@343 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-03-12 19:16:30 +00:00
parent ab69ae3fe6
commit c36ee96550
13 changed files with 230 additions and 64 deletions
+2
View File
@@ -21,6 +21,8 @@ libsub_display_a_SOURCES = \
window_input.h \
window_log.cc \
window_log.h \
window_log_complete.cc \
window_log_complete.h \
window_peer_info.cc \
window_peer_info.h \
window_peer_list.cc \
+5
View File
@@ -21,6 +21,11 @@ Manager::erase(Window* w) {
return Base::erase(itr);
}
Manager::iterator
Manager::find(Window* w) {
return std::find(begin(), end(), w);
}
void
Manager::adjust_layout() {
int countDynamic = 0;
+2
View File
@@ -28,6 +28,8 @@ public:
iterator erase(Window* w);
iterator find(Window* w);
void adjust_layout();
void do_update();
+15 -4
View File
@@ -1,5 +1,7 @@
#include "config.h"
#include <ctime>
#include "canvas.h"
#include "window_log.h"
@@ -12,7 +14,7 @@ WindowLog::WindowLog(core::Log* l) :
set_active(false);
// We're trying out scheduled tasks instead.
//m_connUpdate = l->signal_update().connect(sigc::mem_fun(*this, &WindowLog::receive_update));
m_connUpdate = l->signal_update().connect(sigc::mem_fun(*this, &WindowLog::receive_update));
}
WindowLog::~WindowLog() {
@@ -35,14 +37,23 @@ WindowLog::redraw() {
//m_canvas->print(std::max(0, (int)m_canvas->get_width() / 2 - 5), pos++, "*** Log ***");
m_canvas->print(0, 0, "___");
for (core::Log::iterator itr = m_log->begin(), end = find_older(); itr != end && pos < m_minHeight; ++itr)
m_canvas->print(0, pos++, "<date>: %s", itr->second.c_str());
for (core::Log::iterator itr = m_log->begin(), end = find_older(); itr != end && pos < m_canvas->get_height(); ++itr) {
std::tm *t = std::localtime(&itr->first.tval().tv_sec);
if (t == NULL)
m_canvas->print(0, pos++, "(time error) %s",
itr->second.c_str());
else
m_canvas->print(0, pos++, "(%02i:%02i:%02i) %s",
t->tm_hour, t->tm_min, t->tm_sec,
itr->second.c_str());
}
}
void
WindowLog::receive_update() {
iterator itr = find_older();
int h = std::distance(m_log->begin(), itr);
int h = std::min(std::distance(m_log->begin(), itr), 10);
if (h != m_minHeight) {
set_active(h != 0);
+55
View File
@@ -0,0 +1,55 @@
#include "config.h"
#include <ctime>
#include "canvas.h"
#include "window_log_complete.h"
namespace display {
WindowLogComplete::WindowLogComplete(core::Log* l) :
Window(new Canvas, true),
m_log(l) {
// We're trying out scheduled tasks instead.
m_connUpdate = l->signal_update().connect(sigc::mem_fun(*this, &WindowLogComplete::receive_update));
}
WindowLogComplete::~WindowLogComplete() {
m_connUpdate.disconnect();
}
WindowLogComplete::iterator
WindowLogComplete::find_older() {
return m_log->find_older(utils::Timer::cache() - 60*1000000);
}
void
WindowLogComplete::redraw() {
m_nextDraw = utils::Timer::max();
m_canvas->erase();
int pos = 0;
m_canvas->print(std::max(0, (int)m_canvas->get_width() / 2 - 5), pos++, "*** Log ***");
for (core::Log::iterator itr = m_log->begin(), e = m_log->end(); itr != e && pos < m_canvas->get_height(); ++itr) {
std::tm *t = std::localtime(&itr->first.tval().tv_sec);
if (t == NULL)
m_canvas->print(0, pos++, "(time error) %s",
itr->second.c_str());
else
m_canvas->print(0, pos++, "(%02i:%02i:%02i) %s",
t->tm_hour, t->tm_min, t->tm_sec,
itr->second.c_str());
}
}
void
WindowLogComplete::receive_update() {
mark_dirty();
}
}
+32
View File
@@ -0,0 +1,32 @@
#ifndef RTORRENT_DISPLAY_WINDOW_LOG_COMPLETE_H
#define RTORRENT_DISPLAY_WINDOW_LOG_COMPLETE_H
#include <sigc++/connection.h>
#include "core/log.h"
#include "window.h"
namespace display {
class WindowLogComplete : public Window {
public:
typedef core::Log::iterator iterator;
WindowLogComplete(core::Log* l);
~WindowLogComplete();
virtual void redraw();
void receive_update();
private:
inline iterator find_older();
core::Log* m_log;
sigc::connection m_connUpdate;
};
}
#endif
+8 -4
View File
@@ -4,6 +4,7 @@
#include "core/download.h"
#include "rak/algorithm.h"
#include "utils/parse.h"
#include "window_tracker_list.h"
@@ -38,18 +39,21 @@ WindowTrackerList::redraw() {
Range range = rak::advance_bidirectional<unsigned int>(0,
*m_focus,
m_download->get_download().get_tracker_size(),
m_canvas->get_height());
(m_canvas->get_height() + 1) / 2);
while (range.first != range.second) {
torrent::Tracker t = m_download->get_download().get_tracker(range.first);
m_canvas->print(0, pos, "%c %2i %s",
m_canvas->print(0, pos++, "%c %s",
range.first == *m_focus ? '*' : ' ',
t.get_group(),
t.get_url().c_str());
m_canvas->print(0, pos++, "%c Group: %2i Id: %s",
range.first == *m_focus ? '*' : ' ',
t.get_group(),
utils::escape_string(t.get_tracker_id()).c_str());
++range.first;
++pos;
}
}