Commit 38618919 authored by Enrico Ros's avatar Enrico Ros
Browse files

small updates.

svn path=/branches/kpdf_experiments/kdegraphics/kpdf/; revision=346044
parent 99781606
......@@ -7,10 +7,11 @@
* (at your option) any later version. *
***************************************************************************/
// qt includes
// qt/kde includes
#include <qfile.h>
#include <qmutex.h>
#include <qvaluevector.h>
#include <kdebug.h>
// local includes
#include "PDFDoc.h"
......@@ -38,7 +39,7 @@ public:
int currentPage;
float currentPosition;
QValueVector< KPDFPage* > pages;
// observers related (note: won't delete oservers)
QValueList< KPDFDocumentObserver* > observers;
};
......@@ -61,7 +62,7 @@ KPDFDocument::KPDFDocument()
paperColor.rgb8 = splashMakeRGB8( 0xff, 0xff, 0xff );
d->splashOutputDevice = new QOutputDev( paperColor );
}
KPDFDocument::~KPDFDocument()
{
close();
......@@ -106,7 +107,7 @@ bool KPDFDocument::openFile( const QString & docFile )
sendFilteredPageList();
slotSetCurrentPage( 0 );
}
return true;
}
......@@ -267,7 +268,10 @@ void KPDFDocument::requestPixmap( uint page, int width, int height, bool syn )
// it may happen (in fact it doesn't) that we need rescaling
if ( d->splashOutputDevice->getImage().size() != QSize( width, height ) )
{
kdWarning() << "Pixmap for page '" << page << "' needed rescale." << endl;
kp->setPixmap( d->splashOutputDevice->getImage().smoothScale( width, height ) );
}
else
kp->setPixmap( d->splashOutputDevice->getImage() );
......@@ -286,7 +290,7 @@ void KPDFDocument::requestThumbnail( uint page, int width, int height, bool syn
if ( !d->pdfdoc || !kp || kp->width() < 1 || kp->height() < 1 )
return;
if ( /*syn*/ TRUE )
if ( syn )
{
// in-place Thumbnail generation for syncronous requests
if ( !kp->hasThumbnail( width, height ) )
......@@ -300,7 +304,10 @@ void KPDFDocument::requestThumbnail( uint page, int width, int height, bool syn
// it may happen (in fact it doesn't) that we need rescaling
if ( d->splashOutputDevice->getImage().size() != QSize( width, height ) )
{
kdWarning() << "Thumbnail for page '" << page << "' needed rescale." << endl;
kp->setThumbnail( d->splashOutputDevice->getImage().smoothScale( width, height ) );
}
else
kp->setThumbnail( d->splashOutputDevice->getImage() );
......
......@@ -41,12 +41,22 @@ KPDFPage::~KPDFPage()
}
//BEGIN drawing functions
void KPDFPage::drawPixmap( QPainter * p, const QRect & limits, int /*width*/, int /*height*/ ) const
{// ###
// drawing functions draw the pixmap directly if it has the right size, or
// else set a scale matrix to the painter and paint a quick 'zoomed' pixmap
void KPDFPage::drawPixmap( QPainter * p, const QRect & limits, int width, int height ) const
{
if ( m_pixmap )
p->drawPixmap( limits.topLeft(), *m_pixmap, limits );
{
//if ( m_pixmap->width() == width && m_pixmap->height() == height )
p->drawPixmap( limits.topLeft(), *m_pixmap, limits );
//else
//{
// p->scale( width / (double)m_pixmap->width(), height / (double)m_pixmap->height() );
// p->drawPixmap( 0,0, *m_pixmap, 0,0, m_pixmap->width(), m_pixmap->height() );
//}
}
else
p->fillRect( limits, Qt::blue );
p->fillRect( limits, Qt::white /*FIXME change to the page bg color*/ );
}
void KPDFPage::drawThumbnail( QPainter * p, const QRect & limits, int width, int height ) const // OK
......
......@@ -28,7 +28,7 @@ public:
int pageNumber() const;
int previewWidth() const;
int previewHeight() const;
protected:
void paintEvent(QPaintEvent *);
......
......@@ -243,7 +243,7 @@ void ThumbnailList::slotRequestThumbnails( int /*newContentsX*/, int newContents
if ( top > vHeight )
break;
else if ( top + t->height() > 0 )
m_document->requestThumbnail( t->pageNumber(), t->previewWidth(), t->previewHeight() );
m_document->requestThumbnail( t->pageNumber(), t->previewWidth(), t->previewHeight(), true );
}
}
//END internal SLOTS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment