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

KDECore

  • sources
  • kde-4.14
  • kdelibs
  • 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 
29 using namespace Sonnet;
30 
31 BackgroundEngine::BackgroundEngine(QObject *parent)
32  : QObject(parent)
33 {
34  m_filter = Filter::defaultFilter();
35 }
36 
37 BackgroundEngine::~BackgroundEngine()
38 {
39  delete m_filter;
40 }
41 
42 void BackgroundEngine::setSpeller(const Speller &speller)
43 {
44  m_dict = speller;
45 }
46 
47 void BackgroundEngine::setText(const QString &text)
48 {
49  m_filter->setBuffer(text);
50 }
51 
52 QString BackgroundEngine::text() const
53 {
54  return m_filter->buffer();
55 }
56 
57 void BackgroundEngine::changeLanguage(const QString &lang)
58 {
59  m_dict.setLanguage(lang);
60 }
61 
62 QString BackgroundEngine::language() const
63 {
64  return m_dict.language();
65 }
66 
67 void BackgroundEngine::setFilter(Filter *filter)
68 {
69  QString oldText = m_filter->buffer();
70  m_filter = filter;
71  m_filter->setBuffer(oldText);
72 }
73 
74 void BackgroundEngine::start()
75 {
76  QTimer::singleShot(0, this, SLOT(checkNext()));
77 }
78 
79 void BackgroundEngine::stop()
80 {
81 }
82 
83 void BackgroundEngine::continueChecking()
84 {
85  QTimer::singleShot(0, this, SLOT(checkNext()));
86 }
87 
88 void 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 
104 bool BackgroundEngine::checkWord(const QString &word)
105 {
106  return m_dict.isCorrect(word);
107 }
108 
109 bool BackgroundEngine::addWord(const QString &word)
110 {
111  return m_dict.addToPersonal(word);
112 }
113 
114 QStringList BackgroundEngine::suggest(const QString &word)
115 {
116  return m_dict.suggest(word);
117 }
118 
119 #include "backgroundengine_p.moc"
Sonnet::BackgroundEngine::setFilter
void setFilter(Filter *filter)
Definition: backgroundengine.cpp:67
kdebug.h
Sonnet::BackgroundEngine::continueChecking
void continueChecking()
Definition: backgroundengine.cpp:83
backgroundengine_p.h
Sonnet::Filter
Filter is used to split text into words which will be spell checked.
Definition: filter_p.h:65
Sonnet::Filter::nextWord
virtual Word nextWord() const
Definition: filter.cpp:168
Sonnet::BackgroundEngine::misspelling
void misspelling(const QString &, int)
Emitted when a misspelling is found.
Sonnet::Word::end
bool end
Definition: filter_p.h:55
Sonnet::Speller::isCorrect
bool isCorrect(const QString &word) const
Checks the given word.
Definition: speller.cpp:107
Sonnet::BackgroundEngine::start
void start()
Definition: backgroundengine.cpp:74
Sonnet::BackgroundEngine::stop
void stop()
Definition: backgroundengine.cpp:79
Sonnet::BackgroundEngine::checkWord
bool checkWord(const QString &word)
Definition: backgroundengine.cpp:104
Sonnet::BackgroundEngine::BackgroundEngine
BackgroundEngine(QObject *parent)
Definition: backgroundengine.cpp:31
Sonnet::BackgroundEngine::checkNext
void checkNext()
Definition: backgroundengine.cpp:88
Sonnet::Filter::buffer
QString buffer() const
Definition: filter.cpp:87
Sonnet::Word
Structure abstracts the word and its position in the parent text.
Definition: filter_p.h:40
QObject
Sonnet::Speller::suggest
QStringList suggest(const QString &word) const
Fetches suggestions for the word.
Definition: speller.cpp:122
spellerplugin_p.h
Sonnet::BackgroundEngine::text
QString text() const
Definition: backgroundengine.cpp:52
QString
QStringList
Sonnet::Filter::defaultFilter
static Filter * defaultFilter()
Definition: filter.cpp:45
Sonnet::Speller
Spell checker object.
Definition: speller.h:38
Sonnet::BackgroundEngine::setText
void setText(const QString &)
Definition: backgroundengine.cpp:47
Sonnet::BackgroundEngine::setSpeller
void setSpeller(const Speller &speller)
Definition: backgroundengine.cpp:42
KDE_ISUNLIKELY
#define KDE_ISUNLIKELY(x)
The KDE_ISUNLIKELY macro tags a boolean expression as likely to evaluate to false.
Definition: kdemacros.h.cmake:285
Sonnet::Word::start
int start
Definition: filter_p.h:54
Sonnet::BackgroundEngine::addWord
bool addWord(const QString &word)
Definition: backgroundengine.cpp:109
Sonnet::BackgroundEngine::done
void done()
Emitted when all words have been checked.
Sonnet::BackgroundEngine::~BackgroundEngine
~BackgroundEngine()
Definition: backgroundengine.cpp:37
Sonnet::BackgroundEngine::filter
Filter * filter() const
Definition: backgroundengine_p.h:52
Sonnet::Speller::isMisspelled
bool isMisspelled(const QString &word) const
Checks the given word.
Definition: speller.cpp:115
Sonnet::BackgroundEngine::changeLanguage
void changeLanguage(const QString &)
Definition: backgroundengine.cpp:57
Sonnet::BackgroundEngine::suggest
QStringList suggest(const QString &word)
Definition: backgroundengine.cpp:114
Sonnet::Speller::addToPersonal
bool addToPersonal(const QString &word)
Adds word to the list of of personal words.
Definition: speller.cpp:147
Sonnet::Speller::language
QString language() const
Returns language supported by this speller.
Definition: speller.cpp:163
Sonnet::BackgroundEngine::language
QString language() const
Definition: backgroundengine.cpp:62
Sonnet::Word::word
QString word
Definition: filter_p.h:53
Sonnet::Filter::setBuffer
void setBuffer(const QString &buffer)
Definition: filter.cpp:81
Sonnet::BackgroundEngine::speller
Speller speller() const
Definition: backgroundengine_p.h:43
Sonnet::Speller::setLanguage
void setLanguage(const QString &lang)
Sets the language supported by this speller.
Definition: speller.cpp:264
filter_p.h
QTimer::singleShot
singleShot
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:10 by doxygen 1.8.7 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 API Reference

Skip menu "kdelibs 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

Search



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