File indexing completed on 2024-05-05 04:01:24
0001 /* 0002 * kspell_aspelldict.h 0003 * 0004 * SPDX-FileCopyrightText: 2009 Montel Laurent <montel@kde.org> 0005 * 0006 * SPDX-License-Identifier: LGPL-2.1-or-later 0007 */ 0008 #ifndef KSPELL_HUNSPELLDICT_H 0009 #define KSPELL_HUNSPELLDICT_H 0010 0011 #include "hunspell.hxx" 0012 #include "spellerplugin_p.h" 0013 0014 #include <QStringDecoder> 0015 #include <QStringEncoder> 0016 0017 #include <memory> 0018 0019 class HunspellDict : public Sonnet::SpellerPlugin 0020 { 0021 public: 0022 explicit HunspellDict(const QString &name, const std::shared_ptr<Hunspell> &speller); 0023 ~HunspellDict() override; 0024 bool isCorrect(const QString &word) const override; 0025 0026 QStringList suggest(const QString &word) const override; 0027 0028 bool storeReplacement(const QString &bad, const QString &good) override; 0029 0030 bool addToPersonal(const QString &word) override; 0031 bool addToSession(const QString &word) override; 0032 0033 static std::shared_ptr<Hunspell> createHunspell(const QString &lang, QString path); 0034 0035 private: 0036 QByteArray toDictEncoding(const QString &word) const; 0037 0038 std::shared_ptr<Hunspell> m_speller; 0039 mutable QStringEncoder m_encoder; 0040 mutable QStringDecoder m_decoder; 0041 }; 0042 0043 #endif