36 #include "dictionarycombobox.h"
41 #include <tqstringlist.h>
45 DictionaryComboBox::DictionaryComboBox( TQWidget * parent,
const char * name )
46 : TQComboBox( false, parent, name ),
48 mDefaultDictionary( 0 )
51 connect(
this, TQ_SIGNAL( activated(
int ) ),
52 this, TQ_SLOT( slotDictionaryChanged(
int ) ) );
53 connect(
this, TQ_SIGNAL( dictionaryChanged(
int ) ),
54 mSpellConfig, TQ_SLOT( sSetDictionary(
int ) ) );
57 DictionaryComboBox::~DictionaryComboBox()
63 TQString DictionaryComboBox::currentDictionaryName()
const
68 TQString DictionaryComboBox::currentDictionary()
const
70 TQString dict = mDictionaries[ currentItem() ];
77 void DictionaryComboBox::setCurrentByDictionaryName(
const TQString & name )
82 for (
int i = 0; i < count(); ++i ) {
83 if ( text( i ) == name ) {
84 if ( i != currentItem() ) {
86 slotDictionaryChanged( i );
93 void DictionaryComboBox::setCurrentByDictionary(
const TQString & dictionary )
95 if ( !dictionary.isEmpty() ) {
97 if ( dictionary ==
"<default>" ) {
98 if ( 0 != currentItem() ) {
100 slotDictionaryChanged( 0 );
106 for ( TQStringList::ConstIterator it = mDictionaries.begin();
107 it != mDictionaries.end();
109 if ( *it == dictionary ) {
110 if ( i != currentItem() ) {
112 slotDictionaryChanged( i );
120 if ( mDefaultDictionary != currentItem() ) {
121 setCurrentItem( mDefaultDictionary );
122 slotDictionaryChanged( mDefaultDictionary );
126 KSpellConfig* DictionaryComboBox::spellConfig()
const
131 void DictionaryComboBox::reloadCombo()
134 mSpellConfig =
new KSpellConfig( 0, 0, 0,
false );
135 mSpellConfig->fillDicts(
this, &mDictionaries );
136 mDefaultDictionary = currentItem();
137 mSpellConfig->setDictionary( currentDictionary() );
140 void DictionaryComboBox::slotDictionaryChanged(
int idx )
142 kdDebug( 5006 ) <<
"DictionaryComboBox::slotDictionaryChanged( " << idx
144 emit dictionaryChanged( mDictionaries[idx] );
145 emit dictionaryChanged( idx );
150 #include "dictionarycombobox.moc"