filter.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef KSPELL_FILTER_H
00024 #define KSPELL_FILTER_H
00025
00026 #include <qstring.h>
00027 #include <kdelibs_export.h>
00028
00029 namespace KSpell2
00030 {
00031 class Settings;
00032
00040 struct Word
00041 {
00042 Word() : start( 0 ), end( true )
00043 {}
00044
00045 Word( const QString& w, int st, bool e = false )
00046 : word( w ), start( st ), end( e )
00047 {}
00048 Word( const Word& other )
00049 : word( other.word ), start( other.start ),
00050 end( other.end )
00051 {}
00052
00053 QString word;
00054 uint start;
00055 bool end;
00056 };
00057
00065 class KDE_EXPORT Filter
00066 {
00067 public:
00068 static Filter *defaultFilter();
00069 public:
00070 Filter();
00071 virtual ~Filter();
00072
00073 static Word end();
00074
00078 void setSettings( Settings* );
00079
00083 Settings *settings() const;
00084
00085 bool atEnd() const;
00086
00087 void setBuffer( const QString& buffer );
00088 QString buffer() const;
00089
00090 void restart();
00091
00092 virtual Word nextWord() const;
00093 virtual Word previousWord() const;
00094 virtual Word wordAtPosition( unsigned int pos ) const;
00095
00096 virtual void setCurrentPosition( int );
00097 virtual int currentPosition() const;
00098 virtual void replace( const Word& w, const QString& newWord );
00099
00103 virtual QString context() const;
00104 protected:
00105 bool trySkipLinks() const;
00106 bool ignore( const QString& word ) const;
00107 QChar skipToLetter( uint &fromPosition ) const;
00108 bool shouldBeSkipped( bool wordWasUppercase, bool wordWasRunTogether,
00109 const QString& foundWord ) const;
00110
00111 protected:
00112 QString m_buffer;
00113 mutable uint m_currentPosition;
00114
00115 private:
00116 class Private;
00117 Private *d;
00118 };
00119
00120 }
00121
00122 #endif
|