File indexing completed on 2024-04-28 15:34:19

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 namespace Sonnet
0015 {
0016 /**
0017  * Class is returned by from Loader. It acts
0018  * as the actual spellchecker.
0019  *
0020  * @author Zack Rusin <zack@kde.org>
0021  * @short class used for actual spell checking
0022  */
0023 class SpellerPluginPrivate;
0024 class SONNETCORE_EXPORT SpellerPlugin
0025 {
0026 public:
0027     virtual ~SpellerPlugin();
0028 
0029     /**
0030      * Checks the given word.
0031      * @return false if the word is misspelled. true otherwise
0032      */
0033     virtual bool isCorrect(const QString &word) const = 0;
0034 
0035     /**
0036      * Checks the given word.
0037      * @return true if the word is misspelled. false otherwise
0038      */
0039     bool isMisspelled(const QString &word) const;
0040 
0041     /**
0042      * Fetches suggestions for the word.
0043      *
0044      * @return list of all suggestions for the word
0045      */
0046     virtual QStringList suggest(const QString &word) const = 0;
0047 
0048     /**
0049      * Convenient method calling isCorrect() and suggest()
0050      * if the word isn't correct.
0051      */
0052     virtual bool checkAndSuggest(const QString &word, QStringList &suggestions) const;
0053 
0054     /**
0055      * Stores user defined good replacement for the bad word.
0056      * @returns true on success
0057      */
0058     virtual bool storeReplacement(const QString &bad, const QString &good) = 0;
0059 
0060     /**
0061      * Adds word to the list of of personal words.
0062      * @return true on success
0063      */
0064     virtual bool addToPersonal(const QString &word) = 0;
0065 
0066     /**
0067      * Adds word to the words recognizable in the current session.
0068      * @return true on success
0069      */
0070     virtual bool addToSession(const QString &word) = 0;
0071 
0072     /**
0073      * Returns language supported by this dictionary.
0074      */
0075     QString language() const;
0076 
0077 protected:
0078     SpellerPlugin(const QString &lang);
0079 
0080 private:
0081     SpellerPluginPrivate *const d;
0082 };
0083 }
0084 
0085 #endif