~ubuntu-branches/ubuntu/jaunty/psi/jaunty

« back to all changes in this revision

Viewing changes to src/tools/spellchecker/spellhighlighter.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2008-04-14 18:57:30 UTC
  • mfrom: (2.1.9 hardy)
  • Revision ID: james.westby@ubuntu.com-20080414185730-528re3zp0m2hdlhi
Tags: 0.11-8
* added CONFIG -= link_prl to .pro files and removed dependencies
  which are made unnecessary by this change
* Fix segfault when closing last chat tab with qt4.4
  (This is from upstream svn, rev. 1101) (Closes: Bug#476122)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "spellhighlighter.h"
 
2
#include "spellchecker.h"
 
3
 
 
4
SpellHighlighter::SpellHighlighter(QTextDocument* d) : QSyntaxHighlighter(d)
 
5
{
 
6
}
 
7
 
 
8
void SpellHighlighter::highlightBlock(const QString& text)
 
9
{
 
10
        // Underline 
 
11
        QTextCharFormat tcf;
 
12
        tcf.setUnderlineColor(QBrush(QColor(255,0,0)));
 
13
        tcf.setUnderlineStyle(QTextCharFormat::SpellCheckUnderline);
 
14
 
 
15
        // Match words (minimally)
 
16
        QRegExp expression("\\b\\w+\\b");
 
17
 
 
18
        // Iterate through all words
 
19
        int index = text.indexOf(expression);
 
20
        while (index >= 0) {
 
21
                int length = expression.matchedLength();
 
22
                if (!SpellChecker::instance()->isCorrect(expression.cap()))
 
23
                        setFormat(index, length, tcf);
 
24
                index = text.indexOf(expression, index + length);
 
25
        }
 
26
}