kspell.h
/* This file is part of the KDE libraries
Copyright (C) 1997 David Sweet <dsweet@kde.org>
Copyright (C) 2003 Zack Rusin <zack@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __KSPELL_H__
#define __KSPELL_H__
#include "ksconfig.h"
#include <qobject.h>
#include <qstringlist.h>
#include <qstring.h>
#include <kdelibs_export.h>
class QTextCodec;
class KProcIO;
class KProcess;
class KSpellDlg;
class KDEUI_EXPORT KSpell : public QObject
{
Q_OBJECT
public:
enum spellStatus { Starting = 0, Running, Cleaning, Finished, Error, Crashed, FinishedNoMisspellingsEncountered };
enum SpellerType { Text = 0, HTML, TeX, Nroff };
KSpell(QWidget *parent, const QString &caption,
QObject *receiver, const char *slot, KSpellConfig *kcs=0,
bool progressbar = true, bool modal = false);
KSpell(QWidget *parent, const QString &caption,
QObject *receiver, const char *slot, KSpellConfig *kcs,
bool progressbar, bool modal, SpellerType type);
spellStatus status() const { return m_status; }
virtual void cleanUp ();
void setAutoDelete(bool _autoDelete) { autoDelete = _autoDelete; }
virtual bool check (const QString &_buffer, bool usedialog = true);
int lastPosition() const
{ return lastpos;}
virtual bool checkList (QStringList *_wordlist, bool usedialog = true);
virtual bool checkWord (const QString &_buffer, bool usedialog = false);
bool checkWord( const QString & buffer, bool _usedialog, bool suggest );
void hide ();
QStringList suggestions () const { return sugg; }
int dlgResult () const
{ return dlgresult; }
void moveDlg (int x, int y);
int heightDlg () const;
int widthDlg () const;
QString intermediateBuffer () const {return newbuffer;}
virtual bool ignore (const QString & word);
virtual bool addPersonal (const QString & word);
KSpellConfig ksConfig () const;
void setProgressResolution (unsigned int res);
virtual ~KSpell();
static int modalCheck( QString& text ) KDE_DEPRECATED;
static int modalCheck( QString& text, KSpellConfig * kcs );
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( );
protected slots:
/* All of those signals from KProcIO get sent here. */
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 suggestWord( KProcIO * );
void slotStopCancel (int);
void ispellExit (KProcess *);
void emitDeath();
void ispellErrors (KProcess *, char *, int);
void checkNext();
private slots:
void slotModalReady();
void slotModalDone( const QString & );
void slotSpellCheckerCorrected( const QString & oldText, const QString & newText, unsigned int );
void slotModalSpellCheckerFinished( );
signals:
void dialog3 ();
protected:
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;
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
{ return dlgreplacement; }
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();
void initialize( QWidget *_parent, const QString &_caption,
QObject *obj, const char *slot, KSpellConfig *_ksc,
bool _progressbar, bool _modal, SpellerType type );
private:
class KSpellPrivate;
KSpellPrivate *d;
};
#endif
KSpell::SpellerType
SpellerType
These are possible types of documents which the spell checker can check.
Definition: kspell.h:80
KSpell::dlgResult
int dlgResult() const
Gets the result code of the dialog box.
Definition: kspell.h:240
KProcess
KSpell::suggestions
QStringList suggestions() const
Returns list of suggested word replacements.
Definition: kspell.h:222
KSpell::setAutoDelete
void setAutoDelete(bool _autoDelete)
Sets the auto-delete flag.
Definition: kspell.h:145
KSpell::modaldlg
bool modaldlg
Used for modalCheck.
Definition: kspell.h:541
KSpell::status
spellStatus status() const
Returns the status of KSpell.
Definition: kspell.h:130
KSpell::lastPosition
int lastPosition() const
Returns the position (when using check()) or word number (when using checkList()) of the last word ch...
Definition: kspell.h:167
KSpellConfig
A configuration class/dialog for KSpell.
Definition: ksconfig.h:87
KSpell::intermediateBuffer
QString intermediateBuffer() const
Returns the partially spellchecked buffer.
Definition: kspell.h:267
KSpell::spellStatus
spellStatus
Possible states of the spell checker.
Definition: kspell.h:65
KProcIO
KSpell
KDE Spellchecker
Definition: kspell.h:46

KDE Home | KDE Accessibility Home | Description of Access Keys