mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-27 11:40:07 +00:00
make KDjVu no more a QObject, and remove the traces of "async" loading (never really implemented)
svn path=/trunk/KDE/kdegraphics/okular/; revision=716072
This commit is contained in:
parent
746074cfcb
commit
823edf52b1
|
@ -64,7 +64,6 @@ DjVuGenerator::DjVuGenerator() : Okular::Generator(),
|
|||
{
|
||||
setFeature( TextExtraction );
|
||||
m_djvu = new KDjVu();
|
||||
connect( m_djvu, SIGNAL( imageGenerated( int, const QImage & ) ), this, SLOT( djvuImageGenerated( int, const QImage & ) ) );
|
||||
|
||||
KAboutData *about = new KAboutData(
|
||||
"okular_djvu",
|
||||
|
@ -123,8 +122,6 @@ void DjVuGenerator::generatePixmap( Okular::PixmapRequest * request )
|
|||
QImage img = m_djvu->image( request->pageNumber(), request->width(), request->height(), request->page()->rotation() );
|
||||
if ( img.isNull() )
|
||||
{
|
||||
|
||||
m_djvu->requestImage( request->pageNumber(), request->width(), request->height(), request->page()->rotation() );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -445,7 +445,7 @@ void KDjVu::Private::readMetaData( int page )
|
|||
}
|
||||
|
||||
|
||||
KDjVu::KDjVu() : QObject(), d( new Private )
|
||||
KDjVu::KDjVu() : d( new Private )
|
||||
{
|
||||
// creating the djvu context
|
||||
d->m_djvu_cxt = ddjvu_context_create( "KDjVu" );
|
||||
|
@ -775,25 +775,15 @@ QImage KDjVu::image( int page, int width, int height, int rotation )
|
|||
: cur->width == height && cur->height == width ) )
|
||||
found = true;
|
||||
}
|
||||
if ( !found )
|
||||
return QImage();
|
||||
|
||||
// taking the element and pushing to the top of the list
|
||||
--it;
|
||||
ImageCacheItem* cur2 = *it;
|
||||
d->mImgCache.erase( it );
|
||||
d->mImgCache.push_front( cur2 );
|
||||
|
||||
return cur2->img;
|
||||
}
|
||||
|
||||
void KDjVu::requestImage( int page, int width, int height, int rotation )
|
||||
{
|
||||
QImage tmp = image( page, width, height, rotation );
|
||||
if ( !tmp.isNull() )
|
||||
if ( found )
|
||||
{
|
||||
emit imageGenerated( page, tmp );
|
||||
return;
|
||||
// taking the element and pushing to the top of the list
|
||||
--it;
|
||||
ImageCacheItem* cur2 = *it;
|
||||
d->mImgCache.erase( it );
|
||||
d->mImgCache.push_front( cur2 );
|
||||
|
||||
return cur2->img;
|
||||
}
|
||||
|
||||
if ( !d->m_pages_cache.at( page ) )
|
||||
|
@ -854,15 +844,11 @@ void KDjVu::requestImage( int page, int width, int height, int rotation )
|
|||
p.end();
|
||||
}
|
||||
|
||||
QImage resimg;
|
||||
|
||||
if ( res )
|
||||
{
|
||||
resimg = newimg;
|
||||
|
||||
// delete all the cached pixmaps for the current page with a size that
|
||||
// differs no more than 35% of the new pixmap size
|
||||
int imgsize = resimg.width() * resimg.height();
|
||||
int imgsize = newimg.width() * newimg.height();
|
||||
if ( imgsize > 0 )
|
||||
{
|
||||
for( int i = 0; i < d->mImgCache.count(); )
|
||||
|
@ -889,7 +875,7 @@ void KDjVu::requestImage( int page, int width, int height, int rotation )
|
|||
d->mImgCache.push_front( ich );
|
||||
}
|
||||
|
||||
emit imageGenerated( page, newimg );
|
||||
return newimg;
|
||||
}
|
||||
|
||||
bool KDjVu::exportAsPostScript( const QString & fileName, const QList<int>& pageList ) const
|
||||
|
@ -997,6 +983,3 @@ QList<KDjVu::TextEntity> KDjVu::textEntities( int page, const QString & granular
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#include "kdjvu.moc"
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include <qcolor.h>
|
||||
#include <qimage.h>
|
||||
#include <qlist.h>
|
||||
#include <qobject.h>
|
||||
#include <qpolygon.h>
|
||||
#include <qrect.h>
|
||||
#include <qvariant.h>
|
||||
|
@ -25,9 +24,8 @@ class QFile;
|
|||
/**
|
||||
* @brief Qt (KDE) encapsulation of the DjVuLibre
|
||||
*/
|
||||
class KDjVu : public QObject
|
||||
class KDjVu
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KDjVu();
|
||||
~KDjVu();
|
||||
|
@ -240,18 +238,12 @@ class KDjVu : public QObject
|
|||
*/
|
||||
void linksAndAnnotationsForPage( int pageNum, QList<KDjVu::Link*> *links, QList<KDjVu::Annotation*> *annotations ) const;
|
||||
|
||||
// image handling
|
||||
/**
|
||||
* Check if the image for the specified \p page with the specified
|
||||
* \p width, \p height and \p rotation is already in cache, and returns
|
||||
* it. If not, a null image is returned.
|
||||
*/
|
||||
QImage image( int page, int width, int height, int rotation );
|
||||
/**
|
||||
* Request to load the pixmap for \p page having the specified \p width,
|
||||
* \p height and \p rotation. It will emit pixmapGenerated() when done.
|
||||
*/
|
||||
void requestImage( int page, int width, int height, int rotation );
|
||||
|
||||
/**
|
||||
* Export the currently open document as PostScript file \p fileName.
|
||||
|
@ -271,12 +263,6 @@ class KDjVu : public QObject
|
|||
*/
|
||||
QList<KDjVu::TextEntity> textEntities( int page, const QString & granularity ) const;
|
||||
|
||||
signals:
|
||||
/**
|
||||
* The image \p pix for page \p page was generated.
|
||||
*/
|
||||
void imageGenerated( int page, const QImage & pix );
|
||||
|
||||
private:
|
||||
class Private;
|
||||
Private * const d;
|
||||
|
|
Loading…
Reference in a new issue