Sonnet
spellcheckhighlighter.cpp
324 connect(textDocument(), &QTextDocument::contentsChange, this, &SpellcheckHighlighter::contentsChange);
374 if (word.position() + offset <= cursor.position() && cursor.position() <= word.position() + offset + word.length()) {
403 const bool selectedWordClicked = cursor.hasSelection() && mousePosition >= cursor.selectionStart() && mousePosition <= cursor.selectionEnd();
414 if (d->selectedWord.startsWith(QLatin1Char('\'')) || d->selectedWord.startsWith(QLatin1Char('\"'))) {
418 if (d->selectedWord.endsWith(QLatin1Char('\'')) || d->selectedWord.endsWith(QLatin1Char('\"'))) {
422 wordSelectCursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, d->selectedWord.size());
428 if ((mousePosition < wordSelectCursor.selectionStart() || mousePosition >= wordSelectCursor.selectionEnd()) //
433 wordSelectCursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, d->selectedWord.size());
435 d->wordIsMisspelled = isMouseCursorInsideWord && !d->selectedWord.isEmpty() && d->spellchecker->isMisspelled(d->selectedWord);
468 qCDebug(SONNET_LOG_QUICK) << "No dictionary for \"" << lang << "\" staying with the current language.";
528 wordSelectCursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, d->selectedWord.size());
669 if (k->key() == Qt::Key_Enter || k->key() == Qt::Key_Return || k->key() == Qt::Key_Up || k->key() == Qt::Key_Down || k->key() == Qt::Key_Left
670 || k->key() == Qt::Key_Right || k->key() == Qt::Key_PageUp || k->key() == Qt::Key_PageDown || k->key() == Qt::Key_Home || k->key() == Qt::Key_End
672 && (k->key() == Qt::Key_A || k->key() == Qt::Key_B || k->key() == Qt::Key_E || k->key() == Qt::Key_N
bool addToSession(const QString &word)
Adds word to the words recognizable in the current session.
Definition speller.cpp:136
QStringList suggest(const QString &word) const
Fetches suggestions for the word.
Definition speller.cpp:104
bool addToPersonal(const QString &word)
Adds word to the list of of personal words.
Definition speller.cpp:128
void setLanguage(const QString &lang)
Sets the language supported by this speller.
Definition speller.cpp:243
The Sonnet Highlighter class, used for drawing red lines in text fields when detecting spelling mista...
Definition spellcheckhighlighter.h:54
bool wordIsMisspelled
This property holds whether the current word under the mouse is misspelled.
Definition spellcheckhighlighter.h:75
Q_INVOKABLE void ignoreWord(const QString &word)
Ignores the given word.
Definition spellcheckhighlighter.cpp:500
int selectionStart
This property holds the start of the selection.
Definition spellcheckhighlighter.h:67
void setCurrentLanguage(const QString &language)
Set language to use for spell checking.
Definition spellcheckhighlighter.cpp:462
QString currentLanguage
This property holds the current language used for spell checking.
Definition spellcheckhighlighter.h:87
QString wordUnderMouse
This property holds the current word under the mouse.
Definition spellcheckhighlighter.h:79
QML_ELEMENTQQuickTextDocument * document
This property holds the underneath document from a QML TextEdit.
Definition spellcheckhighlighter.h:59
void setDocument(QTextDocument *document)
Set a new QTextDocument for this highlighter to operate on.
Definition spellcheckhighlighter.cpp:554
Q_INVOKABLE void replaceWord(const QString &word, int at=-1)
Replace word at the current cursor position, or.
Definition spellcheckhighlighter.cpp:506
int cursorPosition
This property holds the current cursor position.
Definition spellcheckhighlighter.h:63
bool autoDetectLanguageDisabled
This property holds whether the automatic language detection is disabled overriding the Sonnet global...
Definition spellcheckhighlighter.h:114
bool active
This property holds whether spell checking is enabled.
Definition spellcheckhighlighter.h:104
Q_INVOKABLE QStringList suggestions(int position, int max=5)
Returns a list of suggested replacements for the given misspelled word.
Definition spellcheckhighlighter.cpp:389
void slotAutoDetection()
Run auto detection, disabling spell checking if too many errors are found.
Definition spellcheckhighlighter.cpp:231
Q_INVOKABLE bool isWordMisspelled(const QString &word)
Checks if a given word is marked as misspelled by the highlighter.
Definition spellcheckhighlighter.cpp:656
bool automatic
This property holds whether spell checking is automatically disabled if there's too many errors.
Definition spellcheckhighlighter.h:109
bool spellCheckerFound
This property holds whether a spell checking backend with support for the currentLanguage was found.
Definition spellcheckhighlighter.h:92
Q_INVOKABLE void addWordToDictionary(const QString &word)
Adds the given word permanently to the dictionary.
Definition spellcheckhighlighter.cpp:494
Q_SCRIPTABLE Q_NOREPLY void start()
bool isSpace(char32_t ucs4)
bool isValid() const const
void setAlphaF(float alpha)
KeyPress
Type type() const const
qsizetype count() const const
QList< T > mid(qsizetype pos, qsizetype length) const const
bool contains(const Key &key) const const
T value(const Key &key, const T &defaultValue) const const
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)
T qobject_cast(QObject *object)
QString tr(const char *sourceText, const char *disambiguation, int n)
const QChar at(qsizetype position) const const
bool isEmpty() const const
qsizetype length() const const
QTextBlockUserData * currentBlockUserData() const const
void rehighlight()
void setCurrentBlockState(int newState)
void setCurrentBlockUserData(QTextBlockUserData *data)
void setDocument(QTextDocument *doc)
void setFormat(int start, int count, const QColor &color)
red
Key_Enter
ControlModifier
bool isValid() const const
QTextBlock next() const const
int position() const const
QTextBlockUserData * userData() const const
SingleUnderline
void setUnderlineColor(const QColor &color)
void setUnderlineStyle(UnderlineStyle style)
MoveAnchor
NextCharacter
WordUnderCursor
QTextBlock block() const const
void clearSelection()
bool hasSelection() const const
void insertText(const QString &text)
int position() const const
int positionInBlock() const const
int selectionEnd() const const
int selectionStart() const const
void setPosition(int pos, MoveMode m)
void contentsChange(int position, int charsRemoved, int charsAdded)
void setBackground(const QBrush &brush)
void setForeground(const QBrush &brush)
void setInterval(int msec)
void setSingleShot(bool singleShot)
void start()
void timeout()
This file is part of the KDE documentation.
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
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.