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

Sonnet

  • 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
28using namespace Sonnet;
29
30HSpellDict::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
44HSpellDict::~HSpellDict()
45{
46 /* It exists in =< hspell-0.8 */
47 if (initialized)
48 hspell_uninit( m_speller );
49}
50
51bool 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
69QStringList 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
83bool 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
91bool HSpellDict::addToPersonal( const QString& word )
92{
93 // hspell-0.9 cannot do this
94 kDebug() << "HSpellDict::addToPersonal: Sorry, cannot.";
95 return false;
96}
97
98bool HSpellDict::addToSession( const QString& word )
99{
100 // hspell-0.9 cannot do this
101 kDebug() << "HSpellDict::addToSession: Sorry, cannot.";
102 return false;
103}
HSpellDict::storeReplacement
virtual bool storeReplacement(const QString &bad, const QString &good)
Definition: kspell_hspelldict.cpp:83
HSpellDict::addToSession
virtual bool addToSession(const QString &word)
Definition: kspell_hspelldict.cpp:98
HSpellDict::~HSpellDict
~HSpellDict()
Definition: kspell_hspelldict.cpp:44
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
HSpellDict::isCorrect
virtual bool isCorrect(const QString &word) const
Definition: kspell_hspelldict.cpp:51
HSpellDict::addToPersonal
virtual bool addToPersonal(const QString &word)
Definition: kspell_hspelldict.cpp:91
Sonnet::SpellerPlugin
kDebug
#define kDebug
kdebug.h
kspell_hspelldict.h
Sonnet
kspell_aspellclient.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Sonnet

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

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
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