Replace 'i < len-1 && func(i+1)' by 'i+1 < len && func(i+1)'
[profile/ivi/qtbase.git] / src / gui / painting / qprinterinfo.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the documentation of the Qt Toolkit.
8 **
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
14 ** this file.
15 **
16 ** Other Usage
17 ** Alternatively, this file may be used in accordance with the terms
18 ** and conditions contained in a signed written agreement between you
19 ** and Nokia.
20 **
21 **
22 **
23 **
24 ** $QT_END_LICENSE$
25 **
26 ****************************************************************************/
27
28 #include "qprinterinfo.h"
29 #include "qprinterinfo_p.h"
30
31 #ifndef QT_NO_PRINTER
32
33 QT_BEGIN_NAMESPACE
34
35 QPrinterInfoPrivate QPrinterInfoPrivate::shared_null;
36
37
38 /*!
39     \class QPrinterInfo
40
41     \brief The QPrinterInfo class gives access to information about
42     existing printers.
43     
44     \ingroup printing
45
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.
50
51     \since 4.4
52 */
53
54 /*!
55     \fn QList<QPrinterInfo> QPrinterInfo::availablePrinters()
56
57     Returns a list of available printers on the system.
58 */
59
60 /*!
61     \fn QPrinterInfo QPrinterInfo::defaultPrinter()
62
63     Returns the default printer on the system.
64
65     The return value should be checked using isNull() before being
66     used, in case there is no default printer.
67
68     \sa isNull()
69 */
70
71 /*!
72     Constructs an empty QPrinterInfo object.
73
74     \sa isNull()
75 */
76 QPrinterInfo::QPrinterInfo()
77     : d_ptr(&QPrinterInfoPrivate::shared_null)
78 {
79 }
80
81 /*!
82     Constructs a copy of \a other.
83 */
84 QPrinterInfo::QPrinterInfo(const QPrinterInfo &other)
85     : d_ptr(new QPrinterInfoPrivate(*other.d_ptr))
86 {
87 }
88
89 /*!
90     Constructs a QPrinterInfo object from \a printer.
91 */
92 QPrinterInfo::QPrinterInfo(const QPrinter &printer)
93     : d_ptr(&QPrinterInfoPrivate::shared_null)
94 {
95     foreach (const QPrinterInfo &printerInfo, availablePrinters()) {
96         if (printerInfo.printerName() == printer.printerName()) {
97             d_ptr.reset(new QPrinterInfoPrivate(*printerInfo.d_ptr));
98             break;
99         }
100     }
101 }
102
103 /*!
104     \internal
105 */
106 QPrinterInfo::QPrinterInfo(const QString &name)
107     : d_ptr(new QPrinterInfoPrivate(name))
108 {
109 }
110
111 /*!
112     Destroys the QPrinterInfo object. References to the values in the
113     object become invalid.
114 */
115 QPrinterInfo::~QPrinterInfo()
116 {
117 }
118
119 /*!
120     Sets the QPrinterInfo object to be equal to \a other.
121 */
122 QPrinterInfo &QPrinterInfo::operator=(const QPrinterInfo &other)
123 {
124     Q_ASSERT(d_ptr);
125     d_ptr.reset(new QPrinterInfoPrivate(*other.d_ptr));
126     return *this;
127 }
128
129 /*!
130     Returns the name of the printer.
131
132     \sa QPrinter::setPrinterName()
133 */
134 QString QPrinterInfo::printerName() const
135 {
136     const Q_D(QPrinterInfo);
137     return d->name;
138 }
139
140 /*!
141     Returns whether this QPrinterInfo object holds a printer definition.
142
143     An empty QPrinterInfo object could result for example from calling
144     defaultPrinter() when there are no printers on the system.
145 */
146 bool QPrinterInfo::isNull() const
147 {
148     const Q_D(QPrinterInfo);
149     return d == &QPrinterInfoPrivate::shared_null;
150 }
151
152 /*!
153     Returns whether this printer is the default printer.
154 */
155 bool QPrinterInfo::isDefault() const
156 {
157     const Q_D(QPrinterInfo);
158     return d->isDefault;
159 }
160
161 /*!
162     \fn QList< QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
163     \since 4.4
164
165     Returns a list of supported paper sizes by the printer.
166
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.
169 */
170
171 QT_END_NAMESPACE
172
173 #endif // QT_NO_PRINTER