1
/****************************************************************************
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the documentation of the Qt Toolkit.
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.
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.
26
****************************************************************************/
28
#include "qprinterinfo.h"
29
#include "qprinterinfo_p.h"
33
#include <qpa/qplatformprintplugin.h>
34
#include <qpa/qplatformprintersupport.h>
38
QPrinterInfoPrivate QPrinterInfoPrivate::shared_null;
44
\brief The QPrinterInfo class gives access to information about
48
\inmodule QtPrintSupport
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.
59
\fn QList<QPrinterInfo> QPrinterInfo::availablePrinters()
61
Returns a list of available printers on the system.
65
\fn QPrinterInfo QPrinterInfo::defaultPrinter()
67
Returns the default printer on the system.
69
The return value should be checked using isNull() before being
70
used, in case there is no default printer.
72
On some systems it is possible for there to be available printers
73
but none of them set to be the default printer.
77
\sa availablePrinters()
81
Constructs an empty QPrinterInfo object.
85
QPrinterInfo::QPrinterInfo()
86
: d_ptr(&QPrinterInfoPrivate::shared_null)
91
Constructs a copy of \a other.
93
QPrinterInfo::QPrinterInfo(const QPrinterInfo &other)
94
: d_ptr(new QPrinterInfoPrivate(*other.d_ptr))
99
Constructs a QPrinterInfo object from \a printer.
101
QPrinterInfo::QPrinterInfo(const QPrinter &printer)
102
: d_ptr(&QPrinterInfoPrivate::shared_null)
104
QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
106
QPrinterInfo pi = ps->printerInfo(printer.printerName());
107
d_ptr.reset(new QPrinterInfoPrivate(*pi.d_ptr));
114
QPrinterInfo::QPrinterInfo(const QString &name)
115
: d_ptr(new QPrinterInfoPrivate(name))
120
Destroys the QPrinterInfo object. References to the values in the
121
object become invalid.
123
QPrinterInfo::~QPrinterInfo()
128
Sets the QPrinterInfo object to be equal to \a other.
130
QPrinterInfo &QPrinterInfo::operator=(const QPrinterInfo &other)
133
d_ptr.reset(new QPrinterInfoPrivate(*other.d_ptr));
138
Returns the name of the printer.
140
This is a unique id to identify the printer and may not be human-readable.
142
\sa QPrinterInfo::description()
143
\sa QPrinter::setPrinterName()
145
QString QPrinterInfo::printerName() const
147
const Q_D(QPrinterInfo);
152
Returns the human-readable description of the printer.
155
\sa QPrinterInfo::printerName()
157
QString QPrinterInfo::description() const
159
const Q_D(QPrinterInfo);
160
return d->description;
164
Returns the human-readable location of the printer.
168
QString QPrinterInfo::location() const
170
const Q_D(QPrinterInfo);
175
Returns the human-readable make and model of the printer.
179
QString QPrinterInfo::makeAndModel() const
181
const Q_D(QPrinterInfo);
182
return d->makeAndModel;
186
Returns whether this QPrinterInfo object holds a printer definition.
188
An empty QPrinterInfo object could result for example from calling
189
defaultPrinter() when there are no printers on the system.
191
bool QPrinterInfo::isNull() const
193
Q_D(const QPrinterInfo);
194
return d == &QPrinterInfoPrivate::shared_null;
198
Returns whether this printer is the default printer.
200
bool QPrinterInfo::isDefault() const
202
Q_D(const QPrinterInfo);
207
Returns a list of supported paper sizes by the printer.
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.
215
QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
217
Q_D(const QPrinterInfo);
218
if (!isNull() && !d->hasPaperSizes) {
219
d->paperSizes = QPlatformPrinterSupportPlugin::get()->supportedPaperSizes(*this);
220
d->hasPaperSizes = true;
222
return d->paperSizes;
225
QList<QPrinterInfo> QPrinterInfo::availablePrinters()
227
QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
229
return QList<QPrinterInfo>();
230
return ps->availablePrinters();
233
QPrinterInfo QPrinterInfo::defaultPrinter()
235
QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
237
return QPrinterInfo();
238
return ps->defaultPrinter();
242
Returns the printer \a printerName.
244
The return value should be checked using isNull() before being
245
used, in case the named printer does not exist.
250
QPrinterInfo QPrinterInfo::printerInfo(const QString &printerName)
252
QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
254
return QPrinterInfo();
255
return ps->printerInfo(printerName);
260
#endif // QT_NO_PRINTER