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