• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

Sonnet

kspell_hspelldict.cpp

Go to the documentation of this file.
00001 
00023 #include "kspell_hspelldict.h"
00024 #include <kdebug.h>
00025 
00026 #include <QtCore/QTextCodec>
00027 
00028 using namespace Sonnet;
00029 
00030 HSpellDict::HSpellDict( const QString& lang )
00031     : SpellerPlugin( lang )
00032 {
00033    int int_error = hspell_init( &m_speller, HSPELL_OPT_DEFAULT );
00034    if ( int_error == -1 ) {
00035       kDebug() << "HSpellDict::HSpellDict: Init failed";
00036     /* hspell understans only iso8859-8-i            */
00037     codec = QTextCodec::codecForName( "iso8859-8-i" );
00038     initialized = false;
00039   } else {
00040     initialized = true;
00041   }
00042 }
00043 
00044 HSpellDict::~HSpellDict()
00045 {
00046     /* It exists in =< hspell-0.8 */
00047     if (initialized)
00048       hspell_uninit( m_speller );
00049 }
00050 
00051 bool HSpellDict::isCorrect( const QString& word ) const
00052 {
00053     kDebug() << "HSpellDict::check word = " << word;
00054     int preflen;
00055     QByteArray wordISO = codec->fromUnicode( word );
00056     /* returns 1 if the word is correct, 0 otherwise */
00057     int correct = hspell_check_word ( m_speller,
00058                               wordISO,
00059                                       &preflen); //this going to be removed
00060                                                  //in next hspell releases
00061     /* I do not really understand what gimatria is   */
00062     if( correct != 1 ){
00063         if( hspell_is_canonic_gimatria( wordISO ) != 0 )
00064     correct = 1;
00065     }
00066     return correct == 1;
00067 }
00068 
00069 QStringList HSpellDict::suggest( const QString& word ) const
00070 {
00071     QStringList qsug;
00072     struct corlist cl;
00073     int n_sugg;
00074     corlist_init( &cl );
00075     hspell_trycorrect( m_speller, codec->fromUnicode( word ), &cl );
00076     for( n_sugg = 0; n_sugg < corlist_n( &cl ); n_sugg++){
00077         qsug.append( codec->toUnicode( corlist_str( &cl, n_sugg) ) );
00078     }
00079     corlist_free( &cl );
00080     return qsug;
00081 }
00082 
00083 bool HSpellDict::storeReplacement( const QString& bad,
00084                                    const QString& good )
00085 {
00086     // hspell-0.9 cannot do this
00087     kDebug() << "HSpellDict::storeReplacement: Sorry, cannot.";
00088     return false;
00089 }
00090 
00091 bool HSpellDict::addToPersonal( const QString& word )
00092 {
00093     // hspell-0.9 cannot do this
00094     kDebug() << "HSpellDict::addToPersonal: Sorry, cannot.";
00095     return false;
00096 }
00097 
00098 bool HSpellDict::addToSession( const QString& word )
00099 {
00100     // hspell-0.9 cannot do this
00101     kDebug() << "HSpellDict::addToSession: Sorry, cannot.";
00102     return false;
00103 }

Sonnet

Skip menu "Sonnet"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal