Add a second parameter to requestTextPage/generateTextPage where you can

specify whether the request should be synchronous or asynchronous

svn path=/trunk/playground/graphics/okular/; revision=628893
remotes/origin/KDE/4.0
Tobias Koenig 19 years ago
parent d16343f677
commit 0847edc4b7
  1. 4
      core/document.cpp
  2. 2
      core/document.h
  3. 25
      core/generator.cpp
  4. 7
      core/generator.h
  5. 9
      core/global.h

@ -1320,7 +1320,7 @@ void Document::requestPixmaps( const QLinkedList< PixmapRequest * > & requests )
d->sendGeneratorRequest();
}
void Document::requestTextPage( uint page )
void Document::requestTextPage( uint page, enum GenerationType type )
{
Page * kp = d->m_pagesVector[ page ];
if ( !d->m_generator || !kp )
@ -1328,7 +1328,7 @@ void Document::requestTextPage( uint page )
// Memory management for TextPages
d->m_generator->generateTextPage( kp );
d->m_generator->generateTextPage( kp, type );
}
void Document::addPageAnnotation( int page, Annotation * annotation )

@ -309,7 +309,7 @@ class OKULAR_EXPORT Document : public QObject
/**
* Sends a request for text page generation for the given page @p number.
*/
void requestTextPage( uint number );
void requestTextPage( uint number, enum GenerationType type = Synchronous );
/**
* Adds a new @p annotation to the given @p page.

@ -134,6 +134,17 @@ void Generator::generatePixmap( PixmapRequest *request )
{
d->createPixmapGenerationThread();
d->mPixmapGenerationThread->startGeneration( request );
/**
* We create the text page for every page that is visible to the
* user, so he can use the text extraction tools without a delay.
*/
if ( !request->page()->hasTextPage() && canGenerateTextPage() ) {
d->mTextPageReady = false;
d->createTextPageGenerationThread();
d->mTextPageGenerationThread->startGeneration( request->page() );
}
return;
}
@ -149,15 +160,17 @@ bool Generator::canGenerateTextPage() const
return d->mTextPageReady;
}
void Generator::generateTextPage( Page *page )
void Generator::generateTextPage( Page *page, enum GenerationType type )
{
d->mTextPageReady = false;
if ( hasFeature( Threaded ) )
{
d->createTextPageGenerationThread();
d->mTextPageGenerationThread->startGeneration( page );
return;
if ( type == Asynchronous ) {
if ( hasFeature( Threaded ) )
{
d->createTextPageGenerationThread();
d->mTextPageGenerationThread->startGeneration( page );
return;
}
}
page->setTextPage( textPage( page ) );

@ -221,9 +221,14 @@ class OKULAR_EXPORT Generator : public QObject
/**
* This method can be called to trigger the generation of
* a text page for the given @p page.
*
* The generation is done synchronous or asynchronous, depending
* on the @p type parameter and the capabilities of the
* generator (e.g. multithreading).
*
* @see TextPage
*/
virtual void generateTextPage( Page * page );
virtual void generateTextPage( Page * page, enum GenerationType type = Synchronous );
/**
* Returns the general information object of the document or 0 if

@ -48,6 +48,15 @@ enum Rotation
Rotation270 = 3 ///< Rotated 2700 degrees clockwise.
};
/**
* Describes the type of generation of objects
*/
enum GenerationType
{
Synchronous, ///< Will create the object in a synchronous way
Asynchronous ///< Will create the object in an asynchronous way
};
}
#endif

Loading…
Cancel
Save