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); }
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); }
void Find::findImplementation(const QString &pattern, KoFindBase::KoFindMatchList &matchList) { //int row = 1; //int column = 1; const ValueStorage *values = d->currentSheet->valueStorage(); Qt::CaseSensitivity sensitivity = options()->option("caseSensitive")->value().toBool() ? Qt::CaseSensitive : Qt::CaseInsensitive; for(int i = 0; i < values->count(); ++i) { Value val = values->data(i); if(val.isString() && val.asString().contains(pattern, sensitivity)) { KoFindMatch match; match.setContainer(QVariant::fromValue(d->currentSheet)); Cell cell(d->currentSheet, values->col(i), values->row(i)); match.setLocation(QVariant::fromValue(cell)); matchList.append(match); d->currentSheetView->setHighlighted(cell.cellPosition(), true); } } }