KSpell Class Reference
KDE Spellchecker. More...
#include <kspell.h>
Inheritance diagram for KSpell:

Public Types | |
enum | spellStatus { Starting = 0, Running, Cleaning, Finished, Error, Crashed } |
Possible states of the spell checker. More... | |
Signals | |
void | misspelling (const QString &originalword, const QStringList &suggestions, unsigned int pos) |
Emitted whenever a misspelled word is found by check() or by checkWord(). | |
void | corrected (const QString &originalword, const QString &newword, unsigned int pos) |
Emitted after the "Replace" or "Replace All" buttons of the dialog was pressed, or if the word was corrected without calling the dialog (i.e., the user previously chose "Replace All" for this word). | |
void | ignoreall (const QString &originalword) |
Emitted when the user pressed "Ignore All" in the dialog. | |
void | ignoreword (const QString &originalword) |
Emitted when the user pressed "Ignore" in the dialog. | |
void | addword (const QString &originalword) |
Emitted when the user pressed "Add" in the dialog. | |
void | replaceall (const QString &origword, const QString &replacement) |
Emitted when the user pressed "ReplaceAll" in the dialog. | |
void | ready (KSpell *) |
Emitted after KSpell has verified that ISpell/ASpell is running and working properly. | |
void | progress (unsigned int i) |
Emitted during a check(). | |
void | done (const QString &buffer) |
Emitted when check() is done. | |
void | done (bool) |
Emitted when checkList() is done. | |
void | death () |
Emitted on terminal errors and after clean up. | |
void | dialog3 () |
Public Member Functions | |
KSpell (QWidget *parent, const QString &caption, QObject *receiver, const char *slot, KSpellConfig *kcs=0, bool progressbar=TRUE, bool modal=FALSE) | |
Starts the spellchecker. | |
spellStatus | status () const |
Returns the status of KSpell. | |
virtual void | cleanUp () |
Cleans up ISpell. | |
void | setAutoDelete (bool _autoDelete) |
Sets the auto-delete flag. | |
virtual bool | check (const QString &_buffer, bool usedialog=TRUE) |
Spellchecks a buffer of many words in plain text format. | |
int | lastPosition () const |
Returns the position (when using check()) or word number (when using checkList()) of the last word checked. | |
virtual bool | checkList (QStringList *_wordlist, bool usedialog=TRUE) |
Spellchecks a list of words. | |
virtual bool | checkWord (const QString &_buffer, bool usedialog=FALSE) |
Spellchecks a single word. | |
void | hide () |
Hides the dialog box. | |
QStringList | suggestions () const |
Returns list of suggested word replacements. | |
int | dlgResult () const |
Gets the result code of the dialog box. | |
void | moveDlg (int x, int y) |
Moves the dialog. | |
int | heightDlg () const |
Returns the height of the dialog box. | |
int | widthDlg () const |
Returns the width of the dialog box. | |
QString | intermediateBuffer () const |
Returns the partially spellchecked buffer. | |
virtual bool | ignore (const QString &word) |
Tells ISpell/ASpell to ignore this word for the life of this KSpell instance. | |
virtual bool | addPersonal (const QString &word) |
Adds a word to the user's personal dictionary. | |
KSpellConfig | ksConfig () const |
void | setProgressResolution (unsigned res) |
Sets the resolution (in percent) of the progress() signals. | |
virtual | ~KSpell () |
The destructor instructs ISpell/ASpell to write out the personal dictionary and then terminates ISpell/ASpell. | |
void | setIgnoreUpperWords (bool b) |
Call setIgnoreUpperWords(true) to tell the spell-checker to ignore words that are completely uppercase. | |
void | setIgnoreTitleCase (bool b) |
Call setIgnoreTitleCase(true) to tell the spell-checker to ignore words with a 'title' case, i.e. | |
Static Public Member Functions | |
int | modalCheck (QString &text) |
Performs a synchronous spellcheck. | |
int | modalCheck (QString &text, KSpellConfig *kcs) |
Performs a synchronous spellcheck. | |
Protected Slots | |
void | KSpell2 (KProcIO *) |
void | checkWord2 (KProcIO *) |
void | checkWord3 () |
void | check2 (KProcIO *) |
void | checkList2 () |
void | checkList3a (KProcIO *) |
void | checkListReplaceCurrent () |
void | checkList4 () |
void | dialog2 (int dlgresult) |
void | check3 () |
void | slotStopCancel (int) |
void | ispellExit (KProcess *) |
void | emitDeath () |
void | ispellErrors (KProcess *, char *, int) |
Protected Member Functions | |
int | parseOneResponse (const QString &_buffer, QString &word, QStringList &sugg) |
QString | funnyWord (const QString &word) |
void | dialog (const QString &word, QStringList &sugg, const char *_slot) |
QString | replacement () const |
void | setUpDialog (bool reallyusedialogbox=TRUE) |
void | emitProgress () |
bool | cleanFputs (const QString &s, bool appendCR=TRUE) |
bool | cleanFputsWord (const QString &s, bool appendCR=TRUE) |
void | startIspell () |
bool | writePersonalDictionary () |
Protected Attributes | |
KProcIO * | proc |
QWidget * | parent |
KSpellConfig * | ksconfig |
KSpellDlg * | ksdlg |
QStringList * | wordlist |
QStringList::Iterator | wlIt |
QStringList | ignorelist |
QStringList | replacelist |
QStringList | sugg |
QTextCodec * | codec |
spellStatus | m_status |
bool | usedialog |
bool | texmode |
bool | dlgon |
bool | personaldict |
bool | dialogwillprocess |
bool | progressbar |
bool | dialogsetup |
bool | autoDelete |
QString | caption |
QString | orig |
QString | origbuffer |
QString | newbuffer |
QString | cwword |
QString | dlgorigword |
QString | dlgreplacement |
QString | dialog3slot |
int | dlgresult |
int | trystart |
int | maxtrystart |
int | lastpos |
unsigned int | totalpos |
unsigned int | lastline |
unsigned int | posinline |
unsigned int | lastlastline |
unsigned int | offset |
unsigned int | progres |
unsigned int | curprog |
bool | modaldlg |
Used for modalCheck. | |
Static Protected Attributes | |
QString | modaltext |
int | modalreturn = 0 |
QWidget * | modalWidgetHack = 0 |
QStringList | modalListText |
Detailed Description
KDE Spellchecker.A KDE programmer's interface to International ISpell 3.1. (GPL 1997) A static method, modalCheck() is provided for convenient access to the spellchecker.
- Author:
- David Sweet <dsweet@kde.org>
- Version:
- Id
- kspell.h,v 1.42 2002/05/22 22:09:08 coolo Exp
- See also:
- KSpellConfig
Definition at line 44 of file kspell.h.
Member Enumeration Documentation
|
Possible states of the spell checker.
Definition at line 63 of file kspell.h. Referenced by status(). |
Constructor & Destructor Documentation
|
Starts the spellchecker. KSpell emits ready() when it has verified that ISpell/ASpell is working properly. Pass the name of a slot -- do not pass zero! Be sure to call cleanUp() when you are done with KSpell. If KSpell could not be started correctly, death() is emitted.
Definition at line 88 of file kspell.cpp. References QTextCodec::codecForName(), QObject::connect(), KSpellConfig::encoding(), KSpellConfig::ignoreList(), modaldlg, QTextCodec::name(), ready(), and KSpellConfig::replaceAllList(). Referenced by modalCheck(). |
|
The destructor instructs ISpell/ASpell to write out the personal dictionary and then terminates ISpell/ASpell.
Definition at line 1135 of file kspell.cpp. |
Member Function Documentation
|
Returns the status of KSpell.
Definition at line 91 of file kspell.h. References spellStatus. Referenced by modalCheck(). |
|
Cleans up ISpell. Write out the personal dictionary and close ISpell's stdin. A death() signal will be emitted when the cleanup is complete, but this method will return immediately. Definition at line 1157 of file kspell.cpp. References KProcess::closeStdin(). |
|
Sets the auto-delete flag. If this is set, the KSpell object is automatically deleted after emitting death(). |
|
Spellchecks a buffer of many words in plain text format.
The
The spell check may be stopped by the user before the entire buffer has been checked. You can check lastPosition() to see how far in Definition at line 868 of file kspell.cpp. References QString::at(), done(), KProcIO::fputs(), QString::length(), QString::mid(), and QString::right(). |
|
Returns the position (when using check()) or word number (when using checkList()) of the last word checked.
|
|
Spellchecks a list of words. checkList() is more flexible than check(). You could parse any type of document (HTML, TeX, etc.) into a list of spell-checkable words and send the list to checkList(). Sending a marked-up document to check() would result in the mark-up tags being spell checked. Definition at line 689 of file kspell.cpp. References KProcIO::fputs(). |
|
Spellchecks a single word. checkWord() is the most flexible function. Some applications might need this flexibility but will sacrifice speed when checking large numbers of words. Consider checkList() for checking many words. Use this method for implementing "online" spellchecking (i.e., spellcheck as-you-type).
checkWord() returns
If The signal corrected() is emitted when the check is complete. You can look at suggestions() to see what the suggested replacements were. Definition at line 487 of file kspell.cpp. References QString::find(), KProcIO::fputs(), QString::isEmpty(), and QString::simplifyWhiteSpace(). |
|
Hides the dialog box. You'll need to do this when you are done with checkWord(); Definition at line 198 of file kspell.cpp. |
|
Returns list of suggested word replacements. After calling checkWord() (an in response to a misspelled() signal you can use this to get the list of suggestions (if any were available). |
|
Gets the result code of the dialog box. After calling checkWord, you can use this to get the dialog box's result code. The possible values are (from kspelldlg.h):
|
|
Moves the dialog. If the dialog is not currently visible, it will be placed at this position when it becomes visible. Use this to get the dialog out of the way of a highlighted misspelled word in a document. Definition at line 1220 of file kspell.cpp. References QWidget::mapToGlobal(), QPoint::x(), and QPoint::y(). |
|
Returns the height of the dialog box.
Definition at line 200 of file kspell.cpp. |
|
Returns the width of the dialog box.
Definition at line 201 of file kspell.cpp. |
|
Returns the partially spellchecked buffer. You might want the full buffer in its partially-checked state. |
|
Tells ISpell/ASpell to ignore this word for the life of this KSpell instance.
Definition at line 424 of file kspell.cpp. References QString::find(), KProcIO::fputs(), QString::isEmpty(), QString::prepend(), and QString::simplifyWhiteSpace(). |
|
Adds a word to the user's personal dictionary.
Definition at line 405 of file kspell.cpp. References QString::find(), KProcIO::fputs(), QString::isEmpty(), QString::prepend(), and QString::simplifyWhiteSpace(). |
|
Definition at line 1150 of file kspell.cpp. References KSpellConfig::setIgnoreList(), and KSpellConfig::setReplaceAllList(). |
|
Sets the resolution (in percent) of the progress() signals. E.g. setProgressResolution (10) instructs KSpell to send progress signals (at most) every 10% (10%, 20%, 30%...). The default is 10%. |
|
Performs a synchronous spellcheck. This method does not return until spellchecking is done or canceled. Your application's GUI will still be updated, however. Definition at line 1244 of file kspell.cpp. |
|
Performs a synchronous spellcheck. This method does not return until spellchecking is done or canceled. Your application's GUI will still be updated, however. This overloaded method uses the spell-check configuration passed as parameter. Definition at line 1250 of file kspell.cpp. |
|
Call setIgnoreUpperWords(true) to tell the spell-checker to ignore words that are completely uppercase. They are spell-checked by default. Definition at line 1227 of file kspell.cpp. |
|
Call setIgnoreTitleCase(true) to tell the spell-checker to ignore words with a 'title' case, i.e. starting with an uppercase letter. They are spell-checked by default. Definition at line 1232 of file kspell.cpp. |
|
Emitted whenever a misspelled word is found by check() or by checkWord().
If it is emitted by checkWord(), These are called _before_ the dialog is opened, so that the calling program's GUI may be updated. (e.g. the misspelled word may be highlighted). |
|
Emitted after the "Replace" or "Replace All" buttons of the dialog was pressed, or if the word was corrected without calling the dialog (i.e., the user previously chose "Replace All" for this word). Results from the dialog may be checked with dlgResult() and replacement().
Note, that when using checkList() this signal can occur more then once with same list position, when checking a word with hyphens. In this case
|
|
Emitted when the user pressed "Ignore All" in the dialog. This could be used to make an application or file specific user dictionary. |
|
Emitted when the user pressed "Ignore" in the dialog. Don't know if this could be useful. |
|
Emitted when the user pressed "Add" in the dialog. This could be used to make an external user dictionary independent of the ISpell personal dictionary. |
|
Emitted when the user pressed "ReplaceAll" in the dialog.
|
|
Emitted after KSpell has verified that ISpell/ASpell is running and working properly.
Referenced by KSpell(). |
|
Emitted during a check().
|
|
Emitted when check() is done.
Be sure to copy the results of Referenced by check(). |
|
Emitted when checkList() is done.
If the argument is |
|
Emitted on terminal errors and after clean up. You can delete the KSpell object in this signal. You can check status() to see what caused the death:
|
Member Data Documentation
|
Used for modalCheck.
Definition at line 497 of file kspell.h. Referenced by KSpell(). |
The documentation for this class was generated from the following files: