kspell_aspellclient.cpp

00001 /*
00002  * kspell_aspellclient.cpp
00003  *
00004  * Copyright (C)  2003  Zack Rusin <zack@kde.org>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00019  * 02110-1301  USA
00020  */
00021 #include "kspell_aspellclient.h"
00022 
00023 #include "kspell_aspelldict.h"
00024 
00025 #include <kgenericfactory.h>
00026 #include <kdebug.h>
00027 
00028 typedef KGenericFactory<ASpellClient> ASpellClientFactory;
00029 K_EXPORT_COMPONENT_FACTORY( kspell_aspell, ASpellClientFactory( "kspell_aspell" )  )
00030 
00031 using namespace KSpell2;
00032 
00033 ASpellClient::ASpellClient( QObject *parent, const char *name, const QStringList& /* args */  )
00034     : Client( parent, name )
00035 {
00036     m_config = new_aspell_config();
00037 }
00038 
00039 ASpellClient::~ASpellClient()
00040 {
00041     delete_aspell_config( m_config );
00042 }
00043 
00044 Dictionary* ASpellClient::dictionary( const QString& language )
00045 {
00046     ASpellDict *ad = new ASpellDict( language );
00047     return ad;
00048 }
00049 
00050 QStringList ASpellClient::languages() const
00051 {
00052     AspellDictInfoList *l = get_aspell_dict_info_list( m_config );
00053     AspellDictInfoEnumeration *el = aspell_dict_info_list_elements( l );
00054 
00055     QStringList langs;
00056     const AspellDictInfo *di = 0;
00057     while ( ( di = aspell_dict_info_enumeration_next( el ) ) ) {
00058         langs.append( di->name );
00059     }
00060 
00061     delete_aspell_dict_info_enumeration( el );
00062 
00063     return langs;
00064 }
00065 
00066 #include "kspell_aspellclient.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys