Exemplo n.º 1
0
void TestFindMatch::testBasic()
{
    KoFindMatch match;

    QTextDocument *doc = new QTextDocument("Test Document", this);
    QVariant docVariant = QVariant::fromValue(doc);
    QVERIFY(docVariant.isValid());
    
    match.setContainer(docVariant);
    QCOMPARE(match.container(), docVariant);
    QCOMPARE(match.container().value<QTextDocument*>(), doc);

    QTextCursor cursor = doc->find("Document");
    QVariant curVariant = QVariant::fromValue(cursor);
    QVERIFY(curVariant.isValid());
    
    match.setLocation(curVariant);
    QCOMPARE(match.location(), curVariant);
    QCOMPARE(match.location().value<QTextCursor>(), cursor);

    QVERIFY(match.isValid());

    KoFindMatch other(docVariant, curVariant);
    QVERIFY(other.isValid());
    QCOMPARE(other.container(), docVariant);
    QCOMPARE(other.location(), curVariant);
}
Exemplo n.º 2
0
void TestFindMatch::testCopyAssign()
{
    KoFindMatch match;

    QTextDocument *doc = new QTextDocument("Test Document", this);
    QVariant docVariant = QVariant::fromValue(doc);
    QTextCursor cursor = doc->find("Document");
    QVariant curVariant = QVariant::fromValue(cursor);

    QVERIFY(docVariant.isValid());
    QVERIFY(curVariant.isValid());
    
    match.setContainer(docVariant);
    match.setLocation(curVariant);

    KoFindMatch other(match);
    QVERIFY(other.isValid());
    QCOMPARE(other.container(), match.container());
    QCOMPARE(other.location(), match.location());

    KoFindMatch third = match;
    QVERIFY(third.isValid());
    QCOMPARE(third.container(), match.container());
    QCOMPARE(third.location(), match.location());

    QVERIFY(other == match);
}
Exemplo n.º 3
0
void CASpreadsheetHandler::findMatchFound (const KoFindMatch& match)
{
    QTextCursor cursor = match.location().value<QTextCursor>();
    updateCanvas();


    d->findText->setCurrentSheet(d->sheet,d->sheetView);
    d->sheetView->activeHighlight();

    d->sheetView->setHighlighted(match.location().value<Calligra::Sheets::Cell>().cellPosition(), true);

    d->canvasItem->resourceManager()->setResource(KoText::CurrentTextAnchor, cursor.anchor());
    d->canvasItem->resourceManager()->setResource(KoText::CurrentTextPosition, cursor.position());
    d->matchFound = true;
}
void CAPresentationHandler::findMatchFound (const KoFindMatch& match)
{
    QTextCursor cursor = match.location().value<QTextCursor>();
    updateCanvas();

    canvas()->resourceManager()->setResource (KoText::CurrentTextAnchor, cursor.anchor());
    canvas()->resourceManager()->setResource (KoText::CurrentTextPosition, cursor.position());
    d->matchFound = true;
}