File indexing completed on 2024-05-05 04:01:24
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 #include <QStringDecoder> 0014 #include <QStringEncoder> 0015 0016 #include "spellerplugin_p.h" 0017 /* libhspell is a C library and it does not have #ifdef __cplusplus */ 0018 extern "C" { 0019 #include "hspell.h" 0020 } 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 mutable QStringDecoder m_decoder; 0045 mutable QStringEncoder m_encoder; 0046 bool initialized; 0047 QSet<QString> m_sessionWords; 0048 QSet<QString> m_personalWords; 0049 QHash<QString, QString> m_replacements; 0050 }; 0051 0052 #endif