class KSpell

# class KSpell | KDE Spellchecker More...
Definition | `#include <kspell.h>`
Inherits | QObject (qt) [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Types

- enum spellStatus { Starting = 0, Running, Cleaning, Finished, Error, Crashed }

#### Public Methods

- KSpell (QWidget *parent, const QString &caption, QObject *receiver, const char *slot, KSpellConfig *kcs=0, bool progressbar = TRUE, bool modal = FALSE )
- spellStatus status () const
- virtual void cleanUp ()
- void setAutoDelete (bool _autoDelete)
- virtual bool check (const QString &_buffer, bool usedialog = TRUE)
- int lastPosition () const
- virtual bool checkList (QStringList *_wordlist, bool usedialog = TRUE)
- virtual bool checkWord (const QString &_buffer, bool usedialog = FALSE)
- void hide ()
- QStringList suggestions () const
- int dlgResult () const
- void moveDlg (int x, int y)
- int heightDlg () const
- int widthDlg () const
- QString intermediateBuffer () const
- virtual bool ignore (const QString & word)
- virtual bool addPersonal (const QString & word)
- KSpellConfig ksConfig () const
- void setProgressResolution (unsigned res)
- virtual ~KSpell ()
- void setIgnoreUpperWords (bool b)
- void setIgnoreTitleCase (bool b)

#### Signals

- void misspelling (const QString & originalword, const QStringList & suggestions, unsigned int pos)
- void corrected (const QString & originalword, const QString & newword, unsigned int pos)
- void ignoreall (const QString & originalword)
- void ignoreword (const QString & originalword)
- void addword (const QString & originalword)
- void replaceall ( const QString & origword , const QString &replacement )
- void ready (KSpell *)
- void progress (unsigned int i)
- void done (const QString &buffer)
- void done (bool)
- void death ( )
- void dialog3 ()

#### Public Static Methods

- static int modalCheck ( QString& text )
- static int modalCheck ( QString& text, KSpellConfig * kcs )

#### Protected Methods

- 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 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 Members

- 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
- static QString modaltext
- static int modalreturn
- static QWidget* modalWidgetHack
- static 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.

See also: KSpellConfig

enum spellStatus { Starting = 0, Running, Cleaning, Finished, Error, Crashed } | ### spellStatus

Possible states of the spell checker.

- `Starting` - After creation of KSpell.
- `Running` - After the ready signal has been emitted.
- `Cleaning` - After cleanUp() has been called.
- `Finished` - After cleanUp() has been completed.

The following error states exist:

- `Error` - An error occurred in the `Starting` state.
- `Crashed` - An error occurred in the `Running` state.

KSpell (QWidget *parent, const QString &caption, QObject *receiver, const char *slot, KSpellConfig *kcs=0, bool progressbar = TRUE, bool modal = FALSE ) | ### KSpell

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.

Parameters:

parent | Parent of KSpellConfig dialog..
caption | Caption of KSpellConfig dialog.
receiver | Receiver object for the ready(KSpell *) signal.
slot | Receiver's slot, will be connected to the ready(KSpell *) signal.
kcs | Configuration for KSpell.
progressbar | Indicates if progress bar should be shown.
modal | Indicates modal or non-modal dialog.

spellStatus status () | ### status

[const]

Returns the status of KSpell.

See also: spellStatus()

void cleanUp () | ### cleanUp

[virtual]

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.

void setAutoDelete (bool _autoDelete) | ### setAutoDelete

Sets the auto-delete flag. If this is set, the KSpell object is automatically deleted after emitting death().

bool check (const QString &_buffer, bool usedialog = TRUE) | ### check

[virtual]

Spellchecks a buffer of many words in plain text format.

The `_buffer` is not modified. The signal done() will be sent when check() is finished and the argument will be a spell-corrected version of `_buffer`.

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 `_buffer` check() reached before stopping.

int lastPosition () | ### lastPosition

[const]

Returns the position (when using check()) or word number (when using checkList()) of the last word checked.

bool checkList (QStringList *_wordlist, bool usedialog = TRUE) | ### checkList

[virtual]

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.

bool checkWord (const QString &_buffer, bool usedialog = FALSE) | ### checkWord

[virtual]

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 `false` if `buffer` is not a single word (e.g. if it contains white space), otherwise it returns `true`;

If `usedialog` is set to `true`, KSpell will open the standard dialog if the word is not found. The dialog results can be queried by using dlgResult() and replacement().

The signal corrected() is emitted when the check is complete. You can look at suggestions() to see what the suggested replacements were.

void hide () | ### hide

Hides the dialog box.

You'll need to do this when you are done with checkWord();

QStringList suggestions () | ### suggestions

[const]

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).

