Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

KSpell Class Reference

#include <kspell.h>

List of all members.

Public Types

enum  spellStatus

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

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)

Static Public Methods

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

Protected Attributes

bool modaldlg


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

enum KSpell::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.

Definition at line 63 of file kspell.h.

Referenced by status().


Constructor & Destructor Documentation

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

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.

virtual KSpell::~KSpell   [virtual]
 

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


Member Function Documentation

virtual bool KSpell::addPersonal const QString &    word [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.

void KSpell::addword const QString &    originalword [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.

virtual bool KSpell::check const QString &    _buffer,
bool    usedialog = TRUE
[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.

virtual bool KSpell::checkList QStringList *    _wordlist,
bool    usedialog = TRUE
[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.

virtual bool KSpell::checkWord const QString &    _buffer,
bool    usedialog = FALSE
[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.

virtual void KSpell::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 KSpell::corrected const QString &    originalword,
const QString &    newword,
unsigned int    pos
[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 KSpell::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.

int KSpell::dlgResult   const [inline]
 

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

Definition at line 200 of file kspell.h.

void KSpell::done bool    [signal]
 

Emitted when checkList() is done.

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

void KSpell::done const QString &    buffer [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().

int KSpell::heightDlg  
 

Returns the height of the dialog box.

void KSpell::hide  
 

Hides the dialog box.

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

virtual bool KSpell::ignore const QString &    word [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.

void KSpell::ignoreall const QString &    originalword [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 KSpell::ignoreword const QString &    originalword [signal]
 

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

QString KSpell::intermediateBuffer   const [inline]
 

Returns the partially spellchecked buffer.

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

Definition at line 227 of file kspell.h.

KSpellConfig KSpell::ksConfig  
 

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

int KSpell::lastPosition   const [inline]
 

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

Definition at line 128 of file kspell.h.

void KSpell::misspelling const QString &    originalword,
const QStringList &    suggestions,
unsigned int    pos
[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).

int KSpell::modalCheck QString &    text,
KSpellConfig   kcs
[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.

int KSpell::modalCheck QString &    text [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.

void KSpell::moveDlg int    x,
int    y
 

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.

void KSpell::progress unsigned int    i [signal]
 

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

void KSpell::ready KSpell *    [signal]
 

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

void KSpell::replaceall const QString &    origword,
const QString &    replacement
[signal]
 

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

void KSpell::setAutoDelete bool    _autoDelete [inline]
 

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

Definition at line 106 of file kspell.h.

void KSpell::setIgnoreTitleCase bool    b
 

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 KSpell::setIgnoreUpperWords bool    b
 

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

void KSpell::setProgressResolution unsigned    res
 

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

spellStatus KSpell::status   const [inline]
 

Returns the status of KSpell.

See also:
spellStatus()

Definition at line 91 of file kspell.h.

References spellStatus.

QStringList KSpell::suggestions   const [inline]
 

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

Definition at line 182 of file kspell.h.

int KSpell::widthDlg  
 

Returns the width of the dialog box.


Member Data Documentation

bool KSpell::modaldlg [protected]
 

Used for modalCheck.

Definition at line 497 of file kspell.h.


The documentation for this class was generated from the following file:
Generated on Wed Aug 13 23:30:25 2003 for kdelibs by doxygen1.2.18