From 6ba8113c1df33df825d7b78c0aed173526ce43fb Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Wed, 29 Nov 2006 21:49:20 +0000 Subject: [PATCH] Preload next and previous page if threading is enabled and not on low memory setting BUGS: 132029 svn path=/branches/KDE/3.5/kdegraphics/kpdf/; revision=609253 --- core/observer.h | 5 +++-- ui/presentationwidget.cpp | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/core/observer.h b/core/observer.h index fabe4ff7d..28f07bf55 100644 --- a/core/observer.h +++ b/core/observer.h @@ -24,10 +24,11 @@ /** PRIORITIES for requests. Globally defined here. **/ #define PAGEVIEW_PRIO 1 -#define PAGEVIEW_PRELOAD_PRIO 3 +#define PAGEVIEW_PRELOAD_PRIO 4 #define THUMBNAILS_PRIO 2 -#define THUMBNAILS_PRELOAD_PRIO 4 +#define THUMBNAILS_PRELOAD_PRIO 5 #define PRESENTATION_PRIO 0 +#define PRESENTATION_PRELOAD_PRIO 3 class KPDFPage; diff --git a/ui/presentationwidget.cpp b/ui/presentationwidget.cpp index f181b2a38..452bc1d12 100644 --- a/ui/presentationwidget.cpp +++ b/ui/presentationwidget.cpp @@ -448,6 +448,27 @@ void PresentationWidget::changePage( int newPage ) m_document->requestPixmaps( request ); // restore cursor QApplication::restoreOverrideCursor(); + // ask for next and previous page if not in low memory usage setting + if (KpdfSettings::memoryLevel() != KpdfSettings::EnumMemoryLevel::Low && KpdfSettings::enableThreading()) { + QValueList< PixmapRequest * > asyncRequests; + if (newPage + 1 < (int)m_document->pages()) + { + PresentationFrame *nextFrame = m_frames[ newPage + 1 ]; + pixW = nextFrame->geometry.width(); + pixH = nextFrame->geometry.height(); + if ( !nextFrame->page->hasPixmap( PRESENTATION_ID, pixW, pixH ) ) + asyncRequests.push_back( new PixmapRequest( PRESENTATION_ID, newPage + 1, pixW, pixH, PRESENTATION_PRELOAD_PRIO, true ) ); + } + if (newPage - 1 >= 0) + { + PresentationFrame *prevFrame = m_frames[ newPage - 1 ]; + pixW = prevFrame->geometry.width(); + pixH = prevFrame->geometry.height(); + if ( !prevFrame->page->hasPixmap( PRESENTATION_ID, pixW, pixH ) ) + asyncRequests.push_back( new PixmapRequest( PRESENTATION_ID, newPage - 1, pixW, pixH, PRESENTATION_PRELOAD_PRIO, true ) ); + } + if (!asyncRequests.isEmpty()) m_document->requestPixmaps( asyncRequests ); + } } else {