SpellcheckHighlighter
#include <spellcheckhighlighter.h>
Properties | |
bool | active |
bool | autoDetectLanguageDisabled |
bool | automatic |
QString | currentLanguage |
int | cursorPosition |
QML_ELEMENTQQuickTextDocument * | document |
QColor | misspelledColor |
int | selectionEnd |
int | selectionStart |
bool | spellCheckerFound |
bool | wordIsMisspelled |
QString | wordUnderMouse |
Properties inherited from QObject | |
objectName | |
Signals | |
void | activeChanged () |
void | activeChanged (const QString &description) |
void | autoDetectLanguageDisabledChanged () |
void | automaticChanged () |
void | changeCursorPosition (int start, int end) |
void | currentLanguageChanged () |
void | cursorPositionChanged () |
void | documentChanged () |
void | misspelledColorChanged () |
void | selectionEndChanged () |
void | selectionStartChanged () |
void | wordIsMisspelledChanged () |
void | wordUnderMouseChanged () |
Public Slots | |
void | setCurrentLanguage (const QString &language) |
void | slotAutoDetection () |
void | slotRehighlight () |
Detailed Description
The Sonnet Highlighter class, used for drawing red lines in text fields when detecting spelling mistakes.
SpellcheckHighlighter is adapted for QML applications. In usual Kirigami/QQC2-desktop-style applications, this can be used directly by adding Kirigami.SpellCheck.enabled: true
on a TextArea.
On other QML applications, you can add the SpellcheckHighlighter as a child of a TextArea.
Note: TextField is not supported, as it lacks QTextDocument API that Sonnet relies on.
Additionally SpellcheckHighlighter provides some convenient methods to create a context menu with suggestions.
- See also
- suggestions
- Since
- 5.88
Definition at line 53 of file spellcheckhighlighter.h.
Property Documentation
◆ active
|
readwrite |
This property holds whether spell checking is enabled.
If active
is true then spell checking is enabled; otherwise it is disabled. Note that you have to disable automatic (de)activation with automatic before you change the state of spell checking if you want to persistently enable/disable spell checking.
- See also
- automatic
- Since
- 5.88
Definition at line 104 of file spellcheckhighlighter.h.
◆ autoDetectLanguageDisabled
|
readwrite |
This property holds whether the automatic language detection is disabled overriding the Sonnet global settings.
- Since
- 5.88
Definition at line 114 of file spellcheckhighlighter.h.
◆ automatic
|
readwrite |
This property holds whether spell checking is automatically disabled if there's too many errors.
- Since
- 5.88
Definition at line 109 of file spellcheckhighlighter.h.
◆ currentLanguage
|
read |
This property holds the current language used for spell checking.
- Since
- 5.88
Definition at line 87 of file spellcheckhighlighter.h.
◆ cursorPosition
|
readwrite |
This property holds the current cursor position.
- Since
- 5.88
Definition at line 63 of file spellcheckhighlighter.h.
◆ document
|
readwrite |
This property holds the underneath document from a QML TextEdit.
- Since
- 5.88
Definition at line 59 of file spellcheckhighlighter.h.
◆ misspelledColor
|
readwrite |
This property holds the spell color.
By default, it's red.
- Since
- 5.88
Definition at line 83 of file spellcheckhighlighter.h.
◆ selectionEnd
|
readwrite |
This property holds the end of the selection.
- Since
- 5.88
Definition at line 71 of file spellcheckhighlighter.h.
◆ selectionStart
|
readwrite |
This property holds the start of the selection.
- Since
- 5.88
Definition at line 67 of file spellcheckhighlighter.h.
◆ spellCheckerFound
|
read |
This property holds whether a spell checking backend with support for the currentLanguage was found.
- Since
- 5.88
Definition at line 92 of file spellcheckhighlighter.h.
◆ wordIsMisspelled
|
read |
This property holds whether the current word under the mouse is misspelled.
- Since
- 5.88
Definition at line 75 of file spellcheckhighlighter.h.
◆ wordUnderMouse
|
read |
This property holds the current word under the mouse.
- Since
- 5.88
Definition at line 79 of file spellcheckhighlighter.h.
Constructor & Destructor Documentation
◆ SpellcheckHighlighter()
Definition at line 157 of file spellcheckhighlighter.cpp.
◆ ~SpellcheckHighlighter()
|
override |
Definition at line 163 of file spellcheckhighlighter.cpp.
Member Function Documentation
◆ active()
bool SpellcheckHighlighter::active | ( | ) | const |
Definition at line 282 of file spellcheckhighlighter.cpp.
◆ activeChanged
Emitted when as-you-type spell checking is enabled or disabled.
- Parameters
-
description is a i18n description of the new state, with an optional reason
- Since
- 5.88
◆ addWordToDictionary()
Adds the given word permanently to the dictionary.
It will never be marked as misspelled again, even after restarting the application.
- Parameters
-
word the word which will be added to the dictionary
- Since
- 5.88
Definition at line 494 of file spellcheckhighlighter.cpp.
◆ autoDetectLanguageDisabled()
bool SpellcheckHighlighter::autoDetectLanguageDisabled | ( | ) | const |
Definition at line 199 of file spellcheckhighlighter.cpp.
◆ automatic()
bool SpellcheckHighlighter::automatic | ( | ) | const |
Definition at line 194 of file spellcheckhighlighter.cpp.
◆ checkerEnabledByDefault()
bool SpellcheckHighlighter::checkerEnabledByDefault | ( | ) | const |
Return true if checker is enabled by default.
- Since
- 5.88
◆ currentLanguage()
QString SpellcheckHighlighter::currentLanguage | ( | ) | const |
Definition at line 457 of file spellcheckhighlighter.cpp.
◆ cursorPosition()
int SpellcheckHighlighter::cursorPosition | ( | ) | const |
Definition at line 560 of file spellcheckhighlighter.cpp.
◆ eventFilter()
Reimplemented from QObject.
Definition at line 661 of file spellcheckhighlighter.cpp.
◆ highlightBlock()
Implements QSyntaxHighlighter.
Definition at line 311 of file spellcheckhighlighter.cpp.
◆ ignoreWord()
Ignores the given word.
This word will not be marked misspelled for this session. It will again be marked as misspelled when creating new highlighters.
- Parameters
-
word the word which will be ignored
- Since
- 5.88
Definition at line 500 of file spellcheckhighlighter.cpp.
◆ intraWordEditing()
|
protected |
Definition at line 204 of file spellcheckhighlighter.cpp.
◆ isWordMisspelled()
Checks if a given word is marked as misspelled by the highlighter.
- Parameters
-
word the word to be checked
- Returns
- true if the given word is misspelled.
- Since
- 5.88
Definition at line 656 of file spellcheckhighlighter.cpp.
◆ misspelledColor()
QColor SpellcheckHighlighter::misspelledColor | ( | ) | const |
Definition at line 642 of file spellcheckhighlighter.cpp.
◆ quickDocument()
QQuickTextDocument * SpellcheckHighlighter::quickDocument | ( | ) | const |
Definition at line 533 of file spellcheckhighlighter.cpp.
◆ replaceWord()
Replace word at the current cursor position, or.
- Parameters
-
at if at is not -1.
- Since
- 5.88
Definition at line 506 of file spellcheckhighlighter.cpp.
◆ selectionEnd()
int SpellcheckHighlighter::selectionEnd | ( | ) | const |
Definition at line 591 of file spellcheckhighlighter.cpp.
◆ selectionStart()
int SpellcheckHighlighter::selectionStart | ( | ) | const |
Definition at line 576 of file spellcheckhighlighter.cpp.
◆ setActive()
void SpellcheckHighlighter::setActive | ( | bool | active | ) |
Definition at line 266 of file spellcheckhighlighter.cpp.
◆ setAutoDetectLanguageDisabled()
void SpellcheckHighlighter::setAutoDetectLanguageDisabled | ( | bool | autoDetectDisabled | ) |
Definition at line 226 of file spellcheckhighlighter.cpp.
◆ setAutomatic()
void SpellcheckHighlighter::setAutomatic | ( | bool | automatic | ) |
Definition at line 214 of file spellcheckhighlighter.cpp.
◆ setCurrentLanguage
Set language to use for spell checking.
- Parameters
-
language the language code for the new language to use.
- Since
- 5.88
Definition at line 462 of file spellcheckhighlighter.cpp.
◆ setCursorPosition()
void SpellcheckHighlighter::setCursorPosition | ( | int | position | ) |
Definition at line 565 of file spellcheckhighlighter.cpp.
◆ setDocument()
void SpellcheckHighlighter::setDocument | ( | QTextDocument * | document | ) |
Set a new QTextDocument for this highlighter to operate on.
- Parameters
-
document the new document to operate on.
- Since
- 5.88
Definition at line 554 of file spellcheckhighlighter.cpp.
◆ setIntraWordEditing()
|
protected |
Definition at line 209 of file spellcheckhighlighter.cpp.
◆ setMisspelled()
|
protectedvirtual |
Definition at line 479 of file spellcheckhighlighter.cpp.
◆ setMisspelledColor()
Definition at line 647 of file spellcheckhighlighter.cpp.
◆ setMisspelledSelected()
|
protectedvirtual |
Definition at line 484 of file spellcheckhighlighter.cpp.
◆ setQuickDocument()
void SpellcheckHighlighter::setQuickDocument | ( | QQuickTextDocument * | document | ) |
Definition at line 538 of file spellcheckhighlighter.cpp.
◆ setSelectionEnd()
void SpellcheckHighlighter::setSelectionEnd | ( | int | position | ) |
Definition at line 596 of file spellcheckhighlighter.cpp.
◆ setSelectionStart()
void SpellcheckHighlighter::setSelectionStart | ( | int | position | ) |
Definition at line 581 of file spellcheckhighlighter.cpp.
◆ slotAutoDetection
|
slot |
Run auto detection, disabling spell checking if too many errors are found.
- Since
- 5.88
Definition at line 231 of file spellcheckhighlighter.cpp.
◆ slotRehighlight
|
slot |
◆ spellCheckerFound()
bool SpellcheckHighlighter::spellCheckerFound | ( | ) | const |
Definition at line 170 of file spellcheckhighlighter.cpp.
◆ suggestions()
QStringList SpellcheckHighlighter::suggestions | ( | int | position, |
int | max = 5 ) |
Returns a list of suggested replacements for the given misspelled word.
If the word is not misspelled, the list will be empty.
- Parameters
-
word the misspelled word max at most this many suggestions will be returned. If this is -1, as many suggestions as the spell backend supports will be returned.
- Returns
- a list of suggested replacements for the word
- Since
- 5.88
Definition at line 389 of file spellcheckhighlighter.cpp.
◆ unsetMisspelled()
|
protectedvirtual |
Definition at line 489 of file spellcheckhighlighter.cpp.
◆ wordIsMisspelled()
bool SpellcheckHighlighter::wordIsMisspelled | ( | ) | const |
Definition at line 632 of file spellcheckhighlighter.cpp.
◆ wordUnderMouse()
QString SpellcheckHighlighter::wordUnderMouse | ( | ) | const |
Definition at line 637 of file spellcheckhighlighter.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:15:10 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.