~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/gui/dialogs/qabstractprintdialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the dialog module of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#include "qabstractprintdialog.h"
 
30
#include "qabstractprintdialog_p.h"
 
31
 
 
32
/*!
 
33
    \class QAbstractPrintDialog
 
34
    \brief The QAbstractPrintDialog class provides a base implementation for
 
35
    print dialogs used to configure printers.
 
36
*/
 
37
 
 
38
/*!
 
39
    \enum QAbstractPrintDialog::PrintRange
 
40
 
 
41
    Used to specify the print range selection option.
 
42
 
 
43
    \value AllPages All pages should be printed.
 
44
    \value Selection Only the selection should be printed.
 
45
    \value PageRange The specified page range should be printed.
 
46
*/
 
47
 
 
48
/*!
 
49
    \enum QAbstractPrintDialog::PrintDialogOption
 
50
 
 
51
    Used to specify which parts of the print dialog should be enabled.
 
52
 
 
53
    \value None None of the options are enabled.
 
54
    \value PrintToFile The print to file option is enabled.
 
55
    \value PrintSelection The print selection option is enalbed.
 
56
    \value PrintPageRange The page range selection option is enabled.
 
57
    \value PrintCollateCopies
 
58
*/
 
59
 
 
60
/*!
 
61
    Constructs an abstract print dialog for \a printer with \a parent
 
62
    as parent widget
 
63
*/
 
64
QAbstractPrintDialog::QAbstractPrintDialog(QPrinter *printer, QWidget *parent)
 
65
    : QDialog(*(new QAbstractPrintDialogPrivate), parent)
 
66
{
 
67
    Q_D(QAbstractPrintDialog);
 
68
    d->printer = printer;
 
69
}
 
70
 
 
71
/*!
 
72
     \internal
 
73
*/
 
74
QAbstractPrintDialog::QAbstractPrintDialog(QAbstractPrintDialogPrivate &ptr,
 
75
                                           QPrinter *printer,
 
76
                                           QWidget *parent)
 
77
    : QDialog(ptr, parent)
 
78
{
 
79
    Q_D(QAbstractPrintDialog);
 
80
    d->printer = printer;
 
81
}
 
82
 
 
83
 
 
84
/*!
 
85
    Sets the set of options that should be enabled in the print dialog
 
86
    to \a options.
 
87
*/
 
88
void QAbstractPrintDialog::setEnabledOptions(PrintDialogOptions options)
 
89
{
 
90
    Q_D(QAbstractPrintDialog);
 
91
    d->options = options;
 
92
}
 
93
 
 
94
/*!
 
95
    Adds the option \a option to the set of enabled options in this dialog.
 
96
*/
 
97
void QAbstractPrintDialog::addEnabledOption(PrintDialogOption option)
 
98
{
 
99
    Q_D(QAbstractPrintDialog);
 
100
    d->options |= option;
 
101
}
 
102
 
 
103
/*!
 
104
    Returns the set of enabled options in this dialog.
 
105
*/
 
106
QAbstractPrintDialog::PrintDialogOptions QAbstractPrintDialog::enabledOptions() const
 
107
{
 
108
    Q_D(const QAbstractPrintDialog);
 
109
    return d->options;
 
110
}
 
111
 
 
112
/*!
 
113
    Returns true if the option \a option is enabled; otherwise returns false
 
114
*/
 
115
bool QAbstractPrintDialog::isOptionEnabled(PrintDialogOption option) const
 
116
{
 
117
    Q_D(const QAbstractPrintDialog);
 
118
    return d->options & option;
 
119
}
 
120
 
 
121
/*!
 
122
    Sets the print range option in to be \a range.
 
123
 */
 
124
void QAbstractPrintDialog::setPrintRange(PrintRange range)
 
125
{
 
126
    Q_D(QAbstractPrintDialog);
 
127
    d->printRange = range;
 
128
}
 
129
 
 
130
/*!
 
131
    Returns the print range.
 
132
*/
 
133
QAbstractPrintDialog::PrintRange QAbstractPrintDialog::printRange() const
 
134
{
 
135
    Q_D(const QAbstractPrintDialog);
 
136
    return d->printRange;
 
137
}
 
