| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 14 | ** a written agreement between you and Nokia.
|
|---|
| 15 | **
|
|---|
| 16 | ** GNU Lesser General Public License Usage
|
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 20 | ** packaging of this file. Please review the following information to
|
|---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 23 | **
|
|---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
|---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
|---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 37 | ** Nokia at [email protected].
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | #include "qabstractprintdialog_p.h"
|
|---|
| 43 | #include "qcoreapplication.h"
|
|---|
| 44 | #include "qprintdialog.h"
|
|---|
| 45 | #include "qprinter.h"
|
|---|
| 46 | #include "private/qprinter_p.h"
|
|---|
| 47 |
|
|---|
| 48 | #ifndef QT_NO_PRINTDIALOG
|
|---|
| 49 |
|
|---|
| 50 | QT_BEGIN_NAMESPACE
|
|---|
| 51 |
|
|---|
| 52 | // hack
|
|---|
| 53 | class QPrintDialogPrivate : public QAbstractPrintDialogPrivate
|
|---|
| 54 | {
|
|---|
| 55 | };
|
|---|
| 56 |
|
|---|
| 57 | /*!
|
|---|
| 58 | \class QAbstractPrintDialog
|
|---|
| 59 | \brief The QAbstractPrintDialog class provides a base implementation for
|
|---|
| 60 | print dialogs used to configure printers.
|
|---|
| 61 |
|
|---|
| 62 | \ingroup printing
|
|---|
| 63 |
|
|---|
| 64 | This class implements getter and setter functions that are used to
|
|---|
| 65 | customize settings shown in print dialogs, but it is not used directly.
|
|---|
| 66 | Use QPrintDialog to display a print dialog in your application.
|
|---|
| 67 |
|
|---|
| 68 | In Symbian, there is no support for printing. Hence, this dialog should not
|
|---|
| 69 | be used in Symbian.
|
|---|
| 70 |
|
|---|
| 71 | \sa QPrintDialog, QPrinter, {Printing with Qt}
|
|---|
| 72 | */
|
|---|
| 73 |
|
|---|
| 74 | /*!
|
|---|
| 75 | \enum QAbstractPrintDialog::PrintRange
|
|---|
| 76 |
|
|---|
| 77 | Used to specify the print range selection option.
|
|---|
| 78 |
|
|---|
| 79 | \value AllPages All pages should be printed.
|
|---|
| 80 | \value Selection Only the selection should be printed.
|
|---|
| 81 | \value PageRange The specified page range should be printed.
|
|---|
| 82 | \value CurrentPage Only the currently visible page should be printed.
|
|---|
| 83 |
|
|---|
| 84 | \sa QPrinter::PrintRange
|
|---|
| 85 | */
|
|---|
| 86 |
|
|---|
| 87 | /*!
|
|---|
| 88 | \enum QAbstractPrintDialog::PrintDialogOption
|
|---|
| 89 |
|
|---|
| 90 | Used to specify which parts of the print dialog should be visible.
|
|---|
| 91 |
|
|---|
| 92 | \value None None of the options are enabled.
|
|---|
| 93 | \value PrintToFile The print to file option is enabled.
|
|---|
| 94 | \value PrintSelection The print selection option is enabled.
|
|---|
| 95 | \value PrintPageRange The page range selection option is enabled.
|
|---|
| 96 | \value PrintShowPageSize Show the page size + margins page only if this is enabled.
|
|---|
| 97 | \value PrintCollateCopies The collate copies option is enabled
|
|---|
| 98 | \value PrintCurrentPage The print current page option is enabled
|
|---|
| 99 |
|
|---|
| 100 | This value is obsolete and does nothing since Qt 4.5:
|
|---|
| 101 |
|
|---|
| 102 | \value DontUseSheet In previous versions of Qt, exec() the print dialog
|
|---|
| 103 | would create a sheet by default the dialog was given a parent.
|
|---|
| 104 | This is no longer supported in Qt 4.5. If you want to use sheets, use
|
|---|
| 105 | QPrintDialog::open() instead.
|
|---|
| 106 | */
|
|---|
| 107 |
|
|---|
| 108 | /*!
|
|---|
| 109 | Constructs an abstract print dialog for \a printer with \a parent
|
|---|
| 110 | as parent widget.
|
|---|
| 111 | */
|
|---|
| 112 | QAbstractPrintDialog::QAbstractPrintDialog(QPrinter *printer, QWidget *parent)
|
|---|
| 113 | : QDialog(*(new QAbstractPrintDialogPrivate), parent)
|
|---|
| 114 | {
|
|---|
| 115 | Q_D(QAbstractPrintDialog);
|
|---|
| 116 | setWindowTitle(QCoreApplication::translate("QPrintDialog", "Print"));
|
|---|
| 117 | d->setPrinter(printer);
|
|---|
| 118 | }
|
|---|
| 119 |
|
|---|
| 120 | /*!
|
|---|
| 121 | \internal
|
|---|
| 122 | */
|
|---|
| 123 | QAbstractPrintDialog::QAbstractPrintDialog(QAbstractPrintDialogPrivate &ptr,
|
|---|
| 124 | QPrinter *printer,
|
|---|
| 125 | QWidget *parent)
|
|---|
| 126 | : QDialog(ptr, parent)
|
|---|
| 127 | {
|
|---|
| 128 | Q_D(QAbstractPrintDialog);
|
|---|
| 129 | setWindowTitle(QCoreApplication::translate("QPrintDialog", "Print"));
|
|---|
| 130 | d->setPrinter(printer);
|
|---|
| 131 | }
|
|---|
| 132 |
|
|---|
| 133 | /*!
|
|---|
| 134 | \internal
|
|---|
| 135 | */
|
|---|
| 136 | QAbstractPrintDialog::~QAbstractPrintDialog()
|
|---|
| 137 | {
|
|---|
| 138 | Q_D(QAbstractPrintDialog);
|
|---|
| 139 | if (d->ownsPrinter)
|
|---|
| 140 | delete d->printer;
|
|---|
| 141 | }
|
|---|
| 142 |
|
|---|
| 143 | /*!
|
|---|
| 144 | Sets the given \a option to be enabled if \a on is true;
|
|---|
| 145 | otherwise, clears the given \a option.
|
|---|
| 146 |
|
|---|
| 147 | \sa options, testOption()
|
|---|
| 148 | */
|
|---|
| 149 | void QPrintDialog::setOption(PrintDialogOption option, bool on)
|
|---|
| 150 | {
|
|---|
| 151 | Q_D(QPrintDialog);
|
|---|
| 152 | if (!(d->pd->options & option) != !on)
|
|---|
|
|---|