compile
[kdegraphics.git] / okular / core / generator_p.cpp
blobe0cf684d46aa31e2ab79bb1285683943e32b1ec7
1 /***************************************************************************
2 * Copyright (C) 2007 Tobias Koenig <tokoe@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 "generator_p.h"
12 #include <kdebug.h>
14 #include "fontinfo.h"
15 #include "generator.h"
16 #include "utils.h"
18 using namespace Okular;
20 PixmapGenerationThread::PixmapGenerationThread( Generator *generator )
21 : mGenerator( generator ), mRequest( 0 ), mCalcBoundingBox( false )
25 void PixmapGenerationThread::startGeneration( PixmapRequest *request, bool calcBoundingBox )
27 mRequest = request;
28 mCalcBoundingBox = calcBoundingBox;
30 start( QThread::InheritPriority );
33 void PixmapGenerationThread::endGeneration()
35 mRequest = 0;
38 PixmapRequest *PixmapGenerationThread::request() const
40 return mRequest;
43 QImage PixmapGenerationThread::image() const
45 return mImage;
48 bool PixmapGenerationThread::calcBoundingBox() const
50 return mCalcBoundingBox;
53 NormalizedRect PixmapGenerationThread::boundingBox() const
55 return mBoundingBox;
58 void PixmapGenerationThread::run()
60 mImage = QImage();
62 if ( mRequest )
64 mImage = mGenerator->image( mRequest );
65 if ( mCalcBoundingBox )
66 mBoundingBox = Utils::imageBoundingBox( &mImage );
71 TextPageGenerationThread::TextPageGenerationThread( Generator *generator )
72 : mGenerator( generator ), mPage( 0 )
76 void TextPageGenerationThread::startGeneration( Page *page )
78 mPage = page;
80 start( QThread::InheritPriority );
83 void TextPageGenerationThread::endGeneration()
85 mPage = 0;
88 Page *TextPageGenerationThread::page() const
90 return mPage;
93 TextPage* TextPageGenerationThread::textPage() const
95 return mTextPage;
98 void TextPageGenerationThread::run()
100 mTextPage = 0;
102 if ( mPage )
103 mTextPage = mGenerator->textPage( mPage );
107 FontExtractionThread::FontExtractionThread( Generator *generator, int pages )
108 : mGenerator( generator ), mNumOfPages( pages ), mGoOn( true )
112 void FontExtractionThread::startExtraction( bool async )
114 if ( async )
116 connect( this, SIGNAL( finished() ), this, SLOT( deleteLater() ) );
117 start( QThread::InheritPriority );
119 else
121 run();
122 deleteLater();
126 void FontExtractionThread::stopExtraction()
128 mGoOn = false;
131 void FontExtractionThread::run()
133 for ( int i = -1; i < mNumOfPages && mGoOn; ++i )
135 FontInfo::List list = mGenerator->fontsForPage( i );
136 foreach ( const FontInfo& fi, list )
138 emit gotFont( fi );
140 emit progress( i );
144 #include "generator_p.moc"