00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef K3SYNTAXHIGHLIGHTER_H
00025 #define K3SYNTAXHIGHLIGHTER_H
00026
00027 #include <kde3support_export.h>
00028
00029 #include <Qt3Support/Q3TextEdit>
00030 #include <Qt3Support/Q3SyntaxHighlighter>
00031 #include <QtGui/QColor>
00032 #include <QtCore/QStringList>
00033
00034 class K3Spell;
00035 class K3SpellConfig;
00036
00040 class KDE3SUPPORT_EXPORT K3SyntaxHighlighter : public Q3SyntaxHighlighter
00041 {
00042 public:
00043 enum SyntaxMode {
00044 PlainTextMode,
00045 RichTextMode
00046 };
00047 K3SyntaxHighlighter( Q3TextEdit *textEdit,
00048 bool colorQuoting = false,
00049 const QColor& QuoteColor0 = Qt::black,
00050 const QColor& QuoteColor1 = QColor( 0x00, 0x80, 0x00 ),
00051 const QColor& QuoteColor2 = QColor( 0x00, 0x80, 0x00 ),
00052 const QColor& QuoteColor3 = QColor( 0x00, 0x80, 0x00 ),
00053 SyntaxMode mode = PlainTextMode );
00054 ~K3SyntaxHighlighter();
00055
00056 int highlightParagraph( const QString& text, int endStateOfLastPara );
00057
00058 private:
00059 class K3SyntaxHighlighterPrivate;
00060 K3SyntaxHighlighterPrivate *const d;
00061 };
00062
00063 class KDE3SUPPORT_EXPORT K3SpellingHighlighter : public K3SyntaxHighlighter
00064 {
00065 public:
00066 K3SpellingHighlighter( Q3TextEdit *textEdit,
00067 const QColor& spellColor = Qt::red,
00068 bool colorQuoting = false,
00069 const QColor& QuoteColor0 = Qt::black,
00070 const QColor& QuoteColor1 = QColor( 0x00, 0x80, 0x00 ),
00071 const QColor& QuoteColor2 = QColor( 0x00, 0x80, 0x00 ),
00072 const QColor& QuoteColor3 = QColor( 0x00, 0x80, 0x00 ) );
00073 ~K3SpellingHighlighter();
00074
00075 virtual int highlightParagraph( const QString &text,
00076 int endStateOfLastPara );
00077 virtual bool isMisspelled( const QString& word ) = 0;
00078 bool intraWordEditing() const;
00079 void setIntraWordEditing( bool editing );
00080 static QStringList personalWords();
00081
00082 private:
00083 void flushCurrentWord();
00084
00085 class K3SpellingHighlighterPrivate;
00086 K3SpellingHighlighterPrivate *const d;
00087 };
00088
00092 class KDE3SUPPORT_EXPORT K3DictSpellingHighlighter : public QObject, public K3SpellingHighlighter
00093 {
00094 Q_OBJECT
00095
00096 public:
00097 K3DictSpellingHighlighter( Q3TextEdit *textEdit,
00098 bool spellCheckingActive = true,
00099 bool autoEnable = true,
00100 const QColor& spellColor = Qt::red,
00101 bool colorQuoting = false,
00102 const QColor& QuoteColor0 = Qt::black,
00103 const QColor& QuoteColor1 = QColor( 0x00, 0x80, 0x00 ),
00104 const QColor& QuoteColor2 = QColor( 0x00, 0x70, 0x00 ),
00105 const QColor& QuoteColor3 = QColor( 0x00, 0x60, 0x00 ),
00106 K3SpellConfig *spellConfig = 0 );
00107 ~K3DictSpellingHighlighter();
00108
00109 virtual bool isMisspelled( const QString &word );
00110 static void dictionaryChanged();
00111 void restartBackgroundSpellCheck();
00112
00125 void setActive( bool active );
00126
00134 bool isActive() const;
00135
00147 void setAutomatic( bool automatic );
00148
00156 bool automatic() const;
00157
00158 Q_SIGNALS:
00159 void activeChanged(const QString &);
00160 void newSuggestions(const QString& originalword, const QStringList& suggestions,
00161 unsigned int pos);
00162
00163 protected:
00164 QString spellKey();
00165 bool eventFilter(QObject *o, QEvent *e);
00166
00167 protected Q_SLOTS:
00168 void slotMisspelling( const QString &originalWord, const QStringList &suggestions, unsigned int pos );
00169 void slotCorrected( const QString &originalWord, const QString &, unsigned int );
00170 void slotRehighlight();
00171 void slotDictionaryChanged();
00172 void slotSpellReady( K3Spell *spell );
00173 void slotAutoDetection();
00174 void slotLocalSpellConfigChanged();
00175 void slotK3SpellNotResponding();
00176
00177 private:
00178 class K3DictSpellingHighlighterPrivate;
00179 K3DictSpellingHighlighterPrivate *const d;
00180 };
00181
00182 #endif