| 1 | // Copyright (C) 2021 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
| 3 | |
| 4 | #ifndef QMLPROPERTYNODE_H |
| 5 | #define QMLPROPERTYNODE_H |
| 6 | |
| 7 | #include "aggregate.h" |
| 8 | #include "nativeenum.h" |
| 9 | #include "node.h" |
| 10 | |
| 11 | #include <QtCore/qglobal.h> |
| 12 | #include <QtCore/qstring.h> |
| 13 | |
| 14 | QT_BEGIN_NAMESPACE |
| 15 | |
| 16 | class QmlPropertyNode : public Node, public NativeEnumInterface |
| 17 | { |
| 18 | public: |
| 19 | QmlPropertyNode(Aggregate *parent, const QString &name, QString type, bool attached); |
| 20 | |
| 21 | void setDataType(const QString &dataType) override; |
| 22 | void setStored(bool stored) { m_stored = toFlagValue(b: stored); } |
| 23 | void setDefaultValue(const QString &value) { m_defaultValue = value; } |
| 24 | void setRequired() { m_required = toFlagValue(b: true); } |
| 25 | void setIsList(bool isList); |
| 26 | |
| 27 | [[nodiscard]] const QString &dataType() const { return m_type; } |
| 28 | [[nodiscard]] bool validateDataType(const QString &type = QString()) const; |
| 29 | [[nodiscard]] const QString &defaultValue() const { return m_defaultValue; } |
| 30 | [[nodiscard]] bool isStored() const { return fromFlagValue(fv: m_stored, defaultValue: true); } |
| 31 | bool isRequired(); |
| 32 | [[nodiscard]] bool isDefault() const override { return m_isDefault; } |
| 33 | [[nodiscard]] bool isReadOnly() const { return fromFlagValue(fv: m_readOnly, defaultValue: false); } |
| 34 | [[nodiscard]] bool isReadOnly(); |
| 35 | [[nodiscard]] bool isAlias() const override { return m_isAlias; } |
| 36 | [[nodiscard]] bool isAttached() const override { return m_attached; } |
| 37 | [[nodiscard]] QString qmlTypeName() const override { return parent()->qmlTypeName(); } |
| 38 | [[nodiscard]] QString logicalModuleName() const override |
| 39 | { |
| 40 | return parent()->logicalModuleName(); |
| 41 | } |
| 42 | [[nodiscard]] QString logicalModuleVersion() const override |
| 43 | { |
| 44 | return parent()->logicalModuleVersion(); |
| 45 | } |
| 46 | [[nodiscard]] QString logicalModuleIdentifier() const override |
| 47 | { |
| 48 | return parent()->logicalModuleIdentifier(); |
| 49 | } |
| 50 | [[nodiscard]] QString element() const override { return parent()->name(); } |
| 51 | NativeEnum *nativeEnum() override { return &m_nativeEnum; } |
| 52 | const NativeEnum *nativeEnum() const override { return &m_nativeEnum; } |
| 53 | |
| 54 | void markDefault() override { m_isDefault = true; } |
| 55 | void markReadOnly(bool flag) override { m_readOnly = toFlagValue(b: flag); } |
| 56 | |
| 57 | private: |
| 58 | PropertyNode *findCorrespondingCppProperty(); |
| 59 | |
| 60 | private: |
| 61 | QString m_type {}; |
| 62 | QString m_defaultValue {}; |
| 63 | FlagValue m_stored { FlagValueDefault }; |
| 64 | bool m_isAlias { false }; |
| 65 | bool m_isDefault { false }; |
| 66 | bool m_attached {}; |
| 67 | FlagValue m_isList { FlagValueDefault }; |
| 68 | FlagValue m_readOnly { FlagValueDefault }; |
| 69 | FlagValue m_required { FlagValueDefault }; |
| 70 | NativeEnum m_nativeEnum; |
| 71 | static QSet<QString> cppQmlValueTypes; |
| 72 | static QRegularExpression cppBasicList; |
| 73 | static QRegularExpression qmlBasicList; |
| 74 | }; |
| 75 | |
| 76 | QT_END_NAMESPACE |
| 77 | |
| 78 | #endif // QMLPROPERTYNODE_H |
| 79 |
