dialogs/qprintdialog_unix.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9 -
10class QOptionTreeItem; -
11class QPPDOptionsModel; -
12 -
13class QPrintPropertiesDialog : public QDialog -
14{ -
15 public: template <typename T> inline void qt_check_for_QOBJECT_macro(const T &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; } static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); static inline QString tr(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } virtual int qt_metacall(QMetaObject::Call, int, void **); private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); struct QPrivateSignal {}; -
16public: -
17 QPrintPropertiesDialog(QAbstractPrintDialog *parent = 0); -
18 ~QPrintPropertiesDialog(); -
19 -
20 void selectPrinter(); -
21 void selectPdfPsPrinter(const QPrinter *p); -
22 -
23 -
24 void applyPrinterProperties(QPrinter *p); -
25 void setupPrinter() const; -
26 -
27protected: -
28 void showEvent(QShowEvent* event); -
29 -
30private: -
31 Ui::QPrintPropertiesWidget widget; -
32 QDialogButtonBox *m_buttons; -
33}; -
34 -
35class QUnixPrintWidgetPrivate; -
36 -
37class QUnixPrintWidget : public QWidget -
38{ -
39 public: template <typename T> inline void qt_check_for_QOBJECT_macro(const T &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; } static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); static inline QString tr(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } virtual int qt_metacall(QMetaObject::Call, int, void **); private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); struct QPrivateSignal {}; -
40 -
41public: -
42 explicit QUnixPrintWidget(QPrinter *printer, QWidget *parent = 0); -
43 ~QUnixPrintWidget(); -
44 void updatePrinter(); -
45 -
46private: -
47 friend class QPrintDialogPrivate; -
48 friend class QUnixPrintWidgetPrivate; -
49 QUnixPrintWidgetPrivate *d; -
50 -
51 -
52 -
53}; -
54 -
55class QUnixPrintWidgetPrivate -
56{ -
57public: -
58 QUnixPrintWidgetPrivate(QUnixPrintWidget *q, QPrinter *prn); -
59 ~QUnixPrintWidgetPrivate(); -
60 -
61 -
62 void applyPrinterProperties(); -
63 bool checkFields(); -
64 void setupPrinter(); -
65 void setOptionsPane(QPrintDialogPrivate *pane); -
66 void setupPrinterProperties(); -
67 -
68 void _q_printerChanged(int index); -
69 void _q_btnPropertiesClicked(); -
70 void _q_btnBrowseClicked(); -
71 -
72 QUnixPrintWidget * const parent; -
73 QPrintPropertiesDialog *propertiesDialog; -
74 Ui::QPrintWidget widget; -
75 QAbstractPrintDialog * q; -
76 QPrinter *printer; -
77 void updateWidget(); -
78 -
79private: -
80 QPrintDialogPrivate *optionsPane; -
81 bool filePrintersAdded; -
82 bool propertiesDialogShown; -
83}; -
84 -
85class QPrintDialogPrivate : public QAbstractPrintDialogPrivate -
86{ -
87 inline QPrintDialog* q_func() { return static_cast<QPrintDialog *>(q_ptr); } inline const QPrintDialog* q_func() const { return static_cast<const QPrintDialog *>(q_ptr); } friend class QPrintDialog; -
88 public: static inline QString tr(const char *sourceText, const char *disambiguation = 0, int n = -1) { return QCoreApplication::translate("QPrintDialog", sourceText, disambiguation, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *sourceText, const char *disambiguation = 0, int n = -1) { return QCoreApplication::translate("QPrintDialog", sourceText, disambiguation, n); } private: -
89public: -
90 QPrintDialogPrivate(); -
91 ~QPrintDialogPrivate(); -
92 -
93 void init(); -
94 -
95 void applyPrinterProperties(); -
96 -
97 void selectPrinter(); -
98 -
99 void _q_chbPrintLastFirstToggled(bool); -
100 -
101 void _q_checkFields(); -
102 -
103 void _q_collapseOrExpandDialog(); -
104 -
105 void setupPrinter(); -
106 void updateWidgets(); -
107 -
108 virtual void setTabs(const QList<QWidget*> &tabs); -
109 -
110 Ui::QPrintSettingsOutput options; -
111 QUnixPrintWidget *top; -
112 QWidget *bottom; -
113 QDialogButtonBox *buttons; -
114 QPushButton *collapseButton; -
115}; -
116QPrintPropertiesDialog::QPrintPropertiesDialog(QAbstractPrintDialog *parent) -
117 : QDialog(parent) -
118{ -
119 QVBoxLayout *lay = new QVBoxLayout(this); -
120 this->setLayout(lay); -
121 QWidget *content = new QWidget(this); -
122 widget.setupUi(content); -
123 m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); -
124 lay->addWidget(content); -
125 lay->addWidget(m_buttons); -
126 -
127 connect(m_buttons->button(QDialogButtonBox::Ok), "2""clicked()", this, "1""accept()"); -
128 connect(m_buttons->button(QDialogButtonBox::Cancel), "2""clicked()", this, "1""reject()"); -
129}
never executed: }
0
130 -
131QPrintPropertiesDialog::~QPrintPropertiesDialog() -
132{ -
133} -
134 -
135void QPrintPropertiesDialog::applyPrinterProperties(QPrinter *p) -
136{ -
137 widget.pageSetup->setPrinter(p); -
138}
never executed: }
0
139 -
140void QPrintPropertiesDialog::setupPrinter() const -
141{ -
142 widget.pageSetup->setupPrinter(); -
143}
never executed: }
0
144 -
145void QPrintPropertiesDialog::selectPrinter() -
146{ -
147 widget.pageSetup->selectPrinter(); -
148}
never executed: }
0
149 -
150void QPrintPropertiesDialog::selectPdfPsPrinter(const QPrinter *p) -
151{ -
152 widget.pageSetup->selectPdfPsPrinter(p); -
153}
never executed: }
0
154 -
155void QPrintPropertiesDialog::showEvent(QShowEvent* event) -
156{ -
157 event->accept(); -
158}
never executed: }
0
159QPrintDialogPrivate::QPrintDialogPrivate() -
160 : top(0), bottom(0), buttons(0), collapseButton(0) -
161{ -
162}
executed: }
Execution Count:3
3
163 -
164QPrintDialogPrivate::~QPrintDialogPrivate() -
165{ -
166} -
167 -
168void QPrintDialogPrivate::init() -
169{ -
170 QPrintDialog * const q = q_func(); -
171 -
172 top = new QUnixPrintWidget(q->printer(), q); -
173 bottom = new QWidget(q); -
174 options.setupUi(bottom); -
175 options.color->setIconSize(QSize(32, 32)); -
176 options.color->setIcon(QIcon(QLatin1String(":/qt-project.org/dialogs/qprintdialog/images/status-color.png"))); -
177 options.grayscale->setIconSize(QSize(32, 32)); -
178 options.grayscale->setIcon(QIcon(QLatin1String(":/qt-project.org/dialogs/qprintdialog/images/status-gray-scale.png"))); -
179 top->d->setOptionsPane(this); -
180 -
181 buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, q); -
182 collapseButton = new QPushButton(QPrintDialog::tr("&Options >>"), buttons); -
183 buttons->addButton(collapseButton, QDialogButtonBox::ResetRole); -
184 bottom->setVisible(false); -
185 -
186 QPushButton *printButton = buttons->button(QDialogButtonBox::Ok); -
187 printButton->setText(QPrintDialog::tr("&Print")); -
188 printButton->setDefault(true); -
189 -
190 QVBoxLayout *lay = new QVBoxLayout(q); -
191 q->setLayout(lay); -
192 lay->addWidget(top); -
193 lay->addWidget(bottom); -
194 lay->addWidget(buttons); -
195 -
196 -
197 -
198 -
199 QObject::connect(buttons, "2""accepted()", q, "1""_q_checkFields()"); -
200 -
201 QObject::connect(buttons, "2""rejected()", q, "1""reject()"); -
202 -
203 QObject::connect(options.reverse, "2""toggled(bool)", -
204 q, "1""_q_chbPrintLastFirstToggled(bool)"); -
205 -
206 QObject::connect(collapseButton, "2""released()", q, "1""_q_collapseOrExpandDialog()"); -
207}
executed: }
Execution Count:3
3
208 -
209 -
210void QPrintDialogPrivate::selectPrinter() -
211{ -
212 QPrintDialog * const q = q_func(); -
213 QPrinter *p = q->printer(); -
214 -
215 if (p->colorMode() == QPrinter::Color)
partially evaluated: p->colorMode() == QPrinter::Color
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
216 options.color->setChecked(true);
executed: options.color->setChecked(true);
Execution Count:4
4
217 else -
218 options.grayscale->setChecked(true);
never executed: options.grayscale->setChecked(true);
0
219 -
220 switch (p->duplex()) { -
221 case QPrinter::DuplexNone: -
222 options.noDuplex->setChecked(true); break;
executed: break;
Execution Count:4
4
223 case QPrinter::DuplexLongSide: -
224 case QPrinter::DuplexAuto: -
225 options.duplexLong->setChecked(true); break;
never executed: break;
0
226 case QPrinter::DuplexShortSide: -
227 options.duplexShort->setChecked(true); break;
never executed: break;
0
228 } -
229 options.copies->setValue(p->copyCount()); -
230 options.collate->setChecked(p->collateCopies()); -
231 options.reverse->setChecked(p->pageOrder() == QPrinter::LastPageFirst); -
232}
executed: }
Execution Count:4
4
233 -
234void QPrintDialogPrivate::applyPrinterProperties() -
235{ -
236 -
237 top->d->applyPrinterProperties(); -
238}
never executed: }
0
239 -
240void QPrintDialogPrivate::setupPrinter() -
241{ -
242 QPrintDialog * const q = q_func(); -
243 QPrinter* p = q->printer(); -
244 -
245 if (options.duplex->isEnabled()) {
never evaluated: options.duplex->isEnabled()
0
246 if (options.noDuplex->isChecked())
never evaluated: options.noDuplex->isChecked()
0
247 p->setDuplex(QPrinter::DuplexNone);
never executed: p->setDuplex(QPrinter::DuplexNone);
0
248 else if (options.duplexLong->isChecked())
never evaluated: options.duplexLong->isChecked()
0
249 p->setDuplex(QPrinter::DuplexLongSide);
never executed: p->setDuplex(QPrinter::DuplexLongSide);
0
250 else -
251 p->setDuplex(QPrinter::DuplexShortSide);
never executed: p->setDuplex(QPrinter::DuplexShortSide);
0
252 } -
253 -
254 p->setColorMode(options.color->isChecked() ? QPrinter::Color : QPrinter::GrayScale); -
255 -
256 -
257 if (options.printAll->isChecked()) {
never evaluated: options.printAll->isChecked()
0
258 p->setPrintRange(QPrinter::AllPages); -
259 p->setFromTo(0,0); -
260 } else if (options.printSelection->isChecked()) {
never evaluated: options.printSelection->isChecked()
never executed: }
0
261 p->setPrintRange(QPrinter::Selection); -
262 p->setFromTo(0,0); -
263 } else if (options.printCurrentPage->isChecked()) {
never evaluated: options.printCurrentPage->isChecked()
never executed: }
0
264 p->setPrintRange(QPrinter::CurrentPage); -
265 p->setFromTo(0,0); -
266 } else if (options.printRange->isChecked()) {
never evaluated: options.printRange->isChecked()
never executed: }
0
267 p->setPrintRange(QPrinter::PageRange); -
268 p->setFromTo(options.from->value(), qMax(options.from->value(), options.to->value())); -
269 }
never executed: }
0
270 -
271 -
272 p->setCopyCount(options.copies->value()); -
273 p->setCollateCopies(options.collate->isChecked()); -
274 -
275 top->d->setupPrinter(); -
276}
never executed: }
0
277 -
278void QPrintDialogPrivate::_q_chbPrintLastFirstToggled(bool checked) -
279{ -
280 QPrintDialog * const q = q_func(); -
281 if (checked)
never evaluated: checked
0
282 q->printer()->setPageOrder(QPrinter::LastPageFirst);
never executed: q->printer()->setPageOrder(QPrinter::LastPageFirst);
0
283 else -
284 q->printer()->setPageOrder(QPrinter::FirstPageFirst);
never executed: q->printer()->setPageOrder(QPrinter::FirstPageFirst);
0
285} -
286 -
287void QPrintDialogPrivate::_q_collapseOrExpandDialog() -
288{ -
289 int collapseHeight = 0; -
290 QPrintDialog * const q = q_func(); -
291 QWidget *widgetToHide = bottom; -
292 if (widgetToHide->isVisible()) {
never evaluated: widgetToHide->isVisible()
0
293 collapseButton->setText(QPrintDialog::tr("&Options >>")); -
294 collapseHeight = widgetToHide->y() + widgetToHide->height() - (top->y() + top->height()); -
295 }
never executed: }
0
296 else -
297 collapseButton->setText(QPrintDialog::tr("&Options <<"));
never executed: collapseButton->setText(QPrintDialog::tr("&Options <<"));
0
298 widgetToHide->setVisible(! widgetToHide->isVisible()); -
299 if (! widgetToHide->isVisible()) {
never evaluated: ! widgetToHide->isVisible()
0
300 q->layout()->activate(); -
301 q->resize( QSize(q->width(), q->height() - collapseHeight) ); -
302 }
never executed: }
0
303}
never executed: }
0
304 -
305 -
306void QPrintDialogPrivate::_q_checkFields() -
307{ -
308 QPrintDialog * const q = q_func(); -
309 if (top->d->checkFields())
never evaluated: top->d->checkFields()
0
310 q->accept();
never executed: q->accept();
0
311}
never executed: }
0
312 -
313 -
314 -
315void QPrintDialogPrivate::updateWidgets() -
316{ -
317 QPrintDialog * const q = q_func(); -
318 options.gbPrintRange->setVisible(q->isOptionEnabled(QPrintDialog::PrintPageRange) || -
319 q->isOptionEnabled(QPrintDialog::PrintSelection) || -
320 q->isOptionEnabled(QPrintDialog::PrintCurrentPage)); -
321 -
322 options.printRange->setEnabled(q->isOptionEnabled(QPrintDialog::PrintPageRange)); -
323 options.printSelection->setVisible(q->isOptionEnabled(QPrintDialog::PrintSelection)); -
324 options.printCurrentPage->setVisible(q->isOptionEnabled(QPrintDialog::PrintCurrentPage)); -
325 options.collate->setVisible(q->isOptionEnabled(QPrintDialog::PrintCollateCopies)); -
326 -
327 switch (q->printRange()) { -
328 case QPrintDialog::AllPages: -
329 options.printAll->setChecked(true); -
330 break;
executed: break;
Execution Count:1
1
331 case QPrintDialog::Selection: -
332 options.printSelection->setChecked(true); -
333 break;
never executed: break;
0
334 case QPrintDialog::PageRange: -
335 options.printRange->setChecked(true); -
336 break;
never executed: break;
0
337 case QPrintDialog::CurrentPage: -
338 if (q->isOptionEnabled(QPrintDialog::PrintCurrentPage))
never evaluated: q->isOptionEnabled(QPrintDialog::PrintCurrentPage)
0
339 options.printCurrentPage->setChecked(true);
never executed: options.printCurrentPage->setChecked(true);
0
340 break;
never executed: break;
0
341 default: -
342 break;
never executed: break;
0
343 } -
344 const int minPage = qMax(1, qMin(q->minPage() , q->maxPage())); -
345 const int maxPage = qMax(1, q->maxPage() == 2147483647 ? 9999 : q->maxPage()); -
346 -
347 options.from->setMinimum(minPage); -
348 options.to->setMinimum(minPage); -
349 options.from->setMaximum(maxPage); -
350 options.to->setMaximum(maxPage); -
351 -
352 options.from->setValue(q->fromPage()); -
353 options.to->setValue(q->toPage()); -
354 top->d->updateWidget(); -
355}
executed: }
Execution Count:1
1
356 -
357void QPrintDialogPrivate::setTabs(const QList<QWidget*> &tabWidgets) -
358{ -
359 QList<QWidget*>::ConstIterator iter = tabWidgets.begin(); -
360 while(iter != tabWidgets.constEnd()) {
never evaluated: iter != tabWidgets.constEnd()
0
361 QWidget *tab = *iter; -
362 options.tabs->addTab(tab, tab->windowTitle()); -
363 ++iter; -
364 }
never executed: }
0
365}
never executed: }
0
366QPrintDialog::QPrintDialog(QPrinter *printer, QWidget *parent) -
367 : QAbstractPrintDialog(*(new QPrintDialogPrivate), printer, parent) -
368{ -
369 QPrintDialogPrivate * const d = d_func(); -
370 d->init(); -
371}
executed: }
Execution Count:2
2
372 -
373 -
374 -
375 -
376QPrintDialog::QPrintDialog(QWidget *parent) -
377 : QAbstractPrintDialog(*(new QPrintDialogPrivate), 0, parent) -
378{ -
379 QPrintDialogPrivate * const d = d_func(); -
380 d->init(); -
381}
executed: }
Execution Count:1
1
382 -
383QPrintDialog::~QPrintDialog() -
384{ -
385} -
386 -
387void QPrintDialog::setVisible(bool visible) -
388{ -
389 QPrintDialogPrivate * const d = d_func(); -
390 -
391 if (visible)
partially evaluated: visible
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
392 d->updateWidgets();
executed: d->updateWidgets();
Execution Count:1
1
393 -
394 QAbstractPrintDialog::setVisible(visible); -
395}
executed: }
Execution Count:1
1
396 -
397int QPrintDialog::exec() -
398{ -
399 return QDialog::exec();
never executed: return QDialog::exec();
0
400} -
401 -
402void QPrintDialog::accept() -
403{ -
404 QPrintDialogPrivate * const d = d_func(); -
405 d->setupPrinter(); -
406 QDialog::accept(); -
407}
never executed: }
0
408QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p, QPrinter *prn) -
409 : parent(p), propertiesDialog(0), printer(prn), optionsPane(0), -
410 filePrintersAdded(false), propertiesDialogShown(false) -
411{ -
412 q = 0; -
413 if (parent)
partially evaluated: parent
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
414 q = qobject_cast<QAbstractPrintDialog*> (parent->parent());
executed: q = qobject_cast<QAbstractPrintDialog*> (parent->parent());
Execution Count:3
3
415 -
416 widget.setupUi(parent); -
417 -
418 int currentPrinterIndex = 0; -
419 QList<QPrinterInfo> printers = QPrinterInfo::availablePrinters(); -
420 -
421 for (int i = 0; i < printers.size(); ++i) {
partially evaluated: i < printers.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
422 QPrinterInfo pInfo = printers.at(i); -
423 widget.printers->addItem(pInfo.printerName()); -
424 if (pInfo.isDefault())
never evaluated: pInfo.isDefault()
0
425 currentPrinterIndex = i;
never executed: currentPrinterIndex = i;
0
426 }
never executed: }
0
427 widget.properties->setEnabled(true); -
428 -
429 -
430 QFileSystemModel *fsm = new QFileSystemModel(widget.filename); -
431 fsm->setRootPath(QDir::homePath()); -
432 widget.filename->setCompleter(new QCompleter(fsm, widget.filename)); -
433 -
434 _q_printerChanged(currentPrinterIndex); -
435 -
436 QObject::connect(widget.printers, "2""currentIndexChanged(int)", -
437 parent, "1""_q_printerChanged(int)"); -
438 QObject::connect(widget.fileBrowser, "2""clicked()", parent, "1""_q_btnBrowseClicked()"); -
439 QObject::connect(widget.properties, "2""clicked()", parent, "1""_q_btnPropertiesClicked()"); -
440 -
441 -
442 widget.preview->setVisible(false); -
443}
executed: }
Execution Count:3
3
444 -
445void QUnixPrintWidgetPrivate::updateWidget() -
446{ -
447 const bool printToFile = q == 0 || q->isOptionEnabled(QPrintDialog::PrintToFile);
partially evaluated: q == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: q->isOptionEnabled(QPrintDialog::PrintToFile)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
448 if (printToFile && !filePrintersAdded) {
partially evaluated: printToFile
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: !filePrintersAdded
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
449 if (widget.printers->count())
partially evaluated: widget.printers->count()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
450 widget.printers->insertSeparator(widget.printers->count());
never executed: widget.printers->insertSeparator(widget.printers->count());
0
451 widget.printers->addItem(QPrintDialog::tr("Print to File (PDF)")); -
452 filePrintersAdded = true; -
453 }
executed: }
Execution Count:1
1
454 if (!printToFile && filePrintersAdded) {
partially evaluated: !printToFile
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
never evaluated: filePrintersAdded
0-1
455 widget.printers->removeItem(widget.printers->count()-1); -
456 widget.printers->removeItem(widget.printers->count()-1); -
457 if (widget.printers->count())
never evaluated: widget.printers->count()
0
458 widget.printers->removeItem(widget.printers->count()-1);
never executed: widget.printers->removeItem(widget.printers->count()-1);
0
459 filePrintersAdded = false; -
460 }
never executed: }
0
461 if (printer && filePrintersAdded && (printer->outputFormat() != QPrinter::NativeFormat
partially evaluated: printer
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: filePrintersAdded
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: printer->outputFormat() != QPrinter::NativeFormat
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
462 || printer->printerName().isEmpty()))
never evaluated: printer->printerName().isEmpty()
0
463 { -
464 if (printer->outputFormat() == QPrinter::PdfFormat)
partially evaluated: printer->outputFormat() == QPrinter::PdfFormat
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
465 widget.printers->setCurrentIndex(widget.printers->count() - 1);
executed: widget.printers->setCurrentIndex(widget.printers->count() - 1);
Execution Count:1
1
466 widget.filename->setEnabled(true); -
467 widget.lOutput->setEnabled(true); -
468 }
executed: }
Execution Count:1
1
469 -
470 widget.filename->setVisible(printToFile); -
471 widget.lOutput->setVisible(printToFile); -
472 widget.fileBrowser->setVisible(printToFile); -
473 -
474 widget.properties->setVisible(q->isOptionEnabled(QAbstractPrintDialog::PrintShowPageSize)); -
475}
executed: }
Execution Count:1
1
476 -
477QUnixPrintWidgetPrivate::~QUnixPrintWidgetPrivate() -
478{ -
479} -
480 -
481void QUnixPrintWidgetPrivate::_q_printerChanged(int index) -
482{ -
483 if (index < 0)
partially evaluated: index < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
484 return;
never executed: return;
0
485 const int printerCount = widget.printers->count(); -
486 widget.filename->setEnabled(false); -
487 widget.lOutput->setEnabled(false); -
488 -
489 -
490 if (propertiesDialog){
partially evaluated: propertiesDialog
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
491 delete propertiesDialog; -
492 propertiesDialog = 0; -
493 propertiesDialogShown = false; -
494 }
never executed: }
0
495 -
496 if (filePrintersAdded) {
partially evaluated: filePrintersAdded
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
497 qt_noop(); -
498 if (index == printerCount - 1) {
never evaluated: index == printerCount - 1
0
499 widget.location->setText(QPrintDialog::tr("Local file")); -
500 widget.type->setText(QPrintDialog::tr("Write PDF file")); -
501 widget.properties->setEnabled(true); -
502 widget.filename->setEnabled(true); -
503 QString filename = widget.filename->text(); -
504 widget.filename->setText(filename); -
505 widget.lOutput->setEnabled(true); -
506 if (optionsPane)
never evaluated: optionsPane
0
507 optionsPane->selectPrinter();
never executed: optionsPane->selectPrinter();
0
508 return;
never executed: return;
0
509 } -
510 }
never executed: }
0
511 -
512 if (printer) {
partially evaluated: printer
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
513 QString printerName = widget.printers->itemText(index); -
514 printer->setPrinterName(printerName); -
515 -
516 QPrinterInfo printerInfo = QPrinterInfo::printerInfo(printer->printerName()); -
517 widget.location->setText(printerInfo.location()); -
518 widget.type->setText(printerInfo.makeAndModel()); -
519 if (optionsPane)
evaluated: optionsPane
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
1-3
520 optionsPane->selectPrinter();
executed: optionsPane->selectPrinter();
Execution Count:1
1
521 }
executed: }
Execution Count:4
4
522}
executed: }
Execution Count:4
4
523 -
524void QUnixPrintWidgetPrivate::setOptionsPane(QPrintDialogPrivate *pane) -
525{ -
526 optionsPane = pane; -
527 if (optionsPane)
partially evaluated: optionsPane
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
528 optionsPane->selectPrinter();
executed: optionsPane->selectPrinter();
Execution Count:3
3
529}
executed: }
Execution Count:3
3
530 -
531void QUnixPrintWidgetPrivate::_q_btnBrowseClicked() -
532{ -
533 QString filename = widget.filename->text(); -
534 -
535 filename = QFileDialog::getSaveFileName(parent, QPrintDialog::tr("Print To File ..."), filename, -
536 QString(), 0, QFileDialog::DontConfirmOverwrite); -
537 -
538 -
539 -
540 if (!filename.isEmpty()) {
never evaluated: !filename.isEmpty()
0
541 widget.filename->setText(filename); -
542 widget.printers->setCurrentIndex(widget.printers->count() - 1); -
543 }
never executed: }
0
544}
never executed: }
0
545 -
546void QUnixPrintWidgetPrivate::applyPrinterProperties() -
547{ -
548 if (printer == 0)
partially evaluated: printer == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
549 return;
never executed: return;
0
550 if (printer->outputFileName().isEmpty()) {
partially evaluated: printer->outputFileName().isEmpty()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
551 QString home = QDir::homePath(); -
552 QString cur = QDir::currentPath(); -
553 if (home.at(home.length()-1) != QLatin1Char('/'))
partially evaluated: home.at(home.length()-1) != QLatin1Char('/')
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
554 home += QLatin1Char('/');
executed: home += QLatin1Char('/');
Execution Count:3
3
555 if (cur.at(cur.length()-1) != QLatin1Char('/'))
partially evaluated: cur.at(cur.length()-1) != QLatin1Char('/')
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
556 cur += QLatin1Char('/');
executed: cur += QLatin1Char('/');
Execution Count:3
3
557 if (cur.left(home.length()) != home)
partially evaluated: cur.left(home.length()) != home
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
558 cur = home;
never executed: cur = home;
0
559 if (QGuiApplication::platformName() == QLatin1String("xcb")) {
partially evaluated: QGuiApplication::platformName() == QLatin1String("xcb")
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
560 if (printer->docName().isEmpty()) {
partially evaluated: printer->docName().isEmpty()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
561 cur += QLatin1String("print.pdf"); -
562 } else {
executed: }
Execution Count:3
3
563 QRegExp re(QString::fromLatin1("(.*)\\.\\S+")); -
564 if (re.exactMatch(printer->docName()))
never evaluated: re.exactMatch(printer->docName())
0
565 cur += re.cap(1);
never executed: cur += re.cap(1);
0
566 else -
567 cur += printer->docName();
never executed: cur += printer->docName();
0
568 cur += QLatin1String(".pdf"); -
569 }
never executed: }
0
570 } -
571 -
572 widget.filename->setText(cur); -
573 }
executed: }
Execution Count:3
3
574 else -
575 widget.filename->setText( printer->outputFileName() );
never executed: widget.filename->setText( printer->outputFileName() );
0
576 QString printerName = printer->printerName(); -
577 if (!printerName.isEmpty()) {
partially evaluated: !printerName.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
578 for (int i = 0; i < widget.printers->count(); ++i) {
never evaluated: i < widget.printers->count()
0
579 if (widget.printers->itemText(i) == printerName) {
never evaluated: widget.printers->itemText(i) == printerName
0
580 widget.printers->setCurrentIndex(i); -
581 break;
never executed: break;
0
582 } -
583 }
never executed: }
0
584 }
never executed: }
0
585 -
586 -
587 if (propertiesDialog)
partially evaluated: propertiesDialog
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
588 propertiesDialog->applyPrinterProperties(printer);
never executed: propertiesDialog->applyPrinterProperties(printer);
0
589}
executed: }
Execution Count:3
3
590 -
591 -
592bool QUnixPrintWidgetPrivate::checkFields() -
593{ -
594 if (widget.filename->isEnabled()) {
never evaluated: widget.filename->isEnabled()
0
595 QString file = widget.filename->text(); -
596 QFile f(file); -
597 QFileInfo fi(f); -
598 bool exists = fi.exists(); -
599 bool opened = false; -
600 if (exists && fi.isDir()) {
never evaluated: exists
never evaluated: fi.isDir()
0
601 QMessageBox::warning(q, q->windowTitle(), -
602 QPrintDialog::tr("%1 is a directory.\nPlease choose a different file name.").arg(file)); -
603 return false;
never executed: return false;
0
604 } 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
605 QMessageBox::warning(q, q->windowTitle(), -
606 QPrintDialog::tr("File %1 is not writable.\nPlease choose a different file name.").arg(file)); -
607 return false;
never executed: return false;
0
608 } else if (exists) {
never evaluated: exists
0
609 int ret = QMessageBox::question(q, q->windowTitle(), -
610 QPrintDialog::tr("%1 already exists.\nDo you want to overwrite it?").arg(file), -
611 QMessageBox::Yes|QMessageBox::No, QMessageBox::No); -
612 if (ret == QMessageBox::No)
never evaluated: ret == QMessageBox::No
0
613 return false;
never executed: return false;
0
614 }
never executed: }
0
615 if (opened) {
never evaluated: opened
0
616 f.close(); -
617 if (!exists)
never evaluated: !exists
0
618 f.remove();
never executed: f.remove();
0
619 }
never executed: }
0
620 }
never executed: }
0
621 -
622 -
623 return true;
never executed: return true;
0
624} -
625 -
626 -
627void QUnixPrintWidgetPrivate::setupPrinterProperties() -
628{ -
629 if (propertiesDialog)
never evaluated: propertiesDialog
0
630 delete propertiesDialog;
never executed: delete propertiesDialog;
0
631 -
632 propertiesDialog = new QPrintPropertiesDialog(q); -
633 propertiesDialog->setResult(QDialog::Rejected); -
634 propertiesDialogShown = false; -
635 -
636 propertiesDialog->applyPrinterProperties(q->printer()); -
637 -
638 if (q->isOptionEnabled(QPrintDialog::PrintToFile)
never evaluated: q->isOptionEnabled(QPrintDialog::PrintToFile)
0
639 && (widget.printers->currentIndex() == widget.printers->count() - 1)) {
never evaluated: (widget.printers->currentIndex() == widget.printers->count() - 1)
0
640 propertiesDialog->selectPdfPsPrinter(q->printer()); -
641 }
never executed: }
0
642 else -
643 propertiesDialog->selectPrinter();
never executed: propertiesDialog->selectPrinter();
0
644} -
645 -
646void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked() -
647{ -
648 if (!propertiesDialog)
never evaluated: !propertiesDialog
0
649 setupPrinterProperties();
never executed: setupPrinterProperties();
0
650 propertiesDialog->exec(); -
651 if (propertiesDialog->result() == QDialog::Rejected) {
never evaluated: propertiesDialog->result() == QDialog::Rejected
0
652 -
653 -
654 delete propertiesDialog; -
655 propertiesDialog = 0; -
656 propertiesDialogShown = false; -
657 } else
never executed: }
0
658 -
659 propertiesDialogShown = true;
never executed: propertiesDialogShown = true;
0
660} -
661 -
662void QUnixPrintWidgetPrivate::setupPrinter() -
663{ -
664 const int printerCount = widget.printers->count(); -
665 const int index = widget.printers->currentIndex(); -
666 -
667 if (filePrintersAdded && index == printerCount - 1) {
never evaluated: filePrintersAdded
never evaluated: index == printerCount - 1
0
668 printer->setPrinterName(QString()); -
669 qt_noop(); -
670 printer->setOutputFormat(QPrinter::PdfFormat); -
671 QString path = widget.filename->text(); -
672 if (QDir::isRelativePath(path))
never evaluated: QDir::isRelativePath(path)
0
673 path = QDir::homePath() + QDir::separator() + path;
never executed: path = QDir::homePath() + QDir::separator() + path;
0
674 printer->setOutputFileName(path); -
675 }
never executed: }
0
676 else { -
677 printer->setPrinterName(widget.printers->currentText()); -
678 printer->setOutputFileName(QString()); -
679 }
never executed: }
0
680 -
681 if (!propertiesDialog)
never evaluated: !propertiesDialog
0
682 setupPrinterProperties();
never executed: setupPrinterProperties();
0
683 -
684 if (propertiesDialog->result() == QDialog::Accepted || !propertiesDialogShown)
never evaluated: propertiesDialog->result() == QDialog::Accepted
never evaluated: !propertiesDialogShown
0
685 propertiesDialog->setupPrinter();
never executed: propertiesDialog->setupPrinter();
0
686}
never executed: }
0
687 -
688 -
689 -
690QUnixPrintWidget::QUnixPrintWidget(QPrinter *printer, QWidget *parent) -
691 : QWidget(parent), d(new QUnixPrintWidgetPrivate(this, printer)) -
692{ -
693 d->applyPrinterProperties(); -
694}
executed: }
Execution Count:3
3
695 -
696 -
697 -
698QUnixPrintWidget::~QUnixPrintWidget() -
699{ -
700 delete d; -
701}
executed: }
Execution Count:3
3
702 -
703 -
704 -
705 -
706 -
707void QUnixPrintWidget::updatePrinter() -
708{ -
709 d->setupPrinter(); -
710}
never executed: }
0
711 -
712 -
713 -
714 -
715 -
716 -
717 -
718 -
719 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial