lib

KoLanguageTab.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C)  2001, 2002 Montel Laurent <lmontel@mandrakesoft.com>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "KoLanguageTab.h"
00021 #include "KoGlobal.h"
00022 
00023 #include <kcombobox.h>
00024 #include <kiconloader.h>
00025 
00026 #include <qstringlist.h>
00027 
00028 #include "KoLanguageTab.moc"
00029 
00030 
00031 KoLanguageTab::KoLanguageTab( KSpell2::Broker::Ptr broker, QWidget* parent, const char* name, WFlags fl )
00032         : KoLanguageTabBase( parent, name, fl )
00033 {
00034     const QStringList langNames = KoGlobal::listOfLanguages();
00035     const QStringList langTags = KoGlobal::listTagOfLanguages();
00036     QStringList spellCheckLanguages;
00037 
00038     if ( broker )
00039         spellCheckLanguages = broker->languages();
00040 
00041     QStringList::ConstIterator itName = langNames.begin();
00042     QStringList::ConstIterator itTag = langTags.begin();
00043     for ( ; itName != langNames.end() && itTag != langTags.end(); ++itName, ++itTag )
00044     {
00045         if ( spellCheckLanguages.find( *itTag ) != spellCheckLanguages.end() )
00046             languageKComboBox->insertItem( SmallIcon( "spellcheck" ), *itName );
00047         else
00048             languageKComboBox->insertItem( *itName );
00049     }
00050     connect( languageKComboBox, SIGNAL( activated( int ) ), this, SIGNAL( languageChanged() ) );
00051 }
00052 
00053 KoLanguageTab::~KoLanguageTab()
00054 {
00055 }
00056 
00057 QString KoLanguageTab::getLanguage() const
00058 {
00059     return KoGlobal::tagOfLanguage( languageKComboBox->currentText() );
00060 }
00061 
00062 void KoLanguageTab::setLanguage( const QString &item )
00063 {
00064     languageKComboBox->setCurrentText( KoGlobal::languageFromTag( item ) );
00065 }
KDE Home | KDE Accessibility Home | Description of Access Keys