-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnsrrenderedpage.h
207 lines (180 loc) · 4.29 KB
/
nsrrenderedpage.h
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#ifndef __NSRRENDEREDPAGE_H__
#define __NSRRENDEREDPAGE_H__
/**
* @file nsrrenderedpage.h
* @author Alexander Saprykin
* @brief Rendered page
*/
#include "nsrrenderrequest.h"
#include "nsrabstractdocument.h"
#include "nsrreadercore_global.h"
#include <QSize>
#include <QPointF>
/**
* @class NSRRenderedPage nsrrenderedpage.h
* @brief Class for rendered page
*/
class NSRREADERCORE_SHARED NSRRenderedPage: public NSRRenderRequest
{
public:
/**
* @brief Constructor
*/
NSRRenderedPage ();
/**
* @brief Constructor from request
* @param req Render request.
*/
NSRRenderedPage (const NSRRenderRequest& req);
/**
* @brief Destructor
*/
virtual ~NSRRenderedPage ();
/**
* @brief Gets page size
* @return Page size, in px.
*/
inline QSize getSize () const {
return QSize (_image.width (), _image.height ());
}
/**
* @brief Gets rendered image
* @return Rendered image.
*/
inline NSR_CORE_IMAGE_DATATYPE getImage () const {
return _image;
}
/**
* @brief Gets page text
* @return Page text.
*/
inline QString getText () const {
return _text;
}
/**
* @brief Gets last image scroll position
* @return Last image scroll position.
* @note Useful to store scroll data right in the page object.
*/
inline QPointF getLastPosition () const {
return _lastPos;
}
/**
* @brief Gets last text view position
* @return Last text view position.
* @note Useful to store scroll data right in the page object.
*/
inline QPointF getLastTextPosition () const {
return _lastTextPos;
}
/**
* @brief Gets page zoom value
* @return Zoom value, in %.
*/
inline double getRenderedZoom () const {
return _renderedZoom;
}
/**
* @brief Gets min page zoom value
* @return Min zoom value, in %.
* @since 1.4.3
*/
inline double getMinRenderZoom () const {
return _minRenderZoom;
}
/**
* @brief Gets max page zoom value
* @return Max zoom value, in %.
* @since 1.4.3
*/
inline double getMaxRenderZoom () const {
return _maxRenderZoom;
}
/**
* @brief Checks whether page was taken from cache
* @return True if page was taken from cache, false otherwise.
*/
inline bool isCached () const {
return _cached;
}
/**
* @brief Checks whether page image is valid (non-empty)
* @return True if page image is valid, false otherwise.
*/
bool isImageValid () const;
/**
* @brief Checks whether page is empty (no image and text)
* @return True if page is empty, false otherwise.
*/
bool isEmpty () const;
/**
* @brief Sets page image
* @param image Page image.
*/
inline void setImage (NSR_CORE_IMAGE_DATATYPE image) {
_image = image;
}
/**
* @brief Sets page text
* @param text Page text.
*/
inline void setText (const QString &text) {
_text = text;
}
/**
* @brief Sets last image scroll position
* @param pos Last image scroll position.
* @note Useful to store scroll data right in the page object.
*/
inline void setLastPosition (const QPointF& pos) {
_lastPos = pos;
}
/**
* @brief Sets last text view position
* @param pos Last text view position.
* @note Useful to store scroll data right in the page object.
*/
inline void setLastTextPosition (const QPointF& pos) {
_lastTextPos = pos;
}
/**
* @brief Sets page zoom value
* @param zoom Page zoom value, in %.
*/
inline void setRenderedZoom (double zoom) {
_renderedZoom = zoom;
}
/**
* @brief Sets page min zoom value
* @param minZoom Page min zoom value, in %.
* @since 1.4.3
*/
inline void setMinRenderZoom (double minZoom) {
_minRenderZoom = minZoom;
}
/**
* @brief Sets page max zoom value
* @param maxZoom Page max zoom value, in %.
* @since 1.4.3
*/
inline void setMaxRenderZoom (double maxZoom) {
_maxRenderZoom = maxZoom;
}
/**
* @brief Marks page as cached
* @param cached Whether page is cached.
*/
inline void setCached (bool cached) {
_cached = cached;
}
private:
NSR_CORE_IMAGE_DATATYPE _image; /**< Page image */
QString _text; /**< Page text */
QPointF _lastPos; /**< Last image scroll position */
QPointF _lastTextPos; /**< Last text view position */
double _renderedZoom; /**< Page zoom value */
double _minRenderZoom; /**< Page min zoom value */
double _maxRenderZoom; /**< Page max zoom value */
bool _cached; /**< Cache flag */
};
#endif /* __NSRRENDEREDPAGE_H__ */