* Finished FileListIterator and basic navigation of the file list.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@832 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2006-12-25 13:19:45 +00:00
parent c453565e8f
commit 25702ea4b7
6 changed files with 48 additions and 48 deletions
+1
View File
@@ -93,6 +93,7 @@ public:
void print_char(const chtype ch) { waddch(m_window, ch); }
void print_char(unsigned int x, unsigned int y, const chtype ch) { mvwaddch(m_window, y, x, ch); }
void set_attr(int attr, int color) { wattr_set(m_window, attr, color, NULL); }
void set_attr(unsigned int x, unsigned int y, unsigned int n, int attr, int color) { mvwchgat(m_window, y, x, n, attr, color, NULL); }
// Initialize stdscr.
+6 -2
View File
@@ -58,8 +58,9 @@ public:
static const int flag_active = (1 << 0);
static const int flag_offscreen = (1 << 1);
static const int flag_left = (1 << 2);
static const int flag_bottom = (1 << 3);
static const int flag_focused = (1 << 2);
static const int flag_left = (1 << 3);
static const int flag_bottom = (1 << 4);
static const extent_type extent_static = extent_type();
static const extent_type extent_full = ~extent_type();
@@ -76,6 +77,9 @@ public:
bool is_offscreen() const { return m_flags & flag_offscreen; }
void set_offscreen(bool state) { if (state) m_flags |= flag_offscreen; else m_flags &= ~flag_offscreen; }
bool is_focused() const { return m_flags & flag_focused; }
void set_focused(bool state) { if (state) m_flags |= flag_focused; else m_flags &= ~flag_focused; }
bool is_left() const { return m_flags & flag_left; }
void set_left(bool state) { if (state) m_flags |= flag_left; else m_flags &= ~flag_left; }
+18 -24
View File
@@ -49,10 +49,10 @@
namespace display {
WindowFileList::WindowFileList(core::Download* d, iterator* focus) :
WindowFileList::WindowFileList(core::Download* d, iterator* selected) :
Window(new Canvas, 0, 0, 0, extent_full, extent_full),
m_download(d),
m_focus(focus) {
m_selected(selected) {
}
/*
@@ -93,30 +93,21 @@ WindowFileList::redraw() {
++pos;
// if (m_focus->first >= fl->size_files() || m_focus->second >= (*(fl->begin() + m_focus->first))->path()->size())
// throw torrent::internal_error("WindowFileList::redraw() called on an object with a bad focus value.");
iterator itr = rak::advance_bidirectional<iterator>(iterator(fl->begin()), *m_selected, iterator(fl->end()), m_canvas->height() - pos).first;
// std::pair<unsigned int, unsigned int> range = rak::advance_bidirectional<unsigned int>(0, *m_focus, fl->size_files(), m_canvas->height() - pos);
// iterator first(fl->begin() + range.first, (*(fl->begin() + range.first))->match_depth_prev());
// iterator last(fl->end());
std::pair<iterator, iterator> range =
rak::advance_bidirectional<iterator>(iterator(fl->begin()), *m_focus, iterator(fl->end()), m_canvas->height() - pos);
while (pos != m_canvas->height() && range.first != range.second) {
if (range.first.is_empty()) {
while (pos != m_canvas->height() && itr != iterator(fl->end())) {
if (itr.is_empty()) {
m_canvas->print(0, pos, "EMPTY");
} else if (range.first.is_entering()) {
m_canvas->print(range.first.depth(), pos, "\\ %s",
range.first.depth() < (*range.first)->path()->size() ? (*range.first)->path()->at(range.first.depth()).c_str() : "UNKNOWN");
} else if (itr.is_entering()) {
m_canvas->print(itr.depth(), pos, "\\ %s",
itr.depth() < (*itr)->path()->size() ? (*itr)->path()->at(itr.depth()).c_str() : "UNKNOWN");
} else if (range.first.is_leaving()) {
m_canvas->print(range.first.depth(), pos, "/");
} else if (itr.is_leaving()) {
m_canvas->print(itr.depth(), pos, "/");
} else if (range.first.is_file()) {
torrent::File* e = *range.first;
} else if (itr.is_file()) {
torrent::File* e = *itr;
std::string priority;
@@ -138,8 +129,8 @@ WindowFileList::redraw() {
break;
};
m_canvas->print(range.first.depth(), pos, "| %s",
range.first.depth() < (*range.first)->path()->size() ? (*range.first)->path()->at(range.first.depth()).c_str() : "UNKNOWN");
m_canvas->print(itr.depth(), pos, "| %s",
itr.depth() < (*itr)->path()->size() ? (*itr)->path()->at(itr.depth()).c_str() : "UNKNOWN");
// %6.1f %s %3d %9s",
// (double)e->size_bytes() / (double)(1 << 20),
@@ -159,7 +150,10 @@ WindowFileList::redraw() {
m_canvas->print(0, pos, "BORK BORK");
}
++range.first;
if (itr == *m_selected)
m_canvas->set_attr(0, pos, m_canvas->width(), is_focused() ? A_REVERSE : A_BOLD, COLOR_PAIR(0));
++itr;
++pos;
}
}
+2 -2
View File
@@ -56,7 +56,7 @@ class WindowFileList : public Window {
public:
typedef torrent::FileListIterator iterator;
WindowFileList(core::Download* d, iterator* focus);
WindowFileList(core::Download* d, iterator* selected);
virtual void redraw();
@@ -64,7 +64,7 @@ private:
int done_percentage(torrent::File* e);
core::Download* m_download;
iterator* m_focus;
iterator* m_selected;
};
}