80 void odfWriting_images(); |
80 void odfWriting_images(); |
81 |
81 |
82 void constructControl(); |
82 void constructControl(); |
83 void constructDocument(); |
83 void constructDocument(); |
84 |
84 |
|
85 void newLineReplacement(); |
|
86 void formatManipulation(); |
|
87 void fontResolution(); |
|
88 |
|
89 void layout_data(); |
85 void layout(); |
90 void layout(); |
|
91 void formattedLayout(); |
86 void paintLayoutToPixmap(); |
92 void paintLayoutToPixmap(); |
87 void paintLayoutToPixmap_painterFill(); |
93 void paintLayoutToPixmap_painterFill(); |
88 |
94 |
89 void document(); |
95 void document(); |
90 void paintDocToPixmap(); |
96 void paintDocToPixmap(); |
282 QTextDocument *doc = new QTextDocument; |
285 QTextDocument *doc = new QTextDocument; |
283 delete doc; |
286 delete doc; |
284 } |
287 } |
285 } |
288 } |
286 |
289 |
|
290 //this step is needed before giving the string to a QTextLayout |
|
291 void tst_QText::newLineReplacement() |
|
292 { |
|
293 QString text = QString::fromLatin1("H\ne\nl\nl\no\n\nW\no\nr\nl\nd"); |
|
294 |
|
295 QBENCHMARK { |
|
296 QString tmp = text; |
|
297 tmp.replace(QLatin1Char('\n'), QChar::LineSeparator); |
|
298 } |
|
299 } |
|
300 |
|
301 void tst_QText::formatManipulation() |
|
302 { |
|
303 QFont font; |
|
304 |
|
305 QBENCHMARK { |
|
306 QTextCharFormat format; |
|
307 format.setFont(font); |
|
308 } |
|
309 } |
|
310 |
|
311 void tst_QText::fontResolution() |
|
312 { |
|
313 QFont font; |
|
314 QFont font2; |
|
315 font.setFamily("DejaVu"); |
|
316 font2.setBold(true); |
|
317 |
|
318 QBENCHMARK { |
|
319 QFont res = font.resolve(font2); |
|
320 } |
|
321 } |
|
322 |
|
323 void tst_QText::layout_data() |
|
324 { |
|
325 QTest::addColumn<bool>("wrap"); |
|
326 QTest::newRow("wrap") << true; |
|
327 QTest::newRow("nowrap") << false; |
|
328 } |
|
329 |
287 void tst_QText::layout() |
330 void tst_QText::layout() |
288 { |
331 { |
|
332 QFETCH(bool,wrap); |
289 QTextLayout layout(m_shortLorem); |
333 QTextLayout layout(m_shortLorem); |
|
334 setupTextLayout(&layout, wrap); |
|
335 |
|
336 QBENCHMARK { |
|
337 QTextLayout layout(m_shortLorem); |
|
338 setupTextLayout(&layout, wrap); |
|
339 } |
|
340 } |
|
341 |
|
342 //### requires tst_QText to be a friend of QTextLayout |
|
343 /*void tst_QText::stackTextLayout() |
|
344 { |
|
345 QStackTextEngine engine(m_shortLorem, qApp->font()); |
|
346 QTextLayout layout(&engine); |
290 setupTextLayout(&layout); |
347 setupTextLayout(&layout); |
291 |
348 |
292 QBENCHMARK { |
349 QBENCHMARK { |
|
350 QStackTextEngine engine(m_shortLorem, qApp->font()); |
|
351 QTextLayout layout(&engine); |
|
352 setupTextLayout(&layout); |
|
353 } |
|
354 }*/ |
|
355 |
|
356 void tst_QText::formattedLayout() |
|
357 { |
|
358 //set up formatting |
|
359 QList<QTextLayout::FormatRange> ranges; |
|
360 { |
|
361 QTextCharFormat format; |
|
362 format.setForeground(QColor("steelblue")); |
|
363 |
|
364 QTextLayout::FormatRange formatRange; |
|
365 formatRange.format = format; |
|
366 formatRange.start = 0; |
|
367 formatRange.length = 50; |
|
368 |
|
369 ranges.append(formatRange); |
|
370 } |
|
371 |
|
372 QTextLayout layout(m_shortLorem); |
|
373 layout.setAdditionalFormats(ranges); |
|
374 setupTextLayout(&layout); |
|
375 |
|
376 QBENCHMARK { |
293 QTextLayout layout(m_shortLorem); |
377 QTextLayout layout(m_shortLorem); |
|
378 layout.setAdditionalFormats(ranges); |
294 setupTextLayout(&layout); |
379 setupTextLayout(&layout); |
295 } |
380 } |
296 } |
381 } |
297 |
382 |
298 void tst_QText::paintLayoutToPixmap() |
383 void tst_QText::paintLayoutToPixmap() |