12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #include "bookunrarqueuethread.h"
- BookUnrarQueueThread::BookUnrarQueueThread(QueueType type):
- m_type(type)
- {
- m_canProceed = false;
- }
- void BookUnrarQueueThread::append(Book* book)
- {
- switch(m_type){
- case PageName:{
- m_nameQueue.append(book);
- if(!this->isRunning())
- this->start();
- }break;
- case PageImage:{
- m_imageQueue.append(book);
- if(!this->isRunning())
- this->start();
- }break;
- }
- }
- void BookUnrarQueueThread::run()
- {
- switch(m_type){
- case PageName:{
- while(!m_nameQueue.isEmpty()){
- if(m_canProceed){
- emit queueNext(m_nameQueue.takeFirst());
- m_canProceed = false;
- }
- msleep(100);
- }
- }break;
- case PageImage:{
- while(!m_imageQueue.isEmpty()){
- if(m_canProceed){
- emit queueNext(m_imageQueue.takeFirst());
- m_canProceed = false;
- }
- msleep(100);
- }
- }break;
- default:break;
- }
- }
- void BookUnrarQueueThread::next()
- {
- m_canProceed = true;
- }
- bool BookUnrarQueueThread::haveItems()
- {
- bool ret(false);
- switch(m_type){
- case PageName:{
- if(!m_nameQueue.isEmpty())
- ret = true;
- }break;
- case PageImage:{
- if(!m_imageQueue.isEmpty()){
- ret = true;
- }
- }break;
- default:break;
- }
- return ret;
- }
|