| 1 | #pragma once |
| 2 | |
| 3 | // Qt |
| 4 | #include <QObject> // Required for inheritance |
| 5 | #include <QMap> |
| 6 | #include <QString> |
| 7 | #include <QTextCharFormat> |
| 8 | |
| 9 | /** |
| 10 | * @brief Class, that describes Qt style |
| 11 | * parser for QCodeEditor. |
| 12 | */ |
| 13 | class QSyntaxStyle : public QObject |
| 14 | { |
| 15 | Q_OBJECT |
| 16 | |
| 17 | public: |
| 18 | |
| 19 | /** |
| 20 | * @brief Constructor. |
| 21 | * @param parent Pointer to parent QObject |
| 22 | */ |
| 23 | explicit QSyntaxStyle(QObject* parent=nullptr); |
| 24 | |
| 25 | /** |
| 26 | * @brief Method for loading and parsing |
| 27 | * style. |
| 28 | * @param fl Style. |
| 29 | * @return Success. |
| 30 | */ |
| 31 | bool load(QString fl); |
| 32 | |
| 33 | /** |
| 34 | * @brief Method for getting style name. |
| 35 | * @return Name. |
| 36 | */ |
| 37 | QString name() const; |
| 38 | |
| 39 | /** |
| 40 | * @brief Method for checking is syntax style loaded. |
| 41 | * @return Is loaded. |
| 42 | */ |
| 43 | bool isLoaded() const; |
| 44 | |
| 45 | /** |
| 46 | * @brief Method for getting format for property |
| 47 | * name. |
| 48 | * @param name Property name. |
| 49 | * @return Text char format. |
| 50 | */ |
| 51 | QTextCharFormat getFormat(QString name) const; |
| 52 | |
| 53 | /** |
| 54 | * @brief Static method for getting default style. |
| 55 | * @return Pointer to default style. |
| 56 | */ |
| 57 | static QSyntaxStyle* defaultStyle(); |
| 58 | |
| 59 | private: |
| 60 | |
| 61 | QString m_name; |
| 62 | |
| 63 | QMap< |
| 64 | QString, |
| 65 | QTextCharFormat |
| 66 | > m_data; |
| 67 | |
| 68 | bool m_loaded; |
| 69 | }; |
| 70 |