00001 #ifndef SXHIGHLIGHTER_H_INCLUDED 00002 #define SXHIGHLIGHTER_H_INCLUDED 00003 00004 #include <QSyntaxHighlighter> 00005 #include <QHash> 00006 #include <QTextCharFormat> 00007 #include "sxGlobal.h" 00008 00010 class QTextDocument; 00011 class SX_GUISDKEXPORT sxHighlighter : public QSyntaxHighlighter 00012 { 00013 Q_OBJECT 00014 00015 public: 00016 sxHighlighter(QTextDocument *parent = 0); 00017 virtual ~sxHighlighter(); 00018 00019 protected: 00020 void highlightBlock(const QString &text); 00021 00022 private: 00023 struct HighlightingRule 00024 { 00025 QRegExp pattern; 00026 QTextCharFormat format; 00027 }; 00028 QVector<HighlightingRule> highlightingRules; 00029 00030 QRegExp commentStartExpression; 00031 QRegExp commentEndExpression; 00032 00033 QTextCharFormat keywordFormat; 00034 QTextCharFormat classFormat; 00035 QTextCharFormat singleLineCommentFormat; 00036 QTextCharFormat multiLineCommentFormat; 00037 QTextCharFormat quotationFormat; 00038 QTextCharFormat functionFormat; 00039 QTextCharFormat propertyFormat; 00040 00041 enum { InBlockComment = 1 }; 00042 }; 00043 00047 class SX_GUISDKEXPORT sxLogHighlighter : public QSyntaxHighlighter 00048 { 00049 Q_OBJECT 00050 public: 00051 sxLogHighlighter(QTextDocument *parent = 0); 00052 virtual ~sxLogHighlighter(); 00053 00054 protected: 00055 void highlightBlock(const QString &text); 00056 00057 private: 00058 struct HighlightingRule 00059 { 00060 QString identifier; 00061 QTextCharFormat format; 00062 }; 00063 QVector<HighlightingRule> highlightingRules; 00064 00065 QTextCharFormat errorFormat; 00066 QTextCharFormat warningFormat; 00067 QTextCharFormat criticalFormat; 00068 QTextCharFormat infoFormat; 00069 }; 00070 00071 #endif // SXHIGHLIGHTER_H_INCLUDED