Sonnet

spellcheckdecorator.h
1 /*
2  * spellcheckdecorator.h
3  *
4  * SPDX-FileCopyrightText: 2013 Aurélien Gâteau <[email protected]>
5  *
6  * SPDX-License-Identifier: LGPL-2.1-or-later
7  */
8 #ifndef SPELLCHECKDECORATOR_H
9 #define SPELLCHECKDECORATOR_H
10 
11 #include <QObject>
12 
13 #include "sonnetui_export.h"
14 
15 class QTextEdit;
16 class QPlainTextEdit;
17 
18 namespace Sonnet
19 {
20 class Highlighter;
21 
22 /**
23  * @class Sonnet::SpellCheckDecorator spellcheckdecorator.h <Sonnet/SpellCheckDecorator>
24  *
25  * @short Connects a Sonnet::Highlighter to a QTextEdit extending the context menu of the text edit with spell check suggestions
26  * @author Aurélien Gâteau <[email protected]>
27  * @since 5.0
28  **/
29 
30 class SONNETUI_EXPORT SpellCheckDecorator : public QObject
31 {
32  Q_OBJECT
33 public:
34  /**
35  * Creates a spell-check decorator.
36  *
37  * @param textEdit the QTextEdit in need of spell-checking. It also is used as the QObject parent for the decorator.
38  */
39  explicit SpellCheckDecorator(QTextEdit *textEdit);
40 
41  /**
42  * Creates a spell-check decorator.
43  *
44  * @param textEdit the QPlainTextEdit in need of spell-checking. It also is used as the QObject parent for the decorator.
45  * @since 5.12
46  */
47  explicit SpellCheckDecorator(QPlainTextEdit *textEdit);
48 
49  ~SpellCheckDecorator() override;
50 
51  /**
52  * Set a custom highlighter on the decorator.
53  *
54  * SpellCheckDecorator does not take ownership of the new highlighter,
55  * and you must manually delete the old highlighter.
56  */
57  void setHighlighter(Highlighter *highlighter);
58 
59  /**
60  * Returns the hightlighter used by the decorator
61  */
62  Highlighter *highlighter() const;
63 
64 protected:
65  bool eventFilter(QObject *obj, QEvent *event) override;
66 
67  /**
68  * Returns true if the spell checking should be enabled for a given block of text
69  * The default implementation always returns true.
70  */
71  virtual bool isSpellCheckingEnabledForBlock(const QString &textBlock) const;
72 
73 private:
74  class Private;
75  Private *const d;
76  Q_DISABLE_COPY(SpellCheckDecorator)
77 };
78 }
79 
80 #endif /* SPELLCHECKDECORATOR_H */
The Sonnet Highlighter class, used for drawing pretty red lines in text fields.
Definition: highlighter.h:23
The sonnet namespace.
Connects a Sonnet::Highlighter to a QTextEdit extending the context menu of the text edit with spell ...
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Sep 25 2022 04:14:52 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.