Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qprintdevice.cpp
Go to the documentation of this file.
1
// Copyright (C) 2014 John Layt <jlayt@kde.org>
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
include
"qprintdevice_p.h"
6
#
include
"qplatformprintdevice.h"
7
8
#
include
<
private
/
qdebug_p
.
h
>
9
10
QT_BEGIN_NAMESPACE
11
12
#
ifndef
QT_NO_PRINTER
13
14
QPrintDevice::QPrintDevice()
15
: d(
new
QPlatformPrintDevice())
16
{
17
}
18
19
QPrintDevice::QPrintDevice(
const
QString &id)
20
: d(
new
QPlatformPrintDevice(id))
21
{
22
}
23
24
QPrintDevice::QPrintDevice(QPlatformPrintDevice *dd)
25
: d(dd)
26
{
27
}
28
29
QPrintDevice::QPrintDevice(
const
QPrintDevice &other)
30
: d(other.d)
31
{
32
}
33
34
QPrintDevice::~QPrintDevice()
35
{
36
}
37
38
QPrintDevice &QPrintDevice::operator=(
const
QPrintDevice &other)
39
{
40
d = other.d;
41
return
*
this
;
42
}
43
44
bool
QPrintDevice::operator==(
const
QPrintDevice &other)
const
45
{
46
if
(d && other.d)
47
return
d->id() == other.d->id();
48
return
d == other.d;
49
}
50
51
QString QPrintDevice::id()
const
52
{
53
return
isValid() ? d->id() : QString();
54
}
55
56
QString QPrintDevice::name()
const
57
{
58
return
isValid() ? d->name() : QString();
59
}
60
61
QString QPrintDevice::location()
const
62
{
63
return
isValid() ? d->location() : QString();
64
}
65
66
QString QPrintDevice::makeAndModel()
const
67
{
68
return
isValid() ? d->makeAndModel() : QString();
69
}
70
71
bool
QPrintDevice::isValid()
const
72
{
73
return
d && d->isValid();
74
}
75
76
bool
QPrintDevice::isDefault()
const
77
{
78
return
isValid() && d->isDefault();
79
}
80
81
bool
QPrintDevice::isRemote()
const
82
{
83
return
isValid() && d->isRemote();
84
}
85
86
QPrint::DeviceState QPrintDevice::state()
const
87
{
88
return
isValid() ? d->state() : QPrint::Error;
89
}
90
91
bool
QPrintDevice::isValidPageLayout(
const
QPageLayout &layout,
int
resolution)
const
92
{
93
return
isValid() && d->isValidPageLayout(layout, resolution);
94
}
95
96
bool
QPrintDevice::supportsMultipleCopies()
const
97
{
98
return
isValid() && d->supportsMultipleCopies();
99
}
100
101
bool
QPrintDevice::supportsCollateCopies()
const
102
{
103
return
isValid() && d->supportsCollateCopies();
104
}
105
106
QPageSize QPrintDevice::defaultPageSize()
const
107
{
108
return
isValid() ? d->defaultPageSize() : QPageSize();
109
}
110
111
QList<QPageSize> QPrintDevice::supportedPageSizes()
const
112
{
113
return
isValid() ? d->supportedPageSizes() : QList<QPageSize>();
114
}
115
116
QPageSize QPrintDevice::supportedPageSize(
const
QPageSize &pageSize)
const
117
{
118
return
isValid() ? d->supportedPageSize(pageSize) : QPageSize();
119
}
120
121
QPageSize QPrintDevice::supportedPageSize(QPageSize::PageSizeId pageSizeId)
const
122
{
123
return
isValid() ? d->supportedPageSize(pageSizeId) : QPageSize();
124
}
125
126
QPageSize QPrintDevice::supportedPageSize(
const
QString &pageName)
const
127
{
128
return
isValid() ? d->supportedPageSize(pageName) : QPageSize();
129
}
130
131
QPageSize QPrintDevice::supportedPageSize(
const
QSize &pointSize)
const
132
{
133
return
isValid() ? d->supportedPageSize(pointSize) : QPageSize();
134
}
135
136
QPageSize QPrintDevice::supportedPageSize(
const
QSizeF &size, QPageSize::Unit units)
const
137
{
138
return
isValid() ? d->supportedPageSize(size, units) : QPageSize();
139
}
140
141
bool
QPrintDevice::supportsCustomPageSizes()
const
142
{
143
return
isValid() && d->supportsCustomPageSizes();
144
}
145
146
QSize QPrintDevice::minimumPhysicalPageSize()
const
147
{
148
return
isValid() ? d->minimumPhysicalPageSize() : QSize();
149
}
150
151
QSize QPrintDevice::maximumPhysicalPageSize()
const
152
{
153
return
isValid() ? d->maximumPhysicalPageSize() : QSize();
154
}
155
156
QMarginsF QPrintDevice::printableMargins(
const
QPageSize &pageSize,
157
QPageLayout::Orientation orientation,
158
int
resolution)
const
159
{
160
return
isValid() ? d->printableMargins(pageSize, orientation, resolution) : QMarginsF();
161
}
162
163
int
QPrintDevice::defaultResolution()
const
164
{
165
return
isValid() ? d->defaultResolution() : 0;
166
}
167
168
QList<
int
> QPrintDevice::supportedResolutions()
const
169
{
170
return
isValid() ? d->supportedResolutions() : QList<
int
>();
171
}
172
173
QPrint::InputSlot QPrintDevice::defaultInputSlot()
const
174
{
175
return
isValid() ? d->defaultInputSlot() : QPrint::InputSlot();
176
}
177
178
QList<QPrint::InputSlot> QPrintDevice::supportedInputSlots()
const
179
{
180
return
isValid() ? d->supportedInputSlots() : QList<QPrint::InputSlot>{};
181
}
182
183
QPrint::OutputBin QPrintDevice::defaultOutputBin()
const
184
{
185
return
isValid() ? d->defaultOutputBin() : QPrint::OutputBin();
186
}
187
188
QList<QPrint::OutputBin> QPrintDevice::supportedOutputBins()
const
189
{
190
return
isValid() ? d->supportedOutputBins() : QList<QPrint::OutputBin>{};
191
}
192
193
QPrint::DuplexMode QPrintDevice::defaultDuplexMode()
const
194
{
195
return
isValid() ? d->defaultDuplexMode() : QPrint::DuplexNone;
196
}
197
198
QList<QPrint::DuplexMode> QPrintDevice::supportedDuplexModes()
const
199
{
200
return
isValid() ? d->supportedDuplexModes() : QList<QPrint::DuplexMode>{};
201
}
202
203
QPrint::ColorMode QPrintDevice::defaultColorMode()
const
204
{
205
return
isValid() ? d->defaultColorMode() : QPrint::GrayScale;
206
}
207
208
QList<QPrint::ColorMode> QPrintDevice::supportedColorModes()
const
209
{
210
return
isValid() ? d->supportedColorModes() : QList<QPrint::ColorMode>{};
211
}
212
213
QVariant QPrintDevice::property(PrintDevicePropertyKey key,
const
QVariant ¶ms)
const
214
{
215
return
isValid() ? d->property(key, params) : QVariant();
216
}
217
218
bool
QPrintDevice::setProperty(PrintDevicePropertyKey key,
const
QVariant &value)
219
{
220
return
isValid() ? d->setProperty(key, value) :
false
;
221
}
222
223
bool
QPrintDevice::isFeatureAvailable(PrintDevicePropertyKey key,
const
QVariant ¶ms)
const
224
{
225
return
isValid() ? d->isFeatureAvailable(key, params) :
false
;
226
}
227
228
#
if
QT_CONFIG
(
mimetype
)
229
QList<QMimeType> QPrintDevice::supportedMimeTypes()
const
230
{
231
return
isValid() ? d->supportedMimeTypes() : QList<QMimeType>();
232
}
233
#
endif
// mimetype
234
235
#
ifndef
QT_NO_DEBUG_STREAM
236
void
QPrintDevice::format(QDebug debug)
const
237
{
238
QDebugStateSaver saver(debug);
239
debug.noquote();
240
debug.nospace();
241
if
(isValid()) {
242
const
QString deviceId = id();
243
const
QString deviceName = name();
244
debug <<
"id=\""
<< deviceId <<
"\", state="
<< state();
245
if
(!deviceName.isEmpty() && deviceName != deviceId)
246
debug <<
", name=\""
<< deviceName <<
'"'
;
247
if
(!location().isEmpty())
248
debug <<
", location=\""
<< location() <<
'"'
;
249
debug <<
", makeAndModel=\""
<< makeAndModel() <<
'"'
;
250
if
(isDefault())
251
debug <<
", default"
;
252
if
(isRemote())
253
debug <<
", remote"
;
254
debug <<
", defaultPageSize="
<< defaultPageSize();
255
if
(supportsCustomPageSizes())
256
debug <<
", supportsCustomPageSizes"
;
257
debug <<
", physicalPageSize=("
;
258
QtDebugUtils::formatQSize(debug, minimumPhysicalPageSize());
259
debug <<
")..("
;
260
QtDebugUtils::formatQSize(debug, maximumPhysicalPageSize());
261
debug <<
"), defaultResolution="
<< defaultResolution()
262
<<
", defaultDuplexMode="
<< defaultDuplexMode()
263
<<
", defaultColorMode="
<< defaultColorMode();
264
#
if
QT_CONFIG
(
mimetype
)
265
const
QList<QMimeType> mimeTypes = supportedMimeTypes();
266
if
(!mimeTypes.isEmpty()) {
267
debug <<
", supportedMimeTypes=("
;
268
for
(
const
auto
&mimeType : mimeTypes)
269
debug <<
" \""
<< mimeType.name() <<
'"'
;
270
debug <<
')'
;
271
}
272
#
endif
// mimetype
273
}
else
{
274
debug <<
"null"
;
275
}
276
}
277
278
QDebug operator<<(QDebug debug,
const
QPrintDevice &p)
279
{
280
QDebugStateSaver saver(debug);
281
debug.nospace();
282
debug <<
"QPrintDevice("
;
283
p.format(debug);
284
debug <<
')'
;
285
return
debug;
286
}
287
#
endif
// QT_NO_DEBUG_STREAM
288
#
endif
// QT_NO_PRINTER
289
290
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtbase
src
printsupport
kernel
qprintdevice.cpp
Generated on
for Qt by
1.18.0