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