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 "node.h"
9
10#include <QtCore/qglobal.h>
11#include <QtCore/qstring.h>
12
13QT_BEGIN_NAMESPACE
14
15class QmlPropertyNode : public Node
16{
17public:
18 QmlPropertyNode(Aggregate *parent, const QString &name, QString type, bool attached);
19
20 void setDataType(const QString &dataType) override { m_type = dataType; }
21 void setStored(bool stored) { m_stored = toFlagValue(b: stored); }
22 void setDefaultValue(const QString &value) { m_defaultValue = value; }
23 void setRequired() { m_required = toFlagValue(b: true); }
24
25 [[nodiscard]] const QString &dataType() const { return m_type; }
26 [[nodiscard]] const QString &defaultValue() const { return m_defaultValue; }
27 [[nodiscard]] bool isStored() const { return fromFlagValue(fv: m_stored, defaultValue: true); }
28 bool isRequired();
29 [[nodiscard]] bool isDefault() const override { return m_isDefault; }
30 [[nodiscard]] bool isReadOnly() const { return fromFlagValue(fv: m_readOnly, defaultValue: false); }
31 [[nodiscard]] bool isReadOnly();
32 [[nodiscard]] bool isAlias() const override { return m_isAlias; }
33 [[nodiscard]] bool isAttached() const override { return m_attached; }
34 [[nodiscard]] bool isQtQuickNode() const override { return parent()->isQtQuickNode(); }
35 [[nodiscard]] QString qmlTypeName() const override { return parent()->qmlTypeName(); }
36 [[nodiscard]] QString logicalModuleName() const override
37 {
38 return parent()->logicalModuleName();
39 }
40 [[nodiscard]] QString logicalModuleVersion() const override
41 {
42 return parent()->logicalModuleVersion();
43 }
44 [[nodiscard]] QString logicalModuleIdentifier() const override
45 {
46 return parent()->logicalModuleIdentifier();
47 }
48 [[nodiscard]] QString element() const override { return parent()->name(); }
49
50 void markDefault() override { m_isDefault = true; }
51 void markReadOnly(bool flag) override { m_readOnly = toFlagValue(b: flag); }
52
53private:
54 PropertyNode *findCorrespondingCppProperty();
55
56private:
57 QString m_type {};
58 QString m_defaultValue {};
59 FlagValue m_stored { FlagValueDefault };
60 bool m_isAlias { false };
61 bool m_isDefault { false };
62 bool m_attached {};
63 FlagValue m_readOnly { FlagValueDefault };
64 FlagValue m_required { FlagValueDefault };
65};
66
67QT_END_NAMESPACE
68
69#endif // QMLPROPERTYNODE_H
70

source code of qttools/src/qdoc/qdoc/qmlpropertynode.h