Commit a90ecbd9 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Continue to implement search

parent c85f1a74
Pipeline #138885 passed with stages
in 3 minutes and 22 seconds
......@@ -37,6 +37,29 @@ int FindUtils::replaceAll(QTextDocument *document, const TextFindWidget *findWid
return count;
}
bool FindUtils::find(QTextDocument *document, const TextFindWidget *findWidget)
{
// Step 1: search without modify text
// Step 2: use FindUtils::normalize
QTextCursor c(document);
// if (document->find())
const QString text = FindUtils::normalize(document->toPlainText());
QTextDocument doc(text);
QTextDocument::FindFlags flags = findWidget->searchOptions() & ~QTextDocument::FindBackward;
if (findWidget->isRegularExpression()) {
c = document->find(findWidget->searchRegularExpression(), c, flags);
} else {
c = document->find(findWidget->searchText(), c, flags);
}
doc.find(findWidget->searchText(), c, flags);
if (!c.isNull()) {
// setTextCursor(search);
return true;
}
return false;
}
// code from kitinerary/src/lib/stringutil.cpp
QChar FindUtils::normalize(QChar c)
{
......
......@@ -25,8 +25,10 @@ namespace FindUtils
* @return number of replacements done
*/
Q_REQUIRED_RESULT int replaceAll(QTextDocument *document, const TextFindWidget *findWidget, const TextReplaceWidget *replaceWidget);
Q_REQUIRED_RESULT QString normalize(QStringView str);
Q_REQUIRED_RESULT QChar normalize(QChar c);
Q_REQUIRED_RESULT bool find(QTextDocument *document, const TextFindWidget *findWidget);
}
} // namespace KPIMTextEdit
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment