• 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
  • hunspell
kspell_hunspelldict.cpp
Go to the documentation of this file.
1 
21 #include "kspell_hunspelldict.h"
22 #include <QFileInfo>
23 
24 #include <kdebug.h>
25 
26 #include <QtCore/QTextCodec>
27 
28 using namespace Sonnet;
29 
30 HunspellDict::HunspellDict( const QString& lang )
31  : SpellerPlugin(lang), m_speller(0)
32 {
33  kDebug()<<" HunspellDict::HunspellDict( const QString& lang ):"<<lang;
34  QString dic=QString("/usr/share/myspell/dicts/%1.dic").arg(lang);
35  if (QFileInfo(dic).exists())
36  m_speller = new Hunspell(QString("/usr/share/myspell/dicts/%1.aff").arg(lang).toUtf8().constData(),dic.toUtf8().constData());
37  else
38  m_speller = 0;
39  kDebug()<<" dddddd "<<m_speller;
40 
41 }
42 
43 HunspellDict::~HunspellDict()
44 {
45  delete m_speller;
46 }
47 
48 bool HunspellDict::isCorrect(const QString &word) const
49 {
50  kDebug()<<" isCorrect :"<<word;
51  if(!m_speller)
52  return false;
53  int result = m_speller->spell(word.toUtf8());
54  kDebug()<<" result :"<<result;
55  return (result != 0) ;
56 }
57 
58 QStringList HunspellDict::suggest(const QString &word) const
59 {
60  if(!m_speller)
61  return QStringList();
62  char ** selection;
63  QStringList lst;
64  int nbWord = m_speller->suggest(&selection, word.toUtf8());
65  for(int i = 0; i <nbWord;++i)
66  {
67  lst << QString::fromUtf8(selection[i]);
68  }
69  m_speller->free_list(&selection, nbWord);
70  return lst;
71 }
72 
73 
74 bool HunspellDict::storeReplacement( const QString& bad,
75  const QString& good )
76 {
77  if (!m_speller)
78  return false;
79  kDebug()<<"HunspellDict::storeReplacement not implemented";
80  return false;
81 }
82 
83 bool HunspellDict::addToPersonal( const QString& word )
84 {
85  if (!m_speller)
86  return false;
87  m_speller->add(word.toUtf8());
88  return false;
89 }
90 
91 bool HunspellDict::addToSession( const QString& word )
92 {
93  if (!m_speller)
94  return false;
95  kDebug()<<" bool HunspellDict::addToSession not implemented";
96  return false;
97 }
kdebug.h
HunspellDict::HunspellDict
HunspellDict(const QString &lang)
Definition: kspell_hunspelldict.cpp:30
kDebug
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
QString::fromUtf8
QString fromUtf8(const char *str, int size)
kspell_hunspelldict.h
HunspellDict::storeReplacement
virtual bool storeReplacement(const QString &bad, const QString &good)
Definition: kspell_hunspelldict.cpp:74
QByteArray::constData
const char * constData() const
QString
QStringList
QFileInfo
HunspellDict::suggest
virtual QStringList suggest(const QString &word) const
Definition: kspell_hunspelldict.cpp:58
Sonnet::SpellerPlugin
HunspellDict::isCorrect
virtual bool isCorrect(const QString &word) const
Definition: kspell_hunspelldict.cpp:48
HunspellDict::addToSession
virtual bool addToSession(const QString &word)
Definition: kspell_hunspelldict.cpp:91
HunspellDict::~HunspellDict
~HunspellDict()
Definition: kspell_hunspelldict.cpp:43
HunspellDict::addToPersonal
virtual bool addToPersonal(const QString &word)
Definition: kspell_hunspelldict.cpp:83
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
QString::toUtf8
QByteArray toUtf8() 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