File indexing completed on 2024-05-12 15:49:37

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 <memory>
0015 
0016 class QTextCodec;
0017 
0018 class HunspellDict : public Sonnet::SpellerPlugin
0019 {
0020 public:
0021     explicit HunspellDict(const QString &name, const std::shared_ptr<Hunspell> &speller);
0022     ~HunspellDict() override;
0023     bool isCorrect(const QString &word) const override;
0024 
0025     QStringList suggest(const QString &word) const override;
0026 
0027     bool storeReplacement(const QString &bad, const QString &good) override;
0028 
0029     bool addToPersonal(const QString &word) override;
0030     bool addToSession(const QString &word) override;
0031 
0032     static std::shared_ptr<Hunspell> createHunspell(const QString &lang, QString path);
0033 
0034 private:
0035     QByteArray toDictEncoding(const QString &word) const;
0036 
0037     std::shared_ptr<Hunspell> m_speller;
0038     QTextCodec *m_codec = nullptr;
0039 };
0040 
0041 #endif