1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the documentation of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:FDL$
10 ** GNU Free Documentation License
11 ** Alternatively, this file may be used under the terms of the GNU Free
12 ** Documentation License version 1.3 as published by the Free Software
13 ** Foundation and appearing in the file included in the packaging of
17 ** Alternatively, this file may be used in accordance with the terms
18 ** and conditions contained in a signed written agreement between you
26 ****************************************************************************/
28 #include "qprinterinfo.h"
29 #include "qprinterinfo_p.h"
35 QPrinterInfoPrivate QPrinterInfoPrivate::shared_null;
41 \brief The QPrinterInfo class gives access to information about
46 Use the static functions to generate a list of QPrinterInfo
47 objects. Each QPrinterInfo object in the list represents a single
48 printer and can be queried for name, supported paper sizes, and
49 whether or not it is the default printer.
55 \fn QList<QPrinterInfo> QPrinterInfo::availablePrinters()
57 Returns a list of available printers on the system.
61 \fn QPrinterInfo QPrinterInfo::defaultPrinter()
63 Returns the default printer on the system.
65 The return value should be checked using isNull() before being
66 used, in case there is no default printer.
72 Constructs an empty QPrinterInfo object.
76 QPrinterInfo::QPrinterInfo()
77 : d_ptr(&QPrinterInfoPrivate::shared_null)
82 Constructs a copy of \a other.
84 QPrinterInfo::QPrinterInfo(const QPrinterInfo &other)
85 : d_ptr(new QPrinterInfoPrivate(*other.d_ptr))
90 Constructs a QPrinterInfo object from \a printer.
92 QPrinterInfo::QPrinterInfo(const QPrinter &printer)
93 : d_ptr(&QPrinterInfoPrivate::shared_null)
95 foreach (const QPrinterInfo &printerInfo, availablePrinters()) {
96 if (printerInfo.printerName() == printer.printerName()) {
97 d_ptr.reset(new QPrinterInfoPrivate(*printerInfo.d_ptr));
106 QPrinterInfo::QPrinterInfo(const QString &name)
107 : d_ptr(new QPrinterInfoPrivate(name))
112 Destroys the QPrinterInfo object. References to the values in the
113 object become invalid.
115 QPrinterInfo::~QPrinterInfo()
120 Sets the QPrinterInfo object to be equal to \a other.
122 QPrinterInfo &QPrinterInfo::operator=(const QPrinterInfo &other)
125 d_ptr.reset(new QPrinterInfoPrivate(*other.d_ptr));
130 Returns the name of the printer.
132 \sa QPrinter::setPrinterName()
134 QString QPrinterInfo::printerName() const
136 const Q_D(QPrinterInfo);
141 Returns whether this QPrinterInfo object holds a printer definition.
143 An empty QPrinterInfo object could result for example from calling
144 defaultPrinter() when there are no printers on the system.
146 bool QPrinterInfo::isNull() const
148 const Q_D(QPrinterInfo);
149 return d == &QPrinterInfoPrivate::shared_null;
153 Returns whether this printer is the default printer.
155 bool QPrinterInfo::isDefault() const
157 const Q_D(QPrinterInfo);
162 \fn QList< QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
165 Returns a list of supported paper sizes by the printer.
167 Not all printer drivers support this query, so the list may be empty.
168 On Mac OS X 10.3, this function always returns an empty list.
173 #endif // QT_NO_PRINTER