315
315
block = m_doc->begin();
316
316
QVERIFY(block.userData() == 0);
317
317
block = block.next();
318
static const char* texts[] = { "1", "1.1.", "1.1.1", "1.1.2", "1.2.", "2", "2.1.", "2.2.", "3", "3.0.1", "1.1" };
318
static const char* texts[] = { "1", "1.1.", "1.1.1", "1.1.2", "1.2.", "2", "2.1.", "2.2.", "3", "3.1.1", "1.1" };
320
320
qreal indent = 0.0;
321
321
while (block.isValid()) {
337
void TestDocumentLayout::testNestedPrefixedLists()
339
/* A list with different prefix for each level should show only the prefix of that level
340
* Specifically we should not concatenate the prefixes of the higher levels
341
* Specifically we should not concatenate the suffixes of the higher levels
342
* That is only the prefix and the suffix of the current level should be applied
344
initForNewTest("MMMM\nSSSS\n");
347
m_styleManager->add(&h1);
349
m_styleManager->add(&h2);
351
KoListStyle listStyle;
352
KoListLevelProperties llp1;
353
llp1.setStartValue(1);
354
llp1.setStyle(KoListStyle::DecimalItem);
355
llp1.setListItemPrefix("Main");
356
llp1.setListItemSuffix(":");
358
listStyle.setLevelProperties(llp1);
360
KoListLevelProperties llp2;
361
llp2.setStartValue(1);
362
llp2.setStyle(KoListStyle::DecimalItem);
364
llp2.setListItemPrefix("Sub");
365
llp2.setListItemSuffix("*");
366
llp2.setDisplayLevel(2);
367
listStyle.setLevelProperties(llp2);
369
h1.setListStyle(&listStyle);
371
h2.setListStyle(&listStyle);
373
QVERIFY(listStyle.hasLevelProperties(1));
374
QVERIFY(listStyle.hasLevelProperties(2));
375
QVERIFY(!listStyle.hasLevelProperties(3));
377
QTextBlock block = m_doc->begin().next();
378
h1.applyStyle(block);
379
block = block.next();
380
QVERIFY(block.isValid());
381
h2.applyStyle(block);
385
block = m_doc->begin();
386
QVERIFY(block.userData() == 0);
387
block = block.next();
388
static const char* texts[] = { "Main1:", "Sub1.1*"};
390
while (block.isValid()) {
391
KoTextBlockData *data = dynamic_cast<KoTextBlockData*>(block.userData());
392
//qDebug() << "text: " << block.text();
393
//qDebug() << "expected: " << texts[i];
395
//qDebug() << data->counterText();
396
QCOMPARE(data->counterText(), QString(texts[i++]));
397
block = block.next();
337
401
void TestDocumentLayout::testAutoRestartList()
339
403
initForNewTest("Humans\nGandhi\nEinstein\nInventions\nCar\nToilet\nLaboratory\n");
635
699
KoTextBlockData *data = dynamic_cast<KoTextBlockData*>(block.userData());
636
700
QCOMPARE(data->counterPosition().x(), 200 - padding - data->counterWidth());
703
void TestDocumentLayout::testMultiLevel()
705
initForNewTest("ListItem1\n");
706
KoListStyle listStyle;
707
KoListLevelProperties llp;
708
llp.setStyle(KoListStyle::DecimalItem);
710
llp.setDisplayLevel(4); // we won't show a .0 at the end so this is truncated to 3
711
listStyle.setLevelProperties(llp);
713
QTextBlock block = m_doc->begin();
714
QVERIFY(block.isValid());
715
listStyle.applyStyle(block);
716
QVERIFY(block.textList());
720
KoTextBlockData *data = dynamic_cast<KoTextBlockData*> (block.userData());
722
QVERIFY(data->hasCounterData());
723
QCOMPARE(data->counterText(), QString("1.1.1"));