Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | QSizeF qt_printerPaperSize(QPrinter::Orientation, QPrinter::PaperSize, QPrinter::Unit, int); | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | static void populatePaperSizes(QComboBox* cb) | - |
18 | { | - |
19 | cb->addItem(QPrintDialog::tr("A0"), QPrinter::A0); | - |
20 | cb->addItem(QPrintDialog::tr("A1"), QPrinter::A1); | - |
21 | cb->addItem(QPrintDialog::tr("A2"), QPrinter::A2); | - |
22 | cb->addItem(QPrintDialog::tr("A3"), QPrinter::A3); | - |
23 | cb->addItem(QPrintDialog::tr("A4"), QPrinter::A4); | - |
24 | cb->addItem(QPrintDialog::tr("A5"), QPrinter::A5); | - |
25 | cb->addItem(QPrintDialog::tr("A6"), QPrinter::A6); | - |
26 | cb->addItem(QPrintDialog::tr("A7"), QPrinter::A7); | - |
27 | cb->addItem(QPrintDialog::tr("A8"), QPrinter::A8); | - |
28 | cb->addItem(QPrintDialog::tr("A9"), QPrinter::A9); | - |
29 | cb->addItem(QPrintDialog::tr("B0"), QPrinter::B0); | - |
30 | cb->addItem(QPrintDialog::tr("B1"), QPrinter::B1); | - |
31 | cb->addItem(QPrintDialog::tr("B2"), QPrinter::B2); | - |
32 | cb->addItem(QPrintDialog::tr("B3"), QPrinter::B3); | - |
33 | cb->addItem(QPrintDialog::tr("B4"), QPrinter::B4); | - |
34 | cb->addItem(QPrintDialog::tr("B5"), QPrinter::B5); | - |
35 | cb->addItem(QPrintDialog::tr("B6"), QPrinter::B6); | - |
36 | cb->addItem(QPrintDialog::tr("B7"), QPrinter::B7); | - |
37 | cb->addItem(QPrintDialog::tr("B8"), QPrinter::B8); | - |
38 | cb->addItem(QPrintDialog::tr("B9"), QPrinter::B9); | - |
39 | cb->addItem(QPrintDialog::tr("B10"), QPrinter::B10); | - |
40 | cb->addItem(QPrintDialog::tr("C5E"), QPrinter::C5E); | - |
41 | cb->addItem(QPrintDialog::tr("DLE"), QPrinter::DLE); | - |
42 | cb->addItem(QPrintDialog::tr("Executive"), QPrinter::Executive); | - |
43 | cb->addItem(QPrintDialog::tr("Folio"), QPrinter::Folio); | - |
44 | cb->addItem(QPrintDialog::tr("Ledger"), QPrinter::Ledger); | - |
45 | cb->addItem(QPrintDialog::tr("Legal"), QPrinter::Legal); | - |
46 | cb->addItem(QPrintDialog::tr("Letter"), QPrinter::Letter); | - |
47 | cb->addItem(QPrintDialog::tr("Tabloid"), QPrinter::Tabloid); | - |
48 | cb->addItem(QPrintDialog::tr("US Common #10 Envelope"), QPrinter::Comm10E); | - |
49 | cb->addItem(QPrintDialog::tr("Custom"), QPrinter::Custom); | - |
50 | } | 0 |
51 | | - |
52 | | - |
53 | static QSizeF sizeForOrientation(QPrinter::Orientation orientation, const QSizeF &size) | - |
54 | { | - |
55 | return (orientation == QPrinter::Portrait) ? size : QSizeF(size.height(), size.width()); never executed: return (orientation == QPrinter::Portrait) ? size : QSizeF(size.height(), size.width()); | 0 |
56 | } | - |
57 | class QPagePreview : public QWidget | - |
58 | { | - |
59 | public: | - |
60 | QPagePreview(QWidget *parent) : QWidget(parent) | - |
61 | { | - |
62 | setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | - |
63 | setMinimumSize(50, 50); | - |
64 | } | 0 |
65 | | - |
66 | void setPaperSize(const QSizeF& size) | - |
67 | { | - |
68 | m_size = size; | - |
69 | update(); | - |
70 | } | 0 |
71 | | - |
72 | void setMargins(qreal left, qreal top, qreal right, qreal bottom) | - |
73 | { | - |
74 | m_left = left; | - |
75 | m_top = top; | - |
76 | m_right = right; | - |
77 | m_bottom = bottom; | - |
78 | update(); | - |
79 | } | 0 |
80 | | - |
81 | protected: | - |
82 | void paintEvent(QPaintEvent *) | - |
83 | { | - |
84 | QRect pageRect; | - |
85 | QSizeF adjustedSize(m_size); | - |
86 | adjustedSize.scale(width()-10, height()-10, Qt::KeepAspectRatio); | - |
87 | pageRect = QRect(QPoint(0,0), adjustedSize.toSize()); | - |
88 | pageRect.moveCenter(rect().center()); | - |
89 | | - |
90 | qreal width_factor = pageRect.width() / m_size.width(); | - |
91 | qreal height_factor = pageRect.height() / m_size.height(); | - |
92 | int leftSize = qRound(m_left*width_factor); | - |
93 | int topSize = qRound(m_top*height_factor); | - |
94 | int rightSize = qRound(m_right*width_factor); | - |
95 | int bottomSize = qRound(m_bottom * height_factor); | - |
96 | QRect marginRect(pageRect.x()+leftSize, | - |
97 | pageRect.y()+topSize, | - |
98 | pageRect.width() - (leftSize+rightSize+1), | - |
99 | pageRect.height() - (topSize+bottomSize+1)); | - |
100 | | - |
101 | QPainter p(this); | - |
102 | QColor shadow(palette().mid().color()); | - |
103 | for (int i=1; i<6; ++i) { | 0 |
104 | shadow.setAlpha(180-i*30); | - |
105 | QRect offset(pageRect.adjusted(i, i, i, i)); | - |
106 | p.setPen(shadow); | - |
107 | p.drawLine(offset.left(), offset.bottom(), offset.right(), offset.bottom()); | - |
108 | p.drawLine(offset.right(), offset.top(), offset.right(), offset.bottom()-1); | - |
109 | } | 0 |
110 | p.fillRect(pageRect, palette().light()); | - |
111 | | - |
112 | if (marginRect.isValid()) { never evaluated: marginRect.isValid() | 0 |
113 | p.setPen(QPen(palette().color(QPalette::Dark), 0, Qt::DotLine)); | - |
114 | p.drawRect(marginRect); | - |
115 | | - |
116 | marginRect.adjust(2, 2, -1, -1); | - |
117 | p.setClipRect(marginRect); | - |
118 | QFont font; | - |
119 | font.setPointSizeF(font.pointSizeF()*0.25); | - |
120 | p.setFont(font); | - |
121 | p.setPen(palette().color(QPalette::Dark)); | - |
122 | QString text(QLatin1String("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.")); | - |
123 | for (int i=0; i<3; ++i) | 0 |
124 | text += text; never executed: text += text; | 0 |
125 | p.drawText(marginRect, Qt::TextWordWrap|Qt::AlignVCenter, text); | - |
126 | } | 0 |
127 | } | 0 |
128 | | - |
129 | private: | - |
130 | | - |
131 | qreal m_left, m_top, m_right, m_bottom; | - |
132 | QSizeF m_size; | - |
133 | }; | - |
134 | | - |
135 | | - |
136 | class QUnixPageSetupDialogPrivate : public QPageSetupDialogPrivate | - |
137 | { | - |
138 | inline QPageSetupDialog* q_func() { return static_cast<QPageSetupDialog *>(q_ptr); } inline const QPageSetupDialog* q_func() const { return static_cast<const QPageSetupDialog *>(q_ptr); } friend class QPageSetupDialog; | - |
139 | | - |
140 | public: | - |
141 | QUnixPageSetupDialogPrivate(QPrinter *printer); | - |
142 | ~QUnixPageSetupDialogPrivate(); | - |
143 | void init(); | - |
144 | | - |
145 | QPageSetupWidget *widget; | - |
146 | }; | - |
147 | | - |
148 | QUnixPageSetupDialogPrivate::QUnixPageSetupDialogPrivate(QPrinter *printer) : QPageSetupDialogPrivate(printer) | - |
149 | { | - |
150 | } executed: } Execution Count:1 | 1 |
151 | | - |
152 | QUnixPageSetupDialogPrivate::~QUnixPageSetupDialogPrivate() | - |
153 | { | - |
154 | } | - |
155 | | - |
156 | void QUnixPageSetupDialogPrivate::init() | - |
157 | { | - |
158 | QPageSetupDialog * const q = q_func(); | - |
159 | | - |
160 | widget = new QPageSetupWidget(q); | - |
161 | widget->setPrinter(printer); | - |
162 | | - |
163 | QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok | - |
164 | | QDialogButtonBox::Cancel, | - |
165 | Qt::Horizontal, q); | - |
166 | QObject::connect(buttons, "2""accepted()", q, "1""accept()"); | - |
167 | QObject::connect(buttons, "2""rejected()", q, "1""reject()"); | - |
168 | | - |
169 | QVBoxLayout *lay = new QVBoxLayout(q); | - |
170 | lay->addWidget(widget); | - |
171 | lay->addWidget(buttons); | - |
172 | } | 0 |
173 | | - |
174 | QPageSetupWidget::QPageSetupWidget(QWidget *parent) | - |
175 | : QWidget(parent), | - |
176 | m_printer(0), | - |
177 | m_blockSignals(false), | - |
178 | m_cups(false) | - |
179 | { | - |
180 | widget.setupUi(this); | - |
181 | | - |
182 | QString suffix = (QLocale::system().measurementSystem() == QLocale::ImperialSystem) never evaluated: (QLocale::system().measurementSystem() == QLocale::ImperialSystem) | 0 |
183 | ? QString::fromLatin1(" in") | - |
184 | : QString::fromLatin1(" mm"); | - |
185 | widget.topMargin->setSuffix(suffix); | - |
186 | widget.bottomMargin->setSuffix(suffix); | - |
187 | widget.leftMargin->setSuffix(suffix); | - |
188 | widget.rightMargin->setSuffix(suffix); | - |
189 | widget.paperWidth->setSuffix(suffix); | - |
190 | widget.paperHeight->setSuffix(suffix); | - |
191 | | - |
192 | QVBoxLayout *lay = new QVBoxLayout(widget.preview); | - |
193 | widget.preview->setLayout(lay); | - |
194 | m_pagePreview = new QPagePreview(widget.preview); | - |
195 | lay->addWidget(m_pagePreview); | - |
196 | | - |
197 | setAttribute(Qt::WA_WState_Polished, false); | - |
198 | | - |
199 | | - |
200 | | - |
201 | | - |
202 | | - |
203 | widget.paperSourceLabel->setVisible(false); | - |
204 | widget.paperSource->setVisible(false); | - |
205 | | - |
206 | | - |
207 | widget.reverseLandscape->setVisible(false); | - |
208 | widget.reversePortrait->setVisible(false); | - |
209 | | - |
210 | populatePaperSizes(widget.paperSize); | - |
211 | | - |
212 | QStringList units; | - |
213 | units << tr("Centimeters (cm)") << tr("Millimeters (mm)") << tr("Inches (in)") << tr("Points (pt)"); | - |
214 | widget.unit->addItems(units); | - |
215 | connect(widget.unit, "2""activated(int)", this, "1""unitChanged(int)"); | - |
216 | widget.unit->setCurrentIndex((QLocale::system().measurementSystem() == QLocale::ImperialSystem) ? 2 : 1); | - |
217 | | - |
218 | connect(widget.paperSize, "2""currentIndexChanged(int)", this, "1""_q_paperSizeChanged()"); | - |
219 | connect(widget.paperWidth, "2""valueChanged(double)", this, "1""_q_paperSizeChanged()"); | - |
220 | connect(widget.paperHeight, "2""valueChanged(double)", this, "1""_q_paperSizeChanged()"); | - |
221 | | - |
222 | connect(widget.leftMargin, "2""valueChanged(double)", this, "1""setLeftMargin(double)"); | - |
223 | connect(widget.topMargin, "2""valueChanged(double)", this, "1""setTopMargin(double)"); | - |
224 | connect(widget.rightMargin, "2""valueChanged(double)", this, "1""setRightMargin(double)"); | - |
225 | connect(widget.bottomMargin, "2""valueChanged(double)", this, "1""setBottomMargin(double)"); | - |
226 | | - |
227 | connect(widget.portrait, "2""clicked()", this, "1""_q_pageOrientationChanged()"); | - |
228 | connect(widget.landscape, "2""clicked()", this, "1""_q_pageOrientationChanged()"); | - |
229 | } | 0 |
230 | | - |
231 | void QPageSetupWidget::setPrinter(QPrinter *printer) | - |
232 | { | - |
233 | m_printer = printer; | - |
234 | m_blockSignals = true; | - |
235 | selectPdfPsPrinter(printer); | - |
236 | printer->getPageMargins(&m_leftMargin, &m_topMargin, &m_rightMargin, &m_bottomMargin, QPrinter::Point); | - |
237 | unitChanged(widget.unit->currentIndex()); | - |
238 | m_pagePreview->setMargins(m_leftMargin, m_topMargin, m_rightMargin, m_bottomMargin); | - |
239 | m_paperSize = printer->paperSize(QPrinter::Point); | - |
240 | widget.paperWidth->setValue(m_paperSize.width() / m_currentMultiplier); | - |
241 | widget.paperHeight->setValue(m_paperSize.height() / m_currentMultiplier); | - |
242 | | - |
243 | widget.landscape->setChecked(printer->orientation() == QPrinter::Landscape); | - |
244 | | - |
245 | | - |
246 | | - |
247 | | - |
248 | qt_noop(); | - |
249 | m_blockSignals = false; | - |
250 | _q_paperSizeChanged(); | - |
251 | } | 0 |
252 | | - |
253 | | - |
254 | void QPageSetupWidget::setupPrinter() const | - |
255 | { | - |
256 | QPrinter::Orientation orientation = widget.portrait->isChecked() never evaluated: widget.portrait->isChecked() | 0 |
257 | ? QPrinter::Portrait | - |
258 | : QPrinter::Landscape; | - |
259 | m_printer->setOrientation(orientation); | - |
260 | | - |
261 | QVariant val = widget.paperSize->itemData(widget.paperSize->currentIndex()); | - |
262 | int ps = m_printer->pageSize(); | - |
263 | if (val.type() == QVariant::Int) { never evaluated: val.type() == QVariant::Int | 0 |
264 | ps = val.toInt(); | - |
265 | } | 0 |
266 | | - |
267 | else if (val.type() == QVariant::ByteArray) { never evaluated: val.type() == QVariant::ByteArray | 0 |
268 | for (int papersize = 0; papersize < QPrinter::NPageSize; ++papersize) { never evaluated: papersize < QPrinter::NPageSize | 0 |
269 | QPdf::PaperSize size = QPdf::paperSize(QPrinter::PaperSize(papersize)); | - |
270 | if (size.width == m_paperSize.width() && size.height == m_paperSize.height()) { never evaluated: size.width == m_paperSize.width() never evaluated: size.height == m_paperSize.height() | 0 |
271 | ps = static_cast<QPrinter::PaperSize>(papersize); | - |
272 | break; | 0 |
273 | } | - |
274 | } | 0 |
275 | } | 0 |
276 | | - |
277 | if (ps == QPrinter::Custom) { never evaluated: ps == QPrinter::Custom | 0 |
278 | m_printer->setPaperSize(sizeForOrientation(orientation, m_paperSize), QPrinter::Point); | - |
279 | } | 0 |
280 | else { | - |
281 | m_printer->setPaperSize(static_cast<QPrinter::PaperSize>(ps)); | - |
282 | } | 0 |
283 | | - |
284 | | - |
285 | | - |
286 | | - |
287 | m_printer->setPageMargins(m_leftMargin, m_topMargin, m_rightMargin, m_bottomMargin, QPrinter::Point); | - |
288 | | - |
289 | } | 0 |
290 | | - |
291 | void QPageSetupWidget::selectPrinter() | - |
292 | { | - |
293 | widget.paperSize->clear(); | - |
294 | | - |
295 | if (QCUPSSupport::isAvailable()) { never evaluated: QCUPSSupport::isAvailable() | 0 |
296 | m_cups = true; | - |
297 | QCUPSSupport cups; | - |
298 | const ppd_option_t* pageSizes = cups.pageSizes(); | - |
299 | const int numChoices = pageSizes ? pageSizes->num_choices : 0; never evaluated: pageSizes | 0 |
300 | | - |
301 | int cupsDefaultSize = 0; | - |
302 | QSize qtPreferredSize = m_printer->paperSize(QPrinter::Point).toSize(); | - |
303 | bool preferredSizeMatched = false; | - |
304 | for (int i = 0; i < numChoices; ++i) { never evaluated: i < numChoices | 0 |
305 | widget.paperSize->addItem(QString::fromLocal8Bit(pageSizes->choices[i].text), QByteArray(pageSizes->choices[i].choice)); | - |
306 | if (static_cast<int>(pageSizes->choices[i].marked) == 1) never evaluated: static_cast<int>(pageSizes->choices[i].marked) == 1 | 0 |
307 | cupsDefaultSize = i; never executed: cupsDefaultSize = i; | 0 |
308 | QRect cupsPaperSize = cups.paperRect(pageSizes->choices[i].choice); | - |
309 | QSize diff = cupsPaperSize.size() - qtPreferredSize; | - |
310 | if (qAbs(diff.width()) < 5 && qAbs(diff.height()) < 5) { never evaluated: qAbs(diff.width()) < 5 never evaluated: qAbs(diff.height()) < 5 | 0 |
311 | widget.paperSize->setCurrentIndex(i); | - |
312 | preferredSizeMatched = true; | - |
313 | } | 0 |
314 | } | 0 |
315 | if (!preferredSizeMatched) never evaluated: !preferredSizeMatched | 0 |
316 | widget.paperSize->setCurrentIndex(cupsDefaultSize); never executed: widget.paperSize->setCurrentIndex(cupsDefaultSize); | 0 |
317 | if (m_printer->d_func()->hasCustomPageMargins) { never evaluated: m_printer->d_func()->hasCustomPageMargins | 0 |
318 | m_printer->getPageMargins(&m_leftMargin, &m_topMargin, &m_rightMargin, &m_bottomMargin, QPrinter::Point); | - |
319 | } else { | 0 |
320 | QByteArray cupsPaperSizeChoice = widget.paperSize->itemData(widget.paperSize->currentIndex()).toByteArray(); | - |
321 | QRect paper = cups.paperRect(cupsPaperSizeChoice); | - |
322 | QRect content = cups.pageRect(cupsPaperSizeChoice); | - |
323 | | - |
324 | m_leftMargin = content.x() - paper.x(); | - |
325 | m_topMargin = content.y() - paper.y(); | - |
326 | m_rightMargin = paper.right() - content.right(); | - |
327 | m_bottomMargin = paper.bottom() - content.bottom(); | - |
328 | } | 0 |
329 | } else | - |
330 | m_cups = false; never executed: m_cups = false; | 0 |
331 | | - |
332 | if (widget.paperSize->count() == 0) { never evaluated: widget.paperSize->count() == 0 | 0 |
333 | populatePaperSizes(widget.paperSize); | - |
334 | widget.paperSize->setCurrentIndex(widget.paperSize->findData( | - |
335 | QLocale::system().measurementSystem() == QLocale::ImperialSystem ? QPrinter::Letter : QPrinter::A4)); | - |
336 | } | 0 |
337 | | - |
338 | unitChanged(widget.unit->currentIndex()); | - |
339 | m_pagePreview->setMargins(m_leftMargin, m_topMargin, m_rightMargin, m_bottomMargin); | - |
340 | | - |
341 | | - |
342 | setupPrinter(); | - |
343 | } | 0 |
344 | | - |
345 | void QPageSetupWidget::selectPdfPsPrinter(const QPrinter *p) | - |
346 | { | - |
347 | m_cups = false; | - |
348 | widget.paperSize->clear(); | - |
349 | populatePaperSizes(widget.paperSize); | - |
350 | widget.paperSize->setCurrentIndex(widget.paperSize->findData(p->paperSize())); | - |
351 | unitChanged(widget.unit->currentIndex()); | - |
352 | m_pagePreview->setMargins(m_leftMargin, m_topMargin, m_rightMargin, m_bottomMargin); | - |
353 | } | 0 |
354 | | - |
355 | | - |
356 | void QPageSetupWidget::_q_paperSizeChanged() | - |
357 | { | - |
358 | QVariant val = widget.paperSize->itemData(widget.paperSize->currentIndex()); | - |
359 | int index = m_printer->pageSize(); | - |
360 | if (val.type() == QVariant::Int) { never evaluated: val.type() == QVariant::Int | 0 |
361 | index = val.toInt(); | - |
362 | } | 0 |
363 | | - |
364 | if (m_blockSignals) return; never evaluated: m_blockSignals | 0 |
365 | m_blockSignals = true; | - |
366 | | - |
367 | QPrinter::PaperSize size = QPrinter::PaperSize(index); | - |
368 | QPrinter::Orientation orientation = widget.portrait->isChecked() never evaluated: widget.portrait->isChecked() | 0 |
369 | ? QPrinter::Portrait | - |
370 | : QPrinter::Landscape; | - |
371 | | - |
372 | bool custom = size == QPrinter::Custom; | - |
373 | | - |
374 | | - |
375 | custom = custom ? m_cups : custom; | 0 |
376 | | - |
377 | | - |
378 | widget.paperWidth->setEnabled(custom); | - |
379 | widget.paperHeight->setEnabled(custom); | - |
380 | widget.widthLabel->setEnabled(custom); | - |
381 | widget.heightLabel->setEnabled(custom); | - |
382 | if (custom) { | 0 |
383 | m_paperSize.setWidth( widget.paperWidth->value() * m_currentMultiplier); | - |
384 | m_paperSize.setHeight( widget.paperHeight->value() * m_currentMultiplier); | - |
385 | m_pagePreview->setPaperSize(m_paperSize); | - |
386 | } else { | 0 |
387 | qt_noop(); | - |
388 | | - |
389 | if (m_cups && QCUPSSupport::isAvailable()) { never evaluated: QCUPSSupport::isAvailable() | 0 |
390 | QCUPSSupport cups; | - |
391 | QByteArray cupsPageSize = widget.paperSize->itemData(widget.paperSize->currentIndex()).toByteArray(); | - |
392 | m_paperSize = cups.paperRect(cupsPageSize).size(); | - |
393 | if (orientation == QPrinter::Landscape) never evaluated: orientation == QPrinter::Landscape | 0 |
394 | m_paperSize = QSizeF(m_paperSize.height(), m_paperSize.width()); never executed: m_paperSize = QSizeF(m_paperSize.height(), m_paperSize.width()); | 0 |
395 | } | 0 |
396 | else | - |
397 | | - |
398 | m_paperSize = qt_printerPaperSize(orientation, size, QPrinter::Point, 1); never executed: m_paperSize = qt_printerPaperSize(orientation, size, QPrinter::Point, 1); | 0 |
399 | | - |
400 | m_pagePreview->setPaperSize(m_paperSize); | - |
401 | widget.paperWidth->setValue(m_paperSize.width() / m_currentMultiplier); | - |
402 | widget.paperHeight->setValue(m_paperSize.height() / m_currentMultiplier); | - |
403 | } | 0 |
404 | m_blockSignals = false; | - |
405 | } | 0 |
406 | | - |
407 | void QPageSetupWidget::_q_pageOrientationChanged() | - |
408 | { | - |
409 | if (QPrinter::PaperSize(widget.paperSize->currentIndex()) == QPrinter::Custom) { never evaluated: QPrinter::PaperSize(widget.paperSize->currentIndex()) == QPrinter::Custom | 0 |
410 | double tmp = widget.paperWidth->value(); | - |
411 | widget.paperWidth->setValue(widget.paperHeight->value()); | - |
412 | widget.paperHeight->setValue(tmp); | - |
413 | } | 0 |
414 | _q_paperSizeChanged(); | - |
415 | } | 0 |
416 | | - |
417 | extern double qt_multiplierForUnit(QPrinter::Unit unit, int resolution); | - |
418 | | - |
419 | void QPageSetupWidget::unitChanged(int item) | - |
420 | { | - |
421 | QString suffix; | - |
422 | switch(item) { | - |
423 | case 0: | - |
424 | m_currentMultiplier = 10 * qt_multiplierForUnit(QPrinter::Millimeter, 1); | - |
425 | suffix = QString::fromLatin1(" cm"); | - |
426 | break; | 0 |
427 | case 2: | - |
428 | m_currentMultiplier = qt_multiplierForUnit(QPrinter::Inch, 1); | - |
429 | suffix = QString::fromLatin1(" in"); | - |
430 | break; | 0 |
431 | case 3: | - |
432 | m_currentMultiplier = qt_multiplierForUnit(QPrinter::Point, 1); | - |
433 | suffix = QString::fromLatin1(" pt"); | - |
434 | break; | 0 |
435 | case 1: | - |
436 | default: | - |
437 | m_currentMultiplier = qt_multiplierForUnit(QPrinter::Millimeter, 1); | - |
438 | suffix = QString::fromLatin1(" mm"); | - |
439 | break; | 0 |
440 | } | - |
441 | const bool old = m_blockSignals; | - |
442 | m_blockSignals = true; | - |
443 | widget.topMargin->setSuffix(suffix); | - |
444 | widget.leftMargin->setSuffix(suffix); | - |
445 | widget.rightMargin->setSuffix(suffix); | - |
446 | widget.bottomMargin->setSuffix(suffix); | - |
447 | widget.paperWidth->setSuffix(suffix); | - |
448 | widget.paperHeight->setSuffix(suffix); | - |
449 | widget.topMargin->setValue(m_topMargin / m_currentMultiplier); | - |
450 | widget.leftMargin->setValue(m_leftMargin / m_currentMultiplier); | - |
451 | widget.rightMargin->setValue(m_rightMargin / m_currentMultiplier); | - |
452 | widget.bottomMargin->setValue(m_bottomMargin / m_currentMultiplier); | - |
453 | widget.paperWidth->setValue(m_paperSize.width() / m_currentMultiplier); | - |
454 | widget.paperHeight->setValue(m_paperSize.height() / m_currentMultiplier); | - |
455 | m_blockSignals = old; | - |
456 | } | 0 |
457 | | - |
458 | void QPageSetupWidget::setTopMargin(double newValue) | - |
459 | { | - |
460 | if (m_blockSignals) return; never evaluated: m_blockSignals | 0 |
461 | m_topMargin = newValue * m_currentMultiplier; | - |
462 | m_pagePreview->setMargins(m_leftMargin, m_topMargin, m_rightMargin, m_bottomMargin); | - |
463 | } | 0 |
464 | | - |
465 | void QPageSetupWidget::setBottomMargin(double newValue) | - |
466 | { | - |
467 | if (m_blockSignals) return; never evaluated: m_blockSignals | 0 |
468 | m_bottomMargin = newValue * m_currentMultiplier; | - |
469 | m_pagePreview->setMargins(m_leftMargin, m_topMargin, m_rightMargin, m_bottomMargin); | - |
470 | } | 0 |
471 | | - |
472 | void QPageSetupWidget::setLeftMargin(double newValue) | - |
473 | { | - |
474 | if (m_blockSignals) return; never evaluated: m_blockSignals | 0 |
475 | m_leftMargin = newValue * m_currentMultiplier; | - |
476 | m_pagePreview->setMargins(m_leftMargin, m_topMargin, m_rightMargin, m_bottomMargin); | - |
477 | } | 0 |
478 | | - |
479 | void QPageSetupWidget::setRightMargin(double newValue) | - |
480 | { | - |
481 | if (m_blockSignals) return; never evaluated: m_blockSignals | 0 |
482 | m_rightMargin = newValue * m_currentMultiplier; | - |
483 | m_pagePreview->setMargins(m_leftMargin, m_topMargin, m_rightMargin, m_bottomMargin); | - |
484 | } | 0 |
485 | | - |
486 | | - |
487 | | - |
488 | QPageSetupDialog::QPageSetupDialog(QPrinter *printer, QWidget *parent) | - |
489 | : QDialog(*(new QUnixPageSetupDialogPrivate(printer)), parent) | - |
490 | { | - |
491 | setWindowTitle(QCoreApplication::translate("QPrintPreviewDialog", "Page Setup")); | - |
492 | } executed: } Execution Count:1 | 1 |
493 | | - |
494 | | - |
495 | QPageSetupDialog::QPageSetupDialog(QWidget *parent) | - |
496 | : QDialog(*(new QUnixPageSetupDialogPrivate(0)), parent) | - |
497 | { | - |
498 | setWindowTitle(QCoreApplication::translate("QPrintPreviewDialog", "Page Setup")); | - |
499 | } | 0 |
500 | | - |
501 | int QPageSetupDialog::exec() | - |
502 | { | - |
503 | QPageSetupDialogPrivate * const d = d_func(); | - |
504 | | - |
505 | int ret = QDialog::exec(); | - |
506 | if (ret == Accepted) never evaluated: ret == Accepted | 0 |
507 | static_cast <QUnixPageSetupDialogPrivate*>(d)->widget->setupPrinter(); never executed: static_cast <QUnixPageSetupDialogPrivate*>(d)->widget->setupPrinter(); | 0 |
508 | return ret; never executed: return ret; | 0 |
509 | } | - |
510 | | - |
511 | | - |
512 | | - |
513 | | - |
514 | | - |
| | |