compile
[kdegraphics.git] / okular / core / pagecontroller.cpp
blob1a2d477cb594000755110c6e8c40971045ec9a6d
1 /***************************************************************************
2 * Copyright (C) 2007 by Pino Toscano <pino@kde.org> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 ***************************************************************************/
10 #include "pagecontroller_p.h"
12 // qt/kde includes
13 #include <kglobal.h>
14 #include <threadweaver/ThreadWeaver.h>
16 // local includes
17 #include "page_p.h"
18 #include "rotationjob_p.h"
20 K_GLOBAL_STATIC( Okular::PageController, page_controller_self )
22 using namespace Okular;
24 PageController::PageController()
25 : QObject()
29 PageController::~PageController()
33 PageController * PageController::self()
35 return page_controller_self;
38 void PageController::addRotationJob(RotationJob *job)
40 initWeaver();
41 ThreadWeaver::Weaver::instance()->enqueue(job);
44 void PageController::imageRotationDone(ThreadWeaver::Job *j)
46 RotationJob *job = qobject_cast< RotationJob * >(j);
48 if ( !job )
49 return;
51 if ( job->page() )
53 job->page()->imageRotationDone( job );
55 emit rotationFinished( job->page()->m_number );
58 job->deleteLater();
61 void PageController::initWeaver()
63 static bool weaverInited = false;
64 if ( weaverInited )
65 return;
67 connect( ThreadWeaver::Weaver::instance(), SIGNAL( jobDone(ThreadWeaver::Job*) ),
68 this, SLOT( imageRotationDone(ThreadWeaver::Job*) ) );
70 weaverInited = true;
73 #include "pagecontroller_p.moc"