00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "KoLanguageTab.h"
00021 #include "KoGlobal.h"
00022
00023 #include <kcombobox.h>
00024 #include <kiconloader.h>
00025
00026 #include <QStringList>
00027
00028 #include "KoLanguageTab.moc"
00029
00030
00031 KoLanguageTab::KoLanguageTab( KSpell2::Loader::Ptr loader, QWidget* parent, const char* name, Qt::WFlags fl )
00032 : KoLanguageTabBase( parent )
00033 {
00034
00035 const QStringList langNames = KoGlobal::listOfLanguages();
00036 const QStringList langTags = KoGlobal::listTagOfLanguages();
00037 QStringList spellCheckLanguages;
00038
00039 if ( loader )
00040 spellCheckLanguages = loader->languages();
00041
00042 QStringList::ConstIterator itName = langNames.begin();
00043 QStringList::ConstIterator itTag = langTags.begin();
00044 for ( ; itName != langNames.end() && itTag != langTags.end(); ++itName, ++itTag )
00045 {
00046 if ( spellCheckLanguages.find( *itTag ) != spellCheckLanguages.end() )
00047 languageKComboBox->addItem( SmallIcon( "spellcheck" ), *itName );
00048 else
00049 languageKComboBox->addItem( *itName );
00050 }
00051 connect( languageKComboBox, SIGNAL( activated( int ) ), this, SIGNAL( languageChanged() ) );
00052 }
00053
00054 KoLanguageTab::~KoLanguageTab()
00055 {
00056 }
00057
00058 QString KoLanguageTab::getLanguage() const
00059 {
00060 return KoGlobal::tagOfLanguage( languageKComboBox->currentText() );
00061 }
00062
00063 void KoLanguageTab::setLanguage( const QString &item )
00064 {
00065 languageKComboBox->setCurrentText( KoGlobal::languageFromTag( item ) );
00066 }