int dlgResult () | ### dlgResult

[const]

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

- KS_CANCEL
- KS_REPLACE
- KS_REPLACEALL
- KS_IGNORE
- KS_IGNOREALL
- KS_ADD
- KS_STOP

void moveDlg (int x, int y) | ### moveDlg

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.

int heightDlg () | ### heightDlg

[const]

Returns the height of the dialog box.

int widthDlg () | ### widthDlg

[const]

Returns the width of the dialog box.

QString intermediateBuffer () | ### intermediateBuffer

[const]

Returns the partially spellchecked buffer.

You might want the full buffer in its partially-checked state.

bool ignore (const QString & word) | ### ignore

[virtual]

Tells ISpell/ASpell to ignore this word for the life of this KSpell instance.

Returns: false if `word` is not a word or there was an error communicating with ISpell/ASpell.

bool addPersonal (const QString & word) | ### addPersonal

[virtual]

Adds a word to the user's personal dictionary.

Returns: false if `word` is not a word or there was an error communicating with ISpell/ASpell.

KSpellConfig ksConfig () | ### ksConfig

[const]

Returns: the KSpellConfig object being used by this KSpell instance.

void setProgressResolution (unsigned res) | ### setProgressResolution

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%.

~KSpell () | ### ~KSpell

[virtual]

The destructor instructs ISpell/ASpell to write out the personal dictionary and then terminates ISpell/ASpell.

int modalCheck ( QString& text ) | ### modalCheck

[static]

Performs a synchronous spellcheck.

This method does not return until spellchecking is done or canceled. Your application's GUI will still be updated, however.

int modalCheck ( QString& text, KSpellConfig * kcs ) | ### modalCheck

[static]

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.

void setIgnoreUpperWords (bool b) | ### setIgnoreUpperWords

Call setIgnoreUpperWords(true) to tell the spell-checker to ignore words that are completely uppercase. They are spell-checked by default.

void setIgnoreTitleCase (bool b) | ### setIgnoreTitleCase

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.

void misspelling (const QString & originalword, const QStringList & suggestions, unsigned int pos) | ### misspelling

[signal]

Emitted whenever a misspelled word is found by check() or by checkWord(). If it is emitted by checkWord(), `pos`=0. If it is emitted by check(), then `pos` indicates the position of the misspelled word in the (original) `_buffer`. (The first position is zero.) If it is emitted by checkList(), `pos` is the index to the misspelled word in the QStringList passed to checkList(). Note, that `originalword` can be only a word part, if it's word with hyphens.

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).

void corrected (const QString & originalword, const QString & newword, unsigned int pos) | ### corrected

[signal]

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 `originalword` is the last replacement.

See also: check()

void ignoreall (const QString & originalword) | ### ignoreall

[signal]

Emitted when the user pressed "Ignore All" in the dialog. This could be used to make an application or file specific user dictionary.

void ignoreword (const QString & originalword) | ### ignoreword

[signal]

Emitted when the user pressed "Ignore" in the dialog. Don't know if this could be useful.

void addword (const QString & originalword) | ### addword

[signal]

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.

void replaceall ( const QString & origword , const QString &replacement ) | ### replaceall

[signal]

Emitted when the user pressed "ReplaceAll" in the dialog.

void ready (KSpell *) | ### ready

[signal]

Emitted after KSpell has verified that ISpell/ASpell is running and working properly.

void progress (unsigned int i) | ### progress

[signal]

Emitted during a check(). `i` is between 1 and 100.

void done (const QString &buffer) | ### done

[signal]

Emitted when check() is done.

Be sure to copy the results of `buffer` if you need them. You can only rely on the contents of buffer for the life of the slot which was signaled by done().

void done (bool) | ### done

[signal]

Emitted when checkList() is done.

If the argument is `true`, then you should update your text from the wordlist, otherwise not.

void death ( ) | ### death

[signal]

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:

- `Error` - KSpell could not start.
- `Crashed` - KSpell encountered an unexpected error during execution.
- `Finished` - Clean up finished.

void KSpell2 (KProcIO *) | ### KSpell2

[protected slots slot]

