2006-07-20 20:47:05 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2005 by Piotr Szymanski <niedakh@gmail.com> *
|
|
|
|
* *
|
|
|
|
* 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. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
2007-04-19 18:30:20 +00:00
|
|
|
#include "generator.h"
|
|
|
|
#include "generator_p.h"
|
|
|
|
|
2007-10-08 21:49:27 +00:00
|
|
|
#include <qeventloop.h>
|
2007-10-15 23:01:27 +00:00
|
|
|
#include <QtGui/QPrinter>
|
2007-10-08 21:49:27 +00:00
|
|
|
|
2006-10-22 13:34:47 +00:00
|
|
|
#include <kdebug.h>
|
2006-10-25 15:35:53 +00:00
|
|
|
#include <kicon.h>
|
2007-03-10 21:32:09 +00:00
|
|
|
#include <klocale.h>
|
2006-03-21 20:00:24 +00:00
|
|
|
|
2006-12-28 16:45:50 +00:00
|
|
|
#include "document.h"
|
2007-09-14 15:29:16 +00:00
|
|
|
#include "document_p.h"
|
2007-01-31 18:31:19 +00:00
|
|
|
#include "page.h"
|
2007-10-08 21:49:27 +00:00
|
|
|
#include "textpage.h"
|
2005-11-20 15:30:15 +00:00
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
using namespace Okular;
|
|
|
|
|
2007-09-14 13:31:55 +00:00
|
|
|
GeneratorPrivate::GeneratorPrivate()
|
2007-12-02 22:55:12 +00:00
|
|
|
: m_document( 0 ),
|
2007-04-20 17:17:44 +00:00
|
|
|
mPixmapGenerationThread( 0 ), mTextPageGenerationThread( 0 ),
|
2007-10-08 21:49:27 +00:00
|
|
|
m_mutex( 0 ), m_threadsMutex( 0 ), mPixmapReady( true ), mTextPageReady( true ),
|
|
|
|
m_closing( false ), m_closingLoop( 0 )
|
2007-04-20 17:17:44 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
GeneratorPrivate::~GeneratorPrivate()
|
2006-10-25 15:35:53 +00:00
|
|
|
{
|
2007-04-20 17:17:44 +00:00
|
|
|
if ( mPixmapGenerationThread )
|
|
|
|
mPixmapGenerationThread->wait();
|
|
|
|
|
|
|
|
delete mPixmapGenerationThread;
|
|
|
|
|
|
|
|
if ( mTextPageGenerationThread )
|
|
|
|
mTextPageGenerationThread->wait();
|
|
|
|
|
|
|
|
delete mTextPageGenerationThread;
|
|
|
|
|
2007-09-15 11:35:53 +00:00
|
|
|
delete m_mutex;
|
2007-10-08 21:49:27 +00:00
|
|
|
delete m_threadsMutex;
|
2007-04-20 17:17:44 +00:00
|
|
|
}
|
|
|
|
|
2007-04-20 17:59:12 +00:00
|
|
|
PixmapGenerationThread* GeneratorPrivate::pixmapGenerationThread()
|
2007-01-31 18:50:31 +00:00
|
|
|
{
|
|
|
|
if ( mPixmapGenerationThread )
|
2007-04-20 17:59:12 +00:00
|
|
|
return mPixmapGenerationThread;
|
2007-01-31 18:50:31 +00:00
|
|
|
|
2007-09-14 13:31:55 +00:00
|
|
|
Q_Q( Generator );
|
|
|
|
mPixmapGenerationThread = new PixmapGenerationThread( q );
|
2007-01-31 18:50:31 +00:00
|
|
|
QObject::connect( mPixmapGenerationThread, SIGNAL( finished() ),
|
2007-09-14 13:31:55 +00:00
|
|
|
q, SLOT( pixmapGenerationFinished() ),
|
2007-01-31 18:50:31 +00:00
|
|
|
Qt::QueuedConnection );
|
2007-04-20 17:59:12 +00:00
|
|
|
|
|
|
|
return mPixmapGenerationThread;
|
2007-01-31 18:50:31 +00:00
|
|
|
}
|
|
|
|
|
2007-04-20 17:59:12 +00:00
|
|
|
TextPageGenerationThread* GeneratorPrivate::textPageGenerationThread()
|
2007-01-31 18:50:31 +00:00
|
|
|
{
|
|
|
|
if ( mTextPageGenerationThread )
|
2007-04-20 17:59:12 +00:00
|
|
|
return mTextPageGenerationThread;
|
2007-01-31 18:50:31 +00:00
|
|
|
|
2007-09-14 13:31:55 +00:00
|
|
|
Q_Q( Generator );
|
|
|
|
mTextPageGenerationThread = new TextPageGenerationThread( q );
|
2007-01-31 18:50:31 +00:00
|
|
|
QObject::connect( mTextPageGenerationThread, SIGNAL( finished() ),
|
2007-09-14 13:31:55 +00:00
|
|
|
q, SLOT( textpageGenerationFinished() ),
|
2007-01-31 18:50:31 +00:00
|
|
|
Qt::QueuedConnection );
|
2007-04-20 17:59:12 +00:00
|
|
|
|
|
|
|
return mTextPageGenerationThread;
|
2007-01-31 18:50:31 +00:00
|
|
|
}
|
|
|
|
|
2007-04-20 17:17:44 +00:00
|
|
|
void GeneratorPrivate::pixmapGenerationFinished()
|
2007-01-31 18:31:19 +00:00
|
|
|
{
|
2007-09-14 13:31:55 +00:00
|
|
|
Q_Q( Generator );
|
2007-01-31 18:31:19 +00:00
|
|
|
PixmapRequest *request = mPixmapGenerationThread->request();
|
|
|
|
mPixmapGenerationThread->endGeneration();
|
|
|
|
|
2007-10-08 21:49:27 +00:00
|
|
|
QMutexLocker locker( threadsLock() );
|
2007-01-31 18:31:19 +00:00
|
|
|
mPixmapReady = true;
|
|
|
|
|
2007-10-08 21:49:27 +00:00
|
|
|
if ( m_closing )
|
|
|
|
{
|
|
|
|
delete request;
|
|
|
|
if ( mTextPageReady )
|
|
|
|
{
|
|
|
|
locker.unlock();
|
|
|
|
m_closingLoop->quit();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
request->page()->setPixmap( request->id(), new QPixmap( QPixmap::fromImage( mPixmapGenerationThread->image() ) ) );
|
|
|
|
|
2007-09-14 13:31:55 +00:00
|
|
|
q->signalPixmapRequestDone( request );
|
2007-01-31 18:31:19 +00:00
|
|
|
}
|
|
|
|
|
2007-04-20 17:17:44 +00:00
|
|
|
void GeneratorPrivate::textpageGenerationFinished()
|
2007-01-31 18:31:19 +00:00
|
|
|
{
|
|
|
|
Page *page = mTextPageGenerationThread->page();
|
|
|
|
mTextPageGenerationThread->endGeneration();
|
|
|
|
|
2007-10-08 21:49:27 +00:00
|
|
|
QMutexLocker locker( threadsLock() );
|
2007-01-31 18:31:19 +00:00
|
|
|
mTextPageReady = true;
|
|
|
|
|
2007-10-08 21:49:27 +00:00
|
|
|
if ( m_closing )
|
|
|
|
{
|
|
|
|
delete mTextPageGenerationThread->textPage();
|
|
|
|
if ( mPixmapReady )
|
|
|
|
{
|
|
|
|
locker.unlock();
|
|
|
|
m_closingLoop->quit();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-01-31 18:31:19 +00:00
|
|
|
if ( mTextPageGenerationThread->textPage() )
|
|
|
|
page->setTextPage( mTextPageGenerationThread->textPage() );
|
|
|
|
}
|
|
|
|
|
2007-10-08 21:49:27 +00:00
|
|
|
QMutex* GeneratorPrivate::threadsLock()
|
|
|
|
{
|
|
|
|
if ( !m_threadsMutex )
|
|
|
|
m_threadsMutex = new QMutex();
|
|
|
|
return m_threadsMutex;
|
|
|
|
}
|
|
|
|
|
2007-01-31 18:31:19 +00:00
|
|
|
|
2007-12-02 20:57:24 +00:00
|
|
|
Generator::Generator( QObject *parent, const QVariantList &args )
|
|
|
|
: QObject( parent ), d_ptr( new GeneratorPrivate() )
|
2006-10-20 16:51:46 +00:00
|
|
|
{
|
2007-09-14 13:31:55 +00:00
|
|
|
d_ptr->q_ptr = this;
|
2007-12-02 20:57:24 +00:00
|
|
|
Q_UNUSED( args )
|
2007-09-14 13:31:55 +00:00
|
|
|
}
|
|
|
|
|
2007-12-02 20:57:24 +00:00
|
|
|
Generator::Generator( GeneratorPrivate &dd, QObject *parent, const QVariantList &args )
|
|
|
|
: QObject( parent ), d_ptr( &dd )
|
2007-09-14 13:31:55 +00:00
|
|
|
{
|
|
|
|
d_ptr->q_ptr = this;
|
2007-12-02 20:57:24 +00:00
|
|
|
Q_UNUSED( args )
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Generator::~Generator()
|
|
|
|
{
|
2007-09-14 13:31:55 +00:00
|
|
|
delete d_ptr;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
2007-01-12 22:49:14 +00:00
|
|
|
bool Generator::loadDocumentFromData( const QByteArray &, QVector< Page * > & )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-10-08 16:46:51 +00:00
|
|
|
bool Generator::closeDocument()
|
|
|
|
{
|
2007-10-08 21:49:27 +00:00
|
|
|
Q_D( Generator );
|
|
|
|
|
|
|
|
d->m_closing = true;
|
|
|
|
|
|
|
|
d->threadsLock()->lock();
|
|
|
|
if ( !( d->mPixmapReady && d->mTextPageReady ) )
|
|
|
|
{
|
|
|
|
QEventLoop loop;
|
|
|
|
d->m_closingLoop = &loop;
|
|
|
|
|
|
|
|
d->threadsLock()->unlock();
|
|
|
|
|
|
|
|
loop.exec();
|
|
|
|
|
|
|
|
d->m_closingLoop = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
d->threadsLock()->unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ret = doCloseDocument();
|
|
|
|
|
|
|
|
d->m_closing = false;
|
|
|
|
|
|
|
|
return ret;
|
2007-10-08 16:46:51 +00:00
|
|
|
}
|
|
|
|
|
2007-01-31 18:31:19 +00:00
|
|
|
bool Generator::canGeneratePixmap() const
|
2007-01-24 15:06:45 +00:00
|
|
|
{
|
2007-09-14 13:31:55 +00:00
|
|
|
Q_D( const Generator );
|
2007-01-31 18:31:19 +00:00
|
|
|
return d->mPixmapReady;
|
2007-01-24 15:06:45 +00:00
|
|
|
}
|
|
|
|
|
2007-01-31 18:31:19 +00:00
|
|
|
void Generator::generatePixmap( PixmapRequest *request )
|
2007-01-24 15:06:45 +00:00
|
|
|
{
|
2007-09-14 13:31:55 +00:00
|
|
|
Q_D( Generator );
|
2007-01-31 18:31:19 +00:00
|
|
|
d->mPixmapReady = false;
|
|
|
|
|
|
|
|
if ( hasFeature( Threaded ) )
|
|
|
|
{
|
2007-04-20 17:59:12 +00:00
|
|
|
d->pixmapGenerationThread()->startGeneration( request );
|
2007-01-31 21:10:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2007-03-11 12:05:48 +00:00
|
|
|
if ( hasFeature( TextExtraction ) && !request->page()->hasTextPage() && canGenerateTextPage() ) {
|
2007-01-31 21:10:00 +00:00
|
|
|
d->mTextPageReady = false;
|
2007-04-20 17:59:12 +00:00
|
|
|
d->textPageGenerationThread()->startGeneration( request->page() );
|
2007-01-31 21:10:00 +00:00
|
|
|
}
|
|
|
|
|
2007-01-31 18:31:19 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
request->page()->setPixmap( request->id(), new QPixmap( QPixmap::fromImage( image( request ) ) ) );
|
|
|
|
|
|
|
|
d->mPixmapReady = true;
|
|
|
|
|
2007-09-14 13:31:55 +00:00
|
|
|
signalPixmapRequestDone( request );
|
2007-01-24 15:06:45 +00:00
|
|
|
}
|
|
|
|
|
2007-01-31 18:31:19 +00:00
|
|
|
bool Generator::canGenerateTextPage() const
|
2007-01-24 18:27:54 +00:00
|
|
|
{
|
2007-09-14 13:31:55 +00:00
|
|
|
Q_D( const Generator );
|
2007-01-31 18:31:19 +00:00
|
|
|
return d->mTextPageReady;
|
2007-01-24 18:27:54 +00:00
|
|
|
}
|
|
|
|
|
2007-08-13 22:25:27 +00:00
|
|
|
void Generator::generateTextPage( Page *page )
|
2007-01-24 15:06:45 +00:00
|
|
|
{
|
2007-09-14 13:31:55 +00:00
|
|
|
Q_D( Generator );
|
2007-01-31 18:31:19 +00:00
|
|
|
page->setTextPage( textPage( page ) );
|
|
|
|
d->mTextPageReady = true;
|
2007-01-24 15:06:45 +00:00
|
|
|
}
|
|
|
|
|
2007-01-31 18:31:19 +00:00
|
|
|
QImage Generator::image( PixmapRequest * )
|
2007-01-24 18:27:54 +00:00
|
|
|
{
|
2007-01-31 18:31:19 +00:00
|
|
|
return QImage();
|
2007-01-24 18:27:54 +00:00
|
|
|
}
|
|
|
|
|
2007-01-31 18:31:19 +00:00
|
|
|
TextPage* Generator::textPage( Page* )
|
2006-10-20 16:51:46 +00:00
|
|
|
{
|
2007-01-31 18:31:19 +00:00
|
|
|
return 0;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const DocumentInfo * Generator::generateDocumentInfo()
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return 0;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const DocumentSynopsis * Generator::generateDocumentSynopsis()
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return 0;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
2007-07-07 20:35:01 +00:00
|
|
|
FontInfo::List Generator::fontsForPage( int )
|
2006-10-20 16:51:46 +00:00
|
|
|
{
|
2007-07-07 20:35:01 +00:00
|
|
|
return FontInfo::List();
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const QList<EmbeddedFile*> * Generator::embeddedFiles() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return 0;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Generator::PageSizeMetric Generator::pagesSizeMetric() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return None;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
2007-03-10 23:59:11 +00:00
|
|
|
bool Generator::isAllowed( Permission ) const
|
2006-10-20 16:51:46 +00:00
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return true;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
2007-01-05 17:09:47 +00:00
|
|
|
void Generator::rotationChanged( Rotation, Rotation )
|
2006-10-20 16:51:46 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-01-05 23:12:06 +00:00
|
|
|
PageSize::List Generator::pageSizes() const
|
2006-10-20 16:51:46 +00:00
|
|
|
{
|
2007-01-05 23:12:06 +00:00
|
|
|
return PageSize::List();
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
2007-01-05 23:12:06 +00:00
|
|
|
void Generator::pageSizeChanged( const PageSize &, const PageSize & )
|
2006-10-20 16:51:46 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-10-15 23:01:27 +00:00
|
|
|
bool Generator::print( QPrinter& )
|
2006-10-20 16:51:46 +00:00
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return false;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
2006-10-28 19:18:36 +00:00
|
|
|
QVariant Generator::metaData( const QString&, const QVariant& ) const
|
2006-10-20 16:51:46 +00:00
|
|
|
{
|
2006-10-28 19:18:36 +00:00
|
|
|
return QVariant();
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
2006-10-25 15:35:53 +00:00
|
|
|
ExportFormat::List Generator::exportFormats() const
|
2006-10-20 16:51:46 +00:00
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return ExportFormat::List();
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
2006-10-25 15:35:53 +00:00
|
|
|
bool Generator::exportTo( const QString&, const ExportFormat& )
|
2006-10-20 16:51:46 +00:00
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return false;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
2007-01-26 16:35:30 +00:00
|
|
|
bool Generator::hasFeature( GeneratorFeature feature ) const
|
2007-01-12 22:49:14 +00:00
|
|
|
{
|
2007-09-14 13:31:55 +00:00
|
|
|
Q_D( const Generator );
|
2007-01-26 16:35:30 +00:00
|
|
|
return d->m_features.contains( feature );
|
2007-01-12 22:49:14 +00:00
|
|
|
}
|
|
|
|
|
2007-01-29 08:17:45 +00:00
|
|
|
void Generator::signalPixmapRequestDone( PixmapRequest * request )
|
2006-10-20 16:51:46 +00:00
|
|
|
{
|
2007-09-14 13:31:55 +00:00
|
|
|
Q_D( Generator );
|
2006-10-25 17:43:15 +00:00
|
|
|
if ( d->m_document )
|
|
|
|
d->m_document->requestDone( request );
|
|
|
|
else
|
2007-01-29 08:17:45 +00:00
|
|
|
Q_ASSERT( !"No document set for generator in signalPixmapRequestDone!" );
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
2007-03-17 12:11:41 +00:00
|
|
|
const Document * Generator::document() const
|
2006-10-20 16:51:46 +00:00
|
|
|
{
|
2007-09-14 13:31:55 +00:00
|
|
|
Q_D( const Generator );
|
2007-09-14 15:29:16 +00:00
|
|
|
return d->m_document->m_parent;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
2007-01-26 16:35:30 +00:00
|
|
|
void Generator::setFeature( GeneratorFeature feature, bool on )
|
|
|
|
{
|
2007-09-14 13:31:55 +00:00
|
|
|
Q_D( Generator );
|
2007-01-26 16:35:30 +00:00
|
|
|
if ( on )
|
|
|
|
d->m_features.insert( feature );
|
|
|
|
else
|
|
|
|
d->m_features.remove( feature );
|
|
|
|
}
|
|
|
|
|
2007-09-14 22:16:00 +00:00
|
|
|
QVariant Generator::documentMetaData( const QString &key, const QVariant &option ) const
|
|
|
|
{
|
|
|
|
Q_D( const Generator );
|
|
|
|
if ( !d->m_document )
|
|
|
|
return QVariant();
|
|
|
|
|
|
|
|
return d->m_document->documentMetaData( key, option );
|
|
|
|
}
|
|
|
|
|
2007-09-15 11:35:53 +00:00
|
|
|
QMutex* Generator::userMutex() const
|
|
|
|
{
|
|
|
|
Q_D( const Generator );
|
|
|
|
if ( !d->m_mutex )
|
|
|
|
{
|
|
|
|
d->m_mutex = new QMutex();
|
|
|
|
}
|
|
|
|
return d->m_mutex;
|
|
|
|
}
|
|
|
|
|
2007-01-26 16:35:30 +00:00
|
|
|
|
2006-10-25 15:35:53 +00:00
|
|
|
PixmapRequest::PixmapRequest( int id, int pageNumber, int width, int height, int priority, bool asynchronous )
|
2007-09-30 21:44:31 +00:00
|
|
|
: d( new PixmapRequestPrivate )
|
2006-10-20 16:51:46 +00:00
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
d->mId = id;
|
|
|
|
d->mPageNumber = pageNumber;
|
|
|
|
d->mWidth = width;
|
|
|
|
d->mHeight = height;
|
|
|
|
d->mPriority = priority;
|
|
|
|
d->mAsynchronous = asynchronous;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
2006-10-25 15:35:53 +00:00
|
|
|
PixmapRequest::~PixmapRequest()
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
delete d;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int PixmapRequest::id() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return d->mId;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int PixmapRequest::pageNumber() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return d->mPageNumber;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int PixmapRequest::width() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return d->mWidth;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int PixmapRequest::height() const
|
2006-10-22 11:25:08 +00:00
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return d->mHeight;
|
2006-10-22 11:25:08 +00:00
|
|
|
}
|
|
|
|
|
2006-10-25 15:35:53 +00:00
|
|
|
int PixmapRequest::priority() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return d->mPriority;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool PixmapRequest::asynchronous() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return d->mAsynchronous;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Page* PixmapRequest::page() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return d->mPage;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
2007-12-04 21:36:32 +00:00
|
|
|
void PixmapRequestPrivate::swap()
|
2006-11-20 07:53:32 +00:00
|
|
|
{
|
2007-12-04 21:36:32 +00:00
|
|
|
qSwap( mWidth, mHeight );
|
2006-11-20 07:53:32 +00:00
|
|
|
}
|
|
|
|
|
2007-04-12 20:43:37 +00:00
|
|
|
class Okular::ExportFormatPrivate : public QSharedData
|
2006-10-25 15:35:53 +00:00
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
public:
|
2007-04-12 20:43:37 +00:00
|
|
|
ExportFormatPrivate( const QString &description, const KMimeType::Ptr &mimeType, const KIcon &icon = KIcon() )
|
|
|
|
: QSharedData(), mDescription( description ), mMimeType( mimeType ), mIcon( icon )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
~ExportFormatPrivate()
|
2006-10-25 17:43:15 +00:00
|
|
|
{
|
|
|
|
}
|
2006-10-25 15:35:53 +00:00
|
|
|
|
2006-10-25 17:43:15 +00:00
|
|
|
QString mDescription;
|
|
|
|
KMimeType::Ptr mMimeType;
|
|
|
|
KIcon mIcon;
|
2006-10-25 15:35:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ExportFormat::ExportFormat()
|
2007-04-12 20:43:37 +00:00
|
|
|
: d( new ExportFormatPrivate( QString(), KMimeType::Ptr() ) )
|
2006-10-25 15:35:53 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ExportFormat::ExportFormat( const QString &description, const KMimeType::Ptr &mimeType )
|
2007-04-12 20:43:37 +00:00
|
|
|
: d( new ExportFormatPrivate( description, mimeType ) )
|
2006-10-25 15:35:53 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ExportFormat::ExportFormat( const KIcon &icon, const QString &description, const KMimeType::Ptr &mimeType )
|
2007-04-12 20:43:37 +00:00
|
|
|
: d( new ExportFormatPrivate( description, mimeType, icon ) )
|
2006-10-25 15:35:53 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ExportFormat::~ExportFormat()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ExportFormat::ExportFormat( const ExportFormat &other )
|
2007-04-12 20:43:37 +00:00
|
|
|
: d( other.d )
|
2006-10-25 15:35:53 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ExportFormat& ExportFormat::operator=( const ExportFormat &other )
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
if ( this == &other )
|
|
|
|
return *this;
|
2006-10-25 15:35:53 +00:00
|
|
|
|
2007-04-12 20:43:37 +00:00
|
|
|
d = other.d;
|
2006-10-25 15:35:53 +00:00
|
|
|
|
2006-10-25 17:43:15 +00:00
|
|
|
return *this;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString ExportFormat::description() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return d->mDescription;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
KMimeType::Ptr ExportFormat::mimeType() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return d->mMimeType;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
KIcon ExportFormat::icon() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return d->mIcon;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
2006-10-22 11:25:08 +00:00
|
|
|
|
2007-03-10 20:51:50 +00:00
|
|
|
bool ExportFormat::isNull() const
|
|
|
|
{
|
|
|
|
return d->mMimeType.isNull() || d->mDescription.isNull();
|
|
|
|
}
|
|
|
|
|
2007-04-21 11:09:41 +00:00
|
|
|
ExportFormat ExportFormat::standardFormat( StandardExportFormat type )
|
2007-03-10 21:32:09 +00:00
|
|
|
{
|
2007-04-21 11:09:41 +00:00
|
|
|
switch ( type )
|
|
|
|
{
|
|
|
|
case PlainText:
|
|
|
|
return ExportFormat( KIcon( "text" ), i18n( "Plain &Text..." ), KMimeType::mimeType( "text/plain" ) );
|
|
|
|
break;
|
|
|
|
case PDF:
|
2007-11-25 14:48:54 +00:00
|
|
|
return ExportFormat( KIcon( "application-pdf" ), i18n( "PDF" ), KMimeType::mimeType( "application/pdf" ) );
|
2007-04-21 11:09:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ExportFormat();
|
2007-03-10 21:32:09 +00:00
|
|
|
}
|
|
|
|
|
2007-04-12 20:43:37 +00:00
|
|
|
bool ExportFormat::operator==( const ExportFormat &other ) const
|
|
|
|
{
|
|
|
|
return d == other.d;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ExportFormat::operator!=( const ExportFormat &other ) const
|
|
|
|
{
|
|
|
|
return d != other.d;
|
|
|
|
}
|
|
|
|
|
2007-07-30 23:58:04 +00:00
|
|
|
QDebug operator<<( QDebug str, const Okular::PixmapRequest &req )
|
2005-11-20 15:30:15 +00:00
|
|
|
{
|
2006-10-22 13:34:47 +00:00
|
|
|
QString s = QString( "%1 PixmapRequest (id: %2) (%3x%4), prio %5, pageNo %6" )
|
2006-10-25 15:35:53 +00:00
|
|
|
.arg( QString( req.asynchronous() ? "Async" : "Sync" ) )
|
|
|
|
.arg( req.id() )
|
|
|
|
.arg( req.width() )
|
|
|
|
.arg( req.height() )
|
|
|
|
.arg( req.priority() )
|
|
|
|
.arg( req.pageNumber() );
|
2007-11-04 23:33:05 +00:00
|
|
|
str << qPrintable( s );
|
2006-10-22 13:34:47 +00:00
|
|
|
return str;
|
2005-11-20 15:30:15 +00:00
|
|
|
}
|
2006-06-10 12:59:09 +00:00
|
|
|
|
|
|
|
#include "generator.moc"
|