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

kspell2

  • kspell2
backgroundchecker.cpp
1 
21 #include "backgroundchecker.h"
22 
23 #include "broker.h"
24 #include "backgroundengine.h"
25 //#include "backgroundthread.h"
26 //#include "threadevents.h"
27 
28 #include <kdebug.h>
29 
30 using namespace KSpell2;
31 
32 class BackgroundChecker::Private
33 {
34 public:
35  //BackgroundThread thread;
36  BackgroundEngine *engine;
37  TQString currentText;
38 };
39 
40 BackgroundChecker::BackgroundChecker( const Broker::Ptr& broker, TQObject* parent,
41  const char *name )
42  : TQObject( parent, name )
43 {
44  d = new Private;
45  //d->thread.setReceiver( this );
46  //d->thread.setBroker( broker );
47  d->engine = new BackgroundEngine( this );
48  d->engine->setBroker( broker );
49  connect( d->engine, TQT_SIGNAL(misspelling( const TQString&, int )),
50  TQT_SIGNAL(misspelling( const TQString&, int )) );
51  connect( d->engine, TQT_SIGNAL(done()),
52  TQT_SLOT(slotEngineDone()) );
53 }
54 
55 BackgroundChecker::~BackgroundChecker()
56 {
57  delete d;
58 }
59 
60 void BackgroundChecker::checkText( const TQString& text )
61 {
62  d->currentText = text;
63  //d->thread.setText( text );
64  d->engine->setText( text );
65  d->engine->start();
66 }
67 
68 void BackgroundChecker::start()
69 {
70  d->currentText = getMoreText();
71  // ## what if d->currentText.isEmpty()?
72  //kdDebug()<<"KSpell BackgroundChecker: starting with : \"" << d->currentText << "\""<<endl;
73  //d->thread.setText( d->currentText );
74  d->engine->setText( d->currentText );
75  d->engine->start();
76 }
77 
78 void BackgroundChecker::stop()
79 {
80  //d->thread.stop();
81  d->engine->stop();
82 }
83 
84 TQString BackgroundChecker::getMoreText()
85 {
86  return TQString::null;
87 }
88 
89 void BackgroundChecker::finishedCurrentFeed()
90 {
91 }
92 
93 void BackgroundChecker::setFilter( Filter *filter )
94 {
95  //d->thread.setFilter( filter );
96  d->engine->setFilter( filter );
97 }
98 
99 Filter *BackgroundChecker::filter() const
100 {
101  //return d->thread.filter();
102  return d->engine->filter();
103 }
104 
105 Broker *BackgroundChecker::broker() const
106 {
107  //return d->thread.broker();
108  return d->engine->broker();
109 }
110 
111 bool BackgroundChecker::checkWord( const TQString& word )
112 {
113  //kdDebug()<<"checking word \""<<word<< "\""<<endl;
114  return d->engine->checkWord( word );
115 }
116 
117 bool BackgroundChecker::addWord( const TQString& word )
118 {
119  return d->engine->addWord( word );
120 }
121 
122 TQStringList BackgroundChecker::suggest( const TQString& word ) const
123 {
124  //return d->thread.suggest( word );
125  return d->engine->suggest( word );
126 }
127 
128 void BackgroundChecker::changeLanguage( const TQString& lang )
129 {
130  //d->thread.changeLanguage( lang );
131  d->engine->changeLanguage( lang );
132 }
133 
134 void BackgroundChecker::continueChecking()
135 {
136  d->engine->continueChecking();
137 }
138 
139 void BackgroundChecker::slotEngineDone()
140 {
141  finishedCurrentFeed();
142  d->currentText = getMoreText();
143 
144  if ( d->currentText.isNull() ) {
145  emit done();
146  } else {
147  //d->thread.setText( d->currentText );
148  d->engine->setText( d->currentText );
149  d->engine->start();
150  }
151 }
152 
154 #if 0
155 void BackgroundChecker::customEvent( TQCustomEvent *event )
156 {
157  if ( (int)event->type() == FoundMisspelling ) {
158  MisspellingEvent *me = static_cast<MisspellingEvent*>( event );
159  kdDebug()<<"Found misspelling of \"" << me->word() << "\"" <<endl;
160  TQString currentWord = d->currentText.mid( me->position(), me->word().length() );
161  if ( currentWord == me->word() )
162  emit misspelling( me->word(), me->position() );
163  else {
164  kdDebug()<<"Cleaning up misspelling for old text which is \""<<currentWord
165  <<"\" and should be \""<<me->word()<<"\""<<endl;
166  }
167  } else if ( (int)event->type() == FinishedChecking ) {
168  d->currentText = getMoreText();
169  if ( d->currentText.isEmpty() )
170  emit done();
171  else
172  d->thread.setText( d->currentText );
173  } else {
174  TQObject::customEvent( event );
175  }
176 }
177 #endif
178 
179 #include "backgroundchecker.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. |