• Skip to content
  • Skip to link menu
KDE 4.1 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 }
00039 
00040 HSpellDict::~HSpellDict()
00041 {
00042     /* It exists in =< hspell-0.8 */
00043     hspell_uninit( m_speller );
00044 }
00045 
00046 bool HSpellDict::isCorrect( const QString& word ) const
00047 {
00048     kDebug() << "HSpellDict::check word = " << word;
00049     int preflen;
00050     QByteArray wordISO = codec->fromUnicode( word );
00051     /* returns 1 if the word is correct, 0 otherwise */
00052     int correct = hspell_check_word ( m_speller,
00053                               wordISO,
00054                                       &preflen); //this going to be removed
00055                                                  //in next hspell releases
00056     /* I do not really understand what gimatria is   */
00057     if( correct != 1 ){
00058         if( hspell_is_canonic_gimatria( wordISO ) != 0 )
00059     correct = 1;
00060     }
00061     return correct == 1;
00062 }
00063 
00064 QStringList HSpellDict::suggest( const QString& word ) const
00065 {
00066     QStringList qsug;
00067     struct corlist cl;
00068     int n_sugg;
00069     corlist_init( &cl );
00070     hspell_trycorrect( m_speller, codec->fromUnicode( word ), &cl );
00071     for( n_sugg = 0; n_sugg < corlist_n( &cl ); n_sugg++){
00072         qsug.append( codec->toUnicode( corlist_str( &cl, n_sugg) ) );
00073     }
00074     corlist_free( &cl );
00075     return qsug;
00076 }
00077 
00078 bool HSpellDict::storeReplacement( const QString& bad,
00079                                    const QString& good )
00080 {
00081     // hspell-0.9 cannot do this
00082     kDebug() << "HSpellDict::storeReplacement: Sorry, cannot.";
00083     return false;
00084 }
00085 
00086 bool HSpellDict::addToPersonal( const QString& word )
00087 {
00088     // hspell-0.9 cannot do this
00089     kDebug() << "HSpellDict::addToPersonal: Sorry, cannot.";
00090     return false;
00091 }
00092 
00093 bool HSpellDict::addToSession( const QString& word )
00094 {
00095     // hspell-0.9 cannot do this
00096     kDebug() << "HSpellDict::addToSession: Sorry, cannot.";
00097     return false;
00098 }

Sonnet

Skip menu "Sonnet"
  • Main Page
  • 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
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
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