Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
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 Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/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 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qplatformdefs.h" | - |
43 | | - |
44 | #ifndef QT_NO_PRINTDIALOG | - |
45 | | - |
46 | #include "private/qabstractprintdialog_p.h" | - |
47 | #include <QtWidgets/qmessagebox.h> | - |
48 | #include "qprintdialog.h" | - |
49 | #include "qfiledialog.h" | - |
50 | #include <QtCore/qdir.h> | - |
51 | #include <QtGui/qevent.h> | - |
52 | #include <QtWidgets/qfilesystemmodel.h> | - |
53 | #include <QtWidgets/qstyleditemdelegate.h> | - |
54 | #include <QtPrintSupport/qprinter.h> | - |
55 | #include <QtPrintSupport/qprinterinfo.h> | - |
56 | #include <private/qprintengine_pdf_p.h> | - |
57 | | - |
58 | #include <QtWidgets/qdialogbuttonbox.h> | - |
59 | | - |
60 | #include "private/qfscompleter_p.h" | - |
61 | #include "ui_qprintpropertieswidget.h" | - |
62 | #include "ui_qprintsettingsoutput.h" | - |
63 | #include "ui_qprintwidget.h" | - |
64 | | - |
65 | #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) | - |
66 | # include <private/qcups_p.h> | - |
67 | #else | - |
68 | # include <QtCore/qlibrary.h> | - |
69 | # include <private/qprintengine_pdf_p.h> | - |
70 | #endif | - |
71 | | - |
72 | /* | - |
73 | | - |
74 | Print dialog class declarations | - |
75 | | - |
76 | QPrintDialog: The main Print Dialog, nothing really held here. | - |
77 | | - |
78 | QUnixPrintWidget: | - |
79 | QUnixPrintWidgetPrivate: The real Unix Print Dialog implementation. | - |
80 | | - |
81 | Directly includes the upper half of the Print Dialog | - |
82 | containing the Printer Selection widgets and | - |
83 | Properties button. | - |
84 | | - |
85 | Embeds the Properties pop-up dialog from | - |
86 | QPrintPropertiesDialog | - |
87 | | - |
88 | Embeds the lower half from separate widget class | - |
89 | QPrintDialogPrivate | - |
90 | | - |
91 | Layout in qprintwidget.ui | - |
92 | | - |
93 | QPrintDialogPrivate: The lower half of the Print Dialog containing the | - |
94 | Copies and Options tabs that expands when the | - |
95 | Options button is selected. | - |
96 | | - |
97 | Layout in qprintsettingsoutput.ui | - |
98 | | - |
99 | QPrintPropertiesDialog: Dialog displayed when clicking on Properties button to | - |
100 | allow editing of Page and Advanced tabs. | - |
101 | | - |
102 | Layout in qprintpropertieswidget.ui | - |
103 | */ | - |
104 | | - |
105 | QT_BEGIN_NAMESPACE | - |
106 | | - |
107 | class QOptionTreeItem; | - |
108 | class QPPDOptionsModel; | - |
109 | | - |
110 | class QPrintPropertiesDialog : public QDialog | - |
111 | { | - |
112 | Q_OBJECT | - |
113 | public: | - |
114 | QPrintPropertiesDialog(QAbstractPrintDialog *parent = 0); | - |
115 | ~QPrintPropertiesDialog(); | - |
116 | | - |
117 | void selectPrinter(); | - |
118 | void selectPdfPsPrinter(const QPrinter *p); | - |
119 | | - |
120 | /// copy printer properties to the widget | - |
121 | void applyPrinterProperties(QPrinter *p); | - |
122 | void setupPrinter() const; | - |
123 | | - |
124 | protected: | - |
125 | void showEvent(QShowEvent* event); | - |
126 | | - |
127 | private: | - |
128 | Ui::QPrintPropertiesWidget widget; | - |
129 | QDialogButtonBox *m_buttons; | - |
130 | }; | - |
131 | | - |
132 | class QUnixPrintWidgetPrivate; | - |
133 | | - |
134 | class QUnixPrintWidget : public QWidget | - |
135 | { | - |
136 | Q_OBJECT | - |
137 | | - |
138 | public: | - |
139 | explicit QUnixPrintWidget(QPrinter *printer, QWidget *parent = 0); | - |
140 | ~QUnixPrintWidget(); | - |
141 | void updatePrinter(); | - |
142 | | - |
143 | private: | - |
144 | friend class QPrintDialogPrivate; | - |
145 | friend class QUnixPrintWidgetPrivate; | - |
146 | QUnixPrintWidgetPrivate *d; | - |
147 | Q_PRIVATE_SLOT(d, void _q_printerChanged(int)) | - |
148 | Q_PRIVATE_SLOT(d, void _q_btnBrowseClicked()) | - |
149 | Q_PRIVATE_SLOT(d, void _q_btnPropertiesClicked()) | - |
150 | }; | - |
151 | | - |
152 | class QUnixPrintWidgetPrivate | - |
153 | { | - |
154 | public: | - |
155 | QUnixPrintWidgetPrivate(QUnixPrintWidget *q, QPrinter *prn); | - |
156 | ~QUnixPrintWidgetPrivate(); | - |
157 | | - |
158 | /// copy printer properties to the widget | - |
159 | void applyPrinterProperties(); | - |
160 | bool checkFields(); | - |
161 | void setupPrinter(); | - |
162 | void setOptionsPane(QPrintDialogPrivate *pane); | - |
163 | void setupPrinterProperties(); | - |
164 | // slots | - |
165 | void _q_printerChanged(int index); | - |
166 | void _q_btnPropertiesClicked(); | - |
167 | void _q_btnBrowseClicked(); | - |
168 | | - |
169 | QUnixPrintWidget * const parent; | - |
170 | QPrintPropertiesDialog *propertiesDialog; | - |
171 | Ui::QPrintWidget widget; | - |
172 | QAbstractPrintDialog * q; | - |
173 | QPrinter *printer; | - |
174 | void updateWidget(); | - |
175 | | - |
176 | private: | - |
177 | QPrintDialogPrivate *optionsPane; | - |
178 | bool filePrintersAdded; | - |
179 | bool propertiesDialogShown; | - |
180 | }; | - |
181 | | - |
182 | class QPrintDialogPrivate : public QAbstractPrintDialogPrivate | - |
183 | { | - |
184 | Q_DECLARE_PUBLIC(QPrintDialog) | - |
185 | Q_DECLARE_TR_FUNCTIONS(QPrintDialog) | - |
186 | public: | - |
187 | QPrintDialogPrivate(); | - |
188 | ~QPrintDialogPrivate(); | - |
189 | | - |
190 | void init(); | - |
191 | /// copy printer properties to the widget | - |
192 | void applyPrinterProperties(); | - |
193 | | - |
194 | void selectPrinter(); | - |
195 | | - |
196 | void _q_chbPrintLastFirstToggled(bool); | - |
197 | #ifndef QT_NO_MESSAGEBOX | - |
198 | void _q_checkFields(); | - |
199 | #endif | - |
200 | void _q_collapseOrExpandDialog(); | - |
201 | | - |
202 | void setupPrinter(); | - |
203 | void updateWidgets(); | - |
204 | | - |
205 | virtual void setTabs(const QList<QWidget*> &tabs); | - |
206 | | - |
207 | Ui::QPrintSettingsOutput options; | - |
208 | QUnixPrintWidget *top; | - |
209 | QWidget *bottom; | - |
210 | QDialogButtonBox *buttons; | - |
211 | QPushButton *collapseButton; | - |
212 | }; | - |
213 | | - |
214 | | - |
215 | //////////////////////////////////////////////////////////////////////////////// | - |
216 | //////////////////////////////////////////////////////////////////////////////// | - |
217 | | - |
218 | /* | - |
219 | | - |
220 | QPrintPropertiesDialog | - |
221 | | - |
222 | Dialog displayed when clicking on Properties button to allow editing of Page | - |
223 | and Advanced tabs. | - |
224 | | - |
225 | */ | - |
226 | | - |
227 | QPrintPropertiesDialog::QPrintPropertiesDialog(QAbstractPrintDialog *parent) | - |
228 | : QDialog(parent) | - |
229 | { | - |
230 | QVBoxLayout *lay = new QVBoxLayout(this); never executed (the execution status of this line is deduced): QVBoxLayout *lay = new QVBoxLayout(this); | - |
231 | this->setLayout(lay); never executed (the execution status of this line is deduced): this->setLayout(lay); | - |
232 | QWidget *content = new QWidget(this); never executed (the execution status of this line is deduced): QWidget *content = new QWidget(this); | - |
233 | widget.setupUi(content); never executed (the execution status of this line is deduced): widget.setupUi(content); | - |
234 | m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); never executed (the execution status of this line is deduced): m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); | - |
235 | lay->addWidget(content); never executed (the execution status of this line is deduced): lay->addWidget(content); | - |
236 | lay->addWidget(m_buttons); never executed (the execution status of this line is deduced): lay->addWidget(m_buttons); | - |
237 | | - |
238 | connect(m_buttons->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept())); never executed (the execution status of this line is deduced): connect(m_buttons->button(QDialogButtonBox::Ok), "2""clicked()", this, "1""accept()"); | - |
239 | connect(m_buttons->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject())); never executed (the execution status of this line is deduced): connect(m_buttons->button(QDialogButtonBox::Cancel), "2""clicked()", this, "1""reject()"); | - |
240 | } | 0 |
241 | | - |
242 | QPrintPropertiesDialog::~QPrintPropertiesDialog() | - |
243 | { | - |
244 | } | - |
245 | | - |
246 | void QPrintPropertiesDialog::applyPrinterProperties(QPrinter *p) | - |
247 | { | - |
248 | widget.pageSetup->setPrinter(p); never executed (the execution status of this line is deduced): widget.pageSetup->setPrinter(p); | - |
249 | } | 0 |
250 | | - |
251 | void QPrintPropertiesDialog::setupPrinter() const | - |
252 | { | - |
253 | widget.pageSetup->setupPrinter(); never executed (the execution status of this line is deduced): widget.pageSetup->setupPrinter(); | - |
254 | } | 0 |
255 | | - |
256 | void QPrintPropertiesDialog::selectPrinter() | - |
257 | { | - |
258 | widget.pageSetup->selectPrinter(); never executed (the execution status of this line is deduced): widget.pageSetup->selectPrinter(); | - |
259 | } | 0 |
260 | | - |
261 | void QPrintPropertiesDialog::selectPdfPsPrinter(const QPrinter *p) | - |
262 | { | - |
263 | widget.pageSetup->selectPdfPsPrinter(p); never executed (the execution status of this line is deduced): widget.pageSetup->selectPdfPsPrinter(p); | - |
264 | } | 0 |
265 | | - |
266 | void QPrintPropertiesDialog::showEvent(QShowEvent* event) | - |
267 | { | - |
268 | event->accept(); never executed (the execution status of this line is deduced): event->accept(); | - |
269 | } | 0 |
270 | | - |
271 | //////////////////////////////////////////////////////////////////////////////// | - |
272 | //////////////////////////////////////////////////////////////////////////////// | - |
273 | | - |
274 | /* | - |
275 | | - |
276 | QPrintDialogPrivate | - |
277 | | - |
278 | The lower half of the Print Dialog containing the Copies and Options | - |
279 | tabs that expands when the Options button is selected. | - |
280 | | - |
281 | */ | - |
282 | QPrintDialogPrivate::QPrintDialogPrivate() | - |
283 | : top(0), bottom(0), buttons(0), collapseButton(0) | - |
284 | { | - |
285 | } executed: } Execution Count:3 | 3 |
286 | | - |
287 | QPrintDialogPrivate::~QPrintDialogPrivate() | - |
288 | { | - |
289 | } | - |
290 | | - |
291 | void QPrintDialogPrivate::init() | - |
292 | { | - |
293 | Q_Q(QPrintDialog); executed (the execution status of this line is deduced): QPrintDialog * const q = q_func(); | - |
294 | | - |
295 | top = new QUnixPrintWidget(q->printer(), q); executed (the execution status of this line is deduced): top = new QUnixPrintWidget(q->printer(), q); | - |
296 | bottom = new QWidget(q); executed (the execution status of this line is deduced): bottom = new QWidget(q); | - |
297 | options.setupUi(bottom); executed (the execution status of this line is deduced): options.setupUi(bottom); | - |
298 | options.color->setIconSize(QSize(32, 32)); executed (the execution status of this line is deduced): options.color->setIconSize(QSize(32, 32)); | - |
299 | options.color->setIcon(QIcon(QLatin1String(":/qt-project.org/dialogs/qprintdialog/images/status-color.png"))); executed (the execution status of this line is deduced): options.color->setIcon(QIcon(QLatin1String(":/qt-project.org/dialogs/qprintdialog/images/status-color.png"))); | - |
300 | options.grayscale->setIconSize(QSize(32, 32)); executed (the execution status of this line is deduced): options.grayscale->setIconSize(QSize(32, 32)); | - |
301 | options.grayscale->setIcon(QIcon(QLatin1String(":/qt-project.org/dialogs/qprintdialog/images/status-gray-scale.png"))); executed (the execution status of this line is deduced): options.grayscale->setIcon(QIcon(QLatin1String(":/qt-project.org/dialogs/qprintdialog/images/status-gray-scale.png"))); | - |
302 | top->d->setOptionsPane(this); executed (the execution status of this line is deduced): top->d->setOptionsPane(this); | - |
303 | | - |
304 | buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, q); executed (the execution status of this line is deduced): buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, q); | - |
305 | collapseButton = new QPushButton(QPrintDialog::tr("&Options >>"), buttons); executed (the execution status of this line is deduced): collapseButton = new QPushButton(QPrintDialog::tr("&Options >>"), buttons); | - |
306 | buttons->addButton(collapseButton, QDialogButtonBox::ResetRole); executed (the execution status of this line is deduced): buttons->addButton(collapseButton, QDialogButtonBox::ResetRole); | - |
307 | bottom->setVisible(false); executed (the execution status of this line is deduced): bottom->setVisible(false); | - |
308 | | - |
309 | QPushButton *printButton = buttons->button(QDialogButtonBox::Ok); executed (the execution status of this line is deduced): QPushButton *printButton = buttons->button(QDialogButtonBox::Ok); | - |
310 | printButton->setText(QPrintDialog::tr("&Print")); executed (the execution status of this line is deduced): printButton->setText(QPrintDialog::tr("&Print")); | - |
311 | printButton->setDefault(true); executed (the execution status of this line is deduced): printButton->setDefault(true); | - |
312 | | - |
313 | QVBoxLayout *lay = new QVBoxLayout(q); executed (the execution status of this line is deduced): QVBoxLayout *lay = new QVBoxLayout(q); | - |
314 | q->setLayout(lay); executed (the execution status of this line is deduced): q->setLayout(lay); | - |
315 | lay->addWidget(top); executed (the execution status of this line is deduced): lay->addWidget(top); | - |
316 | lay->addWidget(bottom); executed (the execution status of this line is deduced): lay->addWidget(bottom); | - |
317 | lay->addWidget(buttons); executed (the execution status of this line is deduced): lay->addWidget(buttons); | - |
318 | | - |
319 | #ifdef QT_NO_MESSAGEBOX | - |
320 | QObject::connect(buttons, SIGNAL(accepted()), q, SLOT(accept())); | - |
321 | #else | - |
322 | QObject::connect(buttons, SIGNAL(accepted()), q, SLOT(_q_checkFields())); executed (the execution status of this line is deduced): QObject::connect(buttons, "2""accepted()", q, "1""_q_checkFields()"); | - |
323 | #endif | - |
324 | QObject::connect(buttons, SIGNAL(rejected()), q, SLOT(reject())); executed (the execution status of this line is deduced): QObject::connect(buttons, "2""rejected()", q, "1""reject()"); | - |
325 | | - |
326 | QObject::connect(options.reverse, SIGNAL(toggled(bool)), executed (the execution status of this line is deduced): QObject::connect(options.reverse, "2""toggled(bool)", | - |
327 | q, SLOT(_q_chbPrintLastFirstToggled(bool))); executed (the execution status of this line is deduced): q, "1""_q_chbPrintLastFirstToggled(bool)"); | - |
328 | | - |
329 | QObject::connect(collapseButton, SIGNAL(released()), q, SLOT(_q_collapseOrExpandDialog())); executed (the execution status of this line is deduced): QObject::connect(collapseButton, "2""released()", q, "1""_q_collapseOrExpandDialog()"); | - |
330 | } executed: } Execution Count:3 | 3 |
331 | | - |
332 | // initialize printer options | - |
333 | void QPrintDialogPrivate::selectPrinter() | - |
334 | { | - |
335 | Q_Q(QPrintDialog); executed (the execution status of this line is deduced): QPrintDialog * const q = q_func(); | - |
336 | QPrinter *p = q->printer(); executed (the execution status of this line is deduced): QPrinter *p = q->printer(); | - |
337 | | - |
338 | if (p->colorMode() == QPrinter::Color) partially evaluated: p->colorMode() == QPrinter::Color yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
339 | options.color->setChecked(true); executed: options.color->setChecked(true); Execution Count:4 | 4 |
340 | else | - |
341 | options.grayscale->setChecked(true); never executed: options.grayscale->setChecked(true); | 0 |
342 | | - |
343 | switch (p->duplex()) { | - |
344 | case QPrinter::DuplexNone: | - |
345 | options.noDuplex->setChecked(true); break; executed: break; Execution Count:4 | 4 |
346 | case QPrinter::DuplexLongSide: | - |
347 | case QPrinter::DuplexAuto: | - |
348 | options.duplexLong->setChecked(true); break; | 0 |
349 | case QPrinter::DuplexShortSide: | - |
350 | options.duplexShort->setChecked(true); break; | 0 |
351 | } | - |
352 | options.copies->setValue(p->copyCount()); executed (the execution status of this line is deduced): options.copies->setValue(p->copyCount()); | - |
353 | options.collate->setChecked(p->collateCopies()); executed (the execution status of this line is deduced): options.collate->setChecked(p->collateCopies()); | - |
354 | options.reverse->setChecked(p->pageOrder() == QPrinter::LastPageFirst); executed (the execution status of this line is deduced): options.reverse->setChecked(p->pageOrder() == QPrinter::LastPageFirst); | - |
355 | } executed: } Execution Count:4 | 4 |
356 | | - |
357 | void QPrintDialogPrivate::applyPrinterProperties() | - |
358 | { | - |
359 | // apply printer options to property dialog | - |
360 | top->d->applyPrinterProperties(); never executed (the execution status of this line is deduced): top->d->applyPrinterProperties(); | - |
361 | } | 0 |
362 | | - |
363 | void QPrintDialogPrivate::setupPrinter() | - |
364 | { | - |
365 | Q_Q(QPrintDialog); never executed (the execution status of this line is deduced): QPrintDialog * const q = q_func(); | - |
366 | QPrinter* p = q->printer(); never executed (the execution status of this line is deduced): QPrinter* p = q->printer(); | - |
367 | | - |
368 | if (options.duplex->isEnabled()) { never evaluated: options.duplex->isEnabled() | 0 |
369 | if (options.noDuplex->isChecked()) never evaluated: options.noDuplex->isChecked() | 0 |
370 | p->setDuplex(QPrinter::DuplexNone); never executed: p->setDuplex(QPrinter::DuplexNone); | 0 |
371 | else if (options.duplexLong->isChecked()) never evaluated: options.duplexLong->isChecked() | 0 |
372 | p->setDuplex(QPrinter::DuplexLongSide); never executed: p->setDuplex(QPrinter::DuplexLongSide); | 0 |
373 | else | - |
374 | p->setDuplex(QPrinter::DuplexShortSide); never executed: p->setDuplex(QPrinter::DuplexShortSide); | 0 |
375 | } | - |
376 | | - |
377 | p->setColorMode(options.color->isChecked() ? QPrinter::Color : QPrinter::GrayScale); never executed (the execution status of this line is deduced): p->setColorMode(options.color->isChecked() ? QPrinter::Color : QPrinter::GrayScale); | - |
378 | | - |
379 | // print range | - |
380 | if (options.printAll->isChecked()) { never evaluated: options.printAll->isChecked() | 0 |
381 | p->setPrintRange(QPrinter::AllPages); never executed (the execution status of this line is deduced): p->setPrintRange(QPrinter::AllPages); | - |
382 | p->setFromTo(0,0); never executed (the execution status of this line is deduced): p->setFromTo(0,0); | - |
383 | } else if (options.printSelection->isChecked()) { never executed: } never evaluated: options.printSelection->isChecked() | 0 |
384 | p->setPrintRange(QPrinter::Selection); never executed (the execution status of this line is deduced): p->setPrintRange(QPrinter::Selection); | - |
385 | p->setFromTo(0,0); never executed (the execution status of this line is deduced): p->setFromTo(0,0); | - |
386 | } else if (options.printCurrentPage->isChecked()) { never executed: } never evaluated: options.printCurrentPage->isChecked() | 0 |
387 | p->setPrintRange(QPrinter::CurrentPage); never executed (the execution status of this line is deduced): p->setPrintRange(QPrinter::CurrentPage); | - |
388 | p->setFromTo(0,0); never executed (the execution status of this line is deduced): p->setFromTo(0,0); | - |
389 | } else if (options.printRange->isChecked()) { never executed: } never evaluated: options.printRange->isChecked() | 0 |
390 | p->setPrintRange(QPrinter::PageRange); never executed (the execution status of this line is deduced): p->setPrintRange(QPrinter::PageRange); | - |
391 | p->setFromTo(options.from->value(), qMax(options.from->value(), options.to->value())); never executed (the execution status of this line is deduced): p->setFromTo(options.from->value(), qMax(options.from->value(), options.to->value())); | - |
392 | } | 0 |
393 | | - |
394 | // copies | - |
395 | p->setCopyCount(options.copies->value()); never executed (the execution status of this line is deduced): p->setCopyCount(options.copies->value()); | - |
396 | p->setCollateCopies(options.collate->isChecked()); never executed (the execution status of this line is deduced): p->setCollateCopies(options.collate->isChecked()); | - |
397 | | - |
398 | top->d->setupPrinter(); never executed (the execution status of this line is deduced): top->d->setupPrinter(); | - |
399 | } | 0 |
400 | | - |
401 | void QPrintDialogPrivate::_q_chbPrintLastFirstToggled(bool checked) | - |
402 | { | - |
403 | Q_Q(QPrintDialog); never executed (the execution status of this line is deduced): QPrintDialog * const q = q_func(); | - |
404 | if (checked) | 0 |
405 | q->printer()->setPageOrder(QPrinter::LastPageFirst); never executed: q->printer()->setPageOrder(QPrinter::LastPageFirst); | 0 |
406 | else | - |
407 | q->printer()->setPageOrder(QPrinter::FirstPageFirst); never executed: q->printer()->setPageOrder(QPrinter::FirstPageFirst); | 0 |
408 | } | - |
409 | | - |
410 | void QPrintDialogPrivate::_q_collapseOrExpandDialog() | - |
411 | { | - |
412 | int collapseHeight = 0; never executed (the execution status of this line is deduced): int collapseHeight = 0; | - |
413 | Q_Q(QPrintDialog); never executed (the execution status of this line is deduced): QPrintDialog * const q = q_func(); | - |
414 | QWidget *widgetToHide = bottom; never executed (the execution status of this line is deduced): QWidget *widgetToHide = bottom; | - |
415 | if (widgetToHide->isVisible()) { never evaluated: widgetToHide->isVisible() | 0 |
416 | collapseButton->setText(QPrintDialog::tr("&Options >>")); never executed (the execution status of this line is deduced): collapseButton->setText(QPrintDialog::tr("&Options >>")); | - |
417 | collapseHeight = widgetToHide->y() + widgetToHide->height() - (top->y() + top->height()); never executed (the execution status of this line is deduced): collapseHeight = widgetToHide->y() + widgetToHide->height() - (top->y() + top->height()); | - |
418 | } | 0 |
419 | else | - |
420 | collapseButton->setText(QPrintDialog::tr("&Options <<")); never executed: collapseButton->setText(QPrintDialog::tr("&Options <<")); | 0 |
421 | widgetToHide->setVisible(! widgetToHide->isVisible()); never executed (the execution status of this line is deduced): widgetToHide->setVisible(! widgetToHide->isVisible()); | - |
422 | if (! widgetToHide->isVisible()) { // make it shrink never evaluated: ! widgetToHide->isVisible() | 0 |
423 | q->layout()->activate(); never executed (the execution status of this line is deduced): q->layout()->activate(); | - |
424 | q->resize( QSize(q->width(), q->height() - collapseHeight) ); never executed (the execution status of this line is deduced): q->resize( QSize(q->width(), q->height() - collapseHeight) ); | - |
425 | } | 0 |
426 | } | 0 |
427 | | - |
428 | #ifndef QT_NO_MESSAGEBOX | - |
429 | void QPrintDialogPrivate::_q_checkFields() | - |
430 | { | - |
431 | Q_Q(QPrintDialog); never executed (the execution status of this line is deduced): QPrintDialog * const q = q_func(); | - |
432 | if (top->d->checkFields()) never evaluated: top->d->checkFields() | 0 |
433 | q->accept(); never executed: q->accept(); | 0 |
434 | } | 0 |
435 | #endif // QT_NO_MESSAGEBOX | - |
436 | | - |
437 | | - |
438 | void QPrintDialogPrivate::updateWidgets() | - |
439 | { | - |
440 | Q_Q(QPrintDialog); executed (the execution status of this line is deduced): QPrintDialog * const q = q_func(); | - |
441 | options.gbPrintRange->setVisible(q->isOptionEnabled(QPrintDialog::PrintPageRange) || executed (the execution status of this line is deduced): options.gbPrintRange->setVisible(q->isOptionEnabled(QPrintDialog::PrintPageRange) || | - |
442 | q->isOptionEnabled(QPrintDialog::PrintSelection) || executed (the execution status of this line is deduced): q->isOptionEnabled(QPrintDialog::PrintSelection) || | - |
443 | q->isOptionEnabled(QPrintDialog::PrintCurrentPage)); executed (the execution status of this line is deduced): q->isOptionEnabled(QPrintDialog::PrintCurrentPage)); | - |
444 | | - |
445 | options.printRange->setEnabled(q->isOptionEnabled(QPrintDialog::PrintPageRange)); executed (the execution status of this line is deduced): options.printRange->setEnabled(q->isOptionEnabled(QPrintDialog::PrintPageRange)); | - |
446 | options.printSelection->setVisible(q->isOptionEnabled(QPrintDialog::PrintSelection)); executed (the execution status of this line is deduced): options.printSelection->setVisible(q->isOptionEnabled(QPrintDialog::PrintSelection)); | - |
447 | options.printCurrentPage->setVisible(q->isOptionEnabled(QPrintDialog::PrintCurrentPage)); executed (the execution status of this line is deduced): options.printCurrentPage->setVisible(q->isOptionEnabled(QPrintDialog::PrintCurrentPage)); | - |
448 | options.collate->setVisible(q->isOptionEnabled(QPrintDialog::PrintCollateCopies)); executed (the execution status of this line is deduced): options.collate->setVisible(q->isOptionEnabled(QPrintDialog::PrintCollateCopies)); | - |
449 | | - |
450 | switch (q->printRange()) { | - |
451 | case QPrintDialog::AllPages: | - |
452 | options.printAll->setChecked(true); executed (the execution status of this line is deduced): options.printAll->setChecked(true); | - |
453 | break; executed: break; Execution Count:1 | 1 |
454 | case QPrintDialog::Selection: | - |
455 | options.printSelection->setChecked(true); never executed (the execution status of this line is deduced): options.printSelection->setChecked(true); | - |
456 | break; | 0 |
457 | case QPrintDialog::PageRange: | - |
458 | options.printRange->setChecked(true); never executed (the execution status of this line is deduced): options.printRange->setChecked(true); | - |
459 | break; | 0 |
460 | case QPrintDialog::CurrentPage: | - |
461 | if (q->isOptionEnabled(QPrintDialog::PrintCurrentPage)) never evaluated: q->isOptionEnabled(QPrintDialog::PrintCurrentPage) | 0 |
462 | options.printCurrentPage->setChecked(true); never executed: options.printCurrentPage->setChecked(true); | 0 |
463 | break; | 0 |
464 | default: | - |
465 | break; | 0 |
466 | } | - |
467 | const int minPage = qMax(1, qMin(q->minPage() , q->maxPage())); executed (the execution status of this line is deduced): const int minPage = qMax(1, qMin(q->minPage() , q->maxPage())); | - |
468 | const int maxPage = qMax(1, q->maxPage() == INT_MAX ? 9999 : q->maxPage()); executed (the execution status of this line is deduced): const int maxPage = qMax(1, q->maxPage() == 2147483647 ? 9999 : q->maxPage()); | - |
469 | | - |
470 | options.from->setMinimum(minPage); executed (the execution status of this line is deduced): options.from->setMinimum(minPage); | - |
471 | options.to->setMinimum(minPage); executed (the execution status of this line is deduced): options.to->setMinimum(minPage); | - |
472 | options.from->setMaximum(maxPage); executed (the execution status of this line is deduced): options.from->setMaximum(maxPage); | - |
473 | options.to->setMaximum(maxPage); executed (the execution status of this line is deduced): options.to->setMaximum(maxPage); | - |
474 | | - |
475 | options.from->setValue(q->fromPage()); executed (the execution status of this line is deduced): options.from->setValue(q->fromPage()); | - |
476 | options.to->setValue(q->toPage()); executed (the execution status of this line is deduced): options.to->setValue(q->toPage()); | - |
477 | top->d->updateWidget(); executed (the execution status of this line is deduced): top->d->updateWidget(); | - |
478 | } executed: } Execution Count:1 | 1 |
479 | | - |
480 | void QPrintDialogPrivate::setTabs(const QList<QWidget*> &tabWidgets) | - |
481 | { | - |
482 | QList<QWidget*>::ConstIterator iter = tabWidgets.begin(); never executed (the execution status of this line is deduced): QList<QWidget*>::ConstIterator iter = tabWidgets.begin(); | - |
483 | while(iter != tabWidgets.constEnd()) { never evaluated: iter != tabWidgets.constEnd() | 0 |
484 | QWidget *tab = *iter; never executed (the execution status of this line is deduced): QWidget *tab = *iter; | - |
485 | options.tabs->addTab(tab, tab->windowTitle()); never executed (the execution status of this line is deduced): options.tabs->addTab(tab, tab->windowTitle()); | - |
486 | ++iter; never executed (the execution status of this line is deduced): ++iter; | - |
487 | } | 0 |
488 | } | 0 |
489 | | - |
490 | //////////////////////////////////////////////////////////////////////////////// | - |
491 | //////////////////////////////////////////////////////////////////////////////// | - |
492 | | - |
493 | /* | - |
494 | | - |
495 | QPrintDialog | - |
496 | | - |
497 | The main Print Dialog. | - |
498 | | - |
499 | */ | - |
500 | | - |
501 | QPrintDialog::QPrintDialog(QPrinter *printer, QWidget *parent) | - |
502 | : QAbstractPrintDialog(*(new QPrintDialogPrivate), printer, parent) | - |
503 | { | - |
504 | Q_D(QPrintDialog); executed (the execution status of this line is deduced): QPrintDialogPrivate * const d = d_func(); | - |
505 | d->init(); executed (the execution status of this line is deduced): d->init(); | - |
506 | } executed: } Execution Count:2 | 2 |
507 | | - |
508 | /*! | - |
509 | Constructs a print dialog with the given \a parent. | - |
510 | */ | - |
511 | QPrintDialog::QPrintDialog(QWidget *parent) | - |
512 | : QAbstractPrintDialog(*(new QPrintDialogPrivate), 0, parent) | - |
513 | { | - |
514 | Q_D(QPrintDialog); executed (the execution status of this line is deduced): QPrintDialogPrivate * const d = d_func(); | - |
515 | d->init(); executed (the execution status of this line is deduced): d->init(); | - |
516 | } executed: } Execution Count:1 | 1 |
517 | | - |
518 | QPrintDialog::~QPrintDialog() | - |
519 | { | - |
520 | } | - |
521 | | - |
522 | void QPrintDialog::setVisible(bool visible) | - |
523 | { | - |
524 | Q_D(QPrintDialog); executed (the execution status of this line is deduced): QPrintDialogPrivate * const d = d_func(); | - |
525 | | - |
526 | if (visible) partially evaluated: visible yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
527 | d->updateWidgets(); executed: d->updateWidgets(); Execution Count:1 | 1 |
528 | | - |
529 | QAbstractPrintDialog::setVisible(visible); executed (the execution status of this line is deduced): QAbstractPrintDialog::setVisible(visible); | - |
530 | } executed: } Execution Count:1 | 1 |
531 | | - |
532 | int QPrintDialog::exec() | - |
533 | { | - |
534 | return QDialog::exec(); never executed: return QDialog::exec(); | 0 |
535 | } | - |
536 | | - |
537 | void QPrintDialog::accept() | - |
538 | { | - |
539 | Q_D(QPrintDialog); never executed (the execution status of this line is deduced): QPrintDialogPrivate * const d = d_func(); | - |
540 | d->setupPrinter(); never executed (the execution status of this line is deduced): d->setupPrinter(); | - |
541 | QDialog::accept(); never executed (the execution status of this line is deduced): QDialog::accept(); | - |
542 | } | 0 |
543 | | - |
544 | //////////////////////////////////////////////////////////////////////////////// | - |
545 | //////////////////////////////////////////////////////////////////////////////// | - |
546 | | - |
547 | /* | - |
548 | | - |
549 | QUnixPrintWidget && QUnixPrintWidgetPrivate | - |
550 | | - |
551 | The upper half of the Print Dialog containing the Printer Selection widgets | - |
552 | | - |
553 | */ | - |
554 | | - |
555 | #if defined (Q_OS_UNIX) | - |
556 | | - |
557 | /*! \internal | - |
558 | */ | - |
559 | QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p, QPrinter *prn) | - |
560 | : parent(p), propertiesDialog(0), printer(prn), optionsPane(0), | - |
561 | filePrintersAdded(false), propertiesDialogShown(false) | - |
562 | { | - |
563 | q = 0; executed (the execution status of this line is deduced): q = 0; | - |
564 | if (parent) partially evaluated: parent yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
565 | q = qobject_cast<QAbstractPrintDialog*> (parent->parent()); executed: q = qobject_cast<QAbstractPrintDialog*> (parent->parent()); Execution Count:3 | 3 |
566 | | - |
567 | widget.setupUi(parent); executed (the execution status of this line is deduced): widget.setupUi(parent); | - |
568 | | - |
569 | int currentPrinterIndex = 0; executed (the execution status of this line is deduced): int currentPrinterIndex = 0; | - |
570 | QList<QPrinterInfo> printers = QPrinterInfo::availablePrinters(); executed (the execution status of this line is deduced): QList<QPrinterInfo> printers = QPrinterInfo::availablePrinters(); | - |
571 | | - |
572 | for (int i = 0; i < printers.size(); ++i) { partially evaluated: i < printers.size() no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
573 | QPrinterInfo pInfo = printers.at(i); never executed (the execution status of this line is deduced): QPrinterInfo pInfo = printers.at(i); | - |
574 | widget.printers->addItem(pInfo.printerName()); never executed (the execution status of this line is deduced): widget.printers->addItem(pInfo.printerName()); | - |
575 | if (pInfo.isDefault()) never evaluated: pInfo.isDefault() | 0 |
576 | currentPrinterIndex = i; never executed: currentPrinterIndex = i; | 0 |
577 | } | 0 |
578 | widget.properties->setEnabled(true); executed (the execution status of this line is deduced): widget.properties->setEnabled(true); | - |
579 | | - |
580 | #if !defined(QT_NO_FILESYSTEMMODEL) && !defined(QT_NO_COMPLETER) | - |
581 | QFileSystemModel *fsm = new QFileSystemModel(widget.filename); executed (the execution status of this line is deduced): QFileSystemModel *fsm = new QFileSystemModel(widget.filename); | - |
582 | fsm->setRootPath(QDir::homePath()); executed (the execution status of this line is deduced): fsm->setRootPath(QDir::homePath()); | - |
583 | widget.filename->setCompleter(new QCompleter(fsm, widget.filename)); executed (the execution status of this line is deduced): widget.filename->setCompleter(new QCompleter(fsm, widget.filename)); | - |
584 | #endif | - |
585 | _q_printerChanged(currentPrinterIndex); executed (the execution status of this line is deduced): _q_printerChanged(currentPrinterIndex); | - |
586 | | - |
587 | QObject::connect(widget.printers, SIGNAL(currentIndexChanged(int)), executed (the execution status of this line is deduced): QObject::connect(widget.printers, "2""currentIndexChanged(int)", | - |
588 | parent, SLOT(_q_printerChanged(int))); executed (the execution status of this line is deduced): parent, "1""_q_printerChanged(int)"); | - |
589 | QObject::connect(widget.fileBrowser, SIGNAL(clicked()), parent, SLOT(_q_btnBrowseClicked())); executed (the execution status of this line is deduced): QObject::connect(widget.fileBrowser, "2""clicked()", parent, "1""_q_btnBrowseClicked()"); | - |
590 | QObject::connect(widget.properties, SIGNAL(clicked()), parent, SLOT(_q_btnPropertiesClicked())); executed (the execution status of this line is deduced): QObject::connect(widget.properties, "2""clicked()", parent, "1""_q_btnPropertiesClicked()"); | - |
591 | | - |
592 | // disable features that QPrinter does not yet support. | - |
593 | widget.preview->setVisible(false); executed (the execution status of this line is deduced): widget.preview->setVisible(false); | - |
594 | } executed: } Execution Count:3 | 3 |
595 | | - |
596 | void QUnixPrintWidgetPrivate::updateWidget() | - |
597 | { | - |
598 | const bool printToFile = q == 0 || q->isOptionEnabled(QPrintDialog::PrintToFile); partially evaluated: q == 0 no Evaluation Count:0 | yes Evaluation Count:1 |
partially evaluated: q->isOptionEnabled(QPrintDialog::PrintToFile) yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
599 | if (printToFile && !filePrintersAdded) { partially evaluated: printToFile yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: !filePrintersAdded yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
600 | if (widget.printers->count()) partially evaluated: widget.printers->count() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
601 | widget.printers->insertSeparator(widget.printers->count()); never executed: widget.printers->insertSeparator(widget.printers->count()); | 0 |
602 | widget.printers->addItem(QPrintDialog::tr("Print to File (PDF)")); executed (the execution status of this line is deduced): widget.printers->addItem(QPrintDialog::tr("Print to File (PDF)")); | - |
603 | filePrintersAdded = true; executed (the execution status of this line is deduced): filePrintersAdded = true; | - |
604 | } executed: } Execution Count:1 | 1 |
605 | if (!printToFile && filePrintersAdded) { partially evaluated: !printToFile no Evaluation Count:0 | yes Evaluation Count:1 |
never evaluated: filePrintersAdded | 0-1 |
606 | widget.printers->removeItem(widget.printers->count()-1); never executed (the execution status of this line is deduced): widget.printers->removeItem(widget.printers->count()-1); | - |
607 | widget.printers->removeItem(widget.printers->count()-1); never executed (the execution status of this line is deduced): widget.printers->removeItem(widget.printers->count()-1); | - |
608 | if (widget.printers->count()) never evaluated: widget.printers->count() | 0 |
609 | widget.printers->removeItem(widget.printers->count()-1); // remove separator never executed: widget.printers->removeItem(widget.printers->count()-1); | 0 |
610 | filePrintersAdded = false; never executed (the execution status of this line is deduced): filePrintersAdded = false; | - |
611 | } | 0 |
612 | if (printer && filePrintersAdded && (printer->outputFormat() != QPrinter::NativeFormat partially evaluated: printer yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: filePrintersAdded yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: printer->outputFormat() != QPrinter::NativeFormat yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
613 | || printer->printerName().isEmpty())) never evaluated: printer->printerName().isEmpty() | 0 |
614 | { | - |
615 | if (printer->outputFormat() == QPrinter::PdfFormat) partially evaluated: printer->outputFormat() == QPrinter::PdfFormat yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
616 | widget.printers->setCurrentIndex(widget.printers->count() - 1); executed: widget.printers->setCurrentIndex(widget.printers->count() - 1); Execution Count:1 | 1 |
617 | widget.filename->setEnabled(true); executed (the execution status of this line is deduced): widget.filename->setEnabled(true); | - |
618 | widget.lOutput->setEnabled(true); executed (the execution status of this line is deduced): widget.lOutput->setEnabled(true); | - |
619 | } executed: } Execution Count:1 | 1 |
620 | | - |
621 | widget.filename->setVisible(printToFile); executed (the execution status of this line is deduced): widget.filename->setVisible(printToFile); | - |
622 | widget.lOutput->setVisible(printToFile); executed (the execution status of this line is deduced): widget.lOutput->setVisible(printToFile); | - |
623 | widget.fileBrowser->setVisible(printToFile); executed (the execution status of this line is deduced): widget.fileBrowser->setVisible(printToFile); | - |
624 | | - |
625 | widget.properties->setVisible(q->isOptionEnabled(QAbstractPrintDialog::PrintShowPageSize)); executed (the execution status of this line is deduced): widget.properties->setVisible(q->isOptionEnabled(QAbstractPrintDialog::PrintShowPageSize)); | - |
626 | } executed: } Execution Count:1 | 1 |
627 | | - |
628 | QUnixPrintWidgetPrivate::~QUnixPrintWidgetPrivate() | - |
629 | { | - |
630 | } | - |
631 | | - |
632 | void QUnixPrintWidgetPrivate::_q_printerChanged(int index) | - |
633 | { | - |
634 | if (index < 0) partially evaluated: index < 0 no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
635 | return; | 0 |
636 | const int printerCount = widget.printers->count(); executed (the execution status of this line is deduced): const int printerCount = widget.printers->count(); | - |
637 | widget.filename->setEnabled(false); executed (the execution status of this line is deduced): widget.filename->setEnabled(false); | - |
638 | widget.lOutput->setEnabled(false); executed (the execution status of this line is deduced): widget.lOutput->setEnabled(false); | - |
639 | | - |
640 | // Reset properties dialog when printer is changed | - |
641 | if (propertiesDialog){ partially evaluated: propertiesDialog no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
642 | delete propertiesDialog; never executed (the execution status of this line is deduced): delete propertiesDialog; | - |
643 | propertiesDialog = 0; never executed (the execution status of this line is deduced): propertiesDialog = 0; | - |
644 | propertiesDialogShown = false; never executed (the execution status of this line is deduced): propertiesDialogShown = false; | - |
645 | } | 0 |
646 | | - |
647 | if (filePrintersAdded) { partially evaluated: filePrintersAdded no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
648 | Q_ASSERT(index != printerCount - 2); // separator never executed (the execution status of this line is deduced): qt_noop(); | - |
649 | if (index == printerCount - 1) { // PDF never evaluated: index == printerCount - 1 | 0 |
650 | widget.location->setText(QPrintDialog::tr("Local file")); never executed (the execution status of this line is deduced): widget.location->setText(QPrintDialog::tr("Local file")); | - |
651 | widget.type->setText(QPrintDialog::tr("Write PDF file")); never executed (the execution status of this line is deduced): widget.type->setText(QPrintDialog::tr("Write PDF file")); | - |
652 | widget.properties->setEnabled(true); never executed (the execution status of this line is deduced): widget.properties->setEnabled(true); | - |
653 | widget.filename->setEnabled(true); never executed (the execution status of this line is deduced): widget.filename->setEnabled(true); | - |
654 | QString filename = widget.filename->text(); never executed (the execution status of this line is deduced): QString filename = widget.filename->text(); | - |
655 | widget.filename->setText(filename); never executed (the execution status of this line is deduced): widget.filename->setText(filename); | - |
656 | widget.lOutput->setEnabled(true); never executed (the execution status of this line is deduced): widget.lOutput->setEnabled(true); | - |
657 | if (optionsPane) never evaluated: optionsPane | 0 |
658 | optionsPane->selectPrinter(); never executed: optionsPane->selectPrinter(); | 0 |
659 | return; | 0 |
660 | } | - |
661 | } | 0 |
662 | | - |
663 | if (printer) { partially evaluated: printer yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
664 | QString printerName = widget.printers->itemText(index); executed (the execution status of this line is deduced): QString printerName = widget.printers->itemText(index); | - |
665 | printer->setPrinterName(printerName); executed (the execution status of this line is deduced): printer->setPrinterName(printerName); | - |
666 | | - |
667 | QPrinterInfo printerInfo = QPrinterInfo::printerInfo(printer->printerName()); executed (the execution status of this line is deduced): QPrinterInfo printerInfo = QPrinterInfo::printerInfo(printer->printerName()); | - |
668 | widget.location->setText(printerInfo.location()); executed (the execution status of this line is deduced): widget.location->setText(printerInfo.location()); | - |
669 | widget.type->setText(printerInfo.makeAndModel()); executed (the execution status of this line is deduced): widget.type->setText(printerInfo.makeAndModel()); | - |
670 | if (optionsPane) evaluated: optionsPane yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-3 |
671 | optionsPane->selectPrinter(); executed: optionsPane->selectPrinter(); Execution Count:1 | 1 |
672 | } executed: } Execution Count:4 | 4 |
673 | } executed: } Execution Count:4 | 4 |
674 | | - |
675 | void QUnixPrintWidgetPrivate::setOptionsPane(QPrintDialogPrivate *pane) | - |
676 | { | - |
677 | optionsPane = pane; executed (the execution status of this line is deduced): optionsPane = pane; | - |
678 | if (optionsPane) partially evaluated: optionsPane yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
679 | optionsPane->selectPrinter(); executed: optionsPane->selectPrinter(); Execution Count:3 | 3 |
680 | } executed: } Execution Count:3 | 3 |
681 | | - |
682 | void QUnixPrintWidgetPrivate::_q_btnBrowseClicked() | - |
683 | { | - |
684 | QString filename = widget.filename->text(); never executed (the execution status of this line is deduced): QString filename = widget.filename->text(); | - |
685 | #ifndef QT_NO_FILEDIALOG | - |
686 | filename = QFileDialog::getSaveFileName(parent, QPrintDialog::tr("Print To File ..."), filename, never executed (the execution status of this line is deduced): filename = QFileDialog::getSaveFileName(parent, QPrintDialog::tr("Print To File ..."), filename, | - |
687 | QString(), 0, QFileDialog::DontConfirmOverwrite); never executed (the execution status of this line is deduced): QString(), 0, QFileDialog::DontConfirmOverwrite); | - |
688 | #else | - |
689 | filename.clear(); | - |
690 | #endif | - |
691 | if (!filename.isEmpty()) { never evaluated: !filename.isEmpty() | 0 |
692 | widget.filename->setText(filename); never executed (the execution status of this line is deduced): widget.filename->setText(filename); | - |
693 | widget.printers->setCurrentIndex(widget.printers->count() - 1); // the pdf one never executed (the execution status of this line is deduced): widget.printers->setCurrentIndex(widget.printers->count() - 1); | - |
694 | } | 0 |
695 | } | 0 |
696 | | - |
697 | void QUnixPrintWidgetPrivate::applyPrinterProperties() | - |
698 | { | - |
699 | if (printer == 0) partially evaluated: printer == 0 no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
700 | return; | 0 |
701 | if (printer->outputFileName().isEmpty()) { partially evaluated: printer->outputFileName().isEmpty() yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
702 | QString home = QDir::homePath(); executed (the execution status of this line is deduced): QString home = QDir::homePath(); | - |
703 | QString cur = QDir::currentPath(); executed (the execution status of this line is deduced): QString cur = QDir::currentPath(); | - |
704 | if (home.at(home.length()-1) != QLatin1Char('/')) partially evaluated: home.at(home.length()-1) != QLatin1Char('/') yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
705 | home += QLatin1Char('/'); executed: home += QLatin1Char('/'); Execution Count:3 | 3 |
706 | if (cur.at(cur.length()-1) != QLatin1Char('/')) partially evaluated: cur.at(cur.length()-1) != QLatin1Char('/') yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
707 | cur += QLatin1Char('/'); executed: cur += QLatin1Char('/'); Execution Count:3 | 3 |
708 | if (cur.left(home.length()) != home) partially evaluated: cur.left(home.length()) != home no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
709 | cur = home; never executed: cur = home; | 0 |
710 | if (QGuiApplication::platformName() == QLatin1String("xcb")) { partially evaluated: QGuiApplication::platformName() == QLatin1String("xcb") yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
711 | if (printer->docName().isEmpty()) { partially evaluated: printer->docName().isEmpty() yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
712 | cur += QLatin1String("print.pdf"); executed (the execution status of this line is deduced): cur += QLatin1String("print.pdf"); | - |
713 | } else { executed: } Execution Count:3 | 3 |
714 | QRegExp re(QString::fromLatin1("(.*)\\.\\S+")); never executed (the execution status of this line is deduced): QRegExp re(QString::fromLatin1("(.*)\\.\\S+")); | - |
715 | if (re.exactMatch(printer->docName())) never evaluated: re.exactMatch(printer->docName()) | 0 |
716 | cur += re.cap(1); never executed: cur += re.cap(1); | 0 |
717 | else | - |
718 | cur += printer->docName(); never executed: cur += printer->docName(); | 0 |
719 | cur += QLatin1String(".pdf"); never executed (the execution status of this line is deduced): cur += QLatin1String(".pdf"); | - |
720 | } | 0 |
721 | } // xcb | - |
722 | | - |
723 | widget.filename->setText(cur); executed (the execution status of this line is deduced): widget.filename->setText(cur); | - |
724 | } executed: } Execution Count:3 | 3 |
725 | else | - |
726 | widget.filename->setText( printer->outputFileName() ); never executed: widget.filename->setText( printer->outputFileName() ); | 0 |
727 | QString printerName = printer->printerName(); executed (the execution status of this line is deduced): QString printerName = printer->printerName(); | - |
728 | if (!printerName.isEmpty()) { partially evaluated: !printerName.isEmpty() no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
729 | for (int i = 0; i < widget.printers->count(); ++i) { never evaluated: i < widget.printers->count() | 0 |
730 | if (widget.printers->itemText(i) == printerName) { never evaluated: widget.printers->itemText(i) == printerName | 0 |
731 | widget.printers->setCurrentIndex(i); never executed (the execution status of this line is deduced): widget.printers->setCurrentIndex(i); | - |
732 | break; | 0 |
733 | } | - |
734 | } | 0 |
735 | } | 0 |
736 | // PDF and PS printers are not added to the dialog yet, we'll handle those cases in QUnixPrintWidgetPrivate::updateWidget | - |
737 | | - |
738 | if (propertiesDialog) partially evaluated: propertiesDialog no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
739 | propertiesDialog->applyPrinterProperties(printer); never executed: propertiesDialog->applyPrinterProperties(printer); | 0 |
740 | } executed: } Execution Count:3 | 3 |
741 | | - |
742 | #ifndef QT_NO_MESSAGEBOX | - |
743 | bool QUnixPrintWidgetPrivate::checkFields() | - |
744 | { | - |
745 | if (widget.filename->isEnabled()) { never evaluated: widget.filename->isEnabled() | 0 |
746 | QString file = widget.filename->text(); never executed (the execution status of this line is deduced): QString file = widget.filename->text(); | - |
747 | QFile f(file); never executed (the execution status of this line is deduced): QFile f(file); | - |
748 | QFileInfo fi(f); never executed (the execution status of this line is deduced): QFileInfo fi(f); | - |
749 | bool exists = fi.exists(); never executed (the execution status of this line is deduced): bool exists = fi.exists(); | - |
750 | bool opened = false; never executed (the execution status of this line is deduced): bool opened = false; | - |
751 | if (exists && fi.isDir()) { never evaluated: exists never evaluated: fi.isDir() | 0 |
752 | QMessageBox::warning(q, q->windowTitle(), never executed (the execution status of this line is deduced): QMessageBox::warning(q, q->windowTitle(), | - |
753 | QPrintDialog::tr("%1 is a directory.\nPlease choose a different file name.").arg(file)); never executed (the execution status of this line is deduced): QPrintDialog::tr("%1 is a directory.\nPlease choose a different file name.").arg(file)); | - |
754 | return false; never executed: return false; | 0 |
755 | } else if ((exists && !fi.isWritable()) || !(opened = f.open(QFile::Append))) { never evaluated: exists never evaluated: !fi.isWritable() never evaluated: !(opened = f.open(QFile::Append)) | 0 |
756 | QMessageBox::warning(q, q->windowTitle(), never executed (the execution status of this line is deduced): QMessageBox::warning(q, q->windowTitle(), | - |
757 | QPrintDialog::tr("File %1 is not writable.\nPlease choose a different file name.").arg(file)); never executed (the execution status of this line is deduced): QPrintDialog::tr("File %1 is not writable.\nPlease choose a different file name.").arg(file)); | - |
758 | return false; never executed: return false; | 0 |
759 | } else if (exists) { | 0 |
760 | int ret = QMessageBox::question(q, q->windowTitle(), never executed (the execution status of this line is deduced): int ret = QMessageBox::question(q, q->windowTitle(), | - |
761 | QPrintDialog::tr("%1 already exists.\nDo you want to overwrite it?").arg(file), never executed (the execution status of this line is deduced): QPrintDialog::tr("%1 already exists.\nDo you want to overwrite it?").arg(file), | - |
762 | QMessageBox::Yes|QMessageBox::No, QMessageBox::No); never executed (the execution status of this line is deduced): QMessageBox::Yes|QMessageBox::No, QMessageBox::No); | - |
763 | if (ret == QMessageBox::No) never evaluated: ret == QMessageBox::No | 0 |
764 | return false; never executed: return false; | 0 |
765 | } | 0 |
766 | if (opened) { | 0 |
767 | f.close(); never executed (the execution status of this line is deduced): f.close(); | - |
768 | if (!exists) | 0 |
769 | f.remove(); never executed: f.remove(); | 0 |
770 | } | 0 |
771 | } | 0 |
772 | | - |
773 | // Every test passed. Accept the dialog. | - |
774 | return true; never executed: return true; | 0 |
775 | } | - |
776 | #endif // QT_NO_MESSAGEBOX | - |
777 | | - |
778 | void QUnixPrintWidgetPrivate::setupPrinterProperties() | - |
779 | { | - |
780 | if (propertiesDialog) never evaluated: propertiesDialog | 0 |
781 | delete propertiesDialog; never executed: delete propertiesDialog; | 0 |
782 | | - |
783 | propertiesDialog = new QPrintPropertiesDialog(q); never executed (the execution status of this line is deduced): propertiesDialog = new QPrintPropertiesDialog(q); | - |
784 | propertiesDialog->setResult(QDialog::Rejected); never executed (the execution status of this line is deduced): propertiesDialog->setResult(QDialog::Rejected); | - |
785 | propertiesDialogShown = false; never executed (the execution status of this line is deduced): propertiesDialogShown = false; | - |
786 | | - |
787 | propertiesDialog->applyPrinterProperties(q->printer()); never executed (the execution status of this line is deduced): propertiesDialog->applyPrinterProperties(q->printer()); | - |
788 | | - |
789 | if (q->isOptionEnabled(QPrintDialog::PrintToFile) never evaluated: q->isOptionEnabled(QPrintDialog::PrintToFile) | 0 |
790 | && (widget.printers->currentIndex() == widget.printers->count() - 1)) {// PDF never evaluated: (widget.printers->currentIndex() == widget.printers->count() - 1) | 0 |
791 | propertiesDialog->selectPdfPsPrinter(q->printer()); never executed (the execution status of this line is deduced): propertiesDialog->selectPdfPsPrinter(q->printer()); | - |
792 | } | 0 |
793 | else | - |
794 | propertiesDialog->selectPrinter(); never executed: propertiesDialog->selectPrinter(); | 0 |
795 | } | - |
796 | | - |
797 | void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked() | - |
798 | { | - |
799 | if (!propertiesDialog) never evaluated: !propertiesDialog | 0 |
800 | setupPrinterProperties(); never executed: setupPrinterProperties(); | 0 |
801 | propertiesDialog->exec(); never executed (the execution status of this line is deduced): propertiesDialog->exec(); | - |
802 | if (propertiesDialog->result() == QDialog::Rejected) { never evaluated: propertiesDialog->result() == QDialog::Rejected | 0 |
803 | // If properties dialog was rejected the dialog is deleted and | - |
804 | // the properties are set to defaults when printer is setup | - |
805 | delete propertiesDialog; never executed (the execution status of this line is deduced): delete propertiesDialog; | - |
806 | propertiesDialog = 0; never executed (the execution status of this line is deduced): propertiesDialog = 0; | - |
807 | propertiesDialogShown = false; never executed (the execution status of this line is deduced): propertiesDialogShown = false; | - |
808 | } else | 0 |
809 | // properties dialog was shown and accepted | - |
810 | propertiesDialogShown = true; never executed: propertiesDialogShown = true; | 0 |
811 | } | - |
812 | | - |
813 | void QUnixPrintWidgetPrivate::setupPrinter() | - |
814 | { | - |
815 | const int printerCount = widget.printers->count(); never executed (the execution status of this line is deduced): const int printerCount = widget.printers->count(); | - |
816 | const int index = widget.printers->currentIndex(); never executed (the execution status of this line is deduced): const int index = widget.printers->currentIndex(); | - |
817 | | - |
818 | if (filePrintersAdded && index == printerCount - 1) { // PDF never evaluated: filePrintersAdded never evaluated: index == printerCount - 1 | 0 |
819 | printer->setPrinterName(QString()); never executed (the execution status of this line is deduced): printer->setPrinterName(QString()); | - |
820 | Q_ASSERT(index != printerCount - 2); // separator never executed (the execution status of this line is deduced): qt_noop(); | - |
821 | printer->setOutputFormat(QPrinter::PdfFormat); never executed (the execution status of this line is deduced): printer->setOutputFormat(QPrinter::PdfFormat); | - |
822 | QString path = widget.filename->text(); never executed (the execution status of this line is deduced): QString path = widget.filename->text(); | - |
823 | if (QDir::isRelativePath(path)) never evaluated: QDir::isRelativePath(path) | 0 |
824 | path = QDir::homePath() + QDir::separator() + path; never executed: path = QDir::homePath() + QDir::separator() + path; | 0 |
825 | printer->setOutputFileName(path); never executed (the execution status of this line is deduced): printer->setOutputFileName(path); | - |
826 | } | 0 |
827 | else { | - |
828 | printer->setPrinterName(widget.printers->currentText()); never executed (the execution status of this line is deduced): printer->setPrinterName(widget.printers->currentText()); | - |
829 | printer->setOutputFileName(QString()); never executed (the execution status of this line is deduced): printer->setOutputFileName(QString()); | - |
830 | } | 0 |
831 | | - |
832 | if (!propertiesDialog) never evaluated: !propertiesDialog | 0 |
833 | setupPrinterProperties(); never executed: setupPrinterProperties(); | 0 |
834 | | - |
835 | if (propertiesDialog->result() == QDialog::Accepted || !propertiesDialogShown) never evaluated: propertiesDialog->result() == QDialog::Accepted never evaluated: !propertiesDialogShown | 0 |
836 | propertiesDialog->setupPrinter(); never executed: propertiesDialog->setupPrinter(); | 0 |
837 | } | 0 |
838 | | - |
839 | /*! \internal | - |
840 | */ | - |
841 | QUnixPrintWidget::QUnixPrintWidget(QPrinter *printer, QWidget *parent) | - |
842 | : QWidget(parent), d(new QUnixPrintWidgetPrivate(this, printer)) | - |
843 | { | - |
844 | d->applyPrinterProperties(); executed (the execution status of this line is deduced): d->applyPrinterProperties(); | - |
845 | } executed: } Execution Count:3 | 3 |
846 | | - |
847 | /*! \internal | - |
848 | */ | - |
849 | QUnixPrintWidget::~QUnixPrintWidget() | - |
850 | { | - |
851 | delete d; executed (the execution status of this line is deduced): delete d; | - |
852 | } executed: } Execution Count:3 | 3 |
853 | | - |
854 | /*! \internal | - |
855 | | - |
856 | Updates the printer with the states held in the QUnixPrintWidget. | - |
857 | */ | - |
858 | void QUnixPrintWidget::updatePrinter() | - |
859 | { | - |
860 | d->setupPrinter(); never executed (the execution status of this line is deduced): d->setupPrinter(); | - |
861 | } | 0 |
862 | | - |
863 | //////////////////////////////////////////////////////////////////////////////// | - |
864 | //////////////////////////////////////////////////////////////////////////////// | - |
865 | | - |
866 | #endif // defined (Q_OS_UNIX) | - |
867 | | - |
868 | QT_END_NAMESPACE | - |
869 | | - |
870 | #include "moc_qprintdialog.cpp" | - |
871 | #include "qprintdialog_unix.moc" | - |
872 | | - |
873 | #endif // QT_NO_PRINTDIALOG | - |
874 | | - |
875 | | - |
| | |