File indexing completed on 2024-05-12 05:29:44
0001 /* 0002 * SPDX-FileCopyrightText: 2007 Ryan Bitanga <ephebiphobic@gmail.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-only 0005 */ 0006 0007 #ifndef SPELLCHECK_H 0008 #define SPELLCHECK_H 0009 0010 #include <sonnet/speller.h> 0011 0012 #include <KRunner/AbstractRunner> 0013 #include <QMutex> 0014 #include <QSharedPointer> 0015 0016 using namespace KRunner; 0017 0018 /** 0019 * This checks the spelling of query 0020 */ 0021 class SpellCheckRunner : public AbstractRunner 0022 { 0023 Q_OBJECT 0024 0025 public: 0026 SpellCheckRunner(QObject *parent, const KPluginMetaData &metaData); 0027 ~SpellCheckRunner() override; 0028 0029 void match(RunnerContext &context) override; 0030 void run(const RunnerContext &context, const QueryMatch &action) override; 0031 0032 void reloadConfiguration() override; 0033 QMimeData *mimeDataForMatch(const QueryMatch &match) override; 0034 0035 private: 0036 void loadData(); 0037 QString findLang(const QStringList &terms); 0038 0039 QString m_triggerWord; 0040 QStringList m_availableLangCodes; // en_US, ru_RU, ... 0041 QMap<QString, QString> m_languages; // key=language name, value=language code 0042 bool m_requireTriggerWord; 0043 QMap<QString, QSharedPointer<Sonnet::Speller>> m_spellers; // spellers 0044 0045 friend class SpellCheckRunnerTest; 0046 }; 0047 0048 #endif