dialogs/qprintpreviewdialog.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8namespace { -
9class QPrintPreviewMainWindow : public QMainWindow -
10{ -
11public: -
12 QPrintPreviewMainWindow(QWidget *parent) : QMainWindow(parent) {}
never executed: }
0
13 QMenu *createPopupMenu() { return 0; }
never executed: return 0;
0
14}; -
15 -
16class ZoomFactorValidator : public QDoubleValidator -
17{ -
18public: -
19 ZoomFactorValidator(QObject* parent) -
20 : QDoubleValidator(parent) {}
never executed: }
0
21 ZoomFactorValidator(qreal bottom, qreal top, int decimals, QObject *parent) -
22 : QDoubleValidator(bottom, top, decimals, parent) {}
never executed: }
0
23 -
24 State validate(QString &input, int &pos) const -
25 { -
26 bool replacePercent = false; -
27 if (input.endsWith(QLatin1Char('%'))) {
never evaluated: input.endsWith(QLatin1Char('%'))
0
28 input = input.left(input.length() - 1); -
29 replacePercent = true; -
30 }
never executed: }
0
31 State state = QDoubleValidator::validate(input, pos); -
32 if (replacePercent)
never evaluated: replacePercent
0
33 input += QLatin1Char('%');
never executed: input += QLatin1Char('%');
0
34 const int num_size = 4; -
35 if (state == Intermediate) {
never evaluated: state == Intermediate
0
36 int i = input.indexOf(QLocale::system().decimalPoint()); -
37 if ((i == -1 && input.size() > num_size)
never evaluated: i == -1
never evaluated: input.size() > num_size
0
38 || (i != -1 && i > num_size))
never evaluated: i != -1
never evaluated: i > num_size
0
39 return Invalid;
never executed: return Invalid;
0
40 }
never executed: }
0
41 return state;
never executed: return state;
0
42 } -
43}; -
44 -
45class LineEdit : public QLineEdit -
46{ -
47 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 {}; -
48public: -
49 LineEdit(QWidget* parent = 0) -
50 : QLineEdit(parent) -
51 { -
52 setContextMenuPolicy(Qt::NoContextMenu); -
53 connect(this, "2""returnPressed()", "1""handleReturnPressed()"); -
54 }
never executed: }
0
55 -
56protected: -
57 void focusInEvent(QFocusEvent *e) -
58 { -
59 origText = text(); -
60 QLineEdit::focusInEvent(e); -
61 }
never executed: }
0
62 -
63 void focusOutEvent(QFocusEvent *e) -
64 { -
65 if (isModified() && !hasAcceptableInput())
never evaluated: isModified()
never evaluated: !hasAcceptableInput()
0
66 setText(origText);
never executed: setText(origText);
0
67 QLineEdit::focusOutEvent(e); -
68 }
never executed: }
0
69 -
70private : -
71 void handleReturnPressed() -
72 { -
73 origText = text(); -
74 }
never executed: }
0
75 -
76private: -
77 QString origText; -
78}; -
79} -
80 -
81class QPrintPreviewDialogPrivate : public QDialogPrivate -
82{ -
83 inline QPrintPreviewDialog* q_func() { return static_cast<QPrintPreviewDialog *>(q_ptr); } inline const QPrintPreviewDialog* q_func() const { return static_cast<const QPrintPreviewDialog *>(q_ptr); } friend class QPrintPreviewDialog; -
84public: -
85 QPrintPreviewDialogPrivate() -
86 : printDialog(0), ownPrinter(false), -
87 initialized(false) {}
never executed: }
0
88 -
89 -
90 void _q_fit(QAction *action); -
91 void _q_zoomIn(); -
92 void _q_zoomOut(); -
93 void _q_navigate(QAction *action); -
94 void _q_setMode(QAction *action); -
95 void _q_pageNumEdited(); -
96 void _q_print(); -
97 void _q_pageSetup(); -
98 void _q_previewChanged(); -
99 void _q_zoomFactorChanged(); -
100 -
101 void init(QPrinter *printer = 0); -
102 void populateScene(); -
103 void layoutPages(); -
104 void setupActions(); -
105 void updateNavActions(); -
106 void setFitting(bool on); -
107 bool isFitting(); -
108 void updatePageNumLabel(); -
109 void updateZoomFactor(); -
110 -
111 QPrintDialog *printDialog; -
112 QPrintPreviewWidget *preview; -
113 QPrinter *printer; -
114 bool ownPrinter; -
115 bool initialized; -
116 -
117 -
118 QLineEdit *pageNumEdit; -
119 QLabel *pageNumLabel; -
120 QComboBox *zoomFactor; -
121 -
122 -
123 QActionGroup* navGroup; -
124 QAction *nextPageAction; -
125 QAction *prevPageAction; -
126 QAction *firstPageAction; -
127 QAction *lastPageAction; -
128 -
129 QActionGroup* fitGroup; -
130 QAction *fitWidthAction; -
131 QAction *fitPageAction; -
132 -
133 QActionGroup* zoomGroup; -
134 QAction *zoomInAction; -
135 QAction *zoomOutAction; -
136 -
137 QActionGroup* orientationGroup; -
138 QAction *portraitAction; -
139 QAction *landscapeAction; -
140 -
141 QActionGroup* modeGroup; -
142 QAction *singleModeAction; -
143 QAction *facingModeAction; -
144 QAction *overviewModeAction; -
145 -
146 QActionGroup *printerGroup; -
147 QAction *printAction; -
148 QAction *pageSetupAction; -
149 -
150 QPointer<QObject> receiverToDisconnectOnClose; -
151 QByteArray memberToDisconnectOnClose; -
152}; -
153 -
154void QPrintPreviewDialogPrivate::init(QPrinter *_printer) -
155{ -
156 QPrintPreviewDialog * const q = q_func(); -
157 -
158 if (_printer) {
never evaluated: _printer
0
159 preview = new QPrintPreviewWidget(_printer, q); -
160 printer = _printer; -
161 } else {
never executed: }
0
162 ownPrinter = true; -
163 printer = new QPrinter; -
164 preview = new QPrintPreviewWidget(printer, q); -
165 }
never executed: }
0
166 QObject::connect(preview, "2""paintRequested(QPrinter*)", q, "2""paintRequested(QPrinter*)"); -
167 QObject::connect(preview, "2""previewChanged()", q, "1""_q_previewChanged()"); -
168 setupActions(); -
169 -
170 pageNumEdit = new LineEdit; -
171 pageNumEdit->setAlignment(Qt::AlignRight); -
172 pageNumEdit->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); -
173 pageNumLabel = new QLabel; -
174 QObject::connect(pageNumEdit, "2""editingFinished()", q, "1""_q_pageNumEdited()"); -
175 -
176 zoomFactor = new QComboBox; -
177 zoomFactor->setEditable(true); -
178 zoomFactor->setMinimumContentsLength(7); -
179 zoomFactor->setInsertPolicy(QComboBox::NoInsert); -
180 LineEdit *zoomEditor = new LineEdit; -
181 zoomEditor->setValidator(new ZoomFactorValidator(1, 1000, 1, zoomEditor)); -
182 zoomFactor->setLineEdit(zoomEditor); -
183 static const short factorsX2[] = { 25, 50, 100, 200, 250, 300, 400, 800, 1600 }; -
184 for (int i = 0; i < int(sizeof(factorsX2) / sizeof(factorsX2[0])); ++i)
never evaluated: i < int(sizeof(factorsX2) / sizeof(factorsX2[0]))
0
185 zoomFactor->addItem(QPrintPreviewDialog::tr("%1%").arg(factorsX2[i] / 2.0));
never executed: zoomFactor->addItem(QPrintPreviewDialog::tr("%1%").arg(factorsX2[i] / 2.0));
0
186 QObject::connect(zoomFactor->lineEdit(), "2""editingFinished()", -
187 q, "1""_q_zoomFactorChanged()"); -
188 QObject::connect(zoomFactor, "2""currentIndexChanged(int)", -
189 q, "1""_q_zoomFactorChanged()"); -
190 -
191 QPrintPreviewMainWindow *mw = new QPrintPreviewMainWindow(q); -
192 QToolBar *toolbar = new QToolBar(mw); -
193 toolbar->addAction(fitWidthAction); -
194 toolbar->addAction(fitPageAction); -
195 toolbar->addSeparator(); -
196 toolbar->addWidget(zoomFactor); -
197 toolbar->addAction(zoomOutAction); -
198 toolbar->addAction(zoomInAction); -
199 toolbar->addSeparator(); -
200 toolbar->addAction(portraitAction); -
201 toolbar->addAction(landscapeAction); -
202 toolbar->addSeparator(); -
203 toolbar->addAction(firstPageAction); -
204 toolbar->addAction(prevPageAction); -
205 -
206 -
207 -
208 -
209 QWidget *pageEdit = new QWidget(toolbar); -
210 QVBoxLayout *vboxLayout = new QVBoxLayout; -
211 vboxLayout->setContentsMargins(0, 0, 0, 0); -
212 QFormLayout *formLayout = new QFormLayout; -
213 -
214 -
215 -
216 -
217 formLayout->setWidget(0, QFormLayout::LabelRole, pageNumEdit); -
218 formLayout->setWidget(0, QFormLayout::FieldRole, pageNumLabel); -
219 vboxLayout->addLayout(formLayout); -
220 vboxLayout->setAlignment(Qt::AlignVCenter); -
221 pageEdit->setLayout(vboxLayout); -
222 toolbar->addWidget(pageEdit); -
223 -
224 toolbar->addAction(nextPageAction); -
225 toolbar->addAction(lastPageAction); -
226 toolbar->addSeparator(); -
227 toolbar->addAction(singleModeAction); -
228 toolbar->addAction(facingModeAction); -
229 toolbar->addAction(overviewModeAction); -
230 toolbar->addSeparator(); -
231 toolbar->addAction(pageSetupAction); -
232 toolbar->addAction(printAction); -
233 -
234 -
235 QToolButton *zoomInButton = static_cast<QToolButton *>(toolbar->widgetForAction(zoomInAction)); -
236 QToolButton *zoomOutButton = static_cast<QToolButton *>(toolbar->widgetForAction(zoomOutAction)); -
237 zoomInButton->setAutoRepeat(true); -
238 zoomInButton->setAutoRepeatInterval(200); -
239 zoomInButton->setAutoRepeatDelay(200); -
240 zoomOutButton->setAutoRepeat(true); -
241 zoomOutButton->setAutoRepeatInterval(200); -
242 zoomOutButton->setAutoRepeatDelay(200); -
243 QObject::connect(zoomInButton, "2""clicked()", q, "1""_q_zoomIn()"); -
244 QObject::connect(zoomOutButton, "2""clicked()", q, "1""_q_zoomOut()"); -
245 -
246 mw->addToolBar(toolbar); -
247 mw->setCentralWidget(preview); -
248 -
249 -
250 mw->setParent(q, Qt::Widget); -
251 -
252 QVBoxLayout *topLayout = new QVBoxLayout; -
253 topLayout->addWidget(mw); -
254 topLayout->setMargin(0); -
255 q->setLayout(topLayout); -
256 -
257 QString caption = QCoreApplication::translate("QPrintPreviewDialog", "Print Preview"); -
258 if (!printer->docName().isEmpty())
never evaluated: !printer->docName().isEmpty()
0
259 caption += QString::fromLatin1(": ") + printer->docName();
never executed: caption += QString::fromLatin1(": ") + printer->docName();
0
260 q->setWindowTitle(caption); -
261 -
262 if (!printer->isValid()
never evaluated: !printer->isValid()
0
263 -
264 -
265 -
266 ) -
267 pageSetupAction->setEnabled(false);
never executed: pageSetupAction->setEnabled(false);
0
268 preview->setFocus(); -
269}
never executed: }
0
270 -
271static inline void qt_setupActionIcon(QAction *action, QLatin1String name) -
272{ -
273 QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/"); -
274 QIcon icon; -
275 icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24)); -
276 icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32)); -
277 action->setIcon(icon); -
278}
never executed: }
0
279 -
280void QPrintPreviewDialogPrivate::setupActions() -
281{ -
282 QPrintPreviewDialog * const q = q_func(); -
283 -
284 -
285 navGroup = new QActionGroup(q); -
286 navGroup->setExclusive(false); -
287 nextPageAction = navGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Next page")); -
288 prevPageAction = navGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Previous page")); -
289 firstPageAction = navGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "First page")); -
290 lastPageAction = navGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Last page")); -
291 qt_setupActionIcon(nextPageAction, QLatin1String("go-next")); -
292 qt_setupActionIcon(prevPageAction, QLatin1String("go-previous")); -
293 qt_setupActionIcon(firstPageAction, QLatin1String("go-first")); -
294 qt_setupActionIcon(lastPageAction, QLatin1String("go-last")); -
295 QObject::connect(navGroup, "2""triggered(QAction*)", q, "1""_q_navigate(QAction*)"); -
296 -
297 -
298 fitGroup = new QActionGroup(q); -
299 fitWidthAction = fitGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Fit width")); -
300 fitPageAction = fitGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Fit page")); -
301 fitWidthAction->setObjectName(QLatin1String("fitWidthAction")); -
302 fitPageAction->setObjectName(QLatin1String("fitPageAction")); -
303 fitWidthAction->setCheckable(true); -
304 fitPageAction->setCheckable(true); -
305 qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width")); -
306 qt_setupActionIcon(fitPageAction, QLatin1String("fit-page")); -
307 QObject::connect(fitGroup, "2""triggered(QAction*)", q, "1""_q_fit(QAction*)"); -
308 -
309 -
310 zoomGroup = new QActionGroup(q); -
311 zoomInAction = zoomGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Zoom in")); -
312 zoomOutAction = zoomGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Zoom out")); -
313 qt_setupActionIcon(zoomInAction, QLatin1String("zoom-in")); -
314 qt_setupActionIcon(zoomOutAction, QLatin1String("zoom-out")); -
315 -
316 -
317 orientationGroup = new QActionGroup(q); -
318 portraitAction = orientationGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Portrait")); -
319 landscapeAction = orientationGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Landscape")); -
320 portraitAction->setCheckable(true); -
321 landscapeAction->setCheckable(true); -
322 qt_setupActionIcon(portraitAction, QLatin1String("layout-portrait")); -
323 qt_setupActionIcon(landscapeAction, QLatin1String("layout-landscape")); -
324 QObject::connect(portraitAction, "2""triggered(bool)", preview, "1""setPortraitOrientation()"); -
325 QObject::connect(landscapeAction, "2""triggered(bool)", preview, "1""setLandscapeOrientation()"); -
326 -
327 -
328 modeGroup = new QActionGroup(q); -
329 singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page")); -
330 facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages")); -
331 overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages")); -
332 qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one")); -
333 qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided")); -
334 qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi")); -
335 singleModeAction->setObjectName(QLatin1String("singleModeAction")); -
336 facingModeAction->setObjectName(QLatin1String("facingModeAction")); -
337 overviewModeAction->setObjectName(QLatin1String("overviewModeAction")); -
338 -
339 singleModeAction->setCheckable(true); -
340 facingModeAction->setCheckable(true); -
341 overviewModeAction->setCheckable(true); -
342 QObject::connect(modeGroup, "2""triggered(QAction*)", q, "1""_q_setMode(QAction*)"); -
343 -
344 -
345 printerGroup = new QActionGroup(q); -
346 printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print")); -
347 pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup")); -
348 qt_setupActionIcon(printAction, QLatin1String("print")); -
349 qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup")); -
350 QObject::connect(printAction, "2""triggered(bool)", q, "1""_q_print()"); -
351 QObject::connect(pageSetupAction, "2""triggered(bool)", q, "1""_q_pageSetup()"); -
352 -
353 -
354 fitPageAction->setChecked(true); -
355 singleModeAction->setChecked(true); -
356 if (preview->orientation() == QPrinter::Portrait)
never evaluated: preview->orientation() == QPrinter::Portrait
0
357 portraitAction->setChecked(true);
never executed: portraitAction->setChecked(true);
0
358 else -
359 landscapeAction->setChecked(true);
never executed: landscapeAction->setChecked(true);
0
360} -
361 -
362 -
363bool QPrintPreviewDialogPrivate::isFitting() -
364{ -
365 return (fitGroup->isExclusive() 0
366 && (fitWidthAction->isChecked() || fitPageAction->isChecked()));
never executed: return (fitGroup->isExclusive() && (fitWidthAction->isChecked() || fitPageAction->isChecked()));
0
367} -
368 -
369 -
370void QPrintPreviewDialogPrivate::setFitting(bool on) -
371{ -
372 if (isFitting() == on)
never evaluated: isFitting() == on
0
373 return;
never executed: return;
0
374 fitGroup->setExclusive(on); -
375 if (on) {
never evaluated: on
0
376 QAction* action = fitWidthAction->isChecked() ? fitWidthAction : fitPageAction;
never evaluated: fitWidthAction->isChecked()
0
377 action->setChecked(true); -
378 if (fitGroup->checkedAction() != action) {
never evaluated: fitGroup->checkedAction() != action
0
379 -
380 fitGroup->removeAction(action); -
381 fitGroup->addAction(action); -
382 }
never executed: }
0
383 } else {
never executed: }
0
384 fitWidthAction->setChecked(false); -
385 fitPageAction->setChecked(false); -
386 }
never executed: }
0
387} -
388 -
389void QPrintPreviewDialogPrivate::updateNavActions() -
390{ -
391 int curPage = preview->currentPage(); -
392 int numPages = preview->pageCount(); -
393 nextPageAction->setEnabled(curPage < numPages); -
394 prevPageAction->setEnabled(curPage > 1); -
395 firstPageAction->setEnabled(curPage > 1); -
396 lastPageAction->setEnabled(curPage < numPages); -
397 pageNumEdit->setText(QString::number(curPage)); -
398}
never executed: }
0
399 -
400void QPrintPreviewDialogPrivate::updatePageNumLabel() -
401{ -
402 QPrintPreviewDialog * const q = q_func(); -
403 -
404 int numPages = preview->pageCount(); -
405 int maxChars = QString::number(numPages).length(); -
406 pageNumLabel->setText(QString::fromLatin1("/ %1").arg(numPages)); -
407 int cyphersWidth = q->fontMetrics().width(QString().fill(QLatin1Char('8'), maxChars)); -
408 int maxWidth = pageNumEdit->minimumSizeHint().width() + cyphersWidth; -
409 pageNumEdit->setMinimumWidth(maxWidth); -
410 pageNumEdit->setMaximumWidth(maxWidth); -
411 pageNumEdit->setValidator(new QIntValidator(1, numPages, pageNumEdit)); -
412 -
413}
never executed: }
0
414 -
415void QPrintPreviewDialogPrivate::updateZoomFactor() -
416{ -
417 zoomFactor->lineEdit()->setText(QString().sprintf("%.1f%%", preview->zoomFactor()*100)); -
418}
never executed: }
0
419 -
420void QPrintPreviewDialogPrivate::_q_fit(QAction* action) -
421{ -
422 setFitting(true); -
423 if (action == fitPageAction)
never evaluated: action == fitPageAction
0
424 preview->fitInView();
never executed: preview->fitInView();
0
425 else -
426 preview->fitToWidth();
never executed: preview->fitToWidth();
0
427} -
428 -
429void QPrintPreviewDialogPrivate::_q_zoomIn() -
430{ -
431 setFitting(false); -
432 preview->zoomIn(); -
433 updateZoomFactor(); -
434}
never executed: }
0
435 -
436void QPrintPreviewDialogPrivate::_q_zoomOut() -
437{ -
438 setFitting(false); -
439 preview->zoomOut(); -
440 updateZoomFactor(); -
441}
never executed: }
0
442 -
443void QPrintPreviewDialogPrivate::_q_pageNumEdited() -
444{ -
445 bool ok = false; -
446 int res = pageNumEdit->text().toInt(&ok); -
447 if (ok)
never evaluated: ok
0
448 preview->setCurrentPage(res);
never executed: preview->setCurrentPage(res);
0
449}
never executed: }
0
450 -
451void QPrintPreviewDialogPrivate::_q_navigate(QAction* action) -
452{ -
453 int curPage = preview->currentPage(); -
454 if (action == prevPageAction)
never evaluated: action == prevPageAction
0
455 preview->setCurrentPage(curPage - 1);
never executed: preview->setCurrentPage(curPage - 1);
0
456 else if (action == nextPageAction)
never evaluated: action == nextPageAction
0
457 preview->setCurrentPage(curPage + 1);
never executed: preview->setCurrentPage(curPage + 1);
0
458 else if (action == firstPageAction)
never evaluated: action == firstPageAction
0
459 preview->setCurrentPage(1);
never executed: preview->setCurrentPage(1);
0
460 else if (action == lastPageAction)
never evaluated: action == lastPageAction
0
461 preview->setCurrentPage(preview->pageCount());
never executed: preview->setCurrentPage(preview->pageCount());
0
462 updateNavActions(); -
463}
never executed: }
0
464 -
465void QPrintPreviewDialogPrivate::_q_setMode(QAction* action) -
466{ -
467 if (action == overviewModeAction) {
never evaluated: action == overviewModeAction
0
468 preview->setViewMode(QPrintPreviewWidget::AllPagesView); -
469 setFitting(false); -
470 fitGroup->setEnabled(false); -
471 navGroup->setEnabled(false); -
472 pageNumEdit->setEnabled(false); -
473 pageNumLabel->setEnabled(false); -
474 } else if (action == facingModeAction) {
never executed: }
never evaluated: action == facingModeAction
0
475 preview->setViewMode(QPrintPreviewWidget::FacingPagesView); -
476 } else {
never executed: }
0
477 preview->setViewMode(QPrintPreviewWidget::SinglePageView); -
478 }
never executed: }
0
479 if (action == facingModeAction || action == singleModeAction) {
never evaluated: action == facingModeAction
never evaluated: action == singleModeAction
0
480 fitGroup->setEnabled(true); -
481 navGroup->setEnabled(true); -
482 pageNumEdit->setEnabled(true); -
483 pageNumLabel->setEnabled(true); -
484 setFitting(true); -
485 }
never executed: }
0
486}
never executed: }
0
487 -
488void QPrintPreviewDialogPrivate::_q_print() -
489{ -
490 QPrintPreviewDialog * const q = q_func(); -
491 if (!printDialog)
never evaluated: !printDialog
0
492 printDialog = new QPrintDialog(printer, q);
never executed: printDialog = new QPrintDialog(printer, q);
0
493 if (printDialog->exec() == QDialog::Accepted) {
never evaluated: printDialog->exec() == QDialog::Accepted
0
494 preview->print(); -
495 q->accept(); -
496 }
never executed: }
0
497}
never executed: }
0
498 -
499void QPrintPreviewDialogPrivate::_q_pageSetup() -
500{ -
501 QPrintPreviewDialog * const q = q_func(); -
502 -
503 QPageSetupDialog pageSetup(printer, q); -
504 if (pageSetup.exec() == QDialog::Accepted) {
never evaluated: pageSetup.exec() == QDialog::Accepted
0
505 -
506 if (preview->orientation() == QPrinter::Portrait) {
never evaluated: preview->orientation() == QPrinter::Portrait
0
507 portraitAction->setChecked(true); -
508 preview->setPortraitOrientation(); -
509 }else {
never executed: }
0
510 landscapeAction->setChecked(true); -
511 preview->setLandscapeOrientation(); -
512 }
never executed: }
0
513 } -
514}
never executed: }
0
515 -
516void QPrintPreviewDialogPrivate::_q_previewChanged() -
517{ -
518 updateNavActions(); -
519 updatePageNumLabel(); -
520 updateZoomFactor(); -
521}
never executed: }
0
522 -
523void QPrintPreviewDialogPrivate::_q_zoomFactorChanged() -
524{ -
525 QString text = zoomFactor->lineEdit()->text(); -
526 bool ok; -
527 qreal factor = text.remove(QLatin1Char('%')).toFloat(&ok); -
528 factor = qMax(qreal(1.0), qMin(qreal(1000.0), factor)); -
529 if (ok) {
never evaluated: ok
0
530 preview->setZoomFactor(factor/100.0); -
531 zoomFactor->setEditText(QString::fromLatin1("%1%").arg(factor)); -
532 setFitting(false); -
533 }
never executed: }
0
534}
never executed: }
0
535QPrintPreviewDialog::QPrintPreviewDialog(QPrinter* printer, QWidget *parent, Qt::WindowFlags flags) -
536 : QDialog(*new QPrintPreviewDialogPrivate, parent, flags) -
537{ -
538 QPrintPreviewDialogPrivate * const d = d_func(); -
539 d->init(printer); -
540}
never executed: }
0
541QPrintPreviewDialog::QPrintPreviewDialog(QWidget *parent, Qt::WindowFlags f) -
542 : QDialog(*new QPrintPreviewDialogPrivate, parent, f) -
543{ -
544 QPrintPreviewDialogPrivate * const d = d_func(); -
545 d->init(); -
546}
never executed: }
0
547 -
548 -
549 -
550 -
551QPrintPreviewDialog::~QPrintPreviewDialog() -
552{ -
553 QPrintPreviewDialogPrivate * const d = d_func(); -
554 if (d->ownPrinter)
never evaluated: d->ownPrinter
0
555 delete d->printer;
never executed: delete d->printer;
0
556 delete d->printDialog; -
557}
never executed: }
0
558 -
559 -
560 -
561 -
562void QPrintPreviewDialog::setVisible(bool visible) -
563{ -
564 QPrintPreviewDialogPrivate * const d = d_func(); -
565 -
566 if (visible && !d->initialized) {
never evaluated: visible
never evaluated: !d->initialized
0
567 d->preview->updatePreview(); -
568 d->initialized = true; -
569 }
never executed: }
0
570 QDialog::setVisible(visible); -
571}
never executed: }
0
572 -
573 -
574 -
575 -
576void QPrintPreviewDialog::done(int result) -
577{ -
578 QPrintPreviewDialogPrivate * const d = d_func(); -
579 QDialog::done(result); -
580 if (d->receiverToDisconnectOnClose) {
never evaluated: d->receiverToDisconnectOnClose
0
581 disconnect(this, "2""finished(int)", -
582 d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); -
583 d->receiverToDisconnectOnClose = 0; -
584 }
never executed: }
0
585 d->memberToDisconnectOnClose.clear(); -
586}
never executed: }
0
587void QPrintPreviewDialog::open(QObject *receiver, const char *member) -
588{ -
589 QPrintPreviewDialogPrivate * const d = d_func(); -
590 -
591 -
592 connect(this, "2""finished(int)", receiver, member); -
593 d->receiverToDisconnectOnClose = receiver; -
594 d->memberToDisconnectOnClose = member; -
595 QDialog::open(); -
596}
never executed: }
0
597 -
598 -
599 -
600 -
601 -
602QPrinter *QPrintPreviewDialog::printer() -
603{ -
604 QPrintPreviewDialogPrivate * const d = d_func(); -
605 return d->printer;
never executed: return d->printer;
0
606} -
607 -
608 -
609 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial