21 #include "backgroundthread.h"
23 #include "threadevents.h"
26 #include "dictionary.h"
29 #include <tqapplication.h>
33 BackgroundThread::BackgroundThread()
34 : TQThread(), m_broker( 0 ), m_dict( 0 )
37 m_filter = Filter::defaultFilter();
41 void BackgroundThread::setReceiver( TQObject *recv )
46 void BackgroundThread::setBroker(
const Broker::Ptr& broker )
51 m_dict = m_broker->dictionary();
55 TQStringList BackgroundThread::suggest(
const TQString& word )
const
57 return m_dict->suggest( word );
60 void BackgroundThread::run()
64 for (
Word w = m_filter->nextWord(); !m_done && !w.end;
65 w = m_filter->nextWord() ) {
66 if ( !m_dict->check( w.word ) && !m_done ) {
67 MisspellingEvent *
event =
new MisspellingEvent( w.word, w.start );
68 TQApplication::postEvent( m_recv, event );
72 FinishedCheckingEvent *
event =
new FinishedCheckingEvent();
73 TQApplication::postEvent( m_recv, event );
76 void BackgroundThread::setText(
const TQString& buff )
80 m_filter->setBuffer( buff );
85 void BackgroundThread::setFilter(
Filter *filter )
89 Filter *oldFilter = m_filter;
92 m_filter->setBuffer( oldFilter->buffer() );
93 oldFilter->setBuffer( TQString::null );
99 void BackgroundThread::changeLanguage(
const TQString& lang )
104 m_dict = m_broker->dictionary( lang );
110 void BackgroundThread::stop()
Filter is used to split text into words which will be spell checked.
Structure abstracts the word and its position in the parent text.