File indexing completed on 2024-04-21 04:00:55
0001 /* 0002 * SPDX-FileCopyrightText: 2004 Zack Rusin <zack@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 #ifndef SONNET_SPELLERPLUGIN_P_H 0007 #define SONNET_SPELLERPLUGIN_P_H 0008 0009 #include <QString> 0010 #include <QStringList> 0011 0012 #include "sonnetcore_export.h" 0013 0014 #include <memory> 0015 0016 namespace Sonnet 0017 { 0018 class SpellerPluginPrivate; 0019 /** 0020 * Class is returned by from Loader. It acts 0021 * as the actual spellchecker. 0022 * 0023 * @author Zack Rusin <zack@kde.org> 0024 * @short class used for actual spell checking 0025 */ 0026 class SONNETCORE_EXPORT SpellerPlugin 0027 { 0028 public: 0029 virtual ~SpellerPlugin(); 0030 0031 /** 0032 * Checks the given word. 0033 * @return false if the word is misspelled. true otherwise 0034 */ 0035 virtual bool isCorrect(const QString &word) const = 0; 0036 0037 /** 0038 * Checks the given word. 0039 * @return true if the word is misspelled. false otherwise 0040 */ 0041 bool isMisspelled(const QString &word) const; 0042 0043 /** 0044 * Fetches suggestions for the word. 0045 * 0046 * @return list of all suggestions for the word 0047 */ 0048 virtual QStringList suggest(const QString &word) const = 0; 0049 0050 /** 0051 * Convenient method calling isCorrect() and suggest() 0052 * if the word isn't correct. 0053 */ 0054 virtual bool checkAndSuggest(const QString &word, QStringList &suggestions) const; 0055 0056 /** 0057 * Stores user defined good replacement for the bad word. 0058 * @returns true on success 0059 */ 0060 virtual bool storeReplacement(const QString &bad, const QString &good) = 0; 0061 0062 /** 0063 * Adds word to the list of of personal words. 0064 * @return true on success 0065 */ 0066 virtual bool addToPersonal(const QString &word) = 0; 0067 0068 /** 0069 * Adds word to the words recognizable in the current session. 0070 * @return true on success 0071 */ 0072 virtual bool addToSession(const QString &word) = 0; 0073 0074 /** 0075 * Returns language supported by this dictionary. 0076 */ 0077 QString language() const; 0078 0079 protected: 0080 SpellerPlugin(const QString &lang); 0081 0082 private: 0083 std::unique_ptr<SpellerPluginPrivate> const d; 0084 }; 0085 } 0086 0087 #endif