• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • kdecore
  • sonnet
backgroundengine.cpp
Go to the documentation of this file.
1
20#include "backgroundengine_p.h"
21
22#include "spellerplugin_p.h"
23#include "filter_p.h"
24
25#include <kdebug.h>
26
27#include <QtCore/QTimer>
28
29using namespace Sonnet;
30
31BackgroundEngine::BackgroundEngine(QObject *parent)
32 : QObject(parent)
33{
34 m_filter = Filter::defaultFilter();
35}
36
37BackgroundEngine::~BackgroundEngine()
38{
39 delete m_filter;
40}
41
42void BackgroundEngine::setSpeller(const Speller &speller)
43{
44 m_dict = speller;
45}
46
47void BackgroundEngine::setText(const QString &text)
48{
49 m_filter->setBuffer(text);
50}
51
52QString BackgroundEngine::text() const
53{
54 return m_filter->buffer();
55}
56
57void BackgroundEngine::changeLanguage(const QString &lang)
58{
59 m_dict.setLanguage(lang);
60}
61
62QString BackgroundEngine::language() const
63{
64 return m_dict.language();
65}
66
67void BackgroundEngine::setFilter(Filter *filter)
68{
69 QString oldText = m_filter->buffer();
70 m_filter = filter;
71 m_filter->setBuffer(oldText);
72}
73
74void BackgroundEngine::start()
75{
76 QTimer::singleShot(0, this, SLOT(checkNext()));
77}
78
79void BackgroundEngine::stop()
80{
81}
82
83void BackgroundEngine::continueChecking()
84{
85 QTimer::singleShot(0, this, SLOT(checkNext()));
86}
87
88void BackgroundEngine::checkNext()
89{
90 Word w = m_filter->nextWord();
91 if (w.end) {
92 emit done();
93 return;
94 }
95
96 if (KDE_ISUNLIKELY( m_dict.isMisspelled(w.word) )) {
97 //kDebug()<<"found misspelling "<< w.word;
98 emit misspelling(w.word, w.start);
99 //wait for the handler. the parent will decide itself when to continue
100 } else
101 continueChecking();
102}
103
104bool BackgroundEngine::checkWord(const QString &word)
105{
106 return m_dict.isCorrect(word);
107}
108
109bool BackgroundEngine::addWord(const QString &word)
110{
111 return m_dict.addToPersonal(word);
112}
113
114QStringList BackgroundEngine::suggest(const QString &word)
115{
116 return m_dict.suggest(word);
117}
118
119#include "backgroundengine_p.moc"
backgroundengine_p.h
QObject
QStringList
QString
Sonnet::BackgroundEngine::done
void done()
Emitted when all words have been checked.
Sonnet::BackgroundEngine::language
QString language() const
Definition: backgroundengine.cpp:62
Sonnet::BackgroundEngine::stop
void stop()
Definition: backgroundengine.cpp:79
Sonnet::BackgroundEngine::BackgroundEngine
BackgroundEngine(QObject *parent)
Definition: backgroundengine.cpp:31
Sonnet::BackgroundEngine::changeLanguage
void changeLanguage(const QString &)
Definition: backgroundengine.cpp:57
Sonnet::BackgroundEngine::~BackgroundEngine
~BackgroundEngine()
Definition: backgroundengine.cpp:37
Sonnet::BackgroundEngine::continueChecking
void continueChecking()
Definition: backgroundengine.cpp:83
Sonnet::BackgroundEngine::setFilter
void setFilter(Filter *filter)
Definition: backgroundengine.cpp:67
Sonnet::BackgroundEngine::misspelling
void misspelling(const QString &, int)
Emitted when a misspelling is found.
Sonnet::BackgroundEngine::checkNext
void checkNext()
Definition: backgroundengine.cpp:88
Sonnet::BackgroundEngine::speller
Speller speller() const
Definition: backgroundengine_p.h:43
Sonnet::BackgroundEngine::start
void start()
Definition: backgroundengine.cpp:74
Sonnet::BackgroundEngine::setSpeller
void setSpeller(const Speller &speller)
Definition: backgroundengine.cpp:42
Sonnet::BackgroundEngine::text
QString text() const
Definition: backgroundengine.cpp:52
Sonnet::BackgroundEngine::filter
Filter * filter() const
Definition: backgroundengine_p.h:52
Sonnet::BackgroundEngine::suggest
QStringList suggest(const QString &word)
Definition: backgroundengine.cpp:114
Sonnet::BackgroundEngine::setText
void setText(const QString &)
Definition: backgroundengine.cpp:47
Sonnet::BackgroundEngine::checkWord
bool checkWord(const QString &word)
Definition: backgroundengine.cpp:104
Sonnet::BackgroundEngine::addWord
bool addWord(const QString &word)
Definition: backgroundengine.cpp:109
Sonnet::Filter
Filter is used to split text into words which will be spell checked.
Definition: filter_p.h:66
Sonnet::Filter::setBuffer
void setBuffer(const QString &buffer)
Definition: filter.cpp:81
Sonnet::Filter::defaultFilter
static Filter * defaultFilter()
Definition: filter.cpp:45
Sonnet::Filter::buffer
QString buffer() const
Definition: filter.cpp:87
Sonnet::Filter::nextWord
virtual Word nextWord() const
Definition: filter.cpp:168
Sonnet::Speller
Spell checker object.
Definition: speller.h:39
Sonnet::Speller::isMisspelled
bool isMisspelled(const QString &word) const
Checks the given word.
Definition: speller.cpp:115
Sonnet::Speller::suggest
QStringList suggest(const QString &word) const
Fetches suggestions for the word.
Definition: speller.cpp:122
Sonnet::Speller::language
QString language() const
Returns language supported by this speller.
Definition: speller.cpp:163
Sonnet::Speller::addToPersonal
bool addToPersonal(const QString &word)
Adds word to the list of of personal words.
Definition: speller.cpp:147
Sonnet::Speller::isCorrect
bool isCorrect(const QString &word) const
Checks the given word.
Definition: speller.cpp:107
Sonnet::Speller::setLanguage
void setLanguage(const QString &lang)
Sets the language supported by this speller.
Definition: speller.cpp:264
filter_p.h
kdebug.h
Sonnet
The sonnet namespace.
Definition: backgroundchecker.h:34
spellerplugin_p.h
Sonnet::Word
Structure abstracts the word and its position in the parent text.
Definition: filter_p.h:41
Sonnet::Word::word
QString word
Definition: filter_p.h:53
Sonnet::Word::start
int start
Definition: filter_p.h:54
Sonnet::Word::end
bool end
Definition: filter_p.h:55
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal