21 #include "backgroundchecker.h"
24 #include "backgroundengine.h"
32 class BackgroundChecker::Private
36 BackgroundEngine *engine;
40 BackgroundChecker::BackgroundChecker(
const Broker::Ptr& broker, TQObject* parent,
42 : TQObject( parent, name )
47 d->engine =
new BackgroundEngine(
this );
48 d->engine->setBroker( broker );
49 connect( d->engine, TQ_SIGNAL(misspelling(
const TQString&,
int )),
50 TQ_SIGNAL(misspelling(
const TQString&,
int )) );
51 connect( d->engine, TQ_SIGNAL(done()),
52 TQ_SLOT(slotEngineDone()) );
55 BackgroundChecker::~BackgroundChecker()
62 d->currentText = text;
64 d->engine->setText( text );
68 void BackgroundChecker::start()
74 d->engine->setText( d->currentText );
78 void BackgroundChecker::stop()
86 return TQString::null;
93 void BackgroundChecker::setFilter(
Filter *filter )
96 d->engine->setFilter( filter );
99 Filter *BackgroundChecker::filter()
const
102 return d->engine->filter();
105 Broker *BackgroundChecker::broker()
const
108 return d->engine->broker();
111 bool BackgroundChecker::checkWord(
const TQString& word )
114 return d->engine->checkWord( word );
117 bool BackgroundChecker::addWord(
const TQString& word )
119 return d->engine->addWord( word );
122 TQStringList BackgroundChecker::suggest(
const TQString& word )
const
125 return d->engine->suggest( word );
128 void BackgroundChecker::changeLanguage(
const TQString& lang )
131 d->engine->changeLanguage( lang );
136 d->engine->continueChecking();
139 void BackgroundChecker::slotEngineDone()
144 if ( d->currentText.isNull() ) {
148 d->engine->setText( d->currentText );
155 void BackgroundChecker::customEvent( TQCustomEvent *event )
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() )
164 kdDebug()<<
"Cleaning up misspelling for old text which is \""<<currentWord
165 <<
"\" and should be \""<<me->word()<<
"\""<<endl;
167 }
else if ( (
int)event->type() == FinishedChecking ) {
169 if ( d->currentText.isEmpty() )
172 d->thread.setText( d->currentText );
174 TQObject::customEvent( event );
179 #include "backgroundchecker.moc"