00001 00010 #ifndef HIGHLIGHTBLOCK_H_ 00011 #define HIGHLIGHTBLOCK_H_ 00012 #include <QtCore/QString> 00013 #include <QtGui/QTextCharFormat> 00014 00018 enum HighlighType 00019 { 00020 singleLine, 00021 multiLines 00022 }; 00023 00029 class HighlightBlock 00030 { 00031 private: 00032 QTextCharFormat format; 00033 QString name; 00034 QString description; 00035 public: 00036 00041 virtual HighlighType type()=0; 00045 virtual ~HighlightBlock(){} 00046 00052 QTextCharFormat getFormat() const 00053 { 00054 return format; 00055 } 00056 00062 QFont getFont() const 00063 { 00064 return format.font(); 00065 } 00066 00073 void setFont(const QFont& __font) 00074 { 00075 format.setFont(__font); 00076 } 00077 00083 const QColor& getForegroundColor() const 00084 { 00085 return format.foreground().color(); 00086 } 00087 00093 void setForegroundColor(const QColor& color) 00094 { 00095 format.setForeground(color); 00096 } 00097 00103 const QColor& getBackgroundColor() const 00104 { 00105 return format.background().color(); 00106 } 00107 00113 void setBackgroundColor(const QColor& color) 00114 { 00115 format.setBackground(color); 00116 } 00117 00122 QString getName() const 00123 { 00124 return name; 00125 } 00126 00131 void setName(QString _name) 00132 { 00133 this->name = _name; 00134 } 00135 00140 QString getDescription() const 00141 { 00142 return description; 00143 } 00144 00149 void setDescription(QString _description) 00150 { 00151 this->description = _description; 00152 } 00153 00154 }; 00155 00160 class SingleLineHighlightBlock : public HighlightBlock 00161 { 00162 private: 00163 QString pattern; 00164 public: 00170 QRegExp getExp() const 00171 { 00172 return QRegExp(pattern); 00173 } 00174 00180 void setPattern(QString _pattern) {pattern=_pattern;} 00181 00182 HighlighType type() 00183 { 00184 return singleLine; 00185 } 00186 00192 QString getPattern() const 00193 { 00194 return pattern; 00195 } 00196 }; 00197 00202 class MultiLinesHighlightBlock : public HighlightBlock 00203 { 00204 private: 00205 QString startingPattern; 00206 QString endingPattern; 00207 public: 00213 QRegExp getStartingExp() const 00214 { 00215 return QRegExp(startingPattern); 00216 } 00217 00223 QRegExp getEndingExp() const 00224 { 00225 return QRegExp(endingPattern); 00226 } 00227 00233 void setStartingPattern(QString _pattern) 00234 { 00235 startingPattern=_pattern; 00236 } 00237 00243 void setEndingPattern(QString _pattern) 00244 { 00245 endingPattern=_pattern; 00246 } 00247 00248 HighlighType type() 00249 { 00250 return multiLines; 00251 } 00252 00258 QString getStartingPattern() const 00259 { 00260 return startingPattern; 00261 } 00262 00268 QString getEndingPattern() const 00269 { 00270 return endingPattern; 00271 } 00272 }; 00273 #endif /* HIGHLIGHTBLOCK_H_ */ 00274
1.5.8