Sonnet

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

KDE's Doxygen guidelines are available online.