Commit 61475abe authored by Pino Toscano's avatar Pino Toscano

Convert the PageView from a QScrollArea + inner QWidget to a QAbstractScrollArea.

- added few utility functions to compensate the miss of a "central scrolled widget", as now we just fully handle (events & painting) the viewport of the scroll area
- manually scroll the overlay widgets (form widgets and video widgets) when the "area" is scrolled
All the page view functionalities should be working as usual, hopefully I should have ported everything (in case it will be fixed later).
Given that now the size page view is no more constrained by the maximum size of a QWidget (which is two orders of magnitude less than the size of an int), we can handle documents with really many pages (10k+) with hopefully no issues.
BUG: 191859
As a side effect of the QScrollArea -> QAbstractScrollArea porting, it seems that there are no more drawing glitches when in right-to-left mode.
BUG: 192636

svn path=/trunk/KDE/kdegraphics/okular/; revision=989285
parent 3f77a20d
......@@ -968,7 +968,7 @@ bool Part::openFile()
if ( !ok )
{
// if can't open document, update windows so they display blank contents
m_pageView->widget()->update();
m_pageView->viewport()->update();
m_thumbnailList->update();
return false;
}
......
This diff is collapsed.
......@@ -19,7 +19,7 @@
#ifndef _OKULAR_PAGEVIEW_H_
#define _OKULAR_PAGEVIEW_H_
#include <qscrollarea.h>
#include <qabstractscrollarea.h>
#include <qlist.h>
#include <qvector.h>
#include "ui/pageviewutils.h"
......@@ -39,19 +39,16 @@ class Annotation;
class FormWidgetIface;
class PageViewPrivate;
class PageViewWidget;
/**
* @short The main view. Handles zoom and continuous mode.. oh, and page
* @short display of course :-)
* ...
*/
class PageView : public QScrollArea, public Okular::DocumentObserver, public Okular::View
class PageView : public QAbstractScrollArea, public Okular::DocumentObserver, public Okular::View
{
Q_OBJECT
friend class PageViewWidget;
public:
PageView( QWidget *parent, Okular::Document *document );
~PageView();
......@@ -94,6 +91,11 @@ Q_OBJECT
KAction *toggleFormsAction() const;
int contentAreaWidth() const;
int contentAreaHeight() const;
QPoint contentAreaPosition() const;
QPoint contentAreaPoint( const QPoint & pos ) const;
public slots:
void errorMessage( const QString & message, int duration = -1 )
{
......@@ -135,12 +137,14 @@ Q_OBJECT
void dragMoveEvent( QDragMoveEvent* );
void dropEvent( QDropEvent* );
private:
void contentsPaintEvent( QPaintEvent *e );
void contentsMouseMoveEvent( QMouseEvent *e );
void contentsMousePressEvent( QMouseEvent *e );
void contentsMouseReleaseEvent( QMouseEvent *e );
void paintEvent( QPaintEvent *e );
void mouseMoveEvent( QMouseEvent *e );
void mousePressEvent( QMouseEvent *e );
void mouseReleaseEvent( QMouseEvent *e );
bool viewportEvent( QEvent *e );
private:
// draw background and items on the opened qpainter
void drawDocumentOnPainter( const QRect & pageViewRect, QPainter * p );
// update item width and height using current zoom parameters
......@@ -166,6 +170,8 @@ Q_OBJECT
void toggleFormWidgets( bool on );
void resizeContentArea( const QSize & newSize );
// don't want to expose classes in here
class PageViewPrivate * d;
......
......@@ -748,8 +748,9 @@ QRect PageViewAnnotator::routeEvent( QMouseEvent * e, PageViewItem * item )
// find out normalized mouse coords inside current item
const QRect & itemRect = item->uncroppedGeometry();
double nX = item->absToPageX(e->x());
double nY = item->absToPageY(e->y());
const QPoint eventPos = m_pageView->contentAreaPoint( e->pos() );
double nX = item->absToPageX( eventPos.x() );
double nY = item->absToPageY( eventPos.y() );
QRect modifiedRect;
......@@ -774,8 +775,9 @@ QRect PageViewAnnotator::routeEvent( QMouseEvent * e, PageViewItem * item )
m_lastDrawnRect.translate( itemRect.left(), itemRect.top() );
// 3.2. decompose paint region in rects and send paint events
QVector<QRect> rects = compoundRegion.unite( m_lastDrawnRect ).rects();
const QPoint areaPos = m_pageView->contentAreaPosition();
for ( int i = 0; i < rects.count(); i++ )
m_pageView->widget()->update( rects[i] );
m_pageView->viewport()->update( rects[i].translated( -areaPos ) );
modifiedRect = compoundRegion.boundingRect() | m_lastDrawnRect;
}
......@@ -857,7 +859,7 @@ void PageViewAnnotator::slotToolSelected( int toolID )
m_lockedItem = 0;
if ( m_lastDrawnRect.isValid() )
{
m_pageView->widget()->update( m_lastDrawnRect );
m_pageView->viewport()->update( m_lastDrawnRect.translated( -m_pageView->contentAreaPosition() ) );
m_lastDrawnRect = QRect();
}
......
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