void checkWord2 (KProcIO *) | ### checkWord2

[protected slots slot]

void checkWord3 () | ### checkWord3

[protected slots slot]

void check2 (KProcIO *) | ### check2

[protected slots slot]

void checkList2 () | ### checkList2

[protected slots slot]

void checkList3a (KProcIO *) | ### checkList3a

[protected slots slot]

void checkListReplaceCurrent () | ### checkListReplaceCurrent

[protected slots slot]

void checkList4 () | ### checkList4

[protected slots slot]

void dialog2 (int dlgresult) | ### dialog2

[protected slots slot]

void check3 () | ### check3

[protected slots slot]

void slotStopCancel (int) | ### slotStopCancel

[protected slots slot]

void ispellExit (KProcess *) | ### ispellExit

[protected slots slot]

void emitDeath () | ### emitDeath

[protected slots slot]

void ispellErrors (KProcess *, char *, int) | ### ispellErrors

[protected slots slot]

void dialog3 () | ### dialog3

[signal]

KProcIO * proc | ### proc

[protected]

QWidget * parent | ### parent

[protected]

KSpellConfig * ksconfig | ### ksconfig

[protected]

KSpellDlg * ksdlg | ### ksdlg

[protected]

QStringList * wordlist | ### wordlist

[protected]

QStringList::Iterator wlIt | ### wlIt

[protected]

QStringList ignorelist | ### ignorelist

[protected]

QStringList replacelist | ### replacelist

[protected]

QStringList sugg | ### sugg

[protected]

QTextCodec* codec | ### codec

[protected]

spellStatus m_status | ### m_status

[protected]

bool usedialog | ### usedialog

[protected]

bool texmode | ### texmode

[protected]

bool dlgon | ### dlgon

[protected]

bool personaldict | ### personaldict

[protected]

bool dialogwillprocess | ### dialogwillprocess

[protected]

bool progressbar | ### progressbar

[protected]

bool dialogsetup | ### dialogsetup

[protected]

bool autoDelete | ### autoDelete

[protected]

QString caption | ### caption

[protected]

QString orig | ### orig

[protected]

QString origbuffer | ### origbuffer

[protected]

QString newbuffer | ### newbuffer

[protected]

QString cwword | ### cwword

[protected]

QString dlgorigword | ### dlgorigword

[protected]

QString dlgreplacement | ### dlgreplacement

[protected]

QString dialog3slot | ### dialog3slot

[protected]

int dlgresult | ### dlgresult

[protected]

int trystart | ### trystart

[protected]

int maxtrystart | ### maxtrystart

[protected]

int lastpos | ### lastpos

[protected]

unsigned int totalpos | ### totalpos

[protected]

unsigned int lastline | ### lastline

[protected]

unsigned int posinline | ### posinline

[protected]

unsigned int lastlastline | ### lastlastline

[protected]

unsigned int offset | ### offset

[protected]

unsigned int progres | ### progres

[protected]

unsigned int curprog | ### curprog

[protected]

bool modaldlg | ### modaldlg

[protected]

static QString modaltext | ### modaltext

[protected]

static int modalreturn | ### modalreturn

[protected]

static QWidget* modalWidgetHack | ### modalWidgetHack

[protected]

static QStringList modalListText | ### modalListText

[protected]

int parseOneResponse (const QString &_buffer, QString &word, QStringList &sugg) | ### parseOneResponse

[protected]

Used for modalCheck.

QString funnyWord (const QString & word) | ### funnyWord

[protected]

void dialog (const QString & word, QStringList & sugg, const char* _slot) | ### dialog

[protected]

QString replacement () | ### replacement

[protected const]

void setUpDialog ( bool reallyusedialogbox = TRUE) | ### setUpDialog

[protected]

void emitProgress () | ### emitProgress

[protected]

bool cleanFputs (const QString & s, bool appendCR=TRUE) | ### cleanFputs

[protected]

bool cleanFputsWord (const QString & s, bool appendCR=TRUE) | ### cleanFputsWord

[protected]

void startIspell () | ### startIspell

[protected]

bool writePersonalDictionary () | ### writePersonalDictionary

[protected]

- Version: $Id: kspell.h,v 1.42 2002/05/22 22:09:08 coolo Exp $
- Author: David Sweet
- Generated: root on macppc.ports.openbsd.org on Sat Sep 6 10:37:57 2003, using kdoc 2.0a54.