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

Sonnet

  • sources
  • kde-4.14
  • kdelibs
  • sonnet
  • plugins
  • hspell
kspell_hspelldict.cpp
Go to the documentation of this file.
1 
23 #include "kspell_hspelldict.h"
24 #include <kdebug.h>
25 
26 #include <QtCore/QTextCodec>
27 
28 using namespace Sonnet;
29 
30 HSpellDict::HSpellDict( const QString& lang )
31  : SpellerPlugin( lang )
32 {
33  int int_error = hspell_init( &m_speller, HSPELL_OPT_DEFAULT );
34  if ( int_error == -1 ) {
35  kDebug() << "HSpellDict::HSpellDict: Init failed";
36  /* hspell understans only iso8859-8-i */
37  codec = QTextCodec::codecForName( "iso8859-8-i" );
38  initialized = false;
39  } else {
40  initialized = true;
41  }
42 }
43 
44 HSpellDict::~HSpellDict()
45 {
46  /* It exists in =< hspell-0.8 */
47  if (initialized)
48  hspell_uninit( m_speller );
49 }
50 
51 bool HSpellDict::isCorrect( const QString& word ) const
52 {
53  kDebug() << "HSpellDict::check word = " << word;
54  int preflen;
55  QByteArray wordISO = codec->fromUnicode( word );
56  /* returns 1 if the word is correct, 0 otherwise */
57  int correct = hspell_check_word ( m_speller,
58  wordISO,
59  &preflen); //this going to be removed
60  //in next hspell releases
61  /* I do not really understand what gimatria is */
62  if( correct != 1 ){
63  if( hspell_is_canonic_gimatria( wordISO ) != 0 )
64  correct = 1;
65  }
66  return correct == 1;
67 }
68 
69 QStringList HSpellDict::suggest( const QString& word ) const
70 {
71  QStringList qsug;
72  struct corlist cl;
73  int n_sugg;
74  corlist_init( &cl );
75  hspell_trycorrect( m_speller, codec->fromUnicode( word ), &cl );
76  for( n_sugg = 0; n_sugg < corlist_n( &cl ); n_sugg++){
77  qsug.append( codec->toUnicode( corlist_str( &cl, n_sugg) ) );
78  }
79  corlist_free( &cl );
80  return qsug;
81 }
82 
83 bool HSpellDict::storeReplacement( const QString& bad,
84  const QString& good )
85 {
86  // hspell-0.9 cannot do this
87  kDebug() << "HSpellDict::storeReplacement: Sorry, cannot.";
88  return false;
89 }
90 
91 bool HSpellDict::addToPersonal( const QString& word )
92 {
93  // hspell-0.9 cannot do this
94  kDebug() << "HSpellDict::addToPersonal: Sorry, cannot.";
95  return false;
96 }
97 
98 bool HSpellDict::addToSession( const QString& word )
99 {
100  // hspell-0.9 cannot do this
101  kDebug() << "HSpellDict::addToSession: Sorry, cannot.";
102  return false;
103 }
QTextCodec::fromUnicode
QByteArray fromUnicode(const QString &str) const
HSpellDict::isCorrect
virtual bool isCorrect(const QString &word) const
Definition: kspell_hspelldict.cpp:51
HSpellDict::~HSpellDict
~HSpellDict()
Definition: kspell_hspelldict.cpp:44
kdebug.h
QByteArray
HSpellDict::addToSession
virtual bool addToSession(const QString &word)
Definition: kspell_hspelldict.cpp:98
kDebug
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
QList::append
void append(const T &value)
kspell_hspelldict.h
HSpellDict::addToPersonal
virtual bool addToPersonal(const QString &word)
Definition: kspell_hspelldict.cpp:91
QString
QStringList
Sonnet::SpellerPlugin
QTextCodec::codecForName
QTextCodec * codecForName(const QByteArray &name)
HSpellDict::storeReplacement
virtual bool storeReplacement(const QString &bad, const QString &good)
Definition: kspell_hspelldict.cpp:83
HSpellDict::suggest
virtual QStringList suggest(const QString &word) const
Definition: kspell_hspelldict.cpp:69
HSpellDict::HSpellDict
HSpellDict(const QString &lang)
Definition: kspell_hspelldict.cpp:30
QTextCodec::toUnicode
QString toUnicode(const QByteArray &a) const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Sonnet

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal