mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-24 18:35:37 +00:00
Last step of the ThreadedGenerator -> Generator merge: remove the old files and rename the used file.
svn path=/trunk/playground/graphics/okular/; revision=628856
This commit is contained in:
parent
6068c76df6
commit
92ea1bba69
|
@ -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 )
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
#include "document.h"
|
||||
#include "generator.h"
|
||||
#include "generator_p.h"
|
||||
#include "page.h"
|
||||
#include "threadedgenerator_p.h"
|
||||
|
||||
using namespace Okular;
|
||||
|
||||
|
|
|
@ -1,144 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2007 Tobias Koenig <tokoe@kde.org> *
|
||||
* *
|
||||
* 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"
|
|
@ -1,113 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2007 Tobias Koenig <tokoe@kde.org> *
|
||||
* *
|
||||
* 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 <okular/core/okular_export.h>
|
||||
|
||||
#include <okular/core/generator.h>
|
||||
|
||||
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
|
Loading…
Reference in a new issue