Sonnet.Highlighter

KDE 4.9 PyKDE API Reference

- KDE's Python API

# Highlighter Class Reference

`from PyKDE4.kdeui import *`

Inherits: QSyntaxHighlighter → QObject
Namespace: Sonnet

## Detailed Description

## Signals
| activeChanged (QString description)
| newSuggestions (QString originalWord, QStringList suggestions)
## Methods
| __init__ (self, QTextEdit textEdit, QString configFile=QString(), QColor col=QColor())
| __init__ (self, Sonnet.Highlighter a0)
| addWordToDictionary (self, QString word)
bool | automatic (self)
bool | checkerEnabledByDefault (self)
QString | currentLanguage (self)
bool | eventFilter (self, QObject o, QEvent e)
| highlightBlock (self, QString text)
| ignoreWord (self, QString word)
bool | intraWordEditing (self)
bool | isActive (self)
bool | isWordMisspelled (self, QString word)
| setActive (self, bool active)
| setAutomatic (self, bool automatic)
| setCurrentLanguage (self, QString lang)
| setIntraWordEditing (self, bool editing)
| setMisspelled (self, int start, int count)
| setMisspelledColor (self, QColor color)
| slotAutoDetection (self)
| slotRehighlight (self)
bool | spellCheckerFound (self)
QStringList | suggestionsForWord (self, QString word, int max=10)
| unsetMisspelled (self, int start, int count)
## Static Methods
QStringList | personalWords ()

## Signal Documentation

activeChanged | ( | QString | description
| ) |  |  |

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

Signal syntax:
  `QObject.connect(source, SIGNAL("activeChanged(const QString&)"), target_slot)`

newSuggestions | ( | QString | originalWord,
|  | QStringList | suggestions
| ) |  |  |

Parameters:

  | originalWord | missspelled word
  | suggestions | list of word which can replace missspelled word

Deprecated:
  use isWordMisspelled() and suggestionsForWord() instead.

Signal syntax:
  `QObject.connect(source, SIGNAL("newSuggestions(const QString&, const QStringList&)"), target_slot)`

## Method Documentation

__init__ | ( | self, |
|  | QTextEdit | textEdit,
|  | QString | configFile=QString(),
|  | QColor | col=QColor()
| ) |  |  |

__init__ | ( | self, |
|  | Sonnet.Highlighter | a0
| ) |  |  |

addWordToDictionary | ( | self, |
|  | QString | word
| ) |  |  |

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:
  4.1

bool automatic | ( |  | self ) |

bool checkerEnabledByDefault | ( |  | self ) |

Return true if checker is enabled by default

Since:
  4.5

QString currentLanguage | ( |  | self ) |

bool eventFilter | ( | self, |
|  | QObject | o,
|  | QEvent | e
| ) |  |  |

highlightBlock | ( | self, |
|  | QString | text
| ) |  |  |

ignoreWord | ( | self, |
|  | QString | word
| ) |  |  |

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:
  4.1

bool intraWordEditing | ( |  | self ) |

bool isActive | ( |  | self ) |

Returns the state of spell checking.

Returns:
  true if spell checking is active

See also:
  setActive()

bool isWordMisspelled | ( | self, |
|  | QString | word
| ) |  |  |

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:
  4.1

setActive | ( | self, |
|  | bool | active
| ) |  |  |

Enable/Disable spell checking.

If active is true then spell checking is enabled; otherwise it is disabled. Note that you have to disable automatic (de)activation with setAutomatic() before you change the state of spell checking if you want to persistently enable/disable spell checking.

Parameters:

  | active | if true, then spell checking is enabled

See also:
  isActive(), setAutomatic()

setAutomatic | ( | self, |
|  | bool | automatic
| ) |  |  |

setCurrentLanguage | ( | self, |
|  | QString | lang
| ) |  |  |

setIntraWordEditing | ( | self, |
|  | bool | editing
| ) |  |  |

setMisspelled | ( | self, |
|  | int | start,
|  | int | count
| ) |  |  |

setMisspelledColor | ( | self, |
|  | QColor | color
| ) |  |  |

Sets the color in which the highlighter underlines misspelled words.

Since:
  4.2

slotAutoDetection | ( |  | self ) |

slotRehighlight | ( |  | self ) |

bool spellCheckerFound | ( |  | self ) |

QStringList suggestionsForWord | ( | self, |
|  | QString | word,
|  | int | max=10
| ) |  |  |

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:
  4.1

unsetMisspelled | ( | self, |
|  | int | start,
|  | int | count
| ) |  |  |

## Static Method Documentation

QStringList personalWords | ( |  | ) |