QtSpell  0.8.0
Spell checking for Qt text widgets
Public Slots | Signals | Public Member Functions | Static Public Member Functions | Private Member Functions | List of all members
QtSpell::Checker Class Referenceabstract

An abstract class providing spell checking support. More...

#include <QtSpell.hpp>

Inherits QObject.

Inherited by QtSpell::TextEditChecker.

Public Slots

void setSpellingEnabled (bool enabled)
 Set whether spell checking should be performed. More...
 

Signals

void languageChanged (const QString &newLang)
 This signal is emitted when the user selects a new language from the spellchecker UI. More...
 

Public Member Functions

 Checker (QObject *parent=0)
 QtSpell::Checker object constructor.
 
virtual ~Checker ()
 QtSpell::Checker object destructor.
 
virtual void checkSpelling (int start=0, int end=-1)=0
 Check the spelling. More...
 
bool setLanguage (const QString &lang)
 Set the spell checking language. More...
 
const QString & getLanguage () const
 Retreive the current spelling language. More...
 
void setDecodeLanguageCodes (bool decode)
 Set whether to decode language codes in the UI. More...
 
bool getDecodeLanguageCodes () const
 Return whether langauge codes are decoded in the UI. More...
 
void setShowCheckSpellingCheckbox (bool show)
 Set whether to display an "Check spelling" checkbox in the UI. More...
 
bool getShowCheckSpellingCheckbox () const
 Return whether a "Check spelling" checkbox is displayed in the UI. More...
 
bool getSpellingEnabled () const
 Return whether spellchecking is performed. More...
 
void addWordToDictionary (const QString &word)
 Add the specified word to the user dictionary. More...
 
bool checkWord (const QString &word) const
 Check the specified word. More...
 
void ignoreWord (const QString &word) const
 Ignore a word for the current session. More...
 
QList< QString > getSpellingSuggestions (const QString &word) const
 Retreive a list of spelling suggestions for the misspelled word. More...
 

Static Public Member Functions

static QList< QString > getLanguageList ()
 Requests the list of languages available for spell checking. More...
 
static QString decodeLanguageCode (const QString &lang)
 Translates a language code to a human readable format (i.e. "en_US" -> "English (United States)"). More...
 

Private Member Functions

virtual QString getWord (int pos, int *start=0, int *end=0) const =0
 Get the word at the specified cursor position. More...
 
virtual void insertWord (int start, int end, const QString &word)=0
 Replaces the specified range with the specified word. More...
 
virtual bool isAttached () const =0
 Returns whether a widget is attached to the checker. More...
 

Detailed Description

An abstract class providing spell checking support.

Definition at line 57 of file QtSpell.hpp.

Member Function Documentation

void QtSpell::Checker::addWordToDictionary ( const QString &  word)

Add the specified word to the user dictionary.

Parameters
wordThe word to add to the dictionary

Definition at line 119 of file Checker.cpp.

virtual void QtSpell::Checker::checkSpelling ( int  start = 0,
int  end = -1 
)
pure virtual

Check the spelling.

Parameters
startThe start position within the buffer.
endThe end position within the buffer (-1 for the buffer end).

Implemented in QtSpell::TextEditChecker.

Referenced by setLanguage().

bool QtSpell::Checker::checkWord ( const QString &  word) const

Check the specified word.

Parameters
wordA word.
Returns
Whether the word is correct.

Definition at line 126 of file Checker.cpp.

Referenced by QtSpell::TextEditChecker::checkSpelling().

QString QtSpell::Checker::decodeLanguageCode ( const QString &  lang)
static

Translates a language code to a human readable format (i.e. "en_US" -> "English (United States)").

Parameters
langThe language locale specifier.
Note
If the iso-codes package is unavailable, the unchanged code is returned.
Returns
The human readable language description.

Definition at line 169 of file Checker.cpp.

References QtSpell::Codetable::instance(), and QtSpell::Codetable::lookup().

