Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/printsupport/dialogs/qpagesetupdialog.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||
2 | ** | - | ||||||||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||
5 | ** | - | ||||||||||||
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||||||||
7 | ** | - | ||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||
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 The Qt Company. For licensing terms | - | ||||||||||||
14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||
15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||
16 | ** | - | ||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||
25 | ** | - | ||||||||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||
29 | ** | - | ||||||||||||
30 | ** $QT_END_LICENSE$ | - | ||||||||||||
31 | ** | - | ||||||||||||
32 | ****************************************************************************/ | - | ||||||||||||
33 | - | |||||||||||||
34 | #include "qpagesetupdialog.h" | - | ||||||||||||
35 | #include <private/qpagesetupdialog_p.h> | - | ||||||||||||
36 | - | |||||||||||||
37 | #include <QtPrintSupport/qprinter.h> | - | ||||||||||||
38 | - | |||||||||||||
39 | #ifndef QT_NO_PRINTDIALOG | - | ||||||||||||
40 | - | |||||||||||||
41 | QT_BEGIN_NAMESPACE | - | ||||||||||||
42 | - | |||||||||||||
43 | /*! | - | ||||||||||||
44 | \class QPageSetupDialog | - | ||||||||||||
45 | - | |||||||||||||
46 | \brief The QPageSetupDialog class provides a configuration dialog | - | ||||||||||||
47 | for the page-related options on a printer. | - | ||||||||||||
48 | - | |||||||||||||
49 | \ingroup standard-dialogs | - | ||||||||||||
50 | \ingroup printing | - | ||||||||||||
51 | \inmodule QtPrintSupport | - | ||||||||||||
52 | - | |||||||||||||
53 | On Windows and \macos the page setup dialog is implemented using | - | ||||||||||||
54 | the native page setup dialogs. | - | ||||||||||||
55 | - | |||||||||||||
56 | Note that on Windows and \macos custom paper sizes won't be | - | ||||||||||||
57 | reflected in the native page setup dialogs. Additionally, custom | - | ||||||||||||
58 | page margins set on a QPrinter won't show in the native \macos | - | ||||||||||||
59 | page setup dialog. | - | ||||||||||||
60 | - | |||||||||||||
61 | \sa QPrinter, QPrintDialog | - | ||||||||||||
62 | */ | - | ||||||||||||
63 | - | |||||||||||||
64 | - | |||||||||||||
65 | /*! | - | ||||||||||||
66 | \fn QPageSetupDialog::QPageSetupDialog(QPrinter *printer, QWidget *parent) | - | ||||||||||||
67 | - | |||||||||||||
68 | Constructs a page setup dialog that configures \a printer with \a | - | ||||||||||||
69 | parent as the parent widget. | - | ||||||||||||
70 | */ | - | ||||||||||||
71 | - | |||||||||||||
72 | /*! | - | ||||||||||||
73 | \fn QPageSetupDialog::~QPageSetupDialog() | - | ||||||||||||
74 | - | |||||||||||||
75 | Destroys the page setup dialog. | - | ||||||||||||
76 | */ | - | ||||||||||||
77 | - | |||||||||||||
78 | /*! | - | ||||||||||||
79 | \since 4.5 | - | ||||||||||||
80 | - | |||||||||||||
81 | \fn QPageSetupDialog::QPageSetupDialog(QWidget *parent) | - | ||||||||||||
82 | - | |||||||||||||
83 | Constructs a page setup dialog that configures a default-constructed | - | ||||||||||||
84 | QPrinter with \a parent as the parent widget. | - | ||||||||||||
85 | - | |||||||||||||
86 | \sa printer() | - | ||||||||||||
87 | */ | - | ||||||||||||
88 | - | |||||||||||||
89 | /*! | - | ||||||||||||
90 | \fn QPrinter *QPageSetupDialog::printer() | - | ||||||||||||
91 | - | |||||||||||||
92 | Returns the printer that was passed to the QPageSetupDialog | - | ||||||||||||
93 | constructor. | - | ||||||||||||
94 | */ | - | ||||||||||||
95 | - | |||||||||||||
96 | QPageSetupDialogPrivate::QPageSetupDialogPrivate(QPrinter *prntr) : printer(0), ownsPrinter(false) | - | ||||||||||||
97 | { | - | ||||||||||||
98 | setPrinter(prntr); | - | ||||||||||||
99 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||
100 | - | |||||||||||||
101 | void QPageSetupDialogPrivate::setPrinter(QPrinter *newPrinter) | - | ||||||||||||
102 | { | - | ||||||||||||
103 | if (printer && ownsPrinter)
| 0-1 | ||||||||||||
104 | delete printer; never executed: delete printer; | 0 | ||||||||||||
105 | - | |||||||||||||
106 | if (newPrinter) {
| 0-1 | ||||||||||||
107 | printer = newPrinter; | - | ||||||||||||
108 | ownsPrinter = false; | - | ||||||||||||
109 | } else { executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||
110 | printer = new QPrinter; | - | ||||||||||||
111 | ownsPrinter = true; | - | ||||||||||||
112 | } never executed: end of block | 0 | ||||||||||||
113 | #ifndef Q_DEAD_CODE_FROM_QT4_X11 | - | ||||||||||||
114 | if (printer->outputFormat() != QPrinter::NativeFormat)
| 0-1 | ||||||||||||
115 | qWarning("QPageSetupDialog: Cannot be used on non-native printers"); executed 1 time by 1 test: QMessageLogger(__FILE__, 115, __PRETTY_FUNCTION__).warning("QPageSetupDialog: Cannot be used on non-native printers"); Executed by:
| 1 | ||||||||||||
116 | #endif | - | ||||||||||||
117 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||
118 | - | |||||||||||||
119 | /*! | - | ||||||||||||
120 | \overload | - | ||||||||||||
121 | \since 4.5 | - | ||||||||||||
122 | - | |||||||||||||
123 | Opens the dialog and connects its accepted() signal to the slot specified | - | ||||||||||||
124 | by \a receiver and \a member. | - | ||||||||||||
125 | - | |||||||||||||
126 | The signal will be disconnected from the slot when the dialog is closed. | - | ||||||||||||
127 | */ | - | ||||||||||||
128 | void QPageSetupDialog::open(QObject *receiver, const char *member) | - | ||||||||||||
129 | { | - | ||||||||||||
130 | Q_D(QPageSetupDialog); | - | ||||||||||||
131 | connect(this, SIGNAL(accepted()), receiver, member); | - | ||||||||||||
132 | d->receiverToDisconnectOnClose = receiver; | - | ||||||||||||
133 | d->memberToDisconnectOnClose = member; | - | ||||||||||||
134 | QDialog::open(); | - | ||||||||||||
135 | } never executed: end of block | 0 | ||||||||||||
136 | - | |||||||||||||
137 | #if defined(Q_OS_MAC) || defined(Q_OS_WIN) | - | ||||||||||||
138 | /*! \fn void QPageSetupDialog::setVisible(bool visible) | - | ||||||||||||
139 | \reimp | - | ||||||||||||
140 | */ | - | ||||||||||||
141 | #endif | - | ||||||||||||
142 | - | |||||||||||||
143 | QPageSetupDialog::~QPageSetupDialog() | - | ||||||||||||
144 | { | - | ||||||||||||
145 | Q_D(QPageSetupDialog); | - | ||||||||||||
146 | if (d->ownsPrinter)
| 0-1 | ||||||||||||
147 | delete d->printer; never executed: delete d->printer; | 0 | ||||||||||||
148 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||
149 | - | |||||||||||||
150 | QPrinter *QPageSetupDialog::printer() | - | ||||||||||||
151 | { | - | ||||||||||||
152 | Q_D(QPageSetupDialog); | - | ||||||||||||
153 | return d->printer; never executed: return d->printer; | 0 | ||||||||||||
154 | } | - | ||||||||||||
155 | - | |||||||||||||
156 | /*! | - | ||||||||||||
157 | \fn int QPageSetupDialog::exec() | - | ||||||||||||
158 | - | |||||||||||||
159 | This virtual function is called to pop up the dialog. It must be | - | ||||||||||||
160 | reimplemented in subclasses. | - | ||||||||||||
161 | */ | - | ||||||||||||
162 | - | |||||||||||||
163 | /*! | - | ||||||||||||
164 | \reimp | - | ||||||||||||
165 | */ | - | ||||||||||||
166 | void QPageSetupDialog::done(int result) | - | ||||||||||||
167 | { | - | ||||||||||||
168 | Q_D(QPageSetupDialog); | - | ||||||||||||
169 | QDialog::done(result); | - | ||||||||||||
170 | if (d->receiverToDisconnectOnClose) {
| 0 | ||||||||||||
171 | disconnect(this, SIGNAL(accepted()), | - | ||||||||||||
172 | d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); | - | ||||||||||||
173 | d->receiverToDisconnectOnClose = 0; | - | ||||||||||||
174 | } never executed: end of block | 0 | ||||||||||||
175 | d->memberToDisconnectOnClose.clear(); | - | ||||||||||||
176 | - | |||||||||||||
177 | } never executed: end of block | 0 | ||||||||||||
178 | - | |||||||||||||
179 | QT_END_NAMESPACE | - | ||||||||||||
180 | - | |||||||||||||
181 | #endif | - | ||||||||||||
Source code | Switch to Preprocessed file |