[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/graphics/okular/core
From: Tobias Koenig <tokoe () kde ! org>
Date: 2007-01-31 21:10:01
Message-ID: 1170277801.596324.2408.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 628893 by tokoe:
Add a second parameter to requestTextPage/generateTextPage where you can
specify whether the request should be synchronous or asynchronous
M +2 -2 document.cpp
M +1 -1 document.h
M +19 -6 generator.cpp
M +6 -1 generator.h
M +9 -0 global.h
--- trunk/playground/graphics/okular/core/document.cpp #628892:628893
@@ -1320,7 +1320,7 @@
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 @@
// Memory management for TextPages
- d->m_generator->generateTextPage( kp );
+ d->m_generator->generateTextPage( kp, type );
}
void Document::addPageAnnotation( int page, Annotation * annotation )
--- trunk/playground/graphics/okular/core/document.h #628892:628893
@@ -309,7 +309,7 @@
/**
* 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.
--- trunk/playground/graphics/okular/core/generator.cpp #628892:628893
@@ -134,6 +134,17 @@
{
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 @@
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 ) );
--- trunk/playground/graphics/okular/core/generator.h #628892:628893
@@ -221,9 +221,14 @@
/**
* 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
--- trunk/playground/graphics/okular/core/global.h #628892:628893
@@ -48,6 +48,15 @@
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic