Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/painting/qpagelayout.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | __attribute__((visibility("default"))) qreal qt_pointMultiplier(QPageLayout::Unit unit) | - | ||||||||||||
8 | { | - | ||||||||||||
9 | switch (unit) { | - | ||||||||||||
10 | case never executed: QPageLayout::Millimeter:case QPageLayout::Millimeter: never executed: case QPageLayout::Millimeter: | 0 | ||||||||||||
11 | return never executed: 2.83464566929;return 2.83464566929; never executed: return 2.83464566929; | 0 | ||||||||||||
12 | case never executed: QPageLayout::Point:case QPageLayout::Point: never executed: case QPageLayout::Point: | 0 | ||||||||||||
13 | return never executed: 1.0;return 1.0; never executed: return 1.0; | 0 | ||||||||||||
14 | case never executed: QPageLayout::Inch:case QPageLayout::Inch: never executed: case QPageLayout::Inch: | 0 | ||||||||||||
15 | return never executed: 72.0;return 72.0; never executed: return 72.0; | 0 | ||||||||||||
16 | case never executed: QPageLayout::Pica:case QPageLayout::Pica: never executed: case QPageLayout::Pica: | 0 | ||||||||||||
17 | return never executed: 12;return 12; never executed: return 12; | 0 | ||||||||||||
18 | case never executed: QPageLayout::Didot:case QPageLayout::Didot: never executed: case QPageLayout::Didot: | 0 | ||||||||||||
19 | return never executed: 1.065826771;return 1.065826771; never executed: return 1.065826771; | 0 | ||||||||||||
20 | case never executed: QPageLayout::Cicero:case QPageLayout::Cicero: never executed: case QPageLayout::Cicero: | 0 | ||||||||||||
21 | return never executed: 12.789921252;return 12.789921252; never executed: return 12.789921252; | 0 | ||||||||||||
22 | } | - | ||||||||||||
23 | return never executed: 1.0;return 1.0; never executed: return 1.0; | 0 | ||||||||||||
24 | } | - | ||||||||||||
25 | - | |||||||||||||
26 | - | |||||||||||||
27 | extern qreal qt_pixelMultiplier(int resolution); | - | ||||||||||||
28 | - | |||||||||||||
29 | QPointF qt_convertPoint(const QPointF &xy, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits) | - | ||||||||||||
30 | { | - | ||||||||||||
31 | - | |||||||||||||
32 | if (fromUnits == toUnits
| 0 | ||||||||||||
33 | return never executed: xy;return xy; never executed: return xy; | 0 | ||||||||||||
34 | - | |||||||||||||
35 | - | |||||||||||||
36 | if (toUnits == QPageLayout::Point
| 0 | ||||||||||||
37 | const qreal multiplier = qt_pointMultiplier(fromUnits); | - | ||||||||||||
38 | return never executed: QPointF(qRound(xy.x() * multiplier),return QPointF(qRound(xy.x() * multiplier), qRound(xy.y() * multiplier)); never executed: return QPointF(qRound(xy.x() * multiplier), qRound(xy.y() * multiplier)); | 0 | ||||||||||||
39 | qRound(xy.y() * multiplier)); never executed: return QPointF(qRound(xy.x() * multiplier), qRound(xy.y() * multiplier)); | 0 | ||||||||||||
40 | } | - | ||||||||||||
41 | - | |||||||||||||
42 | - | |||||||||||||
43 | QPointF pointXy = (
| 0 | ||||||||||||
44 | - | |||||||||||||
45 | - | |||||||||||||
46 | const qreal multiplier = qt_pointMultiplier(toUnits); | - | ||||||||||||
47 | return never executed: QPointF(qRound(pointXy.x() * 100 / multiplier) / 100.0,return QPointF(qRound(pointXy.x() * 100 / multiplier) / 100.0, qRound(pointXy.y() * 100 / multiplier) / 100.0); never executed: return QPointF(qRound(pointXy.x() * 100 / multiplier) / 100.0, qRound(pointXy.y() * 100 / multiplier) / 100.0); | 0 | ||||||||||||
48 | qRound(pointXy.y() * 100 / multiplier) / 100.0); never executed: return QPointF(qRound(pointXy.x() * 100 / multiplier) / 100.0, qRound(pointXy.y() * 100 / multiplier) / 100.0); | 0 | ||||||||||||
49 | } | - | ||||||||||||
50 | - | |||||||||||||
51 | __attribute__((visibility("default"))) QMarginsF qt_convertMargins(const QMarginsF &margins, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits) | - | ||||||||||||
52 | { | - | ||||||||||||
53 | - | |||||||||||||
54 | if (fromUnits == toUnits
| 0 | ||||||||||||
55 | return never executed: margins;return margins; never executed: return margins; | 0 | ||||||||||||
56 | - | |||||||||||||
57 | - | |||||||||||||
58 | if (toUnits == QPageLayout::Point
| 0 | ||||||||||||
59 | const qreal multiplier = qt_pointMultiplier(fromUnits); | - | ||||||||||||
60 | return never executed: QMarginsF(qRound(margins.left() * multiplier),return QMarginsF(qRound(margins.left() * multiplier), qRound(margins.top() * multiplier), qRound(margins.right() * multiplier), qRound(margins.bottom() * multiplier)); never executed: return QMarginsF(qRound(margins.left() * multiplier), qRound(margins.top() * multiplier), qRound(margins.right() * multiplier), qRound(margins.bottom() * multiplier)); | 0 | ||||||||||||
61 | qRound(margins.top() * multiplier), never executed: return QMarginsF(qRound(margins.left() * multiplier), qRound(margins.top() * multiplier), qRound(margins.right() * multiplier), qRound(margins.bottom() * multiplier)); | 0 | ||||||||||||
62 | qRound(margins.right() * multiplier), never executed: return QMarginsF(qRound(margins.left() * multiplier), qRound(margins.top() * multiplier), qRound(margins.right() * multiplier), qRound(margins.bottom() * multiplier)); | 0 | ||||||||||||
63 | qRound(margins.bottom() * multiplier)); never executed: return QMarginsF(qRound(margins.left() * multiplier), qRound(margins.top() * multiplier), qRound(margins.right() * multiplier), qRound(margins.bottom() * multiplier)); | 0 | ||||||||||||
64 | } | - | ||||||||||||
65 | - | |||||||||||||
66 | - | |||||||||||||
67 | QMarginsF pointMargins = fromUnits == QPageLayout::Point
| 0 | ||||||||||||
68 | - | |||||||||||||
69 | - | |||||||||||||
70 | const qreal multiplier = qt_pointMultiplier(toUnits); | - | ||||||||||||
71 | return never executed: QMarginsF(qRound(pointMargins.left() * 100 / multiplier) / 100.0,return QMarginsF(qRound(pointMargins.left() * 100 / multiplier) / 100.0, qRound(pointMargins.top() * 100 / multiplier) / 100.0, qRound(pointMargins.right() * 100 / multiplier) / 100.0, qRound(pointMargins.bottom() * 100 / multiplier) / 100.0); never executed: return QMarginsF(qRound(pointMargins.left() * 100 / multiplier) / 100.0, qRound(pointMargins.top() * 100 / multiplier) / 100.0, qRound(pointMargins.right() * 100 / multiplier) / 100.0, qRound(pointMargins.bottom() * 100 / multiplier) / 100.0); | 0 | ||||||||||||
72 | qRound(pointMargins.top() * 100 / multiplier) / 100.0, never executed: return QMarginsF(qRound(pointMargins.left() * 100 / multiplier) / 100.0, qRound(pointMargins.top() * 100 / multiplier) / 100.0, qRound(pointMargins.right() * 100 / multiplier) / 100.0, qRound(pointMargins.bottom() * 100 / multiplier) / 100.0); | 0 | ||||||||||||
73 | qRound(pointMargins.right() * 100 / multiplier) / 100.0, never executed: return QMarginsF(qRound(pointMargins.left() * 100 / multiplier) / 100.0, qRound(pointMargins.top() * 100 / multiplier) / 100.0, qRound(pointMargins.right() * 100 / multiplier) / 100.0, qRound(pointMargins.bottom() * 100 / multiplier) / 100.0); | 0 | ||||||||||||
74 | qRound(pointMargins.bottom() * 100 / multiplier) / 100.0); never executed: return QMarginsF(qRound(pointMargins.left() * 100 / multiplier) / 100.0, qRound(pointMargins.top() * 100 / multiplier) / 100.0, qRound(pointMargins.right() * 100 / multiplier) / 100.0, qRound(pointMargins.bottom() * 100 / multiplier) / 100.0); | 0 | ||||||||||||
75 | } | - | ||||||||||||
76 | - | |||||||||||||
77 | class QPageLayoutPrivate : public QSharedData | - | ||||||||||||
78 | { | - | ||||||||||||
79 | public: | - | ||||||||||||
80 | - | |||||||||||||
81 | QPageLayoutPrivate(); | - | ||||||||||||
82 | QPageLayoutPrivate(const QPageSize &pageSize, QPageLayout::Orientation orientation, | - | ||||||||||||
83 | const QMarginsF &margins, QPageLayout::Unit units, | - | ||||||||||||
84 | const QMarginsF &minMargins); | - | ||||||||||||
85 | ~QPageLayoutPrivate(); | - | ||||||||||||
86 | - | |||||||||||||
87 | bool operator==(const QPageLayoutPrivate &other) const; | - | ||||||||||||
88 | bool isEquivalentTo(const QPageLayoutPrivate &other) const; | - | ||||||||||||
89 | - | |||||||||||||
90 | bool isValid() const; | - | ||||||||||||
91 | - | |||||||||||||
92 | void clampMargins(const QMarginsF &margins); | - | ||||||||||||
93 | - | |||||||||||||
94 | QMarginsF margins(QPageLayout::Unit units) const; | - | ||||||||||||
95 | QMargins marginsPoints() const; | - | ||||||||||||
96 | QMargins marginsPixels(int resolution) const; | - | ||||||||||||
97 | - | |||||||||||||
98 | void setDefaultMargins(const QMarginsF &minMargins); | - | ||||||||||||
99 | - | |||||||||||||
100 | QSizeF paintSize() const; | - | ||||||||||||
101 | - | |||||||||||||
102 | QRectF fullRect() const; | - | ||||||||||||
103 | QRectF fullRect(QPageLayout::Unit units) const; | - | ||||||||||||
104 | QRect fullRectPoints() const; | - | ||||||||||||
105 | QRect fullRectPixels(int resolution) const; | - | ||||||||||||
106 | - | |||||||||||||
107 | QRectF paintRect() const; | - | ||||||||||||
108 | - | |||||||||||||
109 | private: | - | ||||||||||||
110 | friend class QPageLayout; | - | ||||||||||||
111 | - | |||||||||||||
112 | QSizeF fullSizeUnits(QPageLayout::Unit units) const; | - | ||||||||||||
113 | - | |||||||||||||
114 | QPageSize m_pageSize; | - | ||||||||||||
115 | QPageLayout::Orientation m_orientation; | - | ||||||||||||
116 | QPageLayout::Mode m_mode; | - | ||||||||||||
117 | QPageLayout::Unit m_units; | - | ||||||||||||
118 | QSizeF m_fullSize; | - | ||||||||||||
119 | QMarginsF m_margins; | - | ||||||||||||
120 | QMarginsF m_minMargins; | - | ||||||||||||
121 | QMarginsF m_maxMargins; | - | ||||||||||||
122 | }; | - | ||||||||||||
123 | - | |||||||||||||
124 | QPageLayoutPrivate::QPageLayoutPrivate() | - | ||||||||||||
125 | : m_orientation(QPageLayout::Landscape), | - | ||||||||||||
126 | m_mode(QPageLayout::StandardMode) | - | ||||||||||||
127 | { | - | ||||||||||||
128 | } never executed: end of block | 0 | ||||||||||||
129 | - | |||||||||||||
130 | QPageLayoutPrivate::QPageLayoutPrivate(const QPageSize &pageSize, QPageLayout::Orientation orientation, | - | ||||||||||||
131 | const QMarginsF &margins, QPageLayout::Unit units, | - | ||||||||||||
132 | const QMarginsF &minMargins) | - | ||||||||||||
133 | : m_pageSize(pageSize), | - | ||||||||||||
134 | m_orientation(orientation), | - | ||||||||||||
135 | m_mode(QPageLayout::StandardMode), | - | ||||||||||||
136 | m_units(units), | - | ||||||||||||
137 | m_margins(margins) | - | ||||||||||||
138 | { | - | ||||||||||||
139 | m_fullSize = fullSizeUnits(m_units); | - | ||||||||||||
140 | setDefaultMargins(minMargins); | - | ||||||||||||
141 | } never executed: end of block | 0 | ||||||||||||
142 | - | |||||||||||||
143 | QPageLayoutPrivate::~QPageLayoutPrivate() | - | ||||||||||||
144 | { | - | ||||||||||||
145 | } | - | ||||||||||||
146 | - | |||||||||||||
147 | bool QPageLayoutPrivate::operator==(const QPageLayoutPrivate &other) const | - | ||||||||||||
148 | { | - | ||||||||||||
149 | return never executed: m_pageSize == other.m_pageSizereturn m_pageSize == other.m_pageSize && m_orientation == other.m_orientation && m_units == other.m_units && m_margins == other.m_margins && m_minMargins == other.m_minMargins && m_maxMargins == other.m_maxMargins; never executed: return m_pageSize == other.m_pageSize && m_orientation == other.m_orientation && m_units == other.m_units && m_margins == other.m_margins && m_minMargins == other.m_minMargins && m_maxMargins == other.m_maxMargins; | 0 | ||||||||||||
150 | && m_orientation == other.m_orientation never executed: return m_pageSize == other.m_pageSize && m_orientation == other.m_orientation && m_units == other.m_units && m_margins == other.m_margins && m_minMargins == other.m_minMargins && m_maxMargins == other.m_maxMargins; | 0 | ||||||||||||
151 | && m_units == other.m_units never executed: return m_pageSize == other.m_pageSize && m_orientation == other.m_orientation && m_units == other.m_units && m_margins == other.m_margins && m_minMargins == other.m_minMargins && m_maxMargins == other.m_maxMargins; | 0 | ||||||||||||
152 | && m_margins == other.m_margins never executed: return m_pageSize == other.m_pageSize && m_orientation == other.m_orientation && m_units == other.m_units && m_margins == other.m_margins && m_minMargins == other.m_minMargins && m_maxMargins == other.m_maxMargins; | 0 | ||||||||||||
153 | && m_minMargins == other.m_minMargins never executed: return m_pageSize == other.m_pageSize && m_orientation == other.m_orientation && m_units == other.m_units && m_margins == other.m_margins && m_minMargins == other.m_minMargins && m_maxMargins == other.m_maxMargins; | 0 | ||||||||||||
154 | && m_maxMargins == other.m_maxMargins; never executed: return m_pageSize == other.m_pageSize && m_orientation == other.m_orientation && m_units == other.m_units && m_margins == other.m_margins && m_minMargins == other.m_minMargins && m_maxMargins == other.m_maxMargins; | 0 | ||||||||||||
155 | } | - | ||||||||||||
156 | - | |||||||||||||
157 | bool QPageLayoutPrivate::isEquivalentTo(const QPageLayoutPrivate &other) const | - | ||||||||||||
158 | { | - | ||||||||||||
159 | return never executed: m_pageSize.isEquivalentTo(other.m_pageSize)return m_pageSize.isEquivalentTo(other.m_pageSize) && m_orientation == other.m_orientation && qt_convertMargins(m_margins, m_units, QPageLayout::Point) == qt_convertMargins(other.m_margins, other.m_units, QPageLayout::Point); never executed: return m_pageSize.isEquivalentTo(other.m_pageSize) && m_orientation == other.m_orientation && qt_convertMargins(m_margins, m_units, QPageLayout::Point) == qt_convertMargins(other.m_margins, other.m_units, QPageLayout::Point); | 0 | ||||||||||||
160 | && m_orientation == other.m_orientation never executed: return m_pageSize.isEquivalentTo(other.m_pageSize) && m_orientation == other.m_orientation && qt_convertMargins(m_margins, m_units, QPageLayout::Point) == qt_convertMargins(other.m_margins, other.m_units, QPageLayout::Point); | 0 | ||||||||||||
161 | && qt_convertMargins(m_margins, m_units, QPageLayout::Point) never executed: return m_pageSize.isEquivalentTo(other.m_pageSize) && m_orientation == other.m_orientation && qt_convertMargins(m_margins, m_units, QPageLayout::Point) == qt_convertMargins(other.m_margins, other.m_units, QPageLayout::Point); | 0 | ||||||||||||
162 | == qt_convertMargins(other.m_margins, other.m_units, QPageLayout::Point); never executed: return m_pageSize.isEquivalentTo(other.m_pageSize) && m_orientation == other.m_orientation && qt_convertMargins(m_margins, m_units, QPageLayout::Point) == qt_convertMargins(other.m_margins, other.m_units, QPageLayout::Point); | 0 | ||||||||||||
163 | } | - | ||||||||||||
164 | - | |||||||||||||
165 | bool QPageLayoutPrivate::isValid() const | - | ||||||||||||
166 | { | - | ||||||||||||
167 | return never executed: m_pageSize.isValid();return m_pageSize.isValid(); never executed: return m_pageSize.isValid(); | 0 | ||||||||||||
168 | } | - | ||||||||||||
169 | - | |||||||||||||
170 | void QPageLayoutPrivate::clampMargins(const QMarginsF &margins) | - | ||||||||||||
171 | { | - | ||||||||||||
172 | m_margins = QMarginsF(qBound(m_minMargins.left(), margins.left(), m_maxMargins.left()), | - | ||||||||||||
173 | qBound(m_minMargins.top(), margins.top(), m_maxMargins.top()), | - | ||||||||||||
174 | qBound(m_minMargins.right(), margins.right(), m_maxMargins.right()), | - | ||||||||||||
175 | qBound(m_minMargins.bottom(), margins.bottom(), m_maxMargins.bottom())); | - | ||||||||||||
176 | } never executed: end of block | 0 | ||||||||||||
177 | - | |||||||||||||
178 | QMarginsF QPageLayoutPrivate::margins(QPageLayout::Unit units) const | - | ||||||||||||
179 | { | - | ||||||||||||
180 | return never executed: qt_convertMargins(m_margins, m_units, units);return qt_convertMargins(m_margins, m_units, units); never executed: return qt_convertMargins(m_margins, m_units, units); | 0 | ||||||||||||
181 | } | - | ||||||||||||
182 | - | |||||||||||||
183 | QMargins QPageLayoutPrivate::marginsPoints() const | - | ||||||||||||
184 | { | - | ||||||||||||
185 | return never executed: qt_convertMargins(m_margins, m_units, QPageLayout::Point).toMargins();return qt_convertMargins(m_margins, m_units, QPageLayout::Point).toMargins(); never executed: return qt_convertMargins(m_margins, m_units, QPageLayout::Point).toMargins(); | 0 | ||||||||||||
186 | } | - | ||||||||||||
187 | - | |||||||||||||
188 | QMargins QPageLayoutPrivate::marginsPixels(int resolution) const | - | ||||||||||||
189 | { | - | ||||||||||||
190 | return never executed: marginsPoints() / qt_pixelMultiplier(resolution);return marginsPoints() / qt_pixelMultiplier(resolution); never executed: return marginsPoints() / qt_pixelMultiplier(resolution); | 0 | ||||||||||||
191 | } | - | ||||||||||||
192 | - | |||||||||||||
193 | void QPageLayoutPrivate::setDefaultMargins(const QMarginsF &minMargins) | - | ||||||||||||
194 | { | - | ||||||||||||
195 | m_minMargins = minMargins; | - | ||||||||||||
196 | m_maxMargins = QMarginsF(m_fullSize.width() - m_minMargins.right(), | - | ||||||||||||
197 | m_fullSize.height() - m_minMargins.bottom(), | - | ||||||||||||
198 | m_fullSize.width() - m_minMargins.left(), | - | ||||||||||||
199 | m_fullSize.height() - m_minMargins.top()); | - | ||||||||||||
200 | if (m_mode == QPageLayout::StandardMode
| 0 | ||||||||||||
201 | clampMargins(m_margins); never executed: clampMargins(m_margins); | 0 | ||||||||||||
202 | } never executed: end of block | 0 | ||||||||||||
203 | - | |||||||||||||
204 | QSizeF QPageLayoutPrivate::fullSizeUnits(QPageLayout::Unit units) const | - | ||||||||||||
205 | { | - | ||||||||||||
206 | QSizeF fullPageSize = m_pageSize.size(QPageSize::Unit(units)); | - | ||||||||||||
207 | return never executed: m_orientation == QPageLayout::Landscape ? fullPageSize.transposed() : fullPageSize;return m_orientation == QPageLayout::Landscape ? fullPageSize.transposed() : fullPageSize; never executed: return m_orientation == QPageLayout::Landscape ? fullPageSize.transposed() : fullPageSize; | 0 | ||||||||||||
208 | } | - | ||||||||||||
209 | - | |||||||||||||
210 | QRectF QPageLayoutPrivate::fullRect() const | - | ||||||||||||
211 | { | - | ||||||||||||
212 | return never executed: QRectF(QPointF(0, 0), m_fullSize);return QRectF(QPointF(0, 0), m_fullSize); never executed: return QRectF(QPointF(0, 0), m_fullSize); | 0 | ||||||||||||
213 | } | - | ||||||||||||
214 | - | |||||||||||||
215 | QRectF QPageLayoutPrivate::fullRect(QPageLayout::Unit units) const | - | ||||||||||||
216 | { | - | ||||||||||||
217 | return never executed: units == m_units ? fullRect() : QRectF(QPointF(0, 0), fullSizeUnits(units));return units == m_units ? fullRect() : QRectF(QPointF(0, 0), fullSizeUnits(units)); never executed: return units == m_units ? fullRect() : QRectF(QPointF(0, 0), fullSizeUnits(units)); | 0 | ||||||||||||
218 | } | - | ||||||||||||
219 | - | |||||||||||||
220 | QRect QPageLayoutPrivate::fullRectPoints() const | - | ||||||||||||
221 | { | - | ||||||||||||
222 | if (m_orientation == QPageLayout::Landscape
| 0 | ||||||||||||
223 | return never executed: QRect(QPoint(0, 0), m_pageSize.sizePoints().transposed());return QRect(QPoint(0, 0), m_pageSize.sizePoints().transposed()); never executed: return QRect(QPoint(0, 0), m_pageSize.sizePoints().transposed()); | 0 | ||||||||||||
224 | else | - | ||||||||||||
225 | return never executed: QRect(QPoint(0, 0), m_pageSize.sizePoints());return QRect(QPoint(0, 0), m_pageSize.sizePoints()); never executed: return QRect(QPoint(0, 0), m_pageSize.sizePoints()); | 0 | ||||||||||||
226 | } | - | ||||||||||||
227 | - | |||||||||||||
228 | QRect QPageLayoutPrivate::fullRectPixels(int resolution) const | - | ||||||||||||
229 | { | - | ||||||||||||
230 | if (m_orientation == QPageLayout::Landscape
| 0 | ||||||||||||
231 | return never executed: QRect(QPoint(0, 0), m_pageSize.sizePixels(resolution).transposed());return QRect(QPoint(0, 0), m_pageSize.sizePixels(resolution).transposed()); never executed: return QRect(QPoint(0, 0), m_pageSize.sizePixels(resolution).transposed()); | 0 | ||||||||||||
232 | else | - | ||||||||||||
233 | return never executed: QRect(QPoint(0, 0), m_pageSize.sizePixels(resolution));return QRect(QPoint(0, 0), m_pageSize.sizePixels(resolution)); never executed: return QRect(QPoint(0, 0), m_pageSize.sizePixels(resolution)); | 0 | ||||||||||||
234 | } | - | ||||||||||||
235 | - | |||||||||||||
236 | QRectF QPageLayoutPrivate::paintRect() const | - | ||||||||||||
237 | { | - | ||||||||||||
238 | return never executed: m_mode == QPageLayout::FullPageMode ? fullRect() : fullRect() - m_margins;return m_mode == QPageLayout::FullPageMode ? fullRect() : fullRect() - m_margins; never executed: return m_mode == QPageLayout::FullPageMode ? fullRect() : fullRect() - m_margins; | 0 | ||||||||||||
239 | } | - | ||||||||||||
240 | QPageLayout::QPageLayout() | - | ||||||||||||
241 | : d(new QPageLayoutPrivate()) | - | ||||||||||||
242 | { | - | ||||||||||||
243 | } never executed: end of block | 0 | ||||||||||||
244 | QPageLayout::QPageLayout(const QPageSize &pageSize, Orientation orientation, | - | ||||||||||||
245 | const QMarginsF &margins, Unit units, | - | ||||||||||||
246 | const QMarginsF &minMargins) | - | ||||||||||||
247 | : d(new QPageLayoutPrivate(pageSize, orientation, margins, units, minMargins)) | - | ||||||||||||
248 | { | - | ||||||||||||
249 | } never executed: end of block | 0 | ||||||||||||
250 | - | |||||||||||||
251 | - | |||||||||||||
252 | - | |||||||||||||
253 | - | |||||||||||||
254 | - | |||||||||||||
255 | QPageLayout::QPageLayout(const QPageLayout &other) | - | ||||||||||||
256 | : d(other.d) | - | ||||||||||||
257 | { | - | ||||||||||||
258 | } never executed: end of block | 0 | ||||||||||||
259 | - | |||||||||||||
260 | - | |||||||||||||
261 | - | |||||||||||||
262 | - | |||||||||||||
263 | - | |||||||||||||
264 | QPageLayout::~QPageLayout() | - | ||||||||||||
265 | { | - | ||||||||||||
266 | } | - | ||||||||||||
267 | - | |||||||||||||
268 | - | |||||||||||||
269 | - | |||||||||||||
270 | - | |||||||||||||
271 | - | |||||||||||||
272 | QPageLayout &QPageLayout::operator=(const QPageLayout &other) | - | ||||||||||||
273 | { | - | ||||||||||||
274 | d = other.d; | - | ||||||||||||
275 | return never executed: *this;return *this; never executed: return *this; | 0 | ||||||||||||
276 | } | - | ||||||||||||
277 | bool operator==(const QPageLayout &lhs, const QPageLayout &rhs) | - | ||||||||||||
278 | { | - | ||||||||||||
279 | return never executed: lhs.d == rhs.d || *lhs.d == *rhs.d;return lhs.d == rhs.d || *lhs.d == *rhs.d; never executed: return lhs.d == rhs.d || *lhs.d == *rhs.d; | 0 | ||||||||||||
280 | } | - | ||||||||||||
281 | bool QPageLayout::isEquivalentTo(const QPageLayout &other) const | - | ||||||||||||
282 | { | - | ||||||||||||
283 | return never executed: d && other.d && d->isEquivalentTo(*other.d);return d && other.d && d->isEquivalentTo(*other.d); never executed: return d && other.d && d->isEquivalentTo(*other.d); | 0 | ||||||||||||
284 | } | - | ||||||||||||
285 | - | |||||||||||||
286 | - | |||||||||||||
287 | - | |||||||||||||
288 | - | |||||||||||||
289 | - | |||||||||||||
290 | bool QPageLayout::isValid() const | - | ||||||||||||
291 | { | - | ||||||||||||
292 | return never executed: d->isValid();return d->isValid(); never executed: return d->isValid(); | 0 | ||||||||||||
293 | } | - | ||||||||||||
294 | - | |||||||||||||
295 | - | |||||||||||||
296 | - | |||||||||||||
297 | - | |||||||||||||
298 | - | |||||||||||||
299 | void QPageLayout::setMode(Mode mode) | - | ||||||||||||
300 | { | - | ||||||||||||
301 | d.detach(); | - | ||||||||||||
302 | d->m_mode = mode; | - | ||||||||||||
303 | } never executed: end of block | 0 | ||||||||||||
304 | - | |||||||||||||
305 | - | |||||||||||||
306 | - | |||||||||||||
307 | - | |||||||||||||
308 | - | |||||||||||||
309 | QPageLayout::Mode QPageLayout::mode() const | - | ||||||||||||
310 | { | - | ||||||||||||
311 | return never executed: d->m_mode;return d->m_mode; never executed: return d->m_mode; | 0 | ||||||||||||
312 | } | - | ||||||||||||
313 | void QPageLayout::setPageSize(const QPageSize &pageSize, const QMarginsF &minMargins) | - | ||||||||||||
314 | { | - | ||||||||||||
315 | if (!pageSize.isValid()
| 0 | ||||||||||||
316 | return; never executed: return; | 0 | ||||||||||||
317 | d.detach(); | - | ||||||||||||
318 | d->m_pageSize = pageSize; | - | ||||||||||||
319 | d->m_fullSize = d->fullSizeUnits(d->m_units); | - | ||||||||||||
320 | d->setDefaultMargins(minMargins); | - | ||||||||||||
321 | } never executed: end of block | 0 | ||||||||||||
322 | QPageSize QPageLayout::pageSize() const | - | ||||||||||||
323 | { | - | ||||||||||||
324 | return never executed: d->m_pageSize;return d->m_pageSize; never executed: return d->m_pageSize; | 0 | ||||||||||||
325 | } | - | ||||||||||||
326 | void QPageLayout::setOrientation(Orientation orientation) | - | ||||||||||||
327 | { | - | ||||||||||||
328 | if (orientation != d->m_orientation
| 0 | ||||||||||||
329 | d.detach(); | - | ||||||||||||
330 | d->m_orientation = orientation; | - | ||||||||||||
331 | d->m_fullSize = d->fullSizeUnits(d->m_units); | - | ||||||||||||
332 | - | |||||||||||||
333 | const qreal change = d->m_fullSize.width() - d->m_fullSize.height(); | - | ||||||||||||
334 | d->m_maxMargins.setLeft(d->m_maxMargins.left() + change); | - | ||||||||||||
335 | d->m_maxMargins.setRight(d->m_maxMargins.right() + change); | - | ||||||||||||
336 | d->m_maxMargins.setTop(d->m_maxMargins.top() - change); | - | ||||||||||||
337 | d->m_maxMargins.setBottom(d->m_maxMargins.bottom() - change); | - | ||||||||||||
338 | } never executed: end of block | 0 | ||||||||||||
339 | } never executed: end of block | 0 | ||||||||||||
340 | - | |||||||||||||
341 | - | |||||||||||||
342 | - | |||||||||||||
343 | - | |||||||||||||
344 | - | |||||||||||||
345 | QPageLayout::Orientation QPageLayout::orientation() const | - | ||||||||||||
346 | { | - | ||||||||||||
347 | return never executed: d->m_orientation;return d->m_orientation; never executed: return d->m_orientation; | 0 | ||||||||||||
348 | } | - | ||||||||||||
349 | - | |||||||||||||
350 | - | |||||||||||||
351 | - | |||||||||||||
352 | - | |||||||||||||
353 | - | |||||||||||||
354 | void QPageLayout::setUnits(Unit units) | - | ||||||||||||
355 | { | - | ||||||||||||
356 | if (units != d->m_units
| 0 | ||||||||||||
357 | d.detach(); | - | ||||||||||||
358 | d->m_margins = qt_convertMargins(d->m_margins, d->m_units, units); | - | ||||||||||||
359 | d->m_minMargins = qt_convertMargins(d->m_minMargins, d->m_units, units); | - | ||||||||||||
360 | d->m_maxMargins = qt_convertMargins(d->m_maxMargins, d->m_units, units); | - | ||||||||||||
361 | d->m_units = units; | - | ||||||||||||
362 | d->m_fullSize = d->fullSizeUnits(d->m_units); | - | ||||||||||||
363 | } never executed: end of block | 0 | ||||||||||||
364 | } never executed: end of block | 0 | ||||||||||||
365 | - | |||||||||||||
366 | - | |||||||||||||
367 | - | |||||||||||||
368 | - | |||||||||||||
369 | - | |||||||||||||
370 | QPageLayout::Unit QPageLayout::units() const | - | ||||||||||||
371 | { | - | ||||||||||||
372 | return never executed: d->m_units;return d->m_units; never executed: return d->m_units; | 0 | ||||||||||||
373 | } | - | ||||||||||||
374 | bool QPageLayout::setMargins(const QMarginsF &margins) | - | ||||||||||||
375 | { | - | ||||||||||||
376 | if (d->m_mode == FullPageMode
| 0 | ||||||||||||
377 | d.detach(); | - | ||||||||||||
378 | d->m_margins = margins; | - | ||||||||||||
379 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||
380 | } else if (margins.left() >= d->m_minMargins.left()
| 0 | ||||||||||||
381 | && margins.right() >= d->m_minMargins.right()
| 0 | ||||||||||||
382 | && margins.top() >= d->m_minMargins.top()
| 0 | ||||||||||||
383 | && margins.bottom() >= d->m_minMargins.bottom()
| 0 | ||||||||||||
384 | && margins.left() <= d->m_maxMargins.left()
| 0 | ||||||||||||
385 | && margins.right() <= d->m_maxMargins.right()
| 0 | ||||||||||||
386 | && margins.top() <= d->m_maxMargins.top()
| 0 | ||||||||||||
387 | && margins.bottom() <= d->m_maxMargins.bottom()
| 0 | ||||||||||||
388 | d.detach(); | - | ||||||||||||
389 | d->m_margins = margins; | - | ||||||||||||
390 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||
391 | } | - | ||||||||||||
392 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
393 | } | - | ||||||||||||
394 | bool QPageLayout::setLeftMargin(qreal leftMargin) | - | ||||||||||||
395 | { | - | ||||||||||||
396 | if (d->m_mode == FullPageMode
| 0 | ||||||||||||
397 | || (leftMargin >= d->m_minMargins.left()
| 0 | ||||||||||||
398 | d.detach(); | - | ||||||||||||
399 | d->m_margins.setLeft(leftMargin); | - | ||||||||||||
400 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||
401 | } | - | ||||||||||||
402 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
403 | } | - | ||||||||||||
404 | bool QPageLayout::setRightMargin(qreal rightMargin) | - | ||||||||||||
405 | { | - | ||||||||||||
406 | if (d->m_mode == FullPageMode
| 0 | ||||||||||||
407 | || (rightMargin >= d->m_minMargins.right()
| 0 | ||||||||||||
408 | d.detach(); | - | ||||||||||||
409 | d->m_margins.setRight(rightMargin); | - | ||||||||||||
410 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||
411 | } | - | ||||||||||||
412 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
413 | } | - | ||||||||||||
414 | bool QPageLayout::setTopMargin(qreal topMargin) | - | ||||||||||||
415 | { | - | ||||||||||||
416 | if (d->m_mode == FullPageMode
| 0 | ||||||||||||
417 | || (topMargin >= d->m_minMargins.top()
| 0 | ||||||||||||
418 | d.detach(); | - | ||||||||||||
419 | d->m_margins.setTop(topMargin); | - | ||||||||||||
420 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||
421 | } | - | ||||||||||||
422 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
423 | } | - | ||||||||||||
424 | bool QPageLayout::setBottomMargin(qreal bottomMargin) | - | ||||||||||||
425 | { | - | ||||||||||||
426 | if (d->m_mode == FullPageMode
| 0 | ||||||||||||
427 | || (bottomMargin >= d->m_minMargins.bottom()
| 0 | ||||||||||||
428 | d.detach(); | - | ||||||||||||
429 | d->m_margins.setBottom(bottomMargin); | - | ||||||||||||
430 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||
431 | } | - | ||||||||||||
432 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
433 | } | - | ||||||||||||
434 | - | |||||||||||||
435 | - | |||||||||||||
436 | - | |||||||||||||
437 | - | |||||||||||||
438 | - | |||||||||||||
439 | - | |||||||||||||
440 | - | |||||||||||||
441 | QMarginsF QPageLayout::margins() const | - | ||||||||||||
442 | { | - | ||||||||||||
443 | return never executed: d->m_margins;return d->m_margins; never executed: return d->m_margins; | 0 | ||||||||||||
444 | } | - | ||||||||||||
445 | - | |||||||||||||
446 | - | |||||||||||||
447 | - | |||||||||||||
448 | - | |||||||||||||
449 | - | |||||||||||||
450 | - | |||||||||||||
451 | - | |||||||||||||
452 | QMarginsF QPageLayout::margins(Unit units) const | - | ||||||||||||
453 | { | - | ||||||||||||
454 | return never executed: d->margins(units);return d->margins(units); never executed: return d->margins(units); | 0 | ||||||||||||
455 | } | - | ||||||||||||
456 | - | |||||||||||||
457 | - | |||||||||||||
458 | - | |||||||||||||
459 | - | |||||||||||||
460 | - | |||||||||||||
461 | - | |||||||||||||
462 | - | |||||||||||||
463 | QMargins QPageLayout::marginsPoints() const | - | ||||||||||||
464 | { | - | ||||||||||||
465 | return never executed: d->marginsPoints();return d->marginsPoints(); never executed: return d->marginsPoints(); | 0 | ||||||||||||
466 | } | - | ||||||||||||
467 | - | |||||||||||||
468 | - | |||||||||||||
469 | - | |||||||||||||
470 | - | |||||||||||||
471 | - | |||||||||||||
472 | - | |||||||||||||
473 | - | |||||||||||||
474 | QMargins QPageLayout::marginsPixels(int resolution) const | - | ||||||||||||
475 | { | - | ||||||||||||
476 | return never executed: d->marginsPixels(resolution);return d->marginsPixels(resolution); never executed: return d->marginsPixels(resolution); | 0 | ||||||||||||
477 | } | - | ||||||||||||
478 | void QPageLayout::setMinimumMargins(const QMarginsF &minMargins) | - | ||||||||||||
479 | { | - | ||||||||||||
480 | d.detach(); | - | ||||||||||||
481 | d->setDefaultMargins(minMargins); | - | ||||||||||||
482 | } never executed: end of block | 0 | ||||||||||||
483 | - | |||||||||||||
484 | - | |||||||||||||
485 | - | |||||||||||||
486 | - | |||||||||||||
487 | - | |||||||||||||
488 | - | |||||||||||||
489 | - | |||||||||||||
490 | QMarginsF QPageLayout::minimumMargins() const | - | ||||||||||||
491 | { | - | ||||||||||||
492 | return never executed: d->m_minMargins;return d->m_minMargins; never executed: return d->m_minMargins; | 0 | ||||||||||||
493 | } | - | ||||||||||||
494 | QMarginsF QPageLayout::maximumMargins() const | - | ||||||||||||
495 | { | - | ||||||||||||
496 | return never executed: d->m_maxMargins;return d->m_maxMargins; never executed: return d->m_maxMargins; | 0 | ||||||||||||
497 | } | - | ||||||||||||
498 | QRectF QPageLayout::fullRect() const | - | ||||||||||||
499 | { | - | ||||||||||||
500 | return never executed: isValid() ? d->fullRect() : QRect();return isValid() ? d->fullRect() : QRect(); never executed: return isValid() ? d->fullRect() : QRect(); | 0 | ||||||||||||
501 | } | - | ||||||||||||
502 | QRectF QPageLayout::fullRect(Unit units) const | - | ||||||||||||
503 | { | - | ||||||||||||
504 | return never executed: isValid() ? d->fullRect(units) : QRect();return isValid() ? d->fullRect(units) : QRect(); never executed: return isValid() ? d->fullRect(units) : QRect(); | 0 | ||||||||||||
505 | } | - | ||||||||||||
506 | QRect QPageLayout::fullRectPoints() const | - | ||||||||||||
507 | { | - | ||||||||||||
508 | return never executed: isValid() ? d->fullRectPoints() : QRect();return isValid() ? d->fullRectPoints() : QRect(); never executed: return isValid() ? d->fullRectPoints() : QRect(); | 0 | ||||||||||||
509 | } | - | ||||||||||||
510 | QRect QPageLayout::fullRectPixels(int resolution) const | - | ||||||||||||
511 | { | - | ||||||||||||
512 | return never executed: isValid() ? d->fullRectPixels(resolution) : QRect();return isValid() ? d->fullRectPixels(resolution) : QRect(); never executed: return isValid() ? d->fullRectPixels(resolution) : QRect(); | 0 | ||||||||||||
513 | } | - | ||||||||||||
514 | QRectF QPageLayout::paintRect() const | - | ||||||||||||
515 | { | - | ||||||||||||
516 | return never executed: isValid() ? d->paintRect() : QRectF();return isValid() ? d->paintRect() : QRectF(); never executed: return isValid() ? d->paintRect() : QRectF(); | 0 | ||||||||||||
517 | } | - | ||||||||||||
518 | QRectF QPageLayout::paintRect(Unit units) const | - | ||||||||||||
519 | { | - | ||||||||||||
520 | if (!isValid()
| 0 | ||||||||||||
521 | return never executed: QRectF();return QRectF(); never executed: return QRectF(); | 0 | ||||||||||||
522 | if (units == d->m_units
| 0 | ||||||||||||
523 | return never executed: d->paintRect();return d->paintRect(); never executed: return d->paintRect(); | 0 | ||||||||||||
524 | return never executed: d->m_mode == FullPageMode ? d->fullRect(units)return d->m_mode == FullPageMode ? d->fullRect(units) : d->fullRect(units) - d->margins(units); never executed: return d->m_mode == FullPageMode ? d->fullRect(units) : d->fullRect(units) - d->margins(units); | 0 | ||||||||||||
525 | : d->fullRect(units) - d->margins(units); never executed: return d->m_mode == FullPageMode ? d->fullRect(units) : d->fullRect(units) - d->margins(units); | 0 | ||||||||||||
526 | } | - | ||||||||||||
527 | QRect QPageLayout::paintRectPoints() const | - | ||||||||||||
528 | { | - | ||||||||||||
529 | if (!isValid()
| 0 | ||||||||||||
530 | return never executed: QRect();return QRect(); never executed: return QRect(); | 0 | ||||||||||||
531 | return never executed: d->m_mode == FullPageMode ? d->fullRectPoints()return d->m_mode == FullPageMode ? d->fullRectPoints() : d->fullRectPoints() - d->marginsPoints(); never executed: return d->m_mode == FullPageMode ? d->fullRectPoints() : d->fullRectPoints() - d->marginsPoints(); | 0 | ||||||||||||
532 | : d->fullRectPoints() - d->marginsPoints(); never executed: return d->m_mode == FullPageMode ? d->fullRectPoints() : d->fullRectPoints() - d->marginsPoints(); | 0 | ||||||||||||
533 | } | - | ||||||||||||
534 | QRect QPageLayout::paintRectPixels(int resolution) const | - | ||||||||||||
535 | { | - | ||||||||||||
536 | if (!isValid()
| 0 | ||||||||||||
537 | return never executed: QRect();return QRect(); never executed: return QRect(); | 0 | ||||||||||||
538 | return never executed: d->m_mode == FullPageMode ? d->fullRectPixels(resolution)return d->m_mode == FullPageMode ? d->fullRectPixels(resolution) : d->fullRectPixels(resolution) - d->marginsPixels(resolution); never executed: return d->m_mode == FullPageMode ? d->fullRectPixels(resolution) : d->fullRectPixels(resolution) - d->marginsPixels(resolution); | 0 | ||||||||||||
539 | : d->fullRectPixels(resolution) - d->marginsPixels(resolution); never executed: return d->m_mode == FullPageMode ? d->fullRectPixels(resolution) : d->fullRectPixels(resolution) - d->marginsPixels(resolution); | 0 | ||||||||||||
540 | } | - | ||||||||||||
541 | - | |||||||||||||
542 | - | |||||||||||||
543 | QDebug operator<<(QDebug dbg, const QPageLayout &layout) | - | ||||||||||||
544 | { | - | ||||||||||||
545 | QDebugStateSaver saver(dbg); | - | ||||||||||||
546 | dbg.nospace(); | - | ||||||||||||
547 | dbg.noquote(); | - | ||||||||||||
548 | dbg << "QPageLayout("; | - | ||||||||||||
549 | if (layout.isValid()
| 0 | ||||||||||||
550 | const QMarginsF margins = layout.margins(); | - | ||||||||||||
551 | dbg << '"' << layout.pageSize().name() << "\", " | - | ||||||||||||
552 | << (layout.orientation() == QPageLayout::Portrait ? "Portrait" : "Landscape") | - | ||||||||||||
553 | << ", l:" << margins.left() << " r:" << margins.right() << " t:" | - | ||||||||||||
554 | << margins.top() << " b:" << margins.bottom() << ' '; | - | ||||||||||||
555 | switch (layout.units()) { | - | ||||||||||||
556 | case never executed: QPageLayout::Millimeter:case QPageLayout::Millimeter: never executed: case QPageLayout::Millimeter: | 0 | ||||||||||||
557 | dbg << "mm"; | - | ||||||||||||
558 | break; never executed: break; | 0 | ||||||||||||
559 | case never executed: QPageLayout::Point:case QPageLayout::Point: never executed: case QPageLayout::Point: | 0 | ||||||||||||
560 | dbg << "pt"; | - | ||||||||||||
561 | break; never executed: break; | 0 | ||||||||||||
562 | case never executed: QPageLayout::Inch:case QPageLayout::Inch: never executed: case QPageLayout::Inch: | 0 | ||||||||||||
563 | dbg << "in"; | - | ||||||||||||
564 | break; never executed: break; | 0 | ||||||||||||
565 | case never executed: QPageLayout::Pica:case QPageLayout::Pica: never executed: case QPageLayout::Pica: | 0 | ||||||||||||
566 | dbg << "pc"; | - | ||||||||||||
567 | break; never executed: break; | 0 | ||||||||||||
568 | case never executed: QPageLayout::Didot:case QPageLayout::Didot: never executed: case QPageLayout::Didot: | 0 | ||||||||||||
569 | dbg << "DD"; | - | ||||||||||||
570 | break; never executed: break; | 0 | ||||||||||||
571 | case never executed: QPageLayout::Cicero:case QPageLayout::Cicero: never executed: case QPageLayout::Cicero: | 0 | ||||||||||||
572 | dbg << "CC"; | - | ||||||||||||
573 | break; never executed: break; | 0 | ||||||||||||
574 | } | - | ||||||||||||
575 | } never executed: end of block | 0 | ||||||||||||
576 | dbg << ')'; | - | ||||||||||||
577 | return never executed: dbg;return dbg; never executed: return dbg; | 0 | ||||||||||||
578 | } | - | ||||||||||||
579 | - | |||||||||||||
580 | - | |||||||||||||
581 | - | |||||||||||||
Switch to Source code | Preprocessed file |