3
Copyright 2012 Adam Reichold
5
This file is part of qpdfview.
7
qpdfview is free software: you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation, either version 2 of the License, or
10
(at your option) any later version.
12
qpdfview is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with qpdfview. If not, see <http://www.gnu.org/licenses/>.
28
#include <poppler-qt4.h>
30
#include "annotationdialog.h"
32
class PageItem : public QGraphicsObject
37
static int cacheSize();
38
static void setCacheSize(int cacheSize);
40
static bool decoratePages();
41
static void setDecoratePages(bool decoratePages);
43
static bool decorateLinks();
44
static void setDecorateLinks(bool decorateLinks);
46
static bool invertColors();
47
static void setInvertColors(bool invertColors);
49
static const Qt::KeyboardModifiers& copyModifiers();
50
static void setCopyModifiers(const Qt::KeyboardModifiers& copyModifiers);
52
static const Qt::KeyboardModifiers& annotateModifiers();
53
static void setAnnotateModifiers(const Qt::KeyboardModifiers& annotateModifiers);
55
PageItem(QMutex* mutex, Poppler::Page* page, int index, QGraphicsItem* parent = 0);
58
QRectF boundingRect() const;
59
void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
64
const QList< QRectF >& highlights() const;
65
void setHighlights(const QList< QRectF >& highlights);
70
CopyToClipboardMode = 1,
74
RubberBandMode rubberBandMode() const;
75
void setRubberBandMode(RubberBandMode rubberBandMode);
77
int physicalDpiX() const;
78
int physicalDpiY() const;
79
void setPhysicalDpi(int physicalDpiX, int physicalDpiY);
81
qreal scaleFactor() const;
82
void setScaleFactor(qreal scaleFactor);
84
Poppler::Page::Rotation rotation() const;
85
void setRotation(Poppler::Page::Rotation rotation);
87
const QTransform& transform() const;
88
const QTransform& normalizedTransform() const;
91
void imageReady(int physicalDpiX, int physicalDpiY, qreal scaleFactor, Poppler::Page::Rotation rotation, bool prefetch, QImage image);
93
void linkClicked(int page, qreal left, qreal top);
94
void linkClicked(const QString& url);
96
void rubberBandReset();
101
void startRender(bool prefetch = false);
105
void on_render_finished();
106
void on_imageReady(int physicalDpiX, int physicalDpiY, qreal scaleFactor, Poppler::Page::Rotation rotation, bool prefetch, QImage image);
109
void hoverEnterEvent(QGraphicsSceneHoverEvent* event);
110
void hoverMoveEvent(QGraphicsSceneHoverEvent* event);
111
void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);
112
void mousePressEvent(QGraphicsSceneMouseEvent* event);
113
void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
114
void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
117
static QCache< PageItem*, QImage > s_cache;
119
static bool s_decoratePages;
120
static bool s_decorateLinks;
122
static bool s_invertColors;
124
static Qt::KeyboardModifiers s_copyModifiers;
125
static Qt::KeyboardModifiers s_annotateModifiers;
128
Poppler::Page* m_page;
132
QList< Poppler::Link* > m_links;
133
QList< Poppler::Annotation* > m_annotations;
135
QList< QRectF > m_highlights;
137
RubberBandMode m_rubberBandMode;
140
void copyToClipboard(const QPoint& screenPos);
141
void addAnnotation(const QPoint& screenPos);
142
void removeAnnotation(Poppler::Annotation* annotation, const QPoint& screenPos);
143
void editAnnotation(Poppler::Annotation* annotation, const QPoint& screenPos);
151
Poppler::Page::Rotation m_rotation;
153
QTransform m_transform;
154
QTransform m_normalizedTransform;
155
QRectF m_boundingRect;
159
void prepareGeometry();
163
QFutureWatcher< void >* m_render;
164
void render(int physicalDpiX, int physicalDpiY, qreal scaleFactor, Poppler::Page::Rotation rotation, bool prefetch);
168
class ThumbnailItem : public PageItem
173
ThumbnailItem(QMutex* mutex, Poppler::Page* page, int index, QGraphicsItem* parent = 0);
176
void pageClicked(int page);
179
void hoverMoveEvent(QGraphicsSceneHoverEvent* event);
180
void mousePressEvent(QGraphicsSceneMouseEvent* event);
181
void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
182
void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);