138
 
 
139
/*!
 
140
    Sets the page range in this dialog to be from \a min to \a max. This also
 
141
    enables the PrintPageRange option.
 
142
*/
 
143
void QAbstractPrintDialog::setMinMax(int min, int max)
 
144
{
 
145
    Q_D(QAbstractPrintDialog);
 
146
    Q_ASSERT_X(min <= max, "QAbstractPrintDialog::setMinMax",
 
147
               "'min' must be less than or equal to 'max'");
 
148
    d->minPage = min;
 
149
    d->maxPage = max;
 
150
    d->options |= PrintPageRange;
 
151
}
 
152
 
 
153
/*!
 
154
    Returns the minimum page in the page range.
 
155
*/
 
156
int QAbstractPrintDialog::minPage() const
 
157
{
 
158
    Q_D(const QAbstractPrintDialog);
 
159
    return d->minPage;
 
160
}
 
161
 
 
162
/*!
 
163
    Returns the maximum page in the page range.
 
164
*/
 
165
int QAbstractPrintDialog::maxPage() const
 
166
{
 
167
    Q_D(const QAbstractPrintDialog);
 
168
    return d->maxPage;
 
169
}
 
170
 
 
171
/*!
 
172
    Sets the range in the print dialog to be from \a from to \a to.
 
173
*/
 
174
void QAbstractPrintDialog::setFromTo(int from, int to)
 
175
{
 
176
    Q_D(QAbstractPrintDialog);
 
177
    Q_ASSERT_X(from <= to, "QAbstractPrintDialog::setFromTo",
 
178
               "'from' must be less than or equal to 'to'");
 
179
    d->fromPage = from;
 
180
    d->toPage = to;
 
181
 
 
182
    if (d->minPage == 0 && d->maxPage == 0)
 
183
        setMinMax(1, to);
 
184
}
 
185
 
 
186
/*!
 
187
    Returns the first page to be printed
 
188
*/
 
189
int QAbstractPrintDialog::fromPage() const
 
190
{
 
191
    Q_D(const QAbstractPrintDialog);
 
192
    return d->fromPage;
 
193
}
 
194
 
 
195
/*!
 
196
    Returns the last page to be printed.
 
197
*/
 
198
int QAbstractPrintDialog::toPage() const
 
199
{
 
200
    Q_D(const QAbstractPrintDialog);
 
201
    return d->toPage;
 
202
}
 
203
 
 
204
/*!
 
205
    Returns the printer that this printer dialog operates
 
206
    on.
 
207
*/
 
208
QPrinter *QAbstractPrintDialog::printer() const
 
209
{
 
210
    Q_D(const QAbstractPrintDialog);
 
211
    return d->printer;
 
212
}
 
213
 
 
214
/*!
 
215
    \fn int QAbstractPrintDialog::exec()
 
216
 
 
217
    This virtual function is called to pop up the dialog. It must be
 
218
    reimplemented in subclasses.
 
219
*/
 
220
 
 
221
/*!
 
222
    \class QPrintDialog qprintdialog.h
 
223
 
 
224
    \brief The QPrintDialog class provides a dialog for specifying
 
225
    the printer's configuration.
 
226
 
 
227
    \ingroup dialogs
 
228
 
 
229
    It encompasses both the sort of details needed for doing a simple
 
230
    print-out and some print configuration setup.
 
231
 
 
232
    Typical use of the QPrintDialog is to construct it on a QPrinter
 
233
    object and call exec() to execute it.
 
234
 
 
235
    \code
 
236
    QPrintDialog printDialog(printer, parent);
 
237
    if (printDialog.exec() == QDialog::Accept) {
 
238
        // print ...
 
239
    }
 
240
    \endcode
 
241
 
 
242
    The printer dialog in Motif style:
 
243
 
 
244
    \img qprintdlg-m.png
 
245
*/
 
246
 
 
247
/*!
 
248
    \fn QPrintDialog::QPrintDialog(QPrinter *printer, QWidget *parent)
 
249
 
 
250
    Constructs a new modal printer dialog for the given \a printer
 
251
    with the given \a parent.
 
252
*/
 
253
 
 
254
/*!
 
255
    \fn int QPrintDialog::exec()
 
256
 
 
257
    Launches the print dialog.
 
258
 
 
259
    \sa QDialog::DialogCode, accept(), reject()
 
260
*/