Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/printsupport/kernel/qprinterinfo.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
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 documentation of the Qt Toolkit. | - | ||||||
7 | ** | - | ||||||
8 | ** $QT_BEGIN_LICENSE:FDL$ | - | ||||||
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 Free Documentation License Usage | - | ||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Free | - | ||||||
19 | ** Documentation License version 1.3 as published by the Free Software | - | ||||||
20 | ** Foundation and appearing in the file included in the packaging of | - | ||||||
21 | ** this file. Please review the following information to ensure | - | ||||||
22 | ** the GNU Free Documentation License version 1.3 requirements | - | ||||||
23 | ** will be met: https://www.gnu.org/licenses/fdl-1.3.html. | - | ||||||
24 | ** $QT_END_LICENSE$ | - | ||||||
25 | ** | - | ||||||
26 | ****************************************************************************/ | - | ||||||
27 | - | |||||||
28 | #include "qprinterinfo.h" | - | ||||||
29 | #include "qprinterinfo_p.h" | - | ||||||
30 | #include "qprintdevice_p.h" | - | ||||||
31 | - | |||||||
32 | #ifndef QT_NO_PRINTER | - | ||||||
33 | - | |||||||
34 | #include <QtCore/qdebug.h> | - | ||||||
35 | - | |||||||
36 | #include <qpa/qplatformprintplugin.h> | - | ||||||
37 | #include <qpa/qplatformprintersupport.h> | - | ||||||
38 | - | |||||||
39 | QT_BEGIN_NAMESPACE | - | ||||||
40 | - | |||||||
41 | Q_GLOBAL_STATIC(QPrinterInfoPrivate, shared_null); executed 3 times by 3 tests: end of block Executed by:
executed 3 times by 3 tests: guard.store(QtGlobalStatic::Destroyed); Executed by:
executed 1502 times by 3 tests: return &holder.value; Executed by:
| 0-1502 | ||||||
42 | - | |||||||
43 | class QPrinterInfoPrivateDeleter | - | ||||||
44 | { | - | ||||||
45 | public: | - | ||||||
46 | static inline void cleanup(QPrinterInfoPrivate *d) | - | ||||||
47 | { | - | ||||||
48 | if (d != shared_null)
| 274 | ||||||
49 | delete d; executed 274 times by 3 tests: delete d; Executed by:
| 274 | ||||||
50 | } executed 548 times by 3 tests: end of block Executed by:
| 548 | ||||||
51 | }; | - | ||||||
52 | - | |||||||
53 | QPrinterInfoPrivate::QPrinterInfoPrivate(const QString &id) | - | ||||||
54 | { | - | ||||||
55 | if (!id.isEmpty()) {
| 1-140 | ||||||
56 | QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get(); | - | ||||||
57 | if (ps)
| 0-1 | ||||||
58 | m_printDevice = ps->createPrintDevice(id); executed 1 time by 1 test: m_printDevice = ps->createPrintDevice(id); Executed by:
| 1 | ||||||
59 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||
60 | } executed 141 times by 3 tests: end of block Executed by:
| 141 | ||||||
61 | - | |||||||
62 | QPrinterInfoPrivate::~QPrinterInfoPrivate() | - | ||||||
63 | { | - | ||||||
64 | } | - | ||||||
65 | - | |||||||
66 | /*! | - | ||||||
67 | \class QPrinterInfo | - | ||||||
68 | - | |||||||
69 | \brief The QPrinterInfo class gives access to information about | - | ||||||
70 | existing printers. | - | ||||||
71 | - | |||||||
72 | \ingroup printing | - | ||||||
73 | \inmodule QtPrintSupport | - | ||||||
74 | - | |||||||
75 | Use the static functions to generate a list of QPrinterInfo | - | ||||||
76 | objects. Each QPrinterInfo object in the list represents a single | - | ||||||
77 | printer and can be queried for name, supported paper sizes, and | - | ||||||
78 | whether or not it is the default printer. | - | ||||||
79 | - | |||||||
80 | \since 4.4 | - | ||||||
81 | */ | - | ||||||
82 | - | |||||||
83 | /*! | - | ||||||
84 | Constructs an empty QPrinterInfo object. | - | ||||||
85 | - | |||||||
86 | \sa isNull() | - | ||||||
87 | */ | - | ||||||
88 | QPrinterInfo::QPrinterInfo() | - | ||||||
89 | : d_ptr(shared_null) | - | ||||||
90 | { | - | ||||||
91 | } executed 137 times by 3 tests: end of block Executed by:
| 137 | ||||||
92 | - | |||||||
93 | /*! | - | ||||||
94 | Constructs a copy of \a other. | - | ||||||
95 | */ | - | ||||||
96 | QPrinterInfo::QPrinterInfo(const QPrinterInfo &other) | - | ||||||
97 | : d_ptr((other.d_ptr.data() == shared_null) ? shared_null : new QPrinterInfoPrivate(*other.d_ptr)) | - | ||||||
98 | { | - | ||||||
99 | } executed 135 times by 3 tests: end of block Executed by:
| 135 | ||||||
100 | - | |||||||
101 | /*! | - | ||||||
102 | Constructs a QPrinterInfo object from \a printer. | - | ||||||
103 | */ | - | ||||||
104 | QPrinterInfo::QPrinterInfo(const QPrinter &printer) | - | ||||||
105 | : d_ptr(shared_null) | - | ||||||
106 | { | - | ||||||
107 | QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get(); | - | ||||||
108 | if (ps) {
| 0-2 | ||||||
109 | QPrinterInfo pi(printer.printerName()); | - | ||||||
110 | if (pi.d_ptr.data() == shared_null)
| 0-2 | ||||||
111 | d_ptr.reset(shared_null); never executed: d_ptr.reset(shared_null); | 0 | ||||||
112 | else | - | ||||||
113 | d_ptr.reset(new QPrinterInfoPrivate(*pi.d_ptr)); executed 2 times by 1 test: d_ptr.reset(new QPrinterInfoPrivate(*pi.d_ptr)); Executed by:
| 2 | ||||||
114 | } | - | ||||||
115 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||
116 | - | |||||||
117 | /*! | - | ||||||
118 | \internal | - | ||||||
119 | */ | - | ||||||
120 | QPrinterInfo::QPrinterInfo(const QString &name) | - | ||||||
121 | : d_ptr(new QPrinterInfoPrivate(name)) | - | ||||||
122 | { | - | ||||||
123 | } executed 138 times by 3 tests: end of block Executed by:
| 138 | ||||||
124 | - | |||||||
125 | /*! | - | ||||||
126 | Destroys the QPrinterInfo object. References to the values in the | - | ||||||
127 | object become invalid. | - | ||||||
128 | */ | - | ||||||
129 | QPrinterInfo::~QPrinterInfo() | - | ||||||
130 | { | - | ||||||
131 | } | - | ||||||
132 | - | |||||||
133 | /*! | - | ||||||
134 | Sets the QPrinterInfo object to be equal to \a other. | - | ||||||
135 | */ | - | ||||||
136 | QPrinterInfo &QPrinterInfo::operator=(const QPrinterInfo &other) | - | ||||||
137 | { | - | ||||||
138 | Q_ASSERT(d_ptr); | - | ||||||
139 | if (other.d_ptr.data() == shared_null)
| 1-134 | ||||||
140 | d_ptr.reset(shared_null); executed 1 time by 1 test: d_ptr.reset(shared_null); Executed by:
| 1 | ||||||
141 | else | - | ||||||
142 | d_ptr.reset(new QPrinterInfoPrivate(*other.d_ptr)); executed 134 times by 2 tests: d_ptr.reset(new QPrinterInfoPrivate(*other.d_ptr)); Executed by:
| 134 | ||||||
143 | return *this; executed 135 times by 3 tests: return *this; Executed by:
| 135 | ||||||
144 | } | - | ||||||
145 | - | |||||||
146 | /*! | - | ||||||
147 | Returns the name of the printer. | - | ||||||
148 | - | |||||||
149 | This is a unique id to identify the printer and may not be human-readable. | - | ||||||
150 | - | |||||||
151 | \sa QPrinterInfo::description() | - | ||||||
152 | \sa QPrinter::setPrinterName() | - | ||||||
153 | */ | - | ||||||
154 | QString QPrinterInfo::printerName() const | - | ||||||
155 | { | - | ||||||
156 | const Q_D(QPrinterInfo); | - | ||||||
157 | return d->m_printDevice.id(); executed 2 times by 1 test: return d->m_printDevice.id(); Executed by:
| 2 | ||||||
158 | } | - | ||||||
159 | - | |||||||
160 | /*! | - | ||||||
161 | Returns the human-readable description of the printer. | - | ||||||
162 | - | |||||||
163 | \since 5.0 | - | ||||||
164 | \sa QPrinterInfo::printerName() | - | ||||||
165 | */ | - | ||||||
166 | QString QPrinterInfo::description() const | - | ||||||
167 | { | - | ||||||
168 | const Q_D(QPrinterInfo); | - | ||||||
169 | return d->m_printDevice.name(); never executed: return d->m_printDevice.name(); | 0 | ||||||
170 | } | - | ||||||
171 | - | |||||||
172 | /*! | - | ||||||
173 | Returns the human-readable location of the printer. | - | ||||||
174 | - | |||||||
175 | \since 5.0 | - | ||||||
176 | */ | - | ||||||
177 | QString QPrinterInfo::location() const | - | ||||||
178 | { | - | ||||||
179 | const Q_D(QPrinterInfo); | - | ||||||
180 | return d->m_printDevice.location(); never executed: return d->m_printDevice.location(); | 0 | ||||||
181 | } | - | ||||||
182 | - | |||||||
183 | /*! | - | ||||||
184 | Returns the human-readable make and model of the printer. | - | ||||||
185 | - | |||||||
186 | \since 5.0 | - | ||||||
187 | */ | - | ||||||
188 | QString QPrinterInfo::makeAndModel() const | - | ||||||
189 | { | - | ||||||
190 | const Q_D(QPrinterInfo); | - | ||||||
191 | return d->m_printDevice.makeAndModel(); never executed: return d->m_printDevice.makeAndModel(); | 0 | ||||||
192 | } | - | ||||||
193 | - | |||||||
194 | /*! | - | ||||||
195 | Returns whether this QPrinterInfo object holds a printer definition. | - | ||||||
196 | - | |||||||
197 | An empty QPrinterInfo object could result for example from calling | - | ||||||
198 | defaultPrinter() when there are no printers on the system. | - | ||||||
199 | */ | - | ||||||
200 | bool QPrinterInfo::isNull() const | - | ||||||
201 | { | - | ||||||
202 | Q_D(const QPrinterInfo); | - | ||||||
203 | return d == shared_null || !d->m_printDevice.isValid(); executed 407 times by 3 tests: return d == shared_null || !d->m_printDevice.isValid(); Executed by:
| 407 | ||||||
204 | } | - | ||||||
205 | - | |||||||
206 | /*! | - | ||||||
207 | Returns whether this printer is currently the default printer. | - | ||||||
208 | */ | - | ||||||
209 | bool QPrinterInfo::isDefault() const | - | ||||||
210 | { | - | ||||||
211 | Q_D(const QPrinterInfo); | - | ||||||
212 | return d->m_printDevice.isDefault(); never executed: return d->m_printDevice.isDefault(); | 0 | ||||||
213 | } | - | ||||||
214 | - | |||||||
215 | /*! | - | ||||||
216 | Returns whether this printer is a remote network printer. | - | ||||||
217 | - | |||||||
218 | \since 5.3 | - | ||||||
219 | */ | - | ||||||
220 | bool QPrinterInfo::isRemote() const | - | ||||||
221 | { | - | ||||||
222 | Q_D(const QPrinterInfo); | - | ||||||
223 | return d->m_printDevice.isRemote(); never executed: return d->m_printDevice.isRemote(); | 0 | ||||||
224 | } | - | ||||||
225 | - | |||||||
226 | /*! | - | ||||||
227 | Returns the current state of this printer. | - | ||||||
228 | - | |||||||
229 | This state may not always be accurate, depending on the platform, printer | - | ||||||
230 | driver, or printer itself. | - | ||||||
231 | - | |||||||
232 | \since 5.3 | - | ||||||
233 | */ | - | ||||||
234 | QPrinter::PrinterState QPrinterInfo::state() const | - | ||||||
235 | { | - | ||||||
236 | Q_D(const QPrinterInfo); | - | ||||||
237 | return QPrinter::PrinterState(d->m_printDevice.state()); never executed: return QPrinter::PrinterState(d->m_printDevice.state()); | 0 | ||||||
238 | } | - | ||||||
239 | - | |||||||
240 | /*! | - | ||||||
241 | Returns a list of Page Sizes supported by this printer. | - | ||||||
242 | - | |||||||
243 | \since 5.3 | - | ||||||
244 | */ | - | ||||||
245 | - | |||||||
246 | QList<QPageSize> QPrinterInfo::supportedPageSizes() const | - | ||||||
247 | { | - | ||||||
248 | Q_D(const QPrinterInfo); | - | ||||||
249 | return d->m_printDevice.supportedPageSizes(); executed 2 times by 1 test: return d->m_printDevice.supportedPageSizes(); Executed by:
| 2 | ||||||
250 | } | - | ||||||
251 | - | |||||||
252 | /*! | - | ||||||
253 | Returns the current default Page Size for this printer. | - | ||||||
254 | - | |||||||
255 | \since 5.3 | - | ||||||
256 | */ | - | ||||||
257 | - | |||||||
258 | QPageSize QPrinterInfo::defaultPageSize() const | - | ||||||
259 | { | - | ||||||
260 | Q_D(const QPrinterInfo); | - | ||||||
261 | return d->m_printDevice.defaultPageSize(); never executed: return d->m_printDevice.defaultPageSize(); | 0 | ||||||
262 | } | - | ||||||
263 | - | |||||||
264 | /*! | - | ||||||
265 | Returns whether this printer supports custom page sizes. | - | ||||||
266 | - | |||||||
267 | \since 5.3 | - | ||||||
268 | */ | - | ||||||
269 | - | |||||||
270 | bool QPrinterInfo::supportsCustomPageSizes() const | - | ||||||
271 | { | - | ||||||
272 | Q_D(const QPrinterInfo); | - | ||||||
273 | return d->m_printDevice.supportsCustomPageSizes(); never executed: return d->m_printDevice.supportsCustomPageSizes(); | 0 | ||||||
274 | } | - | ||||||
275 | - | |||||||
276 | /*! | - | ||||||
277 | Returns the minimum physical page size supported by this printer. | - | ||||||
278 | - | |||||||
279 | \sa maximumPhysicalPageSize() | - | ||||||
280 | - | |||||||
281 | \since 5.3 | - | ||||||
282 | */ | - | ||||||
283 | - | |||||||
284 | QPageSize QPrinterInfo::minimumPhysicalPageSize() const | - | ||||||
285 | { | - | ||||||
286 | Q_D(const QPrinterInfo); | - | ||||||
287 | return QPageSize(d->m_printDevice.minimumPhysicalPageSize(), QString(), QPageSize::ExactMatch); never executed: return QPageSize(d->m_printDevice.minimumPhysicalPageSize(), QString(), QPageSize::ExactMatch); | 0 | ||||||
288 | } | - | ||||||
289 | - | |||||||
290 | /*! | - | ||||||
291 | Returns the maximum physical page size supported by this printer. | - | ||||||
292 | - | |||||||
293 | \sa minimumPhysicalPageSize() | - | ||||||
294 | - | |||||||
295 | \since 5.3 | - | ||||||
296 | */ | - | ||||||
297 | - | |||||||
298 | QPageSize QPrinterInfo::maximumPhysicalPageSize() const | - | ||||||
299 | { | - | ||||||
300 | Q_D(const QPrinterInfo); | - | ||||||
301 | return QPageSize(d->m_printDevice.maximumPhysicalPageSize(), QString(), QPageSize::ExactMatch); never executed: return QPageSize(d->m_printDevice.maximumPhysicalPageSize(), QString(), QPageSize::ExactMatch); | 0 | ||||||
302 | } | - | ||||||
303 | - | |||||||
304 | #if QT_DEPRECATED_SINCE(5,3) | - | ||||||
305 | /*! | - | ||||||
306 | \obsolete Use supportedPageSizes() instead. | - | ||||||
307 | - | |||||||
308 | Returns a list of supported paper sizes by the printer. | - | ||||||
309 | - | |||||||
310 | Not all printer drivers support this query, so the list may be empty. | - | ||||||
311 | - | |||||||
312 | \since 4.4 | - | ||||||
313 | */ | - | ||||||
314 | - | |||||||
315 | QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const | - | ||||||
316 | { | - | ||||||
317 | Q_D(const QPrinterInfo); | - | ||||||
318 | QList<QPrinter::PaperSize> list; | - | ||||||
319 | const QList<QPageSize> supportedPageSizes = d->m_printDevice.supportedPageSizes(); | - | ||||||
320 | list.reserve(supportedPageSizes.size()); | - | ||||||
321 | for (const QPageSize &pageSize : supportedPageSizes) | - | ||||||
322 | list.append(QPrinter::PaperSize(pageSize.id())); never executed: list.append(QPrinter::PaperSize(pageSize.id())); | 0 | ||||||
323 | return list; never executed: return list; | 0 | ||||||
324 | } | - | ||||||
325 | - | |||||||
326 | /*! | - | ||||||
327 | \obsolete Use supportedPageSizes() instead. | - | ||||||
328 | - | |||||||
329 | Returns a list of all the paper names supported by the driver with the | - | ||||||
330 | corresponding size in millimeters. | - | ||||||
331 | - | |||||||
332 | Not all printer drivers support this query, so the list may be empty. | - | ||||||
333 | - | |||||||
334 | \since 5.1 | - | ||||||
335 | */ | - | ||||||
336 | - | |||||||
337 | QList<QPair<QString, QSizeF> > QPrinterInfo::supportedSizesWithNames() const | - | ||||||
338 | { | - | ||||||
339 | Q_D(const QPrinterInfo); | - | ||||||
340 | QList<QPair<QString, QSizeF> > list; | - | ||||||
341 | const QList<QPageSize> supportedPageSizes = d->m_printDevice.supportedPageSizes(); | - | ||||||
342 | list.reserve(supportedPageSizes.size()); | - | ||||||
343 | for (const QPageSize &pageSize : supportedPageSizes) | - | ||||||
344 | list.append(qMakePair(pageSize.name(), pageSize.size(QPageSize::Millimeter))); never executed: list.append(qMakePair(pageSize.name(), pageSize.size(QPageSize::Millimeter))); | 0 | ||||||
345 | return list; never executed: return list; | 0 | ||||||
346 | } | - | ||||||
347 | #endif // QT_DEPRECATED_SINCE(5,3) | - | ||||||
348 | - | |||||||
349 | /*! | - | ||||||
350 | Returns a list of resolutions supported by this printer. | - | ||||||
351 | - | |||||||
352 | \since 5.3 | - | ||||||
353 | */ | - | ||||||
354 | - | |||||||
355 | QList<int> QPrinterInfo::supportedResolutions() const | - | ||||||
356 | { | - | ||||||
357 | Q_D(const QPrinterInfo); | - | ||||||
358 | return d->m_printDevice.supportedResolutions(); never executed: return d->m_printDevice.supportedResolutions(); | 0 | ||||||
359 | } | - | ||||||
360 | - | |||||||
361 | /*! | - | ||||||
362 | Returns the default duplex mode of this printer. | - | ||||||
363 | - | |||||||
364 | \since 5.4 | - | ||||||
365 | */ | - | ||||||
366 | - | |||||||
367 | QPrinter::DuplexMode QPrinterInfo::defaultDuplexMode() const | - | ||||||
368 | { | - | ||||||
369 | Q_D(const QPrinterInfo); | - | ||||||
370 | return QPrinter::DuplexMode(d->m_printDevice.defaultDuplexMode()); never executed: return QPrinter::DuplexMode(d->m_printDevice.defaultDuplexMode()); | 0 | ||||||
371 | } | - | ||||||
372 | - | |||||||
373 | /*! | - | ||||||
374 | Returns a list of duplex modes supported by this printer. | - | ||||||
375 | - | |||||||
376 | \since 5.4 | - | ||||||
377 | */ | - | ||||||
378 | - | |||||||
379 | QList<QPrinter::DuplexMode> QPrinterInfo::supportedDuplexModes() const | - | ||||||
380 | { | - | ||||||
381 | Q_D(const QPrinterInfo); | - | ||||||
382 | QList<QPrinter::DuplexMode> list; | - | ||||||
383 | const QList<QPrint::DuplexMode> supportedDuplexModes = d->m_printDevice.supportedDuplexModes(); | - | ||||||
384 | list.reserve(supportedDuplexModes.size()); | - | ||||||
385 | for (QPrint::DuplexMode mode : supportedDuplexModes) | - | ||||||
386 | list << QPrinter::DuplexMode(mode); never executed: list << QPrinter::DuplexMode(mode); | 0 | ||||||
387 | return list; never executed: return list; | 0 | ||||||
388 | } | - | ||||||
389 | - | |||||||
390 | /*! | - | ||||||
391 | Returns a list of all the available Printer Names on this system. | - | ||||||
392 | - | |||||||
393 | It is recommended to use this instead of availablePrinters() as | - | ||||||
394 | it will be faster on most systems. | - | ||||||
395 | - | |||||||
396 | Note that the list may become outdated if changes are made on the local | - | ||||||
397 | system or remote print server. Only instantiate required QPrinterInfo | - | ||||||
398 | instances when needed, and always check for validity before calling. | - | ||||||
399 | - | |||||||
400 | \since 5.3 | - | ||||||
401 | */ | - | ||||||
402 | QStringList QPrinterInfo::availablePrinterNames() | - | ||||||
403 | { | - | ||||||
404 | QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get(); | - | ||||||
405 | if (ps)
| 0-134 | ||||||
406 | return ps->availablePrintDeviceIds(); executed 134 times by 2 tests: return ps->availablePrintDeviceIds(); Executed by:
| 134 | ||||||
407 | return QStringList(); never executed: return QStringList(); | 0 | ||||||
408 | } | - | ||||||
409 | - | |||||||
410 | /*! | - | ||||||
411 | Returns a list of QPrinterInfo objects for all the available printers | - | ||||||
412 | on this system. | - | ||||||
413 | - | |||||||
414 | It is NOT recommended to use this as creating each printer instance may | - | ||||||
415 | take a long time, especially if there are remote networked printers, and | - | ||||||
416 | retained instances may become outdated if changes are made on the local | - | ||||||
417 | system or remote print server. Use availablePrinterNames() instead and | - | ||||||
418 | only instantiate printer instances as you need them. | - | ||||||
419 | */ | - | ||||||
420 | QList<QPrinterInfo> QPrinterInfo::availablePrinters() | - | ||||||
421 | { | - | ||||||
422 | QList<QPrinterInfo> list; | - | ||||||
423 | QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get(); | - | ||||||
424 | if (ps) {
| 0-9 | ||||||
425 | const QStringList availablePrintDeviceIds = ps->availablePrintDeviceIds(); | - | ||||||
426 | list.reserve(availablePrintDeviceIds.size()); | - | ||||||
427 | for (const QString &id : availablePrintDeviceIds) | - | ||||||
428 | list.append(QPrinterInfo(id)); never executed: list.append(QPrinterInfo(id)); | 0 | ||||||
429 | } executed 9 times by 2 tests: end of block Executed by:
| 9 | ||||||
430 | return list; executed 9 times by 2 tests: return list; Executed by:
| 9 | ||||||
431 | } | - | ||||||
432 | - | |||||||
433 | /*! | - | ||||||
434 | Returns the current default printer name. | - | ||||||
435 | - | |||||||
436 | \since 5.3 | - | ||||||
437 | */ | - | ||||||
438 | QString QPrinterInfo::defaultPrinterName() | - | ||||||
439 | { | - | ||||||
440 | QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get(); | - | ||||||
441 | if (ps)
| 0 | ||||||
442 | return ps->defaultPrintDeviceId(); never executed: return ps->defaultPrintDeviceId(); | 0 | ||||||
443 | return QString(); never executed: return QString(); | 0 | ||||||
444 | } | - | ||||||
445 | - | |||||||
446 | /*! | - | ||||||
447 | Returns the default printer on the system. | - | ||||||
448 | - | |||||||
449 | The return value should be checked using isNull() before being | - | ||||||
450 | used, in case there is no default printer. | - | ||||||
451 | - | |||||||
452 | On some systems it is possible for there to be available printers | - | ||||||
453 | but none of them set to be the default printer. | - | ||||||
454 | - | |||||||
455 | \sa isNull() | - | ||||||
456 | \sa isDefault() | - | ||||||
457 | \sa availablePrinters() | - | ||||||
458 | */ | - | ||||||
459 | - | |||||||
460 | QPrinterInfo QPrinterInfo::defaultPrinter() | - | ||||||
461 | { | - | ||||||
462 | QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get(); | - | ||||||
463 | if (ps)
| 0-135 | ||||||
464 | return QPrinterInfo(ps->defaultPrintDeviceId()); executed 135 times by 3 tests: return QPrinterInfo(ps->defaultPrintDeviceId()); Executed by:
| 135 | ||||||
465 | return QPrinterInfo(); never executed: return QPrinterInfo(); | 0 | ||||||
466 | } | - | ||||||
467 | - | |||||||
468 | /*! | - | ||||||
469 | Returns the printer \a printerName. | - | ||||||
470 | - | |||||||
471 | The return value should be checked using isNull() before being | - | ||||||
472 | used, in case the named printer does not exist. | - | ||||||
473 | - | |||||||
474 | \since 5.0 | - | ||||||
475 | \sa isNull() | - | ||||||
476 | */ | - | ||||||
477 | QPrinterInfo QPrinterInfo::printerInfo(const QString &printerName) | - | ||||||
478 | { | - | ||||||
479 | return QPrinterInfo(printerName); executed 1 time by 1 test: return QPrinterInfo(printerName); Executed by:
| 1 | ||||||
480 | } | - | ||||||
481 | - | |||||||
482 | # ifndef QT_NO_DEBUG_STREAM | - | ||||||
483 | QDebug operator<<(QDebug debug, const QPrinterInfo &p) | - | ||||||
484 | { | - | ||||||
485 | QDebugStateSaver saver(debug); | - | ||||||
486 | debug.nospace(); | - | ||||||
487 | debug << "QPrinterInfo("; | - | ||||||
488 | if (p.isNull())
| 0 | ||||||
489 | debug << "null"; never executed: debug << "null"; | 0 | ||||||
490 | else | - | ||||||
491 | p.d_ptr->m_printDevice.format(debug); never executed: p.d_ptr->m_printDevice.format(debug); | 0 | ||||||
492 | debug << ')'; | - | ||||||
493 | return debug; never executed: return debug; | 0 | ||||||
494 | } | - | ||||||
495 | # endif // !QT_NO_DEBUG_STREAM | - | ||||||
496 | - | |||||||
497 | QT_END_NAMESPACE | - | ||||||
498 | - | |||||||
499 | #endif // QT_NO_PRINTER | - | ||||||
Source code | Switch to Preprocessed file |