bool QtSpell::Checker::getDecodeLanguageCodes ( ) const
inline

Return whether langauge codes are decoded in the UI.

Returns
Whether langauge codes are decoded in the UI.

Definition at line 103 of file QtSpell.hpp.

const QString& QtSpell::Checker::getLanguage ( ) const
inline

Retreive the current spelling language.

Returns
The current spelling language.

Definition at line 90 of file QtSpell.hpp.

QList< QString > QtSpell::Checker::getLanguageList ( )
static

Requests the list of languages available for spell checking.

Returns
A list of languages available for spell checking.

Definition at line 160 of file Checker.cpp.

bool QtSpell::Checker::getShowCheckSpellingCheckbox ( ) const
inline

Return whether a "Check spelling" checkbox is displayed in the UI.

Returns
Whether a "Check spelling" checkbox is displayed in the UI.

Definition at line 115 of file QtSpell.hpp.

bool QtSpell::Checker::getSpellingEnabled ( ) const
inline

Return whether spellchecking is performed.

Returns
Whether spellchecking is performed.

Definition at line 121 of file QtSpell.hpp.

QList< QString > QtSpell::Checker::getSpellingSuggestions ( const QString &  word) const

Retreive a list of spelling suggestions for the misspelled word.

Parameters
wordThe misspelled word.
Returns
A list of spelling suggestions.

Definition at line 147 of file Checker.cpp.

virtual QString QtSpell::Checker::getWord ( int  pos,
int *  start = 0,
int *  end = 0 
) const
privatepure virtual

Get the word at the specified cursor position.

Parameters
posThe cursor position.
startIf not 0, will contain the start position of the word.
endIf not 0, will contain the end position of the word.
Returns
The word.

Implemented in QtSpell::TextEditChecker.

void QtSpell::Checker::ignoreWord ( const QString &  word) const

Ignore a word for the current session.

Parameters
wordThe word to ignore.

Definition at line 142 of file Checker.cpp.

virtual void QtSpell::Checker::insertWord ( int  start,
int  end,
const QString &  word 
)
privatepure virtual

Replaces the specified range with the specified word.

Parameters
startThe start position.
endThe end position.
wordThe word to insert.

Implemented in QtSpell::TextEditChecker.

virtual bool QtSpell::Checker::isAttached ( ) const
privatepure virtual

Returns whether a widget is attached to the checker.

Returns
Whether a widget is attached to the checker.

Implemented in QtSpell::TextEditChecker.

Referenced by setLanguage().

void QtSpell::Checker::languageChanged ( const QString &  newLang)
signal

This signal is emitted when the user selects a new language from the spellchecker UI.

Parameters
newLangThe new language, as a locale specifier.
void QtSpell::Checker::setDecodeLanguageCodes ( bool  decode)
inline

Set whether to decode language codes in the UI.

Note
Requres the iso-codes package.
Parameters
decodeWhether to decode the language codes.

Definition at line 97 of file QtSpell.hpp.

bool QtSpell::Checker::setLanguage ( const QString &  lang)

Set the spell checking language.

Parameters
langThe language, as a locale specifier (i.e. "en_US"), or an empty string to attempt to use the system locale.
Returns
true on success, false on failure.

Definition at line 82 of file Checker.cpp.

References checkSpelling(), and isAttached().

void QtSpell::Checker::setShowCheckSpellingCheckbox ( bool  show)
inline

Set whether to display an "Check spelling" checkbox in the UI.

Parameters
showWhether to display an "Check spelling" checkbox in the UI.

Definition at line 109 of file QtSpell.hpp.

void QtSpell::Checker::setSpellingEnabled ( bool  enabled)
inlineslot

Set whether spell checking should be performed.

Parameters
enabledTrue if spell checking should be performed.

Definition at line 171 of file QtSpell.hpp.


The documentation for this class was generated from the following files: