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
#include <kdelibs_export.h>
00033
00034
class QAccel;
00035
class QTimer;
00036
class KSpell;
00037
class KSpellConfig;
00038
00042 class KDEUI_EXPORT KSyntaxHighlighter :
public QSyntaxHighlighter
00043 {
00044
public:
00045
enum SyntaxMode {
00046 PlainTextMode,
00047 RichTextMode
00048 };
00049 KSyntaxHighlighter(
QTextEdit *textEdit,
00050
bool colorQuoting =
false,
00051
const QColor& QuoteColor0 = black,
00052
const QColor& QuoteColor1 =
QColor( 0x00, 0x80, 0x00 ),
00053
const QColor& QuoteColor2 =
QColor( 0x00, 0x80, 0x00 ),
00054
const QColor& QuoteColor3 =
QColor( 0x00, 0x80, 0x00 ),
00055 SyntaxMode mode = PlainTextMode );
00056 ~KSyntaxHighlighter();
00057
00058
int highlightParagraph(
const QString& text,
int endStateOfLastPara );
00059
00060
private:
00061
class KSyntaxHighlighterPrivate;
00062 KSyntaxHighlighterPrivate *d;
00063 };
00064
00065
class KDEUI_EXPORT KSpellingHighlighter :
public KSyntaxHighlighter
00066 {
00067
public:
00068 KSpellingHighlighter(
QTextEdit *textEdit,
00069
const QColor& spellColor = red,
00070
bool colorQuoting =
false,
00071
const QColor& QuoteColor0 = black,
00072
const QColor& QuoteColor1 =
QColor( 0x00, 0x80, 0x00 ),
00073
const QColor& QuoteColor2 =
QColor( 0x00, 0x80, 0x00 ),
00074
const QColor& QuoteColor3 =
QColor( 0x00, 0x80, 0x00 ) );
00075 ~KSpellingHighlighter();
00076
00077
virtual int highlightParagraph(
const QString &text,
00078
int endStateOfLastPara );
00079
virtual bool isMisspelled(
const QString& word ) = 0;
00080
bool intraWordEditing() const;
00081
void setIntraWordEditing(
bool editing );
00082 static
QStringList personalWords();
00083
00084 private:
00085
void flushCurrentWord();
00086
00087 class KSpellingHighlighterPrivate;
00088 KSpellingHighlighterPrivate *d;
00089 };
00090
00094 class KDEUI_EXPORT
KDictSpellingHighlighter : public
QObject, public KSpellingHighlighter
00095 {
00096 Q_OBJECT
00097
00098
public:
00099
KDictSpellingHighlighter(
QTextEdit *textEdit,
00100
bool spellCheckingActive =
true,
00101
bool autoEnable =
true,
00102
const QColor& spellColor = red,
00103
bool colorQuoting =
false,
00104
const QColor& QuoteColor0 = black,
00105
const QColor& QuoteColor1 =
QColor( 0x00, 0x80, 0x00 ),
00106
const QColor& QuoteColor2 =
QColor( 0x00, 0x70, 0x00 ),
00107
const QColor& QuoteColor3 =
QColor( 0x00, 0x60, 0x00 ),
00108
KSpellConfig *spellConfig = 0 );
00109 ~
KDictSpellingHighlighter();
00110
00111
virtual bool isMisspelled(
const QString &word );
00112
static void dictionaryChanged();
00113
void restartBackgroundSpellCheck();
00114
00127
void setActive(
bool active );
00128
00136
bool isActive()
const;
00137
00149
void setAutomatic(
bool automatic );
00150
00158
bool automatic()
const;
00159
00160 signals:
00161
void activeChanged(
const QString &);
00162
void newSuggestions(
const QString& originalword,
const QStringList& suggestions,
00163
unsigned int pos);
00164
00165
protected:
00166
QString spellKey();
00167
bool eventFilter(QObject *o,
QEvent *e);
00168
00169
protected slots:
00170
void slotMisspelling(
const QString &originalWord,
const QStringList &suggestions,
unsigned int pos );
00171
void slotCorrected(
const QString &originalWord,
const QString &,
unsigned int );
00172
void slotRehighlight();
00173
void slotDictionaryChanged();
00174
void slotSpellReady(
KSpell *spell );
00175
void slotAutoDetection();
00176
void slotLocalSpellConfigChanged();
00177
void slotKSpellNotResponding();
00178
00179
private:
00180
class KDictSpellingHighlighterPrivate;
00181 KDictSpellingHighlighterPrivate *d;
00182 };
00183
00184
#endif