qpaintengine_preview.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/printsupport/kernel/qpaintengine_preview.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
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 The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/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 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include <private/qpaintengine_preview_p.h>-
41#include <private/qpainter_p.h>-
42#include <private/qpaintengine_p.h>-
43#include <private/qpicture_p.h>-
44-
45#include <QtPrintSupport/qprintengine.h>-
46#include <QtGui/qpainter.h>-
47#include <QtGui/qpicture.h>-
48-
49#ifndef QT_NO_PRINTPREVIEWWIDGET-
50QT_BEGIN_NAMESPACE-
51-
52class QPreviewPaintEnginePrivate : public QPaintEnginePrivate-
53{-
54 Q_DECLARE_PUBLIC(QPreviewPaintEngine)-
55public:-
56 QPreviewPaintEnginePrivate() : state(QPrinter::Idle) {}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
57 ~QPreviewPaintEnginePrivate() {}-
58-
59 QList<const QPicture *> pages;-
60 QPaintEngine *engine;-
61 QPainter *painter;-
62 QPrinter::PrinterState state;-
63-
64 QPaintEngine *proxy_paint_engine;-
65 QPrintEngine *proxy_print_engine;-
66};-
67-
68-
69QPreviewPaintEngine::QPreviewPaintEngine()-
70 : QPaintEngine(*(new QPreviewPaintEnginePrivate), PaintEngineFeatures(AllFeatures & ~ObjectBoundingModeGradients))-
71{-
72 Q_D(QPreviewPaintEngine);-
73 d->proxy_print_engine = 0;-
74 d->proxy_paint_engine = 0;-
75}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
76-
77QPreviewPaintEngine::~QPreviewPaintEngine()-
78{-
79 Q_D(QPreviewPaintEngine);-
80-
81 qDeleteAll(d->pages);-
82}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
83-
84bool QPreviewPaintEngine::begin(QPaintDevice *)-
85{-
86 Q_D(QPreviewPaintEngine);-
87-
88 qDeleteAll(d->pages);-
89 d->pages.clear();-
90-
91 QPicture *page = new QPicture;-
92 page->d_func()->in_memory_only = true;-
93 d->painter = new QPainter(page);-
94 d->engine = d->painter->paintEngine();-
95 *d->painter->d_func()->state = *painter()->d_func()->state;-
96 d->pages.append(page);-
97 d->state = QPrinter::Active;-
98 return true;
executed 1 time by 1 test: return true;
Executed by:
  • tst_QPrinter
1
99}-
100-
101bool QPreviewPaintEngine::end()-
102{-
103 Q_D(QPreviewPaintEngine);-
104-
105 delete d->painter;-
106 d->painter = 0;-
107 d->engine = 0;-
108 d->state = QPrinter::Idle;-
109 return true;
executed 1 time by 1 test: return true;
Executed by:
  • tst_QPrinter
1
110}-
111-
112void QPreviewPaintEngine::updateState(const QPaintEngineState &state)-
113{-
114 Q_D(QPreviewPaintEngine);-
115 d->engine->updateState(state);-
116}
executed 8 times by 1 test: end of block
Executed by:
  • tst_QPrinter
8
117-
118void QPreviewPaintEngine::drawPath(const QPainterPath &path)-
119{-
120 Q_D(QPreviewPaintEngine);-
121 d->engine->drawPath(path);-
122}
executed 4 times by 1 test: end of block
Executed by:
  • tst_QPrinter
4
123-
124void QPreviewPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)-
125{-
126 Q_D(QPreviewPaintEngine);-
127 d->engine->drawPolygon(points, pointCount, mode);-
128}
never executed: end of block
0
129-
130void QPreviewPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)-
131{-
132 Q_D(QPreviewPaintEngine);-
133 d->engine->drawTextItem(p, textItem);-
134}
executed 4 times by 1 test: end of block
Executed by:
  • tst_QPrinter
4
135-
136void QPreviewPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)-
137{-
138 Q_D(QPreviewPaintEngine);-
139 d->engine->drawPixmap(r, pm, sr);-
140}
never executed: end of block
0
141-
142void QPreviewPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &p)-
143{-
144 Q_D(QPreviewPaintEngine);-
145 d->engine->drawTiledPixmap(r, pm, p);-
146}
never executed: end of block
0
147-
148bool QPreviewPaintEngine::newPage()-
149{-
150 Q_D(QPreviewPaintEngine);-
151-
152 QPicture *page = new QPicture;-
153 page->d_func()->in_memory_only = true;-
154 QPainter *tmp_painter = new QPainter(page);-
155 QPaintEngine *tmp_engine = tmp_painter->paintEngine();-
156-
157 // copy the painter state from the original painter-
158 Q_ASSERT(painter()->d_func()->state && tmp_painter->d_func()->state);-
159 *tmp_painter->d_func()->state = *painter()->d_func()->state;-
160-
161 // composition modes aren't supported on a QPrinter and yields a-
162 // warning, so ignore it for now-
163 tmp_engine->setDirty(DirtyFlags(AllDirty & ~DirtyCompositionMode));-
164 tmp_engine->syncState();-
165-
166 delete d->painter;-
167 d->painter = tmp_painter;-
168 d->pages.append(page);-
169 d->engine = tmp_engine;-
170 return true;
executed 3 times by 1 test: return true;
Executed by:
  • tst_QPrinter
3
171}-
172-
173bool QPreviewPaintEngine::abort()-
174{-
175 Q_D(QPreviewPaintEngine);-
176 end();-
177 qDeleteAll(d->pages);-
178 d->state = QPrinter::Aborted;-
179-
180 return true;
never executed: return true;
0
181}-
182-
183QList<const QPicture *> QPreviewPaintEngine::pages()-
184{-
185 Q_D(QPreviewPaintEngine);-
186 return d->pages;
executed 1 time by 1 test: return d->pages;
Executed by:
  • tst_QPrinter
1
187}-
188-
189void QPreviewPaintEngine::setProxyEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine)-
190{-
191 Q_D(QPreviewPaintEngine);-
192 d->proxy_print_engine = printEngine;-
193 d->proxy_paint_engine = paintEngine;-
194}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
195-
196void QPreviewPaintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &value)-
197{-
198 Q_D(QPreviewPaintEngine);-
199 d->proxy_print_engine->setProperty(key, value);-
200}
never executed: end of block
0
201-
202QVariant QPreviewPaintEngine::property(PrintEnginePropertyKey key) const-
203{-
204 Q_D(const QPreviewPaintEngine);-
205 return d->proxy_print_engine->property(key);
executed 8 times by 1 test: return d->proxy_print_engine->property(key);
Executed by:
  • tst_QPrinter
8
206}-
207-
208int QPreviewPaintEngine::metric(QPaintDevice::PaintDeviceMetric id) const-
209{-
210 Q_D(const QPreviewPaintEngine);-
211 return d->proxy_print_engine->metric(id);
executed 3 times by 1 test: return d->proxy_print_engine->metric(id);
Executed by:
  • tst_QPrinter
3
212}-
213-
214QPrinter::PrinterState QPreviewPaintEngine::printerState() const-
215{-
216 Q_D(const QPreviewPaintEngine);-
217 return d->state;
executed 3 times by 1 test: return d->state;
Executed by:
  • tst_QPrinter
3
218}-
219-
220QT_END_NAMESPACE-
221-
222#endif-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9