2004-09-26 23:39:39 +00:00
|
|
|
/***************************************************************************
|
2005-02-18 18:24:45 +00:00
|
|
|
* Copyright (C) 2004-2005 by Enrico Ros <eros.kde@email.it> *
|
2006-02-18 12:06:52 +00:00
|
|
|
* Copyright (C) 2004-2006 by Albert Astals Cid <tsdgeos@terra.es> *
|
2004-09-27 21:36:25 +00:00
|
|
|
* *
|
2005-01-02 14:29:37 +00:00
|
|
|
* With portions of code from kpdf/kpdf_pagewidget.cc by: *
|
2004-09-27 21:36:25 +00:00
|
|
|
* 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 Dirk Mueller <mueller@kde.org> *
|
|
|
|
* Copyright (C) 2004 by James Ots <kde@jamesots.com> *
|
2004-09-26 23:39:39 +00:00
|
|
|
* *
|
|
|
|
* 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. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
2007-04-19 18:30:20 +00:00
|
|
|
#include "pageview.h"
|
|
|
|
|
2005-01-02 14:55:14 +00:00
|
|
|
// qt/kde includes
|
2005-01-01 21:50:34 +00:00
|
|
|
#include <qcursor.h>
|
2006-03-24 20:40:02 +00:00
|
|
|
#include <qevent.h>
|
2006-10-17 21:26:43 +00:00
|
|
|
#include <qimage.h>
|
2004-09-26 23:39:39 +00:00
|
|
|
#include <qpainter.h>
|
|
|
|
#include <qtimer.h>
|
2006-09-26 22:22:01 +00:00
|
|
|
#include <qset.h>
|
2006-10-07 14:40:32 +00:00
|
|
|
#include <qscrollbar.h>
|
2006-09-27 10:28:03 +00:00
|
|
|
#include <qtooltip.h>
|
2004-10-14 20:21:59 +00:00
|
|
|
#include <qapplication.h>
|
|
|
|
#include <qclipboard.h>
|
2007-05-06 15:10:16 +00:00
|
|
|
#include <QtDBus/QDBusConnection>
|
|
|
|
#include <QtDBus/QDBusConnectionInterface>
|
|
|
|
#include <QtDBus/QDBusInterface>
|
|
|
|
#include <QtDBus/QDBusReply>
|
2006-10-29 13:17:19 +00:00
|
|
|
|
2004-09-26 23:39:39 +00:00
|
|
|
#include <kaction.h>
|
2006-12-19 12:23:43 +00:00
|
|
|
#include <kstandardaction.h>
|
2004-09-26 23:39:39 +00:00
|
|
|
#include <kactioncollection.h>
|
2006-03-24 20:40:02 +00:00
|
|
|
#include <kmenu.h>
|
2004-09-26 23:39:39 +00:00
|
|
|
#include <klocale.h>
|
2004-11-03 17:35:48 +00:00
|
|
|
#include <kfiledialog.h>
|
2006-12-20 20:37:50 +00:00
|
|
|
#include <kglobal.h>
|
2007-01-03 00:17:31 +00:00
|
|
|
#include <kglobalsettings.h>
|
2006-05-08 19:00:23 +00:00
|
|
|
#include <kselectaction.h>
|
|
|
|
#include <ktoggleaction.h>
|
2006-03-24 20:40:02 +00:00
|
|
|
#include <ktoolinvocation.h>
|
2004-11-08 13:13:46 +00:00
|
|
|
#include <kdebug.h>
|
- Page/Link: tooltips for links backported
- 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
2005-08-10 16:14:39 +00:00
|
|
|
#include <kmessagebox.h>
|
2006-08-05 10:35:03 +00:00
|
|
|
#include <kicon.h>
|
2006-06-05 15:47:35 +00:00
|
|
|
|
2005-01-02 14:55:14 +00:00
|
|
|
// system includes
|
2004-09-26 23:39:39 +00:00
|
|
|
#include <math.h>
|
2004-10-06 00:05:49 +00:00
|
|
|
#include <stdlib.h>
|
2004-09-26 23:39:39 +00:00
|
|
|
|
2005-01-02 14:55:14 +00:00
|
|
|
// local includes
|
2007-02-25 00:07:59 +00:00
|
|
|
#include "formwidgets.h"
|
2004-10-20 16:41:13 +00:00
|
|
|
#include "pageviewutils.h"
|
2005-01-27 17:31:07 +00:00
|
|
|
#include "pagepainter.h"
|
2006-08-08 15:31:13 +00:00
|
|
|
#include "core/annotations.h"
|
2007-05-06 15:10:16 +00:00
|
|
|
#include "annotwindow.h"
|
2007-12-24 00:54:21 +00:00
|
|
|
#include "guiutils.h"
|
2006-12-30 12:40:54 +00:00
|
|
|
#include "annotationpopup.h"
|
2005-03-04 23:06:24 +00:00
|
|
|
#include "pageviewannotator.h"
|
2007-09-14 10:02:33 +00:00
|
|
|
#include "toolaction.h"
|
2007-04-20 11:26:05 +00:00
|
|
|
#include "core/action.h"
|
2005-01-02 14:55:14 +00:00
|
|
|
#include "core/document.h"
|
2007-02-25 00:07:59 +00:00
|
|
|
#include "core/form.h"
|
2005-01-02 14:37:49 +00:00
|
|
|
#include "core/page.h"
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
#include "core/misc.h"
|
2005-01-02 14:37:49 +00:00
|
|
|
#include "core/generator.h"
|
2006-03-28 22:22:10 +00:00
|
|
|
#include "settings.h"
|
2004-09-26 23:39:39 +00:00
|
|
|
|
2006-07-09 11:10:24 +00:00
|
|
|
static int pageflags = PagePainter::Accessibility | PagePainter::EnhanceLinks |
|
|
|
|
PagePainter::EnhanceImages | PagePainter::Highlights |
|
2006-09-26 22:22:01 +00:00
|
|
|
PagePainter::TextSelection | PagePainter::Annotations;
|
2006-07-09 11:10:24 +00:00
|
|
|
|
2004-09-26 23:39:39 +00:00
|
|
|
// structure used internally by PageView for data storage
|
|
|
|
class PageViewPrivate
|
|
|
|
{
|
|
|
|
public:
|
2007-10-18 22:09:49 +00:00
|
|
|
PageViewPrivate( PageView *qq );
|
|
|
|
|
|
|
|
FormWidgetsController* formWidgetsController();
|
|
|
|
|
2005-01-09 23:37:07 +00:00
|
|
|
// the document, pageviewItems and the 'visible cache'
|
2007-10-18 22:09:49 +00:00
|
|
|
PageView *q;
|
2006-09-21 08:45:36 +00:00
|
|
|
Okular::Document * document;
|
2006-03-24 20:40:02 +00:00
|
|
|
QVector< PageViewItem * > items;
|
|
|
|
QLinkedList< PageViewItem * > visibleItems;
|
2004-09-26 23:39:39 +00:00
|
|
|
|
2005-03-05 15:59:15 +00:00
|
|
|
// view layout (columns and continuous in Settings), zoom and mouse
|
2004-09-26 23:39:39 +00:00
|
|
|
PageView::ZoomMode zoomMode;
|
|
|
|
float zoomFactor;
|
|
|
|
PageView::MouseMode mouseMode;
|
|
|
|
QPoint mouseGrabPos;
|
2005-01-29 12:32:59 +00:00
|
|
|
QPoint mousePressPos;
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
QPoint mouseSelectPos;
|
2005-03-24 19:10:41 +00:00
|
|
|
bool mouseMidZooming;
|
|
|
|
int mouseMidLastY;
|
2005-06-24 16:41:55 +00:00
|
|
|
bool mouseSelecting;
|
2004-10-30 20:54:48 +00:00
|
|
|
QRect mouseSelectionRect;
|
2005-06-24 16:41:55 +00:00
|
|
|
QColor mouseSelectionColor;
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
bool mouseTextSelecting;
|
2006-09-26 22:22:01 +00:00
|
|
|
QSet< int > pagesWithTextSelection;
|
2005-06-24 16:41:55 +00:00
|
|
|
bool mouseOnRect;
|
2007-07-17 20:58:38 +00:00
|
|
|
Okular::Annotation * mouseAnn;
|
|
|
|
QPoint mouseAnnPos;
|
2006-10-07 14:40:32 +00:00
|
|
|
|
2005-02-01 18:24:16 +00:00
|
|
|
// viewport move
|
|
|
|
bool viewportMoveActive;
|
|
|
|
QTime viewportMoveTime;
|
|
|
|
QPoint viewportMoveDest;
|
|
|
|
QTimer * viewportMoveTimer;
|
|
|
|
// auto scroll
|
2004-10-06 00:05:49 +00:00
|
|
|
int scrollIncrement;
|
2005-02-01 18:24:16 +00:00
|
|
|
QTimer * autoScrollTimer;
|
2005-02-18 18:24:45 +00:00
|
|
|
// annotations
|
2005-03-04 23:06:24 +00:00
|
|
|
PageViewAnnotator * annotator;
|
2006-08-08 15:31:13 +00:00
|
|
|
//text annotation dialogs list
|
2006-08-11 23:53:48 +00:00
|
|
|
QList<AnnotWindow *> m_annowindows;
|
2005-02-01 18:24:16 +00:00
|
|
|
// other stuff
|
|
|
|
QTimer * delayResizeTimer;
|
2004-09-30 18:04:09 +00:00
|
|
|
bool dirtyLayout;
|
2005-02-01 18:24:16 +00:00
|
|
|
bool blockViewport; // prevents changes to viewport
|
2005-01-21 20:05:36 +00:00
|
|
|
bool blockPixmapsRequest; // prevent pixmap requests
|
|
|
|
PageViewMessage * messageWindow; // in pageviewutils.h
|
2007-02-25 00:07:59 +00:00
|
|
|
bool m_formsVisible;
|
2007-10-18 22:09:49 +00:00
|
|
|
FormWidgetsController *formsWidgetController;
|
2004-09-26 23:39:39 +00:00
|
|
|
|
2006-11-22 21:32:21 +00:00
|
|
|
// drag scroll
|
|
|
|
QPoint dragScrollVector;
|
|
|
|
QTimer dragScrollTimer;
|
|
|
|
|
2004-09-26 23:39:39 +00:00
|
|
|
// actions
|
2007-01-19 21:43:53 +00:00
|
|
|
KAction * aRotateClockwise;
|
|
|
|
KAction * aRotateCounterClockwise;
|
|
|
|
KAction * aRotateOriginal;
|
2007-01-05 23:12:06 +00:00
|
|
|
KSelectAction * aPageSizes;
|
2007-01-09 11:02:04 +00:00
|
|
|
QAction * aMouseNormal;
|
|
|
|
QAction * aMouseSelect;
|
|
|
|
QAction * aMouseTextSelect;
|
2005-03-04 23:06:24 +00:00
|
|
|
KToggleAction * aToggleAnnotator;
|
2004-10-29 21:52:06 +00:00
|
|
|
KSelectAction * aZoom;
|
2007-01-28 16:29:48 +00:00
|
|
|
QAction * aZoomIn;
|
|
|
|
QAction * aZoomOut;
|
2004-10-29 21:52:06 +00:00
|
|
|
KToggleAction * aZoomFitWidth;
|
|
|
|
KToggleAction * aZoomFitPage;
|
|
|
|
KToggleAction * aZoomFitText;
|
2007-05-17 20:46:16 +00:00
|
|
|
KSelectAction * aViewMode;
|
2005-03-05 15:59:15 +00:00
|
|
|
KToggleAction * aViewContinuous;
|
2007-01-09 11:02:04 +00:00
|
|
|
QAction * aPrevAction;
|
2007-02-25 00:07:59 +00:00
|
|
|
KAction * aToggleForms;
|
2006-06-25 16:34:11 +00:00
|
|
|
KActionCollection * actionCollection;
|
2006-10-28 22:58:05 +00:00
|
|
|
|
2007-05-17 20:46:16 +00:00
|
|
|
int setting_viewMode;
|
2007-05-19 10:19:25 +00:00
|
|
|
int setting_viewCols;
|
2007-12-31 22:41:32 +00:00
|
|
|
bool setting_centerFirst;
|
2004-09-26 23:39:39 +00:00
|
|
|
};
|
|
|
|
|
2007-10-18 22:09:49 +00:00
|
|
|
PageViewPrivate::PageViewPrivate( PageView *qq )
|
|
|
|
: q( qq )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
FormWidgetsController* PageViewPrivate::formWidgetsController()
|
|
|
|
{
|
|
|
|
if ( !formsWidgetController )
|
|
|
|
{
|
|
|
|
formsWidgetController = new FormWidgetsController();
|
|
|
|
QObject::connect( formsWidgetController, SIGNAL( changed( FormWidgetIface* ) ),
|
|
|
|
q, SLOT( slotFormWidgetChanged( FormWidgetIface * ) ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
return formsWidgetController;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-07 14:40:32 +00:00
|
|
|
class PageViewWidget : public QWidget
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PageViewWidget(PageView *pv) : QWidget(pv), m_pageView(pv) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool event( QEvent *e )
|
|
|
|
{
|
2007-06-20 20:31:07 +00:00
|
|
|
if ( e->type() == QEvent::ToolTip && m_pageView->d->mouseMode == PageView::MouseNormal )
|
2006-10-07 14:40:32 +00:00
|
|
|
{
|
|
|
|
QHelpEvent * he = (QHelpEvent*)e;
|
|
|
|
PageViewItem * pageItem = m_pageView->pickItemOnPoint( he->x(), he->y() );
|
|
|
|
const Okular::ObjectRect * rect = 0;
|
2007-04-20 12:37:12 +00:00
|
|
|
const Okular::Action * link = 0;
|
2006-10-14 10:07:42 +00:00
|
|
|
const Okular::Annotation * ann = 0;
|
2006-10-07 14:40:32 +00:00
|
|
|
if ( pageItem )
|
|
|
|
{
|
|
|
|
double nX = (double)( he->x() - pageItem->geometry().left() ) / (double)pageItem->width();
|
|
|
|
double nY = (double)( he->y() - pageItem->geometry().top() ) / (double)pageItem->height();
|
2006-11-23 17:11:04 +00:00
|
|
|
rect = pageItem->page()->objectRect( Okular::ObjectRect::OAnnotation, nX, nY, pageItem->width(), pageItem->height() );
|
2006-10-07 14:40:32 +00:00
|
|
|
if ( rect )
|
2006-10-16 19:19:42 +00:00
|
|
|
ann = static_cast< const Okular::AnnotationObjectRect * >( rect )->annotation();
|
2006-10-14 10:07:42 +00:00
|
|
|
else
|
|
|
|
{
|
2007-04-20 12:37:12 +00:00
|
|
|
rect = pageItem->page()->objectRect( Okular::ObjectRect::Action, nX, nY, pageItem->width(), pageItem->height() );
|
2006-10-14 10:07:42 +00:00
|
|
|
if ( rect )
|
2007-04-20 12:37:12 +00:00
|
|
|
link = static_cast< const Okular::Action * >( rect->object() );
|
2006-10-14 10:07:42 +00:00
|
|
|
}
|
2006-10-07 14:40:32 +00:00
|
|
|
}
|
|
|
|
|
2006-10-16 19:19:42 +00:00
|
|
|
if ( ann )
|
2006-10-07 14:40:32 +00:00
|
|
|
{
|
|
|
|
QRect r = rect->boundingRect( pageItem->width(), pageItem->height() );
|
|
|
|
r.translate( pageItem->geometry().left(), pageItem->geometry().top() );
|
2007-12-24 00:54:21 +00:00
|
|
|
QString tip = GuiUtils::prettyToolTip( ann );
|
2006-10-16 19:19:42 +00:00
|
|
|
QToolTip::showText( he->globalPos(), tip, this, r );
|
2006-10-07 14:40:32 +00:00
|
|
|
}
|
2006-10-16 19:19:42 +00:00
|
|
|
else if ( link )
|
2006-10-14 10:07:42 +00:00
|
|
|
{
|
|
|
|
QRect r = rect->boundingRect( pageItem->width(), pageItem->height() );
|
|
|
|
r.translate( pageItem->geometry().left(), pageItem->geometry().top() );
|
2007-04-20 12:37:12 +00:00
|
|
|
QString tip = link->actionTip();
|
2006-10-16 19:19:42 +00:00
|
|
|
if ( !tip.isEmpty() )
|
|
|
|
QToolTip::showText( he->globalPos(), tip, this, r );
|
2006-10-14 10:07:42 +00:00
|
|
|
}
|
2006-10-07 14:40:32 +00:00
|
|
|
e->accept();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
// do not stop the event
|
|
|
|
return QWidget::event( e );
|
|
|
|
}
|
|
|
|
|
|
|
|
// viewport events
|
|
|
|
void paintEvent( QPaintEvent *e )
|
|
|
|
{
|
|
|
|
m_pageView->contentsPaintEvent(e);
|
|
|
|
}
|
2004-09-26 23:39:39 +00:00
|
|
|
|
2006-10-07 14:40:32 +00:00
|
|
|
void mouseMoveEvent( QMouseEvent *e )
|
|
|
|
{
|
|
|
|
m_pageView->contentsMouseMoveEvent(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
void mousePressEvent( QMouseEvent *e )
|
|
|
|
{
|
|
|
|
m_pageView->contentsMousePressEvent(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
void mouseReleaseEvent( QMouseEvent *e )
|
|
|
|
{
|
|
|
|
m_pageView->contentsMouseReleaseEvent(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
PageView *m_pageView;
|
|
|
|
};
|
2004-10-20 16:41:13 +00:00
|
|
|
|
2004-09-30 18:16:12 +00:00
|
|
|
/* PageView. What's in this file? -> quick overview.
|
|
|
|
* Code weight (in rows) and meaning:
|
|
|
|
* 160 - constructor and creating actions plus their connected slots (empty stuff)
|
|
|
|
* 70 - DocumentObserver inherited methodes (important)
|
2005-01-09 23:37:07 +00:00
|
|
|
* 550 - events: mouse, keyboard, drag/drop
|
2005-03-05 15:59:15 +00:00
|
|
|
* 170 - slotRelayoutPages: set contents of the scrollview on continuous/single modes
|
2004-09-30 18:16:12 +00:00
|
|
|
* 100 - zoom: zooming pages in different ways, keeping update the toolbar actions, etc..
|
2004-10-30 20:54:48 +00:00
|
|
|
* other misc functions: only slotRequestVisiblePixmaps and pickItemOnPoint noticeable,
|
2004-09-30 18:16:12 +00:00
|
|
|
* and many insignificant stuff like this comment :-)
|
2004-09-26 23:39:39 +00:00
|
|
|
*/
|
2006-09-21 08:45:36 +00:00
|
|
|
PageView::PageView( QWidget *parent, Okular::Document *document )
|
2006-10-07 14:40:32 +00:00
|
|
|
: QScrollArea( parent )
|
2004-09-26 23:39:39 +00:00
|
|
|
{
|
|
|
|
// create and initialize private storage structure
|
2007-10-18 22:09:49 +00:00
|
|
|
d = new PageViewPrivate( this );
|
2004-09-26 23:39:39 +00:00
|
|
|
d->document = document;
|
2007-01-19 21:43:53 +00:00
|
|
|
d->aRotateClockwise = 0;
|
|
|
|
d->aRotateCounterClockwise = 0;
|
|
|
|
d->aRotateOriginal = 0;
|
2007-05-17 20:46:16 +00:00
|
|
|
d->aViewMode = 0;
|
2006-09-21 08:45:36 +00:00
|
|
|
d->zoomMode = (PageView::ZoomMode) Okular::Settings::zoomMode();
|
|
|
|
d->zoomFactor = Okular::Settings::zoomFactor();
|
2004-09-26 23:39:39 +00:00
|
|
|
d->mouseMode = MouseNormal;
|
2005-03-24 19:10:41 +00:00
|
|
|
d->mouseMidZooming = false;
|
2005-06-24 16:41:55 +00:00
|
|
|
d->mouseSelecting = false;
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
d->mouseTextSelecting = false;
|
2004-12-10 16:04:45 +00:00
|
|
|
d->mouseOnRect = false;
|
2007-07-17 20:58:38 +00:00
|
|
|
d->mouseAnn = 0;
|
2005-02-01 18:24:16 +00:00
|
|
|
d->viewportMoveActive = false;
|
|
|
|
d->viewportMoveTimer = 0;
|
2004-10-06 00:05:49 +00:00
|
|
|
d->scrollIncrement = 0;
|
2005-02-01 18:24:16 +00:00
|
|
|
d->autoScrollTimer = 0;
|
2005-03-04 23:06:24 +00:00
|
|
|
d->annotator = 0;
|
2005-02-01 18:24:16 +00:00
|
|
|
d->delayResizeTimer = 0;
|
2004-09-30 18:04:09 +00:00
|
|
|
d->dirtyLayout = false;
|
2005-01-09 23:37:07 +00:00
|
|
|
d->blockViewport = false;
|
2005-01-21 20:05:36 +00:00
|
|
|
d->blockPixmapsRequest = false;
|
2004-10-20 16:41:13 +00:00
|
|
|
d->messageWindow = new PageViewMessage(this);
|
2007-02-25 00:07:59 +00:00
|
|
|
d->m_formsVisible = false;
|
2007-10-18 22:09:49 +00:00
|
|
|
d->formsWidgetController = 0;
|
2007-07-14 12:31:26 +00:00
|
|
|
d->aRotateClockwise = 0;
|
|
|
|
d->aRotateCounterClockwise = 0;
|
|
|
|
d->aRotateOriginal = 0;
|
|
|
|
d->aPageSizes = 0;
|
|
|
|
d->aMouseNormal = 0;
|
|
|
|
d->aMouseSelect = 0;
|
|
|
|
d->aMouseTextSelect = 0;
|
|
|
|
d->aToggleAnnotator = 0;
|
|
|
|
d->aZoomFitWidth = 0;
|
|
|
|
d->aZoomFitPage = 0;
|
|
|
|
d->aZoomFitText = 0;
|
|
|
|
d->aViewMode = 0;
|
|
|
|
d->aViewContinuous = 0;
|
2005-01-28 17:21:28 +00:00
|
|
|
d->aPrevAction = 0;
|
2007-06-05 20:49:00 +00:00
|
|
|
d->aToggleForms = 0;
|
2007-07-14 12:31:26 +00:00
|
|
|
d->actionCollection = 0;
|
2007-01-05 23:12:06 +00:00
|
|
|
d->aPageSizes=0;
|
2007-05-17 20:46:16 +00:00
|
|
|
d->setting_viewMode = Okular::Settings::viewMode();
|
2007-05-19 10:19:25 +00:00
|
|
|
d->setting_viewCols = Okular::Settings::viewColumns();
|
2007-12-31 22:41:32 +00:00
|
|
|
d->setting_centerFirst = Okular::Settings::centerFirstPageInRow();
|
2004-09-27 21:36:25 +00:00
|
|
|
|
2007-05-28 15:29:29 +00:00
|
|
|
setFrameStyle(QFrame::NoFrame);
|
|
|
|
|
2006-06-03 13:01:15 +00:00
|
|
|
setAttribute( Qt::WA_StaticContents );
|
|
|
|
|
2006-06-12 18:25:18 +00:00
|
|
|
setObjectName( QLatin1String( "okular::pageView" ) );
|
2006-06-03 13:01:15 +00:00
|
|
|
|
2004-09-27 21:36:25 +00:00
|
|
|
// widget setup: setup focus, accept drops and track mouse
|
2006-10-07 14:40:32 +00:00
|
|
|
setWidget(new PageViewWidget(this));
|
2004-09-27 21:36:25 +00:00
|
|
|
viewport()->setFocusProxy( this );
|
2006-03-24 20:40:02 +00:00
|
|
|
viewport()->setFocusPolicy( Qt::StrongFocus );
|
2006-10-07 14:40:32 +00:00
|
|
|
widget()->setAttribute( Qt::WA_OpaquePaintEvent );
|
|
|
|
widget()->setAttribute( Qt::WA_NoSystemBackground );
|
2004-09-26 23:39:39 +00:00
|
|
|
setAcceptDrops( true );
|
2006-10-07 14:40:32 +00:00
|
|
|
widget()->setMouseTracking( true );
|
|
|
|
setWidgetResizable(true);
|
2004-09-27 21:36:25 +00:00
|
|
|
|
|
|
|
// conntect the padding of the viewport to pixmaps requests
|
2006-10-07 14:40:32 +00:00
|
|
|
connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(slotRequestVisiblePixmaps()));
|
|
|
|
connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(slotRequestVisiblePixmaps()));
|
2006-11-22 21:32:21 +00:00
|
|
|
connect( &d->dragScrollTimer, SIGNAL(timeout()), this, SLOT(slotDragScroll()) );
|
2004-09-26 23:39:39 +00:00
|
|
|
|
|
|
|
// set a corner button to resize the view to the page size
|
2004-10-29 21:52:06 +00:00
|
|
|
// QPushButton * resizeButton = new QPushButton( viewport() );
|
|
|
|
// resizeButton->setPixmap( SmallIcon("crop") );
|
|
|
|
// setCornerWidget( resizeButton );
|
|
|
|
// resizeButton->setEnabled( false );
|
2004-09-26 23:39:39 +00:00
|
|
|
// connect(...);
|
2006-08-30 14:17:22 +00:00
|
|
|
setAttribute( Qt::WA_InputMethodEnabled, true );
|
2006-09-20 13:58:28 +00:00
|
|
|
|
|
|
|
// schedule the welcome message
|
2006-10-19 21:18:39 +00:00
|
|
|
QMetaObject::invokeMethod(this, "slotShowWelcome", Qt::QueuedConnection);
|
2004-09-26 23:39:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PageView::~PageView()
|
|
|
|
{
|
2005-02-18 18:24:45 +00:00
|
|
|
// delete the local storage structure
|
2006-10-14 10:55:10 +00:00
|
|
|
qDeleteAll(d->m_annowindows);
|
2006-11-19 13:20:22 +00:00
|
|
|
// delete all widgets
|
2006-11-20 20:10:42 +00:00
|
|
|
QVector< PageViewItem * >::const_iterator dIt = d->items.begin(), dEnd = d->items.end();
|
2006-11-19 13:20:22 +00:00
|
|
|
for ( ; dIt != dEnd; ++dIt )
|
|
|
|
delete *dIt;
|
2007-10-18 22:09:49 +00:00
|
|
|
delete d->formsWidgetController;
|
2006-02-18 12:06:52 +00:00
|
|
|
d->document->removeObserver( this );
|
2004-09-26 23:39:39 +00:00
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
2007-07-14 12:31:26 +00:00
|
|
|
void PageView::setupBaseActions( KActionCollection * ac )
|
|
|
|
{
|
|
|
|
d->actionCollection = ac;
|
|
|
|
|
|
|
|
// Zoom actions ( higher scales takes lots of memory! )
|
|
|
|
d->aZoom = new KSelectAction(KIcon( "zoom-original" ), i18n("Zoom"), this);
|
|
|
|
ac->addAction("zoom_to", d->aZoom );
|
|
|
|
d->aZoom->setEditable( true );
|
|
|
|
d->aZoom->setMaxComboViewCount( 13 );
|
|
|
|
connect( d->aZoom, SIGNAL( triggered(QAction *) ), this, SLOT( slotZoom() ) );
|
|
|
|
updateZoomText();
|
|
|
|
|
2007-10-07 23:09:08 +00:00
|
|
|
d->aZoomIn = KStandardAction::zoomIn( this, SLOT( slotZoomIn() ), ac );
|
2007-07-14 12:31:26 +00:00
|
|
|
|
2007-10-07 23:09:08 +00:00
|
|
|
d->aZoomOut = KStandardAction::zoomOut( this, SLOT( slotZoomOut() ), ac );
|
2007-07-14 12:31:26 +00:00
|
|
|
}
|
|
|
|
|
2004-10-27 14:13:17 +00:00
|
|
|
void PageView::setupActions( KActionCollection * ac )
|
2004-09-26 23:39:39 +00:00
|
|
|
{
|
2006-06-25 16:34:11 +00:00
|
|
|
d->actionCollection = ac;
|
|
|
|
|
2007-01-19 21:43:53 +00:00
|
|
|
// orientation menu actions
|
2007-03-25 15:15:50 +00:00
|
|
|
d->aRotateClockwise = new KAction( KIcon( "object-rotate-right" ), i18n( "Rotate Right" ), this );
|
2007-11-02 00:07:32 +00:00
|
|
|
d->aRotateClockwise->setIconText( i18nc( "Rotate right", "Right" ) );
|
2007-01-19 21:43:53 +00:00
|
|
|
ac->addAction( "view_orientation_rotate_cw", d->aRotateClockwise );
|
2007-08-28 12:04:18 +00:00
|
|
|
d->aRotateClockwise->setEnabled( false );
|
2007-01-19 21:43:53 +00:00
|
|
|
connect( d->aRotateClockwise, SIGNAL( triggered() ), this, SLOT( slotRotateClockwise() ) );
|
2007-03-25 15:15:50 +00:00
|
|
|
d->aRotateCounterClockwise = new KAction( KIcon( "object-rotate-left" ), i18n( "Rotate Left" ), this );
|
2007-11-02 00:07:32 +00:00
|
|
|
d->aRotateCounterClockwise->setIconText( i18nc( "Rotate left", "Left" ) );
|
2007-01-19 21:43:53 +00:00
|
|
|
ac->addAction( "view_orientation_rotate_ccw", d->aRotateCounterClockwise );
|
2007-08-28 12:04:18 +00:00
|
|
|
d->aRotateCounterClockwise->setEnabled( false );
|
2007-01-19 21:43:53 +00:00
|
|
|
connect( d->aRotateCounterClockwise, SIGNAL( triggered() ), this, SLOT( slotRotateCounterClockwise() ) );
|
|
|
|
d->aRotateOriginal = new KAction( i18n( "Original Orientation" ), this );
|
|
|
|
ac->addAction( "view_orientation_original", d->aRotateOriginal );
|
2007-08-28 12:04:18 +00:00
|
|
|
d->aRotateOriginal->setEnabled( false );
|
2007-01-19 21:43:53 +00:00
|
|
|
connect( d->aRotateOriginal, SIGNAL( triggered() ), this, SLOT( slotRotateOriginal() ) );
|
|
|
|
|
2007-01-09 11:02:04 +00:00
|
|
|
d->aPageSizes = new KSelectAction(i18n("&Page Size"), this);
|
|
|
|
ac->addAction("view_pagesizes", d->aPageSizes);
|
2007-08-28 12:04:18 +00:00
|
|
|
d->aPageSizes->setEnabled( false );
|
2007-01-19 21:43:53 +00:00
|
|
|
|
2007-01-05 23:12:06 +00:00
|
|
|
connect( d->aPageSizes , SIGNAL( triggered( int ) ),
|
2007-05-01 23:21:29 +00:00
|
|
|
this, SLOT( slotPageSizes( int ) ) );
|
2005-07-20 22:28:23 +00:00
|
|
|
|
2007-01-09 11:02:04 +00:00
|
|
|
d->aZoomFitWidth = new KToggleAction(KIcon( "view_fit_width" ), i18n("Fit &Width"), this);
|
2007-10-07 22:21:13 +00:00
|
|
|
ac->addAction("view_fit_to_width", d->aZoomFitWidth );
|
2004-09-26 23:39:39 +00:00
|
|
|
connect( d->aZoomFitWidth, SIGNAL( toggled( bool ) ), SLOT( slotFitToWidthToggled( bool ) ) );
|
|
|
|
|
2007-01-09 11:02:04 +00:00
|
|
|
d->aZoomFitPage = new KToggleAction(KIcon( "view_fit_window" ), i18n("Fit &Page"), this);
|
2007-10-07 22:21:13 +00:00
|
|
|
ac->addAction("view_fit_to_page", d->aZoomFitPage );
|
2004-09-26 23:39:39 +00:00
|
|
|
connect( d->aZoomFitPage, SIGNAL( toggled( bool ) ), SLOT( slotFitToPageToggled( bool ) ) );
|
|
|
|
|
2007-11-02 23:23:06 +00:00
|
|
|
/*
|
2008-01-03 19:55:37 +00:00
|
|
|
d->aZoomFitText = new KToggleAction(KIcon( "zoom-fit-best" ), i18n("Fit &Text"), this);
|
2007-01-09 11:02:04 +00:00
|
|
|
ac->addAction("zoom_fit_text", d->aZoomFitText );
|
2004-09-30 18:04:09 +00:00
|
|
|
connect( d->aZoomFitText, SIGNAL( toggled( bool ) ), SLOT( slotFitToTextToggled( bool ) ) );
|
2007-11-02 23:23:06 +00:00
|
|
|
*/
|
2004-09-30 18:04:09 +00:00
|
|
|
|
2004-09-26 23:39:39 +00:00
|
|
|
// View-Layout actions
|
2007-05-17 20:46:16 +00:00
|
|
|
QStringList viewModes;
|
2007-07-23 16:38:14 +00:00
|
|
|
viewModes.append( i18n( "Single Page" ) );
|
|
|
|
viewModes.append( i18n( "Facing Pages" ) );
|
2007-05-17 20:46:16 +00:00
|
|
|
viewModes.append( i18n( "Overview" ) );
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
|
2008-01-01 14:52:38 +00:00
|
|
|
d->aViewMode = new KSelectAction(KIcon( "view-split-left-right" ), i18n("&View Mode"), this);
|
2007-05-17 20:46:16 +00:00
|
|
|
ac->addAction("view_render_mode", d->aViewMode );
|
|
|
|
connect( d->aViewMode, SIGNAL( triggered( int ) ), SLOT( slotViewMode( int ) ) );
|
|
|
|
d->aViewMode->setItems( viewModes );
|
|
|
|
d->aViewMode->setCurrentItem( Okular::Settings::viewMode() );
|
2004-09-26 23:39:39 +00:00
|
|
|
|
2008-01-01 12:25:48 +00:00
|
|
|
d->aViewContinuous = new KToggleAction(KIcon( "view-list-text" ), i18n("&Continuous"), this);
|
2007-01-09 11:02:04 +00:00
|
|
|
ac->addAction("view_continuous", d->aViewContinuous );
|
2005-03-05 15:59:15 +00:00
|
|
|
connect( d->aViewContinuous, SIGNAL( toggled( bool ) ), SLOT( slotContinuousToggled( bool ) ) );
|
2006-09-21 08:45:36 +00:00
|
|
|
d->aViewContinuous->setChecked( Okular::Settings::viewContinuous() );
|
2004-09-26 23:39:39 +00:00
|
|
|
|
|
|
|
// Mouse-Mode actions
|
2006-03-24 21:31:46 +00:00
|
|
|
QActionGroup * actGroup = new QActionGroup( this );
|
|
|
|
actGroup->setExclusive( true );
|
2007-08-05 10:24:21 +00:00
|
|
|
d->aMouseNormal = new KAction( KIcon( "input-mouse" ), i18n( "&Browse Tool" ), this );
|
2007-01-09 11:02:04 +00:00
|
|
|
ac->addAction("mouse_drag", d->aMouseNormal );
|
2006-04-13 11:24:57 +00:00
|
|
|
connect( d->aMouseNormal, SIGNAL( triggered() ), this, SLOT( slotSetMouseNormal() ) );
|
2007-08-20 20:25:22 +00:00
|
|
|
d->aMouseNormal->setIconText( i18nc( "Browse Tool", "Browse" ) );
|
2006-04-01 15:12:32 +00:00
|
|
|
d->aMouseNormal->setCheckable( true );
|
2007-08-04 17:42:06 +00:00
|
|
|
d->aMouseNormal->setShortcut( Qt::CTRL + Qt::Key_1 );
|
2006-03-24 21:31:46 +00:00
|
|
|
d->aMouseNormal->setActionGroup( actGroup );
|
2005-01-28 17:21:28 +00:00
|
|
|
d->aMouseNormal->setChecked( true );
|
2004-09-26 23:39:39 +00:00
|
|
|
|
2007-03-08 21:41:46 +00:00
|
|
|
KAction * mz = new KAction(KIcon( "zoom-original" ), i18n("&Zoom Tool"), this);
|
2007-01-09 11:02:04 +00:00
|
|
|
ac->addAction("mouse_zoom", mz );
|
2006-04-13 11:24:57 +00:00
|
|
|
connect( mz, SIGNAL( triggered() ), this, SLOT( slotSetMouseZoom() ) );
|
2007-08-20 20:25:22 +00:00
|
|
|
mz->setIconText( i18nc( "Zoom Tool", "Zoom" ) );
|
2006-04-01 15:12:32 +00:00
|
|
|
mz->setCheckable( true );
|
2007-08-04 17:42:06 +00:00
|
|
|
mz->setShortcut( Qt::CTRL + Qt::Key_2 );
|
2006-03-24 21:31:46 +00:00
|
|
|
mz->setActionGroup( actGroup );
|
2004-11-03 17:35:48 +00:00
|
|
|
|
2008-01-03 20:05:17 +00:00
|
|
|
d->aMouseSelect = new KAction(KIcon( "select-rectangular" ), i18n("&Selection Tool"), this);
|
2007-01-09 11:02:04 +00:00
|
|
|
ac->addAction("mouse_select", d->aMouseSelect );
|
2006-04-13 11:24:57 +00:00
|
|
|
connect( d->aMouseSelect, SIGNAL( triggered() ), this, SLOT( slotSetMouseSelect() ) );
|
2007-11-13 22:46:44 +00:00
|
|
|
d->aMouseSelect->setIconText( i18nc( "Select Tool", "Selection" ) );
|
2006-04-01 15:12:32 +00:00
|
|
|
d->aMouseSelect->setCheckable( true );
|
2007-08-04 17:42:06 +00:00
|
|
|
d->aMouseSelect->setShortcut( Qt::CTRL + Qt::Key_3 );
|
2006-03-24 21:31:46 +00:00
|
|
|
d->aMouseSelect->setActionGroup( actGroup );
|
2004-11-03 17:35:48 +00:00
|
|
|
|
2008-01-03 19:55:37 +00:00
|
|
|
d->aMouseTextSelect = new KAction(KIcon( "draw-text" ), i18n("&Text Selection Tool"), this);
|
2007-01-09 11:02:04 +00:00
|
|
|
ac->addAction("mouse_textselect", d->aMouseTextSelect );
|
2006-09-26 22:22:01 +00:00
|
|
|
connect( d->aMouseTextSelect, SIGNAL( triggered() ), this, SLOT( slotSetMouseTextSelect() ) );
|
2007-08-20 20:25:22 +00:00
|
|
|
d->aMouseTextSelect->setIconText( i18nc( "Text Selection Tool", "Text Selection" ) );
|
2006-09-26 22:22:01 +00:00
|
|
|
d->aMouseTextSelect->setCheckable( true );
|
2007-08-04 17:42:06 +00:00
|
|
|
d->aMouseTextSelect->setShortcut( Qt::CTRL + Qt::Key_4 );
|
2006-09-26 22:22:01 +00:00
|
|
|
d->aMouseTextSelect->setActionGroup( actGroup );
|
|
|
|
|
2007-12-08 18:49:02 +00:00
|
|
|
d->aToggleAnnotator = new KToggleAction(KIcon( "draw-freehand" ), i18n("&Review"), this);
|
2007-01-09 11:02:04 +00:00
|
|
|
ac->addAction("mouse_toggle_annotate", d->aToggleAnnotator );
|
2006-04-01 15:12:32 +00:00
|
|
|
d->aToggleAnnotator->setCheckable( true );
|
2005-03-04 23:06:24 +00:00
|
|
|
connect( d->aToggleAnnotator, SIGNAL( toggled( bool ) ), SLOT( slotToggleAnnotator( bool ) ) );
|
2006-04-10 18:50:27 +00:00
|
|
|
d->aToggleAnnotator->setShortcut( Qt::Key_F6 );
|
2004-09-26 23:39:39 +00:00
|
|
|
|
2007-09-14 10:02:33 +00:00
|
|
|
ToolAction *ta = new ToolAction( this );
|
|
|
|
ac->addAction( "mouse_selecttools", ta );
|
|
|
|
ta->addAction( d->aMouseSelect );
|
|
|
|
ta->addAction( d->aMouseTextSelect );
|
|
|
|
|
2004-09-26 23:39:39 +00:00
|
|
|
// Other actions
|
2007-01-09 11:02:04 +00:00
|
|
|
KAction * su = new KAction(i18n("Scroll Up"), this);
|
|
|
|
ac->addAction("view_scroll_up", su );
|
2006-04-13 11:41:36 +00:00
|
|
|
connect( su, SIGNAL( triggered() ), this, SLOT( slotScrollUp() ) );
|
|
|
|
su->setShortcut( QKeySequence(Qt::SHIFT + Qt::Key_Up) );
|
2006-09-29 09:02:07 +00:00
|
|
|
addAction(su);
|
2004-10-06 00:05:49 +00:00
|
|
|
|
2007-01-09 11:02:04 +00:00
|
|
|
KAction * sd = new KAction(i18n("Scroll Down"), this);
|
|
|
|
ac->addAction("view_scroll_down", sd );
|
2006-04-13 11:41:36 +00:00
|
|
|
connect( sd, SIGNAL( triggered() ), this, SLOT( slotScrollDown() ) );
|
|
|
|
sd->setShortcut( QKeySequence(Qt::SHIFT + Qt::Key_Down) );
|
2006-09-29 09:02:07 +00:00
|
|
|
addAction(sd);
|
2007-02-25 00:07:59 +00:00
|
|
|
|
|
|
|
d->aToggleForms = new KAction( this );
|
|
|
|
ac->addAction( "view_toggle_forms", d->aToggleForms );
|
|
|
|
connect( d->aToggleForms, SIGNAL( triggered() ), this, SLOT( slotToggleForms() ) );
|
2007-08-28 12:04:18 +00:00
|
|
|
d->aToggleForms->setEnabled( false );
|
2007-02-25 00:07:59 +00:00
|
|
|
toggleFormWidgets( false );
|
2004-09-26 23:39:39 +00:00
|
|
|
}
|
|
|
|
|
2006-11-19 13:50:41 +00:00
|
|
|
bool PageView::canFitPageWidth() const
|
2005-01-10 13:43:44 +00:00
|
|
|
{
|
2007-05-17 20:46:16 +00:00
|
|
|
return Okular::Settings::viewMode() != 0 || d->zoomMode != ZoomFitWidth;
|
2005-01-10 13:43:44 +00:00
|
|
|
}
|
|
|
|
|
2005-01-09 23:37:07 +00:00
|
|
|
void PageView::fitPageWidth( int page )
|
2004-12-04 23:23:18 +00:00
|
|
|
{
|
2005-01-09 23:37:07 +00:00
|
|
|
// zoom: Fit Width, columns: 1. setActions + relayout + setPage + update
|
2004-12-04 23:23:18 +00:00
|
|
|
d->zoomMode = ZoomFitWidth;
|
2007-05-17 20:46:16 +00:00
|
|
|
Okular::Settings::setViewMode( 0 );
|
2004-12-04 23:23:18 +00:00
|
|
|
d->aZoomFitWidth->setChecked( true );
|
|
|
|
d->aZoomFitPage->setChecked( false );
|
2007-11-03 12:58:46 +00:00
|
|
|
// d->aZoomFitText->setChecked( false );
|
2007-05-17 20:46:16 +00:00
|
|
|
d->aViewMode->setCurrentItem( 0 );
|
2004-12-04 23:23:18 +00:00
|
|
|
viewport()->setUpdatesEnabled( false );
|
|
|
|
slotRelayoutPages();
|
|
|
|
viewport()->setUpdatesEnabled( true );
|
2005-01-09 23:37:07 +00:00
|
|
|
d->document->setViewportPage( page );
|
2005-01-10 13:43:44 +00:00
|
|
|
updateZoomText();
|
2005-06-13 10:22:37 +00:00
|
|
|
setFocus();
|
2004-12-04 23:23:18 +00:00
|
|
|
}
|
|
|
|
|
2006-12-30 12:40:54 +00:00
|
|
|
void PageView::setAnnotationWindow( Okular::Annotation * annotation )
|
2006-08-08 15:31:13 +00:00
|
|
|
{
|
2006-12-30 12:40:54 +00:00
|
|
|
if ( !annotation )
|
2006-08-08 15:31:13 +00:00
|
|
|
return;
|
2006-12-30 12:40:54 +00:00
|
|
|
|
|
|
|
// find the annot window
|
|
|
|
AnnotWindow* existWindow = 0;
|
|
|
|
foreach ( AnnotWindow* tempwnd, d->m_annowindows )
|
2006-08-08 15:31:13 +00:00
|
|
|
{
|
2006-12-30 12:40:54 +00:00
|
|
|
if ( tempwnd )
|
2006-08-08 15:31:13 +00:00
|
|
|
{
|
2006-12-30 12:40:54 +00:00
|
|
|
if ( tempwnd->m_annot == annotation )
|
2006-08-08 15:31:13 +00:00
|
|
|
{
|
2006-12-30 12:40:54 +00:00
|
|
|
existWindow = tempwnd;
|
2006-08-08 15:31:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-12-30 12:40:54 +00:00
|
|
|
|
|
|
|
if ( existWindow == 0 )
|
2006-08-08 15:31:13 +00:00
|
|
|
{
|
2006-12-30 12:40:54 +00:00
|
|
|
existWindow = new AnnotWindow( this, annotation );
|
|
|
|
|
|
|
|
d->m_annowindows << existWindow;
|
2006-08-08 15:31:13 +00:00
|
|
|
}
|
2006-12-30 12:40:54 +00:00
|
|
|
|
|
|
|
existWindow->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PageView::removeAnnotationWindow( Okular::Annotation *annotation )
|
|
|
|
{
|
|
|
|
QList<AnnotWindow *>::Iterator it = d->m_annowindows.begin();
|
|
|
|
QList<AnnotWindow *>::Iterator itEnd = d->m_annowindows.end();
|
|
|
|
for ( ; it != itEnd; ++it )
|
|
|
|
{
|
|
|
|
if ( annotation == (*it)->m_annot )
|
2006-08-08 15:31:13 +00:00
|
|
|
{
|
2006-12-30 12:40:54 +00:00
|
|
|
delete *it;
|
|
|
|
d->m_annowindows.erase( it );
|
|
|
|
|
|
|
|
return;
|
2006-08-08 15:31:13 +00:00
|
|
|
}
|
2006-12-30 12:40:54 +00:00
|
|
|
}
|
2006-08-08 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
- Page/Link: tooltips for links backported
- 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
2005-08-10 16:14:39 +00:00
|
|
|
void PageView::displayMessage( const QString & message,PageViewMessage::Icon icon,int duration )
|
2005-03-04 23:06:24 +00:00
|
|
|
{
|
2006-09-21 08:45:36 +00:00
|
|
|
if ( !Okular::Settings::showOSD() )
|
- Page/Link: tooltips for links backported
- 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
2005-08-10 16:14:39 +00:00
|
|
|
{
|
|
|
|
if (icon == PageViewMessage::Error)
|
|
|
|
KMessageBox::error( this, message );
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
}
|
2005-03-04 23:06:24 +00:00
|
|
|
|
|
|
|
// hide messageWindow if string is empty
|
|
|
|
if ( message.isEmpty() )
|
|
|
|
return d->messageWindow->hide();
|
|
|
|
|
|
|
|
// display message (duration is length dependant)
|
- Page/Link: tooltips for links backported
- 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
2005-08-10 16:14:39 +00:00
|
|
|
if (duration==-1)
|
|
|
|
duration = 500 + 100 * message.length();
|
|
|
|
d->messageWindow->display( message, icon, duration );
|
2005-03-04 23:06:24 +00:00
|
|
|
}
|
|
|
|
|
2006-10-28 22:58:05 +00:00
|
|
|
void PageView::reparseConfig()
|
|
|
|
{
|
|
|
|
// set the scroll bars policies
|
|
|
|
Qt::ScrollBarPolicy scrollBarMode = Okular::Settings::showScrollBars() ?
|
|
|
|
Qt::ScrollBarAsNeeded : Qt::ScrollBarAlwaysOff;
|
|
|
|
if ( horizontalScrollBarPolicy() != scrollBarMode )
|
|
|
|
{
|
|
|
|
setHorizontalScrollBarPolicy( scrollBarMode );
|
|
|
|
setVerticalScrollBarPolicy( scrollBarMode );
|
|
|
|
}
|
|
|
|
|
2007-12-31 22:41:32 +00:00
|
|
|
const int viewMode = Okular::Settings::viewMode();
|
|
|
|
if ( ( viewMode == 2 && ( (int)Okular::Settings::viewColumns() != d->setting_viewCols ) )
|
|
|
|
|| ( viewMode > 0 && ( Okular::Settings::centerFirstPageInRow() != d->setting_centerFirst ) )
|
|
|
|
)
|
2006-10-28 22:58:05 +00:00
|
|
|
{
|
2007-05-17 20:46:16 +00:00
|
|
|
d->setting_viewMode = Okular::Settings::viewMode();
|
2007-05-19 10:19:25 +00:00
|
|
|
d->setting_viewCols = Okular::Settings::viewColumns();
|
2007-12-31 22:41:32 +00:00
|
|
|
d->setting_centerFirst = Okular::Settings::centerFirstPageInRow();
|
2006-10-28 22:58:05 +00:00
|
|
|
|
|
|
|
slotRelayoutPages();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-25 00:07:59 +00:00
|
|
|
KAction *PageView::toggleFormsAction() const
|
|
|
|
{
|
|
|
|
return d->aToggleForms;
|
|
|
|
}
|
|
|
|
|
2006-11-24 21:02:38 +00:00
|
|
|
void PageView::copyTextSelection() const
|
|
|
|
{
|
|
|
|
if ( d->pagesWithTextSelection.isEmpty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
QString text;
|
|
|
|
QList< int > selpages = d->pagesWithTextSelection.toList();
|
|
|
|
qSort( selpages );
|
|
|
|
const Okular::Page * pg = 0;
|
|
|
|
if ( selpages.count() == 1 )
|
|
|
|
{
|
|
|
|
pg = d->document->page( selpages.first() );
|
|
|
|
text.append( pg->text( pg->textSelection() ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pg = d->document->page( selpages.first() );
|
|
|
|
text.append( pg->text( pg->textSelection() ) );
|
|
|
|
int end = selpages.count() - 1;
|
|
|
|
for( int i = 1; i < end; ++i )
|
|
|
|
{
|
|
|
|
pg = d->document->page( selpages.at( i ) );
|
|
|
|
text.append( pg->text() );
|
|
|
|
}
|
|
|
|
pg = d->document->page( selpages.last() );
|
|
|
|
text.append( pg->text( pg->textSelection() ) );
|
|
|
|
}
|
|
|
|
if ( !text.isEmpty() )
|
|
|
|
{
|
|
|
|
QClipboard *cb = QApplication::clipboard();
|
|
|
|
cb->setText( text, QClipboard::Clipboard );
|
|
|
|
if ( cb->supportsSelection() )
|
|
|
|
cb->setText( text, QClipboard::Selection );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-03 21:35:05 +00:00
|
|
|
void PageView::selectAll()
|
|
|
|
{
|
|
|
|
if ( d->mouseMode != MouseTextSelect )
|
|
|
|
return;
|
|
|
|
|
|
|
|
QVector< PageViewItem * >::const_iterator it = d->items.begin(), itEnd = d->items.end();
|
|
|
|
for ( ; it < itEnd; ++it )
|
|
|
|
{
|
|
|
|
Okular::RegularAreaRect * area = textSelectionForItem( *it );
|
|
|
|
d->pagesWithTextSelection.insert( (*it)->pageNumber() );
|
|
|
|
d->document->setPageTextSelection( (*it)->pageNumber(), area, palette().color( QPalette::Active, QPalette::Highlight ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-09 23:37:07 +00:00
|
|
|
//BEGIN DocumentObserver inherited methods
|
2007-09-09 10:50:36 +00:00
|
|
|
void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, int setupFlags )
|
2004-10-10 13:21:30 +00:00
|
|
|
{
|
2007-09-09 10:50:36 +00:00
|
|
|
bool documentChanged = setupFlags & Okular::DocumentObserver::DocumentChanged;
|
2004-10-10 13:21:30 +00:00
|
|
|
// reuse current pages if nothing new
|
2007-09-09 10:50:36 +00:00
|
|
|
if ( ( pageSet.count() == d->items.count() ) && !documentChanged && !( setupFlags & Okular::DocumentObserver::NewLayoutForPages ) )
|
2004-10-10 13:21:30 +00:00
|
|
|
{
|
|
|
|
int count = pageSet.count();
|
|
|
|
for ( int i = 0; (i < count) && !documentChanged; i++ )
|
2004-11-05 00:14:00 +00:00
|
|
|
if ( (int)pageSet[i]->number() != d->items[i]->pageNumber() )
|
2004-10-10 13:21:30 +00:00
|
|
|
documentChanged = true;
|
|
|
|
if ( !documentChanged )
|
|
|
|
return;
|
|
|
|
}
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
|
2004-10-10 13:21:30 +00:00
|
|
|
// delete all widgets (one for each page in pageSet)
|
2006-11-20 20:10:42 +00:00
|
|
|
QVector< PageViewItem * >::const_iterator dIt = d->items.begin(), dEnd = d->items.end();
|
2004-09-26 23:39:39 +00:00
|
|
|
for ( ; dIt != dEnd; ++dIt )
|
|
|
|
delete *dIt;
|
2004-11-05 00:14:00 +00:00
|
|
|
d->items.clear();
|
2005-01-03 01:10:27 +00:00
|
|
|
d->visibleItems.clear();
|
2007-12-31 18:28:02 +00:00
|
|
|
d->pagesWithTextSelection.clear();
|
2007-02-25 00:07:59 +00:00
|
|
|
toggleFormWidgets( false );
|
2004-09-26 23:39:39 +00:00
|
|
|
|
2007-08-28 12:04:18 +00:00
|
|
|
bool haspages = !pageSet.isEmpty();
|
2007-02-25 00:07:59 +00:00
|
|
|
bool hasformwidgets = false;
|
2004-09-26 23:39:39 +00:00
|
|
|
// create children widgets
|
2006-09-21 08:45:36 +00:00
|
|
|
QVector< Okular::Page * >::const_iterator setIt = pageSet.begin(), setEnd = pageSet.end();
|
2004-09-26 23:39:39 +00:00
|
|
|
for ( ; setIt != setEnd; ++setIt )
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
{
|
2007-02-25 00:07:59 +00:00
|
|
|
PageViewItem * item = new PageViewItem( *setIt );
|
|
|
|
d->items.push_back( item );
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
#ifdef PAGEVIEW_DEBUG
|
2007-07-31 10:19:48 +00:00
|
|
|
kDebug().nospace() << "geom for " << d->items.last()->pageNumber() << " is " << d->items.last()->geometry();
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
#endif
|
2007-02-25 00:07:59 +00:00
|
|
|
const QLinkedList< Okular::FormField * > pageFields = (*setIt)->formFields();
|
|
|
|
QLinkedList< Okular::FormField * >::const_iterator ffIt = pageFields.begin(), ffEnd = pageFields.end();
|
|
|
|
for ( ; ffIt != ffEnd; ++ffIt )
|
|
|
|
{
|
|
|
|
Okular::FormField * ff = *ffIt;
|
|
|
|
FormWidgetIface * w = FormWidgetFactory::createWidget( ff, widget() );
|
|
|
|
if ( w )
|
|
|
|
{
|
2007-10-18 22:09:49 +00:00
|
|
|
w->setPageItem( item );
|
|
|
|
w->setFormWidgetsController( d->formWidgetsController() );
|
2007-12-31 22:22:38 +00:00
|
|
|
w->setVisibility( false );
|
2007-04-28 23:22:20 +00:00
|
|
|
w->setCanBeFilled( d->document->isAllowed( Okular::AllowFillForms ) );
|
2007-02-25 00:07:59 +00:00
|
|
|
item->formWidgets().insert( ff->name(), w );
|
|
|
|
hasformwidgets = true;
|
|
|
|
}
|
|
|
|
}
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
}
|
2004-09-26 23:39:39 +00:00
|
|
|
|
2005-01-09 23:37:07 +00:00
|
|
|
// invalidate layout so relayout/repaint will happen on next viewport change
|
2007-08-28 12:04:18 +00:00
|
|
|
if ( haspages )
|
2005-07-15 18:20:57 +00:00
|
|
|
// TODO for Enrico: Check if doing always the slotRelayoutPages() is not
|
|
|
|
// suboptimal in some cases, i'd say it is not but a recheck will not hurt
|
|
|
|
// Need slotRelayoutPages() here instead of d->dirtyLayout = true
|
2007-05-02 23:06:38 +00:00
|
|
|
// because opening a document from another document will not trigger a viewportchange
|
2005-07-15 18:20:57 +00:00
|
|
|
// so pages are never relayouted
|
2006-10-19 21:18:39 +00:00
|
|
|
QMetaObject::invokeMethod(this, "slotRelayoutPages", Qt::QueuedConnection);
|
2005-01-27 17:31:07 +00:00
|
|
|
else
|
2005-11-04 11:59:51 +00:00
|
|
|
{
|
|
|
|
// update the mouse cursor when closing because we may have close through a link and
|
|
|
|
// want the cursor to come back to the normal cursor
|
2006-10-07 14:40:32 +00:00
|
|
|
updateCursor( widget()->mapFromGlobal( QCursor::pos() ) );
|
|
|
|
setWidgetResizable(true);
|
2005-11-04 11:59:51 +00:00
|
|
|
}
|
2004-10-29 20:20:21 +00:00
|
|
|
|
|
|
|
// OSD to display pages
|
2006-09-21 08:45:36 +00:00
|
|
|
if ( documentChanged && pageSet.count() > 0 && Okular::Settings::showOSD() )
|
2004-10-29 20:20:21 +00:00
|
|
|
d->messageWindow->display(
|
2006-04-10 18:50:27 +00:00
|
|
|
i18np(" Loaded a one-page document.",
|
2007-02-13 17:45:54 +00:00
|
|
|
" Loaded a %1-page document.",
|
2004-11-30 20:03:45 +00:00
|
|
|
pageSet.count() ),
|
2004-10-29 20:20:21 +00:00
|
|
|
PageViewMessage::Info, 4000 );
|
2005-07-20 22:28:23 +00:00
|
|
|
|
2007-06-05 20:49:00 +00:00
|
|
|
if ( d->aPageSizes )
|
|
|
|
{ // may be null if dummy mode is on
|
|
|
|
bool pageSizes = d->document->supportsPageSizes();
|
|
|
|
d->aPageSizes->setEnabled( pageSizes );
|
|
|
|
// set the new page sizes:
|
|
|
|
// - if the generator supports them
|
|
|
|
// - if the document changed
|
|
|
|
if ( pageSizes && documentChanged )
|
|
|
|
{
|
|
|
|
QStringList items;
|
|
|
|
foreach ( const Okular::PageSize &p, d->document->pageSizes() )
|
|
|
|
items.append( p.name() );
|
|
|
|
d->aPageSizes->setItems( items );
|
|
|
|
}
|
|
|
|
}
|
2007-08-28 12:04:18 +00:00
|
|
|
if ( d->aRotateClockwise )
|
|
|
|
d->aRotateClockwise->setEnabled( haspages );
|
|
|
|
if ( d->aRotateCounterClockwise )
|
|
|
|
d->aRotateCounterClockwise->setEnabled( haspages );
|
|
|
|
if ( d->aRotateOriginal )
|
|
|
|
d->aRotateOriginal->setEnabled( haspages );
|
2007-06-05 20:49:00 +00:00
|
|
|
if ( d->aToggleForms )
|
|
|
|
{ // may be null if dummy mode is on
|
2007-08-28 12:04:18 +00:00
|
|
|
d->aToggleForms->setEnabled( haspages && hasformwidgets );
|
2007-01-05 23:12:06 +00:00
|
|
|
}
|
2007-08-27 22:11:18 +00:00
|
|
|
bool allowAnnotations = d->document->isAllowed( Okular::AllowNotes );
|
2007-04-30 17:40:53 +00:00
|
|
|
if ( d->annotator )
|
2007-08-27 22:11:18 +00:00
|
|
|
{
|
2007-12-09 01:35:42 +00:00
|
|
|
bool allowTools = haspages && allowAnnotations;
|
|
|
|
d->annotator->setToolsEnabled( allowTools );
|
|
|
|
d->annotator->setTextToolsEnabled( allowTools && d->document->supportsSearching() );
|
|
|
|
}
|
|
|
|
if ( d->aToggleAnnotator )
|
|
|
|
{
|
|
|
|
if ( !allowAnnotations && d->aToggleAnnotator->isChecked() )
|
2007-08-27 22:11:18 +00:00
|
|
|
{
|
|
|
|
d->aToggleAnnotator->trigger();
|
|
|
|
}
|
2007-08-28 12:04:18 +00:00
|
|
|
d->aToggleAnnotator->setEnabled( allowAnnotations );
|
2007-12-09 01:35:42 +00:00
|
|
|
}
|
2004-09-26 23:39:39 +00:00
|
|
|
}
|
|
|
|
|
2005-02-01 18:24:16 +00:00
|
|
|
void PageView::notifyViewportChanged( bool smoothMove )
|
2004-09-26 23:39:39 +00:00
|
|
|
{
|
2005-01-09 23:37:07 +00:00
|
|
|
// if we are the one changing viewport, skip this nofity
|
|
|
|
if ( d->blockViewport )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// block setViewport outgoing calls
|
|
|
|
d->blockViewport = true;
|
|
|
|
|
|
|
|
// find PageViewItem matching the viewport description
|
2006-09-21 08:45:36 +00:00
|
|
|
const Okular::DocumentViewport & vp = d->document->viewport();
|
2005-01-09 23:37:07 +00:00
|
|
|
PageViewItem * item = 0;
|
2006-11-20 20:10:42 +00:00
|
|
|
QVector< PageViewItem * >::const_iterator iIt = d->items.begin(), iEnd = d->items.end();
|
2004-11-05 00:14:00 +00:00
|
|
|
for ( ; iIt != iEnd; ++iIt )
|
2005-01-21 20:05:36 +00:00
|
|
|
if ( (*iIt)->pageNumber() == vp.pageNumber )
|
2004-09-26 23:39:39 +00:00
|
|
|
{
|
2005-01-09 23:37:07 +00:00
|
|
|
item = *iIt;
|
2004-09-26 23:39:39 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-01-09 23:37:07 +00:00
|
|
|
if ( !item )
|
|
|
|
{
|
2007-07-31 10:19:48 +00:00
|
|
|
kWarning() << "viewport for page" << vp.pageNumber << "has no matching item!";
|
2005-11-04 11:59:51 +00:00
|
|
|
d->blockViewport = false;
|
2004-09-30 18:16:12 +00:00
|
|
|
return;
|
2005-01-09 23:37:07 +00:00
|
|
|
}
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
#ifdef PAGEVIEW_DEBUG
|
2007-07-31 10:19:48 +00:00
|
|
|
kDebug() << "document viewport changed";
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
#endif
|
2004-10-10 13:21:30 +00:00
|
|
|
// relayout in "Single Pages" mode or if a relayout is pending
|
2005-01-21 20:05:36 +00:00
|
|
|
d->blockPixmapsRequest = true;
|
2006-09-21 08:45:36 +00:00
|
|
|
if ( !Okular::Settings::viewContinuous() || d->dirtyLayout )
|
2004-09-30 18:16:12 +00:00
|
|
|
slotRelayoutPages();
|
|
|
|
|
2005-02-01 18:24:16 +00:00
|
|
|
// restore viewport center or use default {x-center,v-top} alignment
|
2005-01-09 23:37:07 +00:00
|
|
|
const QRect & r = item->geometry();
|
2005-02-01 18:24:16 +00:00
|
|
|
int newCenterX = r.left(),
|
|
|
|
newCenterY = r.top();
|
2005-06-13 11:53:47 +00:00
|
|
|
if ( vp.rePos.enabled )
|
2004-11-05 18:14:20 +00:00
|
|
|
{
|
2006-09-21 08:45:36 +00:00
|
|
|
if ( vp.rePos.pos == Okular::DocumentViewport::Center )
|
2005-06-13 11:53:47 +00:00
|
|
|
{
|
|
|
|
newCenterX += (int)( vp.rePos.normalizedX * (double)r.width() );
|
|
|
|
newCenterY += (int)( vp.rePos.normalizedY * (double)r.height() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// TopLeft
|
|
|
|
newCenterX += (int)( vp.rePos.normalizedX * (double)r.width() + viewport()->width() / 2 );
|
|
|
|
newCenterY += (int)( vp.rePos.normalizedY * (double)r.height() + viewport()->height() / 2 );
|
|
|
|
}
|
2005-02-01 18:24:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newCenterX += r.width() / 2;
|
2006-10-07 14:40:32 +00:00
|
|
|
newCenterY += viewport()->height() / 2 - 10;
|
2005-02-01 18:24:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// if smooth movement requested, setup parameters and start it
|
|
|
|
if ( smoothMove )
|
|
|
|
{
|
|
|
|
d->viewportMoveActive = true;
|
|
|
|
d->viewportMoveTime.start();
|
|
|
|
d->viewportMoveDest.setX( newCenterX );
|
|
|
|
d->viewportMoveDest.setY( newCenterY );
|
|
|
|
if ( !d->viewportMoveTimer )
|
|
|
|
{
|
|
|
|
d->viewportMoveTimer = new QTimer( this );
|
|
|
|
connect( d->viewportMoveTimer, SIGNAL( timeout() ),
|
|
|
|
this, SLOT( slotMoveViewport() ) );
|
|
|
|
}
|
|
|
|
d->viewportMoveTimer->start( 25 );
|
|
|
|
verticalScrollBar()->setEnabled( false );
|
|
|
|
horizontalScrollBar()->setEnabled( false );
|
2004-11-05 18:14:20 +00:00
|
|
|
}
|
2005-01-09 23:37:07 +00:00
|
|
|
else
|
2005-02-01 18:24:16 +00:00
|
|
|
center( newCenterX, newCenterY );
|
2005-01-21 20:05:36 +00:00
|
|
|
d->blockPixmapsRequest = false;
|
2005-01-09 23:37:07 +00:00
|
|
|
|
|
|
|
// request visible pixmaps in the current viewport and recompute it
|
2004-09-30 18:16:12 +00:00
|
|
|
slotRequestVisiblePixmaps();
|
|
|
|
|
2005-01-09 23:37:07 +00:00
|
|
|
// enable setViewport calls
|
|
|
|
d->blockViewport = false;
|
|
|
|
|
2004-09-30 18:16:12 +00:00
|
|
|
// update zoom text if in a ZoomFit/* zoom mode
|
|
|
|
if ( d->zoomMode != ZoomFixed )
|
|
|
|
updateZoomText();
|
2005-01-01 21:50:34 +00:00
|
|
|
|
2005-01-09 23:37:07 +00:00
|
|
|
// since the page has moved below cursor, update it
|
2006-10-07 14:40:32 +00:00
|
|
|
updateCursor( widget()->mapFromGlobal( QCursor::pos() ) );
|
2004-09-26 23:39:39 +00:00
|
|
|
}
|
2004-12-21 12:38:52 +00:00
|
|
|
|
2005-01-30 00:58:16 +00:00
|
|
|
void PageView::notifyPageChanged( int pageNumber, int changedFlags )
|
2004-12-21 12:38:52 +00:00
|
|
|
{
|
2005-01-30 00:58:16 +00:00
|
|
|
// only handle pixmap / highlight changes notifies
|
|
|
|
if ( changedFlags & DocumentObserver::Bookmark )
|
|
|
|
return;
|
2004-12-21 12:38:52 +00:00
|
|
|
|
2005-01-09 23:37:07 +00:00
|
|
|
// iterate over visible items: if page(pageNumber) is one of them, repaint it
|
2006-11-20 20:10:42 +00:00
|
|
|
QLinkedList< PageViewItem * >::const_iterator iIt = d->visibleItems.begin(), iEnd = d->visibleItems.end();
|
2004-12-21 12:38:52 +00:00
|
|
|
for ( ; iIt != iEnd; ++iIt )
|
2007-12-31 17:35:22 +00:00
|
|
|
if ( (*iIt)->pageNumber() == pageNumber && (*iIt)->isVisible() )
|
2004-12-21 12:38:52 +00:00
|
|
|
{
|
|
|
|
// update item's rectangle plus the little outline
|
|
|
|
QRect expandedRect = (*iIt)->geometry();
|
2006-03-29 16:46:09 +00:00
|
|
|
expandedRect.adjust( -1, -1, 3, 3 );
|
2006-10-07 14:40:32 +00:00
|
|
|
widget()->update( expandedRect );
|
2005-01-02 11:50:38 +00:00
|
|
|
|
2005-01-02 13:40:40 +00:00
|
|
|
// if we were "zoom-dragging" do not overwrite the "zoom-drag" cursor
|
2005-01-09 23:37:07 +00:00
|
|
|
if ( cursor().shape() != Qt::SizeVerCursor )
|
2005-01-02 11:50:38 +00:00
|
|
|
{
|
2005-01-09 23:37:07 +00:00
|
|
|
// since the page has been regenerated below cursor, update it
|
2006-10-07 14:40:32 +00:00
|
|
|
updateCursor( widget()->mapFromGlobal( QCursor::pos() ) );
|
2005-01-02 11:50:38 +00:00
|
|
|
}
|
2004-12-21 12:38:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-09 23:37:07 +00:00
|
|
|
void PageView::notifyContentsCleared( int changedFlags )
|
2004-12-21 12:38:52 +00:00
|
|
|
{
|
2005-01-09 23:37:07 +00:00
|
|
|
// if pixmaps were cleared, re-ask them
|
|
|
|
if ( changedFlags & DocumentObserver::Pixmap )
|
2006-10-19 21:18:39 +00:00
|
|
|
QMetaObject::invokeMethod(this, "slotRequestVisiblePixmaps", Qt::QueuedConnection);
|
2004-12-21 12:38:52 +00:00
|
|
|
}
|
2005-01-09 23:37:07 +00:00
|
|
|
|
2007-07-08 14:25:08 +00:00
|
|
|
void PageView::notifyZoom( int factor )
|
|
|
|
{
|
|
|
|
if ( factor > 0 )
|
|
|
|
updateZoom( ZoomIn );
|
|
|
|
else
|
|
|
|
updateZoom( ZoomOut );
|
|
|
|
}
|
|
|
|
|
2006-11-20 20:10:42 +00:00
|
|
|
bool PageView::canUnloadPixmap( int pageNumber ) const
|
2005-01-09 23:37:07 +00:00
|
|
|
{
|
2006-11-24 19:29:52 +00:00
|
|
|
if ( Okular::Settings::memoryLevel() != Okular::Settings::EnumMemoryLevel::Aggressive )
|
|
|
|
{
|
|
|
|
// if the item is visible, forbid unloading
|
|
|
|
QLinkedList< PageViewItem * >::const_iterator vIt = d->visibleItems.begin(), vEnd = d->visibleItems.end();
|
|
|
|
for ( ; vIt != vEnd; ++vIt )
|
|
|
|
if ( (*vIt)->pageNumber() == pageNumber )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// forbid unloading of the visible items, and of the previous and next
|
|
|
|
QLinkedList< PageViewItem * >::const_iterator vIt = d->visibleItems.begin(), vEnd = d->visibleItems.end();
|
|
|
|
for ( ; vIt != vEnd; ++vIt )
|
|
|
|
if ( abs( (*vIt)->pageNumber() - pageNumber ) <= 1 )
|
|
|
|
return false;
|
|
|
|
}
|
2005-01-09 23:37:07 +00:00
|
|
|
// if hidden premit unloading
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
//END DocumentObserver inherited methods
|
2004-09-26 23:39:39 +00:00
|
|
|
|
2004-10-10 12:42:42 +00:00
|
|
|
//BEGIN widget events
|
2006-10-07 14:40:32 +00:00
|
|
|
void PageView::contentsPaintEvent(QPaintEvent *pe)
|
2006-09-27 10:28:03 +00:00
|
|
|
{
|
2006-10-07 14:40:32 +00:00
|
|
|
// create the rect into contents from the clipped screen rect
|
|
|
|
QRect viewportRect = viewport()->rect();
|
|
|
|
viewportRect.translate( horizontalScrollBar()->value(), verticalScrollBar()->value() );
|
|
|
|
QRect contentsRect = pe->rect().intersect( viewportRect );
|
|
|
|
if ( !contentsRect.isValid() )
|
|
|
|
return;
|
2006-09-27 10:28:03 +00:00
|
|
|
|
2006-10-22 13:49:11 +00:00
|
|
|
#ifdef PAGEVIEW_DEBUG
|
2007-07-31 10:19:48 +00:00
|
|
|
kDebug() << "paintevent" << contentsRect;
|
2006-10-22 13:49:11 +00:00
|
|
|
#endif
|
2006-10-07 14:40:32 +00:00
|
|
|
|
|
|
|
// create the screen painter. a pixel painted at contentsX,contentsY
|
|
|
|
// appears to the top-left corner of the scrollview.
|
|
|
|
QPainter screenPainter( widget() );
|
|
|
|
|
|
|
|
// selectionRect is the normalized mouse selection rect
|
|
|
|
QRect selectionRect = d->mouseSelectionRect;
|
|
|
|
if ( !selectionRect.isNull() )
|
|
|
|
selectionRect = selectionRect.normalized();
|
|
|
|
// selectionRectInternal without the border
|
|
|
|
QRect selectionRectInternal = selectionRect;
|
|
|
|
selectionRectInternal.adjust( 1, 1, -1, -1 );
|
|
|
|
// color for blending
|
|
|
|
QColor selBlendColor = (selectionRect.width() > 8 || selectionRect.height() > 8) ?
|
|
|
|
d->mouseSelectionColor : Qt::red;
|
|
|
|
|
|
|
|
// subdivide region into rects
|
2007-02-03 23:09:40 +00:00
|
|
|
const QVector<QRect> &allRects = pe->region().rects();
|
2006-10-07 14:40:32 +00:00
|
|
|
uint numRects = allRects.count();
|
|
|
|
|
|
|
|
// preprocess rects area to see if it worths or not using subdivision
|
|
|
|
uint summedArea = 0;
|
|
|
|
for ( uint i = 0; i < numRects; i++ )
|
2006-09-27 10:28:03 +00:00
|
|
|
{
|
2006-10-07 14:40:32 +00:00
|
|
|
const QRect & r = allRects[i];
|
|
|
|
summedArea += r.width() * r.height();
|
2006-09-27 10:28:03 +00:00
|
|
|
}
|
2006-10-07 14:40:32 +00:00
|
|
|
// very elementary check: SUMj(Region[j].area) is less than boundingRect.area
|
|
|
|
bool useSubdivision = summedArea < (0.6 * contentsRect.width() * contentsRect.height());
|
|
|
|
if ( !useSubdivision )
|
|
|
|
numRects = 1;
|
- Page/Link: tooltips for links backported
- 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
2005-08-10 16:14:39 +00:00
|
|
|
|
2006-10-07 14:40:32 +00:00
|
|
|
// iterate over the rects (only one loop if not using subdivision)
|
|
|
|
for ( uint i = 0; i < numRects; i++ )
|
2004-11-01 14:37:15 +00:00
|
|
|
{
|
2006-10-07 14:40:32 +00:00
|
|
|
if ( useSubdivision )
|
|
|
|
{
|
|
|
|
// set 'contentsRect' to a part of the sub-divided region
|
|
|
|
contentsRect = allRects[i].normalized().intersect( viewportRect );
|
|
|
|
if ( !contentsRect.isValid() )
|
|
|
|
continue;
|
|
|
|
}
|
2006-10-22 13:49:11 +00:00
|
|
|
#ifdef PAGEVIEW_DEBUG
|
2007-07-31 10:19:48 +00:00
|
|
|
kDebug() << contentsRect;
|
2006-10-22 13:49:11 +00:00
|
|
|
#endif
|
2004-10-31 12:43:13 +00:00
|
|
|
|
2006-10-07 14:40:32 +00:00
|
|
|
// note: this check will take care of all things requiring alpha blending (not only selection)
|
|
|
|
bool wantCompositing = !selectionRect.isNull() && contentsRect.intersects( selectionRect );
|
2004-11-08 13:13:46 +00:00
|
|
|
|
2006-10-07 14:40:32 +00:00
|
|
|
if ( wantCompositing && Okular::Settings::enableCompositing() )
|
2004-10-31 13:55:07 +00:00
|
|
|
{
|
2006-10-07 14:40:32 +00:00
|
|
|
// create pixmap and open a painter over it (contents{left,top} becomes pixmap {0,0})
|
|
|
|
QPixmap doubleBuffer( contentsRect.size() );
|
|
|
|
QPainter pixmapPainter( &doubleBuffer );
|
|
|
|
pixmapPainter.translate( -contentsRect.left(), -contentsRect.top() );
|
|
|
|
|
|
|
|
// 1) Layer 0: paint items and clear bg on unpainted rects
|
|
|
|
drawDocumentOnPainter( contentsRect, &pixmapPainter );
|
|
|
|
// 2) Layer 1a: paint (blend) transparent selection
|
|
|
|
if ( !selectionRect.isNull() && selectionRect.intersects( contentsRect ) &&
|
|
|
|
!selectionRectInternal.contains( contentsRect ) )
|
2004-10-31 17:04:04 +00:00
|
|
|
{
|
2006-10-07 14:40:32 +00:00
|
|
|
QRect blendRect = selectionRectInternal.intersect( contentsRect );
|
|
|
|
// skip rectangles covered by the selection's border
|
|
|
|
if ( blendRect.isValid() )
|
|
|
|
{
|
|
|
|
// grab current pixmap into a new one to colorize contents
|
|
|
|
QPixmap blendedPixmap( blendRect.width(), blendRect.height() );
|
|
|
|
QPainter p( &blendedPixmap );
|
|
|
|
p.drawPixmap( 0, 0, doubleBuffer,
|
|
|
|
blendRect.left() - contentsRect.left(), blendRect.top() - contentsRect.top(),
|
|
|
|
blendRect.width(), blendRect.height() );
|
2006-10-17 21:26:43 +00:00
|
|
|
|
|
|
|
QColor blCol = selBlendColor.dark( 140 );
|
2007-05-19 10:42:10 +00:00
|
|
|
blCol.setAlphaF( 0.2 );
|
|
|
|
p.fillRect( blendedPixmap.rect(), blCol );
|
2006-10-07 14:40:32 +00:00
|
|
|
// copy the blended pixmap back to its place
|
|
|
|
pixmapPainter.drawPixmap( blendRect.left(), blendRect.top(), blendedPixmap );
|
|
|
|
}
|
|
|
|
// draw border (red if the selection is too small)
|
|
|
|
pixmapPainter.setPen( selBlendColor );
|
2007-12-09 16:14:24 +00:00
|
|
|
pixmapPainter.drawRect( selectionRect.adjusted( 0, 0, -1, -1 ) );
|
2006-10-07 14:40:32 +00:00
|
|
|
}
|
|
|
|
// 3) Layer 1: give annotator painting control
|
|
|
|
if ( d->annotator && d->annotator->routePaints( contentsRect ) )
|
|
|
|
d->annotator->routePaint( &pixmapPainter, contentsRect );
|
|
|
|
// 4) Layer 2: overlays
|
|
|
|
if ( Okular::Settings::debugDrawBoundaries() )
|
|
|
|
{
|
|
|
|
pixmapPainter.setPen( Qt::blue );
|
|
|
|
pixmapPainter.drawRect( contentsRect );
|
2004-10-31 17:04:04 +00:00
|
|
|
}
|
2004-10-30 20:54:48 +00:00
|
|
|
|
2006-10-07 14:40:32 +00:00
|
|
|
// finish painting and draw contents
|
|
|
|
pixmapPainter.end();
|
|
|
|
screenPainter.drawPixmap( contentsRect.left(), contentsRect.top(), doubleBuffer );
|
2004-10-31 13:55:07 +00:00
|
|
|
}
|
2006-10-07 14:40:32 +00:00
|
|
|
else
|
2004-10-31 13:55:07 +00:00
|
|
|
{
|
2006-10-07 14:40:32 +00:00
|
|
|
// 1) Layer 0: paint items and clear bg on unpainted rects
|
|
|
|
drawDocumentOnPainter( contentsRect, &screenPainter );
|
|
|
|
// 2) Layer 1: paint opaque selection
|
|
|
|
if ( !selectionRect.isNull() && selectionRect.intersects( contentsRect ) &&
|
|
|
|
!selectionRectInternal.contains( contentsRect ) )
|
|
|
|
{
|
|
|
|
screenPainter.setPen( palette().color( QPalette::Active, QPalette::Highlight ).dark(110) );
|
|
|
|
screenPainter.drawRect( selectionRect );
|
|
|
|
}
|
|
|
|
// 3) Layer 1: give annotator painting control
|
|
|
|
if ( d->annotator && d->annotator->routePaints( contentsRect ) )
|
|
|
|
d->annotator->routePaint( &screenPainter, contentsRect );
|
|
|
|
// 4) Layer 2: overlays
|
|
|
|
if ( Okular::Settings::debugDrawBoundaries() )
|
|
|
|
{
|
|
|
|
screenPainter.setPen( Qt::red );
|
|
|
|
screenPainter.drawRect( contentsRect );
|
|
|
|
}
|
2004-10-31 13:55:07 +00:00
|
|
|
}
|
2004-10-31 12:43:13 +00:00
|
|
|
}
|
2004-10-29 21:52:06 +00:00
|
|
|
}
|
|
|
|
|
2006-11-19 00:04:16 +00:00
|
|
|
void PageView::resizeEvent( QResizeEvent *e )
|
2004-10-29 21:52:06 +00:00
|
|
|
{
|
2005-02-26 18:05:01 +00:00
|
|
|
if ( d->items.isEmpty() )
|
2006-11-19 00:04:16 +00:00
|
|
|
{
|
|
|
|
widget()->resize(e->size());
|
2005-02-26 18:05:01 +00:00
|
|
|
return;
|
2006-11-19 00:04:16 +00:00
|
|
|
}
|
2005-02-26 18:05:01 +00:00
|
|
|
|
2005-03-24 19:10:41 +00:00
|
|
|
// start a timer that will refresh the pixmap after 0.2s
|
2005-02-26 18:05:01 +00:00
|
|
|
if ( !d->delayResizeTimer )
|
2004-10-29 21:52:06 +00:00
|
|
|
{
|
2005-02-26 18:05:01 +00:00
|
|
|
d->delayResizeTimer = new QTimer( this );
|
2006-05-28 21:52:36 +00:00
|
|
|
d->delayResizeTimer->setSingleShot( true );
|
2005-02-26 18:05:01 +00:00
|
|
|
connect( d->delayResizeTimer, SIGNAL( timeout() ), this, SLOT( slotRelayoutPages() ) );
|
2004-10-29 21:52:06 +00:00
|
|
|
}
|
2006-05-28 21:52:36 +00:00
|
|
|
d->delayResizeTimer->start( 200 );
|
2004-10-29 21:52:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PageView::keyPressEvent( QKeyEvent * e )
|
|
|
|
{
|
|
|
|
e->accept();
|
2005-01-18 16:43:36 +00:00
|
|
|
|
2005-02-01 18:24:16 +00:00
|
|
|
// if performing a selection or dyn zooming, disable keys handling
|
2006-10-28 23:27:44 +00:00
|
|
|
if ( ( d->mouseSelecting && e->key() != Qt::Key_Escape ) || d->mouseMidZooming )
|
2005-02-01 18:24:16 +00:00
|
|
|
return;
|
|
|
|
|
2005-02-02 18:18:26 +00:00
|
|
|
// if viewport is moving, disable keys handling
|
|
|
|
if ( d->viewportMoveActive )
|
|
|
|
return;
|
|
|
|
|
2004-10-29 21:52:06 +00:00
|
|
|
// move/scroll page by using keys
|
|
|
|
switch ( e->key() )
|
|
|
|
{
|
2006-03-24 20:40:02 +00:00
|
|
|
case Qt::Key_Down:
|
|
|
|
case Qt::Key_PageDown:
|
2006-07-04 21:57:19 +00:00
|
|
|
case Qt::Key_Space:
|
2007-07-20 12:18:55 +00:00
|
|
|
case Qt::Key_Up:
|
|
|
|
case Qt::Key_PageUp:
|
|
|
|
case Qt::Key_Backspace:
|
|
|
|
if ( e->key() == Qt::Key_Down
|
|
|
|
|| e->key() == Qt::Key_PageDown
|
|
|
|
|| ( e->key() == Qt::Key_Space && ( e->modifiers() & Qt::ShiftModifier ) != Qt::ShiftModifier ) )
|
2004-11-05 01:11:50 +00:00
|
|
|
{
|
2007-07-20 12:18:55 +00:00
|
|
|
// if in single page mode and at the bottom of the screen, go to next page
|
|
|
|
if ( Okular::Settings::viewContinuous() || verticalScrollBar()->value() < verticalScrollBar()->maximum() )
|
|
|
|
{
|
|
|
|
if ( e->key() == Qt::Key_Down )
|
|
|
|
verticalScrollBar()->triggerAction( QScrollBar::SliderSingleStepAdd );
|
|
|
|
else
|
|
|
|
verticalScrollBar()->triggerAction( QScrollBar::SliderPageStepAdd );
|
|
|
|
}
|
|
|
|
else if ( (int)d->document->currentPage() < d->items.count() - 1 )
|
|
|
|
{
|
|
|
|
// more optimized than document->setNextPage and then move view to top
|
|
|
|
Okular::DocumentViewport newViewport = d->document->viewport();
|
|
|
|
newViewport.pageNumber += d->document->currentPage() ? viewColumns() : 1;
|
|
|
|
if ( newViewport.pageNumber >= (int)d->items.count() )
|
|
|
|
newViewport.pageNumber = d->items.count() - 1;
|
|
|
|
newViewport.rePos.enabled = true;
|
|
|
|
newViewport.rePos.normalizedY = 0.0;
|
|
|
|
d->document->setViewport( newViewport );
|
|
|
|
}
|
2004-11-05 01:11:50 +00:00
|
|
|
}
|
2007-07-20 12:18:55 +00:00
|
|
|
else
|
2005-01-09 23:37:07 +00:00
|
|
|
{
|
2007-07-20 12:18:55 +00:00
|
|
|
// if in single page mode and at the top of the screen, go to \ page
|
|
|
|
if ( Okular::Settings::viewContinuous() || verticalScrollBar()->value() > verticalScrollBar()->minimum() )
|
|
|
|
{
|
|
|
|
if ( e->key() == Qt::Key_Up )
|
|
|
|
verticalScrollBar()->triggerAction( QScrollBar::SliderSingleStepSub );
|
|
|
|
else
|
|
|
|
verticalScrollBar()->triggerAction( QScrollBar::SliderPageStepSub );
|
|
|
|
}
|
|
|
|
else if ( d->document->currentPage() > 0 )
|
|
|
|
{
|
|
|
|
// more optimized than document->setPrevPage and then move view to bottom
|
|
|
|
Okular::DocumentViewport newViewport = d->document->viewport();
|
|
|
|
newViewport.pageNumber -= viewColumns();
|
|
|
|
if ( newViewport.pageNumber < 0 )
|
|
|
|
newViewport.pageNumber = 0;
|
|
|
|
newViewport.rePos.enabled = true;
|
|
|
|
newViewport.rePos.normalizedY = 1.0;
|
|
|
|
d->document->setViewport( newViewport );
|
|
|
|
}
|
2005-01-09 23:37:07 +00:00
|
|
|
}
|
2004-10-29 21:52:06 +00:00
|
|
|
break;
|
2006-03-24 20:40:02 +00:00
|
|
|
case Qt::Key_Left:
|
2006-04-02 12:36:55 +00:00
|
|
|
horizontalScrollBar()->triggerAction( QScrollBar::SliderSingleStepSub );
|
2004-10-29 21:52:06 +00:00
|
|
|
break;
|
2006-03-24 20:40:02 +00:00
|
|
|
case Qt::Key_Right:
|
2006-04-02 12:36:55 +00:00
|
|
|
horizontalScrollBar()->triggerAction( QScrollBar::SliderSingleStepAdd );
|
2004-10-29 21:52:06 +00:00
|
|
|
break;
|
2006-10-28 23:27:44 +00:00
|
|
|
case Qt::Key_Escape:
|
|
|
|
selectionClear();
|
|
|
|
d->mousePressPos = QPoint();
|
|
|
|
if ( d->aPrevAction )
|
|
|
|
{
|
|
|
|
d->aPrevAction->trigger();
|
|
|
|
d->aPrevAction = 0;
|
|
|
|
}
|
|
|
|
break;
|
2006-03-24 20:40:02 +00:00
|
|
|
case Qt::Key_Shift:
|
|
|
|
case Qt::Key_Control:
|
2005-02-01 18:24:16 +00:00
|
|
|
if ( d->autoScrollTimer )
|
2004-10-29 21:52:06 +00:00
|
|
|
{
|
2005-02-01 18:24:16 +00:00
|
|
|
if ( d->autoScrollTimer->isActive() )
|
|
|
|
d->autoScrollTimer->stop();
|
2004-10-29 21:52:06 +00:00
|
|
|
else
|
|
|
|
slotAutoScoll();
|
|
|
|
return;
|
|
|
|
}
|
2006-04-23 15:49:14 +00:00
|
|
|
// else fall trhough
|
2004-10-29 21:52:06 +00:00
|
|
|
default:
|
|
|
|
e->ignore();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// if a known key has been pressed, stop scrolling the page
|
2005-02-01 18:24:16 +00:00
|
|
|
if ( d->autoScrollTimer )
|
2004-10-29 21:52:06 +00:00
|
|
|
{
|
|
|
|
d->scrollIncrement = 0;
|
2005-02-01 18:24:16 +00:00
|
|
|
d->autoScrollTimer->stop();
|
2004-10-29 21:52:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-23 17:45:36 +00:00
|
|
|
void PageView::keyReleaseEvent( QKeyEvent * e )
|
|
|
|
{
|
|
|
|
e->accept();
|
|
|
|
|
|
|
|
if ( d->annotator && d->annotator->routeEvents() )
|
|
|
|
{
|
|
|
|
if ( d->annotator->routeKeyEvent( e ) )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( e->key() == Qt::Key_Escape && d->autoScrollTimer )
|
|
|
|
{
|
|
|
|
d->scrollIncrement = 0;
|
|
|
|
d->autoScrollTimer->stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-14 15:03:12 +00:00
|
|
|
void PageView::inputMethodEvent( QInputMethodEvent * e )
|
|
|
|
{
|
2007-03-17 22:58:41 +00:00
|
|
|
Q_UNUSED(e)
|
2006-08-14 15:03:12 +00:00
|
|
|
}
|
|
|
|
|
2007-07-17 20:58:38 +00:00
|
|
|
static QPoint rotateInRect( const QPoint &rotated, Okular::Rotation rotation )
|
|
|
|
{
|
|
|
|
QPoint ret;
|
|
|
|
|
|
|
|
switch ( rotation )
|
|
|
|
{
|
|
|
|
case Okular::Rotation90:
|
|
|
|
ret = QPoint( rotated.y(), -rotated.x() );
|
|
|
|
break;
|
|
|
|
case Okular::Rotation180:
|
|
|
|
ret = QPoint( -rotated.x(), -rotated.y() );
|
|
|
|
break;
|
|
|
|
case Okular::Rotation270:
|
|
|
|
ret = QPoint( -rotated.y(), rotated.x() );
|
|
|
|
break;
|
|
|
|
case Okular::Rotation0: // no modifications
|
|
|
|
default: // other cases
|
|
|
|
ret = rotated;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-10-29 21:52:06 +00:00
|
|
|
void PageView::contentsMouseMoveEvent( QMouseEvent * e )
|
|
|
|
{
|
2005-01-29 12:32:59 +00:00
|
|
|
// don't perform any mouse action when no document is shown
|
|
|
|
if ( d->items.isEmpty() )
|
|
|
|
return;
|
|
|
|
|
2005-02-01 18:24:16 +00:00
|
|
|
// don't perform any mouse action when viewport is autoscrolling
|
|
|
|
if ( d->viewportMoveActive )
|
|
|
|
return;
|
|
|
|
|
2004-11-16 17:36:02 +00:00
|
|
|
// if holding mouse mid button, perform zoom
|
2006-08-30 14:17:22 +00:00
|
|
|
if ( d->mouseMidZooming && (e->buttons() & Qt::MidButton) )
|
2004-11-16 17:36:02 +00:00
|
|
|
{
|
2005-03-24 19:10:41 +00:00
|
|
|
int mouseY = e->globalPos().y();
|
|
|
|
int deltaY = d->mouseMidLastY - mouseY;
|
|
|
|
|
|
|
|
// wrap mouse from top to bottom
|
|
|
|
QRect mouseContainer = KGlobalSettings::desktopGeometry( this );
|
|
|
|
if ( mouseY <= mouseContainer.top() + 4 &&
|
|
|
|
d->zoomFactor < 3.99 )
|
|
|
|
{
|
|
|
|
mouseY = mouseContainer.bottom() - 5;
|
|
|
|
QCursor::setPos( e->globalPos().x(), mouseY );
|
|
|
|
}
|
|
|
|
// wrap mouse from bottom to top
|
|
|
|
else if ( mouseY >= mouseContainer.bottom() - 4 &&
|
|
|
|
d->zoomFactor > 0.11 )
|
|
|
|
{
|
|
|
|
mouseY = mouseContainer.top() + 5;
|
|
|
|
QCursor::setPos( e->globalPos().x(), mouseY );
|
|
|
|
}
|
|
|
|
// remember last position
|
|
|
|
d->mouseMidLastY = mouseY;
|
|
|
|
|
|
|
|
// update zoom level, perform zoom and redraw
|
|
|
|
if ( deltaY )
|
|
|
|
{
|
|
|
|
d->zoomFactor *= ( 1.0 + ( (double)deltaY / 500.0 ) );
|
|
|
|
updateZoom( ZoomRefreshCurrent );
|
2006-06-03 13:01:15 +00:00
|
|
|
viewport()->repaint();
|
2005-03-24 19:10:41 +00:00
|
|
|
}
|
2004-11-16 17:36:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2004-10-29 21:52:06 +00:00
|
|
|
|
2005-02-18 18:24:45 +00:00
|
|
|
// if we're editing an annotation, dispatch event to it
|
2005-03-04 23:06:24 +00:00
|
|
|
if ( d->annotator && d->annotator->routeEvents() )
|
2005-02-18 18:24:45 +00:00
|
|
|
{
|
2005-03-04 23:06:24 +00:00
|
|
|
PageViewItem * pageItem = pickItemOnPoint( e->x(), e->y() );
|
|
|
|
d->annotator->routeEvent( e, pageItem );
|
2005-02-18 18:24:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-09-28 21:41:50 +00:00
|
|
|
bool leftButton = (e->buttons() == Qt::LeftButton);
|
2006-09-28 22:19:31 +00:00
|
|
|
bool rightButton = (e->buttons() == Qt::RightButton);
|
2004-10-29 21:52:06 +00:00
|
|
|
switch ( d->mouseMode )
|
|
|
|
{
|
|
|
|
case MouseNormal:
|
|
|
|
if ( leftButton )
|
|
|
|
{
|
2007-07-17 20:58:38 +00:00
|
|
|
if ( d->mouseAnn )
|
|
|
|
{
|
|
|
|
PageViewItem * pageItem = pickItemOnPoint( e->x(), e->y() );
|
|
|
|
if ( pageItem )
|
|
|
|
{
|
|
|
|
const QRect & itemRect = pageItem->geometry();
|
|
|
|
QPoint newpos( e->x() - itemRect.left(), e->y() - itemRect.top() );
|
|
|
|
Okular::NormalizedRect r = d->mouseAnn->boundingRectangle();
|
|
|
|
QPoint p( newpos - d->mouseAnnPos );
|
|
|
|
QPointF pf( rotateInRect( p, pageItem->page()->totalOrientation() ) );
|
|
|
|
if ( pageItem->page()->totalOrientation() % 2 == 0 )
|
|
|
|
{
|
|
|
|
pf.rx() /= pageItem->width();
|
|
|
|
pf.ry() /= pageItem->height();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pf.rx() /= pageItem->height();
|
|
|
|
pf.ry() /= pageItem->width();
|
|
|
|
}
|
|
|
|
d->mouseAnn->translate( Okular::NormalizedPoint( pf.x(), pf.y() ) );
|
|
|
|
d->mouseAnnPos = newpos;
|
|
|
|
d->document->modifyPageAnnotation( pageItem->pageNumber(), d->mouseAnn );
|
|
|
|
}
|
|
|
|
}
|
2004-10-29 21:52:06 +00:00
|
|
|
// drag page
|
2007-07-17 20:58:38 +00:00
|
|
|
else if ( !d->mouseGrabPos.isNull() )
|
2004-10-29 21:52:06 +00:00
|
|
|
{
|
2005-03-24 19:10:41 +00:00
|
|
|
QPoint mousePos = e->globalPos();
|
|
|
|
QPoint delta = d->mouseGrabPos - mousePos;
|
|
|
|
|
|
|
|
// wrap mouse from top to bottom
|
|
|
|
QRect mouseContainer = KGlobalSettings::desktopGeometry( this );
|
|
|
|
if ( mousePos.y() <= mouseContainer.top() + 4 &&
|
2006-03-29 13:52:17 +00:00
|
|
|
verticalScrollBar()->value() < verticalScrollBar()->maximum() - 10 )
|
2005-03-24 19:10:41 +00:00
|
|
|
{
|
|
|
|
mousePos.setY( mouseContainer.bottom() - 5 );
|
|
|
|
QCursor::setPos( mousePos );
|
|
|
|
}
|
|
|
|
// wrap mouse from bottom to top
|
|
|
|
else if ( mousePos.y() >= mouseContainer.bottom() - 4 &&
|
|
|
|
verticalScrollBar()->value() > 10 )
|
|
|
|
{
|
|
|
|
mousePos.setY( mouseContainer.top() + 5 );
|
|
|
|
QCursor::setPos( mousePos );
|
|
|
|
}
|
|
|
|
// remember last position
|
|
|
|
d->mouseGrabPos = mousePos;
|
|
|
|
|
2004-10-29 21:52:06 +00:00
|
|
|
// scroll page by position increment
|
2006-10-07 14:40:32 +00:00
|
|
|
horizontalScrollBar()->setValue(horizontalScrollBar()->value() + delta.x());
|
|
|
|
verticalScrollBar()->setValue(verticalScrollBar()->value() + delta.y());
|
2004-10-29 21:52:06 +00:00
|
|
|
}
|
|
|
|
}
|
2006-09-28 22:19:31 +00:00
|
|
|
else if ( rightButton && !d->mousePressPos.isNull() )
|
|
|
|
{
|
|
|
|
// if mouse moves 5 px away from the press point, switch to 'selection'
|
|
|
|
int deltaX = d->mousePressPos.x() - e->globalPos().x(),
|
|
|
|
deltaY = d->mousePressPos.y() - e->globalPos().y();
|
|
|
|
if ( deltaX > 5 || deltaX < -5 || deltaY > 5 || deltaY < -5 )
|
|
|
|
{
|
|
|
|
d->aPrevAction = d->aMouseNormal;
|
|
|
|
d->aMouseSelect->trigger();
|
|
|
|
QPoint newPos(e->x() + deltaX, e->y() + deltaY);
|
|
|
|
selectionStart( newPos, palette().color( QPalette::Active, QPalette::Highlight ).light( 120 ), false );
|
|
|
|
selectionEndPoint( e->pos() );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-01-29 12:32:59 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// only hovering the page, so update the cursor
|
2006-10-07 14:40:32 +00:00
|
|
|
updateCursor( widget()->mapFromGlobal( QCursor::pos() ) );
|
2004-10-31 17:12:52 +00:00
|
|
|
}
|
2004-10-29 21:52:06 +00:00
|
|
|
break;
|
|
|
|
|
2004-11-03 17:35:48 +00:00
|
|
|
case MouseZoom:
|
2004-11-16 17:36:02 +00:00
|
|
|
case MouseSelect:
|
2007-09-14 10:02:33 +00:00
|
|
|
case MouseImageSelect:
|
2005-01-28 17:21:28 +00:00
|
|
|
// set second corner of selection
|
2006-09-26 22:22:01 +00:00
|
|
|
if ( d->mouseSelecting )
|
|
|
|
selectionEndPoint( e->pos() );
|
|
|
|
break;
|
|
|
|
case MouseTextSelect:
|
|
|
|
// if mouse moves 5 px away from the press point and the document soupports text extraction, do 'textselection'
|
|
|
|
if ( !d->mouseTextSelecting && !d->mousePressPos.isNull() && d->document->supportsSearching() && ( ( e->pos() - d->mouseSelectPos ).manhattanLength() > 5 ) )
|
|
|
|
{
|
|
|
|
d->mouseTextSelecting = true;
|
|
|
|
}
|
|
|
|
if ( d->mouseTextSelecting )
|
|
|
|
{
|
2006-10-03 17:13:42 +00:00
|
|
|
int first = -1;
|
|
|
|
QList< Okular::RegularAreaRect * > selections = textSelections( e->pos(), d->mouseSelectPos, first );
|
2006-09-26 22:22:01 +00:00
|
|
|
QSet< int > pagesWithSelectionSet;
|
2006-10-03 17:13:42 +00:00
|
|
|
for ( int i = 0; i < selections.count(); ++i )
|
|
|
|
pagesWithSelectionSet.insert( i + first );
|
2006-09-26 22:22:01 +00:00
|
|
|
|
|
|
|
QSet< int > noMoreSelectedPages = d->pagesWithTextSelection - pagesWithSelectionSet;
|
|
|
|
// clear the selection from pages not selected anymore
|
|
|
|
foreach( int p, noMoreSelectedPages )
|
|
|
|
{
|
|
|
|
d->document->setPageTextSelection( p, 0, QColor() );
|
|
|
|
}
|
2006-10-03 17:13:42 +00:00
|
|
|
// set the new selection for the selected pages
|
|
|
|
foreach( int p, pagesWithSelectionSet )
|
|
|
|
{
|
|
|
|
d->document->setPageTextSelection( p, selections[ p - first ], palette().color( QPalette::Active, QPalette::Highlight ) );
|
|
|
|
}
|
2006-09-26 22:22:01 +00:00
|
|
|
d->pagesWithTextSelection = pagesWithSelectionSet;
|
|
|
|
}
|
2007-09-07 19:57:46 +00:00
|
|
|
updateCursor( widget()->mapFromGlobal( QCursor::pos() ) );
|
2004-10-29 21:52:06 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-26 23:39:39 +00:00
|
|
|
void PageView::contentsMousePressEvent( QMouseEvent * e )
|
|
|
|
{
|
2005-01-29 12:32:59 +00:00
|
|
|
// don't perform any mouse action when no document is shown
|
|
|
|
if ( d->items.isEmpty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// if performing a selection or dyn zooming, disable mouse press
|
2005-06-24 16:41:55 +00:00
|
|
|
if ( d->mouseSelecting || d->mouseMidZooming || d->viewportMoveActive )
|
2005-01-29 12:32:59 +00:00
|
|
|
return;
|
|
|
|
|
2005-02-01 18:24:16 +00:00
|
|
|
// if the page is scrolling, stop it
|
|
|
|
if ( d->autoScrollTimer )
|
|
|
|
{
|
|
|
|
d->scrollIncrement = 0;
|
|
|
|
d->autoScrollTimer->stop();
|
|
|
|
}
|
|
|
|
|
2005-03-24 19:10:41 +00:00
|
|
|
// if pressing mid mouse button while not doing other things, begin 'continuous zoom' mode
|
2006-06-07 20:24:32 +00:00
|
|
|
if ( e->button() == Qt::MidButton )
|
2004-11-16 17:36:02 +00:00
|
|
|
{
|
2005-03-24 19:10:41 +00:00
|
|
|
d->mouseMidZooming = true;
|
|
|
|
d->mouseMidLastY = e->globalPos().y();
|
2006-06-03 13:01:15 +00:00
|
|
|
setCursor( Qt::SizeVerCursor );
|
2004-11-16 17:36:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2004-10-20 16:41:13 +00:00
|
|
|
|
2005-02-18 18:24:45 +00:00
|
|
|
// if we're editing an annotation, dispatch event to it
|
2005-03-04 23:06:24 +00:00
|
|
|
if ( d->annotator && d->annotator->routeEvents() )
|
2005-02-18 18:24:45 +00:00
|
|
|
{
|
2005-03-04 23:06:24 +00:00
|
|
|
PageViewItem * pageItem = pickItemOnPoint( e->x(), e->y() );
|
|
|
|
d->annotator->routeEvent( e, pageItem );
|
2005-02-18 18:24:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-01-29 12:32:59 +00:00
|
|
|
// update press / 'start drag' mouse position
|
|
|
|
d->mousePressPos = e->globalPos();
|
|
|
|
|
2004-10-20 16:41:13 +00:00
|
|
|
// handle mode dependant mouse press actions
|
2006-09-26 22:22:01 +00:00
|
|
|
bool leftButton = e->button() == Qt::LeftButton,
|
|
|
|
rightButton = e->button() == Qt::RightButton;
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
|
|
|
|
// Not sure we should erase the selection when clicking with left.
|
2006-09-26 22:22:01 +00:00
|
|
|
if ( d->mouseMode != MouseTextSelect )
|
2006-06-10 17:06:03 +00:00
|
|
|
textSelectionClear();
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
|
2004-09-26 23:39:39 +00:00
|
|
|
switch ( d->mouseMode )
|
|
|
|
{
|
2005-01-29 12:32:59 +00:00
|
|
|
case MouseNormal: // drag start / click / link following
|
2004-10-20 16:41:13 +00:00
|
|
|
if ( leftButton )
|
2004-09-30 18:16:12 +00:00
|
|
|
{
|
2007-07-17 20:58:38 +00:00
|
|
|
PageViewItem * pageItem = 0;
|
|
|
|
if ( ( e->modifiers() & Qt::ControlModifier ) && ( pageItem = pickItemOnPoint( e->x(), e->y() ) ) )
|
|
|
|
{
|
|
|
|
// find out normalized mouse coords inside current item
|
|
|
|
const QRect & itemRect = pageItem->geometry();
|
|
|
|
double nX = (double)(e->x() - itemRect.left()) / itemRect.width();
|
|
|
|
double nY = (double)(e->y() - itemRect.top()) / itemRect.height();
|
|
|
|
const Okular::ObjectRect * orect = pageItem->page()->objectRect( Okular::ObjectRect::OAnnotation, nX, nY, itemRect.width(), itemRect.height() );
|
|
|
|
d->mouseAnnPos = QPoint( e->x() - itemRect.left(), e->y() - itemRect.top() );
|
|
|
|
if ( orect )
|
|
|
|
d->mouseAnn = ( (Okular::AnnotationObjectRect *)orect )->annotation();
|
|
|
|
// consider no annotation caught if its type is not movable
|
2007-12-24 00:54:21 +00:00
|
|
|
if ( d->mouseAnn && !GuiUtils::canBeMoved( d->mouseAnn ) )
|
2007-07-17 20:58:38 +00:00
|
|
|
d->mouseAnn = 0;
|
|
|
|
}
|
|
|
|
if ( !d->mouseAnn )
|
|
|
|
{
|
2005-01-29 12:32:59 +00:00
|
|
|
d->mouseGrabPos = d->mouseOnRect ? QPoint() : d->mousePressPos;
|
2004-12-10 16:04:45 +00:00
|
|
|
if ( !d->mouseOnRect )
|
2006-06-03 13:01:15 +00:00
|
|
|
setCursor( Qt::SizeAllCursor );
|
2007-07-17 20:58:38 +00:00
|
|
|
}
|
2004-09-30 18:16:12 +00:00
|
|
|
}
|
2006-09-26 22:22:01 +00:00
|
|
|
else if ( rightButton )
|
|
|
|
{
|
|
|
|
PageViewItem * pageItem = pickItemOnPoint( e->x(), e->y() );
|
|
|
|
if ( pageItem )
|
|
|
|
{
|
|
|
|
// find out normalized mouse coords inside current item
|
|
|
|
const QRect & itemRect = pageItem->geometry();
|
|
|
|
double nX = (double)(e->x() - itemRect.left()) / itemRect.width();
|
|
|
|
double nY = (double)(e->y() - itemRect.top()) / itemRect.height();
|
|
|
|
Okular::Annotation * ann = 0;
|
2006-11-23 17:11:04 +00:00
|
|
|
const Okular::ObjectRect * orect = pageItem->page()->objectRect( Okular::ObjectRect::OAnnotation, nX, nY, itemRect.width(), itemRect.height() );
|
2006-09-26 22:22:01 +00:00
|
|
|
if ( orect )
|
|
|
|
ann = ( (Okular::AnnotationObjectRect *)orect )->annotation();
|
|
|
|
if ( ann )
|
|
|
|
{
|
2006-12-30 12:40:54 +00:00
|
|
|
AnnotationPopup popup( ann, d->document, this );
|
|
|
|
popup.setPageNumber( pageItem->pageNumber() );
|
|
|
|
|
|
|
|
connect( &popup, SIGNAL( setAnnotationWindow( Okular::Annotation* ) ),
|
|
|
|
this, SLOT( setAnnotationWindow( Okular::Annotation* ) ) );
|
|
|
|
connect( &popup, SIGNAL( removeAnnotationWindow( Okular::Annotation* ) ),
|
|
|
|
this, SLOT( removeAnnotationWindow( Okular::Annotation* ) ) );
|
|
|
|
|
|
|
|
popup.exec( e->globalPos() );
|
2006-09-26 22:22:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-10-20 16:41:13 +00:00
|
|
|
break;
|
2004-09-26 23:39:39 +00:00
|
|
|
|
2005-01-29 12:32:59 +00:00
|
|
|
case MouseZoom: // set first corner of the zoom rect
|
|
|
|
if ( leftButton )
|
2006-09-26 22:22:01 +00:00
|
|
|
selectionStart( e->pos(), palette().color( QPalette::Active, QPalette::Highlight ), false );
|
2005-01-29 12:32:59 +00:00
|
|
|
else if ( rightButton )
|
|
|
|
updateZoom( ZoomOut );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseSelect: // set first corner of the selection rect
|
2007-09-14 10:02:33 +00:00
|
|
|
case MouseImageSelect:
|
2006-11-03 00:12:23 +00:00
|
|
|
if ( leftButton )
|
|
|
|
{
|
2006-09-26 22:22:01 +00:00
|
|
|
selectionStart( e->pos(), palette().color( QPalette::Active, QPalette::Highlight ).light( 120 ), false );
|
2006-11-03 00:12:23 +00:00
|
|
|
}
|
2004-11-03 17:35:48 +00:00
|
|
|
break;
|
2006-09-26 22:22:01 +00:00
|
|
|
case MouseTextSelect:
|
|
|
|
d->mouseSelectPos = e->pos();
|
|
|
|
if ( !rightButton )
|
|
|
|
{
|
|
|
|
textSelectionClear();
|
|
|
|
}
|
|
|
|
break;
|
2004-09-26 23:39:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-28 13:53:47 +00:00
|
|
|
void PageView::contentsMouseReleaseEvent( QMouseEvent * e )
|
- Page/Link: tooltips for links backported
- 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
2005-08-10 16:14:39 +00:00
|
|
|
{
|
2006-11-22 21:32:21 +00:00
|
|
|
// stop the drag scrolling
|
|
|
|
d->dragScrollTimer.stop();
|
|
|
|
|
2005-02-26 18:05:01 +00:00
|
|
|
// don't perform any mouse action when no document is shown..
|
2005-01-29 12:32:59 +00:00
|
|
|
if ( d->items.isEmpty() )
|
2005-02-26 18:05:01 +00:00
|
|
|
{
|
|
|
|
// ..except for right Clicks (emitted even it viewport is empty)
|
2006-03-24 20:40:02 +00:00
|
|
|
if ( e->button() == Qt::RightButton )
|
2005-02-26 18:05:01 +00:00
|
|
|
emit rightClick( 0, e->globalPos() );
|
2005-01-29 12:32:59 +00:00
|
|
|
return;
|
2005-02-26 18:05:01 +00:00
|
|
|
}
|
2005-01-29 12:32:59 +00:00
|
|
|
|
2005-02-01 18:24:16 +00:00
|
|
|
// don't perform any mouse action when viewport is autoscrolling
|
|
|
|
if ( d->viewportMoveActive )
|
|
|
|
return;
|
|
|
|
|
2004-11-16 17:36:02 +00:00
|
|
|
// handle mode indepent mid buttom zoom
|
2006-06-07 20:24:32 +00:00
|
|
|
if ( d->mouseMidZooming && (e->button() == Qt::MidButton) )
|
2004-11-16 17:36:02 +00:00
|
|
|
{
|
2005-03-24 19:10:41 +00:00
|
|
|
d->mouseMidZooming = false;
|
|
|
|
// request pixmaps since it was disabled during drag
|
|
|
|
slotRequestVisiblePixmaps();
|
|
|
|
// the cursor may now be over a link.. update it
|
2005-01-02 11:50:38 +00:00
|
|
|
updateCursor( e->pos() );
|
2004-11-16 17:36:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-02-18 18:24:45 +00:00
|
|
|
// if we're editing an annotation, dispatch event to it
|
2005-03-04 23:06:24 +00:00
|
|
|
if ( d->annotator && d->annotator->routeEvents() )
|
2005-02-18 18:24:45 +00:00
|
|
|
{
|
2005-03-04 23:06:24 +00:00
|
|
|
PageViewItem * pageItem = pickItemOnPoint( e->x(), e->y() );
|
|
|
|
d->annotator->routeEvent( e, pageItem );
|
2005-02-18 18:24:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-07-17 20:58:38 +00:00
|
|
|
if ( d->mouseAnn )
|
|
|
|
{
|
|
|
|
setCursor( Qt::ArrowCursor );
|
|
|
|
d->mouseAnn = 0;
|
|
|
|
}
|
|
|
|
|
2006-09-26 22:22:01 +00:00
|
|
|
bool leftButton = e->button() == Qt::LeftButton;
|
|
|
|
bool rightButton = e->button() == Qt::RightButton;
|
2004-09-26 23:39:39 +00:00
|
|
|
switch ( d->mouseMode )
|
|
|
|
{
|
2005-01-29 12:32:59 +00:00
|
|
|
case MouseNormal:{
|
2005-01-02 11:50:38 +00:00
|
|
|
// return the cursor to its normal state after dragging
|
2005-01-29 12:32:59 +00:00
|
|
|
if ( cursor().shape() == Qt::SizeAllCursor )
|
|
|
|
updateCursor( e->pos() );
|
2005-01-02 11:50:38 +00:00
|
|
|
|
2005-01-02 17:24:50 +00:00
|
|
|
PageViewItem * pageItem = pickItemOnPoint( e->x(), e->y() );
|
|
|
|
|
2005-01-29 12:32:59 +00:00
|
|
|
// if the mouse has not moved since the press, that's a -click-
|
|
|
|
if ( leftButton && pageItem && d->mousePressPos == e->globalPos())
|
2004-10-02 14:30:30 +00:00
|
|
|
{
|
2005-02-08 15:24:23 +00:00
|
|
|
double nX = (double)(e->x() - pageItem->geometry().left()) / (double)pageItem->width(),
|
|
|
|
nY = (double)(e->y() - pageItem->geometry().top()) / (double)pageItem->height();
|
2006-09-21 08:45:36 +00:00
|
|
|
const Okular::ObjectRect * rect;
|
2007-04-20 12:37:12 +00:00
|
|
|
rect = pageItem->page()->objectRect( Okular::ObjectRect::Action, nX, nY, pageItem->width(), pageItem->height() );
|
2004-12-10 16:04:45 +00:00
|
|
|
if ( rect )
|
2004-10-20 16:41:13 +00:00
|
|
|
{
|
2005-07-15 18:20:57 +00:00
|
|
|
// handle click over a link
|
2007-04-20 12:37:12 +00:00
|
|
|
const Okular::Action * action = static_cast< const Okular::Action * >( rect->object() );
|
2007-04-20 12:49:17 +00:00
|
|
|
d->document->processAction( action );
|
2004-10-20 16:41:13 +00:00
|
|
|
}
|
2005-07-15 18:20:57 +00:00
|
|
|
else
|
2004-10-20 16:41:13 +00:00
|
|
|
{
|
2006-11-17 22:15:15 +00:00
|
|
|
// TODO: find a better way to activate the source reference "links"
|
|
|
|
// for the moment they are activated with Shift + left click
|
2006-11-23 17:11:04 +00:00
|
|
|
rect = e->modifiers() == Qt::ShiftModifier ? pageItem->page()->objectRect( Okular::ObjectRect::SourceRef, nX, nY, pageItem->width(), pageItem->height() ) : 0;
|
2006-11-17 22:15:15 +00:00
|
|
|
if ( rect )
|
|
|
|
{
|
2007-01-02 17:05:49 +00:00
|
|
|
const Okular::SourceReference * ref = static_cast< const Okular::SourceReference * >( rect->object() );
|
2006-11-17 22:15:15 +00:00
|
|
|
d->document->processSourceReference( ref );
|
|
|
|
}
|
|
|
|
#if 0
|
2005-07-15 18:20:57 +00:00
|
|
|
// a link can move us to another page or even to another document, there's no point in trying to
|
|
|
|
// process the click on the image once we have processes the click on the link
|
2006-11-23 17:11:04 +00:00
|
|
|
rect = pageItem->page()->objectRect( Okular::ObjectRect::Image, nX, nY, pageItem->width(), pageItem->height() );
|
2005-07-15 18:20:57 +00:00
|
|
|
if ( rect )
|
|
|
|
{
|
|
|
|
// handle click over a image
|
|
|
|
}
|
|
|
|
/* Enrico and me have decided this is not worth the trouble it generates
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// if not on a rect, the click selects the page
|
|
|
|
// if ( pageItem->pageNumber() != (int)d->document->currentPage() )
|
|
|
|
d->document->setViewportPage( pageItem->pageNumber(), PAGEVIEW_ID );
|
|
|
|
}*/
|
2006-11-17 22:15:15 +00:00
|
|
|
#endif
|
2004-10-20 16:41:13 +00:00
|
|
|
}
|
2004-10-02 14:30:30 +00:00
|
|
|
}
|
2004-12-04 23:23:18 +00:00
|
|
|
else if ( rightButton )
|
2004-09-28 13:53:47 +00:00
|
|
|
{
|
2006-09-26 22:22:01 +00:00
|
|
|
if ( pageItem && d->mousePressPos == e->globalPos() )
|
|
|
|
{
|
|
|
|
double nX = (double)(e->x() - pageItem->geometry().left()) / (double)pageItem->width(),
|
|
|
|
nY = (double)(e->y() - pageItem->geometry().top()) / (double)pageItem->height();
|
|
|
|
const Okular::ObjectRect * rect;
|
2007-04-20 12:37:12 +00:00
|
|
|
rect = pageItem->page()->objectRect( Okular::ObjectRect::Action, nX, nY, pageItem->width(), pageItem->height() );
|
2006-09-26 22:22:01 +00:00
|
|
|
if ( rect )
|
|
|
|
{
|
|
|
|
// handle right click over a link
|
2007-04-20 12:37:12 +00:00
|
|
|
const Okular::Action * link = static_cast< const Okular::Action * >( rect->object() );
|
2006-09-26 22:22:01 +00:00
|
|
|
// creating the menu and its actions
|
|
|
|
KMenu menu( this );
|
|
|
|
QAction * actProcessLink = menu.addAction( i18n( "Follow This Link" ) );
|
|
|
|
QAction * actCopyLinkLocation = 0;
|
2007-05-02 22:50:27 +00:00
|
|
|
if ( dynamic_cast< const Okular::BrowseAction * >( link ) )
|
2007-11-10 18:45:48 +00:00
|
|
|
actCopyLinkLocation = menu.addAction( KIcon( "edit-copy" ), i18n( "Copy Link Address" ) );
|
2006-09-26 22:22:01 +00:00
|
|
|
QAction * res = menu.exec( e->globalPos() );
|
|
|
|
if ( res )
|
|
|
|
{
|
|
|
|
if ( res == actProcessLink )
|
|
|
|
{
|
2007-04-20 12:49:17 +00:00
|
|
|
d->document->processAction( link );
|
2006-09-26 22:22:01 +00:00
|
|
|
}
|
|
|
|
else if ( res == actCopyLinkLocation )
|
|
|
|
{
|
2007-05-02 22:50:27 +00:00
|
|
|
const Okular::BrowseAction * browseLink = static_cast< const Okular::BrowseAction * >( link );
|
2006-09-26 22:22:01 +00:00
|
|
|
QClipboard *cb = QApplication::clipboard();
|
|
|
|
cb->setText( browseLink->url(), QClipboard::Clipboard );
|
|
|
|
if ( cb->supportsSelection() )
|
|
|
|
cb->setText( browseLink->url(), QClipboard::Selection );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// a link can move us to another page or even to another document, there's no point in trying to
|
|
|
|
// process the click on the image once we have processes the click on the link
|
2006-11-23 17:11:04 +00:00
|
|
|
rect = pageItem->page()->objectRect( Okular::ObjectRect::Image, nX, nY, pageItem->width(), pageItem->height() );
|
2006-09-26 22:22:01 +00:00
|
|
|
if ( rect )
|
|
|
|
{
|
|
|
|
// handle right click over a image
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// right click (if not within 5 px of the press point, the mode
|
|
|
|
// had been already changed to 'Selection' instead of 'Normal')
|
|
|
|
emit rightClick( pageItem->page(), e->globalPos() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// right click (if not within 5 px of the press point, the mode
|
|
|
|
// had been already changed to 'Selection' instead of 'Normal')
|
|
|
|
emit rightClick( pageItem ? pageItem->page() : 0, e->globalPos() );
|
|
|
|
}
|
2004-09-28 13:53:47 +00:00
|
|
|
}
|
2004-11-16 17:36:02 +00:00
|
|
|
}break;
|
2004-09-26 23:39:39 +00:00
|
|
|
|
2005-01-29 12:32:59 +00:00
|
|
|
case MouseZoom:
|
|
|
|
// if a selection rect has been defined, zoom into it
|
2005-06-24 16:41:55 +00:00
|
|
|
if ( leftButton && d->mouseSelecting )
|
2004-11-03 17:35:48 +00:00
|
|
|
{
|
2006-03-29 16:46:09 +00:00
|
|
|
QRect selRect = d->mouseSelectionRect.normalized();
|
2005-01-29 12:32:59 +00:00
|
|
|
if ( selRect.width() <= 8 && selRect.height() <= 8 )
|
|
|
|
{
|
|
|
|
selectionClear();
|
2004-11-05 01:11:50 +00:00
|
|
|
break;
|
2005-01-29 12:32:59 +00:00
|
|
|
}
|
2004-11-03 17:35:48 +00:00
|
|
|
|
2004-11-05 01:11:50 +00:00
|
|
|
// find out new zoom ratio and normalized view center (relative to the contentsRect)
|
2006-10-07 14:40:32 +00:00
|
|
|
double zoom = qMin( (double)viewport()->width() / (double)selRect.width(), (double)viewport()->height() / (double)selRect.height() );
|
|
|
|
double nX = (double)(selRect.left() + selRect.right()) / (2.0 * (double)widget()->width());
|
2006-10-30 18:17:11 +00:00
|
|
|
double nY = (double)(selRect.top() + selRect.bottom()) / (2.0 * (double)widget()->height());
|
2004-11-03 17:35:48 +00:00
|
|
|
|
|
|
|
// zoom up to 400%
|
|
|
|
if ( d->zoomFactor <= 4.0 || zoom <= 1.0 )
|
|
|
|
{
|
|
|
|
d->zoomFactor *= zoom;
|
2004-11-05 01:11:50 +00:00
|
|
|
viewport()->setUpdatesEnabled( false );
|
2004-11-03 17:35:48 +00:00
|
|
|
updateZoom( ZoomRefreshCurrent );
|
2004-11-05 01:11:50 +00:00
|
|
|
viewport()->setUpdatesEnabled( true );
|
2004-11-03 17:35:48 +00:00
|
|
|
}
|
|
|
|
|
2004-11-05 01:11:50 +00:00
|
|
|
// recenter view and update the viewport
|
2006-10-30 18:17:11 +00:00
|
|
|
center( (int)(nX * widget()->width()), (int)(nY * widget()->height()) );
|
2006-10-07 14:40:32 +00:00
|
|
|
widget()->update();
|
2004-11-03 17:35:48 +00:00
|
|
|
|
|
|
|
// hide message box and delete overlay window
|
|
|
|
selectionClear();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2007-09-14 10:02:33 +00:00
|
|
|
case MouseSelect:
|
|
|
|
case MouseImageSelect:
|
|
|
|
{
|
2005-06-13 11:28:15 +00:00
|
|
|
// if mouse is released and selection is null this is a rightClick
|
2005-06-24 16:41:55 +00:00
|
|
|
if ( rightButton && !d->mouseSelecting )
|
2005-03-05 15:59:15 +00:00
|
|
|
{
|
|
|
|
PageViewItem * pageItem = pickItemOnPoint( e->x(), e->y() );
|
|
|
|
emit rightClick( pageItem ? pageItem->page() : 0, e->globalPos() );
|
2005-06-13 11:28:15 +00:00
|
|
|
break;
|
2005-03-05 15:59:15 +00:00
|
|
|
}
|
2005-06-13 11:28:15 +00:00
|
|
|
|
2005-01-29 12:32:59 +00:00
|
|
|
// if a selection is defined, display a popup
|
2005-03-24 19:10:41 +00:00
|
|
|
if ( (!leftButton && !d->aPrevAction) || (!rightButton && d->aPrevAction) ||
|
2005-06-24 16:41:55 +00:00
|
|
|
!d->mouseSelecting )
|
2004-11-16 17:36:02 +00:00
|
|
|
break;
|
2004-10-20 16:41:13 +00:00
|
|
|
|
2006-03-29 16:46:09 +00:00
|
|
|
QRect selectionRect = d->mouseSelectionRect.normalized();
|
2005-01-29 12:32:59 +00:00
|
|
|
if ( selectionRect.width() <= 8 && selectionRect.height() <= 8 )
|
2005-01-02 10:46:33 +00:00
|
|
|
{
|
|
|
|
selectionClear();
|
2005-01-29 12:32:59 +00:00
|
|
|
if ( d->aPrevAction )
|
|
|
|
{
|
2006-03-24 20:40:02 +00:00
|
|
|
d->aPrevAction->trigger();
|
2005-01-29 12:32:59 +00:00
|
|
|
d->aPrevAction = 0;
|
|
|
|
}
|
2004-11-16 17:36:02 +00:00
|
|
|
break;
|
2005-01-02 10:46:33 +00:00
|
|
|
}
|
2004-11-03 17:35:48 +00:00
|
|
|
|
- Page/Link: tooltips for links backported
- 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
2005-08-10 16:14:39 +00:00
|
|
|
// if we support text generation
|
2006-05-26 14:32:35 +00:00
|
|
|
QString selectedText;
|
- Page/Link: tooltips for links backported
- 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
2005-08-10 16:14:39 +00:00
|
|
|
if (d->document->supportsSearching())
|
|
|
|
{
|
2006-09-13 12:11:42 +00:00
|
|
|
// grab text in selection by extracting it from all intersected pages
|
2006-09-21 08:45:36 +00:00
|
|
|
const Okular::Page * okularPage=0;
|
2006-11-20 20:10:42 +00:00
|
|
|
QVector< PageViewItem * >::const_iterator iIt = d->items.begin(), iEnd = d->items.end();
|
2006-09-13 12:11:42 +00:00
|
|
|
for ( ; iIt != iEnd; ++iIt )
|
|
|
|
{
|
|
|
|
PageViewItem * item = *iIt;
|
|
|
|
const QRect & itemRect = item->geometry();
|
|
|
|
if ( selectionRect.intersects( itemRect ) )
|
|
|
|
{
|
|
|
|
// request the textpage if there isn't one
|
2006-09-21 08:45:36 +00:00
|
|
|
okularPage= item->page();
|
2007-07-31 10:19:48 +00:00
|
|
|
kWarning() << "checking if page" << item->pageNumber() << "has text:" << okularPage->hasTextPage();
|
2006-11-23 16:09:26 +00:00
|
|
|
if ( !okularPage->hasTextPage() )
|
2006-09-21 08:45:36 +00:00
|
|
|
d->document->requestTextPage( okularPage->number() );
|
2006-09-13 12:11:42 +00:00
|
|
|
// grab text in the rect that intersects itemRect
|
|
|
|
QRect relativeRect = selectionRect.intersect( itemRect );
|
|
|
|
relativeRect.translate( -itemRect.left(), -itemRect.top() );
|
2006-12-24 18:19:18 +00:00
|
|
|
Okular::RegularAreaRect rects;
|
|
|
|
rects.append( Okular::NormalizedRect( relativeRect, item->width(), item->height() ) );
|
|
|
|
selectedText += okularPage->text( &rects );
|
2006-09-13 12:11:42 +00:00
|
|
|
}
|
|
|
|
}
|
- Page/Link: tooltips for links backported
- 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
2005-08-10 16:14:39 +00:00
|
|
|
}
|
2004-11-03 17:35:48 +00:00
|
|
|
|
2004-11-16 17:36:02 +00:00
|
|
|
// popup that ask to copy:text and copy/save:image
|
2006-03-24 20:40:02 +00:00
|
|
|
KMenu menu( this );
|
|
|
|
QAction *textToClipboard = 0, *speakText = 0, *imageToClipboard = 0, *imageToFile = 0;
|
2006-05-26 14:32:35 +00:00
|
|
|
if ( d->document->supportsSearching() && !selectedText.isEmpty() )
|
2004-11-16 17:36:02 +00:00
|
|
|
{
|
2007-02-13 17:45:54 +00:00
|
|
|
menu.addTitle( i18np( "Text (1 character)", "Text (%1 characters)", selectedText.length() ) );
|
2007-03-08 21:41:46 +00:00
|
|
|
textToClipboard = menu.addAction( KIcon("edit-copy"), i18n( "Copy to Clipboard" ) );
|
2007-01-02 22:37:55 +00:00
|
|
|
if ( !d->document->isAllowed( Okular::AllowCopy ) )
|
2006-05-19 18:22:54 +00:00
|
|
|
{
|
2006-04-05 17:49:44 +00:00
|
|
|
textToClipboard->setEnabled( false );
|
2006-05-19 18:22:54 +00:00
|
|
|
textToClipboard->setText( i18n("Copy forbidden by DRM") );
|
|
|
|
}
|
2006-09-21 08:45:36 +00:00
|
|
|
if ( Okular::Settings::useKTTSD() )
|
2007-12-09 16:12:08 +00:00
|
|
|
speakText = menu.addAction( KIcon("text-speak"), i18n( "Speak Text" ) );
|
2004-11-16 17:36:02 +00:00
|
|
|
}
|
2006-04-10 19:50:00 +00:00
|
|
|
menu.addTitle( i18n( "Image (%1 by %2 pixels)", selectionRect.width(), selectionRect.height() ) );
|
2007-12-09 16:12:08 +00:00
|
|
|
imageToClipboard = menu.addAction( KIcon("image-x-generic"), i18n( "Copy to Clipboard" ) );
|
2007-03-08 21:41:46 +00:00
|
|
|
imageToFile = menu.addAction( KIcon("document-save"), i18n( "Save to File..." ) );
|
2006-03-24 20:40:02 +00:00
|
|
|
QAction *choice = menu.exec( e->globalPos() );
|
2006-06-02 10:32:29 +00:00
|
|
|
// check if the user really selected an action
|
2006-06-02 10:30:32 +00:00
|
|
|
if ( choice )
|
|
|
|
{
|
2006-10-21 22:07:05 +00:00
|
|
|
// IMAGE operation chosen
|
2006-03-24 20:40:02 +00:00
|
|
|
if ( choice == imageToClipboard || choice == imageToFile )
|
2004-11-03 17:35:48 +00:00
|
|
|
{
|
2004-11-16 17:36:02 +00:00
|
|
|
// renders page into a pixmap
|
|
|
|
QPixmap copyPix( selectionRect.width(), selectionRect.height() );
|
|
|
|
QPainter copyPainter( ©Pix );
|
|
|
|
copyPainter.translate( -selectionRect.left(), -selectionRect.top() );
|
2005-04-01 16:24:11 +00:00
|
|
|
drawDocumentOnPainter( selectionRect, ©Painter );
|
2004-11-16 17:36:02 +00:00
|
|
|
|
2006-03-24 20:40:02 +00:00
|
|
|
if ( choice == imageToClipboard )
|
2004-11-03 17:35:48 +00:00
|
|
|
{
|
2004-11-16 17:36:02 +00:00
|
|
|
// [2] copy pixmap to clipboard
|
|
|
|
QClipboard *cb = QApplication::clipboard();
|
|
|
|
cb->setPixmap( copyPix, QClipboard::Clipboard );
|
|
|
|
if ( cb->supportsSelection() )
|
|
|
|
cb->setPixmap( copyPix, QClipboard::Selection );
|
2006-04-10 19:50:00 +00:00
|
|
|
d->messageWindow->display( i18n( "Image [%1x%2] copied to clipboard.", copyPix.width(), copyPix.height() ) );
|
2004-11-16 17:36:02 +00:00
|
|
|
}
|
2006-03-24 20:40:02 +00:00
|
|
|
else if ( choice == imageToFile )
|
2004-11-16 17:36:02 +00:00
|
|
|
{
|
|
|
|
// [3] save pixmap to file
|
2006-07-03 10:15:55 +00:00
|
|
|
QString fileName = KFileDialog::getSaveFileName( KUrl(), "image/png image/jpeg", this );
|
2006-06-12 10:51:07 +00:00
|
|
|
if ( fileName.isEmpty() )
|
2004-11-16 17:36:02 +00:00
|
|
|
d->messageWindow->display( i18n( "File not saved." ), PageViewMessage::Warning );
|
|
|
|
else
|
2004-11-03 17:35:48 +00:00
|
|
|
{
|
2006-08-29 21:09:55 +00:00
|
|
|
KMimeType::Ptr mime = KMimeType::findByUrl( fileName );
|
2006-03-24 20:40:02 +00:00
|
|
|
QString type;
|
|
|
|
if ( !mime )
|
2004-11-16 17:36:02 +00:00
|
|
|
type = "PNG";
|
2006-03-24 20:40:02 +00:00
|
|
|
else
|
2006-06-12 10:51:07 +00:00
|
|
|
type = mime->name().section( '/', -1 ).toUpper();
|
|
|
|
copyPix.save( fileName, qPrintable( type ) );
|
|
|
|
d->messageWindow->display( i18n( "Image [%1x%2] saved to %3 file.", copyPix.width(), copyPix.height(), type ) );
|
2004-11-03 17:35:48 +00:00
|
|
|
}
|
|
|
|
}
|
2004-10-20 16:41:13 +00:00
|
|
|
}
|
2006-10-21 22:07:05 +00:00
|
|
|
// TEXT operation chosen
|
2005-01-29 12:32:59 +00:00
|
|
|
else
|
2004-11-16 17:36:02 +00:00
|
|
|
{
|
2006-03-24 20:40:02 +00:00
|
|
|
if ( choice == textToClipboard )
|
2005-01-29 12:32:59 +00:00
|
|
|
{
|
|
|
|
// [1] copy text to clipboard
|
|
|
|
QClipboard *cb = QApplication::clipboard();
|
2006-05-26 14:32:35 +00:00
|
|
|
cb->setText( selectedText, QClipboard::Clipboard );
|
2005-01-29 12:32:59 +00:00
|
|
|
if ( cb->supportsSelection() )
|
2006-05-26 14:32:35 +00:00
|
|
|
cb->setText( selectedText, QClipboard::Selection );
|
2005-01-29 12:32:59 +00:00
|
|
|
}
|
2006-03-24 20:40:02 +00:00
|
|
|
else if ( choice == speakText )
|
2005-01-29 12:32:59 +00:00
|
|
|
{
|
|
|
|
// [2] speech selection using KTTSD
|
2005-02-04 22:35:44 +00:00
|
|
|
// Albert says is this ever necessary?
|
|
|
|
// we already attached on Part constructor
|
2005-03-05 15:59:15 +00:00
|
|
|
// If KTTSD not running, start it.
|
2006-08-28 18:12:22 +00:00
|
|
|
QDBusReply<bool> reply = QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kttsd");
|
2006-07-03 10:15:55 +00:00
|
|
|
bool kttsdactive = false;
|
|
|
|
if ( reply.isValid() )
|
|
|
|
kttsdactive = reply.value();
|
2006-07-09 09:00:08 +00:00
|
|
|
if ( !kttsdactive )
|
2005-03-05 15:59:15 +00:00
|
|
|
{
|
|
|
|
QString error;
|
2006-03-24 20:40:02 +00:00
|
|
|
if (KToolInvocation::startServiceByDesktopName("kttsd", QStringList(), &error))
|
2005-03-05 15:59:15 +00:00
|
|
|
{
|
2006-04-10 19:50:00 +00:00
|
|
|
d->messageWindow->display( i18n("Starting KTTSD Failed: %1", error) );
|
2006-07-09 09:00:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
kttsdactive = true;
|
2005-03-05 15:59:15 +00:00
|
|
|
}
|
|
|
|
}
|
2006-07-09 09:00:08 +00:00
|
|
|
if ( kttsdactive )
|
2005-02-01 17:20:33 +00:00
|
|
|
{
|
2006-07-09 09:00:08 +00:00
|
|
|
// creating the connection to the kspeech interface
|
|
|
|
QDBusInterface kspeech("org.kde.kttsd", "/KSpeech", "org.kde.KSpeech");
|
|
|
|
kspeech.call("setApplicationName", "okular");
|
|
|
|
kspeech.call("say", selectedText, 0);
|
2005-02-01 17:20:33 +00:00
|
|
|
}
|
2005-01-29 12:32:59 +00:00
|
|
|
}
|
2004-11-16 17:36:02 +00:00
|
|
|
}
|
2006-06-02 10:30:32 +00:00
|
|
|
}
|
2004-11-16 17:36:02 +00:00
|
|
|
// clear widget selection and invalidate rect
|
|
|
|
selectionClear();
|
2005-01-28 17:21:28 +00:00
|
|
|
|
|
|
|
// restore previous action if came from it using right button
|
|
|
|
if ( d->aPrevAction )
|
|
|
|
{
|
2006-03-24 20:40:02 +00:00
|
|
|
d->aPrevAction->trigger();
|
2005-01-28 17:21:28 +00:00
|
|
|
d->aPrevAction = 0;
|
|
|
|
}
|
2004-11-16 17:36:02 +00:00
|
|
|
}break;
|
2006-09-26 22:22:01 +00:00
|
|
|
case MouseTextSelect:
|
|
|
|
setCursor( Qt::ArrowCursor );
|
|
|
|
if ( d->mouseTextSelecting )
|
|
|
|
{
|
|
|
|
d->mouseTextSelecting = false;
|
|
|
|
// textSelectionClear();
|
|
|
|
}
|
2006-11-24 21:02:38 +00:00
|
|
|
else if ( !d->mousePressPos.isNull() && rightButton )
|
2006-09-26 22:22:01 +00:00
|
|
|
{
|
2006-11-24 21:02:38 +00:00
|
|
|
KMenu menu( this );
|
2007-03-08 21:41:46 +00:00
|
|
|
QAction *textToClipboard = menu.addAction( KIcon( "edit-copy" ), i18n( "Copy Text" ) );
|
2007-01-02 22:37:55 +00:00
|
|
|
if ( !d->document->isAllowed( Okular::AllowCopy ) )
|
2006-11-24 21:02:38 +00:00
|
|
|
{
|
|
|
|
textToClipboard->setEnabled( false );
|
|
|
|
textToClipboard->setText( i18n("Copy forbidden by DRM") );
|
|
|
|
}
|
|
|
|
QAction *choice = menu.exec( e->globalPos() );
|
|
|
|
// check if the user really selected an action
|
|
|
|
if ( choice )
|
2006-09-26 22:22:01 +00:00
|
|
|
{
|
2006-11-24 21:02:38 +00:00
|
|
|
if ( choice == textToClipboard )
|
|
|
|
copyTextSelection();
|
2006-09-26 22:22:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2004-09-26 23:39:39 +00:00
|
|
|
}
|
2005-01-29 12:32:59 +00:00
|
|
|
|
|
|
|
// reset mouse press / 'drag start' position
|
|
|
|
d->mousePressPos = QPoint();
|
2004-09-26 23:39:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PageView::wheelEvent( QWheelEvent *e )
|
|
|
|
{
|
2005-02-01 18:24:16 +00:00
|
|
|
// don't perform any mouse action when viewport is autoscrolling
|
|
|
|
if ( d->viewportMoveActive )
|
|
|
|
return;
|
|
|
|
|
2006-10-26 20:59:07 +00:00
|
|
|
if ( !d->document->isOpened() )
|
|
|
|
{
|
|
|
|
QScrollArea::wheelEvent( e );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-10-29 21:52:06 +00:00
|
|
|
int delta = e->delta(),
|
|
|
|
vScroll = verticalScrollBar()->value();
|
2004-09-26 23:39:39 +00:00
|
|
|
e->accept();
|
2006-09-26 22:22:01 +00:00
|
|
|
if ( (e->modifiers() & Qt::ControlModifier) == Qt::ControlModifier ) {
|
2004-10-24 07:06:04 +00:00
|
|
|
if ( e->delta() < 0 )
|
2004-09-26 23:39:39 +00:00
|
|
|
slotZoomOut();
|
|
|
|
else
|
|
|
|
slotZoomIn();
|
|
|
|
}
|
2006-09-21 08:45:36 +00:00
|
|
|
else if ( delta <= -120 && !Okular::Settings::viewContinuous() && vScroll == verticalScrollBar()->maximum() )
|
2004-09-30 18:16:12 +00:00
|
|
|
{
|
2004-10-29 21:52:06 +00:00
|
|
|
// go to next page
|
2006-08-30 14:17:22 +00:00
|
|
|
if ( (int)d->document->currentPage() < d->items.count() - 1 )
|
2005-01-09 23:37:07 +00:00
|
|
|
{
|
2005-06-13 11:53:47 +00:00
|
|
|
// more optimized than document->setNextPage and then move view to top
|
2006-09-21 08:45:36 +00:00
|
|
|
Okular::DocumentViewport newViewport = d->document->viewport();
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
newViewport.pageNumber += d->document->currentPage() ? viewColumns() : 1;
|
2005-04-14 11:33:28 +00:00
|
|
|
if ( newViewport.pageNumber >= (int)d->items.count() )
|
|
|
|
newViewport.pageNumber = d->items.count() - 1;
|
2005-06-13 11:53:47 +00:00
|
|
|
newViewport.rePos.enabled = true;
|
|
|
|
newViewport.rePos.normalizedY = 0.0;
|
2005-01-09 23:37:07 +00:00
|
|
|
d->document->setViewport( newViewport );
|
|
|
|
}
|
2004-09-30 18:16:12 +00:00
|
|
|
}
|
2006-09-21 08:45:36 +00:00
|
|
|
else if ( delta >= 120 && !Okular::Settings::viewContinuous() && vScroll == verticalScrollBar()->minimum() )
|
2004-10-29 21:52:06 +00:00
|
|
|
{
|
|
|
|
// go to prev page
|
2005-01-09 23:37:07 +00:00
|
|
|
if ( d->document->currentPage() > 0 )
|
2004-12-12 22:57:54 +00:00
|
|
|
{
|
2005-06-13 11:53:47 +00:00
|
|
|
// more optimized than document->setPrevPage and then move view to bottom
|
2006-09-21 08:45:36 +00:00
|
|
|
Okular::DocumentViewport newViewport = d->document->viewport();
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
newViewport.pageNumber -= viewColumns();
|
2005-04-14 11:33:28 +00:00
|
|
|
if ( newViewport.pageNumber < 0 )
|
|
|
|
newViewport.pageNumber = 0;
|
2005-06-13 11:53:47 +00:00
|
|
|
newViewport.rePos.enabled = true;
|
|
|
|
newViewport.rePos.normalizedY = 1.0;
|
2005-01-09 23:37:07 +00:00
|
|
|
d->document->setViewport( newViewport );
|
2004-12-12 22:57:54 +00:00
|
|
|
}
|
2004-10-29 21:52:06 +00:00
|
|
|
}
|
|
|
|
else
|
2006-10-07 14:40:32 +00:00
|
|
|
QScrollArea::wheelEvent( e );
|
2005-01-02 17:12:35 +00:00
|
|
|
|
2006-10-07 14:40:32 +00:00
|
|
|
QPoint cp = widget()->mapFromGlobal(mapToGlobal(e->pos()));
|
2004-12-26 21:20:17 +00:00
|
|
|
updateCursor(cp);
|
2004-09-30 18:16:12 +00:00
|
|
|
}
|
|
|
|
|
2004-09-26 23:39:39 +00:00
|
|
|
void PageView::dragEnterEvent( QDragEnterEvent * ev )
|
|
|
|
{
|
|
|
|
ev->accept();
|
|
|
|
}
|
|
|
|
|
2006-09-26 22:22:01 +00:00
|
|
|
void PageView::dragMoveEvent( QDragMoveEvent * ev )
|
|
|
|
{
|
|
|
|
ev->accept();
|
|
|
|
}
|
|
|
|
|
2004-09-26 23:39:39 +00:00
|
|
|
void PageView::dropEvent( QDropEvent * ev )
|
|
|
|
{
|
2006-03-24 20:40:02 +00:00
|
|
|
if ( KUrl::List::canDecode( ev->mimeData() ) )
|
|
|
|
emit urlDropped( KUrl::List::fromMimeData( ev->mimeData() ).first() );
|
2004-09-26 23:39:39 +00:00
|
|
|
}
|
|
|
|
//END widget events
|
|
|
|
|
2006-10-03 17:13:42 +00:00
|
|
|
QList< Okular::RegularAreaRect * > PageView::textSelections( const QPoint& start, const QPoint& end, int& firstpage )
|
|
|
|
{
|
|
|
|
firstpage = -1;
|
|
|
|
QList< Okular::RegularAreaRect * > ret;
|
|
|
|
QSet< int > affectedItemsSet;
|
|
|
|
QRect selectionRect = QRect( start, end ).normalized();
|
|
|
|
foreach( PageViewItem * item, d->items )
|
|
|
|
{
|
2007-12-31 17:35:22 +00:00
|
|
|
if ( item->isVisible() && selectionRect.intersects( item->geometry() ) )
|
2006-10-03 17:13:42 +00:00
|
|
|
affectedItemsSet.insert( item->pageNumber() );
|
|
|
|
}
|
2006-12-23 16:36:08 +00:00
|
|
|
#ifdef PAGEVIEW_DEBUG
|
2007-07-31 10:19:48 +00:00
|
|
|
kDebug() << ">>>> item selected by mouse:" << affectedItemsSet.count();
|
2006-12-23 16:36:08 +00:00
|
|
|
#endif
|
2006-10-03 17:13:42 +00:00
|
|
|
|
|
|
|
if ( !affectedItemsSet.isEmpty() )
|
|
|
|
{
|
|
|
|
// is the mouse drag line the ne-sw diagonal of the selection rect?
|
|
|
|
bool direction_ne_sw = start == selectionRect.topRight() || start == selectionRect.bottomLeft();
|
|
|
|
|
|
|
|
int tmpmin = d->document->pages();
|
|
|
|
int tmpmax = 0;
|
|
|
|
foreach( int p, affectedItemsSet )
|
|
|
|
{
|
|
|
|
if ( p < tmpmin ) tmpmin = p;
|
|
|
|
if ( p > tmpmax ) tmpmax = p;
|
|
|
|
}
|
|
|
|
|
|
|
|
PageViewItem * a = pickItemOnPoint( (int)( direction_ne_sw ? selectionRect.right() : selectionRect.left() ), (int)selectionRect.top() );
|
|
|
|
int min = a && ( a->pageNumber() != tmpmax ) ? a->pageNumber() : tmpmin;
|
|
|
|
PageViewItem * b = pickItemOnPoint( (int)( direction_ne_sw ? selectionRect.left() : selectionRect.right() ), (int)selectionRect.bottom() );
|
|
|
|
int max = b && ( b->pageNumber() != tmpmin ) ? b->pageNumber() : tmpmax;
|
|
|
|
|
|
|
|
QList< int > affectedItemsIds;
|
|
|
|
for ( int i = min; i <= max; ++i )
|
|
|
|
affectedItemsIds.append( i );
|
2006-12-23 16:36:08 +00:00
|
|
|
#ifdef PAGEVIEW_DEBUG
|
2007-07-31 10:19:48 +00:00
|
|
|
kDebug() << ">>>> pages:" << affectedItemsIds;
|
2006-12-23 16:36:08 +00:00
|
|
|
#endif
|
2006-10-03 17:13:42 +00:00
|
|
|
firstpage = affectedItemsIds.first();
|
|
|
|
|
|
|
|
if ( affectedItemsIds.count() == 1 )
|
|
|
|
{
|
|
|
|
PageViewItem * item = d->items[ affectedItemsIds.first() ];
|
|
|
|
selectionRect.translate( -item->geometry().topLeft() );
|
|
|
|
ret.append( textSelectionForItem( item,
|
|
|
|
direction_ne_sw ? selectionRect.topRight() : selectionRect.topLeft(),
|
|
|
|
direction_ne_sw ? selectionRect.bottomLeft() : selectionRect.bottomRight() ) );
|
|
|
|
}
|
|
|
|
else if ( affectedItemsIds.count() > 1 )
|
|
|
|
{
|
|
|
|
// first item
|
|
|
|
PageViewItem * first = d->items[ affectedItemsIds.first() ];
|
|
|
|
QRect geom = first->geometry().intersect( selectionRect ).translated( -first->geometry().topLeft() );
|
|
|
|
ret.append( textSelectionForItem( first,
|
|
|
|
selectionRect.bottom() > geom.height() ? ( direction_ne_sw ? geom.topRight() : geom.topLeft() ) : ( direction_ne_sw ? geom.bottomRight() : geom.bottomLeft() ),
|
|
|
|
QPoint() ) );
|
|
|
|
// last item
|
|
|
|
PageViewItem * last = d->items[ affectedItemsIds.last() ];
|
|
|
|
geom = last->geometry().intersect( selectionRect ).translated( -last->geometry().topLeft() );
|
|
|
|
// the last item needs to appended at last...
|
|
|
|
Okular::RegularAreaRect * lastArea = textSelectionForItem( last,
|
|
|
|
QPoint(),
|
|
|
|
selectionRect.bottom() > geom.height() ? ( direction_ne_sw ? geom.bottomLeft() : geom.bottomRight() ) : ( direction_ne_sw ? geom.topLeft() : geom.topRight() ) );
|
|
|
|
affectedItemsIds.removeFirst();
|
|
|
|
affectedItemsIds.removeLast();
|
|
|
|
// item between the two above
|
|
|
|
foreach( int page, affectedItemsIds )
|
|
|
|
{
|
|
|
|
ret.append( textSelectionForItem( d->items[ page ] ) );
|
|
|
|
}
|
|
|
|
ret.append( lastArea );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-01 16:24:11 +00:00
|
|
|
void PageView::drawDocumentOnPainter( const QRect & contentsRect, QPainter * p )
|
2004-10-30 20:54:48 +00:00
|
|
|
{
|
|
|
|
// when checking if an Item is contained in contentsRect, instead of
|
|
|
|
// growing PageViewItems rects (for keeping outline into account), we
|
|
|
|
// grow the contentsRect
|
|
|
|
QRect checkRect = contentsRect;
|
2006-03-29 16:46:09 +00:00
|
|
|
checkRect.adjust( -3, -3, 1, 1 );
|
2004-10-30 20:54:48 +00:00
|
|
|
|
2006-10-21 22:07:05 +00:00
|
|
|
// create a region from which we'll subtract painted rects
|
2004-11-03 17:35:48 +00:00
|
|
|
QRegion remainingArea( contentsRect );
|
|
|
|
|
2005-04-01 16:24:11 +00:00
|
|
|
// iterate over all items painting the ones intersecting contentsRect
|
2006-11-20 20:10:42 +00:00
|
|
|
QVector< PageViewItem * >::const_iterator iIt = d->items.begin(), iEnd = d->items.end();
|
2004-11-05 00:14:00 +00:00
|
|
|
for ( ; iIt != iEnd; ++iIt )
|
2004-10-30 20:54:48 +00:00
|
|
|
{
|
|
|
|
// check if a piece of the page intersects the contents rect
|
2007-12-31 17:35:22 +00:00
|
|
|
if ( !(*iIt)->isVisible() || !(*iIt)->geometry().intersects( checkRect ) )
|
2004-11-05 18:14:20 +00:00
|
|
|
continue;
|
2004-10-30 20:54:48 +00:00
|
|
|
|
2005-04-01 16:24:11 +00:00
|
|
|
// get item and item's outline geometries
|
2004-11-05 18:14:20 +00:00
|
|
|
PageViewItem * item = *iIt;
|
2005-04-01 16:24:11 +00:00
|
|
|
QRect itemGeometry = item->geometry(),
|
|
|
|
outlineGeometry = itemGeometry;
|
2006-03-29 16:46:09 +00:00
|
|
|
outlineGeometry.adjust( -1, -1, 3, 3 );
|
2004-10-30 20:54:48 +00:00
|
|
|
|
2005-04-01 16:24:11 +00:00
|
|
|
// move the painter to the top-left corner of the page
|
2004-11-05 18:14:20 +00:00
|
|
|
p->save();
|
2005-04-01 16:24:11 +00:00
|
|
|
p->translate( itemGeometry.left(), itemGeometry.top() );
|
2004-11-05 18:14:20 +00:00
|
|
|
|
2005-04-01 16:24:11 +00:00
|
|
|
// draw the page outline (black border and 2px bottom-right shadow)
|
|
|
|
if ( !itemGeometry.contains( contentsRect ) )
|
2004-11-05 18:14:20 +00:00
|
|
|
{
|
2005-04-01 16:24:11 +00:00
|
|
|
int itemWidth = itemGeometry.width(),
|
|
|
|
itemHeight = itemGeometry.height();
|
2004-11-05 18:14:20 +00:00
|
|
|
// draw simple outline
|
|
|
|
p->setPen( Qt::black );
|
2006-10-11 18:26:23 +00:00
|
|
|
p->drawRect( -1, -1, itemWidth + 1, itemHeight + 1 );
|
2004-11-05 18:14:20 +00:00
|
|
|
// draw bottom/right gradient
|
2006-10-11 18:26:23 +00:00
|
|
|
static int levels = 2;
|
2006-03-24 20:40:02 +00:00
|
|
|
int r = QColor(Qt::gray).red() / (levels + 2),
|
|
|
|
g = QColor(Qt::gray).green() / (levels + 2),
|
|
|
|
b = QColor(Qt::gray).blue() / (levels + 2);
|
2004-11-05 18:14:20 +00:00
|
|
|
for ( int i = 0; i < levels; i++ )
|
2004-10-30 20:54:48 +00:00
|
|
|
{
|
2004-11-05 18:14:20 +00:00
|
|
|
p->setPen( QColor( r * (i+2), g * (i+2), b * (i+2) ) );
|
2005-04-01 16:24:11 +00:00
|
|
|
p->drawLine( i, i + itemHeight + 1, i + itemWidth + 1, i + itemHeight + 1 );
|
|
|
|
p->drawLine( i + itemWidth + 1, i, i + itemWidth + 1, i + itemHeight );
|
2004-11-05 18:14:20 +00:00
|
|
|
p->setPen( Qt::gray );
|
2005-04-01 16:24:11 +00:00
|
|
|
p->drawLine( -1, i + itemHeight + 1, i - 1, i + itemHeight + 1 );
|
|
|
|
p->drawLine( i + itemWidth + 1, -1, i + itemWidth + 1, i - 1 );
|
2004-10-30 20:54:48 +00:00
|
|
|
}
|
2004-11-05 18:14:20 +00:00
|
|
|
}
|
2004-10-30 20:54:48 +00:00
|
|
|
|
2006-10-21 22:07:05 +00:00
|
|
|
// draw the page using the PagePainter with all flags active
|
2005-04-01 16:24:11 +00:00
|
|
|
if ( contentsRect.intersects( itemGeometry ) )
|
2004-11-05 18:14:20 +00:00
|
|
|
{
|
2005-04-01 16:24:11 +00:00
|
|
|
QRect pixmapRect = contentsRect.intersect( itemGeometry );
|
2006-03-29 16:46:09 +00:00
|
|
|
pixmapRect.translate( -itemGeometry.left(), -itemGeometry.top() );
|
2006-07-09 11:10:24 +00:00
|
|
|
PagePainter::paintPageOnPainter( p, item->page(), PAGEVIEW_ID, pageflags,
|
2005-04-01 16:24:11 +00:00
|
|
|
itemGeometry.width(), itemGeometry.height(), pixmapRect );
|
2004-10-30 20:54:48 +00:00
|
|
|
}
|
2004-11-05 18:14:20 +00:00
|
|
|
|
|
|
|
// remove painted area from 'remainingArea' and restore painter
|
|
|
|
remainingArea -= outlineGeometry.intersect( contentsRect );
|
|
|
|
p->restore();
|
2004-10-30 20:54:48 +00:00
|
|
|
}
|
2004-11-03 17:35:48 +00:00
|
|
|
|
2005-04-01 16:24:11 +00:00
|
|
|
// fill with background color the unpainted area
|
2007-02-03 23:09:40 +00:00
|
|
|
const QVector<QRect> &backRects = remainingArea.rects();
|
2006-03-24 20:40:02 +00:00
|
|
|
int backRectsNumber = backRects.count();
|
2007-07-22 16:12:30 +00:00
|
|
|
// the previous color here was Qt::gray
|
|
|
|
QColor backColor = widget()->palette().color( QPalette::Dark );
|
2006-03-24 20:40:02 +00:00
|
|
|
for ( int jr = 0; jr < backRectsNumber; jr++ )
|
2005-03-24 19:10:41 +00:00
|
|
|
p->fillRect( backRects[ jr ], backColor );
|
2004-10-30 20:54:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PageView::updateItemSize( PageViewItem * item, int colWidth, int rowHeight )
|
|
|
|
{
|
2006-09-21 08:45:36 +00:00
|
|
|
const Okular::Page * okularPage = item->page();
|
|
|
|
double width = okularPage->width(),
|
|
|
|
height = okularPage->height(),
|
2004-10-30 20:54:48 +00:00
|
|
|
zoom = d->zoomFactor;
|
|
|
|
|
|
|
|
if ( d->zoomMode == ZoomFixed )
|
|
|
|
{
|
|
|
|
width *= zoom;
|
|
|
|
height *= zoom;
|
|
|
|
item->setWHZ( (int)width, (int)height, d->zoomFactor );
|
|
|
|
}
|
|
|
|
else if ( d->zoomMode == ZoomFitWidth )
|
|
|
|
{
|
2006-09-21 08:45:36 +00:00
|
|
|
height = okularPage->ratio() * colWidth;
|
2004-10-30 20:54:48 +00:00
|
|
|
item->setWHZ( colWidth, (int)height, (double)colWidth / width );
|
2005-07-15 18:20:57 +00:00
|
|
|
d->zoomFactor = (double)colWidth / width;
|
2004-10-30 20:54:48 +00:00
|
|
|
}
|
|
|
|
else if ( d->zoomMode == ZoomFitPage )
|
|
|
|
{
|
|
|
|
double scaleW = (double)colWidth / (double)width;
|
|
|
|
double scaleH = (double)rowHeight / (double)height;
|
2006-03-29 17:16:46 +00:00
|
|
|
zoom = qMin( scaleW, scaleH );
|
2004-10-30 20:54:48 +00:00
|
|
|
item->setWHZ( (int)(zoom * width), (int)(zoom * height), zoom );
|
2005-07-15 18:20:57 +00:00
|
|
|
d->zoomFactor = zoom;
|
2004-10-30 20:54:48 +00:00
|
|
|
}
|
|
|
|
#ifndef NDEBUG
|
|
|
|
else
|
2007-07-31 10:19:48 +00:00
|
|
|
kDebug() << "calling updateItemSize with unrecognized d->zoomMode!";
|
2004-10-30 20:54:48 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
PageViewItem * PageView::pickItemOnPoint( int x, int y )
|
|
|
|
{
|
|
|
|
PageViewItem * item = 0;
|
2007-02-03 23:09:40 +00:00
|
|
|
QLinkedList< PageViewItem * >::const_iterator iIt = d->visibleItems.constBegin(), iEnd = d->visibleItems.constEnd();
|
2004-11-05 00:14:00 +00:00
|
|
|
for ( ; iIt != iEnd; ++iIt )
|
2004-10-30 20:54:48 +00:00
|
|
|
{
|
2004-11-05 00:14:00 +00:00
|
|
|
PageViewItem * i = *iIt;
|
2004-10-30 20:54:48 +00:00
|
|
|
const QRect & r = i->geometry();
|
|
|
|
if ( x < r.right() && x > r.left() && y < r.bottom() )
|
|
|
|
{
|
|
|
|
if ( y > r.top() )
|
|
|
|
item = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
2006-09-26 22:22:01 +00:00
|
|
|
void PageView::textSelectionClear()
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
{
|
2006-09-26 22:22:01 +00:00
|
|
|
// something to clear
|
|
|
|
if ( !d->pagesWithTextSelection.isEmpty() )
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
{
|
2006-09-26 22:22:01 +00:00
|
|
|
QSet< int >::ConstIterator it = d->pagesWithTextSelection.constBegin(), itEnd = d->pagesWithTextSelection.constEnd();
|
|
|
|
for ( ; it != itEnd; ++it )
|
|
|
|
d->document->setPageTextSelection( *it, 0, QColor() );
|
|
|
|
d->pagesWithTextSelection.clear();
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
}
|
2006-09-26 22:22:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PageView::selectionStart( const QPoint & pos, const QColor & color, bool /*aboveAll*/ )
|
|
|
|
{
|
|
|
|
selectionClear();
|
|
|
|
d->mouseSelecting = true;
|
|
|
|
d->mouseSelectionRect.setRect( pos.x(), pos.y(), 1, 1 );
|
|
|
|
d->mouseSelectionColor = color;
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
// ensures page doesn't scroll
|
|
|
|
if ( d->autoScrollTimer )
|
|
|
|
{
|
|
|
|
d->scrollIncrement = 0;
|
|
|
|
d->autoScrollTimer->stop();
|
|
|
|
}
|
|
|
|
}
|
2006-09-26 22:22:01 +00:00
|
|
|
|
|
|
|
void PageView::selectionEndPoint( const QPoint & pos )
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
{
|
2006-09-26 22:22:01 +00:00
|
|
|
if ( !d->mouseSelecting )
|
|
|
|
return;
|
2006-06-10 17:06:03 +00:00
|
|
|
|
2006-11-22 21:32:21 +00:00
|
|
|
if (pos.x() < horizontalScrollBar()->value()) d->dragScrollVector.setX(pos.x() - horizontalScrollBar()->value());
|
|
|
|
else if (horizontalScrollBar()->value() + viewport()->width() < pos.x()) d->dragScrollVector.setX(pos.x() - horizontalScrollBar()->value() - viewport()->width());
|
|
|
|
else d->dragScrollVector.setX(0);
|
|
|
|
|
|
|
|
if (pos.y() < verticalScrollBar()->value()) d->dragScrollVector.setY(pos.y() - verticalScrollBar()->value());
|
|
|
|
else if (verticalScrollBar()->value() + viewport()->height() < pos.y()) d->dragScrollVector.setY(pos.y() - verticalScrollBar()->value() - viewport()->height());
|
|
|
|
else d->dragScrollVector.setY(0);
|
|
|
|
|
|
|
|
if (d->dragScrollVector != QPoint(0, 0))
|
|
|
|
{
|
|
|
|
if (!d->dragScrollTimer.isActive()) d->dragScrollTimer.start(100);
|
|
|
|
}
|
|
|
|
else d->dragScrollTimer.stop();
|
|
|
|
|
2006-09-26 22:22:01 +00:00
|
|
|
// update the selection rect
|
|
|
|
QRect updateRect = d->mouseSelectionRect;
|
|
|
|
d->mouseSelectionRect.setBottomLeft( pos );
|
|
|
|
updateRect |= d->mouseSelectionRect;
|
2006-10-07 14:40:32 +00:00
|
|
|
widget()->update( updateRect.adjusted( -1, -1, 1, 1 ) );
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
}
|
|
|
|
|
2007-09-03 19:35:55 +00:00
|
|
|
static Okular::NormalizedPoint rotateInNormRect( const QPoint &rotated, const QRect &rect, Okular::Rotation rotation )
|
|
|
|
{
|
|
|
|
Okular::NormalizedPoint ret;
|
|
|
|
|
|
|
|
switch ( rotation )
|
|
|
|
{
|
|
|
|
case Okular::Rotation0:
|
|
|
|
ret = Okular::NormalizedPoint( rotated.x(), rotated.y(), rect.width(), rect.height() );
|
|
|
|
break;
|
|
|
|
case Okular::Rotation90:
|
|
|
|
ret = Okular::NormalizedPoint( rotated.y(), rect.width() - rotated.x(), rect.height(), rect.width() );
|
|
|
|
break;
|
|
|
|
case Okular::Rotation180:
|
|
|
|
ret = Okular::NormalizedPoint( rect.width() - rotated.x(), rect.height() - rotated.y(), rect.width(), rect.height() );
|
|
|
|
break;
|
|
|
|
case Okular::Rotation270:
|
|
|
|
ret = Okular::NormalizedPoint( rect.height() - rotated.y(), rotated.x(), rect.height(), rect.width() );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-10-03 17:13:42 +00:00
|
|
|
Okular::RegularAreaRect * PageView::textSelectionForItem( PageViewItem * item, const QPoint & startPoint, const QPoint & endPoint )
|
2004-09-26 23:39:39 +00:00
|
|
|
{
|
2006-09-26 22:22:01 +00:00
|
|
|
const QRect & geometry = item->geometry();
|
|
|
|
Okular::NormalizedPoint startCursor( 0.0, 0.0 );
|
|
|
|
if ( !startPoint.isNull() )
|
2004-10-29 21:52:06 +00:00
|
|
|
{
|
2007-09-03 19:35:55 +00:00
|
|
|
startCursor = rotateInNormRect( startPoint, geometry, item->page()->rotation() );
|
2004-10-29 21:52:06 +00:00
|
|
|
}
|
2006-09-26 22:22:01 +00:00
|
|
|
Okular::NormalizedPoint endCursor( 1.0, 1.0 );
|
|
|
|
if ( !endPoint.isNull() )
|
|
|
|
{
|
2007-09-03 19:35:55 +00:00
|
|
|
endCursor = rotateInNormRect( endPoint, geometry, item->page()->rotation() );
|
2006-09-26 22:22:01 +00:00
|
|
|
}
|
|
|
|
Okular::TextSelection mouseTextSelectionInfo( startCursor, endCursor );
|
2004-09-26 23:39:39 +00:00
|
|
|
|
2006-09-26 22:22:01 +00:00
|
|
|
const Okular::Page * okularPage = item->page();
|
|
|
|
|
2006-11-23 16:09:26 +00:00
|
|
|
if ( !okularPage->hasTextPage() )
|
2006-09-26 22:22:01 +00:00
|
|
|
d->document->requestTextPage( okularPage->number() );
|
|
|
|
|
2006-11-23 17:11:04 +00:00
|
|
|
Okular::RegularAreaRect * selectionArea = okularPage->textArea( &mouseTextSelectionInfo );
|
2006-12-23 16:36:08 +00:00
|
|
|
#ifdef PAGEVIEW_DEBUG
|
2007-07-31 10:19:48 +00:00
|
|
|
kDebug().nospace() << "text areas (" << okularPage->number() << "): " << ( selectionArea ? QString::number( selectionArea->count() ) : "(none)" );
|
2006-12-23 16:36:08 +00:00
|
|
|
#endif
|
2006-10-03 17:13:42 +00:00
|
|
|
return selectionArea;
|
2004-11-03 17:35:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PageView::selectionClear()
|
|
|
|
{
|
2006-06-11 23:38:12 +00:00
|
|
|
QRect updatedRect = d->mouseSelectionRect.normalized().adjusted( 0, 0, 1, 1 );
|
2005-06-24 16:41:55 +00:00
|
|
|
d->mouseSelecting = false;
|
2006-06-11 23:38:12 +00:00
|
|
|
d->mouseSelectionRect.setCoords( 0, 0, 0, 0 );
|
2006-10-07 14:40:32 +00:00
|
|
|
widget()->update( updatedRect );
|
2004-11-03 17:35:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PageView::updateZoom( ZoomMode newZoomMode )
|
|
|
|
{
|
2004-10-29 21:52:06 +00:00
|
|
|
if ( newZoomMode == ZoomFixed )
|
|
|
|
{
|
|
|
|
if ( d->aZoom->currentItem() == 0 )
|
|
|
|
newZoomMode = ZoomFitWidth;
|
|
|
|
else if ( d->aZoom->currentItem() == 1 )
|
|
|
|
newZoomMode = ZoomFitPage;
|
|
|
|
}
|
2004-09-26 23:39:39 +00:00
|
|
|
|
2004-10-29 21:52:06 +00:00
|
|
|
float newFactor = d->zoomFactor;
|
2007-01-09 11:02:04 +00:00
|
|
|
QAction * checkedZoomAction = 0;
|
2004-10-29 21:52:06 +00:00
|
|
|
switch ( newZoomMode )
|
|
|
|
{
|
2004-11-03 17:35:48 +00:00
|
|
|
case ZoomFixed:{ //ZoomFixed case
|
2004-10-29 21:52:06 +00:00
|
|
|
QString z = d->aZoom->currentText();
|
2006-07-29 12:52:35 +00:00
|
|
|
// kdelibs4 sometimes adds accelerators to actions' text directly :(
|
|
|
|
z.remove ('&');
|
|
|
|
z.remove ('%');
|
|
|
|
newFactor = KGlobal::locale()->readNumber( z ) / 100.0;
|
2004-10-29 21:52:06 +00:00
|
|
|
}break;
|
|
|
|
case ZoomIn:
|
2004-11-05 01:11:50 +00:00
|
|
|
newFactor += (newFactor > 0.99) ? ( newFactor > 1.99 ? 0.5 : 0.2 ) : 0.1;
|
2004-10-29 21:52:06 +00:00
|
|
|
newZoomMode = ZoomFixed;
|
|
|
|
break;
|
|
|
|
case ZoomOut:
|
2007-09-03 21:29:09 +00:00
|
|
|
newFactor -= (newFactor > 1.01) ? ( newFactor > 2.01 ? 0.5 : 0.2 ) : 0.1;
|
2004-10-29 21:52:06 +00:00
|
|
|
newZoomMode = ZoomFixed;
|
|
|
|
break;
|
|
|
|
case ZoomFitWidth:
|
|
|
|
checkedZoomAction = d->aZoomFitWidth;
|
|
|
|
break;
|
|
|
|
case ZoomFitPage:
|
|
|
|
checkedZoomAction = d->aZoomFitPage;
|
|
|
|
break;
|
|
|
|
case ZoomFitText:
|
|
|
|
checkedZoomAction = d->aZoomFitText;
|
|
|
|
break;
|
|
|
|
case ZoomRefreshCurrent:
|
|
|
|
newZoomMode = ZoomFixed;
|
|
|
|
d->zoomFactor = -1;
|
|
|
|
break;
|
|
|
|
}
|
2004-10-30 23:59:09 +00:00
|
|
|
if ( newFactor > 4.0 )
|
|
|
|
newFactor = 4.0;
|
|
|
|
if ( newFactor < 0.1 )
|
|
|
|
newFactor = 0.1;
|
2004-09-26 23:39:39 +00:00
|
|
|
|
2004-10-29 21:52:06 +00:00
|
|
|
if ( newZoomMode != d->zoomMode || (newZoomMode == ZoomFixed && newFactor != d->zoomFactor ) )
|
|
|
|
{
|
2004-10-30 23:59:09 +00:00
|
|
|
// rebuild layout and update the whole viewport
|
2004-10-29 21:52:06 +00:00
|
|
|
d->zoomMode = newZoomMode;
|
|
|
|
d->zoomFactor = newFactor;
|
2005-01-09 23:37:07 +00:00
|
|
|
// be sure to block updates to document's viewport
|
|
|
|
bool prevState = d->blockViewport;
|
|
|
|
d->blockViewport = true;
|
2004-10-29 21:52:06 +00:00
|
|
|
slotRelayoutPages();
|
2005-01-09 23:37:07 +00:00
|
|
|
d->blockViewport = prevState;
|
2004-10-30 23:59:09 +00:00
|
|
|
// request pixmaps
|
|
|
|
slotRequestVisiblePixmaps();
|
|
|
|
// update zoom text
|
2004-10-29 21:52:06 +00:00
|
|
|
updateZoomText();
|
|
|
|
// update actions checked state
|
2007-07-14 12:31:26 +00:00
|
|
|
if ( d->aZoomFitWidth )
|
|
|
|
{
|
2004-10-29 21:52:06 +00:00
|
|
|
d->aZoomFitWidth->setChecked( checkedZoomAction == d->aZoomFitWidth );
|
|
|
|
d->aZoomFitPage->setChecked( checkedZoomAction == d->aZoomFitPage );
|
2007-11-03 12:58:46 +00:00
|
|
|
// d->aZoomFitText->setChecked( checkedZoomAction == d->aZoomFitText );
|
2007-07-14 12:31:26 +00:00
|
|
|
}
|
2005-06-24 16:43:19 +00:00
|
|
|
// store zoom settings
|
2006-09-21 08:45:36 +00:00
|
|
|
Okular::Settings::setZoomMode( newZoomMode );
|
|
|
|
Okular::Settings::setZoomFactor( newFactor );
|
2007-05-23 21:59:12 +00:00
|
|
|
Okular::Settings::self()->writeConfig();
|
2004-10-29 21:52:06 +00:00
|
|
|
}
|
2007-01-28 16:29:48 +00:00
|
|
|
|
|
|
|
d->aZoomIn->setEnabled( d->zoomFactor < 3.9 );
|
|
|
|
d->aZoomOut->setEnabled( d->zoomFactor > 0.2 );
|
2004-09-26 23:39:39 +00:00
|
|
|
}
|
|
|
|
|
2004-10-29 21:52:06 +00:00
|
|
|
void PageView::updateZoomText()
|
2004-09-26 23:39:39 +00:00
|
|
|
{
|
2004-10-29 21:52:06 +00:00
|
|
|
// use current page zoom as zoomFactor if in ZoomFit/* mode
|
2004-11-05 00:14:00 +00:00
|
|
|
if ( d->zoomMode != ZoomFixed && d->items.count() > 0 )
|
2006-03-29 17:16:46 +00:00
|
|
|
d->zoomFactor = d->items[ qMax( 0, (int)d->document->currentPage() ) ]->zoomFactor();
|
2004-10-29 21:52:06 +00:00
|
|
|
float newFactor = d->zoomFactor;
|
2006-04-13 11:24:57 +00:00
|
|
|
d->aZoom->removeAllActions();
|
2004-09-26 23:39:39 +00:00
|
|
|
|
2004-10-29 21:52:06 +00:00
|
|
|
// add items that describe fit actions
|
|
|
|
QStringList translated;
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
translated << i18n("Fit Width") << i18n("Fit Page") /*<< i18n("Fit Text")*/;
|
2004-10-20 16:41:13 +00:00
|
|
|
|
2004-10-29 21:52:06 +00:00
|
|
|
// add percent items
|
|
|
|
QString double_oh( "00" );
|
2006-11-07 19:29:48 +00:00
|
|
|
const float zoomValue[10] = { 0.12, 0.25, 0.33, 0.50, 0.66, 0.75, 1.00, 1.25, 1.50, 2.00 };
|
2004-10-29 21:52:06 +00:00
|
|
|
int idx = 0,
|
|
|
|
selIdx = 2; // use 3 if "fit text" present
|
|
|
|
bool inserted = false; //use: "d->zoomMode != ZoomFixed" to hide Fit/* zoom ratio
|
|
|
|
while ( idx < 10 || !inserted )
|
2004-09-28 13:53:47 +00:00
|
|
|
{
|
2004-10-29 21:52:06 +00:00
|
|
|
float value = idx < 10 ? zoomValue[ idx ] : newFactor;
|
|
|
|
if ( !inserted && newFactor < (value - 0.0001) )
|
|
|
|
value = newFactor;
|
|
|
|
else
|
|
|
|
idx ++;
|
|
|
|
if ( value > (newFactor - 0.0001) && value < (newFactor + 0.0001) )
|
|
|
|
inserted = true;
|
|
|
|
if ( !inserted )
|
|
|
|
selIdx++;
|
|
|
|
QString localValue( KGlobal::locale()->formatNumber( value * 100.0, 2 ) );
|
|
|
|
localValue.remove( KGlobal::locale()->decimalSymbol() + double_oh );
|
2006-11-03 22:09:16 +00:00
|
|
|
// remove a trailing zero in numbers like 66.70
|
|
|
|
if ( localValue.right( 1 ) == QLatin1String( "0" ) && localValue.indexOf( KGlobal::locale()->decimalSymbol() ) > -1 )
|
|
|
|
localValue.chop( 1 );
|
2004-10-29 21:52:06 +00:00
|
|
|
translated << QString( "%1%" ).arg( localValue );
|
2004-09-28 13:53:47 +00:00
|
|
|
}
|
2004-10-29 21:52:06 +00:00
|
|
|
d->aZoom->setItems( translated );
|
|
|
|
|
|
|
|
// select current item in list
|
|
|
|
if ( d->zoomMode == ZoomFitWidth )
|
|
|
|
selIdx = 0;
|
|
|
|
else if ( d->zoomMode == ZoomFitPage )
|
|
|
|
selIdx = 1;
|
|
|
|
else if ( d->zoomMode == ZoomFitText )
|
|
|
|
selIdx = 2;
|
|
|
|
d->aZoom->setCurrentItem( selIdx );
|
2004-09-26 23:39:39 +00:00
|
|
|
}
|
|
|
|
|
2004-12-26 21:20:17 +00:00
|
|
|
void PageView::updateCursor( const QPoint &p )
|
|
|
|
{
|
|
|
|
// detect the underlaying page (if present)
|
|
|
|
PageViewItem * pageItem = pickItemOnPoint( p.x(), p.y() );
|
2007-09-07 19:57:46 +00:00
|
|
|
if ( pageItem )
|
2004-12-26 21:20:17 +00:00
|
|
|
{
|
2005-02-08 15:24:23 +00:00
|
|
|
double nX = (double)(p.x() - pageItem->geometry().left()) / (double)pageItem->width(),
|
|
|
|
nY = (double)(p.y() - pageItem->geometry().top()) / (double)pageItem->height();
|
2004-12-26 21:20:17 +00:00
|
|
|
|
2005-02-09 17:45:16 +00:00
|
|
|
// if over a ObjectRect (of type Link) change cursor to hand
|
2006-09-26 22:22:01 +00:00
|
|
|
if ( d->mouseMode == MouseTextSelect )
|
|
|
|
setCursor( Qt::IBeamCursor );
|
2007-07-17 20:58:38 +00:00
|
|
|
else if ( d->mouseAnn )
|
|
|
|
setCursor( Qt::ClosedHandCursor );
|
2005-01-02 11:50:38 +00:00
|
|
|
else
|
2006-09-26 22:22:01 +00:00
|
|
|
{
|
2007-04-20 12:37:12 +00:00
|
|
|
const Okular::ObjectRect * linkobj = pageItem->page()->objectRect( Okular::ObjectRect::Action, nX, nY, pageItem->width(), pageItem->height() );
|
2006-11-23 17:11:04 +00:00
|
|
|
const Okular::ObjectRect * annotobj = pageItem->page()->objectRect( Okular::ObjectRect::OAnnotation, nX, nY, pageItem->width(), pageItem->height() );
|
2006-10-16 19:19:42 +00:00
|
|
|
if ( linkobj && !annotobj )
|
|
|
|
{
|
|
|
|
d->mouseOnRect = true;
|
2006-09-26 22:22:01 +00:00
|
|
|
setCursor( Qt::PointingHandCursor );
|
2006-10-16 19:19:42 +00:00
|
|
|
}
|
2006-09-26 22:22:01 +00:00
|
|
|
else
|
2006-11-11 13:45:44 +00:00
|
|
|
{
|
|
|
|
d->mouseOnRect = false;
|
2007-07-17 20:58:38 +00:00
|
|
|
if ( annotobj
|
|
|
|
&& ( QApplication::keyboardModifiers() & Qt::ControlModifier )
|
2007-12-24 00:54:21 +00:00
|
|
|
&& GuiUtils::canBeMoved( static_cast< const Okular::AnnotationObjectRect * >( annotobj )->annotation() ) )
|
2007-07-17 20:58:38 +00:00
|
|
|
{
|
|
|
|
setCursor( Qt::OpenHandCursor );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
setCursor( Qt::ArrowCursor );
|
|
|
|
}
|
2006-11-11 13:45:44 +00:00
|
|
|
}
|
2006-09-26 22:22:01 +00:00
|
|
|
}
|
2004-12-26 21:20:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// if there's no page over the cursor and we were showing the pointingHandCursor
|
|
|
|
// go back to the normal one
|
2005-01-02 11:50:38 +00:00
|
|
|
d->mouseOnRect = false;
|
2006-06-03 13:01:15 +00:00
|
|
|
setCursor( Qt::ArrowCursor );
|
2004-12-26 21:20:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-16 19:47:20 +00:00
|
|
|
int PageView::viewColumns() const
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
{
|
2007-05-17 20:46:16 +00:00
|
|
|
int nr = Okular::Settings::viewMode();
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
if (nr<2)
|
|
|
|
return nr+1;
|
2006-09-21 08:45:36 +00:00
|
|
|
return Okular::Settings::viewColumns();
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
}
|
|
|
|
|
2006-10-16 19:47:20 +00:00
|
|
|
int PageView::viewRows() const
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
{
|
2007-05-17 20:46:16 +00:00
|
|
|
if ( Okular::Settings::viewMode() < 2 )
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
return 1;
|
2006-09-21 08:45:36 +00:00
|
|
|
return Okular::Settings::viewRows();
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
}
|
|
|
|
|
2006-10-07 14:40:32 +00:00
|
|
|
void PageView::center(int cx, int cy)
|
|
|
|
{
|
|
|
|
horizontalScrollBar()->setValue(cx - viewport()->width() / 2);
|
|
|
|
verticalScrollBar()->setValue(cy - viewport()->height() / 2);
|
|
|
|
}
|
|
|
|
|
2007-02-25 00:07:59 +00:00
|
|
|
void PageView::toggleFormWidgets( bool on )
|
|
|
|
{
|
2007-02-25 14:59:26 +00:00
|
|
|
bool somehadfocus = false;
|
2007-02-25 00:07:59 +00:00
|
|
|
QVector< PageViewItem * >::const_iterator dIt = d->items.begin(), dEnd = d->items.end();
|
|
|
|
for ( ; dIt != dEnd; ++dIt )
|
|
|
|
{
|
2007-10-18 20:35:34 +00:00
|
|
|
bool hadfocus = (*dIt)->setFormWidgetsVisible( on );
|
|
|
|
somehadfocus = somehadfocus || hadfocus;
|
2007-02-25 00:07:59 +00:00
|
|
|
}
|
2007-02-25 14:59:26 +00:00
|
|
|
if ( somehadfocus )
|
|
|
|
setFocus();
|
2007-02-25 00:07:59 +00:00
|
|
|
d->m_formsVisible = on;
|
2007-06-05 20:49:00 +00:00
|
|
|
if ( d->aToggleForms ) // it may not exist if we are on dummy mode
|
2007-02-25 00:07:59 +00:00
|
|
|
{
|
2007-06-05 20:49:00 +00:00
|
|
|
if ( d->m_formsVisible )
|
|
|
|
{
|
|
|
|
d->aToggleForms->setText( i18n( "Hide Forms" ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
d->aToggleForms->setText( i18n( "Show Forms" ) );
|
|
|
|
}
|
2007-02-25 00:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-29 21:52:06 +00:00
|
|
|
//BEGIN private SLOTS
|
2004-09-30 18:04:09 +00:00
|
|
|
void PageView::slotRelayoutPages()
|
2007-05-17 20:46:16 +00:00
|
|
|
// called by: notifySetup, viewportResizeEvent, slotViewMode, slotContinuousToggled, updateZoom
|
2004-09-27 21:36:25 +00:00
|
|
|
{
|
|
|
|
// set an empty container if we have no pages
|
2004-11-05 00:14:00 +00:00
|
|
|
int pageCount = d->items.count();
|
2004-09-27 21:36:25 +00:00
|
|
|
if ( pageCount < 1 )
|
|
|
|
{
|
2006-10-07 14:40:32 +00:00
|
|
|
setWidgetResizable(true);
|
2004-09-27 21:36:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-02-01 18:24:16 +00:00
|
|
|
// if viewport was auto-moving, stop it
|
|
|
|
if ( d->viewportMoveActive )
|
|
|
|
{
|
|
|
|
d->viewportMoveActive = false;
|
|
|
|
d->viewportMoveTimer->stop();
|
|
|
|
verticalScrollBar()->setEnabled( true );
|
|
|
|
horizontalScrollBar()->setEnabled( true );
|
|
|
|
}
|
|
|
|
|
2004-11-05 00:14:00 +00:00
|
|
|
// common iterator used in this method and viewport parameters
|
2006-11-20 20:10:42 +00:00
|
|
|
QVector< PageViewItem * >::const_iterator iIt, iEnd = d->items.end();
|
2006-10-07 14:40:32 +00:00
|
|
|
int viewportWidth = viewport()->width(),
|
|
|
|
viewportHeight = viewport()->height(),
|
2004-09-30 18:16:12 +00:00
|
|
|
fullWidth = 0,
|
|
|
|
fullHeight = 0;
|
2006-10-07 14:40:32 +00:00
|
|
|
QRect viewportRect( horizontalScrollBar()->value(), verticalScrollBar()->value(), viewportWidth, viewportHeight );
|
2004-11-05 00:14:00 +00:00
|
|
|
|
2005-04-14 11:33:28 +00:00
|
|
|
// handle the 'center first page in row' stuff
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
int nCols = viewColumns();
|
2006-09-21 08:45:36 +00:00
|
|
|
bool centerFirstPage = Okular::Settings::centerFirstPageInRow() && nCols > 1;
|
2007-12-31 17:35:22 +00:00
|
|
|
const bool continuousView = Okular::Settings::viewContinuous();
|
2005-04-14 11:33:28 +00:00
|
|
|
|
2005-03-05 15:59:15 +00:00
|
|
|
// set all items geometry and resize contents. handle 'continuous' and 'single' modes separately
|
2007-12-31 17:35:22 +00:00
|
|
|
|
|
|
|
PageViewItem * currentItem = d->items[ qMax( 0, (int)d->document->currentPage() ) ];
|
|
|
|
|
2005-04-14 11:33:28 +00:00
|
|
|
// handle the 'centering on first row' stuff
|
|
|
|
if ( centerFirstPage )
|
|
|
|
pageCount += nCols - 1;
|
2004-09-27 21:36:25 +00:00
|
|
|
// Here we find out column's width and row's height to compute a table
|
|
|
|
// so we can place widgets 'centered in virtual cells'.
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
int nRows;
|
|
|
|
|
2007-05-17 20:46:16 +00:00
|
|
|
// if ( Okular::Settings::viewMode() < 2 )
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
nRows = (int)ceil( (float)pageCount / (float)nCols );
|
2006-09-21 08:45:36 +00:00
|
|
|
// nRows=(int)ceil( (float)pageCount / (float) Okular::Settings::viewRows() );
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
// else
|
2006-09-21 08:45:36 +00:00
|
|
|
// nRows = Okular::Settings::viewRows();
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
|
|
|
|
int * colWidth = new int[ nCols ],
|
2004-09-27 21:36:25 +00:00
|
|
|
* rowHeight = new int[ nRows ],
|
|
|
|
cIdx = 0,
|
|
|
|
rIdx = 0;
|
|
|
|
for ( int i = 0; i < nCols; i++ )
|
|
|
|
colWidth[ i ] = viewportWidth / nCols;
|
|
|
|
for ( int i = 0; i < nRows; i++ )
|
|
|
|
rowHeight[ i ] = 0;
|
2005-04-14 11:33:28 +00:00
|
|
|
// handle the 'centering on first row' stuff
|
|
|
|
if ( centerFirstPage )
|
2007-12-31 17:35:22 +00:00
|
|
|
{
|
2005-04-14 11:33:28 +00:00
|
|
|
pageCount -= nCols - 1;
|
2007-12-31 17:35:22 +00:00
|
|
|
cIdx += nCols - 1;
|
|
|
|
}
|
2004-09-27 21:36:25 +00:00
|
|
|
|
|
|
|
// 1) find the maximum columns width and rows height for a grid in
|
|
|
|
// which each page must well-fit inside a cell
|
2004-11-05 00:14:00 +00:00
|
|
|
for ( iIt = d->items.begin(); iIt != iEnd; ++iIt )
|
2004-09-26 23:39:39 +00:00
|
|
|
{
|
2004-11-05 00:14:00 +00:00
|
|
|
PageViewItem * item = *iIt;
|
2004-10-30 20:54:48 +00:00
|
|
|
// update internal page size (leaving a little margin in case of Fit* modes)
|
2005-04-14 11:33:28 +00:00
|
|
|
updateItemSize( item, colWidth[ cIdx ] - 6, viewportHeight - 12 );
|
2004-09-27 21:36:25 +00:00
|
|
|
// find row's maximum height and column's max width
|
2005-01-03 15:51:05 +00:00
|
|
|
if ( item->width() + 6 > colWidth[ cIdx ] )
|
|
|
|
colWidth[ cIdx ] = item->width() + 6;
|
2005-04-14 11:33:28 +00:00
|
|
|
if ( item->height() + 12 > rowHeight[ rIdx ] )
|
|
|
|
rowHeight[ rIdx ] = item->height() + 12;
|
|
|
|
// handle the 'centering on first row' stuff
|
2004-09-27 21:36:25 +00:00
|
|
|
// update col/row indices
|
|
|
|
if ( ++cIdx == nCols )
|
2004-09-26 23:39:39 +00:00
|
|
|
{
|
2004-09-27 21:36:25 +00:00
|
|
|
cIdx = 0;
|
|
|
|
rIdx++;
|
2004-09-26 23:39:39 +00:00
|
|
|
}
|
|
|
|
}
|
2004-09-27 21:36:25 +00:00
|
|
|
|
2007-12-31 17:35:22 +00:00
|
|
|
const int pageRowIdx = ( ( centerFirstPage ? nCols - 1 : 0 ) + currentItem->pageNumber() ) / nCols;
|
|
|
|
|
2005-04-14 11:33:28 +00:00
|
|
|
// 2) compute full size
|
|
|
|
for ( int i = 0; i < nCols; i++ )
|
|
|
|
fullWidth += colWidth[ i ];
|
2007-12-31 17:35:22 +00:00
|
|
|
if ( continuousView )
|
|
|
|
{
|
|
|
|
for ( int i = 0; i < nRows; i++ )
|
|
|
|
fullHeight += rowHeight[ i ];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
fullHeight = rowHeight[ pageRowIdx ];
|
2005-04-14 11:33:28 +00:00
|
|
|
|
|
|
|
// 3) arrange widgets inside cells (and refine fullHeight if needed)
|
2004-09-27 21:36:25 +00:00
|
|
|
int insertX = 0,
|
2005-04-14 11:33:28 +00:00
|
|
|
insertY = fullHeight < viewportHeight ? ( viewportHeight - fullHeight ) / 2 : 0;
|
2007-12-31 17:35:22 +00:00
|
|
|
const int origInsertY = insertY;
|
2004-10-30 20:54:48 +00:00
|
|
|
cIdx = 0;
|
|
|
|
rIdx = 0;
|
2007-12-31 17:35:22 +00:00
|
|
|
if ( centerFirstPage )
|
|
|
|
{
|
|
|
|
cIdx += nCols - 1;
|
|
|
|
for ( int i = 0; i < cIdx; ++i )
|
|
|
|
insertX += colWidth[ i ];
|
|
|
|
}
|
2004-11-05 00:14:00 +00:00
|
|
|
for ( iIt = d->items.begin(); iIt != iEnd; ++iIt )
|
2004-09-27 21:36:25 +00:00
|
|
|
{
|
2004-11-05 00:14:00 +00:00
|
|
|
PageViewItem * item = *iIt;
|
2004-10-30 20:54:48 +00:00
|
|
|
int cWidth = colWidth[ cIdx ],
|
2004-09-27 21:36:25 +00:00
|
|
|
rHeight = rowHeight[ rIdx ];
|
2007-12-31 17:35:22 +00:00
|
|
|
if ( continuousView || rIdx == pageRowIdx )
|
2005-04-14 11:33:28 +00:00
|
|
|
{
|
2007-12-31 17:35:22 +00:00
|
|
|
const bool reallyDoCenterFirst = item->pageNumber() == 0 && centerFirstPage;
|
|
|
|
item->moveTo( (reallyDoCenterFirst ? 0 : insertX) + ( (reallyDoCenterFirst ? fullWidth : cWidth) - item->width()) / 2,
|
|
|
|
(continuousView ? insertY : origInsertY) + (rHeight - item->height()) / 2 );
|
|
|
|
item->setVisible( true );
|
2005-04-14 11:33:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-12-31 17:35:22 +00:00
|
|
|
item->moveTo( 0, 0 );
|
|
|
|
item->setVisible( false );
|
2005-04-14 11:33:28 +00:00
|
|
|
}
|
2007-12-31 22:22:38 +00:00
|
|
|
item->setFormWidgetsVisible( d->m_formsVisible );
|
2004-09-27 21:36:25 +00:00
|
|
|
// advance col/row index
|
|
|
|
insertX += cWidth;
|
|
|
|
if ( ++cIdx == nCols )
|
|
|
|
{
|
|
|
|
cIdx = 0;
|
|
|
|
rIdx++;
|
|
|
|
insertX = 0;
|
2005-04-14 11:33:28 +00:00
|
|
|
insertY += rHeight;
|
2004-09-27 21:36:25 +00:00
|
|
|
}
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
#ifdef PAGEVIEW_DEBUG
|
2007-07-31 10:19:48 +00:00
|
|
|
kWarning() << "updating size for pageno" << item->pageNumber() << "to" << item->geometry();
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
#endif
|
2004-09-27 21:36:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
delete [] colWidth;
|
|
|
|
delete [] rowHeight;
|
2004-09-30 18:16:12 +00:00
|
|
|
|
2004-11-05 00:14:00 +00:00
|
|
|
// 3) reset dirty state
|
|
|
|
d->dirtyLayout = false;
|
|
|
|
|
|
|
|
// 4) update scrollview's contents size and recenter view
|
2006-03-30 15:27:27 +00:00
|
|
|
bool wasUpdatesEnabled = viewport()->updatesEnabled();
|
2006-10-08 20:12:02 +00:00
|
|
|
if ( fullWidth != widget()->width() || fullHeight != widget()->height() )
|
2004-09-30 18:16:12 +00:00
|
|
|
{
|
2005-01-09 23:37:07 +00:00
|
|
|
// disable updates and resize the viewportContents
|
2005-01-10 13:43:44 +00:00
|
|
|
if ( wasUpdatesEnabled )
|
|
|
|
viewport()->setUpdatesEnabled( false );
|
2006-10-07 14:40:32 +00:00
|
|
|
setWidgetResizable(false);
|
2006-10-08 18:20:04 +00:00
|
|
|
fullWidth = qMax(fullWidth, viewport()->width());
|
|
|
|
fullHeight = qMax(fullHeight, viewport()->height());
|
2006-10-07 14:40:32 +00:00
|
|
|
widget()->resize( fullWidth, fullHeight );
|
2005-01-10 13:43:44 +00:00
|
|
|
// restore previous viewport if defined and updates enabled
|
|
|
|
if ( wasUpdatesEnabled )
|
2004-11-05 00:14:00 +00:00
|
|
|
{
|
2006-09-21 08:45:36 +00:00
|
|
|
const Okular::DocumentViewport & vp = d->document->viewport();
|
2005-01-10 13:43:44 +00:00
|
|
|
if ( vp.pageNumber >= 0 )
|
|
|
|
{
|
2006-10-07 14:40:32 +00:00
|
|
|
int prevX = horizontalScrollBar()->value(),
|
|
|
|
prevY = verticalScrollBar()->value();
|
2005-01-10 13:43:44 +00:00
|
|
|
const QRect & geometry = d->items[ vp.pageNumber ]->geometry();
|
2005-06-13 11:53:47 +00:00
|
|
|
double nX = vp.rePos.enabled ? vp.rePos.normalizedX : 0.5,
|
|
|
|
nY = vp.rePos.enabled ? vp.rePos.normalizedY : 0.0;
|
2006-10-29 13:42:07 +00:00
|
|
|
center( geometry.left() + qRound( nX * (double)geometry.width() ),
|
|
|
|
geometry.top() + qRound( nY * (double)geometry.height() ) );
|
2005-06-13 10:37:41 +00:00
|
|
|
// center() usually moves the viewport, that requests pixmaps too.
|
|
|
|
// if that doesn't happen we have to request them by hand
|
2006-10-07 14:40:32 +00:00
|
|
|
if ( prevX == horizontalScrollBar()->value() && prevY == verticalScrollBar()->value() )
|
2005-06-13 10:37:41 +00:00
|
|
|
slotRequestVisiblePixmaps();
|
2005-01-10 13:43:44 +00:00
|
|
|
}
|
|
|
|
// or else go to center page
|
|
|
|
else
|
|
|
|
center( fullWidth / 2, 0 );
|
|
|
|
viewport()->setUpdatesEnabled( true );
|
2004-11-05 00:14:00 +00:00
|
|
|
}
|
2004-09-26 23:39:39 +00:00
|
|
|
}
|
2004-09-27 21:36:25 +00:00
|
|
|
|
2005-01-10 13:43:44 +00:00
|
|
|
// 5) update the whole viewport if updated enabled
|
|
|
|
if ( wasUpdatesEnabled )
|
2006-10-07 14:40:32 +00:00
|
|
|
widget()->update();
|
2004-09-30 18:04:09 +00:00
|
|
|
}
|
|
|
|
|
2006-10-07 14:40:32 +00:00
|
|
|
void PageView::slotRequestVisiblePixmaps()
|
2004-09-30 18:16:12 +00:00
|
|
|
{
|
2005-01-21 20:05:36 +00:00
|
|
|
// if requests are blocked (because raised by an unwanted event), exit
|
2005-03-24 19:10:41 +00:00
|
|
|
if ( d->blockPixmapsRequest || d->viewportMoveActive ||
|
|
|
|
d->mouseMidZooming )
|
2005-01-21 20:05:36 +00:00
|
|
|
return;
|
|
|
|
|
2004-09-30 18:16:12 +00:00
|
|
|
// precalc view limits for intersecting with page coords inside the lOOp
|
2006-10-07 14:40:32 +00:00
|
|
|
bool isEvent = !d->blockViewport;
|
|
|
|
QRect viewportRect( horizontalScrollBar()->value(),
|
|
|
|
verticalScrollBar()->value(),
|
|
|
|
viewport()->width(), viewport()->height() );
|
2004-09-30 18:16:12 +00:00
|
|
|
|
2005-01-09 23:37:07 +00:00
|
|
|
// some variables used to determine the viewport
|
2005-01-28 17:21:28 +00:00
|
|
|
int nearPageNumber = -1;
|
|
|
|
double viewportCenterX = (viewportRect.left() + viewportRect.right()) / 2.0,
|
|
|
|
viewportCenterY = (viewportRect.top() + viewportRect.bottom()) / 2.0,
|
|
|
|
focusedX = 0.5,
|
2005-01-09 23:37:07 +00:00
|
|
|
focusedY = 0.0,
|
|
|
|
minDistance = -1.0;
|
|
|
|
|
|
|
|
// iterate over all items
|
2004-12-21 12:38:52 +00:00
|
|
|
d->visibleItems.clear();
|
2006-09-21 08:45:36 +00:00
|
|
|
QLinkedList< Okular::PixmapRequest * > requestedPixmaps;
|
|
|
|
QVector< Okular::VisiblePageRect * > visibleRects;
|
2006-11-20 20:10:42 +00:00
|
|
|
QVector< PageViewItem * >::const_iterator iIt = d->items.begin(), iEnd = d->items.end();
|
2004-11-05 00:14:00 +00:00
|
|
|
for ( ; iIt != iEnd; ++iIt )
|
2004-09-30 18:16:12 +00:00
|
|
|
{
|
2004-12-22 18:21:36 +00:00
|
|
|
PageViewItem * i = *iIt;
|
2007-12-31 17:35:22 +00:00
|
|
|
if ( !i->isVisible() )
|
|
|
|
continue;
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
#ifdef PAGEVIEW_DEBUG
|
2007-07-31 10:19:48 +00:00
|
|
|
kWarning() << "checking page" << i->pageNumber();
|
|
|
|
kWarning().nospace() << "viewportRect is " << viewportRect << ", page item is " << i->geometry() << " intersect : " << viewportRect.intersects( i->geometry() );
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
#endif
|
2005-01-09 23:37:07 +00:00
|
|
|
// if the item doesn't intersect the viewport, skip it
|
2006-06-23 21:11:52 +00:00
|
|
|
QRect intersectionRect = viewportRect.intersect( i->geometry() );
|
|
|
|
if ( intersectionRect.isEmpty() )
|
2004-12-22 18:21:36 +00:00
|
|
|
continue;
|
|
|
|
|
2005-01-09 23:37:07 +00:00
|
|
|
// add the item to the 'visible list'
|
2004-12-22 18:21:36 +00:00
|
|
|
d->visibleItems.push_back( i );
|
2006-09-21 08:45:36 +00:00
|
|
|
Okular::VisiblePageRect * vItem = new Okular::VisiblePageRect( i->pageNumber(), Okular::NormalizedRect( intersectionRect.translated( -i->geometry().topLeft() ), i->geometry().width(), i->geometry().height() ) );
|
2006-06-23 21:11:52 +00:00
|
|
|
visibleRects.push_back( vItem );
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
#ifdef PAGEVIEW_DEBUG
|
2007-07-31 10:19:48 +00:00
|
|
|
kWarning() << "checking for pixmap for page" << i->pageNumber() << "=" << i->page()->hasPixmap( PAGEVIEW_ID, i->width(), i->height() );
|
|
|
|
kWarning() << "checking for text for page" << i->pageNumber() << "=" << i->page()->hasTextPage();
|
2006-11-24 21:44:25 +00:00
|
|
|
#endif
|
2005-01-09 23:37:07 +00:00
|
|
|
// if the item has not the right pixmap, add a request for it
|
2006-11-20 07:53:32 +00:00
|
|
|
if ( !i->page()->hasPixmap( PAGEVIEW_ID, i->width(), i->height() ) )
|
2005-01-18 16:43:36 +00:00
|
|
|
{
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
#ifdef PAGEVIEW_DEBUG
|
2007-07-31 10:19:48 +00:00
|
|
|
kWarning() << "rerequesting visible pixmaps for page" << i->pageNumber() << "!";
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
#endif
|
2006-09-21 08:45:36 +00:00
|
|
|
Okular::PixmapRequest * p = new Okular::PixmapRequest(
|
2006-06-02 20:42:57 +00:00
|
|
|
PAGEVIEW_ID, i->pageNumber(), i->width(), i->height(), PAGEVIEW_PRIO, true );
|
2005-01-18 16:43:36 +00:00
|
|
|
requestedPixmaps.push_back( p );
|
|
|
|
}
|
2005-01-09 23:37:07 +00:00
|
|
|
|
|
|
|
// look for the item closest to viewport center and the relative
|
|
|
|
// position between the item and the viewport center
|
|
|
|
if ( isEvent )
|
|
|
|
{
|
|
|
|
const QRect & geometry = i->geometry();
|
2005-04-14 11:33:28 +00:00
|
|
|
// compute distance between item center and viewport center (slightly moved left)
|
|
|
|
double distance = hypot( (geometry.left() + geometry.right()) / 2 - (viewportCenterX - 4),
|
2005-01-10 13:43:44 +00:00
|
|
|
(geometry.top() + geometry.bottom()) / 2 - viewportCenterY );
|
2005-01-09 23:37:07 +00:00
|
|
|
if ( distance >= minDistance && nearPageNumber != -1 )
|
|
|
|
continue;
|
|
|
|
nearPageNumber = i->pageNumber();
|
|
|
|
minDistance = distance;
|
|
|
|
if ( geometry.height() > 0 && geometry.width() > 0 )
|
|
|
|
{
|
2005-01-28 17:21:28 +00:00
|
|
|
focusedX = ( viewportCenterX - (double)geometry.left() ) / (double)geometry.width();
|
|
|
|
focusedY = ( viewportCenterY - (double)geometry.top() ) / (double)geometry.height();
|
2005-01-09 23:37:07 +00:00
|
|
|
}
|
|
|
|
}
|
2004-12-21 12:38:52 +00:00
|
|
|
}
|
|
|
|
|
2005-01-20 17:33:05 +00:00
|
|
|
// if preloading is enabled, add the pages before and after in preloading
|
|
|
|
if ( !d->visibleItems.isEmpty() &&
|
2006-09-21 08:45:36 +00:00
|
|
|
Okular::Settings::memoryLevel() != Okular::Settings::EnumMemoryLevel::Low &&
|
|
|
|
Okular::Settings::enableThreading() )
|
2005-01-18 16:43:36 +00:00
|
|
|
{
|
2007-01-04 21:47:54 +00:00
|
|
|
// as the requests are done in the order as they appear in the list,
|
|
|
|
// request first the next page and then the previous
|
|
|
|
|
|
|
|
// add the page after the 'visible series' in preload
|
|
|
|
int tailRequest = d->visibleItems.last()->pageNumber() + 1;
|
|
|
|
if ( tailRequest < (int)d->items.count() )
|
2005-01-18 16:43:36 +00:00
|
|
|
{
|
2007-01-04 21:47:54 +00:00
|
|
|
PageViewItem * i = d->items[ tailRequest ];
|
2005-01-20 17:33:05 +00:00
|
|
|
// request the pixmap if not already present
|
2006-11-20 07:53:32 +00:00
|
|
|
if ( !i->page()->hasPixmap( PAGEVIEW_ID, i->width(), i->height() ) && i->width() > 0 )
|
2006-09-21 08:45:36 +00:00
|
|
|
requestedPixmaps.push_back( new Okular::PixmapRequest(
|
2006-06-02 20:42:57 +00:00
|
|
|
PAGEVIEW_ID, i->pageNumber(), i->width(), i->height(), PAGEVIEW_PRELOAD_PRIO, true ) );
|
2005-01-20 17:33:05 +00:00
|
|
|
}
|
|
|
|
|
2007-01-04 21:47:54 +00:00
|
|
|
// add the page before the 'visible series' in preload
|
|
|
|
int headRequest = d->visibleItems.first()->pageNumber() - 1;
|
|
|
|
if ( headRequest >= 0 )
|
2005-01-20 17:33:05 +00:00
|
|
|
{
|
2007-01-04 21:47:54 +00:00
|
|
|
PageViewItem * i = d->items[ headRequest ];
|
2005-01-20 17:33:05 +00:00
|
|
|
// request the pixmap if not already present
|
2006-11-20 07:53:32 +00:00
|
|
|
if ( !i->page()->hasPixmap( PAGEVIEW_ID, i->width(), i->height() ) && i->width() > 0 )
|
2006-09-21 08:45:36 +00:00
|
|
|
requestedPixmaps.push_back( new Okular::PixmapRequest(
|
2006-06-02 20:42:57 +00:00
|
|
|
PAGEVIEW_ID, i->pageNumber(), i->width(), i->height(), PAGEVIEW_PRELOAD_PRIO, true ) );
|
2005-01-18 16:43:36 +00:00
|
|
|
}
|
|
|
|
}
|
2005-01-09 23:37:07 +00:00
|
|
|
|
2005-01-20 17:33:05 +00:00
|
|
|
// send requests to the document
|
|
|
|
if ( !requestedPixmaps.isEmpty() )
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
{
|
2005-01-20 17:33:05 +00:00
|
|
|
d->document->requestPixmaps( requestedPixmaps );
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
}
|
2005-01-28 17:21:28 +00:00
|
|
|
// if this functions was invoked by viewport events, send update to document
|
2005-01-09 23:37:07 +00:00
|
|
|
if ( isEvent && nearPageNumber != -1 )
|
|
|
|
{
|
|
|
|
// determine the document viewport
|
2006-09-21 08:45:36 +00:00
|
|
|
Okular::DocumentViewport newViewport( nearPageNumber );
|
2005-06-13 11:53:47 +00:00
|
|
|
newViewport.rePos.enabled = true;
|
|
|
|
newViewport.rePos.normalizedX = focusedX;
|
|
|
|
newViewport.rePos.normalizedY = focusedY;
|
2005-01-09 23:37:07 +00:00
|
|
|
// set the viewport to other observers
|
2005-01-10 13:43:44 +00:00
|
|
|
d->document->setViewport( newViewport , PAGEVIEW_ID);
|
2005-01-09 23:37:07 +00:00
|
|
|
}
|
2006-06-23 21:11:52 +00:00
|
|
|
d->document->setVisiblePageRects( visibleRects, PAGEVIEW_ID );
|
2004-09-30 18:16:12 +00:00
|
|
|
}
|
2004-10-06 00:05:49 +00:00
|
|
|
|
2005-02-01 18:24:16 +00:00
|
|
|
void PageView::slotMoveViewport()
|
|
|
|
{
|
|
|
|
// converge to viewportMoveDest in 1 second
|
|
|
|
int diffTime = d->viewportMoveTime.elapsed();
|
|
|
|
if ( diffTime >= 667 || !d->viewportMoveActive )
|
|
|
|
{
|
|
|
|
center( d->viewportMoveDest.x(), d->viewportMoveDest.y() );
|
|
|
|
d->viewportMoveTimer->stop();
|
|
|
|
d->viewportMoveActive = false;
|
|
|
|
slotRequestVisiblePixmaps();
|
|
|
|
verticalScrollBar()->setEnabled( true );
|
|
|
|
horizontalScrollBar()->setEnabled( true );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-04-04 23:55:40 +00:00
|
|
|
// move the viewport smoothly (kmplot: p(x)=1+0.47*(x-1)^3-0.25*(x-1)^4)
|
2005-02-01 18:24:16 +00:00
|
|
|
float convergeSpeed = (float)diffTime / 667.0,
|
2006-10-07 14:40:32 +00:00
|
|
|
x = ((float)viewport()->width() / 2.0) + horizontalScrollBar()->value(),
|
|
|
|
y = ((float)viewport()->height() / 2.0) + verticalScrollBar()->value(),
|
2005-02-01 18:24:16 +00:00
|
|
|
diffX = (float)d->viewportMoveDest.x() - x,
|
|
|
|
diffY = (float)d->viewportMoveDest.y() - y;
|
|
|
|
convergeSpeed *= convergeSpeed * (1.4 - convergeSpeed);
|
|
|
|
center( (int)(x + diffX * convergeSpeed),
|
|
|
|
(int)(y + diffY * convergeSpeed ) );
|
|
|
|
}
|
|
|
|
|
2004-10-06 00:05:49 +00:00
|
|
|
void PageView::slotAutoScoll()
|
|
|
|
{
|
|
|
|
// the first time create the timer
|
2005-02-01 18:24:16 +00:00
|
|
|
if ( !d->autoScrollTimer )
|
2004-10-06 00:05:49 +00:00
|
|
|
{
|
2005-02-01 18:24:16 +00:00
|
|
|
d->autoScrollTimer = new QTimer( this );
|
2006-05-28 21:52:36 +00:00
|
|
|
d->autoScrollTimer->setSingleShot( true );
|
2005-02-01 18:24:16 +00:00
|
|
|
connect( d->autoScrollTimer, SIGNAL( timeout() ), this, SLOT( slotAutoScoll() ) );
|
2004-10-06 00:05:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// if scrollIncrement is zero, stop the timer
|
|
|
|
if ( !d->scrollIncrement )
|
|
|
|
{
|
2005-02-01 18:24:16 +00:00
|
|
|
d->autoScrollTimer->stop();
|
2004-10-06 00:05:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// compute delay between timer ticks and scroll amount per tick
|
|
|
|
int index = abs( d->scrollIncrement ) - 1; // 0..9
|
|
|
|
const int scrollDelay[10] = { 200, 100, 50, 30, 20, 30, 25, 20, 30, 20 };
|
|
|
|
const int scrollOffset[10] = { 1, 1, 1, 1, 1, 2, 2, 2, 4, 4 };
|
2006-05-28 21:52:36 +00:00
|
|
|
d->autoScrollTimer->start( scrollDelay[ index ] );
|
2006-10-07 14:40:32 +00:00
|
|
|
int delta = d->scrollIncrement > 0 ? scrollOffset[ index ] : -scrollOffset[ index ];
|
|
|
|
verticalScrollBar()->setValue(verticalScrollBar()->value() + delta);
|
2004-10-06 00:05:49 +00:00
|
|
|
}
|
2004-09-30 18:16:12 +00:00
|
|
|
|
2006-11-22 21:32:21 +00:00
|
|
|
void PageView::slotDragScroll()
|
|
|
|
{
|
|
|
|
horizontalScrollBar()->setValue(horizontalScrollBar()->value() + d->dragScrollVector.x());
|
|
|
|
verticalScrollBar()->setValue(verticalScrollBar()->value() + d->dragScrollVector.y());
|
|
|
|
QPoint p = widget()->mapFromGlobal( QCursor::pos() );
|
|
|
|
selectionEndPoint( p );
|
|
|
|
}
|
|
|
|
|
2006-09-20 13:58:28 +00:00
|
|
|
void PageView::slotShowWelcome()
|
|
|
|
{
|
|
|
|
// show initial welcome text
|
|
|
|
d->messageWindow->display( i18n( "Welcome" ), PageViewMessage::Info, 2000 );
|
|
|
|
}
|
|
|
|
|
2004-10-29 21:52:06 +00:00
|
|
|
void PageView::slotZoom()
|
2004-09-30 18:04:09 +00:00
|
|
|
{
|
2004-12-13 18:21:37 +00:00
|
|
|
setFocus();
|
2004-10-29 21:52:06 +00:00
|
|
|
updateZoom( ZoomFixed );
|
|
|
|
}
|
2004-10-20 16:41:13 +00:00
|
|
|
|
2004-10-29 21:52:06 +00:00
|
|
|
void PageView::slotZoomIn()
|
|
|
|
{
|
|
|
|
updateZoom( ZoomIn );
|
|
|
|
}
|
2004-09-30 18:04:09 +00:00
|
|
|
|
2004-10-29 21:52:06 +00:00
|
|
|
void PageView::slotZoomOut()
|
|
|
|
{
|
|
|
|
updateZoom( ZoomOut );
|
|
|
|
}
|
2004-09-30 18:04:09 +00:00
|
|
|
|
2004-10-29 21:52:06 +00:00
|
|
|
void PageView::slotFitToWidthToggled( bool on )
|
|
|
|
{
|
|
|
|
if ( on ) updateZoom( ZoomFitWidth );
|
2004-09-30 18:04:09 +00:00
|
|
|
}
|
|
|
|
|
2004-10-29 21:52:06 +00:00
|
|
|
void PageView::slotFitToPageToggled( bool on )
|
2004-09-30 18:04:09 +00:00
|
|
|
{
|
2004-10-29 21:52:06 +00:00
|
|
|
if ( on ) updateZoom( ZoomFitPage );
|
|
|
|
}
|
2004-09-30 18:04:09 +00:00
|
|
|
|
2004-10-29 21:52:06 +00:00
|
|
|
void PageView::slotFitToTextToggled( bool on )
|
|
|
|
{
|
|
|
|
if ( on ) updateZoom( ZoomFitText );
|
|
|
|
}
|
2004-09-30 18:04:09 +00:00
|
|
|
|
2007-05-17 20:46:16 +00:00
|
|
|
void PageView::slotViewMode( int nr )
|
2004-10-29 21:52:06 +00:00
|
|
|
{
|
2007-05-17 20:46:16 +00:00
|
|
|
if ( (int)Okular::Settings::viewMode() != nr )
|
2004-09-30 18:04:09 +00:00
|
|
|
{
|
2007-05-17 20:46:16 +00:00
|
|
|
Okular::Settings::setViewMode( nr );
|
2007-05-23 21:59:12 +00:00
|
|
|
Okular::Settings::self()->writeConfig();
|
2004-10-29 21:52:06 +00:00
|
|
|
if ( d->document->pages() > 0 )
|
|
|
|
slotRelayoutPages();
|
2004-09-30 18:04:09 +00:00
|
|
|
}
|
2004-09-26 23:39:39 +00:00
|
|
|
}
|
|
|
|
|
2005-03-05 15:59:15 +00:00
|
|
|
void PageView::slotContinuousToggled( bool on )
|
2004-09-28 13:53:47 +00:00
|
|
|
{
|
2006-09-21 08:45:36 +00:00
|
|
|
if ( Okular::Settings::viewContinuous() != on )
|
2004-09-28 13:53:47 +00:00
|
|
|
{
|
2006-09-21 08:45:36 +00:00
|
|
|
Okular::Settings::setViewContinuous( on );
|
2007-05-23 21:59:12 +00:00
|
|
|
Okular::Settings::self()->writeConfig();
|
2004-10-29 21:52:06 +00:00
|
|
|
if ( d->document->pages() > 0 )
|
|
|
|
slotRelayoutPages();
|
2004-09-28 13:53:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-29 21:52:06 +00:00
|
|
|
void PageView::slotSetMouseNormal()
|
2004-09-26 23:39:39 +00:00
|
|
|
{
|
2004-10-29 21:52:06 +00:00
|
|
|
d->mouseMode = MouseNormal;
|
2005-02-12 17:42:54 +00:00
|
|
|
// hide the messageWindow
|
2004-11-03 17:35:48 +00:00
|
|
|
d->messageWindow->hide();
|
2005-03-04 23:06:24 +00:00
|
|
|
// reshow the annotator toolbar if hiding was forced
|
|
|
|
if ( d->aToggleAnnotator->isChecked() )
|
|
|
|
slotToggleAnnotator( true );
|
2007-09-14 16:02:02 +00:00
|
|
|
// force an update of the cursor
|
|
|
|
updateCursor( widget()->mapFromGlobal( QCursor::pos() ) );
|
2004-11-03 17:35:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PageView::slotSetMouseZoom()
|
|
|
|
{
|
|
|
|
d->mouseMode = MouseZoom;
|
2005-02-12 17:42:54 +00:00
|
|
|
// change the text in messageWindow (and show it if hidden)
|
2005-01-17 14:57:18 +00:00
|
|
|
d->messageWindow->display( i18n( "Select zooming area. Right-click to zoom out." ), PageViewMessage::Info, -1 );
|
2005-03-04 23:06:24 +00:00
|
|
|
// force hiding of annotator toolbar
|
|
|
|
if ( d->annotator )
|
|
|
|
d->annotator->setEnabled( false );
|
2007-09-14 16:02:02 +00:00
|
|
|
// force an update of the cursor
|
|
|
|
updateCursor( widget()->mapFromGlobal( QCursor::pos() ) );
|
2004-09-26 23:39:39 +00:00
|
|
|
}
|
|
|
|
|
2004-11-16 17:36:02 +00:00
|
|
|
void PageView::slotSetMouseSelect()
|
2004-09-26 23:39:39 +00:00
|
|
|
{
|
2004-11-16 17:36:02 +00:00
|
|
|
d->mouseMode = MouseSelect;
|
2005-02-12 17:42:54 +00:00
|
|
|
// change the text in messageWindow (and show it if hidden)
|
2005-01-17 14:57:18 +00:00
|
|
|
d->messageWindow->display( i18n( "Draw a rectangle around the text/graphics to copy." ), PageViewMessage::Info, -1 );
|
2005-03-04 23:06:24 +00:00
|
|
|
// force hiding of annotator toolbar
|
|
|
|
if ( d->annotator )
|
|
|
|
d->annotator->setEnabled( false );
|
2007-09-14 16:02:02 +00:00
|
|
|
// force an update of the cursor
|
|
|
|
updateCursor( widget()->mapFromGlobal( QCursor::pos() ) );
|
2005-02-18 18:24:45 +00:00
|
|
|
}
|
|
|
|
|
2006-09-26 22:22:01 +00:00
|
|
|
void PageView::slotSetMouseTextSelect()
|
|
|
|
{
|
|
|
|
d->mouseMode = MouseTextSelect;
|
|
|
|
// change the text in messageWindow (and show it if hidden)
|
|
|
|
d->messageWindow->display( i18n( "Select text." ), PageViewMessage::Info, -1 );
|
|
|
|
// force hiding of annotator toolbar
|
|
|
|
if ( d->annotator )
|
|
|
|
d->annotator->setEnabled( false );
|
2007-09-14 16:02:02 +00:00
|
|
|
// force an update of the cursor
|
|
|
|
updateCursor( widget()->mapFromGlobal( QCursor::pos() ) );
|
2006-09-26 22:22:01 +00:00
|
|
|
}
|
|
|
|
|
2005-03-04 23:06:24 +00:00
|
|
|
void PageView::slotToggleAnnotator( bool on )
|
2005-02-18 18:24:45 +00:00
|
|
|
{
|
2006-11-19 01:23:06 +00:00
|
|
|
// the 'inHere' trick is needed as the slotSetMouseZoom() calls this
|
|
|
|
static bool inHere = false;
|
|
|
|
if ( inHere )
|
2005-03-04 23:06:24 +00:00
|
|
|
return;
|
2006-11-19 01:23:06 +00:00
|
|
|
inHere = true;
|
|
|
|
|
|
|
|
// the annotator can be used in normal mouse mode only, so if asked for it,
|
|
|
|
// switch to normal mode
|
|
|
|
if ( on && d->mouseMode != MouseNormal )
|
|
|
|
d->aMouseNormal->trigger();
|
2005-02-18 18:24:45 +00:00
|
|
|
|
2005-03-04 23:06:24 +00:00
|
|
|
// create the annotator object if not present
|
|
|
|
if ( !d->annotator )
|
2007-04-30 17:40:53 +00:00
|
|
|
{
|
2005-03-04 23:06:24 +00:00
|
|
|
d->annotator = new PageViewAnnotator( this, d->document );
|
2007-12-09 01:35:42 +00:00
|
|
|
bool allowTools = d->document->pages() > 0 && d->document->isAllowed( Okular::AllowNotes );
|
|
|
|
d->annotator->setToolsEnabled( allowTools );
|
|
|
|
d->annotator->setTextToolsEnabled( allowTools && d->document->supportsSearching() );
|
2007-04-30 17:40:53 +00:00
|
|
|
}
|
2005-03-04 23:06:24 +00:00
|
|
|
|
|
|
|
// initialize/reset annotator (and show/hide toolbar)
|
|
|
|
d->annotator->setEnabled( on );
|
2006-11-19 01:23:06 +00:00
|
|
|
|
|
|
|
inHere = false;
|
2004-09-26 23:39:39 +00:00
|
|
|
}
|
|
|
|
|
2004-10-29 21:52:06 +00:00
|
|
|
void PageView::slotScrollUp()
|
2004-09-26 23:39:39 +00:00
|
|
|
{
|
2004-10-29 21:52:06 +00:00
|
|
|
if ( d->scrollIncrement < -9 )
|
|
|
|
return;
|
|
|
|
d->scrollIncrement--;
|
|
|
|
slotAutoScoll();
|
2004-10-30 20:54:48 +00:00
|
|
|
setFocus();
|
2004-10-29 21:52:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PageView::slotScrollDown()
|
|
|
|
{
|
|
|
|
if ( d->scrollIncrement > 9 )
|
|
|
|
return;
|
|
|
|
d->scrollIncrement++;
|
|
|
|
slotAutoScoll();
|
2004-10-30 20:54:48 +00:00
|
|
|
setFocus();
|
2004-09-26 23:39:39 +00:00
|
|
|
}
|
2007-01-19 21:43:53 +00:00
|
|
|
|
|
|
|
void PageView::slotRotateClockwise()
|
|
|
|
{
|
|
|
|
int id = ( (int)d->document->rotation() + 1 ) % 4;
|
2007-05-01 23:09:45 +00:00
|
|
|
d->document->setRotation( id );
|
2007-01-19 21:43:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PageView::slotRotateCounterClockwise()
|
|
|
|
{
|
|
|
|
int id = ( (int)d->document->rotation() + 3 ) % 4;
|
2007-05-01 23:09:45 +00:00
|
|
|
d->document->setRotation( id );
|
2007-01-19 21:43:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PageView::slotRotateOriginal()
|
|
|
|
{
|
2007-05-01 23:09:45 +00:00
|
|
|
d->document->setRotation( 0 );
|
2007-01-19 21:43:53 +00:00
|
|
|
}
|
2007-02-25 00:07:59 +00:00
|
|
|
|
2007-05-01 23:21:29 +00:00
|
|
|
void PageView::slotPageSizes( int newsize )
|
|
|
|
{
|
|
|
|
if ( newsize < 0 || newsize >= d->document->pageSizes().count() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
d->document->setPageSize( d->document->pageSizes().at( newsize ) );
|
|
|
|
}
|
|
|
|
|
2007-02-25 00:07:59 +00:00
|
|
|
void PageView::slotToggleForms()
|
|
|
|
{
|
|
|
|
toggleFormWidgets( !d->m_formsVisible );
|
|
|
|
}
|
2007-10-18 22:09:49 +00:00
|
|
|
|
|
|
|
void PageView::slotFormWidgetChanged( FormWidgetIface *w )
|
|
|
|
{
|
|
|
|
}
|
2004-10-29 21:52:06 +00:00
|
|
|
//END private SLOTS
|
2004-09-26 23:39:39 +00:00
|
|
|
|
|
|
|
#include "pageview.moc"
|