Warning, file /rolisteam/rolisteam/src/libraries/rwidgets/editors/noteeditor/format_OO_oasis_/XML_Editor.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 #ifndef XMLHIGHLIGHTER_H
0002 #define XMLHIGHLIGHTER_H
0003 
0004 #include "rwidgets_global.h"
0005 #include <QColor>
0006 #include <QDebug>
0007 #include <QDomDocument>
0008 #include <QObject>
0009 #include <QSyntaxHighlighter>
0010 #include <QTextCharFormat>
0011 #include <QTextEdit>
0012 #include <QWidget>
0013 #include <QtCore>
0014 #include <QtGui>
0015 class RWIDGET_EXPORT XmlHighlighter : public QSyntaxHighlighter
0016 {
0017 public:
0018     XmlHighlighter(QObject* parent);
0019     XmlHighlighter(QTextDocument* parent);
0020     XmlHighlighter(QTextEdit* parent);
0021     ~XmlHighlighter();
0022 
0023     enum HighlightType
0024     {
0025         SyntaxChar,
0026         ElementName,
0027         Comment,
0028         AttributeName,
0029         AttributeValue,
0030         Error,
0031         Other
0032     };
0033 
0034     void setHighlightColor(HighlightType type, QColor color, bool foreground= true);
0035     void setHighlightFormat(HighlightType type, QTextCharFormat format);
0036 
0037 protected:
0038     void highlightBlock(const QString& rstrText);
0039     int processDefaultText(int i, const QString& rstrText);
0040 
0041 private:
0042     void init();
0043 
0044     QTextCharFormat fmtSyntaxChar;
0045     QTextCharFormat fmtElementName;
0046     QTextCharFormat fmtComment;
0047     QTextCharFormat fmtAttributeName;
0048     QTextCharFormat fmtAttributeValue;
0049     QTextCharFormat fmtError;
0050     QTextCharFormat fmtOther;
0051 
0052     enum ParsingState
0053     {
0054         NoState= 0,
0055         ExpectElementNameOrSlash,
0056         ExpectElementName,
0057         ExpectAttributeOrEndOfElement,
0058         ExpectEqual,
0059         ExpectAttributeValue
0060     };
0061 
0062     enum BlockState
0063     {
0064         NoBlock= -1,
0065         InComment,
0066         InElement
0067     };
0068 
0069     ParsingState state;
0070 };
0071 
0072 class XMLTextEdit : public QTextEdit
0073 {
0074     Q_OBJECT
0075     //
0076 public:
0077     XMLTextEdit(QWidget* parent= 0);
0078     bool Conform();
0079     QDomDocument xml_document();
0080     inline QString text() const { return QTextEdit::toPlainText(); }
0081     QMenu* createOwnStandardContextMenu();
0082 
0083 protected:
0084     void contextMenuEvent(QContextMenuEvent* e);
0085     bool event(QEvent* event);
0086 
0087 private:
0088     XmlHighlighter* highlight;
0089 signals:
0090 public slots:
0091     void Syntaxcheck();
0092     void setPlainText(const QString txt);
0093 };
0094 
0095 #endif // XMLHIGHLIGHTER_H