qprintdialog_unix.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
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 The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://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 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qplatformdefs.h"-
41-
42#ifndef QT_NO_PRINTDIALOG-
43-
44#include "private/qabstractprintdialog_p.h"-
45#include <QtWidgets/qmessagebox.h>-
46#include "qprintdialog.h"-
47#include "qfiledialog.h"-
48#include <QtCore/qdir.h>-
49#include <QtGui/qevent.h>-
50#include <QtWidgets/qfilesystemmodel.h>-
51#include <QtWidgets/qstyleditemdelegate.h>-
52#include <QtPrintSupport/qprinter.h>-
53-
54#include <qpa/qplatformprintplugin.h>-
55#include <qpa/qplatformprintersupport.h>-
56-
57#include <private/qprintdevice_p.h>-
58-
59#include <QtWidgets/qdialogbuttonbox.h>-
60-
61#include "private/qfscompleter_p.h"-
62#include "ui_qprintpropertieswidget.h"-
63#include "ui_qprintsettingsoutput.h"-
64#include "ui_qprintwidget.h"-
65-
66#ifndef QT_NO_CUPS-
67#include <private/qcups_p.h>-
68#include "qcupsjobwidget_p.h"-
69#endif-
70-
71/*-
72-
73Print dialog class declarations-
74-
75 QPrintDialog: The main Print Dialog, nothing really held here.-
76-
77 QUnixPrintWidget:-
78 QUnixPrintWidgetPrivate: The real Unix Print Dialog implementation.-
79-
80 Directly includes the upper half of the Print Dialog-
81 containing the Printer Selection widgets and-
82 Properties button.-
83-
84 Embeds the Properties pop-up dialog from-
85 QPrintPropertiesDialog-
86-
87 Embeds the lower half from separate widget class-
88 QPrintDialogPrivate-
89-
90 Layout in qprintwidget.ui-
91-
92 QPrintDialogPrivate: The lower half of the Print Dialog containing the-
93 Copies and Options tabs that expands when the-
94 Options button is selected.-
95-
96 Layout in qprintsettingsoutput.ui-
97-
98 QPrintPropertiesDialog: Dialog displayed when clicking on Properties button to-
99 allow editing of Page and Advanced tabs.-
100-
101 Layout in qprintpropertieswidget.ui-
102*/-
103-
104static void initResources()-
105{-
106 Q_INIT_RESOURCE(qprintdialog);-
107}
executed 3 times by 1 test: end of block
Executed by:
  • tst_QPrinter
3
108-
109QT_BEGIN_NAMESPACE-
110-
111class QOptionTreeItem;-
112class QPPDOptionsModel;-
113-
114class QPrintPropertiesDialog : public QDialog-
115{-
116 Q_OBJECT-
117public:-
118 QPrintPropertiesDialog(QAbstractPrintDialog *parent = 0);-
119 ~QPrintPropertiesDialog();-
120-
121 void selectPrinter(QPrinter::OutputFormat outputFormat, const QString &printerName);-
122-
123 /// copy printer properties to the widget-
124 void applyPrinterProperties(QPrinter *p);-
125 void setupPrinter() const;-
126-
127private:-
128 friend class QUnixPrintWidgetPrivate;-
129 Ui::QPrintPropertiesWidget widget;-
130 QDialogButtonBox *m_buttons;-
131#ifndef QT_NO_CUPS-
132 QCupsJobWidget *m_jobOptions;-
133#endif-
134};-
135-
136class QUnixPrintWidgetPrivate;-
137-
138class QUnixPrintWidget : public QWidget-
139{-
140 Q_OBJECT-
141-
142public:-
143 explicit QUnixPrintWidget(QPrinter *printer, QWidget *parent = 0);-
144 ~QUnixPrintWidget();-
145 void updatePrinter();-
146-
147private:-
148 friend class QPrintDialogPrivate;-
149 friend class QUnixPrintWidgetPrivate;-
150 QUnixPrintWidgetPrivate *d;-
151 Q_PRIVATE_SLOT(d, void _q_printerChanged(int))-
152 Q_PRIVATE_SLOT(d, void _q_btnBrowseClicked())-
153 Q_PRIVATE_SLOT(d, void _q_btnPropertiesClicked())-
154};-
155-
156class QUnixPrintWidgetPrivate-
157{-
158public:-
159 QUnixPrintWidgetPrivate(QUnixPrintWidget *q, QPrinter *prn);-
160 ~QUnixPrintWidgetPrivate();-
161-
162 /// copy printer properties to the widget-
163 void applyPrinterProperties();-
164 bool checkFields();-
165 void setupPrinter();-
166 void setOptionsPane(QPrintDialogPrivate *pane);-
167 void setupPrinterProperties();-
168// slots-
169 void _q_printerChanged(int index);-
170 void _q_btnPropertiesClicked();-
171 void _q_btnBrowseClicked();-
172-
173 QUnixPrintWidget * const parent;-
174 QPrintPropertiesDialog *propertiesDialog;-
175 Ui::QPrintWidget widget;-
176 QAbstractPrintDialog * q;-
177 QPrinter *printer;-
178 QPrintDevice m_currentPrintDevice;-
179-
180 void updateWidget();-
181-
182private:-
183 QPrintDialogPrivate *optionsPane;-
184 bool filePrintersAdded;-
185 bool propertiesDialogShown;-
186};-
187-
188class QPrintDialogPrivate : public QAbstractPrintDialogPrivate-
189{-
190 Q_DECLARE_PUBLIC(QPrintDialog)-
191 Q_DECLARE_TR_FUNCTIONS(QPrintDialog)-
192public:-
193 QPrintDialogPrivate();-
194 ~QPrintDialogPrivate();-
195-
196 void init();-
197 /// copy printer properties to the widget-
198 void applyPrinterProperties();-
199-
200 void selectPrinter(const QPrinter::OutputFormat outputFormat);-
201-
202 void _q_togglePageSetCombo(bool);-
203#ifndef QT_NO_MESSAGEBOX-
204 void _q_checkFields();-
205#endif-
206 void _q_collapseOrExpandDialog();-
207-
208 void setupPrinter();-
209 void updateWidgets();-
210-
211 virtual void setTabs(const QList<QWidget*> &tabs) Q_DECL_OVERRIDE;-
212-
213 Ui::QPrintSettingsOutput options;-
214 QUnixPrintWidget *top;-
215 QWidget *bottom;-
216 QDialogButtonBox *buttons;-
217 QPushButton *collapseButton;-
218 QPrinter::OutputFormat printerOutputFormat;-
219};-
220-
221-
222////////////////////////////////////////////////////////////////////////////////-
223////////////////////////////////////////////////////////////////////////////////-
224-
225/*-
226-
227 QPrintPropertiesDialog-
228-
229 Dialog displayed when clicking on Properties button to allow editing of Page-
230 and Advanced tabs.-
231-
232*/-
233-
234QPrintPropertiesDialog::QPrintPropertiesDialog(QAbstractPrintDialog *parent)-
235 : QDialog(parent)-
236{-
237 setWindowTitle(tr("Printer Properties"));-
238 QVBoxLayout *lay = new QVBoxLayout(this);-
239 this->setLayout(lay);-
240 QWidget *content = new QWidget(this);-
241 widget.setupUi(content);-
242 m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);-
243 lay->addWidget(content);-
244 lay->addWidget(m_buttons);-
245-
246 connect(m_buttons->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept()));-
247 connect(m_buttons->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject()));-
248-
249#ifndef QT_NO_CUPS-
250 m_jobOptions = new QCupsJobWidget();-
251 widget.tabs->addTab(m_jobOptions, tr("Job Options"));-
252#endif-
253}
never executed: end of block
0
254-
255QPrintPropertiesDialog::~QPrintPropertiesDialog()-
256{-
257}-
258-
259void QPrintPropertiesDialog::applyPrinterProperties(QPrinter *p)-
260{-
261 widget.pageSetup->setPrinter(p);-
262#ifndef QT_NO_CUPS-
263 m_jobOptions->setPrinter(p);-
264#endif-
265}
never executed: end of block
0
266-
267void QPrintPropertiesDialog::setupPrinter() const-
268{-
269 widget.pageSetup->setupPrinter();-
270#ifndef QT_NO_CUPS-
271 m_jobOptions->setupPrinter();-
272#endif-
273}
never executed: end of block
0
274-
275void QPrintPropertiesDialog::selectPrinter(QPrinter::OutputFormat outputFormat, const QString &printerName)-
276{-
277 widget.pageSetup->selectPrinter(outputFormat, printerName);-
278}
never executed: end of block
0
279-
280////////////////////////////////////////////////////////////////////////////////-
281////////////////////////////////////////////////////////////////////////////////-
282-
283/*-
284-
285 QPrintDialogPrivate-
286-
287 The lower half of the Print Dialog containing the Copies and Options-
288 tabs that expands when the Options button is selected.-
289-
290*/-
291QPrintDialogPrivate::QPrintDialogPrivate()-
292 : top(0), bottom(0), buttons(0), collapseButton(0)-
293{-
294 initResources();-
295}
executed 3 times by 1 test: end of block
Executed by:
  • tst_QPrinter
