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

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
parent ff3216cc
......@@ -20,6 +20,7 @@ More items (first items will enter 'In progress list' first):
-> implement history (mainly for actionNamed)
-> history as a toolbox child (collecting DOs's setPage calls)
-> zoom: fit text (with configurable margin)
-> autodetect "/dev/speech" and provide {document/page/selection} -> reading
-> automatic online dictionaries / translators (BR80338)
-> add OCR for building TextPages out of pure graphical (aka scanned) pages
-> 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))
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
-> use a KConfigXT settings framework
-> reading aids (accessibility): paper color: select, mode: normal, invert, contrast, recolor bg/text, enhance: links, ...
-> pageview: fix keys/mouse in single/continous modes
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)
-> FIX: sheet rotation in landscape case
-> 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)
Here comes a list of suggestions from a dot post http://dot.kde.org/1095261317 and IRC:
Tool: ruler
Tool: distance measure
Tool: ruler, measure: distance, perimeter, ?area?
Tool: color picker
Annotations: yellow notes 'post-it' like
Speak: integration with a voice synthesizer
......
......@@ -11,17 +11,25 @@
#include <qpainter.h>
#include <qsize.h>
#include <kglobalsettings.h>
#include <kdebug.h>
#include "pixmapwidget.h"
#include "document.h"
#include "page.h"
/** PixmapWidget TODO: check image rotation for aspect ratio (and implement rotation) **/
PixmapWidget::PixmapWidget( QWidget * parent, const KPDFPage * kp )
: QWidget( parent, 0, WNoAutoErase ), m_page( kp ),
m_marginLeft(0), m_marginTop(0), m_marginRight(0), m_marginBottom(0),
m_pixmapWidth(0), m_pixmapHeight(0), m_zoomFactor( 1.0 )
// TODO : REMOVE "#ifndef NDEBUG" stuff before merging to HEAD! (added 20041024)
PixmapWidget::PixmapWidget( QWidget * parent, const KPDFPage * kp, const char * name )
/* Note on PixmapWidget Wflags (Enrico):
It's SO IMPORTANT to set WNoAutoErase and WStaticContents.
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
{
#ifndef NDEBUG
return m_marginLeft + pixmapWidth() + m_marginRight;
#else
return m_marginLeft + m_pixmapWidth + m_marginRight;
#endif
}
int PixmapWidget::heightHint() const
{
#ifndef NDEBUG
return m_marginTop + pixmapHeight() + m_marginBottom;
#else
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
......@@ -131,7 +175,7 @@ void ThumbnailWidget::paintEvent( QPaintEvent * e )
/** PageWidget **/
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
setPixmapMargins( 1, 1, 4, 4 );
......@@ -178,6 +222,13 @@ void PageWidget::paintEvent( QPaintEvent * e )
{
QRect clip = e->rect();
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 );
// if drawn region includes an edge of the page
......
......@@ -23,7 +23,7 @@ class KPDFPage;
class PixmapWidget : public QWidget
{
public:
PixmapWidget( QWidget * parent, const KPDFPage * page );
PixmapWidget( QWidget * parent, const KPDFPage * page, const char * name = 0 );
// internal size/placements evaluators
void setZoomFixed( double magFactor = 1.0 );
......@@ -34,8 +34,8 @@ public:
// full size (for resizing) and inner pixmap size
int widthHint() const;
int heightHint() const;
int pixmapWidth() const { return m_pixmapWidth; }
int pixmapHeight() const { return m_pixmapHeight; }
int pixmapWidth() const;
int pixmapHeight() const;
// other queries
int pageNumber() const;
......
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