00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
#ifndef __KSPELL_H__
00020
#define __KSPELL_H__
00021
00022
#include "ksconfig.h"
00023
00024
#include <qobject.h>
00025
#include <qstringlist.h>
00026
#include <qstring.h>
00027
#include <kdelibs_export.h>
00028
00029
class QTextCodec;
00030
class KProcIO;
00031
class KProcess;
00032
class KSpellDlg;
00033
00046 class KDEUI_EXPORT KSpell :
public QObject
00047 {
00048 Q_OBJECT
00049
00050
public:
00051
00065 enum spellStatus { Starting = 0, Running, Cleaning, Finished, Error, Crashed, FinishedNoMisspellingsEncountered };
00066
00080 enum SpellerType { Text = 0, HTML, TeX, Nroff };
00081
00099 KSpell(
QWidget *parent,
const QString &caption,
00100
QObject *receiver,
const char *slot,
KSpellConfig *kcs=0,
00101
bool progressbar =
true,
bool modal =
false);
00102
00121 KSpell(
QWidget *parent,
const QString &caption,
00122
QObject *receiver,
const char *slot,
KSpellConfig *kcs,
00123
bool progressbar,
bool modal, SpellerType type);
00124
00130 spellStatus status()
const {
return m_status; }
00131
00139
virtual void cleanUp ();
00140
00145 void setAutoDelete(
bool _autoDelete) { autoDelete = _autoDelete; }
00146
00160
virtual bool check (
const QString &_buffer,
bool usedialog =
true);
00161
00167 int lastPosition()
const
00168
{
return lastpos;}
00169
00180
virtual bool checkList (
QStringList *_wordlist,
bool usedialog =
true);
00181
00204
virtual bool checkWord (
const QString &_buffer,
bool usedialog =
false);
00205
bool checkWord(
const QString & buffer,
bool _usedialog,
bool suggest );
00206
00212
void hide ();
00213
00222 QStringList suggestions ()
const {
return sugg; }
00223
00240 int dlgResult ()
const
00241
{
return dlgresult; }
00242
00251
void moveDlg (
int x,
int y);
00252
00256
int heightDlg () const;
00260
int widthDlg () const;
00261
00267 QString intermediateBuffer ()
const {
return newbuffer;}
00268
00275
virtual bool ignore (
const QString & word);
00276
00283
virtual bool addPersonal (
const QString & word);
00284
00288
KSpellConfig ksConfig () const;
00289
00297
void setProgressResolution (
unsigned int res);
00298
00303 virtual ~KSpell();
00304
00313 static
int modalCheck(
QString& text ) KDE_DEPRECATED;
00314
00323 static
int modalCheck(
QString& text,
KSpellConfig * kcs );
00324
00329
void setIgnoreUpperWords(
bool b);
00330
00336
void setIgnoreTitleCase(
bool b);
00337
00338 signals:
00339
00357
void misspelling (const
QString & originalword, const
QStringList & suggestions,
00358
unsigned int pos);
00359
00375
void corrected (const
QString & originalword, const
QString & newword,
unsigned int pos);
00376
00383
void ignoreall (const
QString & originalword);
00384
00390
void ignoreword (const
QString & originalword);
00391
00398
void addword (const
QString & originalword);
00399
00403
void replaceall( const
QString & origword , const
QString &replacement );
00404
00409
void ready(KSpell *);
00410
00415
void progress (
unsigned int i);
00416
00425
void done (const
QString &buffer);
00426
00434
void done(
bool);
00435
00446
void death( );
00447
00448
00449 protected slots:
00450
00451
void KSpell2 (
KProcIO *);
00452
void checkWord2 (KProcIO *);
00453
void checkWord3 ();
00454
void check2 (KProcIO *);
00455
void checkList2 ();
00456
void checkList3a (KProcIO *);
00457
void checkListReplaceCurrent ();
00458
void checkList4 ();
00459
void dialog2 (
int dlgresult);
00460
void check3 ();
00461
void suggestWord( KProcIO * );
00462
00463
void slotStopCancel (
int);
00464
void ispellExit (
KProcess *);
00465
void emitDeath();
00466
void ispellErrors (KProcess *,
char *,
int);
00467
void checkNext();
00468
00469 private slots:
00473
void slotModalReady();
00474
00478
void slotModalDone( const
QString & );
00479
00483
void slotSpellCheckerCorrected( const QString & oldText, const QString & newText,
unsigned int );
00484
00488
void slotModalSpellCheckerFinished( );
00489
00490 signals:
00491
void dialog3 ();
00492
00493 protected:
00494
00495 KProcIO *proc;
00496
QWidget *parent;
00497
KSpellConfig *ksconfig;
00498 KSpellDlg *ksdlg;
00499
QStringList *wordlist;
00500
QStringList::Iterator wlIt;
00501
QStringList ignorelist;
00502
QStringList replacelist;
00503
QStringList sugg;
00504
QTextCodec* codec;
00505
00506 spellStatus m_status;
00507
00508
bool usedialog;
00509
bool texmode;
00510
bool dlgon;
00511
bool personaldict;
00512
bool dialogwillprocess;
00513
bool progressbar;
00514
bool dialogsetup;
00515
bool autoDelete;
00516
00517 QString caption;
00518 QString orig;
00519 QString origbuffer;
00520 QString newbuffer;
00521 QString cwword;
00522 QString dlgorigword;
00523 QString dlgreplacement;
00524 QString dialog3slot;
00525
00526
int dlgresult;
00527
int trystart;
00528
int maxtrystart;
00529
int lastpos;
00530
unsigned int totalpos;
00531
unsigned int lastline;
00532
unsigned int posinline;
00533
unsigned int lastlastline;
00534
unsigned int offset;
00535
unsigned int progres;
00536
unsigned int curprog;
00537
00541 bool modaldlg;
00542 static QString modaltext;
00543 static
int modalreturn;
00544 static
QWidget* modalWidgetHack;
00545
00546
int parseOneResponse (const QString &_buffer, QString &word,
QStringList &sugg);
00547 QString funnyWord (const QString & word);
00548
void dialog (const QString & word,
QStringList & sugg, const
char* _slot);
00549 QString replacement ()
const
00550
{
return dlgreplacement; }
00551
00552
void setUpDialog (
bool reallyusedialogbox =
true);
00553
00554
void emitProgress ();
00555
bool cleanFputs (
const QString & s,
bool appendCR=
true);
00556
bool cleanFputsWord (
const QString & s,
bool appendCR=
true);
00557
void startIspell();
00558
bool writePersonalDictionary();
00559
void initialize(
QWidget *_parent,
const QString &_caption,
00560
QObject *obj,
const char *slot,
KSpellConfig *_ksc,
00561
bool _progressbar,
bool _modal, SpellerType type );
00562
00563
private:
00564
class KSpellPrivate;
00565 KSpellPrivate *d;
00566 };
00567
00568
#endif