File indexing completed on 2024-05-12 15:49:37
0001 /* 0002 * kspell_hspelldict.h 0003 * 0004 * SPDX-FileCopyrightText: 2003 Zack Rusin <zack@kde.org> 0005 * SPDX-FileCopyrightText: 2005 Mashrab Kuvatov <kmashrab@uni-bremen.de> 0006 * 0007 * SPDX-License-Identifier: LGPL-2.1-or-later 0008 */ 0009 #ifndef KSPELL_HSPELLDICT_H 0010 #define KSPELL_HSPELLDICT_H 0011 0012 #include <QSet> 0013 0014 #include "spellerplugin_p.h" 0015 /* libhspell is a C library and it does not have #ifdef __cplusplus */ 0016 extern "C" { 0017 #include "hspell.h" 0018 } 0019 0020 class QTextCodec; 0021 0022 class HSpellDict : public Sonnet::SpellerPlugin 0023 { 0024 public: 0025 explicit HSpellDict(const QString &lang); 0026 ~HSpellDict(); 0027 bool isCorrect(const QString &word) const override; 0028 0029 QStringList suggest(const QString &word) const override; 0030 0031 bool storeReplacement(const QString &bad, const QString &good) override; 0032 0033 bool addToPersonal(const QString &word) override; 0034 bool addToSession(const QString &word) override; 0035 inline bool isInitialized() const 0036 { 0037 return initialized; 0038 } 0039 0040 private: 0041 void storePersonalWords(); 0042 0043 struct dict_radix *m_speller; 0044 QTextCodec *codec; 0045 bool initialized; 0046 QSet<QString> m_sessionWords; 0047 QSet<QString> m_personalWords; 0048 QHash<QString, QString> m_replacements; 0049 }; 0050 0051 #endif