* Added torrent::FileList to the API.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@659 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2006-03-30 17:57:57 +00:00
parent 8ea6f78e21
commit 59a23ea9ed
9 changed files with 65 additions and 44 deletions
+12 -12
View File
@@ -38,6 +38,8 @@
#include <stdexcept>
#include <rak/algorithm.h>
#include <torrent/file.h>
#include <torrent/file_list.h>
#include <torrent/path.h>
#include "core/download.h"
@@ -74,8 +76,9 @@ WindowFileList::redraw() {
m_slotSchedule(this, (cachedTime + rak::timer::from_seconds(10)).round_seconds());
m_canvas->erase();
if (m_download->get_download().size_file_entries() == 0 ||
m_canvas->get_height() < 2)
torrent::FileList fl = m_download->get_download().file_list();
if (fl.size() == 0 || m_canvas->get_height() < 2)
return;
int pos = 0;
@@ -89,16 +92,13 @@ WindowFileList::redraw() {
++pos;
if (*m_focus >= m_download->get_download().size_file_entries())
if (*m_focus >= fl.size())
throw std::logic_error("WindowFileList::redraw() called on an object with a bad focus value");
Range range = rak::advance_bidirectional<unsigned int>(0,
*m_focus,
m_download->get_download().size_file_entries(),
m_canvas->get_height() - pos);
Range range = rak::advance_bidirectional<unsigned int>(0, *m_focus, fl.size(), m_canvas->get_height() - pos);
while (range.first != range.second) {
torrent::Entry e = m_download->get_download().file_entry(range.first);
torrent::File e = fl.get(range.first);
std::string path = e.path_str();
@@ -110,15 +110,15 @@ WindowFileList::redraw() {
std::string priority;
switch (e.priority()) {
case torrent::Entry::OFF:
case torrent::File::OFF:
priority = "off";
break;
case torrent::Entry::NORMAL:
case torrent::File::NORMAL:
priority = " ";
break;
case torrent::Entry::HIGH:
case torrent::File::HIGH:
priority = "hig";
break;
@@ -146,7 +146,7 @@ WindowFileList::redraw() {
}
int
WindowFileList::done_percentage(torrent::Entry& e) {
WindowFileList::done_percentage(torrent::File& e) {
int chunks = e.chunk_end() - e.chunk_begin();
return chunks ? (e.completed_chunks() * 100) / chunks : 100;
+2 -2
View File
@@ -42,7 +42,7 @@
#include "window.h"
namespace torrent {
class Entry;
class File;
}
namespace core {
@@ -60,7 +60,7 @@ public:
virtual void redraw();
private:
int done_percentage(torrent::Entry& e);
int done_percentage(torrent::File& e);
core::Download* m_download;
+1
View File
@@ -39,6 +39,7 @@
#include <stdexcept>
#include <rak/algorithm.h>
#include <rak/string_manip.h>
#include <torrent/tracker.h>
#include <torrent/tracker_list.h>
#include "core/download.h"