File indexing completed on 2024-05-05 04:01:24

0001 /*
0002  * kspell_hunspellclient.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_HUNSPELLCLIENT_H
0009 #define KSPELL_HUNSPELLCLIENT_H
0010 
0011 #include "client_p.h"
0012 #include <QMap>
0013 #include <memory>
0014 
0015 class Hunspell;
0016 
0017 namespace Sonnet
0018 {
0019 class SpellerPlugin;
0020 }
0021 
0022 using Sonnet::SpellerPlugin;
0023 
0024 class HunspellClient : public Sonnet::Client
0025 {
0026     Q_OBJECT
0027     Q_INTERFACES(Sonnet::Client)
0028     Q_PLUGIN_METADATA(IID "org.kde.Sonnet.HunspellClient")
0029 public:
0030     explicit HunspellClient(QObject *parent = nullptr);
0031     ~HunspellClient() override;
0032 
0033     int reliability() const override
0034     {
0035         return 40;
0036     }
0037 
0038     SpellerPlugin *createSpeller(const QString &language) override;
0039 
0040     QStringList languages() const override;
0041 
0042     QString name() const override
0043     {
0044         return QStringLiteral("Hunspell");
0045     }
0046 
0047 private:
0048     QMap<QString, QString> m_languagePaths;
0049     QMap<QString, std::weak_ptr<Hunspell>> m_hunspellCache;
0050     QMap<QString, QString> m_languageAliases;
0051 };
0052 
0053 #endif