3
296-
297QPrintDialogPrivate::~QPrintDialogPrivate()-
298{-
299}-
300-
301void QPrintDialogPrivate::init()-
302{-
303 Q_Q(QPrintDialog);-
304-
305 top = new QUnixPrintWidget(q->printer(), q);-
306 bottom = new QWidget(q);-
307 options.setupUi(bottom);-
308 options.color->setIconSize(QSize(32, 32));-
309 options.color->setIcon(QIcon(QLatin1String(":/qt-project.org/dialogs/qprintdialog/images/status-color.png")));-
310 options.grayscale->setIconSize(QSize(32, 32));-
311 options.grayscale->setIcon(QIcon(QLatin1String(":/qt-project.org/dialogs/qprintdialog/images/status-gray-scale.png")));-
312-
313#ifndef QT_NO_CUPS-
314 // Add Page Set widget if CUPS is available-
315 options.pageSetCombo->addItem(tr("All Pages"), QVariant::fromValue(QCUPSSupport::AllPages));-
316 options.pageSetCombo->addItem(tr("Odd Pages"), QVariant::fromValue(QCUPSSupport::OddPages));-
317 options.pageSetCombo->addItem(tr("Even Pages"), QVariant::fromValue(QCUPSSupport::EvenPages));-
318#endif-
319-
320 top->d->setOptionsPane(this);-
321-
322 buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, q);-
323 collapseButton = new QPushButton(QPrintDialog::tr("&Options >>"), buttons);-
324 buttons->addButton(collapseButton, QDialogButtonBox::ResetRole);-
325 bottom->setVisible(false);-
326-
327 QPushButton *printButton = buttons->button(QDialogButtonBox::Ok);-
328 printButton->setText(QPrintDialog::tr("&Print"));-
329 printButton->setDefault(true);-
330-
331 QVBoxLayout *lay = new QVBoxLayout(q);-
332 q->setLayout(lay);-
333 lay->addWidget(top);-
334 lay->addWidget(bottom);-
335 lay->addWidget(buttons);-
336-
337#ifdef QT_NO_MESSAGEBOX-
338 QObject::connect(buttons, SIGNAL(accepted()), q, SLOT(accept()));-
339#else-
340 QObject::connect(buttons, SIGNAL(accepted()), q, SLOT(_q_checkFields()));-
341#endif-
342 QObject::connect(buttons, SIGNAL(rejected()), q, SLOT(reject()));-
343-
344 QObject::connect(options.printSelection, SIGNAL(toggled(bool)),-
345 q, SLOT(_q_togglePageSetCombo(bool)));-
346-
347 QObject::connect(options.printCurrentPage, SIGNAL(toggled(bool)),-
348 q, SLOT(_q_togglePageSetCombo(bool)));-
349-
350 QObject::connect(collapseButton, SIGNAL(released()), q, SLOT(_q_collapseOrExpandDialog()));-
351}
executed 3 times by 1 test: end of block
Executed by:
  • tst_QPrinter
