1) Dealing with the QScrollView (introduced for continous navigation) is a

real PITA. Tons of unneeded repaints are casted everywhere, even when
hiding or covering widgets.
Here we fix a big-bad-bug that repainted all the already viewed pages on
a zoom operation. That means that if zooming on a page after viewing 150
pages, then *at least* 150 pages got repainted :-(.
Tried to disable clipper(), but got weird results.
2) Adding devel only debug code to check for a possible bug Aaron told me,
but I actually wasn't unable to reproduce.

svn path=/branches/kpdf_experiments/kdegraphics/kpdf/; revision=357273
This commit is contained in:
Enrico Ros 2004-10-24 09:17:24 +00:00
parent ff3216ccde
commit f8dfcf3289
3 changed files with 64 additions and 12 deletions

View file

@ -20,6 +20,7 @@ More items (first items will enter 'In progress list' first):
-> implement history (mainly for actionNamed) -> implement history (mainly for actionNamed)
-> history as a toolbox child (collecting DOs's setPage calls) -> history as a toolbox child (collecting DOs's setPage calls)
-> zoom: fit text (with configurable margin) -> zoom: fit text (with configurable margin)
-> autodetect "/dev/speech" and provide {document/page/selection} -> reading
-> automatic online dictionaries / translators (BR80338) -> automatic online dictionaries / translators (BR80338)
-> add OCR for building TextPages out of pure graphical (aka scanned) pages -> add OCR for building TextPages out of pure graphical (aka scanned) pages
-> merge head copyright headers (by albert) -> merge head copyright headers (by albert)
@ -28,13 +29,14 @@ More items (first items will enter 'In progress list' first):
-> wrong zoom buttons order (BR74248) (check consistancy with kdvi/kghostview/.. (not konq)) -> wrong zoom buttons order (BR74248) (check consistancy with kdvi/kghostview/.. (not konq))
Porting / In progress on the branch (first item comes first): Porting / In progress on the branch (first item comes first):
-> click over image allows "save image" (and display rect around image too) -> ADD: click over image allows "save image" (and display rect around image too)
-> ADD: viewport changes the right way when clicking links -> ADD: viewport changes the right way when clicking links
-> use a KConfigXT settings framework -> use a KConfigXT settings framework
-> reading aids (accessibility): paper color: select, mode: normal, invert, contrast, recolor bg/text, enhance: links, ... -> reading aids (accessibility): paper color: select, mode: normal, invert, contrast, recolor bg/text, enhance: links, ...
-> pageview: fix keys/mouse in single/continous modes -> pageview: fix keys/mouse in single/continous modes
Done (newest feature comes firts): Done (newest feature comes firts):
-> FIX: workaround for scrollview bug 1/2 (painting hidden widgets under certain circumstances)
-> ADD: zoom into a rect defined by mouse (aka zoom to window) -> ADD: zoom into a rect defined by mouse (aka zoom to window)
-> FIX: sheet rotation in landscape case -> FIX: sheet rotation in landscape case
-> ADD: Some dcop functions (goToPage, openDocument and give # of pages) (Albert) -> ADD: Some dcop functions (goToPage, openDocument and give # of pages) (Albert)
@ -63,8 +65,7 @@ Done (newest feature comes firts):
-> MRG: merge lots of kpdf_part and part (centralview) code (to simplify/clenup) -> MRG: merge lots of kpdf_part and part (centralview) code (to simplify/clenup)
Here comes a list of suggestions from a dot post http://dot.kde.org/1095261317 and IRC: Here comes a list of suggestions from a dot post http://dot.kde.org/1095261317 and IRC:
Tool: ruler Tool: ruler, measure: distance, perimeter, ?area?
Tool: distance measure
Tool: color picker Tool: color picker
Annotations: yellow notes 'post-it' like Annotations: yellow notes 'post-it' like
Speak: integration with a voice synthesizer Speak: integration with a voice synthesizer

View file

@ -11,17 +11,25 @@
#include <qpainter.h> #include <qpainter.h>
#include <qsize.h> #include <qsize.h>
#include <kglobalsettings.h> #include <kglobalsettings.h>
#include <kdebug.h>
#include "pixmapwidget.h" #include "pixmapwidget.h"
#include "document.h" #include "document.h"
#include "page.h" #include "page.h"
/** PixmapWidget TODO: check image rotation for aspect ratio (and implement rotation) **/ // TODO : REMOVE "#ifndef NDEBUG" stuff before merging to HEAD! (added 20041024)
PixmapWidget::PixmapWidget( QWidget * parent, const KPDFPage * kp ) PixmapWidget::PixmapWidget( QWidget * parent, const KPDFPage * kp, const char * name )
: QWidget( parent, 0, WNoAutoErase ), m_page( kp ), /* Note on PixmapWidget Wflags (Enrico):
m_marginLeft(0), m_marginTop(0), m_marginRight(0), m_marginBottom(0), It's SO IMPORTANT to set WNoAutoErase and WStaticContents.
m_pixmapWidth(0), m_pixmapHeight(0), m_zoomFactor( 1.0 ) If not, already exposed widgets will receive a paint event when resized
(for example when zooming/relayouting in PageView) even if not shown in
current PageView's viewport.
*/
: QWidget( parent, name, WNoAutoErase | WStaticContents ), m_page( kp ),
m_marginLeft( 0 ), m_marginTop( 0 ), m_marginRight( 0 ), m_marginBottom( 0 ),
m_pixmapWidth( -1 ), m_pixmapHeight( -1 ),
m_zoomFactor( 1.0 )
{ {
} }
@ -51,12 +59,48 @@ void PixmapWidget::setZoomFitRect( int rectWidth, int rectHeight )
int PixmapWidget::widthHint() const int PixmapWidget::widthHint() const
{ {
#ifndef NDEBUG
return m_marginLeft + pixmapWidth() + m_marginRight;
#else
return m_marginLeft + m_pixmapWidth + m_marginRight; return m_marginLeft + m_pixmapWidth + m_marginRight;
#endif
} }
int PixmapWidget::heightHint() const int PixmapWidget::heightHint() const
{ {
#ifndef NDEBUG
return m_marginTop + pixmapHeight() + m_marginBottom;
#else
return m_marginTop + m_pixmapHeight + m_marginBottom; return m_marginTop + m_pixmapHeight + m_marginBottom;
#endif
}
int PixmapWidget::pixmapWidth() const
{
#ifndef NDEBUG
// code enabled for dev/testers only. please make sure that setZoom*
// gets called
if ( m_pixmapWidth < 0 )
{
kdDebug() << "No pixmapWidth set for page " << m_page->number() << " !" << endl;
return 1;
}
#endif
return m_pixmapWidth;
}
int PixmapWidget::pixmapHeight() const
{
#ifndef NDEBUG
// code enabled for dev/testers only. please make sure that setZoom*
// gets called
if ( m_pixmapHeight < 0 )
{
kdDebug() << "No pixmapHeight set for page " << m_page->number() << " !" << endl;
return 1;
}
#endif
return m_pixmapHeight;
} }
int PixmapWidget::pageNumber() const int PixmapWidget::pageNumber() const
@ -131,7 +175,7 @@ void ThumbnailWidget::paintEvent( QPaintEvent * e )
/** PageWidget **/ /** PageWidget **/
PageWidget::PageWidget( QWidget *parent, const KPDFPage *page ) PageWidget::PageWidget( QWidget *parent, const KPDFPage *page )
: PixmapWidget( parent, page ), m_selBeginX( -1 ), m_selBeginY( -1 ) : PixmapWidget( parent, page, "pageWidget" ), m_selBeginX( -1 ), m_selBeginY( -1 )
{ {
// keep bottom equal to right margin // keep bottom equal to right margin
setPixmapMargins( 1, 1, 4, 4 ); setPixmapMargins( 1, 1, 4, 4 );
@ -178,6 +222,13 @@ void PageWidget::paintEvent( QPaintEvent * e )
{ {
QRect clip = e->rect(); QRect clip = e->rect();
QRect pageClip = clip.intersect( QRect( m_marginLeft, m_marginTop, m_pixmapWidth, m_pixmapHeight ) ); QRect pageClip = clip.intersect( QRect( m_marginLeft, m_marginTop, m_pixmapWidth, m_pixmapHeight ) );
// FIXME: this prevents outline-only paints (but saves pixmap repaints!!)
if ( !pageClip.isValid() || pageClip.width() < 1 || pageClip.height() < 1 )
return;
// kdDebug() << "repaint on page " << pageNumber() << " on rect: " << pageClip << endl;
QPainter p( this ); QPainter p( this );
// if drawn region includes an edge of the page // if drawn region includes an edge of the page

View file

@ -23,7 +23,7 @@ class KPDFPage;
class PixmapWidget : public QWidget class PixmapWidget : public QWidget
{ {
public: public:
PixmapWidget( QWidget * parent, const KPDFPage * page ); PixmapWidget( QWidget * parent, const KPDFPage * page, const char * name = 0 );
// internal size/placements evaluators // internal size/placements evaluators
void setZoomFixed( double magFactor = 1.0 ); void setZoomFixed( double magFactor = 1.0 );
@ -34,8 +34,8 @@ public:
// full size (for resizing) and inner pixmap size // full size (for resizing) and inner pixmap size
int widthHint() const; int widthHint() const;
int heightHint() const; int heightHint() const;
int pixmapWidth() const { return m_pixmapWidth; } int pixmapWidth() const;
int pixmapHeight() const { return m_pixmapHeight; } int pixmapHeight() const;
// other queries // other queries
int pageNumber() const; int pageNumber() const;