• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdespell2
 

tdespell2

  • tdespell2
backgroundengine.cpp
1
21#include "backgroundengine.h"
22
23#include "defaultdictionary.h"
24#include "dictionary.h"
25#include "filter.h"
26
27#include <kdebug.h>
28
29#include <tqtimer.h>
30
31using namespace KSpell2;
32
33BackgroundEngine::BackgroundEngine( TQObject *parent )
34 : TQObject( parent )
35{
36 m_filter = Filter::defaultFilter();
37 m_dict = 0;
38}
39
40BackgroundEngine::~BackgroundEngine()
41{
42 delete m_dict; m_dict = 0;
43}
44
45void BackgroundEngine::setBroker( const Broker::Ptr& broker )
46{
47 m_broker = broker;
48 delete m_dict;
49 m_defaultDict = m_broker->defaultDictionary();
50 m_filter->setSettings( m_broker->settings() );
51}
52
53void BackgroundEngine::setText( const TQString& text )
54{
55 m_filter->setBuffer( text );
56}
57
58TQString BackgroundEngine::text() const
59{
60 return m_filter->buffer();
61}
62
63void BackgroundEngine::changeLanguage( const TQString& lang )
64{
65 delete m_dict;
66 if ( lang.isEmpty() ) {
67 m_dict = 0;
68 } else {
69 m_dict = m_broker->dictionary( lang );
70 }
71}
72
73TQString BackgroundEngine::language() const
74{
75 if ( m_dict )
76 return m_dict->language();
77 else
78 return m_defaultDict->language();
79}
80
81void BackgroundEngine::setFilter( Filter *filter )
82{
83 TQString oldText = m_filter->buffer();
84 m_filter = filter;
85 m_filter->setBuffer( oldText );
86}
87
88void BackgroundEngine::start()
89{
90 TQTimer::singleShot( 0, this, TQ_SLOT(checkNext()) );
91}
92
93void BackgroundEngine::stop()
94{
95}
96
97void BackgroundEngine::continueChecking()
98{
99 TQTimer::singleShot( 0, this, TQ_SLOT(checkNext()) );
100}
101
102void BackgroundEngine::checkNext()
103{
104 Word w = m_filter->nextWord();
105 if ( w.end ) {
106 emit done();
107 return;
108 }
109
110 Dictionary *dict = ( m_dict ) ? m_dict : static_cast<Dictionary*>( m_defaultDict );
111
112 if ( !dict->check( w.word ) ) {
113 //kdDebug()<<"found misspelling "<< w.word <<endl;
114 emit misspelling( w.word, w.start );
115 //wait for the handler. the parent will decide itself when to continue
116 } else
117 continueChecking();
118}
119
120bool BackgroundEngine::checkWord( const TQString& word )
121{
122 Dictionary *dict = ( m_dict ) ? m_dict : static_cast<Dictionary*>( m_defaultDict );
123 return dict->check( word );
124}
125
126bool BackgroundEngine::addWord( const TQString& word )
127{
128 Dictionary *dict = ( m_dict ) ? m_dict : static_cast<Dictionary*>( m_defaultDict );
129 return dict->addToPersonal( word );
130}
131
132TQStringList BackgroundEngine::suggest( const TQString& word )
133{
134 Dictionary *dict = ( m_dict ) ? m_dict : static_cast<Dictionary*>( m_defaultDict );
135 return dict->suggest( word );
136}
137
138#include "backgroundengine.moc"
KSpell2::Dictionary
Class is returned by from Broker.
Definition: dictionary.h:37
KSpell2::Dictionary::addToPersonal
virtual bool addToPersonal(const TQString &word)=0
Adds word to the list of of personal words.
KSpell2::Dictionary::suggest
virtual TQStringList suggest(const TQString &word)=0
Fetches suggestions for the word.
KSpell2::Dictionary::check
virtual bool check(const TQString &word)=0
Checks the given word.
KSpell2::Filter
Filter is used to split text into words which will be spell checked.
Definition: filter.h:65
KSpell2
tdespell_hspellclient.h
Definition: backgroundchecker.h:29
KSpell2::Word
Structure abstracts the word and its position in the parent text.
Definition: filter.h:40

tdespell2

Skip menu "tdespell2"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

tdespell2

Skip menu "tdespell2"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdespell2 by doxygen 1.9.4
This website is maintained by Timothy Pearson.