1
#include "spellhighlighter.h"
2
#include "spellchecker.h"
4
SpellHighlighter::SpellHighlighter(QTextDocument* d) : QSyntaxHighlighter(d)
8
void SpellHighlighter::highlightBlock(const QString& text)
12
tcf.setUnderlineColor(QBrush(QColor(255,0,0)));
13
tcf.setUnderlineStyle(QTextCharFormat::SpellCheckUnderline);
15
// Match words (minimally)
16
QRegExp expression("\\b\\w+\\b");
18
// Iterate through all words
19
int index = text.indexOf(expression);
21
int length = expression.matchedLength();
22
if (!SpellChecker::instance()->isCorrect(expression.cap()))
23
setFormat(index, length, tcf);
24
index = text.indexOf(expression, index + length);