2 * This file is a part of QComicBook.
4 * Copyright (C) 2005-2006 Pawel Stolowski <yogin@linux.bydg.org>
6 * QComicBook is free software; you can redestribute it and/or modify it
7 * under terms of GNU General Public License by Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY. See GPL for more details.
13 #include "imgloader.h"
14 #include "imgdirsink.h"
17 using namespace QComicBook;
19 ImgLoaderThread::ImgLoaderThread(): QThread(), prio(QThread::LowPriority), sink(NULL), stopped(false)
23 ImgLoaderThread::~ImgLoaderThread()
27 void ImgLoaderThread::setPriority(QThread::Priority p)
34 void ImgLoaderThread::setSink(ImgDirSink *sink)
41 void ImgLoaderThread::request(int page)
44 if (requests.contains(page))
49 requests.append(page);
50 if (!running() && !stopped)
59 void ImgLoaderThread::request(int first, int n)
62 const int last = first + n;
63 for (int i=first; i<last; i++)
64 if (requests.contains(i) == 0)
66 if (!running() && !stopped)
75 void ImgLoaderThread::stop()
82 void ImgLoaderThread::run()
87 if (stopped || requests.empty())
93 const int n = requests.first();
98 sink->getImage(n, result);