00001 #ifndef RULE_EDITING_H 00002 #define RULE_EDITING_H 00003 00004 #include <QDialog> 00005 #include <QTimer> 00006 #include <QSyntaxHighlighter> 00007 #include <QTextCharFormat> 00008 #include <QTextEdit> 00009 #include <ros_type_introspection/renamer.hpp> 00010 00011 namespace Ui { 00012 class RuleEditing; 00013 } 00014 00015 class XMLSyntaxHighlighter : public QSyntaxHighlighter 00016 { 00017 Q_OBJECT 00018 public: 00019 XMLSyntaxHighlighter(QObject * parent); 00020 XMLSyntaxHighlighter(QTextDocument * parent); 00021 XMLSyntaxHighlighter(QTextEdit * parent); 00022 00023 protected: 00024 virtual void highlightBlock(const QString & text); 00025 00026 private: 00027 void highlightByRegex(const QTextCharFormat & format, 00028 const QRegExp & regex, const QString & text); 00029 void setRegexes(); 00030 void setFormats(); 00031 00032 private: 00033 QTextCharFormat _xmlKeywordFormat; 00034 QTextCharFormat _xmlElementFormat; 00035 QTextCharFormat _xmlAttributeFormat; 00036 QTextCharFormat _xmlValueFormat; 00037 QTextCharFormat _xmlCommentFormat; 00038 00039 QList<QRegExp> _xmlKeywordRegexes; 00040 QRegExp _xmlElementRegex; 00041 QRegExp _xmlAttributeRegex; 00042 QRegExp _xmlValueRegex; 00043 QRegExp _xmlCommentRegex; 00044 }; 00045 00046 00047 class RuleEditing : public QDialog 00048 { 00049 Q_OBJECT 00050 00051 public: 00052 explicit RuleEditing(QWidget *parent = 0); 00053 ~RuleEditing(); 00054 00055 static RosIntrospection::SubstitutionRuleMap getRenamingRules(); 00056 00057 static QString getRenamingXML(); 00058 00059 private slots: 00060 00061 void on_pushButtonSave_pressed(); 00062 00063 void on_pushButtonReset_pressed(); 00064 00065 void on_timer(); 00066 00067 void on_pushButtonCancel_pressed(); 00068 00069 private: 00070 00071 bool isValidXml(); 00072 00073 Ui::RuleEditing *ui; 00074 00075 XMLSyntaxHighlighter *_highlighter; 00076 QTimer _timer; 00077 00078 private slots: 00079 00080 virtual void closeEvent(QCloseEvent *event) override; 00081 00082 }; 00083 00084 #endif // RULE_EDITING_H