~ubuntu-branches/debian/jessie/qpdfview/jessie

« back to all changes in this revision

Viewing changes to sources/pageitem.h

  • Committer: Package Import Robot
  • Author(s): Benjamin Eltzner
  • Date: 2012-09-02 15:18:34 UTC
  • mfrom: (1.2.1) (4.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20120902151834-xa61s2fuphrrdwxs
Tags: 0.3.3-1
* Fixed some rendering artifacts.
* Improved navigation using bookmarks.
* Reorganized settings dialog and made keyboard modifiers for several mouse
  actions configurable.
* Added menu and tool bar actions to copy texts or images or add annotations.
* Added Ukrainian translation. Thanks to Vladimir Smolyar.
* Updated Slovak translation. Thanks to DAG Software.
* Updated Czech translation. Thanks to Pavel Fric.
* Updated Russian translation. Thanks to Eugene Marshal and Vladimir Smolyar.
* Added MIME file. (Closes: #685599)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
Copyright 2012 Adam Reichold
 
4
 
 
5
This file is part of qpdfview.
 
6
 
 
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.
 
11
 
 
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.
 
16
 
 
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/>.
 
19
 
 
20
*/
 
21
 
 
22
#ifndef PAGEITEM_H
 
23
#define PAGEITEM_H
 
24
 
 
25
#include <QtCore>
 
26
#include <QtGui>
 
27
 
 
28
#include <poppler-qt4.h>
 
29
 
 
30
#include "annotationdialog.h"
 
31
 
 
32
class PageItem : public QGraphicsObject
 
33
{
 
34
    Q_OBJECT
 
35
 
 
36
public:
 
37
    static int cacheSize();
 
38
    static void setCacheSize(int cacheSize);
 
39
 
 
40
    static bool decoratePages();
 
41
    static void setDecoratePages(bool decoratePages);
 
42
 
 
43
    static bool decorateLinks();
 
44
    static void setDecorateLinks(bool decorateLinks);
 
45
 
 
46
    static bool invertColors();
 
47
    static void setInvertColors(bool invertColors);
 
48
 
 
49
    static const Qt::KeyboardModifiers& copyModifiers();
 
50
    static void setCopyModifiers(const Qt::KeyboardModifiers& copyModifiers);
 
51
 
 
52
    static const Qt::KeyboardModifiers& annotateModifiers();
 
53
    static void setAnnotateModifiers(const Qt::KeyboardModifiers& annotateModifiers);
 
54
 
 
55
    PageItem(QMutex* mutex, Poppler::Page* page, int index, QGraphicsItem* parent = 0);
 
56
    ~PageItem();
 
57
 
 
58
    QRectF boundingRect() const;
 
59
    void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
 
60
 
 
61
    int index() const;
 
62
    QSizeF size() const;
 
63
 
 
64
    const QList< QRectF >& highlights() const;
 
65
    void setHighlights(const QList< QRectF >& highlights);
 
66
 
 
67
    enum RubberBandMode
 
68
    {
 
69
        ModifiersMode = 0,
 
70
        CopyToClipboardMode = 1,
 
71
        AddAnnotationMode = 2
 
72
    };
 
73
 
 
74
    RubberBandMode rubberBandMode() const;
 
75
    void setRubberBandMode(RubberBandMode rubberBandMode);
 
76
 
 
77
    int physicalDpiX() const;
 
78
    int physicalDpiY() const;
 
79
    void setPhysicalDpi(int physicalDpiX, int physicalDpiY);
 
80
 
 
81
    qreal scaleFactor() const;
 
82
    void setScaleFactor(qreal scaleFactor);
 
83
 
 
84
    Poppler::Page::Rotation rotation() const;
 
85
    void setRotation(Poppler::Page::Rotation rotation);
 
86
 
 
87
    const QTransform& transform() const;
 
88
    const QTransform& normalizedTransform() const;
 
89
 
 
90
signals:
 
91
    void imageReady(int physicalDpiX, int physicalDpiY, qreal scaleFactor, Poppler::Page::Rotation rotation, bool prefetch, QImage image);
 
92
 
 
93
    void linkClicked(int page, qreal left, qreal top);
 
94
    void linkClicked(const QString& url);
 
95
 
 
96
    void rubberBandReset();
 
97
 
 
98
public slots:
 
99
    void refresh();
 
100
 
 
101
    void startRender(bool prefetch = false);
 
102
    void cancelRender();
 
103
 
 
104
protected slots:
 
105
    void on_render_finished();
 
106
    void on_imageReady(int physicalDpiX, int physicalDpiY, qreal scaleFactor, Poppler::Page::Rotation rotation, bool prefetch, QImage image);
 
107
 
 
108
protected:
 
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);
 
115
 
 
116
private:
 
117
    static QCache< PageItem*, QImage > s_cache;
 
118
 
 
119
    static bool s_decoratePages;
 
120
    static bool s_decorateLinks;
 
121
 
 
122
    static bool s_invertColors;
 
123
 
 
124
    static Qt::KeyboardModifiers s_copyModifiers;
 
125
    static Qt::KeyboardModifiers s_annotateModifiers;
 
126
 
 
127
    QMutex* m_mutex;
 
128
    Poppler::Page* m_page;
 
129
 
 
130
    int m_index;
 
131
    QSizeF m_size;
 
132
    QList< Poppler::Link* > m_links;
 
133
    QList< Poppler::Annotation* > m_annotations;
 
134
 
 
135
    QList< QRectF > m_highlights;
 
136
 
 
137
    RubberBandMode m_rubberBandMode;
 
138
    QRectF m_rubberBand;
 
139
 
 
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);
 
144
 
 
145
    // geometry
 
146
 
 
147
    int m_physicalDpiX;
 
148
    int m_physicalDpiY;
 
149
 
 
150
    qreal m_scaleFactor;
 
151
    Poppler::Page::Rotation m_rotation;
 
152
 
 
153
    QTransform m_transform;
 
154
    QTransform m_normalizedTransform;
 
155
    QRectF m_boundingRect;
 
156
 
 
157
    QImage m_image;
 
158
 
 
159
    void prepareGeometry();
 
160
 
 
161
    // render
 
162
 
 
163
    QFutureWatcher< void >* m_render;
 
164
    void render(int physicalDpiX, int physicalDpiY, qreal scaleFactor, Poppler::Page::Rotation rotation, bool prefetch);
 
165
 
 
166
};
 
167
 
 
168
class ThumbnailItem : public PageItem
 
169
{
 
170
    Q_OBJECT
 
171
 
 
172
public:
 
173
    ThumbnailItem(QMutex* mutex, Poppler::Page* page, int index, QGraphicsItem* parent = 0);
 
174
 
 
175
signals:
 
176
    void pageClicked(int page);
 
177
 
 
178
protected:
 
179
    void hoverMoveEvent(QGraphicsSceneHoverEvent* event);
 
180
    void mousePressEvent(QGraphicsSceneMouseEvent* event);
 
181
    void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
 
182
    void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
 
183
 
 
184
};
 
185
 
 
186
#endif // PAGEITEM_H