3
352-
353// initialize printer options-
354void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputFormat)-
355{-
356 Q_Q(QPrintDialog);-
357 QPrinter *p = q->printer();-
358 printerOutputFormat = outputFormat;-
359-
360 if (p->colorMode() == QPrinter::Color)
p->colorMode()...Printer::ColorDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-4
361 options.color->setChecked(true);
executed 4 times by 1 test: options.color->setChecked(true);
Executed by:
  • tst_QPrinter
4
362 else-
363 options.grayscale->setChecked(true);
never executed: options.grayscale->setChecked(true);
0
364-
365 switch (p->duplex()) {-
366 case QPrinter::DuplexNone:
executed 4 times by 1 test: case QPrinter::DuplexNone:
Executed by:
  • tst_QPrinter
4
367 options.noDuplex->setChecked(true); break;
executed 4 times by 1 test: break;
Executed by:
  • tst_QPrinter
4
368 case QPrinter::DuplexLongSide:
never executed: case QPrinter::DuplexLongSide:
0
369 case QPrinter::DuplexAuto:
never executed: case QPrinter::DuplexAuto:
0
370 options.duplexLong->setChecked(true); break;
never executed: break;
0
371 case QPrinter::DuplexShortSide:
never executed: case QPrinter::DuplexShortSide:
0
372 options.duplexShort->setChecked(true); break;
never executed: break;
0
373 }-
374 options.copies->setValue(p->copyCount());-
375 options.collate->setChecked(p->collateCopies());-
376 options.reverse->setChecked(p->pageOrder() == QPrinter::LastPageFirst);-
377-
378 if (outputFormat == QPrinter::PdfFormat || options.printSelection->isChecked()
outputFormat =...ter::PdfFormatDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QPrinter
options.printS...n->isChecked()Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QPrinter
0-4
379 || options.printCurrentPage->isChecked())
options.printC...e->isChecked()Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QPrinter
0-4
380-
381 options.pageSetCombo->setEnabled(false);
never executed: options.pageSetCombo->setEnabled(false);
0
382 else-
383 options.pageSetCombo->setEnabled(true);
executed 4 times by 1 test: options.pageSetCombo->setEnabled(true);
Executed by:
  • tst_QPrinter
4
384}-
385-
386void QPrintDialogPrivate::applyPrinterProperties()-
387{-
388 // apply printer options to property dialog-
389 top->d->applyPrinterProperties();-
390}
never executed: end of block
0
391-
392void QPrintDialogPrivate::setupPrinter()-
393{-
394 // First setup the requested OutputFormat, Printer and Page Size first-
395 top->d->setupPrinter();-
396-
397 // Then setup Print Job options-
398 Q_Q(QPrintDialog);-
399 QPrinter* p = q->printer();-
400-
401 if (options.duplex->isEnabled()) {
options.duplex->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
402 if (options.noDuplex->isChecked())
options.noDuplex->isChecked()Description
TRUEnever evaluated
FALSEnever evaluated
0
403 p->setDuplex(QPrinter::DuplexNone);
never executed: p->setDuplex(QPrinter::DuplexNone);
0
404 else if (options.duplexLong->isChecked())
options.duplex...g->isChecked()Description
TRUEnever evaluated
FALSEnever evaluated
0
405 p->setDuplex(QPrinter::DuplexLongSide);
never executed: p->setDuplex(QPrinter::DuplexLongSide);
0
406 else-
407 p->setDuplex(QPrinter::DuplexShortSide);
never executed: p->setDuplex(QPrinter::DuplexShortSide);
0
408 }-
409-
410 p->setColorMode(options.color->isChecked() ? QPrinter::Color : QPrinter::GrayScale);-
411 p->setPageOrder(options.reverse->isChecked() ? QPrinter::LastPageFirst : QPrinter::FirstPageFirst);-
412-
413 // print range-
414 if (options.printAll->isChecked()) {
options.printAll->isChecked()Description
TRUEnever evaluated
FALSEnever evaluated
0
415 p->setPrintRange(QPrinter::AllPages);-
416 p->setFromTo(0,0);-
417 } else if (options.printSelection->isChecked()) {
never executed: end of block
options.printS...n->isChecked()Description
TRUEnever evaluated
FALSEnever evaluated
0
418 p->setPrintRange(QPrinter::Selection);-
419 p->setFromTo(0,0);-
420 } else if (options.printCurrentPage->isChecked()) {
never executed: end of block
options.printC...e->isChecked()Description
TRUEnever evaluated
FALSEnever evaluated
0
421 p->setPrintRange(QPrinter::CurrentPage);-
422 p->setFromTo(0,0);-
423 } else if (options.printRange->isChecked()) {
never executed: end of block
options.printR...e->isChecked()Description
TRUEnever evaluated
FALSEnever evaluated
0
424 if (q->isOptionEnabled(QPrintDialog::PrintPageRange)) {
q->isOptionEna...rintPageRange)Description
TRUEnever evaluated
FALSEnever evaluated
0
425 p->setPrintRange(QPrinter::PageRange);-
426 p->setFromTo(options.from->value(), qMax(options.from->value(), options.to->value()));-
427 } else {
never executed: end of block
0
428 // This case happens when CUPS server-side page range is enabled-
429 // Setting the range to the printer occurs below-
430 p->setPrintRange(QPrinter::AllPages);-
431 p->setFromTo(0,0);-
432 }
never executed: end of block
0
433 }-
434-
435#ifndef QT_NO_CUPS-
436 // page set-
437 if (p->printRange() == QPrinter::AllPages || p->printRange() == QPrinter::PageRange) {
p->printRange(...nter::AllPagesDescription
TRUEnever evaluated
FALSEnever evaluated
p->printRange(...ter::PageRangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
438 //If the application is selecting pages and the first page number is even then need to adjust the odd-even accordingly-
439 QCUPSSupport::PageSet pageSet = options.pageSetCombo->itemData(options.pageSetCombo->currentIndex()).value<QCUPSSupport::PageSet>();-
440 if (q->isOptionEnabled(QPrintDialog::PrintPageRange)
q->isOptionEna...rintPageRange)Description
TRUEnever evaluated
FALSEnever evaluated
0
441 && p->printRange() == QPrinter::PageRange
p->printRange(...ter::PageRangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
442 && (q->fromPage() % 2 == 0)) {
(q->fromPage() % 2 == 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
443-
444 switch (pageSet) {-
445 case QCUPSSupport::AllPages:
never executed: case QCUPSSupport::AllPages:
0
446 break;
never executed: break;
0
447 case QCUPSSupport::OddPages:
never executed: case QCUPSSupport::OddPages:
0
448 QCUPSSupport::setPageSet(p, QCUPSSupport::EvenPages);-
449 break;
never executed: break;
0
450 case QCUPSSupport::EvenPages:
never executed: case QCUPSSupport::EvenPages:
0
451 QCUPSSupport::setPageSet(p, QCUPSSupport::OddPages);-
452 break;
never executed: break;
0
453 }-
454 } else if (pageSet != QCUPSSupport::AllPages) {
never executed: end of block
pageSet != QCU...port::AllPagesDescription
TRUEnever evaluated
FALSEnever evaluated
0
455 QCUPSSupport::setPageSet(p, pageSet);-
456 }
never executed: end of block
0
457-
458 // server-side page range, since we set the page range on the printer to 0-0/AllPages above,-
459 // we need to take the values directly from the widget as q->fromPage() will return 0-
460 if (!q->isOptionEnabled(QPrintDialog::PrintPageRange) && options.printRange->isChecked())
!q->isOptionEn...rintPageRange)Description
TRUEnever evaluated
FALSEnever evaluated
options.printR...e->isChecked()Description
TRUEnever evaluated
FALSEnever evaluated
0
461 QCUPSSupport::setPageRange(p, options.from->value(), qMax(options.from->value(), options.to->value()));
never executed: QCUPSSupport::setPageRange(p, options.from->value(), qMax(options.from->value(), options.to->value()));
0
462 }
never executed: end of block
0
463#endif-
464-
465 // copies-
466 p->setCopyCount(options.copies->value());-
467 p->setCollateCopies(options.collate->isChecked());-
468}
never executed: end of block
0
469-
470void QPrintDialogPrivate::_q_togglePageSetCombo(bool checked)-
471{-
472 if (printerOutputFormat == QPrinter::PdfFormat)
printerOutputF...ter::PdfFormatDescription
TRUEnever evaluated
FALSEnever evaluated
0
473 return;
never executed: return;
0
474-
475 options.pageSetCombo->setDisabled(checked);-
476}
never executed: end of block
0
477-
478void QPrintDialogPrivate::_q_collapseOrExpandDialog()-
479{-
480 int collapseHeight = 0;-
481 Q_Q(QPrintDialog);-
482 QWidget *widgetToHide = bottom;-
483 if (widgetToHide->isVisible()) {
widgetToHide->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
484 collapseButton->setText(QPrintDialog::tr("&Options >>"));-
485 collapseHeight = widgetToHide->y() + widgetToHide->height() - (top->y() + top->height());-
486 }
never executed: end of block
0
487 else-
488 collapseButton->setText(QPrintDialog::tr("&Options <<"));
never executed: collapseButton->setText(QPrintDialog::tr("&Options <<"));
0
489 widgetToHide->setVisible(! widgetToHide->isVisible());-
490 if (! widgetToHide->isVisible()) { // make it shrink
! widgetToHide->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
491 q->layout()->activate();-
492 q->resize( QSize(q->width(), q->height() - collapseHeight) );-
493 }
never executed: end of block
0
494}
never executed: end of block
0
495-
496#ifndef QT_NO_MESSAGEBOX-
497void QPrintDialogPrivate::_q_checkFields()-
498{-
499 Q_Q(QPrintDialog);-
500 if (top->d->checkFields())
top->d->checkFields()Description
TRUEnever evaluated
FALSEnever evaluated
0
501 q->accept();
never executed: q->accept();
0
502}
never executed: end of block
0
503#endif // QT_NO_MESSAGEBOX-
504-
505-
506void QPrintDialogPrivate::updateWidgets()-
507{-
508 Q_Q(QPrintDialog);-
509 options.gbPrintRange->setVisible(q->isOptionEnabled(QPrintDialog::PrintPageRange) ||-
510 q->isOptionEnabled(QPrintDialog::PrintSelection) ||-
511 q->isOptionEnabled(QPrintDialog::PrintCurrentPage));-
512-
513 options.printRange->setEnabled(q->isOptionEnabled(QPrintDialog::PrintPageRange));-
514 options.printSelection->setVisible(q->isOptionEnabled(QPrintDialog::PrintSelection));-
515 options.printCurrentPage->setVisible(q->isOptionEnabled(QPrintDialog::PrintCurrentPage));-
516 options.collate->setVisible(q->isOptionEnabled(QPrintDialog::PrintCollateCopies));-
517-
518#ifndef QT_NO_CUPS-
519 // Don't display Page Set if only Selection or Current Page are enabled-
520 if (!q->isOptionEnabled(QPrintDialog::PrintPageRange)
!q->isOptionEn...rintPageRange)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-1
521 && (q->isOptionEnabled(QPrintDialog::PrintSelection) || q->isOptionEnabled(QPrintDialog::PrintCurrentPage))) {
q->isOptionEna...rintSelection)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
q->isOptionEna...ntCurrentPage)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
0-1
522 options.pageSetCombo->setVisible(false);-
523 options.pageSetLabel->setVisible(false);-
524 } else {
never executed: end of block
0
525 options.pageSetCombo->setVisible(true);-
526 options.pageSetLabel->setVisible(true);-
527 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
528-
529 if (!q->isOptionEnabled(QPrintDialog::PrintPageRange)) {
!q->isOptionEn...rintPageRange)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-1
530 // If we can do CUPS server side pages selection,-
531 // display the page range widgets-
532 options.gbPrintRange->setVisible(true);-
533 options.printRange->setEnabled(true);-
534 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
535#endif-
536-
537 switch (q->printRange()) {-
538 case QPrintDialog::AllPages:
executed 1 time by 1 test: case QPrintDialog::AllPages:
Executed by:
  • tst_QPrinter
1
539 options.printAll->setChecked(true);-
540 options.pageSetCombo->setEnabled(true);-
541 break;
executed 1 time by 1 test: break;
Executed by:
  • tst_QPrinter
1
542 case QPrintDialog::Selection:
never executed: case QPrintDialog::Selection:
0
543 options.printSelection->setChecked(true);-
544 options.pageSetCombo->setEnabled(false);-
545 break;
never executed: break;
0
546 case QPrintDialog::PageRange:
never executed: case QPrintDialog::PageRange:
0
547 options.printRange->setChecked(true);-
548 options.pageSetCombo->setEnabled(true);-
549 break;
never executed: break;
0
550 case QPrintDialog::CurrentPage:
never executed: case QPrintDialog::CurrentPage:
0
551 if (q->isOptionEnabled(QPrintDialog::PrintCurrentPage)) {
q->isOptionEna...ntCurrentPage)Description
TRUEnever evaluated
FALSEnever evaluated
0
552 options.printCurrentPage->setChecked(true);-
553 options.pageSetCombo->setEnabled(false);-
554 }
never executed: end of block
0
555 break;
never executed: break;
0
556 default:
never executed: default:
0
557 break;
never executed: break;
0
558 }-
559 const int minPage = qMax(1, qMin(q->minPage() , q->maxPage()));-
560 const int maxPage = qMax(1, q->maxPage() == INT_MAX ? 9999 : q->maxPage());-
561-
562 options.from->setMinimum(minPage);-
563 options.to->setMinimum(minPage);-
564 options.from->setMaximum(maxPage);-
565 options.to->setMaximum(maxPage);-
566-
567 options.from->setValue(q->fromPage());-
568 options.to->setValue(q->toPage());-
569 top->d->updateWidget();-
570}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
571-
572void QPrintDialogPrivate::setTabs(const QList<QWidget*> &tabWidgets)-
573{-
574 QList<QWidget*>::ConstIterator iter = tabWidgets.begin();-
575 while(iter != tabWidgets.constEnd()) {
iter != tabWidgets.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
576 QWidget *tab = *iter;-
577 options.tabs->addTab(tab, tab->windowTitle());-
578 ++iter;-
579 }
never executed: end of block
0
580}
never executed: end of block
0
581-
582////////////////////////////////////////////////////////////////////////////////-
583////////////////////////////////////////////////////////////////////////////////-
584-
585/*-
586-
587 QPrintDialog-
588-
589 The main Print Dialog.-
590-
591*/-
592-
593QPrintDialog::QPrintDialog(QPrinter *printer, QWidget *parent)-
594 : QAbstractPrintDialog(*(new QPrintDialogPrivate), printer, parent)-
595{-
596 Q_D(QPrintDialog);-
597 d->init();-
598}
executed 2 times by 1 test: end of block
Executed by:
  • tst_QPrinter
