widgets/qprintpreviewwidget.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtGui module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qprintpreviewwidget.h" -
43#include "private/qwidget_p.h" -
44#include <private/qprinter_p.h> -
45 -
46#include <QtCore/qmath.h> -
47#include <QtWidgets/qboxlayout.h> -
48#include <QtWidgets/qgraphicsitem.h> -
49#include <QtWidgets/qgraphicsview.h> -
50#include <QtWidgets/qscrollbar.h> -
51#include <QtWidgets/qstyleoption.h> -
52 -
53#ifndef QT_NO_PRINTPREVIEWWIDGET -
54 -
55QT_BEGIN_NAMESPACE -
56 -
57namespace { -
58class PageItem : public QGraphicsItem -
59{ -
60public: -
61 PageItem(int _pageNum, const QPicture* _pagePicture, QSize _paperSize, QRect _pageRect) -
62 : pageNum(_pageNum), pagePicture(_pagePicture), -
63 paperSize(_paperSize), pageRect(_pageRect) -
64 { -
65 qreal border = qMax(paperSize.height(), paperSize.width()) / 25;
never executed (the execution status of this line is deduced): qreal border = qMax(paperSize.height(), paperSize.width()) / 25;
-
66 brect = QRectF(QPointF(-border, -border),
never executed (the execution status of this line is deduced): brect = QRectF(QPointF(-border, -border),
-
67 QSizeF(paperSize)+QSizeF(2*border, 2*border));
never executed (the execution status of this line is deduced): QSizeF(paperSize)+QSizeF(2*border, 2*border));
-
68 setCacheMode(DeviceCoordinateCache);
never executed (the execution status of this line is deduced): setCacheMode(DeviceCoordinateCache);
-
69 }
never executed: }
0
70 -
71 inline QRectF boundingRect() const -
72 { return brect; }
never executed: return brect;
0
73 -
74 inline int pageNumber() const -
75 { return pageNum; }
never executed: return pageNum;
0
76 -
77 void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget); -
78 -
79private: -
80 int pageNum; -
81 const QPicture* pagePicture; -
82 QSize paperSize; -
83 QRect pageRect; -
84 QRectF brect; -
85}; -
86 -
87void PageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -
88{ -
89 Q_UNUSED(widget);
never executed (the execution status of this line is deduced): (void)widget;;
-
90 -
91#if 0 -
92 // Draw item bounding rect, for debugging -
93 painter->save(); -
94 painter->setPen(QPen(Qt::red, 0)); -
95 painter->setBrush(Qt::NoBrush); -
96 painter->drawRect(QRectF(-border()+1.0, -border()+1.0, boundingRect().width()-2, boundingRect().height()-2)); -
97 painter->restore(); -
98#endif -
99 -
100 QRectF paperRect(0,0, paperSize.width(), paperSize.height());
never executed (the execution status of this line is deduced): QRectF paperRect(0,0, paperSize.width(), paperSize.height());
-
101 -
102 // Draw shadow -
103 painter->setClipRect(option->exposedRect);
never executed (the execution status of this line is deduced): painter->setClipRect(option->exposedRect);
-
104 qreal shWidth = paperRect.width()/100;
never executed (the execution status of this line is deduced): qreal shWidth = paperRect.width()/100;
-
105 QRectF rshadow(paperRect.topRight() + QPointF(0, shWidth),
never executed (the execution status of this line is deduced): QRectF rshadow(paperRect.topRight() + QPointF(0, shWidth),
-
106 paperRect.bottomRight() + QPointF(shWidth, 0));
never executed (the execution status of this line is deduced): paperRect.bottomRight() + QPointF(shWidth, 0));
-
107 QLinearGradient rgrad(rshadow.topLeft(), rshadow.topRight());
never executed (the execution status of this line is deduced): QLinearGradient rgrad(rshadow.topLeft(), rshadow.topRight());
-
108 rgrad.setColorAt(0.0, QColor(0,0,0,255));
never executed (the execution status of this line is deduced): rgrad.setColorAt(0.0, QColor(0,0,0,255));
-
109 rgrad.setColorAt(1.0, QColor(0,0,0,0));
never executed (the execution status of this line is deduced): rgrad.setColorAt(1.0, QColor(0,0,0,0));
-
110 painter->fillRect(rshadow, QBrush(rgrad));
never executed (the execution status of this line is deduced): painter->fillRect(rshadow, QBrush(rgrad));
-
111 QRectF bshadow(paperRect.bottomLeft() + QPointF(shWidth, 0),
never executed (the execution status of this line is deduced): QRectF bshadow(paperRect.bottomLeft() + QPointF(shWidth, 0),
-
112 paperRect.bottomRight() + QPointF(0, shWidth));
never executed (the execution status of this line is deduced): paperRect.bottomRight() + QPointF(0, shWidth));
-
113 QLinearGradient bgrad(bshadow.topLeft(), bshadow.bottomLeft());
never executed (the execution status of this line is deduced): QLinearGradient bgrad(bshadow.topLeft(), bshadow.bottomLeft());
-
114 bgrad.setColorAt(0.0, QColor(0,0,0,255));
never executed (the execution status of this line is deduced): bgrad.setColorAt(0.0, QColor(0,0,0,255));
-
115 bgrad.setColorAt(1.0, QColor(0,0,0,0));
never executed (the execution status of this line is deduced): bgrad.setColorAt(1.0, QColor(0,0,0,0));
-
116 painter->fillRect(bshadow, QBrush(bgrad));
never executed (the execution status of this line is deduced): painter->fillRect(bshadow, QBrush(bgrad));
-
117 QRectF cshadow(paperRect.bottomRight(),
never executed (the execution status of this line is deduced): QRectF cshadow(paperRect.bottomRight(),
-
118 paperRect.bottomRight() + QPointF(shWidth, shWidth));
never executed (the execution status of this line is deduced): paperRect.bottomRight() + QPointF(shWidth, shWidth));
-
119 QRadialGradient cgrad(cshadow.topLeft(), shWidth, cshadow.topLeft());
never executed (the execution status of this line is deduced): QRadialGradient cgrad(cshadow.topLeft(), shWidth, cshadow.topLeft());
-
120 cgrad.setColorAt(0.0, QColor(0,0,0,255));
never executed (the execution status of this line is deduced): cgrad.setColorAt(0.0, QColor(0,0,0,255));
-
121 cgrad.setColorAt(1.0, QColor(0,0,0,0));
never executed (the execution status of this line is deduced): cgrad.setColorAt(1.0, QColor(0,0,0,0));
-
122 painter->fillRect(cshadow, QBrush(cgrad));
never executed (the execution status of this line is deduced): painter->fillRect(cshadow, QBrush(cgrad));
-
123 -
124 painter->setClipRect(paperRect & option->exposedRect);
never executed (the execution status of this line is deduced): painter->setClipRect(paperRect & option->exposedRect);
-
125 painter->fillRect(paperRect, Qt::white);
never executed (the execution status of this line is deduced): painter->fillRect(paperRect, Qt::white);
-
126 if (!pagePicture)
never evaluated: !pagePicture
0
127 return;
never executed: return;
0
128 painter->drawPicture(pageRect.topLeft(), *pagePicture);
never executed (the execution status of this line is deduced): painter->drawPicture(pageRect.topLeft(), *pagePicture);
-
129 -
130 // Effect: make anything drawn in the margins look washed out. -
131 QPainterPath path;
never executed (the execution status of this line is deduced): QPainterPath path;
-
132 path.addRect(paperRect);
never executed (the execution status of this line is deduced): path.addRect(paperRect);
-
133 path.addRect(pageRect);
never executed (the execution status of this line is deduced): path.addRect(pageRect);
-
134 painter->setPen(QPen(Qt::NoPen));
never executed (the execution status of this line is deduced): painter->setPen(QPen(Qt::NoPen));
-
135 painter->setBrush(QColor(255, 255, 255, 180));
never executed (the execution status of this line is deduced): painter->setBrush(QColor(255, 255, 255, 180));
-
136 painter->drawPath(path);
never executed (the execution status of this line is deduced): painter->drawPath(path);
-
137 -
138#if 0 -
139 // Draw frame around paper. -
140 painter->setPen(QPen(Qt::black, 0)); -
141 painter->setBrush(Qt::NoBrush); -
142 painter->drawRect(paperRect); -
143#endif -
144 -
145 // todo: drawtext "Page N" below paper -
146}
never executed: }
0
147 -
148class GraphicsView : public QGraphicsView -
149{ -
150 Q_OBJECT -
151public: -
152 GraphicsView(QWidget* parent = 0) -
153 : QGraphicsView(parent) -
154 { -
155#ifdef Q_OS_MAC -
156 setFrameStyle(QFrame::NoFrame); -
157#endif -
158 }
never executed: }
0
159signals: -
160 void resized(); -
161 -
162protected: -
163 void resizeEvent(QResizeEvent* e) -
164 { -
165 QGraphicsView::resizeEvent(e);
never executed (the execution status of this line is deduced): QGraphicsView::resizeEvent(e);
-
166 emit resized();
never executed (the execution status of this line is deduced): resized();
-
167 }
never executed: }
0
168 -
169 void showEvent(QShowEvent* e) -
170 { -
171 QGraphicsView::showEvent(e);
never executed (the execution status of this line is deduced): QGraphicsView::showEvent(e);
-
172 emit resized();
never executed (the execution status of this line is deduced): resized();
-
173 }
never executed: }
0
174}; -
175 -
176} // anonymous namespace -
177 -
178class QPrintPreviewWidgetPrivate : public QWidgetPrivate -
179{ -
180 Q_DECLARE_PUBLIC(QPrintPreviewWidget) -
181public: -
182 QPrintPreviewWidgetPrivate() -
183 : scene(0), curPage(1), -
184 viewMode(QPrintPreviewWidget::SinglePageView), -
185 zoomMode(QPrintPreviewWidget::FitInView), -
186 zoomFactor(1), initialized(false), fitting(true) -
187 {}
never executed: }
0
188 -
189 // private slots -
190 void _q_fit(bool doFitting = false); -
191 void _q_updateCurrentPage(); -
192 -
193 void init(); -
194 void populateScene(); -
195 void layoutPages(); -
196 void generatePreview(); -
197 void setCurrentPage(int pageNumber); -
198 void zoom(qreal zoom); -
199 void setZoomFactor(qreal zoomFactor); -
200 int calcCurrentPage(); -
201 -
202 GraphicsView *graphicsView; -
203 QGraphicsScene *scene; -
204 -
205 int curPage; -
206 QList<const QPicture *> pictures; -
207 QList<QGraphicsItem *> pages; -
208 -
209 QPrintPreviewWidget::ViewMode viewMode; -
210 QPrintPreviewWidget::ZoomMode zoomMode; -
211 qreal zoomFactor; -
212 bool ownPrinter; -
213 QPrinter* printer; -
214 bool initialized; -
215 bool fitting; -
216}; -
217 -
218void QPrintPreviewWidgetPrivate::_q_fit(bool doFitting) -
219{ -
220 Q_Q(QPrintPreviewWidget);
never executed (the execution status of this line is deduced): QPrintPreviewWidget * const q = q_func();
-
221 -
222 if (curPage < 1 || curPage > pages.count())
never evaluated: curPage < 1
never evaluated: curPage > pages.count()
0
223 return;
never executed: return;
0
224 -
225 if (!doFitting && !fitting)
never evaluated: !doFitting
never evaluated: !fitting
0
226 return;
never executed: return;
0
227 -
228 if (doFitting && fitting) {
never evaluated: doFitting
never evaluated: fitting
0
229 QRect viewRect = graphicsView->viewport()->rect();
never executed (the execution status of this line is deduced): QRect viewRect = graphicsView->viewport()->rect();
-
230 if (zoomMode == QPrintPreviewWidget::FitInView) {
never evaluated: zoomMode == QPrintPreviewWidget::FitInView
0
231 QList<QGraphicsItem*> containedItems = graphicsView->items(viewRect, Qt::ContainsItemBoundingRect);
never executed (the execution status of this line is deduced): QList<QGraphicsItem*> containedItems = graphicsView->items(viewRect, Qt::ContainsItemBoundingRect);
-
232 foreach(QGraphicsItem* item, containedItems) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(containedItems)> _container_(containedItems); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem* item = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
233 PageItem* pg = static_cast<PageItem*>(item);
never executed (the execution status of this line is deduced): PageItem* pg = static_cast<PageItem*>(item);
-
234 if (pg->pageNumber() == curPage)
never evaluated: pg->pageNumber() == curPage
0
235 return;
never executed: return;
0
236 }
never executed: }
0
237 }
never executed: }
0
238 -
239 int newPage = calcCurrentPage();
never executed (the execution status of this line is deduced): int newPage = calcCurrentPage();
-
240 if (newPage != curPage)
never evaluated: newPage != curPage
0
241 curPage = newPage;
never executed: curPage = newPage;
0
242 }
never executed: }
0
243 -
244 QRectF target = pages.at(curPage-1)->sceneBoundingRect();
never executed (the execution status of this line is deduced): QRectF target = pages.at(curPage-1)->sceneBoundingRect();
-
245 if (viewMode == QPrintPreviewWidget::FacingPagesView) {
never evaluated: viewMode == QPrintPreviewWidget::FacingPagesView
0
246 // fit two pages -
247 if (curPage % 2)
never evaluated: curPage % 2
0
248 target.setLeft(target.left() - target.width());
never executed: target.setLeft(target.left() - target.width());
0
249 else -
250 target.setRight(target.right() + target.width());
never executed: target.setRight(target.right() + target.width());
0
251 } else if (viewMode == QPrintPreviewWidget::AllPagesView) {
never evaluated: viewMode == QPrintPreviewWidget::AllPagesView
0
252 target = scene->itemsBoundingRect();
never executed (the execution status of this line is deduced): target = scene->itemsBoundingRect();
-
253 }
never executed: }
0
254 -
255 if (zoomMode == QPrintPreviewWidget::FitToWidth) {
never evaluated: zoomMode == QPrintPreviewWidget::FitToWidth
0
256 QTransform t;
never executed (the execution status of this line is deduced): QTransform t;
-
257 qreal scale = graphicsView->viewport()->width() / target.width();
never executed (the execution status of this line is deduced): qreal scale = graphicsView->viewport()->width() / target.width();
-
258 t.scale(scale, scale);
never executed (the execution status of this line is deduced): t.scale(scale, scale);
-
259 graphicsView->setTransform(t);
never executed (the execution status of this line is deduced): graphicsView->setTransform(t);
-
260 if (doFitting && fitting) {
never evaluated: doFitting
never evaluated: fitting
0
261 QRectF viewSceneRect = graphicsView->viewportTransform().mapRect(graphicsView->viewport()->rect());
never executed (the execution status of this line is deduced): QRectF viewSceneRect = graphicsView->viewportTransform().mapRect(graphicsView->viewport()->rect());
-
262 viewSceneRect.moveTop(target.top());
never executed (the execution status of this line is deduced): viewSceneRect.moveTop(target.top());
-
263 graphicsView->ensureVisible(viewSceneRect); // Nah...
never executed (the execution status of this line is deduced): graphicsView->ensureVisible(viewSceneRect);
-
264 }
never executed: }
0
265 } else {
never executed: }
0
266 graphicsView->fitInView(target, Qt::KeepAspectRatio);
never executed (the execution status of this line is deduced): graphicsView->fitInView(target, Qt::KeepAspectRatio);
-
267 if (zoomMode == QPrintPreviewWidget::FitInView) {
never evaluated: zoomMode == QPrintPreviewWidget::FitInView
0
268 int step = qRound(graphicsView->matrix().mapRect(target).height());
never executed (the execution status of this line is deduced): int step = qRound(graphicsView->matrix().mapRect(target).height());
-
269 graphicsView->verticalScrollBar()->setSingleStep(step);
never executed (the execution status of this line is deduced): graphicsView->verticalScrollBar()->setSingleStep(step);
-
270 graphicsView->verticalScrollBar()->setPageStep(step);
never executed (the execution status of this line is deduced): graphicsView->verticalScrollBar()->setPageStep(step);
-
271 }
never executed: }
0
272 }
never executed: }
0
273 -
274 zoomFactor = graphicsView->transform().m11() * (float(printer->logicalDpiY()) / q->logicalDpiY());
never executed (the execution status of this line is deduced): zoomFactor = graphicsView->transform().m11() * (float(printer->logicalDpiY()) / q->logicalDpiY());
-
275 emit q->previewChanged();
never executed (the execution status of this line is deduced): q->previewChanged();
-
276}
never executed: }
0
277 -
278void QPrintPreviewWidgetPrivate::_q_updateCurrentPage() -
279{ -
280 Q_Q(QPrintPreviewWidget);
never executed (the execution status of this line is deduced): QPrintPreviewWidget * const q = q_func();
-
281 -
282 if (viewMode == QPrintPreviewWidget::AllPagesView)
never evaluated: viewMode == QPrintPreviewWidget::AllPagesView
0
283 return;
never executed: return;
0
284 -
285 int newPage = calcCurrentPage();
never executed (the execution status of this line is deduced): int newPage = calcCurrentPage();
-
286 if (newPage != curPage) {
never evaluated: newPage != curPage
0
287 curPage = newPage;
never executed (the execution status of this line is deduced): curPage = newPage;
-
288 emit q->previewChanged();
never executed (the execution status of this line is deduced): q->previewChanged();
-
289 }
never executed: }
0
290}
never executed: }
0
291 -
292int QPrintPreviewWidgetPrivate::calcCurrentPage() -
293{ -
294 int maxArea = 0;
never executed (the execution status of this line is deduced): int maxArea = 0;
-
295 int newPage = curPage;
never executed (the execution status of this line is deduced): int newPage = curPage;
-
296 QRect viewRect = graphicsView->viewport()->rect();
never executed (the execution status of this line is deduced): QRect viewRect = graphicsView->viewport()->rect();
-
297 QList<QGraphicsItem*> items = graphicsView->items(viewRect);
never executed (the execution status of this line is deduced): QList<QGraphicsItem*> items = graphicsView->items(viewRect);
-
298 for (int i=0; i<items.size(); ++i) {
never evaluated: i<items.size()
0
299 PageItem* pg = static_cast<PageItem*>(items.at(i));
never executed (the execution status of this line is deduced): PageItem* pg = static_cast<PageItem*>(items.at(i));
-
300 QRect overlap = graphicsView->mapFromScene(pg->sceneBoundingRect()).boundingRect() & viewRect;
never executed (the execution status of this line is deduced): QRect overlap = graphicsView->mapFromScene(pg->sceneBoundingRect()).boundingRect() & viewRect;
-
301 int area = overlap.width() * overlap.height();
never executed (the execution status of this line is deduced): int area = overlap.width() * overlap.height();
-
302 if (area > maxArea) {
never evaluated: area > maxArea
0
303 maxArea = area;
never executed (the execution status of this line is deduced): maxArea = area;
-
304 newPage = pg->pageNumber();
never executed (the execution status of this line is deduced): newPage = pg->pageNumber();
-
305 } else if (area == maxArea && pg->pageNumber() < newPage) {
never executed: }
never evaluated: area == maxArea
never evaluated: pg->pageNumber() < newPage
0
306 newPage = pg->pageNumber();
never executed (the execution status of this line is deduced): newPage = pg->pageNumber();
-
307 }
never executed: }
0
308 } -
309 return newPage;
never executed: return newPage;
0
310} -
311 -
312void QPrintPreviewWidgetPrivate::init() -
313{ -
314 Q_Q(QPrintPreviewWidget);
never executed (the execution status of this line is deduced): QPrintPreviewWidget * const q = q_func();
-
315 -
316 graphicsView = new GraphicsView;
never executed (the execution status of this line is deduced): graphicsView = new GraphicsView;
-
317 graphicsView->setInteractive(false);
never executed (the execution status of this line is deduced): graphicsView->setInteractive(false);
-
318 graphicsView->setDragMode(QGraphicsView::ScrollHandDrag);
never executed (the execution status of this line is deduced): graphicsView->setDragMode(QGraphicsView::ScrollHandDrag);
-
319 graphicsView->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
never executed (the execution status of this line is deduced): graphicsView->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
-
320 QObject::connect(graphicsView->verticalScrollBar(), SIGNAL(valueChanged(int)),
never executed (the execution status of this line is deduced): QObject::connect(graphicsView->verticalScrollBar(), "2""valueChanged(int)",
-
321 q, SLOT(_q_updateCurrentPage()));
never executed (the execution status of this line is deduced): q, "1""_q_updateCurrentPage()");
-
322 QObject::connect(graphicsView, SIGNAL(resized()), q, SLOT(_q_fit()));
never executed (the execution status of this line is deduced): QObject::connect(graphicsView, "2""resized()", q, "1""_q_fit()");
-
323 -
324 scene = new QGraphicsScene(graphicsView);
never executed (the execution status of this line is deduced): scene = new QGraphicsScene(graphicsView);
-
325 scene->setBackgroundBrush(Qt::gray);
never executed (the execution status of this line is deduced): scene->setBackgroundBrush(Qt::gray);
-
326 graphicsView->setScene(scene);
never executed (the execution status of this line is deduced): graphicsView->setScene(scene);
-
327 -
328 QVBoxLayout *layout = new QVBoxLayout;
never executed (the execution status of this line is deduced): QVBoxLayout *layout = new QVBoxLayout;
-
329 q->setLayout(layout);
never executed (the execution status of this line is deduced): q->setLayout(layout);
-
330 layout->setContentsMargins(0, 0, 0, 0);
never executed (the execution status of this line is deduced): layout->setContentsMargins(0, 0, 0, 0);
-
331 layout->addWidget(graphicsView);
never executed (the execution status of this line is deduced): layout->addWidget(graphicsView);
-
332}
never executed: }
0
333 -
334void QPrintPreviewWidgetPrivate::populateScene() -
335{ -
336 // remove old pages -
337 for (int i = 0; i < pages.size(); i++)
never evaluated: i < pages.size()
0
338 scene->removeItem(pages.at(i));
never executed: scene->removeItem(pages.at(i));
0
339 qDeleteAll(pages);
never executed (the execution status of this line is deduced): qDeleteAll(pages);
-
340 pages.clear();
never executed (the execution status of this line is deduced): pages.clear();
-
341 -
342 int numPages = pictures.count();
never executed (the execution status of this line is deduced): int numPages = pictures.count();
-
343 QSize paperSize = printer->paperRect().size();
never executed (the execution status of this line is deduced): QSize paperSize = printer->paperRect().size();
-
344 QRect pageRect = printer->pageRect();
never executed (the execution status of this line is deduced): QRect pageRect = printer->pageRect();
-
345 -
346 for (int i = 0; i < numPages; i++) {
never evaluated: i < numPages
0
347 PageItem* item = new PageItem(i+1, pictures.at(i), paperSize, pageRect);
never executed (the execution status of this line is deduced): PageItem* item = new PageItem(i+1, pictures.at(i), paperSize, pageRect);
-
348 scene->addItem(item);
never executed (the execution status of this line is deduced): scene->addItem(item);
-
349 pages.append(item);
never executed (the execution status of this line is deduced): pages.append(item);
-
350 }
never executed: }
0
351}
never executed: }
0
352 -
353void QPrintPreviewWidgetPrivate::layoutPages() -
354{ -
355 int numPages = pages.count();
never executed (the execution status of this line is deduced): int numPages = pages.count();
-
356 if (numPages < 1)
never evaluated: numPages < 1
0
357 return;
never executed: return;
0
358 -
359 int numPagePlaces = numPages;
never executed (the execution status of this line is deduced): int numPagePlaces = numPages;
-
360 int cols = 1; // singleMode and default
never executed (the execution status of this line is deduced): int cols = 1;
-
361 if (viewMode == QPrintPreviewWidget::AllPagesView) {
never evaluated: viewMode == QPrintPreviewWidget::AllPagesView
0
362 if (printer->orientation() == QPrinter::Portrait)
never evaluated: printer->orientation() == QPrinter::Portrait
0
363 cols = qCeil(qSqrt((float) numPages));
never executed: cols = qCeil(qSqrt((float) numPages));
0
364 else -
365 cols = qFloor(qSqrt((float) numPages));
never executed: cols = qFloor(qSqrt((float) numPages));
0
366 cols += cols % 2; // Nicer with an even number of cols
never executed (the execution status of this line is deduced): cols += cols % 2;
-
367 }
never executed: }
0
368 else if (viewMode == QPrintPreviewWidget::FacingPagesView) {
never evaluated: viewMode == QPrintPreviewWidget::FacingPagesView
0
369 cols = 2;
never executed (the execution status of this line is deduced): cols = 2;
-
370 numPagePlaces += 1;
never executed (the execution status of this line is deduced): numPagePlaces += 1;
-
371 }
never executed: }
0
372 int rows = qCeil(qreal(numPagePlaces) / cols);
never executed (the execution status of this line is deduced): int rows = qCeil(qreal(numPagePlaces) / cols);
-
373 -
374 qreal itemWidth = pages.at(0)->boundingRect().width();
never executed (the execution status of this line is deduced): qreal itemWidth = pages.at(0)->boundingRect().width();
-
375 qreal itemHeight = pages.at(0)->boundingRect().height();
never executed (the execution status of this line is deduced): qreal itemHeight = pages.at(0)->boundingRect().height();
-
376 int pageNum = 1;
never executed (the execution status of this line is deduced): int pageNum = 1;
-
377 for (int i = 0; i < rows && pageNum <= numPages; i++) {
never evaluated: i < rows
never evaluated: pageNum <= numPages
0
378 for (int j = 0; j < cols && pageNum <= numPages; j++) {
never evaluated: j < cols
never evaluated: pageNum <= numPages
0
379 if (!i && !j && viewMode == QPrintPreviewWidget::FacingPagesView) {
never evaluated: !i
never evaluated: !j
never evaluated: viewMode == QPrintPreviewWidget::FacingPagesView
0
380 // Front page doesn't have a facing page -
381 continue;
never executed: continue;
0
382 } else { -
383 pages.at(pageNum-1)->setPos(QPointF(j*itemWidth, i*itemHeight));
never executed (the execution status of this line is deduced): pages.at(pageNum-1)->setPos(QPointF(j*itemWidth, i*itemHeight));
-
384 pageNum++;
never executed (the execution status of this line is deduced): pageNum++;
-
385 }
never executed: }
0
386 } -
387 }
never executed: }
0
388 scene->setSceneRect(scene->itemsBoundingRect());
never executed (the execution status of this line is deduced): scene->setSceneRect(scene->itemsBoundingRect());
-
389}
never executed: }
0
390 -
391void QPrintPreviewWidgetPrivate::generatePreview() -
392{ -
393 //### If QPrinter::setPreviewMode() becomes public, handle the -
394 //### case that we have been constructed with a printer that -
395 //### _already_ has been preview-painted to, so we should -
396 //### initially just show the pages it already contains, and not -
397 //### emit paintRequested() until the user changes some parameter -
398 -
399 Q_Q(QPrintPreviewWidget);
never executed (the execution status of this line is deduced): QPrintPreviewWidget * const q = q_func();
-
400 printer->d_func()->setPreviewMode(true);
never executed (the execution status of this line is deduced): printer->d_func()->setPreviewMode(true);
-
401 emit q->paintRequested(printer);
never executed (the execution status of this line is deduced): q->paintRequested(printer);
-
402 printer->d_func()->setPreviewMode(false);
never executed (the execution status of this line is deduced): printer->d_func()->setPreviewMode(false);
-
403 pictures = printer->d_func()->previewPages();
never executed (the execution status of this line is deduced): pictures = printer->d_func()->previewPages();
-
404 populateScene(); // i.e. setPreviewPrintedPictures() e.l.
never executed (the execution status of this line is deduced): populateScene();
-
405 layoutPages();
never executed (the execution status of this line is deduced): layoutPages();
-
406 curPage = qBound(1, curPage, pages.count());
never executed (the execution status of this line is deduced): curPage = qBound(1, curPage, pages.count());
-
407 if (fitting)
never evaluated: fitting
0
408 _q_fit();
never executed: _q_fit();
0
409 emit q->previewChanged();
never executed (the execution status of this line is deduced): q->previewChanged();
-
410}
never executed: }
0
411 -
412void QPrintPreviewWidgetPrivate::setCurrentPage(int pageNumber) -
413{ -
414 if (pageNumber < 1 || pageNumber > pages.count())
never evaluated: pageNumber < 1
never evaluated: pageNumber > pages.count()
0
415 return;
never executed: return;
0
416 -
417 int lastPage = curPage;
never executed (the execution status of this line is deduced): int lastPage = curPage;
-
418 curPage = pageNumber;
never executed (the execution status of this line is deduced): curPage = pageNumber;
-
419 -
420 if (lastPage != curPage && lastPage > 0 && lastPage <= pages.count()) {
never evaluated: lastPage != curPage
never evaluated: lastPage > 0
never evaluated: lastPage <= pages.count()
0
421 if (zoomMode != QPrintPreviewWidget::FitInView) {
never evaluated: zoomMode != QPrintPreviewWidget::FitInView
0
422 QScrollBar *hsc = graphicsView->horizontalScrollBar();
never executed (the execution status of this line is deduced): QScrollBar *hsc = graphicsView->horizontalScrollBar();
-
423 QScrollBar *vsc = graphicsView->verticalScrollBar();
never executed (the execution status of this line is deduced): QScrollBar *vsc = graphicsView->verticalScrollBar();
-
424 QPointF pt = graphicsView->transform().map(pages.at(curPage-1)->pos());
never executed (the execution status of this line is deduced): QPointF pt = graphicsView->transform().map(pages.at(curPage-1)->pos());
-
425 vsc->setValue(int(pt.y()) - 10);
never executed (the execution status of this line is deduced): vsc->setValue(int(pt.y()) - 10);
-
426 hsc->setValue(int(pt.x()) - 10);
never executed (the execution status of this line is deduced): hsc->setValue(int(pt.x()) - 10);
-
427 } else {
never executed: }
0
428 graphicsView->centerOn(pages.at(curPage-1));
never executed (the execution status of this line is deduced): graphicsView->centerOn(pages.at(curPage-1));
-
429 }
never executed: }
0
430 } -
431}
never executed: }
0
432 -
433void QPrintPreviewWidgetPrivate::zoom(qreal zoom) -
434{ -
435 zoomFactor *= zoom;
never executed (the execution status of this line is deduced): zoomFactor *= zoom;
-
436 graphicsView->scale(zoom, zoom);
never executed (the execution status of this line is deduced): graphicsView->scale(zoom, zoom);
-
437}
never executed: }
0
438 -
439void QPrintPreviewWidgetPrivate::setZoomFactor(qreal _zoomFactor) -
440{ -
441 Q_Q(QPrintPreviewWidget);
never executed (the execution status of this line is deduced): QPrintPreviewWidget * const q = q_func();
-
442 zoomFactor = _zoomFactor;
never executed (the execution status of this line is deduced): zoomFactor = _zoomFactor;
-
443 graphicsView->resetTransform();
never executed (the execution status of this line is deduced): graphicsView->resetTransform();
-
444 int dpi_y = q->logicalDpiY();
never executed (the execution status of this line is deduced): int dpi_y = q->logicalDpiY();
-
445 int printer_dpi_y = printer->logicalDpiY();
never executed (the execution status of this line is deduced): int printer_dpi_y = printer->logicalDpiY();
-
446 graphicsView->scale(zoomFactor*(dpi_y/float(printer_dpi_y)),
never executed (the execution status of this line is deduced): graphicsView->scale(zoomFactor*(dpi_y/float(printer_dpi_y)),
-
447 zoomFactor*(dpi_y/float(printer_dpi_y)));
never executed (the execution status of this line is deduced): zoomFactor*(dpi_y/float(printer_dpi_y)));
-
448}
never executed: }
0
449 -
450/////////////////////////////////////// -
451 -
452/*! -
453 \class QPrintPreviewWidget -
454 \since 4.4 -
455 -
456 \brief The QPrintPreviewWidget class provides a widget for -
457 previewing page layouts for printer output. -
458 -
459 \ingroup printing -
460 \inmodule QtPrintSupport -
461 -
462 QPrintPreviewDialog uses a QPrintPreviewWidget internally, and the -
463 purpose of QPrintPreviewWidget is to make it possible to embed the -
464 preview into other widgets. It also makes it possible to build a different -
465 user interface around it than the default one provided with QPrintPreviewDialog. -
466 -
467 Using QPrintPreviewWidget is straightforward: -
468 -
469 \list 1 -
470 \li Create the QPrintPreviewWidget -
471 -
472 Construct the QPrintPreviewWidget either by passing in an -
473 existing QPrinter object, or have QPrintPreviewWidget create a -
474 default constructed QPrinter object for you. -
475 -
476 \li Connect the paintRequested() signal to a slot. -
477 -
478 When the widget needs to generate a set of preview pages, a -
479 paintRequested() signal will be emitted from the widget. Connect a -
480 slot to this signal, and draw onto the QPrinter passed in as a -
481 signal parameter. Call QPrinter::newPage(), to start a new -
482 page in the preview. -
483 -
484 \endlist -
485 -
486 \sa QPrinter, QPrintDialog, QPageSetupDialog, QPrintPreviewDialog -
487*/ -
488 -
489 -
490/*! -
491 \enum QPrintPreviewWidget::ViewMode -
492 -
493 This enum is used to describe the view mode of the preview widget. -
494 -
495 \value SinglePageView A mode where single pages in the preview -
496 is viewed. -
497 -
498 \value FacingPagesView A mode where the facing pages in the preview -
499 is viewed. -
500 -
501 \value AllPagesView A view mode where all the pages in the preview -
502 is viewed. -
503*/ -
504 -
505/*! -
506 \enum QPrintPreviewWidget::ZoomMode -
507 -
508 This enum is used to describe zoom mode of the preview widget. -
509 -
510 \value CustomZoom The zoom is set to a custom zoom value. -
511 -
512 \value FitToWidth This mode fits the current page to the width of the view. -
513 -
514 \value FitInView This mode fits the current page inside the view. -
515 -
516*/ -
517 -
518/*! -
519 Constructs a QPrintPreviewWidget based on \a printer and with \a -
520 parent as the parent widget. The widget flags \a flags are passed on -
521 to the QWidget constructor. -
522 -
523 \sa QWidget::setWindowFlags() -
524*/ -
525QPrintPreviewWidget::QPrintPreviewWidget(QPrinter *printer, QWidget *parent, Qt::WindowFlags flags) -
526 : QWidget(*new QPrintPreviewWidgetPrivate, parent, flags) -
527{ -
528 Q_D(QPrintPreviewWidget);
never executed (the execution status of this line is deduced): QPrintPreviewWidgetPrivate * const d = d_func();
-
529 d->printer = printer;
never executed (the execution status of this line is deduced): d->printer = printer;
-
530 d->ownPrinter = false;
never executed (the execution status of this line is deduced): d->ownPrinter = false;
-
531 d->init();
never executed (the execution status of this line is deduced): d->init();
-
532}
never executed: }
0
533 -
534/*! -
535 \overload -
536 -
537 This will cause QPrintPreviewWidget to create an internal, default -
538 constructed QPrinter object, which will be used to generate the -
539 preview. -
540*/ -
541QPrintPreviewWidget::QPrintPreviewWidget(QWidget *parent, Qt::WindowFlags flags) -
542 : QWidget(*new QPrintPreviewWidgetPrivate, parent, flags) -
543{ -
544 Q_D(QPrintPreviewWidget);
never executed (the execution status of this line is deduced): QPrintPreviewWidgetPrivate * const d = d_func();
-
545 d->printer = new QPrinter;
never executed (the execution status of this line is deduced): d->printer = new QPrinter;
-
546 d->ownPrinter = true;
never executed (the execution status of this line is deduced): d->ownPrinter = true;
-
547 d->init();
never executed (the execution status of this line is deduced): d->init();
-
548}
never executed: }
0
549 -
550 -
551/*! -
552 Destroys the QPrintPreviewWidget. -
553*/ -
554QPrintPreviewWidget::~QPrintPreviewWidget() -
555{ -
556 Q_D(QPrintPreviewWidget);
never executed (the execution status of this line is deduced): QPrintPreviewWidgetPrivate * const d = d_func();
-
557 if (d->ownPrinter)
never evaluated: d->ownPrinter
0
558 delete d->printer;
never executed: delete d->printer;
0
559}
never executed: }
0
560 -
561/*! -
562 Returns the current view mode. The default view mode is SinglePageView. -
563*/ -
564QPrintPreviewWidget::ViewMode QPrintPreviewWidget::viewMode() const -
565{ -
566 Q_D(const QPrintPreviewWidget);
never executed (the execution status of this line is deduced): const QPrintPreviewWidgetPrivate * const d = d_func();
-
567 return d->viewMode;
never executed: return d->viewMode;
0
568} -
569 -
570/*! -
571 Sets the view mode to \a mode. The default view mode is -
572 SinglePageView. -
573*/ -
574void QPrintPreviewWidget::setViewMode(ViewMode mode) -
575{ -
576 Q_D(QPrintPreviewWidget);
never executed (the execution status of this line is deduced): QPrintPreviewWidgetPrivate * const d = d_func();
-
577 d->viewMode = mode;
never executed (the execution status of this line is deduced): d->viewMode = mode;
-
578 d->layoutPages();
never executed (the execution status of this line is deduced): d->layoutPages();
-
579 if (d->viewMode == AllPagesView) {
never evaluated: d->viewMode == AllPagesView
0
580 d->graphicsView->fitInView(d->scene->itemsBoundingRect(), Qt::KeepAspectRatio);
never executed (the execution status of this line is deduced): d->graphicsView->fitInView(d->scene->itemsBoundingRect(), Qt::KeepAspectRatio);
-
581 d->fitting = false;
never executed (the execution status of this line is deduced): d->fitting = false;
-
582 d->zoomMode = QPrintPreviewWidget::CustomZoom;
never executed (the execution status of this line is deduced): d->zoomMode = QPrintPreviewWidget::CustomZoom;
-
583 d->zoomFactor = d->graphicsView->transform().m11() * (float(d->printer->logicalDpiY()) / logicalDpiY());
never executed (the execution status of this line is deduced): d->zoomFactor = d->graphicsView->transform().m11() * (float(d->printer->logicalDpiY()) / logicalDpiY());
-
584 emit previewChanged();
never executed (the execution status of this line is deduced): previewChanged();
-
585 } else {
never executed: }
0
586 d->fitting = true;
never executed (the execution status of this line is deduced): d->fitting = true;
-
587 d->_q_fit();
never executed (the execution status of this line is deduced): d->_q_fit();
-
588 }
never executed: }
0
589} -
590 -
591/*! -
592 Returns the current orientation of the preview. This value is -
593 obtained from the QPrinter object associated with the preview. -
594*/ -
595QPrinter::Orientation QPrintPreviewWidget::orientation() const -
596{ -
597 Q_D(const QPrintPreviewWidget);
never executed (the execution status of this line is deduced): const QPrintPreviewWidgetPrivate * const d = d_func();
-
598 return d->printer->orientation();
never executed: return d->printer->orientation();
0
599} -
600 -
601/*! -
602 Sets the current orientation to \a orientation. This value will be -
603 set on the QPrinter object associated with the preview. -
604*/ -
605void QPrintPreviewWidget::setOrientation(QPrinter::Orientation orientation) -
606{ -
607 Q_D(QPrintPreviewWidget);
never executed (the execution status of this line is deduced): QPrintPreviewWidgetPrivate * const d = d_func();
-
608 d->printer->setOrientation(orientation);
never executed (the execution status of this line is deduced): d->printer->setOrientation(orientation);
-
609 d->generatePreview();
never executed (the execution status of this line is deduced): d->generatePreview();
-
610}
never executed: }
0
611 -
612/*! -
613 Prints the preview to the printer associated with the preview. -
614*/ -
615void QPrintPreviewWidget::print() -
616{ -
617 Q_D(QPrintPreviewWidget);
never executed (the execution status of this line is deduced): QPrintPreviewWidgetPrivate * const d = d_func();
-
618 // ### make use of the generated pages -
619 emit paintRequested(d->printer);
never executed (the execution status of this line is deduced): paintRequested(d->printer);
-
620}
never executed: }
0
621 -
622/*! -
623 Zooms the current view in by \a factor. The default value for \a -
624 factor is 1.1, which means the view will be scaled up by 10%. -
625*/ -
626void QPrintPreviewWidget::zoomIn(qreal factor) -
627{ -
628 Q_D(QPrintPreviewWidget);
never executed (the execution status of this line is deduced): QPrintPreviewWidgetPrivate * const d = d_func();
-
629 d->fitting = false;
never executed (the execution status of this line is deduced): d->fitting = false;
-
630 d->zoomMode = QPrintPreviewWidget::CustomZoom;
never executed (the execution status of this line is deduced): d->zoomMode = QPrintPreviewWidget::CustomZoom;
-
631 d->zoom(factor);
never executed (the execution status of this line is deduced): d->zoom(factor);
-
632}
never executed: }
0
633 -
634/*! -
635 Zooms the current view out by \a factor. The default value for \a -
636 factor is 1.1, which means the view will be scaled down by 10%. -
637*/ -
638void QPrintPreviewWidget::zoomOut(qreal factor) -
639{ -
640 Q_D(QPrintPreviewWidget);
never executed (the execution status of this line is deduced): QPrintPreviewWidgetPrivate * const d = d_func();
-
641 d->fitting = false;
never executed (the execution status of this line is deduced): d->fitting = false;
-
642 d->zoomMode = QPrintPreviewWidget::CustomZoom;
never executed (the execution status of this line is deduced): d->zoomMode = QPrintPreviewWidget::CustomZoom;
-
643 d->zoom(1/factor);
never executed (the execution status of this line is deduced): d->zoom(1/factor);
-
644}
never executed: }
0
645 -
646/*! -
647 Returns the zoom factor of the view. -
648*/ -
649qreal QPrintPreviewWidget::zoomFactor() const -
650{ -
651 Q_D(const QPrintPreviewWidget);
never executed (the execution status of this line is deduced): const QPrintPreviewWidgetPrivate * const d = d_func();
-
652 return d->zoomFactor;
never executed: return d->zoomFactor;
0
653} -
654 -
655/*! -
656 Sets the zoom factor of the view to \a factor. For example, a -
657 value of 1.0 indicates an unscaled view, which is approximately -
658 the size the view will have on paper. A value of 0.5 will halve -
659 the size of the view, while a value of 2.0 will double the size of -
660 the view. -
661*/ -
662void QPrintPreviewWidget::setZoomFactor(qreal factor) -
663{ -
664 Q_D(QPrintPreviewWidget);
never executed (the execution status of this line is deduced): QPrintPreviewWidgetPrivate * const d = d_func();
-
665 d->fitting = false;
never executed (the execution status of this line is deduced): d->fitting = false;
-
666 d->zoomMode = QPrintPreviewWidget::CustomZoom;
never executed (the execution status of this line is deduced): d->zoomMode = QPrintPreviewWidget::CustomZoom;
-
667 d->setZoomFactor(factor);
never executed (the execution status of this line is deduced): d->setZoomFactor(factor);
-
668}
never executed: }
0
669 -
670/*! -
671 \since 4.6 -
672 Returns the number of pages in the preview. -
673*/ -
674int QPrintPreviewWidget::pageCount() const -
675{ -
676 Q_D(const QPrintPreviewWidget);
never executed (the execution status of this line is deduced): const QPrintPreviewWidgetPrivate * const d = d_func();
-
677 return d->pages.size();
never executed: return d->pages.size();
0
678} -
679 -
680/*! -
681 Returns the currently viewed page in the preview. -
682*/ -
683int QPrintPreviewWidget::currentPage() const -
684{ -
685 Q_D(const QPrintPreviewWidget);
never executed (the execution status of this line is deduced): const QPrintPreviewWidgetPrivate * const d = d_func();
-
686 return d->curPage;
never executed: return d->curPage;
0
687} -
688 -
689/*! -
690 Sets the current page in the preview. This will cause the view to -
691 skip to the beginning of \a page. -
692*/ -
693void QPrintPreviewWidget::setCurrentPage(int page) -
694{ -
695 Q_D(QPrintPreviewWidget);
never executed (the execution status of this line is deduced): QPrintPreviewWidgetPrivate * const d = d_func();
-
696 d->setCurrentPage(page);
never executed (the execution status of this line is deduced): d->setCurrentPage(page);
-
697}
never executed: }
0
698 -
699/*! -
700 This is a convenience function and is the same as calling \c -
701 {setZoomMode(QPrintPreviewWidget::FitToWidth)}. -
702*/ -
703void QPrintPreviewWidget::fitToWidth() -
704{ -
705 setZoomMode(FitToWidth);
never executed (the execution status of this line is deduced): setZoomMode(FitToWidth);
-
706}
never executed: }
0
707 -
708/*! -
709 This is a convenience function and is the same as calling \c -
710 {setZoomMode(QPrintPreviewWidget::FitInView)}. -
711*/ -
712void QPrintPreviewWidget::fitInView() -
713{ -
714 setZoomMode(FitInView);
never executed (the execution status of this line is deduced): setZoomMode(FitInView);
-
715}
never executed: }
0
716 -
717/*! -
718 Sets the zoom mode to \a zoomMode. The default zoom mode is FitInView. -
719 -
720 \sa zoomMode(), viewMode(), setViewMode() -
721*/ -
722void QPrintPreviewWidget::setZoomMode(QPrintPreviewWidget::ZoomMode zoomMode) -
723{ -
724 Q_D(QPrintPreviewWidget);
never executed (the execution status of this line is deduced): QPrintPreviewWidgetPrivate * const d = d_func();
-
725 d->zoomMode = zoomMode;
never executed (the execution status of this line is deduced): d->zoomMode = zoomMode;
-
726 if (d->zoomMode == FitInView || d->zoomMode == FitToWidth) {
never evaluated: d->zoomMode == FitInView
never evaluated: d->zoomMode == FitToWidth
0
727 d->fitting = true;
never executed (the execution status of this line is deduced): d->fitting = true;
-
728 d->_q_fit(true);
never executed (the execution status of this line is deduced): d->_q_fit(true);
-
729 } else {
never executed: }
0
730 d->fitting = false;
never executed (the execution status of this line is deduced): d->fitting = false;
-
731 }
never executed: }
0
732} -
733 -
734/*! -
735 Returns the current zoom mode. -
736 -
737 \sa setZoomMode(), viewMode(), setViewMode() -
738*/ -
739QPrintPreviewWidget::ZoomMode QPrintPreviewWidget::zoomMode() const -
740{ -
741 Q_D(const QPrintPreviewWidget);
never executed (the execution status of this line is deduced): const QPrintPreviewWidgetPrivate * const d = d_func();
-
742 return d->zoomMode;
never executed: return d->zoomMode;
0
743} -
744 -
745/*! -
746 This is a convenience function and is the same as calling \c -
747 {setOrientation(QPrinter::Landscape)}. -
748*/ -
749void QPrintPreviewWidget::setLandscapeOrientation() -
750{ -
751 setOrientation(QPrinter::Landscape);
never executed (the execution status of this line is deduced): setOrientation(QPrinter::Landscape);
-
752}
never executed: }
0
753 -
754/*! -
755 This is a convenience function and is the same as calling \c -
756 {setOrientation(QPrinter::Portrait)}. -
757*/ -
758void QPrintPreviewWidget::setPortraitOrientation() -
759{ -
760 setOrientation(QPrinter::Portrait);
never executed (the execution status of this line is deduced): setOrientation(QPrinter::Portrait);
-
761}
never executed: }
0
762 -
763/*! -
764 This is a convenience function and is the same as calling \c -
765 {setViewMode(QPrintPreviewWidget::SinglePageView)}. -
766*/ -
767void QPrintPreviewWidget::setSinglePageViewMode() -
768{ -
769 setViewMode(SinglePageView);
never executed (the execution status of this line is deduced): setViewMode(SinglePageView);
-
770}
never executed: }
0
771 -
772/*! -
773 This is a convenience function and is the same as calling \c -
774 {setViewMode(QPrintPreviewWidget::FacingPagesView)}. -
775*/ -
776void QPrintPreviewWidget::setFacingPagesViewMode() -
777{ -
778 setViewMode(FacingPagesView);
never executed (the execution status of this line is deduced): setViewMode(FacingPagesView);
-
779}
never executed: }
0
780 -
781/*! -
782 This is a convenience function and is the same as calling \c -
783 {setViewMode(QPrintPreviewWidget::AllPagesView)}. -
784*/ -
785void QPrintPreviewWidget::setAllPagesViewMode() -
786{ -
787 setViewMode(AllPagesView);
never executed (the execution status of this line is deduced): setViewMode(AllPagesView);
-
788}
never executed: }
0
789 -
790 -
791/*! -
792 This function updates the preview, which causes the -
793 paintRequested() signal to be emitted. -
794*/ -
795void QPrintPreviewWidget::updatePreview() -
796{ -
797 Q_D(QPrintPreviewWidget);
never executed (the execution status of this line is deduced): QPrintPreviewWidgetPrivate * const d = d_func();
-
798 d->initialized = true;
never executed (the execution status of this line is deduced): d->initialized = true;
-
799 d->generatePreview();
never executed (the execution status of this line is deduced): d->generatePreview();
-
800 d->graphicsView->updateGeometry();
never executed (the execution status of this line is deduced): d->graphicsView->updateGeometry();
-
801}
never executed: }
0
802 -
803/*! \reimp -
804*/ -
805void QPrintPreviewWidget::setVisible(bool visible) -
806{ -
807 Q_D(QPrintPreviewWidget);
never executed (the execution status of this line is deduced): QPrintPreviewWidgetPrivate * const d = d_func();
-
808 if (visible && !d->initialized)
never evaluated: visible
never evaluated: !d->initialized
0
809 updatePreview();
never executed: updatePreview();
0
810 QWidget::setVisible(visible);
never executed (the execution status of this line is deduced): QWidget::setVisible(visible);
-
811}
never executed: }
0
812 -
813/*! -
814 \fn void QPrintPreviewWidget::paintRequested(QPrinter *printer) -
815 -
816 This signal is emitted when the preview widget needs to generate a -
817 set of preview pages. \a printer is the printer associated with -
818 this preview widget. -
819*/ -
820 -
821/*! -
822 \fn void QPrintPreviewWidget::previewChanged() -
823 -
824 This signal is emitted whenever the preview widget has changed -
825 some internal state, such as the orientation. -
826*/ -
827 -
828 -
829QT_END_NAMESPACE -
830 -
831#include "moc_qprintpreviewwidget.cpp" -
832#include "qprintpreviewwidget.moc" -
833 -
834#endif // QT_NO_PRINTPREVIEWWIDGET -
835 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial