lib Library API Documentation

KoSpell Class Reference

KDE Spellchecker. More...

#include <kospell.h>

Inheritance diagram for KoSpell:

QObject List of all members.

Public Types

enum  spellStatus {
  Starting = 0, Running, Cleaning, Finished,
  Error, Crashed
}
enum  Spelling {
  SpellingOk, SpellingIgnore, Misspelled, SpellingError,
  SpellingDone
}

Signals

void misspelling (const QString &originalword, int pos)
void ready (KoSpell *)
void done ()
void death ()
QStringList getAvailDictsAspell ()
QStringList getAvailDictsIspell ()

Public Member Functions

 KoSpell (QWidget *parent, QObject *receiver, const char *slot, KSpellConfig *kcs=0)
spellStatus status () const
virtual void cleanUp ()
virtual bool check (const QString &buffer)
Spelling parseLine (const QString &line, QString &word, int &pos)
virtual bool ignore (const QString &word)
virtual bool addPersonal (const QString &word)
KSpellConfig ksConfig () const
virtual ~KoSpell ()
void setIgnoreUpperWords (bool b)
void setIgnoreTitleCase (bool b)

Protected Slots

void KoSpell2 (KProcIO *)
void check2 (KProcIO *)
void ispellExit (KProcess *)
void emitDeath ()
void ispellErrors (KProcess *, char *, int)

Protected Member Functions

QString funnyWord (const QString &word)
void startIspell ()
bool writePersonalDictionary ()

Static Protected Member Functions

bool interpret (QString &fname, QString &lname, QString &hname)

Protected Attributes

QStringList m_buffer
QStringList ignorelist
int trystart
int maxtrystart
KProcIO * proc
QWidgetparent
KSpellConfig * ksconfig
QTextCodeccodec
spellStatus m_status

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>
See also:
KSpellConfig

Definition at line 42 of file kospell.h.


Member Enumeration Documentation

enum KoSpell::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 62 of file kospell.h.

Referenced by status().


Constructor & Destructor Documentation

KoSpell::KoSpell QWidget parent,
QObject receiver,
const char *  slot,
KSpellConfig *  kcs = 0
 

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.

Definition at line 68 of file kospell.cc.

References KoSpell(), and ready().

Referenced by KoSpell().

KoSpell::~KoSpell  )  [virtual]
 

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

Definition at line 501 of file kospell.cc.


Member Function Documentation

spellStatus KoSpell::status  )  const [inline]
 

Returns the status of KSpell.

See also:
spellStatus()

Definition at line 106 of file kospell.h.

References spellStatus.

void KoSpell::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.

Definition at line 514 of file kospell.cc.

bool KoSpell::check const QString buffer  )  [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.

Definition at line 396 of file kospell.cc.

References check().

Referenced by check().

bool KoSpell::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.

Definition at line 301 of file kospell.cc.

References ignore().

Referenced by ignore().

bool KoSpell::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.

Definition at line 282 of file kospell.cc.

References addPersonal().

Referenced by addPersonal().

KSpellConfig KoSpell::ksConfig  )  const
 

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

Definition at line 508 of file kospell.cc.

void KoSpell::setIgnoreUpperWords bool  b  ) 
 

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

They are spell-checked by default.

Definition at line 559 of file kospell.cc.

References setIgnoreUpperWords().

Referenced by setIgnoreUpperWords().

void KoSpell::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.

Definition at line 564 of file kospell.cc.

References setIgnoreTitleCase().

Referenced by setIgnoreTitleCase().

void KoSpell::misspelling const QString originalword,
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).

void KoSpell::ready KoSpell  )  [signal]
 

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

Referenced by KoSpell().

void KoSpell::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.


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Nov 17 06:54:22 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003