2
599-
600/*!-
601 Constructs a print dialog with the given \a parent.-
602*/-
603QPrintDialog::QPrintDialog(QWidget *parent)-
604 : QAbstractPrintDialog(*(new QPrintDialogPrivate), 0, parent)-
605{-
606 Q_D(QPrintDialog);-
607 d->init();-
608}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
609-
610QPrintDialog::~QPrintDialog()-
611{-
612}-
613-
614void QPrintDialog::setVisible(bool visible)-
615{-
616 Q_D(QPrintDialog);-
617-
618 if (visible)
visibleDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-1
619 d->updateWidgets();
executed 1 time by 1 test: d->updateWidgets();
Executed by:
  • tst_QPrinter
1
620-
621 QAbstractPrintDialog::setVisible(visible);-
622}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
623-
624int QPrintDialog::exec()-
625{-
626 return QDialog::exec();
never executed: return QDialog::exec();
0
627}-
628-
629void QPrintDialog::accept()-
630{-
631 Q_D(QPrintDialog);-
632 d->setupPrinter();-
633 QDialog::accept();-
634}
never executed: end of block
0
635-
636////////////////////////////////////////////////////////////////////////////////-
637////////////////////////////////////////////////////////////////////////////////-
638-
639/*-
640-
641 QUnixPrintWidget && QUnixPrintWidgetPrivate-
642-
643 The upper half of the Print Dialog containing the Printer Selection widgets-
644-
645*/-
646-
647#if defined (Q_OS_UNIX)-
648-
649/*! \internal-
650*/-
651QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p, QPrinter *prn)-
652 : parent(p), propertiesDialog(0), printer(prn), optionsPane(0),-
653 filePrintersAdded(false), propertiesDialogShown(false)-
654{-
655 q = 0;-
656 if (parent)
parentDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-3
657 q = qobject_cast<QAbstractPrintDialog*> (parent->parent());
executed 3 times by 1 test: q = qobject_cast<QAbstractPrintDialog*> (parent->parent());
Executed by:
  • tst_QPrinter
3
658-
659 widget.setupUi(parent);-
660-
661 int currentPrinterIndex = 0;-
662 QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();-
663 if (ps) {
psDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-3
664 const QStringList printers = ps->availablePrintDeviceIds();-
665 const QString defaultPrinter = ps->defaultPrintDeviceId();-
666-
667 widget.printers->addItems(printers);-
668-
669 const int idx = printers.indexOf(defaultPrinter);-
670 if (idx >= 0)
idx >= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QPrinter
0-3
671 currentPrinterIndex = idx;
never executed: currentPrinterIndex = idx;
0
672 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_QPrinter
3
673 widget.properties->setEnabled(true);-
674-
675#if !defined(QT_NO_FILESYSTEMMODEL) && !defined(QT_NO_COMPLETER)-
676 QFileSystemModel *fsm = new QFileSystemModel(widget.filename);-
677 fsm->setRootPath(QDir::homePath());-
678 widget.filename->setCompleter(new QCompleter(fsm, widget.filename));-
679#endif-
680 _q_printerChanged(currentPrinterIndex);-
681-
682 QObject::connect(widget.printers, SIGNAL(currentIndexChanged(int)),-
683 parent, SLOT(_q_printerChanged(int)));-
684 QObject::connect(widget.fileBrowser, SIGNAL(clicked()), parent, SLOT(_q_btnBrowseClicked()));-
685 QObject::connect(widget.properties, SIGNAL(clicked()), parent, SLOT(_q_btnPropertiesClicked()));-
686-
687 // disable features that QPrinter does not yet support.-
688 widget.preview->setVisible(false);-
689}
executed 3 times by 1 test: end of block
Executed by:
  • tst_QPrinter
3
690-
691void QUnixPrintWidgetPrivate::updateWidget()-
692{-
693 const bool printToFile = q == 0 || q->isOptionEnabled(QPrintDialog::PrintToFile);
q == 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
q->isOptionEna...::PrintToFile)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-1
694 if (printToFile && !filePrintersAdded) {
printToFileDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
!filePrintersAddedDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-1
695 if (widget.printers->count())
widget.printers->count()Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
0-1
696 widget.printers->insertSeparator(widget.printers->count());
never executed: widget.printers->insertSeparator(widget.printers->count());
0
697 widget.printers->addItem(QPrintDialog::tr("Print to File (PDF)"));-
698 filePrintersAdded = true;-
699 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
700 if (!printToFile && filePrintersAdded) {
!printToFileDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
filePrintersAddedDescription
TRUEnever evaluated
FALSEnever evaluated
0-1
701 widget.printers->removeItem(widget.printers->count()-1);-
702 widget.printers->removeItem(widget.printers->count()-1);-
703 if (widget.printers->count())
widget.printers->count()Description
TRUEnever evaluated
FALSEnever evaluated
0
704 widget.printers->removeItem(widget.printers->count()-1); // remove separator
never executed: widget.printers->removeItem(widget.printers->count()-1);
0
705 filePrintersAdded = false;-
706 }
never executed: end of block
0
707 if (printer && filePrintersAdded && (printer->outputFormat() != QPrinter::NativeFormat
printerDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
filePrintersAddedDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
printer->outpu...::NativeFormatDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-1
708 || printer->printerName().isEmpty()))
printer->print...me().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
709 {-
710 if (printer->outputFormat() == QPrinter::PdfFormat)
printer->outpu...ter::PdfFormatDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-1
711 widget.printers->setCurrentIndex(widget.printers->count() - 1);
executed 1 time by 1 test: widget.printers->setCurrentIndex(widget.printers->count() - 1);
Executed by:
  • tst_QPrinter
1
712 widget.filename->setEnabled(true);-
713 widget.lOutput->setEnabled(true);-
714 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
715-
716 widget.filename->setVisible(printToFile);-
717 widget.lOutput->setVisible(printToFile);-
718 widget.fileBrowser->setVisible(printToFile);-
719-
720 widget.properties->setVisible(q->isOptionEnabled(QAbstractPrintDialog::PrintShowPageSize));-
721}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QPrinter
1
722-
723QUnixPrintWidgetPrivate::~QUnixPrintWidgetPrivate()-
724{-
725}-
726-
727void QUnixPrintWidgetPrivate::_q_printerChanged(int index)-
728{-
729 if (index < 0)
index < 0Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QPrinter
0-4
730 return;
never executed: return;
0
731 const int printerCount = widget.printers->count();-
732 widget.filename->setEnabled(false);-
733 widget.lOutput->setEnabled(false);-
734-
735 // Reset properties dialog when printer is changed-
736 if (propertiesDialog){
propertiesDialogDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QPrinter
0-4
737 delete propertiesDialog;-
738 propertiesDialog = 0;-
739 propertiesDialogShown = false;-
740 }
never executed: end of block
0
741-
742 if (filePrintersAdded) {
filePrintersAddedDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QPrinter
0-4
743 Q_ASSERT(index != printerCount - 2); // separator-
744 if (index == printerCount - 1) { // PDF
index == printerCount - 1Description
TRUEnever evaluated
FALSEnever evaluated
0
745 widget.location->setText(QPrintDialog::tr("Local file"));-
746 widget.type->setText(QPrintDialog::tr("Write PDF file"));-
747 widget.properties->setEnabled(true);-
748 widget.filename->setEnabled(true);-
749 QString filename = widget.filename->text();-
750 widget.filename->setText(filename);-
751 widget.lOutput->setEnabled(true);-
752 if (optionsPane)
optionsPaneDescription
TRUEnever evaluated
FALSEnever evaluated
0
753 optionsPane->selectPrinter(QPrinter::PdfFormat);
never executed: optionsPane->selectPrinter(QPrinter::PdfFormat);
0
754 return;
never executed: return;
0
755 }-
756 }
never executed: end of block
0
757-
758 if (printer) {
printerDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-4
759 QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();-
760 if (ps)
psDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-4
761 m_currentPrintDevice = ps->createPrintDevice(widget.printers->itemText(index));
executed 4 times by 1 test: m_currentPrintDevice = ps->createPrintDevice(widget.printers->itemText(index));
Executed by:
  • tst_QPrinter
4
762-
763 printer->setPrinterName(m_currentPrintDevice.id());-
764-
765 widget.location->setText(m_currentPrintDevice.location());-
766 widget.type->setText(m_currentPrintDevice.makeAndModel());-
767 if (optionsPane)
optionsPaneDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QPrinter
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QPrinter
1-3
768 optionsPane->selectPrinter(QPrinter::NativeFormat);
executed 1 time by 1 test: optionsPane->selectPrinter(QPrinter::NativeFormat);
Executed by:
  • tst_QPrinter
1
769 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_QPrinter
4
770}
executed 4 times by 1 test: end of block
Executed by:
  • tst_QPrinter
4
771-
772void QUnixPrintWidgetPrivate::setOptionsPane(QPrintDialogPrivate *pane)-
773{-
774 optionsPane = pane;-
775 if (optionsPane)
optionsPaneDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-3
776 optionsPane->selectPrinter(QPrinter::NativeFormat);
executed 3 times by 1 test: optionsPane->selectPrinter(QPrinter::NativeFormat);
Executed by:
  • tst_QPrinter
3
777}
executed 3 times by 1 test: end of block
Executed by:
  • tst_QPrinter
3
778-
779void QUnixPrintWidgetPrivate::_q_btnBrowseClicked()-
780{-
781 QString filename = widget.filename->text();-
782#ifndef QT_NO_FILEDIALOG-
783 filename = QFileDialog::getSaveFileName(parent, QPrintDialog::tr("Print To File ..."), filename,-
784 QString(), 0, QFileDialog::DontConfirmOverwrite);-
785#else-
786 filename.clear();-
787#endif-
788 if (!filename.isEmpty()) {
!filename.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
789 widget.filename->setText(filename);-
790 widget.printers->setCurrentIndex(widget.printers->count() - 1); // the pdf one-
791 }
never executed: end of block
0
792}
never executed: end of block
0
793-
794void QUnixPrintWidgetPrivate::applyPrinterProperties()-
795{-
796 if (printer == 0)
printer == 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QPrinter
0-3
797 return;
never executed: return;
0
798 if (printer->outputFileName().isEmpty()) {
printer->outpu...me().isEmpty()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-3
799 QString home = QDir::homePath();-
800 QString cur = QDir::currentPath();-
801 if (home.at(home.length()-1) != QLatin1Char('/'))
home.at(home.l...atin1Char('/')Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-3
802 home += QLatin1Char('/');
executed 3 times by 1 test: home += QLatin1Char('/');
Executed by:
  • tst_QPrinter
3
803 if (!cur.isEmpty() && cur.at(cur.length()-1) != QLatin1Char('/'))
!cur.isEmpty()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
cur.at(cur.len...atin1Char('/')Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-3
804 cur += QLatin1Char('/');
executed 3 times by 1 test: cur += QLatin1Char('/');
Executed by:
  • tst_QPrinter
3
805 if (!cur.startsWith(home))
!cur.startsWith(home)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QPrinter
0-3
806 cur = home;
never executed: cur = home;
0
807 if (QGuiApplication::platformName() == QLatin1String("xcb")) {
QGuiApplicatio...1String("xcb")Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-3
808 if (printer->docName().isEmpty()) {
printer->docName().isEmpty()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QPrinter
FALSEnever evaluated
0-3
809 cur += QLatin1String("print.pdf");-
810 } else {
executed 3 times by 1 test: end of block
Executed by:
  • tst_QPrinter
3
811 QRegExp re(QString::fromLatin1("(.*)\\.\\S+"));-
812 if (re.exactMatch(printer->docName()))
re.exactMatch(...er->docName())Description
TRUEnever evaluated
FALSEnever evaluated
0
813 cur += re.cap(1);
never executed: cur += re.cap(1);
0
814 else-
815 cur += printer->docName();
never executed: cur += printer->docName();
0
816 cur += QLatin1String(".pdf");-
817 }
never executed: end of block
0
818 } // xcb-
819-
820 widget.filename->setText(cur);-
821 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_QPrinter
3
822 else-
823 widget.filename->setText( printer->outputFileName() );
never executed: widget.filename->setText( printer->outputFileName() );
0
824 QString printerName = printer->printerName();-
825 if (!printerName.isEmpty()) {
!printerName.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QPrinter
0-3
826 const int i = widget.printers->findText(printerName);-
827 if (i >= 0)
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
828 widget.printers->setCurrentIndex(i);
never executed: widget.printers->setCurrentIndex(i);
0
829 }
never executed: end of block
0
830 // PDF printer not added to the dialog yet, we'll handle those cases in QUnixPrintWidgetPrivate::updateWidget-
831-
832 if (propertiesDialog)
propertiesDialogDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QPrinter
0-3
833 propertiesDialog->applyPrinterProperties(printer);
never executed: propertiesDialog->applyPrinterProperties(printer);
0
834}
executed 3 times by 1 test: end of block
Executed by:
  • tst_QPrinter
3
835-
836#ifndef QT_NO_MESSAGEBOX-
837bool QUnixPrintWidgetPrivate::checkFields()-
838{-
839 if (widget.filename->isEnabled()) {
widget.filename->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
840 QString file = widget.filename->text();-
841 QFile f(file);-
842 QFileInfo fi(f);-
843 bool exists = fi.exists();-
844 bool opened = false;-
845 if (exists && fi.isDir()) {
existsDescription
TRUEnever evaluated
FALSEnever evaluated
fi.isDir()Description
TRUEnever evaluated
FALSEnever evaluated
0
846 QMessageBox::warning(q, q->windowTitle(),-
847 QPrintDialog::tr("%1 is a directory.\nPlease choose a different file name.").arg(file));-
848 return false;
never executed: return false;
0
849 } else if ((exists && !fi.isWritable()) || !(opened = f.open(QFile::Append))) {
existsDescription
TRUEnever evaluated
FALSEnever evaluated
!fi.isWritable()Description
TRUEnever evaluated
FALSEnever evaluated
!(opened = f.o...File::Append))Description
TRUEnever evaluated
FALSEnever evaluated
0
850 QMessageBox::warning(q, q->windowTitle(),-
851 QPrintDialog::tr("File %1 is not writable.\nPlease choose a different file name.").arg(file));-
852 return false;
never executed: return false;
0
853 } else if (exists) {
existsDescription
TRUEnever evaluated
FALSEnever evaluated
0
854 int ret = QMessageBox::question(q, q->windowTitle(),-
855 QPrintDialog::tr("%1 already exists.\nDo you want to overwrite it?").arg(file),-
856 QMessageBox::Yes|QMessageBox::No, QMessageBox::No);-
857 if (ret == QMessageBox::No)
ret == QMessageBox::NoDescription
TRUEnever evaluated
FALSEnever evaluated
0
858 return false;
never executed: return false;
0
859 }
never executed: end of block
0
860 if (opened) {
openedDescription
TRUEnever evaluated
FALSEnever evaluated
0
861 f.close();-
862 if (!exists)
!existsDescription
TRUEnever evaluated
FALSEnever evaluated
0
863 f.remove();
never executed: f.remove();
0
864 }
never executed: end of block
0
865 }
never executed: end of block
0
866-
867#ifndef QT_NO_CUPS-
868 if (propertiesDialogShown) {
propertiesDialogShownDescription
TRUEnever evaluated
FALSEnever evaluated
0
869 QCUPSSupport::PagesPerSheet pagesPerSheet = propertiesDialog->widget.pageSetup->m_ui.pagesPerSheetCombo-
870 ->currentData().value<QCUPSSupport::PagesPerSheet>();-
871-
872 QCUPSSupport::PageSet pageSet = optionsPane->options.pageSetCombo->currentData().value<QCUPSSupport::PageSet>();-
873-
874-
875 if (pagesPerSheet != QCUPSSupport::OnePagePerSheet
pagesPerSheet ...nePagePerSheetDescription
TRUEnever evaluated
FALSEnever evaluated
0
876 && pageSet != QCUPSSupport::AllPages) {
pageSet != QCU...port::AllPagesDescription
TRUEnever evaluated
FALSEnever evaluated
0
877 QMessageBox::warning(q, q->windowTitle(),-
878 QPrintDialog::tr("Options 'Pages Per Sheet' and 'Page Set' cannot be used together.\nPlease turn one of those options off."));-
879 return false;
never executed: return false;
0
880 }-
881 }
never executed: end of block
0
882#endif-
883-
884 // Every test passed. Accept the dialog.-
885 return true;
never executed: return true;
0
886}-
887#endif // QT_NO_MESSAGEBOX-
888-
889void QUnixPrintWidgetPrivate::setupPrinterProperties()-
890{-
891 if (propertiesDialog)
propertiesDialogDescription
TRUEnever evaluated
FALSEnever evaluated
0
892 delete propertiesDialog;
never executed: delete propertiesDialog;
0
893-
894 propertiesDialog = new QPrintPropertiesDialog(q);-
895 propertiesDialog->setResult(QDialog::Rejected);-
896 propertiesDialogShown = false;-
897-
898 propertiesDialog->applyPrinterProperties(q->printer());-
899-
900 if (q->isOptionEnabled(QPrintDialog::PrintToFile)
q->isOptionEna...::PrintToFile)Description
TRUEnever evaluated
FALSEnever evaluated
0
901 && (widget.printers->currentIndex() == widget.printers->count() - 1)) {// PDF
(widget.printe...->count() - 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
902 propertiesDialog->selectPrinter(QPrinter::PdfFormat, QString());-
903 }
never executed: end of block
0
904 else-
905 propertiesDialog->selectPrinter(QPrinter::NativeFormat, widget.printers->currentText());
never executed: propertiesDialog->selectPrinter(QPrinter::NativeFormat, widget.printers->currentText());
0
906}-
907-
908void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked()-
909{-
910 if (!propertiesDialog)
!propertiesDialogDescription
TRUEnever evaluated
FALSEnever evaluated
0
911 setupPrinterProperties();
never executed: setupPrinterProperties();
0
912 propertiesDialog->exec();-
913 if (!propertiesDialogShown && propertiesDialog->result() == QDialog::Rejected) {
!propertiesDialogShownDescription
TRUEnever evaluated
FALSEnever evaluated
propertiesDial...alog::RejectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
914 // If properties dialog was rejected the dialog is deleted and-
915 // the properties are set to defaults when printer is setup-
916 delete propertiesDialog;-
917 propertiesDialog = 0;-
918 propertiesDialogShown = false;-
919 } else
never executed: end of block
0
920 // properties dialog was shown and accepted-
921 propertiesDialogShown = true;
never executed: propertiesDialogShown = true;
0
922}-
923-
924void QUnixPrintWidgetPrivate::setupPrinter()-
925{-
926 const int printerCount = widget.printers->count();-
927 const int index = widget.printers->currentIndex();-
928-
929 if (filePrintersAdded && index == printerCount - 1) { // PDF
filePrintersAddedDescription
TRUEnever evaluated
FALSEnever evaluated
index == printerCount - 1Description
TRUEnever evaluated
FALSEnever evaluated
0
930 printer->setPrinterName(QString());-
931 Q_ASSERT(index != printerCount - 2); // separator-
932 printer->setOutputFormat(QPrinter::PdfFormat);-
933 QString path = widget.filename->text();-
934 if (QDir::isRelativePath(path))
QDir::isRelativePath(path)Description
TRUEnever evaluated
FALSEnever evaluated
0
935 path = QDir::homePath() + QDir::separator() + path;
never executed: path = QDir::homePath() + QDir::separator() + path;
0
936 printer->setOutputFileName(path);-
937 }
never executed: end of block
0
938 else {-
939 printer->setPrinterName(widget.printers->currentText());-
940 printer->setOutputFileName(QString());-
941 }
never executed: end of block
0
942-
943 if (!propertiesDialog)
!propertiesDialogDescription
TRUEnever evaluated
FALSEnever evaluated
0
944 setupPrinterProperties();
never executed: setupPrinterProperties();
0
945-
946 if (propertiesDialog->result() == QDialog::Accepted || !propertiesDialogShown)
propertiesDial...alog::AcceptedDescription
TRUEnever evaluated
FALSEnever evaluated
!propertiesDialogShownDescription
TRUEnever evaluated
FALSEnever evaluated
0
947 propertiesDialog->setupPrinter();
never executed: propertiesDialog->setupPrinter();
0
948}
never executed: end of block
0
949-
950/*! \internal-
951*/-
952QUnixPrintWidget::QUnixPrintWidget(QPrinter *printer, QWidget *parent)-
953 : QWidget(parent), d(new QUnixPrintWidgetPrivate(this, printer))-
954{-
955 d->applyPrinterProperties();-
956}
executed 3 times by 1 test: end of block
Executed by:
  • tst_QPrinter
3
957-
958/*! \internal-
959*/-
960QUnixPrintWidget::~QUnixPrintWidget()-
961{-
962 delete d;-
963}
executed 3 times by 1 test: end of block
Executed by:
  • tst_QPrinter
3
964-
965/*! \internal-
966-
967 Updates the printer with the states held in the QUnixPrintWidget.-
968*/-
969void QUnixPrintWidget::updatePrinter()-
970{-
971 d->setupPrinter();-
972}
never executed: end of block
0
973-
974////////////////////////////////////////////////////////////////////////////////-
975////////////////////////////////////////////////////////////////////////////////-
976-
977#endif // defined (Q_OS_UNIX)-
978-
979QT_END_NAMESPACE-
980-
981#include "moc_qprintdialog.cpp"-
982#include "qprintdialog_unix.moc"-
983-
984#endif // QT_NO_PRINTDIALOG-
985-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9