| 1 | #pragma once |
| 2 | |
| 3 | // QCodeEditor |
| 4 | #include <QStyleSyntaxHighlighter> // Required for inheritance |
| 5 | #include <QHighlightRule> |
| 6 | |
| 7 | // Qt |
| 8 | #include <QVector> |
| 9 | |
| 10 | /** |
| 11 | * @brief Class, that describes JSON code |
| 12 | * highlighter. |
| 13 | */ |
| 14 | class QJSONHighlighter : public QStyleSyntaxHighlighter |
| 15 | { |
| 16 | Q_OBJECT |
| 17 | public: |
| 18 | |
| 19 | /** |
| 20 | * @brief Constructor. |
| 21 | * @param document Pointer to document. |
| 22 | */ |
| 23 | explicit QJSONHighlighter(QTextDocument* document=nullptr); |
| 24 | |
| 25 | protected: |
| 26 | |
| 27 | void highlightBlock(const QString& text) override; |
| 28 | |
| 29 | private: |
| 30 | QVector<QHighlightRule> m_highlightRules; |
| 31 | QRegularExpression m_keyRegex; |
| 32 | }; |
| 33 |