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 KSYNTAXHIGHLIGHTER_H
00025
#define KSYNTAXHIGHLIGHTER_H
00026
00027
#include <qtextedit.h>
00028
#include <qsyntaxhighlighter.h>
00029
#include <qcolor.h>
00030
#include <qstringlist.h>
00031
00032
class QAccel;
00033
class QTimer;
00034
class KSpell;
00035
class KSpellConfig;
00036
00037
class KSyntaxHighlighter :
public QSyntaxHighlighter
00038 {
00039
public:
00040
enum SyntaxMode {
00041 PlainTextMode,
00042 RichTextMode
00043 };
00044 KSyntaxHighlighter(
QTextEdit *textEdit,
00045
bool colorQuoting =
false,
00046
const QColor& QuoteColor0 = black,
00047
const QColor& QuoteColor1 =
QColor( 0x00, 0x80, 0x00 ),
00048
const QColor& QuoteColor2 =
QColor( 0x00, 0x80, 0x00 ),
00049
const QColor& QuoteColor3 =
QColor( 0x00, 0x80, 0x00 ),
00050 SyntaxMode mode = PlainTextMode );
00051 ~KSyntaxHighlighter();
00052
00053
int highlightParagraph(
const QString& text,
int endStateOfLastPara );
00054
00055
private:
00056
class KSyntaxHighlighterPrivate;
00057 KSyntaxHighlighterPrivate *d;
00058 };
00059
00060
class KSpellingHighlighter :
public KSyntaxHighlighter
00061 {
00062
public:
00063 KSpellingHighlighter(
QTextEdit *textEdit,
00064
const QColor& spellColor = red,
00065
bool colorQuoting =
false,
00066
const QColor& QuoteColor0 = black,
00067
const QColor& QuoteColor1 =
QColor( 0x00, 0x80, 0x00 ),
00068
const QColor& QuoteColor2 =
QColor( 0x00, 0x80, 0x00 ),
00069
const QColor& QuoteColor3 =
QColor( 0x00, 0x80, 0x00 ) );
00070 ~KSpellingHighlighter();
00071
00072
virtual int highlightParagraph(
const QString &text,
00073
int endStateOfLastPara );
00074
virtual bool isMisspelled(
const QString& word ) = 0;
00075
bool intraWordEditing() const;
00076
void setIntraWordEditing(
bool editing );
00077 static
QStringList personalWords();
00078
00079 private:
00080
void flushCurrentWord();
00081
00082 class KSpellingHighlighterPrivate;
00083 KSpellingHighlighterPrivate *d;
00084 };
00085
00086 class KDictSpellingHighlighter : public
QObject, public KSpellingHighlighter
00087 {
00088 Q_OBJECT
00089
00090
public:
00091 KDictSpellingHighlighter(
QTextEdit *textEdit,
00092
bool spellCheckingActive =
true,
00093
bool autoEnable =
true,
00094
const QColor& spellColor = red,
00095
bool colorQuoting =
false,
00096
const QColor& QuoteColor0 = black,
00097
const QColor& QuoteColor1 =
QColor( 0x00, 0x80, 0x00 ),
00098
const QColor& QuoteColor2 =
QColor( 0x00, 0x70, 0x00 ),
00099
const QColor& QuoteColor3 =
QColor( 0x00, 0x60, 0x00 ),
00100
KSpellConfig *spellConfig = 0 );
00101 ~KDictSpellingHighlighter();
00102
00103
virtual bool isMisspelled(
const QString &word );
00104
static void dictionaryChanged();
00105
void restartBackgroundSpellCheck();
00106
00119
void setActive(
bool active );
00120
00128
bool isActive() const;
00129
00141
void setAutomatic(
bool automatic );
00142
00150
bool automatic() const;
00151
00152 signals:
00153
void activeChanged(const
QString &);
00154
void newSuggestions(const QString& originalword, const
QStringList& suggestions,
00155
unsigned int pos);
00156
00157 protected:
00158 QString spellKey();
00159
bool eventFilter(QObject *o,
QEvent *e);
00160
00161 protected slots:
00162
void slotMisspelling( const QString &originalWord, const
QStringList &suggestions,
unsigned int pos );
00163
void slotCorrected( const QString &originalWord, const QString &,
unsigned int );
00164
void slotRehighlight();
00165
void slotDictionaryChanged();
00166
void slotSpellReady(
KSpell *spell );
00167
void slotAutoDetection();
00168
void slotLocalSpellConfigChanged();
00169
void slotKSpellNotResponding();
00170
00171 private:
00172 class KDictSpellingHighlighterPrivate;
00173 KDictSpellingHighlighterPrivate *d;
00174 };
00175
00176 #endif