qprinterinfo.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/printsupport/kernel/qprinterinfo.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9namespace { namespace Q_QGS_shared_null { typedef QPrinterInfoPrivate Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized) guard.store(QtGlobalStatic::Destroyed); } }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return &holder.value; } } } static QGlobalStatic<QPrinterInfoPrivate, Q_QGS_shared_null::innerFunction, Q_QGS_shared_null::guard> shared_null;;-
10-
11class QPrinterInfoPrivateDeleter-
12{-
13public:-
14 static inline void cleanup(QPrinterInfoPrivate *d)-
15 {-
16 if (d != shared_null)-
17 delete d;-
18 }-
19};-
20-
21QPrinterInfoPrivate::QPrinterInfoPrivate(const QString &id)-
22{-
23 if (!id.isEmpty()) {-
24 QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();-
25 if (ps)-
26 m_printDevice = ps->createPrintDevice(id);-
27 }-
28}-
29-
30QPrinterInfoPrivate::~QPrinterInfoPrivate()-
31{-
32}-
33QPrinterInfo::QPrinterInfo()-
34 : d_ptr(shared_null)-
35{-
36}-
37-
38-
39-
40-
41QPrinterInfo::QPrinterInfo(const QPrinterInfo &other)-
42 : d_ptr((other.d_ptr.data() == shared_null) ? shared_null : new QPrinterInfoPrivate(*other.d_ptr))-
43{-
44}-
45-
46-
47-
48-
49QPrinterInfo::QPrinterInfo(const QPrinter &printer)-
50 : d_ptr(shared_null)-
51{-
52 QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();-
53 if (ps) {-
54 QPrinterInfo pi(printer.printerName());-
55 if (pi.d_ptr.data() == shared_null)-
56 d_ptr.reset(shared_null);-
57 else-
58 d_ptr.reset(new QPrinterInfoPrivate(*pi.d_ptr));-
59 }-
60}-
61-
62-
63-
64-
65QPrinterInfo::QPrinterInfo(const QString &name)-
66 : d_ptr(new QPrinterInfoPrivate(name))-
67{-
68}-
69-
70-
71-
72-
73-
74QPrinterInfo::~QPrinterInfo()-
75{-
76}-
77-
78-
79-
80-
81QPrinterInfo &QPrinterInfo::operator=(const QPrinterInfo &other)-
82{-
83 ((!(d_ptr)) ? qt_assert("d_ptr",__FILE__,138) : qt_noop());-
84 if (other.d_ptr.data() == shared_null)-
85 d_ptr.reset(shared_null);-
86 else-
87 d_ptr.reset(new QPrinterInfoPrivate(*other.d_ptr));-
88 return *this;-
89}-
90QString QPrinterInfo::printerName() const-
91{-
92 const QPrinterInfoPrivate * const d = d_func();-
93 return d->m_printDevice.id();-
94}-
95-
96-
97-
98-
99-
100-
101-
102QString QPrinterInfo::description() const-
103{-
104 const QPrinterInfoPrivate * const d = d_func();-
105 return d->m_printDevice.name();-
106}-
107-
108-
109-
110-
111-
112-
113QString QPrinterInfo::location() const-
114{-
115 const QPrinterInfoPrivate * const d = d_func();-
116 return d->m_printDevice.location();-
117}-
118-
119-
120-
121-
122-
123-
124QString QPrinterInfo::makeAndModel() const-
125{-
126 const QPrinterInfoPrivate * const d = d_func();-
127 return d->m_printDevice.makeAndModel();-
128}-
129-
130-
131-
132-
133-
134-
135-
136bool QPrinterInfo::isNull() const-
137{-
138 const QPrinterInfoPrivate * const d = d_func();-
139 return d == shared_null || !d->m_printDevice.isValid();-
140}-
141-
142-
143-
144-
145bool QPrinterInfo::isDefault() const-
146{-
147 const QPrinterInfoPrivate * const d = d_func();-
148 return d->m_printDevice.isDefault();-
149}-
150-
151-
152-
153-
154-
155-
156bool QPrinterInfo::isRemote() const-
157{-
158 const QPrinterInfoPrivate * const d = d_func();-
159 return d->m_printDevice.isRemote();-
160}-
161QPrinter::PrinterState QPrinterInfo::state() const-
162{-
163 const QPrinterInfoPrivate * const d = d_func();-
164 return QPrinter::PrinterState(d->m_printDevice.state());-
165}-
166-
167-
168-
169-
170-
171-
172-
173QList<QPageSize> QPrinterInfo::supportedPageSizes() const-
174{-
175 const QPrinterInfoPrivate * const d = d_func();-
176 return d->m_printDevice.supportedPageSizes();-
177}-
178-
179-
180-
181-
182-
183-
184-
185QPageSize QPrinterInfo::defaultPageSize() const-
186{-
187 const QPrinterInfoPrivate * const d = d_func();-
188 return d->m_printDevice.defaultPageSize();-
189}-
190-
191-
192-
193-
194-
195-
196-
197bool QPrinterInfo::supportsCustomPageSizes() const-
198{-
199 const QPrinterInfoPrivate * const d = d_func();-
200 return d->m_printDevice.supportsCustomPageSizes();-
201}-
202QPageSize QPrinterInfo::minimumPhysicalPageSize() const-
203{-
204 const QPrinterInfoPrivate * const d = d_func();-
205 return QPageSize(d->m_printDevice.minimumPhysicalPageSize(), QString(), QPageSize::ExactMatch);-
206}-
207QPageSize QPrinterInfo::maximumPhysicalPageSize() const-
208{-
209 const QPrinterInfoPrivate * const d = d_func();-
210 return QPageSize(d->m_printDevice.maximumPhysicalPageSize(), QString(), QPageSize::ExactMatch);-
211}-
212QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const-
213{-
214 const QPrinterInfoPrivate * const d = d_func();-
215 QList<QPrinter::PaperSize> list;-
216 const QList<QPageSize> supportedPageSizes = d->m_printDevice.supportedPageSizes();-
217 list.reserve(supportedPageSizes.size());-
218 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(supportedPageSizes)>::type> _container_((supportedPageSizes)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QPageSize &pageSize = *_container_.i; _container_.control; _container_.control = 0: supportedPageSizes)-
219 list.append(QPrinter::PaperSize(pageSize.id()));
never executed: list.append(QPrinter::PaperSize(pageSize.id()));
0
220 return
never executed: return list;
list;
never executed: return list;
0
221}-
222QList<QPair<QString, QSizeF> > QPrinterInfo::supportedSizesWithNames() const-
223{-
224 const QPrinterInfoPrivate * const d = d_func();-
225 QList<QPair<QString, QSizeF> > list;-
226 const QList<QPageSize> supportedPageSizes = d->m_printDevice.supportedPageSizes();-
227 list.reserve(supportedPageSizes.size());-
228 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(supportedPageSizes)>::type> _container_((supportedPageSizes)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (const QPageSize &pageSize = *_container_.i; _container_.control; _container_.control = 0: supportedPageSizes)-
229 list.append(qMakePair(pageSize.name(), pageSize.size(QPageSize::Millimeter)));
never executed: list.append(qMakePair(pageSize.name(), pageSize.size(QPageSize::Millimeter)));
0
230 return
never executed: return list;
list;
never executed: return list;
0
231}-
232QList<int> QPrinterInfo::supportedResolutions() const-
233{-
234 const QPrinterInfoPrivate * const d = d_func();-
235 return d->m_printDevice.supportedResolutions();-
236}-
237-
238-
239-
240-
241-
242-
243-
244QPrinter::DuplexMode QPrinterInfo::defaultDuplexMode() const-
245{-
246 const QPrinterInfoPrivate * const d = d_func();-
247 return QPrinter::DuplexMode(d->m_printDevice.defaultDuplexMode());-
248}-
249-
250-
251-
252-
253-
254-
255-
256QList<QPrinter::DuplexMode> QPrinterInfo::supportedDuplexModes() const-
257{-
258 const QPrinterInfoPrivate * const d = d_func();-
259 QList<QPrinter::DuplexMode> list;-
260 const QList<QPrint::DuplexMode> supportedDuplexModes = d->m_printDevice.supportedDuplexModes();-
261 list.reserve(supportedDuplexModes.size());-
262 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(supportedDuplexModes)>::type> _container_((supportedDuplexModes)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QPrint::DuplexMode mode = *_container_.i; _container_.control; _container_.control = 0: supportedDuplexModes)-
263 list << QPrinter::DuplexMode(mode);
never executed: list << QPrinter::DuplexMode(mode);
0
264 return
never executed: return list;
list;
never executed: return list;
0
265}-
266QStringList QPrinterInfo::availablePrinterNames()-
267{-
268 QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();-
269 if (ps)-
270 return ps->availablePrintDeviceIds();-
271 return QStringList();-
272}-
273QList<QPrinterInfo> QPrinterInfo::availablePrinters()-
274{-
275 QList<QPrinterInfo> list;-
276 QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();-
277 if (ps
psDescription
TRUEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QPrinter
  • tst_QPrinterInfo
FALSEnever evaluated
) {
0-9
278 const QStringList availablePrintDeviceIds = ps->availablePrintDeviceIds();-
279 list.reserve(availablePrintDeviceIds.size());-
280 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(availablePrintDeviceIds)>::type> _container_((availablePrintDeviceIds)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (const QString &id = *_container_.i; _container_.control; _container_.control = 0: availablePrintDeviceIds)-
281 list.append(QPrinterInfo(id));
never executed: list.append(QPrinterInfo(id));
0
282 }
executed 9 times by 2 tests: end of block
Executed by:
  • tst_QPrinter
  • tst_QPrinterInfo
9
283 return
executed 9 times by 2 tests: return list;
Executed by:
  • tst_QPrinter
  • tst_QPrinterInfo
list;
executed 9 times by 2 tests: return list;
Executed by:
  • tst_QPrinter
  • tst_QPrinterInfo
9
284}-
285-
286-
287-
288-
289-
290-
291QString QPrinterInfo::defaultPrinterName()-
292{-
293 QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();-
294 if (ps)-
295 return ps->defaultPrintDeviceId();-
296 return QString();-
297}-
298QPrinterInfo QPrinterInfo::defaultPrinter()-
299{-
300 QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();-
301 if (ps)-
302 return QPrinterInfo(ps->defaultPrintDeviceId());-
303 return QPrinterInfo();-
304}-
305QPrinterInfo QPrinterInfo::printerInfo(const QString &printerName)-
306{-
307 return QPrinterInfo(printerName);-
308}-
309-
310-
311QDebug operator<<(QDebug debug, const QPrinterInfo &p)-
312{-
313 QDebugStateSaver saver(debug);-
314 debug.nospace();-
315 debug << "QPrinterInfo(";-
316 if (p.isNull())-
317 debug << "null";-
318 else-
319 p.d_ptr->m_printDevice.format(debug);-
320 debug << ')';-
321 return debug;-
322}-
323-
324-
325-
Switch to Source codePreprocessed file

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