home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kspell2 / backgroundchecker.h next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  3.8 KB  |  125 lines

  1. /**
  2.  * backgroundchecker.h
  3.  *
  4.  * Copyright (C)  2004  Zack Rusin <zack@kde.org>
  5.  *
  6.  * This library is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU Lesser General Public
  8.  * License as published by the Free Software Foundation; either
  9.  * version 2.1 of the License, or (at your option) any later version.
  10.  *
  11.  * This library is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  * Lesser General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU Lesser General Public
  17.  * License along with this library; if not, write to the Free Software
  18.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19.  * 02110-1301  USA
  20.  */
  21. #ifndef KSPELL_BACKGROUNDCHECKER_H
  22. #define KSPELL_BACKGROUNDCHECKER_H
  23.  
  24. #include "broker.h"
  25.  
  26. class QCustomEvent;
  27.  
  28. namespace KSpell2
  29. {
  30.     class Filter;
  31.  
  32.     /**
  33.      *
  34.      * BackgroundChecker is used to perform spell checking without
  35.      * blocking the application. You can use it as is by calling
  36.      * the checkText function or subclass it and reimplement
  37.      * getMoreText function.
  38.      *
  39.      * The misspelling signal is emitted whenever a mispelled word
  40.      * is found. The background checker stops right before emitting
  41.      * the signal. So the parent has to call continueChecking function
  42.      * to resume the checking.
  43.      *
  44.      * done signal is emitted when whole text is spell checked.
  45.      *
  46.      * @author Zack Rusin <zack@kde.org>
  47.      * @short class used for spell checking in the background
  48.      */
  49.     class KDE_EXPORT BackgroundChecker : public QObject
  50.     {
  51.         Q_OBJECT
  52.     public:
  53.         BackgroundChecker( const Broker::Ptr& broker, QObject *parent =0,
  54.                            const char *name =0 );
  55.         ~BackgroundChecker();
  56.  
  57.         /**
  58.          * This method is used to spell check static text.
  59.          * It automatically invokes start().
  60.          *
  61.          * Use getMoreText() with start() to spell check a stream.
  62.          */
  63.         void checkText( const QString& );
  64.  
  65.         Filter *filter() const;
  66.  
  67.         Broker *broker() const;
  68.         void changeLanguage( const QString& lang );
  69.  
  70.         bool checkWord( const QString& word );
  71.         QStringList suggest( const QString& ) const;
  72.         bool addWord( const QString& word );
  73.     public slots:
  74.         virtual void setFilter( KSpell2::Filter *filter );
  75.         virtual void start();
  76.         virtual void stop();
  77.  
  78.         /**
  79.          * After emitting misspelling signal the background
  80.          * checker stops. The catcher is responsible for calling
  81.          * continueChecking function to resume checking.
  82.          */
  83.         virtual void continueChecking();
  84.  
  85.     signals:
  86.         /**
  87.          * Emitted whenever a misspelled word is found
  88.          */
  89.         void misspelling( const QString& word, int start );
  90.  
  91.         /**
  92.          * Emitted after the whole text has been spell checked.
  93.          */
  94.         void done();
  95.  
  96.     protected:
  97.         /**
  98.          * This function is called to get the text to spell check.
  99.          * It will be called continuesly until it returns QString::null
  100.          * in which case the done() singnal is emitted.
  101.          * Note: the start parameter in mispelling() is not a combined
  102.          * position but a position in the last string returned
  103.          * by getMoreText. You need to store the state in the derivatives.
  104.          */
  105.         virtual QString getMoreText();
  106.  
  107.         /**
  108.          * This function will be called whenever the background checker
  109.          * will be finished text which it got from getMoreText.
  110.          */
  111.         virtual void finishedCurrentFeed();
  112.  
  113.     protected slots:
  114.         void slotEngineDone();
  115.     protected:
  116.         //void customEvent( QCustomEvent *event );
  117.     private:
  118.         class Private;
  119.         Private *d;
  120.     };
  121.  
  122. }
  123.  
  124. #endif
  125.