00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef K3SPELL_H
00020 #define K3SPELL_H
00021
00022 #include <kde3support_export.h>
00023
00024 #include <QtCore/QObject>
00025 #include <QtCore/QStringList>
00026 #include <QtCore/QString>
00027
00028 class QTextCodec;
00029 class KProcess;
00030 class K3SpellConfig;
00031 class K3SpellDlg;
00032
00046 class KDE3SUPPORT_EXPORT_DEPRECATED K3Spell : 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 K3Spell(QWidget *parent, const QString &caption,
00100 QObject *receiver, const char *slot, K3SpellConfig *kcs=0,
00101 bool progressbar = true, bool modal = false);
00102
00121 K3Spell(QWidget *parent, const QString &caption,
00122 QObject *receiver, const char *slot, K3SpellConfig *kcs,
00123 bool progressbar, bool modal, SpellerType type);
00124
00130 spellStatus status() const;
00131
00139 virtual void cleanUp ();
00140
00145 void setAutoDelete(bool _autoDelete);
00146
00160 virtual bool check (const QString &_buffer, bool usedialog = true);
00161
00167 int lastPosition() const;
00168
00179 virtual bool checkList (QStringList *_wordlist, bool usedialog = true);
00180
00203 virtual bool checkWord (const QString &_buffer, bool usedialog = false);
00204 bool checkWord( const QString & buffer, bool _usedialog, bool suggest );
00205
00211 void hide ();
00212
00221 QStringList suggestions () const;
00222
00239 int dlgResult () const;
00240
00249 void moveDlg (int x, int y);
00250
00254 int heightDlg () const;
00258 int widthDlg () const;
00259
00265 QString intermediateBuffer () const;
00266
00273 virtual bool ignore (const QString & word);
00274
00281 virtual bool addPersonal (const QString & word);
00282
00286 K3SpellConfig ksConfig () const;
00287
00295 void setProgressResolution (unsigned int res);
00296
00301 virtual ~K3Spell();
00302
00311 static KDE_DEPRECATED int modalCheck( QString& text );
00312
00321 static int modalCheck( QString& text, K3SpellConfig * kcs );
00322
00327 void setIgnoreUpperWords(bool b);
00328
00334 void setIgnoreTitleCase(bool b);
00335
00336 Q_SIGNALS:
00337
00355 void misspelling (const QString & originalword, const QStringList & suggestions,
00356 unsigned int pos);
00357
00373 void corrected (const QString & originalword, const QString & newword, unsigned int pos);
00374
00381 void ignoreall (const QString & originalword);
00382
00388 void ignoreword (const QString & originalword);
00389
00396 void addword (const QString & originalword);
00397
00401 void replaceall( const QString & origword , const QString &replacement );
00402
00407 void ready(K3Spell *);
00408
00413 void progress (unsigned int i);
00414
00423 void done (const QString &buffer);
00424
00432 void done(bool);
00433
00444 void death( );
00445
00446
00447 protected Q_SLOTS:
00448
00449 void K3Spell2 ();
00450 void checkWord2 ();
00451 void checkWord3 ();
00452 void check2 ();
00453 void checkList2 ();
00454 void checkList3a ();
00455 void checkListReplaceCurrent ();
00456 void checkList4 ();
00457 void dialog2 (int dlgresult);
00458 void check3 ();
00459 void suggestWord();
00460
00461 void slotStopCancel (int);
00462 void ispellExit ();
00463 void emitDeath();
00464 void ispellErrors ();
00465 void checkNext();
00466
00467 private Q_SLOTS:
00471 void slotModalReady();
00472
00476 void slotModalDone( const QString & );
00477
00481 void slotSpellCheckerCorrected( const QString & oldText, const QString & newText, unsigned int );
00482
00486 void slotModalSpellCheckerFinished( );
00487
00488 Q_SIGNALS:
00489 void dialog3 ();
00490
00491 protected:
00492
00493 KProcess *proc;
00494 QWidget *parent;
00495 K3SpellConfig *ksconfig;
00496 K3SpellDlg *ksdlg;
00497 QStringList *wordlist;
00498 QStringList::Iterator wlIt;
00499 QStringList ignorelist;
00500 QStringList replacelist;
00501 QStringList sugg;
00502
00503 spellStatus m_status;
00504
00505 bool usedialog;
00506 bool texmode;
00507 bool dlgon;
00508 bool personaldict;
00509 bool dialogwillprocess;
00510 bool progressbar;
00511 bool dialogsetup;
00512 bool autoDelete;
00513
00514 QString caption;
00515 QString orig;
00516 QString origbuffer;
00517 QString newbuffer;
00518 QString cwword;
00519 QString dlgorigword;
00520 QString dlgreplacement;
00521 QString dialog3slot;
00522
00523 int dlgresult;
00524 int trystart;
00525 int maxtrystart;
00526 int lastpos;
00527 unsigned int totalpos;
00528 int lastline;
00529 unsigned int posinline;
00530 unsigned int lastlastline;
00531 unsigned int offset;
00532 unsigned int progres;
00533 unsigned int curprog;
00534
00538 bool modaldlg;
00539 static QString modaltext;
00540 static int modalreturn;
00541 static QWidget* modalWidgetHack;
00542
00543 int parseOneResponse (const QString &_buffer, QString &word, QStringList &sugg);
00544 QString funnyWord (const QString & word);
00545 void dialog (const QString & word, QStringList & sugg, const char* _slot);
00546 QString replacement () const;
00547
00548 void setUpDialog ( bool reallyusedialogbox = true);
00549
00550 void emitProgress ();
00551 bool cleanFputs (const QString & s );
00552 bool cleanFputsWord (const QString & s );
00553 void startIspell();
00554 bool writePersonalDictionary();
00555 void initialize( QWidget *_parent, const QString &_caption,
00556 QObject *obj, const char *slot, K3SpellConfig *_ksc,
00557 bool _progressbar, bool _modal, SpellerType type );
00558
00559 private:
00560 class K3SpellPrivate;
00561 K3SpellPrivate *d;
00562 };
00563
00564 #endif