Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#include "qprintdevice_p.h"
6
7#include <private/qdebug_p.h>
8
10
11#ifndef QT_NO_PRINTER
12
17
22
24 : d(dd)
25{
26}
27
32
36
38{
39 d = other.d;
40 return *this;
41}
42
44{
45 if (d && other.d)
46 return d->id() == other.d->id();
47 return d == other.d;
48}
49
51{
52 return isValid() ? d->id() : QString();
53}
54
56{
57 return isValid() ? d->name() : QString();
58}
59
61{
62 return isValid() ? d->location() : QString();
63}
64
66{
67 return isValid() ? d->makeAndModel() : QString();
68}
69
71{
72 return d && d->isValid();
73}
74
76{
77 return isValid() && d->isDefault();
78}
79
81{
82 return isValid() && d->isRemote();
83}
84
89
90bool QPrintDevice::isValidPageLayout(const QPageLayout &layout, int resolution) const
91{
92 return isValid() && d->isValidPageLayout(layout, resolution);
93}
94
99
101{
102 return isValid() && d->supportsCollateCopies();
103}
104
109
110QList<QPageSize> QPrintDevice::supportedPageSizes() const
111{
112 return isValid() ? d->supportedPageSizes() : QList<QPageSize>();
113}
114
116{
117 return isValid() ? d->supportedPageSize(pageSize) : QPageSize();
118}
119
121{
122 return isValid() ? d->supportedPageSize(pageSizeId) : QPageSize();
123}
124
126{
127 return isValid() ? d->supportedPageSize(pageName) : QPageSize();
128}
129
131{
132 return isValid() ? d->supportedPageSize(pointSize) : QPageSize();
133}
134
139
141{
142 return isValid() && d->supportsCustomPageSizes();
143}
144
149
154
156 QPageLayout::Orientation orientation,
157 int resolution) const
158{
159 return isValid() ? d->printableMargins(pageSize, orientation, resolution) : QMarginsF();
160}
161
163{
164 return isValid() ? d->defaultResolution() : 0;
165}
166
168{
169 return isValid() ? d->supportedResolutions() : QList<int>();
170}
171
176
177QList<QPrint::InputSlot> QPrintDevice::supportedInputSlots() const
178{
179 return isValid() ? d->supportedInputSlots() : QList<QPrint::InputSlot>{};
180}
181
186
187QList<QPrint::OutputBin> QPrintDevice::supportedOutputBins() const
188{
189 return isValid() ? d->supportedOutputBins() : QList<QPrint::OutputBin>{};
190}
191
196
197QList<QPrint::DuplexMode> QPrintDevice::supportedDuplexModes() const
198{
199 return isValid() ? d->supportedDuplexModes() : QList<QPrint::DuplexMode>{};
200}
201
206
207QList<QPrint::ColorMode> QPrintDevice::supportedColorModes() const
208{
209 return isValid() ? d->supportedColorModes() : QList<QPrint::ColorMode>{};
210}
211
216
218{
219 return isValid() ? d->setProperty(key, value) : false;
220}
221
226
227#if QT_CONFIG(mimetype)
228QList<QMimeType> QPrintDevice::supportedMimeTypes() const
229{
230 return isValid() ? d->supportedMimeTypes() : QList<QMimeType>();
231}
232#endif // mimetype
233
234# ifndef QT_NO_DEBUG_STREAM
236{
237 QDebugStateSaver saver(debug);
238 debug.noquote();
239 debug.nospace();
240 if (isValid()) {
241 const QString deviceId = id();
242 const QString deviceName = name();
243 debug << "id=\"" << deviceId << "\", state=" << state();
244 if (!deviceName.isEmpty() && deviceName != deviceId)
245 debug << ", name=\"" << deviceName << '"';
246 if (!location().isEmpty())
247 debug << ", location=\"" << location() << '"';
248 debug << ", makeAndModel=\"" << makeAndModel() << '"';
249 if (isDefault())
250 debug << ", default";
251 if (isRemote())
252 debug << ", remote";
253 debug << ", defaultPageSize=" << defaultPageSize();
255 debug << ", supportsCustomPageSizes";
256 debug << ", physicalPageSize=(";
258 debug << ")..(";
260 debug << "), defaultResolution=" << defaultResolution()
261 << ", defaultDuplexMode=" << defaultDuplexMode()
262 << ", defaultColorMode="<< defaultColorMode();
263# if QT_CONFIG(mimetype)
264 const QList<QMimeType> mimeTypes = supportedMimeTypes();
265 if (!mimeTypes.isEmpty()) {
266 debug << ", supportedMimeTypes=(";
267 for (const auto &mimeType : mimeTypes)
268 debug << " \"" << mimeType.name() << '"';
269 debug << ')';
270 }
271# endif // mimetype
272 } else {
273 debug << "null";
274 }
275}
276
278{
279 QDebugStateSaver saver(debug);
280 debug.nospace();
281 debug << "QPrintDevice(";
282 p.format(debug);
283 debug << ')';
284 return debug;
285}
286# endif // QT_NO_DEBUG_STREAM
287#endif // QT_NO_PRINTER
288
\inmodule QtCore
\inmodule QtCore
\inmodule QtCore
Definition qmargins.h:270
\inmodule QtGui
Definition qpagelayout.h:20
Orientation
This enum type defines the page orientation.
Definition qpagelayout.h:33
\inmodule QtGui
Definition qpagesize.h:22
Unit
This enum type is used to specify the measurement unit for page sizes.
Definition qpagesize.h:175
PageSizeId
This enum type lists the available page sizes as defined in the Postscript PPD standard.
Definition qpagesize.h:25
virtual QString id() const
virtual bool supportsCollateCopies() const
virtual bool isFeatureAvailable(QPrintDevice::PrintDevicePropertyKey key, const QVariant &params) const
virtual QPrint::ColorMode defaultColorMode() const
virtual QSize maximumPhysicalPageSize() const
virtual QPageSize supportedPageSize(const QPageSize &pageSize) const
virtual QList< QPrint::OutputBin > supportedOutputBins() const
virtual bool isDefault() const
virtual QList< QPrint::InputSlot > supportedInputSlots() const
virtual bool supportsCustomPageSizes() const
virtual QList< QPrint::ColorMode > supportedColorModes() const
virtual bool isValid() const
virtual int defaultResolution() const
virtual bool isRemote() const
virtual QVariant property(QPrintDevice::PrintDevicePropertyKey key) const
virtual QPageSize defaultPageSize() const
virtual bool supportsMultipleCopies() const
virtual bool setProperty(QPrintDevice::PrintDevicePropertyKey key, const QVariant &value)
virtual bool isValidPageLayout(const QPageLayout &layout, int resolution) const
virtual QList< QPageSize > supportedPageSizes() const
virtual QPrint::DeviceState state() const
virtual QString name() const
virtual QPrint::InputSlot defaultInputSlot() const
virtual QList< int > supportedResolutions() const
virtual QList< QPrint::DuplexMode > supportedDuplexModes() const
virtual QPrint::DuplexMode defaultDuplexMode() const
virtual QMarginsF printableMargins(const QPageSize &pageSize, QPageLayout::Orientation orientation, int resolution) const
virtual QString makeAndModel() const
virtual QString location() const
virtual QSize minimumPhysicalPageSize() const
virtual QPrint::OutputBin defaultOutputBin() const
QPageSize supportedPageSize(const QPageSize &pageSize) const
bool isValidPageLayout(const QPageLayout &layout, int resolution) const
QList< QPrint::InputSlot > supportedInputSlots() const
bool isValid() const
int defaultResolution() const
QPageSize defaultPageSize() const
bool isRemote() const
QList< QPrint::DuplexMode > supportedDuplexModes() const
bool isDefault() const
QPrint::DuplexMode defaultDuplexMode() const
QPrint::DeviceState state() const
QVariant property(PrintDevicePropertyKey key) const
void format(QDebug debug) const
QString name() const
QList< QPageSize > supportedPageSizes() const
bool isFeatureAvailable(PrintDevicePropertyKey key, const QVariant &params) const
bool supportsMultipleCopies() const
QList< QPrint::ColorMode > supportedColorModes() const
QSize minimumPhysicalPageSize() const
bool operator==(const QPrintDevice &other) const
QSize maximumPhysicalPageSize() const
QPrint::InputSlot defaultInputSlot() const
QList< int > supportedResolutions() const
QString makeAndModel() const
QPrint::ColorMode defaultColorMode() const
bool supportsCollateCopies() const
QList< QPrint::OutputBin > supportedOutputBins() const
QPrint::OutputBin defaultOutputBin() const
QPrintDevice & operator=(const QPrintDevice &other)
bool setProperty(PrintDevicePropertyKey key, const QVariant &value)
QString location() const
QMarginsF printableMargins(const QPageSize &pageSize, QPageLayout::Orientation orientation, int resolution) const
QString id() const
bool supportsCustomPageSizes() const
\inmodule QtCore
Definition qsize.h:208
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
\inmodule QtCore
Definition qvariant.h:65
ColorMode
Definition qprint_p.h:72
@ GrayScale
Definition qprint_p.h:73
DuplexMode
Definition qprint_p.h:64
@ DuplexNone
Definition qprint_p.h:65
DeviceState
Definition qprint_p.h:56
@ Error
Definition qprint_p.h:60
Combined button and popup list for selecting options.
static void formatQSize(QDebug &debug, const Size &size)
Definition qdebug_p.h:39
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
const char * mimeType
GLuint64 key
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint id
[7]
GLfloat units
void ** params
GLfloat GLfloat p
[1]
QDebug operator<<(QDebug debug, const QPrintDevice &p)
QVBoxLayout * layout
QSharedPointer< T > other(t)
[5]