KDE3Support
K3Spell Class Reference
KDE Spellchecker More...
#include <k3spell.h>

Public Types | |
enum | SpellerType { Text = 0, HTML, TeX, Nroff } |
enum | spellStatus { Starting = 0, Running, Cleaning, Finished, Error, Crashed, FinishedNoMisspellingsEncountered } |
Signals | |
void | addword (const QString &originalword) |
void | corrected (const QString &originalword, const QString &newword, unsigned int pos) |
void | death () |
void | dialog3 () |
void | done (bool) |
void | done (const QString &buffer) |
void | ignoreall (const QString &originalword) |
void | ignoreword (const QString &originalword) |
void | misspelling (const QString &originalword, const QStringList &suggestions, unsigned int pos) |
void | progress (unsigned int i) |
void | ready (K3Spell *) |
void | replaceall (const QString &origword, const QString &replacement) |
Public Member Functions | |
virtual bool | addPersonal (const QString &word) |
virtual bool | check (const QString &_buffer, bool usedialog=true) |
virtual bool | checkList (QStringList *_wordlist, bool usedialog=true) |
bool | checkWord (const QString &buffer, bool _usedialog, bool suggest) |
virtual bool | checkWord (const QString &_buffer, bool usedialog=false) |
virtual void | cleanUp () |
int | dlgResult () const |
int | heightDlg () const |
void | hide () |
virtual bool | ignore (const QString &word) |
QString | intermediateBuffer () const |
K3Spell (QWidget *parent, const QString &caption, QObject *receiver, const char *slot, K3SpellConfig *kcs, bool progressbar, bool modal, SpellerType type) | |
K3Spell (QWidget *parent, const QString &caption, QObject *receiver, const char *slot, K3SpellConfig *kcs=0, bool progressbar=true, bool modal=false) | |
K3SpellConfig | ksConfig () const |
int | lastPosition () const |
void | moveDlg (int x, int y) |
void | setAutoDelete (bool _autoDelete) |
void | setIgnoreTitleCase (bool b) |
void | setIgnoreUpperWords (bool b) |
void | setProgressResolution (unsigned int res) |
spellStatus | status () const |
QStringList | suggestions () const |
int | widthDlg () const |
virtual | ~K3Spell () |
Static Public Member Functions | |
static int | modalCheck (QString &text, K3SpellConfig *kcs) |
static KDE_DEPRECATED int | modalCheck (QString &text) |
Protected Slots | |
void | check2 () |
void | check3 () |
void | checkList2 () |
void | checkList3a () |
void | checkList4 () |
void | checkListReplaceCurrent () |
void | checkNext () |
void | checkWord2 () |
void | checkWord3 () |
void | dialog2 (int dlgresult) |
void | emitDeath () |
void | ispellErrors () |
void | ispellExit () |
void | K3Spell2 () |
void | slotStopCancel (int) |
void | suggestWord () |
Protected Member Functions | |
bool | cleanFputs (const QString &s) |
bool | cleanFputsWord (const QString &s) |
void | dialog (const QString &word, QStringList &sugg, const char *_slot) |
void | emitProgress () |
QString | funnyWord (const QString &word) |
void | initialize (QWidget *_parent, const QString &_caption, QObject *obj, const char *slot, K3SpellConfig *_ksc, bool _progressbar, bool _modal, SpellerType type) |
int | parseOneResponse (const QString &_buffer, QString &word, QStringList &sugg) |
QString | replacement () const |
void | setUpDialog (bool reallyusedialogbox=true) |
void | startIspell () |
bool | writePersonalDictionary () |
Protected Attributes | |
bool | autoDelete |
QString | caption |
unsigned int | curprog |
QString | cwword |
QString | dialog3slot |
bool | dialogsetup |
bool | dialogwillprocess |
bool | dlgon |
QString | dlgorigword |
QString | dlgreplacement |
int | dlgresult |
QStringList | ignorelist |
K3SpellConfig * | ksconfig |
K3SpellDlg * | ksdlg |
unsigned int | lastlastline |
int | lastline |
int | lastpos |
spellStatus | m_status |
int | maxtrystart |
bool | modaldlg |
QString | newbuffer |
unsigned int | offset |
QString | orig |
QString | origbuffer |
QWidget * | parent |
bool | personaldict |
unsigned int | posinline |
KProcess * | proc |
unsigned int | progres |
bool | progressbar |
QStringList | replacelist |
QStringList | sugg |
bool | texmode |
unsigned int | totalpos |
int | trystart |
bool | usedialog |
QStringList::Iterator | wlIt |
QStringList * | wordlist |
Static Protected Attributes | |
static int | modalreturn = 0 |
static QString | modaltext |
static QWidget * | modalWidgetHack = 0 |
Detailed Description
KDE SpellcheckerA KDE programmer's interface to International ISpell 3.1, ASpell, HSpell and ZPSpell.. A static method, modalCheck() is provided for convenient access to the spellchecker.
- See also:
- K3SpellConfig, KSyntaxHighlighter
- Deprecated:
- , use sonnet instead
Definition at line 46 of file k3spell.h.
Member Enumeration Documentation
enum K3Spell::SpellerType |
These are possible types of documents which the spell checker can check.
Text
- The default type, checks every wordHTML
- For HTML/SGML/XML documents, will skip the tags,TeX
- For TeX/LaTeX documents, will skip commands,Nroff
- For nroff/troff documents.
enum K3Spell::spellStatus |
Possible states of the spell checker.
Starting
- After creation of K3Spell.Running
- After the ready signal has been emitted.Cleaning
- After cleanUp() has been called.Finished
- After cleanUp() has been completed.
Error
- An error occurred in theStarting
state.Crashed
- An error occurred in theRunning
state.
Constructor & Destructor Documentation
K3Spell::K3Spell | ( | QWidget * | parent, | |
const QString & | caption, | |||
QObject * | receiver, | |||
const char * | slot, | |||
K3SpellConfig * | kcs = 0 , |
|||
bool | progressbar = true , |
|||
bool | modal = false | |||
) |
Starts the spellchecker.
K3Spell 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 K3Spell.
If K3Spell could not be started correctly, death() is emitted.
- Parameters:
-
parent Parent of K3SpellConfig dialog.. caption Caption of K3SpellConfig dialog. receiver Receiver object for the ready(K3Spell *) signal. slot Receiver's slot, will be connected to the ready(K3Spell *) signal. kcs Configuration for K3Spell. progressbar Indicates if progress bar should be shown. modal Indicates modal or non-modal dialog.
Definition at line 124 of file k3spell.cpp.
K3Spell::K3Spell | ( | QWidget * | parent, | |
const QString & | caption, | |||
QObject * | receiver, | |||
const char * | slot, | |||
K3SpellConfig * | kcs, | |||
bool | progressbar, | |||
bool | modal, | |||
SpellerType | type | |||
) |
Starts the spellchecker.
K3Spell 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 K3Spell.
If K3Spell could not be started correctly, death() is emitted.
- Parameters:
-
parent Parent of K3SpellConfig dialog.. caption Caption of K3SpellConfig dialog. receiver Receiver object for the ready(K3Spell *) signal. slot Receiver's slot, will be connected to the ready(K3Spell *) signal. kcs Configuration for K3Spell. progressbar Indicates if progress bar should be shown. modal Indicates modal or non-modal dialog. type Type of the document to check
Definition at line 132 of file k3spell.cpp.
K3Spell::~K3Spell | ( | ) | [virtual] |
The destructor instructs ISpell/ASpell to write out the personal dictionary and then terminates ISpell/ASpell.
Definition at line 1345 of file k3spell.cpp.
Member Function Documentation
bool K3Spell::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 430 of file k3spell.cpp.
void K3Spell::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.
bool K3Spell::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.
Definition at line 1023 of file k3spell.cpp.
void K3Spell::check2 | ( | ) | [protected, slot] |
Definition at line 1088 of file k3spell.cpp.
void K3Spell::check3 | ( | ) | [protected, slot] |
Definition at line 1207 of file k3spell.cpp.
bool K3Spell::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.
Definition at line 827 of file k3spell.cpp.
void K3Spell::checkList2 | ( | ) | [protected, slot] |
Definition at line 854 of file k3spell.cpp.
void K3Spell::checkList3a | ( | ) | [protected, slot] |
Definition at line 885 of file k3spell.cpp.
void K3Spell::checkList4 | ( | ) | [protected, slot] |
Definition at line 974 of file k3spell.cpp.
void K3Spell::checkListReplaceCurrent | ( | ) | [protected, slot] |
Definition at line 959 of file k3spell.cpp.
void K3Spell::checkNext | ( | ) | [protected, slot] |
Definition at line 644 of file k3spell.cpp.
bool K3Spell::checkWord | ( | const QString & | buffer, | |
bool | _usedialog, | |||
bool | suggest | |||
) |
bool K3Spell::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
, K3Spell 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.
set the dialog signal handler
Definition at line 512 of file k3spell.cpp.
void K3Spell::checkWord2 | ( | ) | [protected, slot] |
Definition at line 602 of file k3spell.cpp.
void K3Spell::checkWord3 | ( | ) | [protected, slot] |
Definition at line 682 of file k3spell.cpp.
bool K3Spell::cleanFputs | ( | const QString & | s | ) | [protected] |
Definition at line 490 of file k3spell.cpp.
bool K3Spell::cleanFputsWord | ( | const QString & | s | ) | [protected] |
Definition at line 463 of file k3spell.cpp.
void K3Spell::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 1362 of file k3spell.cpp.
void K3Spell::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 than once with same list position, when checking a word with hyphens. In this case originalword
is the last replacement.
- See also:
- check()
void K3Spell::death | ( | ) | [signal] |
void K3Spell::dialog | ( | const QString & | word, | |
QStringList & | sugg, | |||
const char * | _slot | |||
) | [protected] |
Definition at line 1263 of file k3spell.cpp.
void K3Spell::dialog2 | ( | int | dlgresult | ) | [protected, slot] |
Definition at line 1297 of file k3spell.cpp.
void K3Spell::dialog3 | ( | ) | [signal] |
int K3Spell::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
Definition at line 152 of file k3spell.cpp.
void K3Spell::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 K3Spell::done | ( | const QString & | buffer | ) | [signal] |
void K3Spell::emitDeath | ( | ) | [protected, slot] |
Definition at line 1408 of file k3spell.cpp.
void K3Spell::emitProgress | ( | ) | [protected] |
Definition at line 1421 of file k3spell.cpp.
Definition at line 689 of file k3spell.cpp.
int K3Spell::heightDlg | ( | ) | const |
void K3Spell::hide | ( | ) |
Hides the dialog box.
You'll need to do this when you are done with checkWord();
Definition at line 145 of file k3spell.cpp.
bool K3Spell::ignore | ( | const QString & | word | ) | [virtual] |
Tells ISpell/ASpell to ignore this word for the life of this K3Spell instance.
- Returns:
- false if
word
is not a word or there was an error communicating with ISpell/ASpell.
Definition at line 449 of file k3spell.cpp.
void K3Spell::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 K3Spell::ignoreword | ( | const QString & | originalword | ) | [signal] |
Emitted when the user pressed "Ignore" in the dialog.
Don't know if this could be useful.
void K3Spell::initialize | ( | QWidget * | _parent, | |
const QString & | _caption, | |||
QObject * | obj, | |||
const char * | slot, | |||
K3SpellConfig * | _ksc, | |||
bool | _progressbar, | |||
bool | _modal, | |||
SpellerType | type | |||
) | [protected] |
Definition at line 1518 of file k3spell.cpp.
QString K3Spell::intermediateBuffer | ( | ) | const |
Returns the partially spellchecked buffer.
You might want the full buffer in its partially-checked state.
Definition at line 160 of file k3spell.cpp.
void K3Spell::ispellErrors | ( | ) | [protected, slot] |
Definition at line 357 of file k3spell.cpp.
void K3Spell::ispellExit | ( | ) | [protected, slot] |
Definition at line 1381 of file k3spell.cpp.
void K3Spell::K3Spell2 | ( | ) | [protected, slot] |
Definition at line 363 of file k3spell.cpp.
K3SpellConfig K3Spell::ksConfig | ( | ) | const |
- Returns:
- the K3SpellConfig object being used by this K3Spell instance.
Definition at line 1355 of file k3spell.cpp.
int K3Spell::lastPosition | ( | ) | const |
Returns the position (when using check()) or word number (when using checkList()) of the last word checked.
Definition at line 1082 of file k3spell.cpp.
void K3Spell::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 K3Spell::modalCheck | ( | QString & | text, | |
K3SpellConfig * | 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.
Definition at line 1462 of file k3spell.cpp.
int K3Spell::modalCheck | ( | QString & | text | ) | [static] |
- Deprecated:
- Performs a synchronous spellcheck.
Definition at line 1456 of file k3spell.cpp.
void K3Spell::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.
Definition at line 1432 of file k3spell.cpp.
int K3Spell::parseOneResponse | ( | const QString & | _buffer, | |
QString & | word, | |||
QStringList & | sugg | |||
) | [protected] |
Definition at line 724 of file k3spell.cpp.
void K3Spell::progress | ( | unsigned int | i | ) | [signal] |
Emitted during a check().
i
is between 1 and 100.
void K3Spell::ready | ( | K3Spell * | ) | [signal] |
Emitted after K3Spell has verified that ISpell/ASpell is running and working properly.
Emitted when the user pressed "ReplaceAll" in the dialog.
QString K3Spell::replacement | ( | ) | const [protected] |
Definition at line 1292 of file k3spell.cpp.
void K3Spell::setAutoDelete | ( | bool | _autoDelete | ) |
Sets the auto-delete flag.
If this is set, the K3Spell object is automatically deleted after emitting death().
Definition at line 1376 of file k3spell.cpp.
void K3Spell::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 1444 of file k3spell.cpp.
void K3Spell::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 1439 of file k3spell.cpp.
void K3Spell::setProgressResolution | ( | unsigned int | res | ) |
Sets the resolution (in percent) of the progress() signals.
E.g. setProgressResolution (10) instructs K3Spell to send progress signals (at most) every 10% (10%, 20%, 30%...). The default is 10%.
Definition at line 1416 of file k3spell.cpp.
void K3Spell::setUpDialog | ( | bool | reallyusedialogbox = true |
) | [protected] |
Definition at line 411 of file k3spell.cpp.
void K3Spell::slotStopCancel | ( | int | result | ) | [protected, slot] |
Definition at line 1246 of file k3spell.cpp.
void K3Spell::startIspell | ( | ) | [protected] |
Definition at line 191 of file k3spell.cpp.
K3Spell::spellStatus K3Spell::status | ( | ) | const |
QStringList K3Spell::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).
Definition at line 147 of file k3spell.cpp.
void K3Spell::suggestWord | ( | ) | [protected, slot] |
Definition at line 659 of file k3spell.cpp.
int K3Spell::widthDlg | ( | ) | const |
bool K3Spell::writePersonalDictionary | ( | ) | [protected] |
Definition at line 444 of file k3spell.cpp.
Member Data Documentation
bool K3Spell::autoDelete [protected] |
QString K3Spell::caption [protected] |
unsigned int K3Spell::curprog [protected] |
QString K3Spell::cwword [protected] |
QString K3Spell::dialog3slot [protected] |
bool K3Spell::dialogsetup [protected] |
bool K3Spell::dialogwillprocess [protected] |
bool K3Spell::dlgon [protected] |
QString K3Spell::dlgorigword [protected] |
QString K3Spell::dlgreplacement [protected] |
int K3Spell::dlgresult [protected] |
QStringList K3Spell::ignorelist [protected] |
K3SpellConfig* K3Spell::ksconfig [protected] |
K3SpellDlg* K3Spell::ksdlg [protected] |
unsigned int K3Spell::lastlastline [protected] |
int K3Spell::lastline [protected] |
int K3Spell::lastpos [protected] |
spellStatus K3Spell::m_status [protected] |
int K3Spell::maxtrystart [protected] |
bool K3Spell::modaldlg [protected] |
int K3Spell::modalreturn = 0 [static, protected] |
QString K3Spell::modaltext [static, protected] |
QWidget * K3Spell::modalWidgetHack = 0 [static, protected] |
QString K3Spell::newbuffer [protected] |
unsigned int K3Spell::offset [protected] |
QString K3Spell::orig [protected] |
QString K3Spell::origbuffer [protected] |
QWidget* K3Spell::parent [protected] |
bool K3Spell::personaldict [protected] |
unsigned int K3Spell::posinline [protected] |
KProcess* K3Spell::proc [protected] |
unsigned int K3Spell::progres [protected] |
bool K3Spell::progressbar [protected] |
QStringList K3Spell::replacelist [protected] |
QStringList K3Spell::sugg [protected] |
bool K3Spell::texmode [protected] |
unsigned int K3Spell::totalpos [protected] |
int K3Spell::trystart [protected] |
bool K3Spell::usedialog [protected] |
QStringList::Iterator K3Spell::wlIt [protected] |
QStringList* K3Spell::wordlist [protected] |
The documentation for this class was generated from the following files: