kernel/qprinterinfo.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 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 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 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: http://www.gnu.org/copyleft/fdl.html. -
24** $QT_END_LICENSE$ -
25** -
26****************************************************************************/ -
27 -
28#include "qprinterinfo.h" -
29#include "qprinterinfo_p.h" -
30 -
31#ifndef QT_NO_PRINTER -
32 -
33#include <qpa/qplatformprintplugin.h> -
34#include <qpa/qplatformprintersupport.h> -
35 -
36QT_BEGIN_NAMESPACE -
37 -
38QPrinterInfoPrivate QPrinterInfoPrivate::shared_null; -
39 -
40 -
41/*! -
42 \class QPrinterInfo -
43 -
44 \brief The QPrinterInfo class gives access to information about -
45 existing printers. -
46 -
47 \ingroup printing -
48 \inmodule QtPrintSupport -
49 -
50 Use the static functions to generate a list of QPrinterInfo -
51 objects. Each QPrinterInfo object in the list represents a single -
52 printer and can be queried for name, supported paper sizes, and -
53 whether or not it is the default printer. -
54 -
55 \since 4.4 -
56*/ -
57 -
58/*! -
59 \fn QList<QPrinterInfo> QPrinterInfo::availablePrinters() -
60 -
61 Returns a list of available printers on the system. -
62*/ -
63 -
64/*! -
65 \fn QPrinterInfo QPrinterInfo::defaultPrinter() -
66 -
67 Returns the default printer on the system. -
68 -
69 The return value should be checked using isNull() before being -
70 used, in case there is no default printer. -
71 -
72 On some systems it is possible for there to be available printers -
73 but none of them set to be the default printer. -
74 -
75 \sa isNull() -
76 \sa isDefault() -
77 \sa availablePrinters() -
78*/ -
79 -
80/*! -
81 Constructs an empty QPrinterInfo object. -
82 -
83 \sa isNull() -
84*/ -
85QPrinterInfo::QPrinterInfo() -
86 : d_ptr(&QPrinterInfoPrivate::shared_null) -
87{ -
88}
executed: }
Execution Count:90
90
89 -
90/*! -
91 Constructs a copy of \a other. -
92*/ -
93QPrinterInfo::QPrinterInfo(const QPrinterInfo &other) -
94 : d_ptr(new QPrinterInfoPrivate(*other.d_ptr)) -
95{ -
96}
never executed: }
0
97 -
98/*! -
99 Constructs a QPrinterInfo object from \a printer. -
100*/ -
101QPrinterInfo::QPrinterInfo(const QPrinter &printer) -
102 : d_ptr(&QPrinterInfoPrivate::shared_null) -
103{ -
104 QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
never executed (the execution status of this line is deduced): QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
-
105 if (ps) {
never evaluated: ps
0
106 QPrinterInfo pi = ps->printerInfo(printer.printerName());
never executed (the execution status of this line is deduced): QPrinterInfo pi = ps->printerInfo(printer.printerName());
-
107 d_ptr.reset(new QPrinterInfoPrivate(*pi.d_ptr));
never executed (the execution status of this line is deduced): d_ptr.reset(new QPrinterInfoPrivate(*pi.d_ptr));
-
108 }
never executed: }
0
109}
never executed: }
0
110 -
111/*! -
112 \internal -
113*/ -
114QPrinterInfo::QPrinterInfo(const QString &name) -
115 : d_ptr(new QPrinterInfoPrivate(name)) -
116{ -
117}
never executed: }
0
118 -
119/*! -
120 Destroys the QPrinterInfo object. References to the values in the -
121 object become invalid. -
122*/ -
123QPrinterInfo::~QPrinterInfo() -
124{ -
125} -
126 -
127/*! -
128 Sets the QPrinterInfo object to be equal to \a other. -
129*/ -
130QPrinterInfo &QPrinterInfo::operator=(const QPrinterInfo &other) -
131{ -
132 Q_ASSERT(d_ptr);
never executed (the execution status of this line is deduced): qt_noop();
-
133 d_ptr.reset(new QPrinterInfoPrivate(*other.d_ptr));
never executed (the execution status of this line is deduced): d_ptr.reset(new QPrinterInfoPrivate(*other.d_ptr));
-
134 return *this;
never executed: return *this;
0
135} -
136 -
137/*! -
138 Returns the name of the printer. -
139 -
140 This is a unique id to identify the printer and may not be human-readable. -
141 -
142 \sa QPrinterInfo::description() -
143 \sa QPrinter::setPrinterName() -
144*/ -
145QString QPrinterInfo::printerName() const -
146{ -
147 const Q_D(QPrinterInfo);
executed (the execution status of this line is deduced): const QPrinterInfoPrivate * const d = d_func();
-
148 return d->name;
executed: return d->name;
Execution Count:3
3
149} -
150 -
151/*! -
152 Returns the human-readable description of the printer. -
153 -
154 \since 5.0 -
155 \sa QPrinterInfo::printerName() -
156*/ -
157QString QPrinterInfo::description() const -
158{ -
159 const Q_D(QPrinterInfo);
never executed (the execution status of this line is deduced): const QPrinterInfoPrivate * const d = d_func();
-
160 return d->description;
never executed: return d->description;
0
161} -
162 -
163/*! -
164 Returns the human-readable location of the printer. -
165 -
166 \since 5.0 -
167*/ -
168QString QPrinterInfo::location() const -
169{ -
170 const Q_D(QPrinterInfo);
executed (the execution status of this line is deduced): const QPrinterInfoPrivate * const d = d_func();
-
171 return d->location;
executed: return d->location;
Execution Count:4
4
172} -
173 -
174/*! -
175 Returns the human-readable make and model of the printer. -
176 -
177 \since 5.0 -
178*/ -
179QString QPrinterInfo::makeAndModel() const -
180{ -
181 const Q_D(QPrinterInfo);
executed (the execution status of this line is deduced): const QPrinterInfoPrivate * const d = d_func();
-
182 return d->makeAndModel;
executed: return d->makeAndModel;
Execution Count:4
4
183} -
184 -
185/*! -
186 Returns whether this QPrinterInfo object holds a printer definition. -
187 -
188 An empty QPrinterInfo object could result for example from calling -
189 defaultPrinter() when there are no printers on the system. -
190*/ -
191bool QPrinterInfo::isNull() const -
192{ -
193 Q_D(const QPrinterInfo);
executed (the execution status of this line is deduced): const QPrinterInfoPrivate * const d = d_func();
-
194 return d == &QPrinterInfoPrivate::shared_null;
executed: return d == &QPrinterInfoPrivate::shared_null;
Execution Count:84
84
195} -
196 -
197/*! -
198 Returns whether this printer is the default printer. -
199*/ -
200bool QPrinterInfo::isDefault() const -
201{ -
202 Q_D(const QPrinterInfo);
never executed (the execution status of this line is deduced): const QPrinterInfoPrivate * const d = d_func();
-
203 return d->isDefault;
never executed: return d->isDefault;
0
204} -
205 -
206/*! -
207 Returns a list of supported paper sizes by the printer. -
208 -
209 Not all printer drivers support this query, so the list may be empty. -
210 On Mac OS X 10.3, this function always returns an empty list. -
211 -
212 \since 4.4 -
213*/ -
214 -
215QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const -
216{ -
217 Q_D(const QPrinterInfo);
never executed (the execution status of this line is deduced): const QPrinterInfoPrivate * const d = d_func();
-
218 if (!isNull() && !d->hasPaperSizes) {
never evaluated: !isNull()
never evaluated: !d->hasPaperSizes
0
219 d->paperSizes = QPlatformPrinterSupportPlugin::get()->supportedPaperSizes(*this);
never executed (the execution status of this line is deduced): d->paperSizes = QPlatformPrinterSupportPlugin::get()->supportedPaperSizes(*this);
-
220 d->hasPaperSizes = true;
never executed (the execution status of this line is deduced): d->hasPaperSizes = true;
-
221 }
never executed: }
0
222 return d->paperSizes;
never executed: return d->paperSizes;
0
223} -
224 -
225QList<QPrinterInfo> QPrinterInfo::availablePrinters() -
226{ -
227 QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
executed (the execution status of this line is deduced): QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
-
228 if (!ps)
partially evaluated: !ps
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:100
0-100
229 return QList<QPrinterInfo>();
never executed: return QList<QPrinterInfo>();
0
230 return ps->availablePrinters();
executed: return ps->availablePrinters();
Execution Count:100
100
231} -
232 -
233QPrinterInfo QPrinterInfo::defaultPrinter() -
234{ -
235 QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
executed (the execution status of this line is deduced): QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
-
236 if (!ps)
partially evaluated: !ps
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:85
0-85
237 return QPrinterInfo();
never executed: return QPrinterInfo();
0
238 return ps->defaultPrinter();
executed: return ps->defaultPrinter();
Execution Count:85
85
239} -
240 -
241/*! -
242 Returns the printer \a printerName. -
243 -
244 The return value should be checked using isNull() before being -
245 used, in case the named printer does not exist. -
246 -
247 \since 5.0 -
248 \sa isNull() -
249*/ -
250QPrinterInfo QPrinterInfo::printerInfo(const QString &printerName) -
251{ -
252 QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
executed (the execution status of this line is deduced): QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
-
253 if (!ps)
partially evaluated: !ps
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
254 return QPrinterInfo();
never executed: return QPrinterInfo();
0
255 return ps->printerInfo(printerName);
executed: return ps->printerInfo(printerName);
Execution Count:4
4
256} -
257 -
258QT_END_NAMESPACE -
259 -
260#endif // QT_NO_PRINTER -
261 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial