kspell Library API Documentation

kspell.h

00001 /* This file is part of the KDE libraries
00002    Copyright (C) 1997 David Sweet <dsweet@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00016    Boston, MA 02111-1307, USA.
00017 */
00018 #ifndef __KSPELL_H__
00019 #define __KSPELL_H__
00020 
00021 #include "ksconfig.h"
00022 
00023 #include <qobject.h>
00024 #include <qstringlist.h>
00025 #include <qstring.h>
00026 
00027 class QTextCodec;
00028 class KProcIO;
00029 class KProcess;
00030 class KSpellDlg;
00031 
00044 class KSpell : public QObject
00045 {
00046   Q_OBJECT
00047 
00048 public:
00049 
00063   enum spellStatus { Starting = 0, Running, Cleaning, Finished, Error, Crashed };
00064 
00082   KSpell(QWidget *parent, const QString &caption,
00083          QObject *receiver, const char *slot, KSpellConfig *kcs=0,
00084          bool progressbar = TRUE, bool modal = FALSE );
00085 
00091   spellStatus status() const { return m_status; }
00092 
00100   virtual void cleanUp ();
00101 
00106   void setAutoDelete(bool _autoDelete) { autoDelete = _autoDelete; }
00107 
00121   virtual bool check (const QString &_buffer, bool usedialog = TRUE);
00122 
00128   int lastPosition() const
00129     { return lastpos;}
00130 
00141   virtual bool checkList (QStringList *_wordlist, bool usedialog = TRUE);
00142 
00165   virtual bool checkWord (const QString &_buffer, bool usedialog = FALSE);
00166 
00172   void hide ();
00173 
00182   QStringList suggestions () const { return sugg; }
00183 
00200   int dlgResult () const
00201     { return dlgresult; }
00202 
00211   void moveDlg (int x, int y);
00212 
00216   int heightDlg () const;
00220   int widthDlg () const;
00221 
00227   QString intermediateBuffer () const {return newbuffer;}
00228 
00235   virtual bool ignore (const QString & word);
00236 
00243   virtual bool addPersonal (const QString & word);
00244 
00248   KSpellConfig ksConfig () const;
00249 
00257   void setProgressResolution (unsigned res);
00258 
00263   virtual ~KSpell();
00264 
00271   static int modalCheck( QString& text ); // marked as deprecated
00272 
00281   static int modalCheck( QString& text, KSpellConfig * kcs );
00282 
00287   void setIgnoreUpperWords(bool b);
00288 
00294   void setIgnoreTitleCase(bool b);
00295 
00296 signals:
00297 
00315   void misspelling (const QString & originalword, const QStringList & suggestions,
00316                     unsigned int pos);
00317 
00333   void corrected (const QString & originalword, const QString & newword, unsigned int pos);
00334 
00341   void ignoreall (const QString & originalword);
00342 
00348   void ignoreword (const QString & originalword);
00349 
00356   void addword (const QString & originalword);
00357 
00361   void replaceall( const QString & origword ,  const QString &replacement );
00362 
00367   void ready(KSpell *);
00368 
00373   void progress (unsigned int i);
00374 
00383   void done (const QString &buffer);
00384 
00392   void done(bool);
00393 
00404   void death( );
00405 
00406 
00407 protected slots:
00408   /* All of those signals from KProcIO get sent here. */
00409   void KSpell2 (KProcIO *);
00410   void checkWord2 (KProcIO *);
00411   void checkWord3 ();
00412   void check2 (KProcIO *);
00413   void checkList2 ();
00414   void checkList3a (KProcIO *);
00415   void checkListReplaceCurrent ();
00416   void checkList4 ();
00417   void dialog2 (int dlgresult);
00418   void check3 ();
00419 
00420   void slotStopCancel (int);
00421   void ispellExit (KProcess *);
00422   void emitDeath();
00423   void ispellErrors (KProcess *, char *, int);
00424 
00425 private slots:
00429   void slotModalReady();
00430 
00434   void slotModalDone( const QString & );
00435 
00439   void slotSpellCheckerCorrected( const QString & oldText, const QString & newText, unsigned int );
00440 
00444   void  slotModalSpellCheckerFinished( );
00445 
00446 signals:
00447   void dialog3 ();
00448 
00449 protected:
00450 
00451   KProcIO *proc;
00452   QWidget *parent;
00453   KSpellConfig *ksconfig;
00454   KSpellDlg *ksdlg;
00455   QStringList *wordlist;
00456   QStringList::Iterator wlIt;
00457   QStringList ignorelist;
00458   QStringList replacelist;
00459   QStringList sugg;
00460   QTextCodec* codec;
00461 
00462   spellStatus m_status;
00463 
00464   bool usedialog;
00465   bool texmode;
00466   bool dlgon;
00467   bool personaldict;
00468   bool dialogwillprocess;
00469   bool progressbar;
00470   bool dialogsetup;
00471   bool autoDelete;
00472 
00473   QString caption;
00474   QString orig;
00475   QString origbuffer;
00476   QString newbuffer;
00477   QString cwword;
00478   QString dlgorigword;
00479   QString dlgreplacement;
00480   QString dialog3slot;
00481 
00482   int dlgresult;
00483   int trystart;
00484   int maxtrystart;
00485   int lastpos;
00486   unsigned int totalpos;
00487   unsigned int lastline;
00488   unsigned int posinline;
00489   unsigned int lastlastline;
00490   unsigned int offset;
00491   unsigned int progres;
00492   unsigned int curprog;
00493 
00497   bool modaldlg;
00498   static QString modaltext;
00499   static int modalreturn;
00500   static QWidget* modalWidgetHack;
00501   static QStringList modalListText;
00502 
00503   int parseOneResponse (const QString &_buffer, QString &word, QStringList &sugg);
00504   QString funnyWord (const QString & word);
00505   void dialog (const QString & word, QStringList & sugg, const char* _slot);
00506   QString replacement () const
00507     { return dlgreplacement; }
00508 
00509   void setUpDialog ( bool reallyusedialogbox = TRUE);
00510 
00511   void emitProgress ();
00512   bool cleanFputs (const QString & s, bool appendCR=TRUE);
00513   bool cleanFputsWord (const QString & s, bool appendCR=TRUE);
00514   void startIspell();
00515   bool writePersonalDictionary ();
00516 
00517 private:
00518   class KSpellPrivate;
00519   KSpellPrivate *d;
00520 };
00521 
00548 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:27:47 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001