00001 00010 #ifndef HIGHLIGHTBLOCK_H_ 00011 #define HIGHLIGHTBLOCK_H_ 00012 #include <QtCore/QString> 00013 #include <QtGui/QTextCharFormat> 00014 00015 00021 class HighlightBlock 00022 { 00023 private: 00024 QTextCharFormat format; 00025 QString name; 00026 QString description; 00027 public: 00028 00032 HighlightBlock() 00033 { 00034 format.setFontFamily("Courier New"); 00035 format.setFontPointSize(8); 00036 format.setForeground(QColor(0,0,0)); 00037 format.setBackground(QColor(255,255,255)); 00038 } 00042 enum HighlighType 00043 { 00044 sl, 00045 ml 00046 }; 00051 virtual HighlighType type()=0; 00055 virtual ~HighlightBlock(){} 00056 00062 QTextCharFormat getFormat() const 00063 { 00064 return format; 00065 } 00066 00072 QFont getFont() const 00073 { 00074 return format.font(); 00075 } 00076 00083 void setFont(const QFont& __font) 00084 { 00085 format.setFont(__font); 00086 } 00087 00093 const QColor& getForegroundColor() const 00094 { 00095 return format.foreground().color(); 00096 } 00097 00103 void setForegroundColor(const QColor& color) 00104 { 00105 format.setForeground(color); 00106 } 00107 00113 const QColor& getBackgroundColor() const 00114 { 00115 return format.background().color(); 00116 } 00117 00123 void setBackgroundColor(const QColor& color) 00124 { 00125 format.setBackground(color); 00126 } 00127 00132 QString getName() const 00133 { 00134 return name; 00135 } 00136 00141 void setName(QString _name) 00142 { 00143 this->name = _name; 00144 } 00145 00150 QString getDescription() const 00151 { 00152 return description; 00153 } 00154 00159 void setDescription(QString _description) 00160 { 00161 this->description = _description; 00162 } 00163 00164 }; 00165 00170 class SingleLineHighlightBlock : public HighlightBlock 00171 { 00172 private: 00173 QString pattern; 00174 public: 00180 QRegExp getExp() const 00181 { 00182 return QRegExp(pattern); 00183 } 00184 00190 void setPattern(QString _pattern) {pattern=_pattern;} 00191 00192 HighlighType type() 00193 { 00194 return sl; 00195 } 00196 00202 QString getPattern() const 00203 { 00204 return pattern; 00205 } 00206 }; 00207 00212 class MultiLinesHighlightBlock : public HighlightBlock 00213 { 00214 private: 00215 QString startingPattern; 00216 QString endingPattern; 00217 public: 00223 QRegExp getStartingExp() const 00224 { 00225 return QRegExp(startingPattern); 00226 } 00227 00233 QRegExp getEndingExp() const 00234 { 00235 return QRegExp(endingPattern); 00236 } 00237 00243 void setStartingPattern(QString _pattern) 00244 { 00245 startingPattern=_pattern; 00246 } 00247 00253 void setEndingPattern(QString _pattern) 00254 { 00255 endingPattern=_pattern; 00256 } 00257 00258 HighlighType type() 00259 { 00260 return ml; 00261 } 00262 00268 QString getStartingPattern() const 00269 { 00270 return startingPattern; 00271 } 00272 00278 QString getEndingPattern() const 00279 { 00280 return endingPattern; 00281 } 00282 }; 00283 #endif /* HIGHLIGHTBLOCK_H_ */ 00284
1.5.8