Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickdesignersupportproperties.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
8
10
12 const QQuickDesignerSupport::PropertyName &propertyName)
13{
15 propertyNameList->append(propertyName);
16}
17
22
24{
25 // we just create one and the ownership goes automatically to the object in nodeinstance see init method
27}
28
30{
31 return list.isValid() && list.canCount() && list.canAt() && list.canAppend() && list.canClear();
32}
33
38
43
48
53
56 const QQuickDesignerSupport::PropertyName &propertyName,
57 bool *hasChanged)
58{
59 return QQuickDesignerCustomObjectData::hasBindingForProperty(object, context, propertyName, hasChanged);
60}
61
64 const QQuickDesignerSupport::PropertyName &propertyName,
65 const QString &expression)
66{
67 QQuickDesignerCustomObjectData::setPropertyBinding(object, context, propertyName, expression);
68}
69
76
78{
79 return metaProperty.metaType().flags().testFlag(QMetaType::PointerToQObject);
80}
81
82
84{
85 return QQmlMetaType::toQObject(metaProperty.read(object));
86}
87
92
95 QObjectList *inspectedObjects,
96 int depth = 0)
97{
99
100 if (depth > 2)
101 return propertyNameList;
102
103 if (!inspectedObjects->contains(object))
104 inspectedObjects->append(object);
105
106 const QMetaObject *metaObject = object->metaObject();
107 for (int index = 0; index < metaObject->propertyCount(); ++index) {
108 QMetaProperty metaProperty = metaObject->property(index);
109 QQmlProperty declarativeProperty(object, QString::fromUtf8(metaProperty.name()));
110 if (declarativeProperty.isValid() && !declarativeProperty.isWritable() && declarativeProperty.propertyTypeCategory() == QQmlProperty::Object) {
111 if (declarativeProperty.name() != QLatin1String("parent")) {
112 QObject *childObject = QQmlMetaType::toQObject(declarativeProperty.read());
113 if (childObject)
114 propertyNameList.append(propertyNameListForWritableProperties(childObject,
115 baseName + QQuickDesignerSupport::PropertyName(metaProperty.name())
116 + '.', inspectedObjects,
117 depth + 1));
118 }
119 } else if (QQmlGadgetPtrWrapper *valueType
120 = QQmlGadgetPtrWrapper::instance(qmlEngine(object), metaProperty.metaType())) {
121 valueType->setValue(metaProperty.read(object));
122 propertyNameList.append(propertyNameListForWritableProperties(valueType,
123 baseName + QQuickDesignerSupport::PropertyName(metaProperty.name())
124 + '.', inspectedObjects,
125 depth + 1));
126 }
127
128 if (metaProperty.isReadable() && metaProperty.isWritable()) {
130 baseName + QQuickDesignerSupport::PropertyName(metaProperty.name()));
131 }
132 }
133
134 return propertyNameList;
135}
136
138{
139 QObjectList localObjectList;
140 return ::propertyNameListForWritableProperties(object, {}, &localObjectList);
141}
142
144{
145 if (propertyName.contains(".") && propertyName.contains("__"))
146 return true;
147
148 if (propertyName.count(".") > 1)
149 return true;
150
151 return false;
152}
153
156 QObjectList *inspectedObjects,
157 int depth)
158{
160
161 QObjectList localObjectList;
162
163 if (inspectedObjects == nullptr)
164 inspectedObjects = &localObjectList;
165
166 if (depth > 2)
167 return propertyNameList;
168
169 if (!inspectedObjects->contains(object))
170 inspectedObjects->append(object);
171
172 const QMetaObject *metaObject = object->metaObject();
173
174 QStringList deferredPropertyNames;
175 const int namesIndex = metaObject->indexOfClassInfo("DeferredPropertyNames");
176 if (namesIndex != -1) {
177 QMetaClassInfo classInfo = metaObject->classInfo(namesIndex);
178 deferredPropertyNames = QString::fromUtf8(classInfo.value()).split(QLatin1Char(','));
179 }
180
181 for (int index = 0; index < metaObject->propertyCount(); ++index) {
182 QMetaProperty metaProperty = metaObject->property(index);
183 QQmlProperty declarativeProperty(object, QString::fromUtf8(metaProperty.name()));
184 if (declarativeProperty.isValid() && declarativeProperty.propertyTypeCategory() == QQmlProperty::Object) {
185 if (declarativeProperty.name() != QLatin1String("parent")
186 && !deferredPropertyNames.contains(declarativeProperty.name())) {
187 QObject *childObject = QQmlMetaType::toQObject(declarativeProperty.read());
188 if (childObject)
189 propertyNameList.append(allPropertyNames(childObject,
190 baseName
192 + '.', inspectedObjects,
193 depth + 1));
194 }
195 } else if (QQmlGadgetPtrWrapper *valueType
196 = QQmlGadgetPtrWrapper::instance(qmlEngine(object), metaProperty.metaType())) {
197 valueType->setValue(metaProperty.read(object));
198 propertyNameList.append(baseName + QQuickDesignerSupport::PropertyName(metaProperty.name()));
199 propertyNameList.append(allPropertyNames(valueType,
200 baseName
202 + '.', inspectedObjects,
203 depth + 1));
204 } else {
206 baseName + QQuickDesignerSupport::PropertyName(metaProperty.name()));
207 }
208 }
209
210 return propertyNameList;
211}
212
213
215
216
217
218
\inmodule QtCore
Definition qbytearray.h:57
bool contains(char c) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qbytearray.h:660
qsizetype count(char c) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void append(parameter_type t)
Definition qlist.h:458
\inmodule QtCore
\inmodule QtCore
QMetaType metaType() const
QVariant read(const QObject *obj) const
Reads the property's value from the given object.
bool isWritable() const
Returns true if this property is writable; otherwise returns false.
const char * name() const
Returns this property's name.
bool isReadable() const
Returns true if this property is readable; otherwise returns false.
constexpr TypeFlags flags() const
Definition qmetatype.h:2658
@ PointerToQObject
Definition qmetatype.h:406
\inmodule QtCore
Definition qobject.h:103
The QQmlContext class defines a context within a QML engine.
Definition qqmlcontext.h:25
static QQmlDesignerMetaObject * getNodeInstanceMetaObject(QObject *object, QQmlEngine *engine)
The QQmlEngine class provides an environment for instantiating QML components.
Definition qqmlengine.h:57
static QQmlGadgetPtrWrapper * instance(QQmlEngine *engine, QMetaType type)
The QQmlListReference class allows the manipulation of QQmlListProperty properties.
Definition qqmllist.h:183
static QObject * toQObject(const QVariant &, bool *ok=nullptr)
static QQmlPropertyCache::ConstPtr propertyCache(QObject *object, QTypeRevision version=QTypeRevision())
Returns a QQmlPropertyCache for obj if one is available.
The QQmlProperty class abstracts accessing properties on objects created from QML.
static void doResetProperty(QObject *object, QQmlContext *context, const QQuickDesignerSupport::PropertyName &propertyName)
static void setPropertyBinding(QObject *object, QQmlContext *context, const QQuickDesignerSupport::PropertyName &propertyName, const QString &expression)
static bool hasValidResetBinding(QObject *object, const QQuickDesignerSupport::PropertyName &propertyName)
static QVariant getResetValue(QObject *object, const QQuickDesignerSupport::PropertyName &propertyName)
static bool hasBindingForProperty(QObject *object, QQmlContext *context, const QQuickDesignerSupport::PropertyName &propertyName, bool *hasChanged)
static void keepBindingFromGettingDeleted(QObject *object, QQmlContext *context, const QQuickDesignerSupport::PropertyName &propertyName)
static QQuickDesignerSupport::PropertyNameList allPropertyNames(QObject *object, const QQuickDesignerSupport::PropertyName &baseName=QQuickDesignerSupport::PropertyName(), QObjectList *inspectedObjects=nullptr, int depth=0)
static QObject * readQObjectProperty(const QMetaProperty &metaProperty, QObject *object)
static void registerNodeInstanceMetaObject(QObject *object, QQmlEngine *engine)
static void keepBindingFromGettingDeleted(QObject *object, QQmlContext *context, const QQuickDesignerSupport::PropertyName &propertyName)
static QQuickDesignerSupport::PropertyNameList propertyNameListForWritableProperties(QObject *object)
static bool isPropertyQObject(const QMetaProperty &metaProperty)
static QVariant getResetValue(QObject *object, const QQuickDesignerSupport::PropertyName &propertyName)
static bool hasFullImplementedListInterface(const QQmlListReference &list)
static bool isPropertyBlackListed(const QQuickDesignerSupport::PropertyName &propertyName)
static void doResetProperty(QObject *object, QQmlContext *context, const QQuickDesignerSupport::PropertyName &propertyName)
static bool hasBindingForProperty(QObject *object, QQmlContext *context, const QQuickDesignerSupport::PropertyName &propertyName, bool *hasChanged)
static bool hasValidResetBinding(QObject *object, const QQuickDesignerSupport::PropertyName &propertyName)
static void createNewDynamicProperty(QObject *object, QQmlEngine *engine, const QString &name)
static void setPropertyBinding(QObject *object, QQmlContext *context, const QQuickDesignerSupport::PropertyName &propertyName, const QString &expression)
QList< PropertyName > PropertyNameList
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:6018
\inmodule QtCore
Definition qvariant.h:65
Combined button and popup list for selecting options.
static void * context
GLint GLenum GLsizei GLsizei GLsizei depth
GLuint index
[2]
GLuint object
[3]
GLuint name
QQmlEngine * qmlEngine(const QObject *obj)
Definition qqml.cpp:80
static QQuickDesignerSupport::PropertyNameList propertyNameListForWritableProperties(QObject *object, const QQuickDesignerSupport::PropertyName &baseName, QObjectList *inspectedObjects, int depth=0)
static QT_BEGIN_NAMESPACE void addToPropertyNameListIfNotBlackListed(QQuickDesignerSupport::PropertyNameList *propertyNameList, const QQuickDesignerSupport::PropertyName &propertyName)
QList< int > list
[14]
obj metaObject() -> className()
QJSEngine engine
[0]
\inmodule QtCore \reentrant
Definition qchar.h:18
\inmodule QtCore