diff --git a/CMakeLists.txt b/CMakeLists.txt index eda07b7d7..a51e6296b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,6 @@ set(okularcore_SRCS core/sourcereference.cpp core/textdocumentgenerator.cpp core/textpage.cpp - core/threadedgenerator.cpp core/utils.cpp ) @@ -64,7 +63,6 @@ install( FILES core/sourcereference.h core/textdocumentgenerator.h core/textpage.h - core/threadedgenerator.h core/utils.h DESTINATION ${INCLUDE_INSTALL_DIR}/okular/core ) diff --git a/core/generator.cpp b/core/generator.cpp index 123918f38..1f804fe2d 100644 --- a/core/generator.cpp +++ b/core/generator.cpp @@ -14,8 +14,8 @@ #include "document.h" #include "generator.h" +#include "generator_p.h" #include "page.h" -#include "threadedgenerator_p.h" using namespace Okular; diff --git a/core/threadedgenerator_p.h b/core/generator_p.h similarity index 100% rename from core/threadedgenerator_p.h rename to core/generator_p.h diff --git a/core/threadedgenerator.cpp b/core/threadedgenerator.cpp deleted file mode 100644 index f45911217..000000000 --- a/core/threadedgenerator.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 Tobias Koenig * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - ***************************************************************************/ - -#include "core/page.h" -#include "core/textpage.h" - -#include "threadedgenerator.h" -#include "threadedgenerator_p.h" - -using namespace Okular; - -class ThreadedGenerator::Private -{ - public: - Private( ThreadedGenerator *parent ) - : mParent( parent ), - mPixmapReady( true ), - mTextPageReady( true ) - { - mPixmapGenerationThread = new PixmapGenerationThread( mParent ); - mParent->connect( mPixmapGenerationThread, SIGNAL( finished() ), - mParent, SLOT( pixmapGenerationFinished() ), - Qt::QueuedConnection ); - - mTextPageGenerationThread = new TextPageGenerationThread( mParent ); - mParent->connect( mTextPageGenerationThread, SIGNAL( finished() ), - mParent, SLOT( textpageGenerationFinished() ), - Qt::QueuedConnection ); - } - - ~Private() - { - if ( mPixmapGenerationThread ) - mPixmapGenerationThread->wait(); - - delete mPixmapGenerationThread; - - if ( mTextPageGenerationThread ) - mTextPageGenerationThread->wait(); - - delete mTextPageGenerationThread; - } - - void pixmapGenerationFinished(); - void textpageGenerationFinished(); - - ThreadedGenerator *mParent; - PixmapGenerationThread *mPixmapGenerationThread; - TextPageGenerationThread *mTextPageGenerationThread; - bool mPixmapReady; - bool mTextPageReady; -}; - -void ThreadedGenerator::Private::pixmapGenerationFinished() -{ - PixmapRequest *request = mPixmapGenerationThread->request(); - mPixmapGenerationThread->endGeneration(); - - request->page()->setPixmap( request->id(), new QPixmap( QPixmap::fromImage( mPixmapGenerationThread->image() ) ) ); - - mPixmapReady = true; - - mParent->signalPixmapRequestDone( request ); -} - -void ThreadedGenerator::Private::textpageGenerationFinished() -{ - Page *page = mTextPageGenerationThread->page(); - mTextPageGenerationThread->endGeneration(); - - mTextPageReady = true; - - if ( mTextPageGenerationThread->textPage() ) - page->setTextPage( mTextPageGenerationThread->textPage() ); -} - -ThreadedGenerator::ThreadedGenerator() - : d( new Private( this ) ) -{ -} - -ThreadedGenerator::~ThreadedGenerator() -{ - delete d; -} - -bool ThreadedGenerator::canRequestPixmap() const -{ - return d->mPixmapReady; -} - -void ThreadedGenerator::requestPixmap( PixmapRequest * request ) -{ - d->mPixmapReady = false; - - d->mPixmapGenerationThread->startGeneration( request ); -} - -bool ThreadedGenerator::canRequestTextPage() const -{ - return d->mTextPageReady; -} - -void ThreadedGenerator::requestTextPage( Page * page ) -{ - d->mTextPageReady = false; - - d->mTextPageGenerationThread->startGeneration( page ); -} - -TextPage* ThreadedGenerator::textPage( Page* ) -{ - return 0; -} - -bool ThreadedGenerator::canGeneratePixmap() const -{ - // dummy implementation - return false; -} - -void ThreadedGenerator::generatePixmap( PixmapRequest* ) -{ - // dummy implementation -} - -bool ThreadedGenerator::canGenerateTextPage() const -{ - // dummy implementation - return false; -} - -void ThreadedGenerator::generateSyncTextPage( Page* ) -{ - // dummy implementation -} - -#include "threadedgenerator.moc" diff --git a/core/threadedgenerator.h b/core/threadedgenerator.h deleted file mode 100644 index 495bd0b8f..000000000 --- a/core/threadedgenerator.h +++ /dev/null @@ -1,113 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 Tobias Koenig * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - ***************************************************************************/ - -#ifndef OKULAR_THREADEDGENERATOR_H -#define OKULAR_THREADEDGENERATOR_H - -#include - -#include - -namespace Okular { - -/** - * ThreadedGenerator is meant to be a base class for Okular generators - * which supports multithreaded generation of page pixmaps, text pages - * and other data structures. - */ -class OKULAR_EXPORT ThreadedGenerator : public Generator -{ - friend class PixmapGenerationThread; - friend class TextPageGenerationThread; - - Q_OBJECT - - public: - /** - * Creates a new threaded generator. - */ - ThreadedGenerator(); - - /** - * Destroys the threaded generator. - */ - ~ThreadedGenerator(); - - /** - * Returns whether the generator is ready to - * handle a new pixmap generation request. - */ - bool canRequestPixmap() const; - - /** - * This method can be called to trigger the generation of - * a new pixmap as described by @p request. - */ - void requestPixmap( PixmapRequest * request ); - - /** - * Returns whether the generator is ready to - * handle a new text page generation request. - */ - bool canRequestTextPage() const; - - /** - * This method can be called to trigger the generation of - * a text page for the given @p page. - * @see TextPage - */ - void requestTextPage( Page * page ); - - protected: - /** - * Returns the image of the page as specified in - * the passed pixmap @p request. - * - * Note: This method is executed in its own separated thread! - */ - virtual QImage image( PixmapRequest *page ) = 0; - - /** - * Returns the text page for the given @p page. - * - * Note: This method is executed in its own separated thread! - */ - virtual TextPage* textPage( Page *page ); - - /** - * @internal - */ - bool canGeneratePixmap() const; - - /** - * @internal - */ - void generatePixmap( PixmapRequest* ); - - /** - * @internal - */ - bool canGenerateTextPage() const; - - /** - * @internal - */ - void generateSyncTextPage( Page* ); - - private: - class Private; - Private* const d; - - Q_PRIVATE_SLOT( d, void pixmapGenerationFinished() ) - Q_PRIVATE_SLOT( d, void textpageGenerationFinished() ) -}; - -} - -#endif