| 1 | /* |
| 2 | * kspell_aspelldict.h |
| 3 | * |
| 4 | * SPDX-FileCopyrightText: 2009 Montel Laurent <montel@kde.org> |
| 5 | * |
| 6 | * SPDX-License-Identifier: LGPL-2.1-or-later |
| 7 | */ |
| 8 | #ifndef KSPELL_HUNSPELLDICT_H |
| 9 | #define KSPELL_HUNSPELLDICT_H |
| 10 | |
| 11 | #include "hunspell.hxx" |
| 12 | #include "spellerplugin_p.h" |
| 13 | |
| 14 | #include <QStringDecoder> |
| 15 | #include <QStringEncoder> |
| 16 | |
| 17 | #include <memory> |
| 18 | |
| 19 | class HunspellDict : public Sonnet::SpellerPlugin |
| 20 | { |
| 21 | public: |
| 22 | explicit HunspellDict(const QString &name, const std::shared_ptr<Hunspell> &speller); |
| 23 | ~HunspellDict() override; |
| 24 | bool isCorrect(const QString &word) const override; |
| 25 | |
| 26 | QStringList suggest(const QString &word) const override; |
| 27 | |
| 28 | bool storeReplacement(const QString &bad, const QString &good) override; |
| 29 | |
| 30 | bool addToPersonal(const QString &word) override; |
| 31 | bool addToSession(const QString &word) override; |
| 32 | |
| 33 | static std::shared_ptr<Hunspell> createHunspell(const QString &lang, QString path); |
| 34 | |
| 35 | private: |
| 36 | QByteArray toDictEncoding(const QString &word) const; |
| 37 | |
| 38 | std::shared_ptr<Hunspell> m_speller; |
| 39 | mutable QStringEncoder m_encoder; |
| 40 | mutable QStringDecoder m_decoder; |
| 41 | }; |
| 42 | |
| 43 | #endif |
| 44 | |