KPimTextEdit

plaintextsyntaxspellcheckinghighlighter.h
1 /*
2  SPDX-FileCopyrightText: 2015-2022 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "kpimtextedit_export.h"
10 
11 #include <KSyntaxHighlighting/SyntaxHighlighter>
12 #include <Sonnet/Highlighter>
13 
14 namespace KSyntaxHighlighting
15 {
16 class Format;
17 }
18 
19 namespace KPIMTextEdit
20 {
21 class PlainTextEditor;
22 class PlainTextSyntaxSpellCheckingHighlighterPrivate;
23 /**
24  * @brief The PlainTextSyntaxSpellCheckingHighlighter class
25  * @author Laurent Montel <[email protected]>
26  */
28 {
29 public:
30  explicit PlainTextSyntaxSpellCheckingHighlighter(PlainTextEditor *plainText, const QColor &misspelledColor = Qt::red);
32 
33  void toggleSpellHighlighting(bool on);
34 
35  void setDefinition(const KSyntaxHighlighting::Definition &def) override;
36 
37  /**
38  * Reimplemented to highlight quote blocks.
39  */
40  void highlightBlock(const QString &text) override;
41 
42 protected:
43  /**
44  * Reimplemented, the base version sets the text color to black, which
45  * is not what we want. We do nothing, the format is already reset by
46  * Qt.
47  * @param start the beginning of text
48  * @param count the amount of characters to set
49  */
50  void unsetMisspelled(int start, int count) override;
51 
52  /**
53  * Reimplemented to set the color of the misspelled word to a color
54  * defined by setQuoteColor().
55  */
56  void setMisspelled(int start, int count) override;
57 
58  void applyFormat(int offset, int length, const KSyntaxHighlighting::Format &format) override;
59 
60 private:
61  std::unique_ptr<PlainTextSyntaxSpellCheckingHighlighterPrivate> const d;
62 };
63 }
Q_SCRIPTABLE Q_NOREPLY void start()
The PlainTextEditor class.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri May 27 2022 04:12:48 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.