This repository was archived by the owner on Jul 19, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewer_paged.h
More file actions
130 lines (105 loc) · 3.16 KB
/
Copy pathviewer_paged.h
File metadata and controls
130 lines (105 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
* Widget for viewing paged content like a PDF document.
* Copyright (c) 2021-2026 Benjamin Johnson
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef VIEWER_PAGED_H
#define VIEWER_PAGED_H
#include <QObject>
#include <QList>
#include <QPoint>
#include <QRect>
#include <QSize>
#include <QImage>
#include <QMovie>
#include <QPixmap>
#include <QTimer>
#include <QWidget>
#include <QScrollArea>
#include <QMoveEvent>
#include <QPaintEvent>
#include <QResizeEvent>
#include <QWheelEvent>
class PagedContent; // defined below
struct Page; // defined in viewer_paged.cpp
class Renderer;
class PagedContentRenderer;
class PagedContentViewer : public QScrollArea
{
Q_OBJECT
public:
PagedContentViewer(QWidget *parent);
QSize sizeHint() const;
void setRenderer(Renderer *replacement);
void setZoomFactor(int percent);
QPoint scrollBarPosition() const;
void setScrollBarPosition(int x, int y);
inline void setScrollBarPosition(const QPoint &point)
{ setScrollBarPosition(point.x(), point.y()); }
public slots:
void clear();
void display();
void setFitToWidth(bool enabled);
private:
void resizeEvent(QResizeEvent *event);
void wheelEvent(QWheelEvent *event);
PagedContent *content;
bool m_fitToWidth;
signals:
void wheelZoomed(int delta);
};
/*
* This class is considered an implementation detail.
* All interactions should go through PagedContentViewer.
*/
class PagedContent : public QWidget
{
Q_OBJECT
protected:
PagedContent(QScrollArea *parent);
~PagedContent();
void setRenderer(Renderer *replacement);
void setZoomFactor(int percent);
friend class PagedContentViewer;
protected slots:
void clear();
void display();
private:
// Qt events
void moveEvent(QMoveEvent *event);
void paintEvent(QPaintEvent *event);
// Other private methods
void paintVisiblePages();
void purgeCache();
void updatePageGeometry();
PagedContentRenderer *renderer;
QList<Page*> pages;
// We use a list rather than a queue for this because Qt may generate
// multiple paint events between refresh()es
QList<int> visiblePages;
QMovie *movie;
QTimer *renderTimer;
int m_zoomFactor;
bool paintPlaceholders;
private slots:
void renderVisiblePages();
void setPageImage(int num, const QImage &image);
void setPagePixmap(int num, const QPixmap &pixmap);
void showNextFrame(const QRect &rect);
signals:
void imageRequested(int num);
};
#endif /* VIEWER_PAGED_H */