qprintpreviewdialog.cpp

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

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