21 #include "backgroundengine.h"
23 #include "defaultdictionary.h"
24 #include "dictionary.h"
33 BackgroundEngine::BackgroundEngine( TQObject *parent )
36 m_filter = Filter::defaultFilter();
40 BackgroundEngine::~BackgroundEngine()
42 delete m_dict; m_dict = 0;
45 void BackgroundEngine::setBroker(
const Broker::Ptr& broker )
49 m_defaultDict = m_broker->defaultDictionary();
50 m_filter->setSettings( m_broker->settings() );
53 void BackgroundEngine::setText(
const TQString& text )
55 m_filter->setBuffer( text );
58 TQString BackgroundEngine::text()
const
60 return m_filter->buffer();
63 void BackgroundEngine::changeLanguage(
const TQString& lang )
66 if ( lang.isEmpty() ) {
69 m_dict = m_broker->dictionary( lang );
73 TQString BackgroundEngine::language()
const
76 return m_dict->language();
78 return m_defaultDict->language();
81 void BackgroundEngine::setFilter(
Filter *filter )
83 TQString oldText = m_filter->buffer();
85 m_filter->setBuffer( oldText );
88 void BackgroundEngine::start()
90 TQTimer::singleShot( 0,
this, TQT_SLOT(checkNext()) );
93 void BackgroundEngine::stop()
97 void BackgroundEngine::continueChecking()
99 TQTimer::singleShot( 0,
this, TQT_SLOT(checkNext()) );
102 void BackgroundEngine::checkNext()
104 Word w = m_filter->nextWord();
110 Dictionary *dict = ( m_dict ) ? m_dict : static_cast<Dictionary*>( m_defaultDict );
112 if ( !dict->
check( w.word ) ) {
114 emit misspelling( w.word, w.start );
120 bool BackgroundEngine::checkWord(
const TQString& word )
122 Dictionary *dict = ( m_dict ) ? m_dict : static_cast<Dictionary*>( m_defaultDict );
123 return dict->
check( word );
126 bool BackgroundEngine::addWord(
const TQString& word )
128 Dictionary *dict = ( m_dict ) ? m_dict : static_cast<Dictionary*>( m_defaultDict );
132 TQStringList BackgroundEngine::suggest(
const TQString& word )
134 Dictionary *dict = ( m_dict ) ? m_dict : static_cast<Dictionary*>( m_defaultDict );
138 #include "backgroundengine.moc"
virtual bool check(const TQString &word)=0
Checks the given word.
Filter is used to split text into words which will be spell checked.
Class is returned by from Broker.
Structure abstracts the word and its position in the parent text.
virtual bool addToPersonal(const TQString &word)=0
Adds word to the list of of personal words.
virtual TQStringList suggest(const TQString &word)=0
Fetches suggestions for the word.