mirror of
https://invent.kde.org/graphics/okular
synced 2024-11-05 18:34:53 +00:00
34b8e28322
- Page: rotation does not switch height and width - Document/Part/Generator: 1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel also add possibility to merge an XML .rc file with menu layout. Relevant functions are: QString Generator::getXMLFile(), returns a QString with your .rc file name. void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface 2. Supporting backend settings: If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings] set to true) are found, a menu item: configure backends is created, clicking on it results in loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg) function should be overloaded by a generator and dlg->addPage should be used to add pages. If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another. 3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration) to the generator class, and sending a message to the user is as simple as emitting a signal! 4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your event and return true if pageview is to proceed with its handling or false if not. 5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your Generator::print() 6. PixmapRequest handling update: a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async) b.) Document::sendGeneratorRequests is a slot now c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving) is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is run in three places: 1. in requestPixmaps when we receive a request 2. in requestDone if pixmapStack is not empty 3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async) it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request 7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime - TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks. svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
154 lines
6.1 KiB
C++
154 lines
6.1 KiB
C++
/***************************************************************************
|
|
* Copyright (C) 2004 by Enrico Ros <eros.kde@email.it> *
|
|
* Copyright (C) 2004 by Albert Astals Cid <tsdgeos@terra.es> *
|
|
* *
|
|
* With portions of code from kpdf/kpdf_pagewidget.h by: *
|
|
* Copyright (C) 2002 by Wilco Greven <greven@kde.org> *
|
|
* Copyright (C) 2003 by Christophe Devriese *
|
|
* <Christophe.Devriese@student.kuleuven.ac.be> *
|
|
* Copyright (C) 2003 by Laurent Montel <montel@kde.org> *
|
|
* Copyright (C) 2003 by Kurt Pfeifle <kpfeifle@danka.de> *
|
|
* *
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
* (at your option) any later version. *
|
|
***************************************************************************/
|
|
// This file follows coding style described in kdebase/kicker/HACKING
|
|
|
|
#ifndef _KPDF_PAGEVIEW_H_
|
|
#define _KPDF_PAGEVIEW_H_
|
|
|
|
#include <qscrollview.h>
|
|
#include <qvaluevector.h>
|
|
#include "ui/pageviewutils.h"
|
|
#include "core/observer.h"
|
|
|
|
class KURL;
|
|
class KActionCollection;
|
|
|
|
class KPDFDocument;
|
|
class PageViewPrivate;
|
|
|
|
/**
|
|
* @short The main view. Handles zoom and continuous mode.. oh, and page
|
|
* @short display of course :-)
|
|
* ...
|
|
*/
|
|
class PageView : public QScrollView, public DocumentObserver
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
PageView( QWidget *parent, KPDFDocument *document );
|
|
~PageView();
|
|
|
|
// Zoom mode ( last 4 are internally used only! )
|
|
enum ZoomMode { ZoomFixed = 0, ZoomFitWidth = 1, ZoomFitPage = 2, ZoomFitText,
|
|
ZoomIn, ZoomOut, ZoomRefreshCurrent };
|
|
enum MouseMode { MouseNormal, MouseZoom, MouseSelect };
|
|
|
|
// create actions that interact with this widget
|
|
void setupActions( KActionCollection * collection );
|
|
|
|
// misc methods (from RMB menu/children)
|
|
bool canFitPageWidth();
|
|
void fitPageWidth( int page );
|
|
// keep in sync with pageviewutils
|
|
void displayMessage( const QString & message , PageViewMessage::Icon icon=PageViewMessage::Info, int duration=-1 );
|
|
|
|
// inherited from DocumentObserver
|
|
uint observerId() const { return PAGEVIEW_ID; }
|
|
void notifySetup( const QValueVector< KPDFPage * > & pages, bool documentChanged );
|
|
void notifyViewportChanged( bool smoothMove );
|
|
void notifyPageChanged( int pageNumber, int changedFlags );
|
|
void notifyContentsCleared( int changedFlags );
|
|
bool canUnloadPixmap( int pageNum );
|
|
|
|
public slots:
|
|
void errorMessage( QString &message,int duration )
|
|
{
|
|
displayMessage( message, PageViewMessage::Error, duration );
|
|
}
|
|
|
|
void noticeMessage( QString & message,int duration )
|
|
{
|
|
displayMessage( message, PageViewMessage::Info, duration );
|
|
}
|
|
|
|
void warningMessage( QString & message,int duration )
|
|
{
|
|
displayMessage( message, PageViewMessage::Warning, duration );
|
|
}
|
|
|
|
signals:
|
|
void urlDropped( const KURL& );
|
|
void rightClick( const KPDFPage *, const QPoint & );
|
|
|
|
protected:
|
|
// viewport events
|
|
void viewportPaintEvent( QPaintEvent * pe );
|
|
void viewportResizeEvent( QResizeEvent* );
|
|
|
|
// mouse / keyboard events
|
|
void keyPressEvent( QKeyEvent* );
|
|
void contentsMouseMoveEvent( QMouseEvent* );
|
|
void contentsMousePressEvent( QMouseEvent* );
|
|
void contentsMouseReleaseEvent( QMouseEvent* );
|
|
void wheelEvent( QWheelEvent* );
|
|
|
|
// drag and drop related events
|
|
void dragEnterEvent( QDragEnterEvent* );
|
|
void dropEvent( QDropEvent* );
|
|
|
|
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
|
|
void updateItemSize( PageViewItem * item, int columnWidth, int rowHeight );
|
|
// return the widget placed on a certain point or 0 if clicking on empty space
|
|
PageViewItem * pickItemOnPoint( int x, int y );
|
|
// start / modify / clear selection rectangle
|
|
void selectionStart( int x, int y, const QColor & color, bool aboveAll = false );
|
|
void selectionEndPoint( int x, int y );
|
|
void selectionClear();
|
|
// update internal zoom values and end in a slotRelayoutPages();
|
|
void updateZoom( ZoomMode newZm );
|
|
// update the text on the label using global zoom value or current page's one
|
|
void updateZoomText();
|
|
// updates cursor
|
|
void updateCursor( const QPoint &p );
|
|
|
|
// don't want to expose classes in here
|
|
class PageViewPrivate * d;
|
|
|
|
private slots:
|
|
// activated either directly or via QTimer on the viewportResizeEvent
|
|
void slotRelayoutPages();
|
|
// activated either directly or via the contentsMoving(int,int) signal
|
|
void slotRequestVisiblePixmaps( int left = -1, int top = -1 );
|
|
// activated by the viewport move timer
|
|
void slotMoveViewport();
|
|
// activated by the autoscroll timer (Shift+Up/Down keys)
|
|
void slotAutoScoll();
|
|
// type-ahead find timeout
|
|
void slotStopFindAhead();
|
|
|
|
// connected to local actions (toolbar, menu, ..)
|
|
void slotZoom();
|
|
void slotZoomIn();
|
|
void slotZoomOut();
|
|
void slotFitToWidthToggled( bool );
|
|
void slotFitToPageToggled( bool );
|
|
void slotFitToTextToggled( bool );
|
|
void slotTwoPagesToggled( bool );
|
|
void slotContinuousToggled( bool );
|
|
void slotSetMouseNormal();
|
|
void slotSetMouseZoom();
|
|
void slotSetMouseSelect();
|
|
void slotToggleAnnotator( bool );
|
|
void slotScrollUp();
|
|
void slotScrollDown();
|
|
};
|
|
|
|
#endif
|