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

kspell2

  • kspell2
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 
31 using namespace KSpell2;
32 
33 BackgroundEngine::BackgroundEngine( TQObject *parent )
34  : TQObject( parent )
35 {
36  m_filter = Filter::defaultFilter();
37  m_dict = 0;
38 }
39 
40 BackgroundEngine::~BackgroundEngine()
41 {
42  delete m_dict; m_dict = 0;
43 }
44 
45 void 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 
53 void BackgroundEngine::setText( const TQString& text )
54 {
55  m_filter->setBuffer( text );
56 }
57 
58 TQString BackgroundEngine::text() const
59 {
60  return m_filter->buffer();
61 }
62 
63 void 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 
73 TQString BackgroundEngine::language() const
74 {
75  if ( m_dict )
76  return m_dict->language();
77  else
78  return m_defaultDict->language();
79 }
80 
81 void BackgroundEngine::setFilter( Filter *filter )
82 {
83  TQString oldText = m_filter->buffer();
84  m_filter = filter;
85  m_filter->setBuffer( oldText );
86 }
87 
88 void BackgroundEngine::start()
89 {
90  TQTimer::singleShot( 0, this, TQT_SLOT(checkNext()) );
91 }
92 
93 void BackgroundEngine::stop()
94 {
95 }
96 
97 void BackgroundEngine::continueChecking()
98 {
99  TQTimer::singleShot( 0, this, TQT_SLOT(checkNext()) );
100 }
101 
102 void 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 
120 bool 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 
126 bool 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 
132 TQStringList 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

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

kspell2

Skip menu "kspell2"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kspell2 by doxygen 1.8.1.2
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |