Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/designer/qquickdesignersupportproperties.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||
2 | ** | - | ||||||||||||||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||
5 | ** | - | ||||||||||||||||||
6 | ** This file is part of the QtQuick module of the Qt Toolkit. | - | ||||||||||||||||||
7 | ** | - | ||||||||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||
16 | ** | - | ||||||||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||
24 | ** | - | ||||||||||||||||||
25 | ** GNU General Public License Usage | - | ||||||||||||||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||
35 | ** | - | ||||||||||||||||||
36 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||
37 | ** | - | ||||||||||||||||||
38 | ****************************************************************************/ | - | ||||||||||||||||||
39 | - | |||||||||||||||||||
40 | #include "qquickdesignersupportproperties_p.h" | - | ||||||||||||||||||
41 | - | |||||||||||||||||||
42 | #include "qqmldesignermetaobject_p.h" | - | ||||||||||||||||||
43 | #include "qquickdesignercustomobjectdata_p.h" | - | ||||||||||||||||||
44 | - | |||||||||||||||||||
45 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
46 | - | |||||||||||||||||||
47 | static void addToPropertyNameListIfNotBlackListed(QQuickDesignerSupport::PropertyNameList *propertyNameList, | - | ||||||||||||||||||
48 | const QQuickDesignerSupport::PropertyName &propertyName) | - | ||||||||||||||||||
49 | { | - | ||||||||||||||||||
50 | if (!QQuickDesignerSupportProperties::isPropertyBlackListed(propertyName))
| 8-240 | ||||||||||||||||||
51 | propertyNameList->append(propertyName); executed 240 times by 1 test: propertyNameList->append(propertyName); Executed by:
| 240 | ||||||||||||||||||
52 | } executed 248 times by 1 test: end of block Executed by:
| 248 | ||||||||||||||||||
53 | - | |||||||||||||||||||
54 | void QQuickDesignerSupportProperties::createNewDynamicProperty(QObject *object, QQmlEngine *engine, const QString &name) | - | ||||||||||||||||||
55 | { | - | ||||||||||||||||||
56 | QQmlDesignerMetaObject::getNodeInstanceMetaObject(object, engine)->createNewDynamicProperty(name); | - | ||||||||||||||||||
57 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
58 | - | |||||||||||||||||||
59 | void QQuickDesignerSupportProperties::registerNodeInstanceMetaObject(QObject *object, QQmlEngine *engine) | - | ||||||||||||||||||
60 | { | - | ||||||||||||||||||
61 | // we just create one and the ownership goes automatically to the object in nodeinstance see init method | - | ||||||||||||||||||
62 | QQmlDesignerMetaObject::getNodeInstanceMetaObject(object, engine); | - | ||||||||||||||||||
63 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
64 | - | |||||||||||||||||||
65 | bool QQuickDesignerSupportProperties::hasFullImplementedListInterface(const QQmlListReference &list) | - | ||||||||||||||||||
66 | { | - | ||||||||||||||||||
67 | return list.isValid() && list.canCount() && list.canAt() && list.canAppend() && list.canClear(); never executed: return list.isValid() && list.canCount() && list.canAt() && list.canAppend() && list.canClear(); | 0 | ||||||||||||||||||
68 | } | - | ||||||||||||||||||
69 | - | |||||||||||||||||||
70 | void QQuickDesignerSupportProperties::registerCustomData(QObject *object) | - | ||||||||||||||||||
71 | { | - | ||||||||||||||||||
72 | QQuickDesignerCustomObjectData::registerData(object); | - | ||||||||||||||||||
73 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
74 | - | |||||||||||||||||||
75 | QVariant QQuickDesignerSupportProperties::getResetValue(QObject *object, const QQuickDesignerSupport::PropertyName &propertyName) | - | ||||||||||||||||||
76 | { | - | ||||||||||||||||||
77 | return QQuickDesignerCustomObjectData::getResetValue(object, propertyName); executed 8 times by 1 test: return QQuickDesignerCustomObjectData::getResetValue(object, propertyName); Executed by:
| 8 | ||||||||||||||||||
78 | } | - | ||||||||||||||||||
79 | - | |||||||||||||||||||
80 | void QQuickDesignerSupportProperties::doResetProperty(QObject *object, QQmlContext *context, const QQuickDesignerSupport::PropertyName &propertyName) | - | ||||||||||||||||||
81 | { | - | ||||||||||||||||||
82 | QQuickDesignerCustomObjectData::doResetProperty(object, context, propertyName); | - | ||||||||||||||||||
83 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
84 | - | |||||||||||||||||||
85 | bool QQuickDesignerSupportProperties::hasValidResetBinding(QObject *object, const QQuickDesignerSupport::PropertyName &propertyName) | - | ||||||||||||||||||
86 | { | - | ||||||||||||||||||
87 | return QQuickDesignerCustomObjectData::hasValidResetBinding(object, propertyName); executed 2 times by 1 test: return QQuickDesignerCustomObjectData::hasValidResetBinding(object, propertyName); Executed by:
| 2 | ||||||||||||||||||
88 | } | - | ||||||||||||||||||
89 | - | |||||||||||||||||||
90 | bool QQuickDesignerSupportProperties::hasBindingForProperty(QObject *object, | - | ||||||||||||||||||
91 | QQmlContext *context, | - | ||||||||||||||||||
92 | const QQuickDesignerSupport::PropertyName &propertyName, | - | ||||||||||||||||||
93 | bool *hasChanged) | - | ||||||||||||||||||
94 | { | - | ||||||||||||||||||
95 | return QQuickDesignerCustomObjectData::hasBindingForProperty(object, context, propertyName, hasChanged); executed 12 times by 1 test: return QQuickDesignerCustomObjectData::hasBindingForProperty(object, context, propertyName, hasChanged); Executed by:
| 12 | ||||||||||||||||||
96 | } | - | ||||||||||||||||||
97 | - | |||||||||||||||||||
98 | void QQuickDesignerSupportProperties::setPropertyBinding(QObject *object, | - | ||||||||||||||||||
99 | QQmlContext *context, | - | ||||||||||||||||||
100 | const QQuickDesignerSupport::PropertyName &propertyName, | - | ||||||||||||||||||
101 | const QString &expression) | - | ||||||||||||||||||
102 | { | - | ||||||||||||||||||
103 | QQuickDesignerCustomObjectData::setPropertyBinding(object, context, propertyName, expression); | - | ||||||||||||||||||
104 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
105 | - | |||||||||||||||||||
106 | void QQuickDesignerSupportProperties::keepBindingFromGettingDeleted(QObject *object, | - | ||||||||||||||||||
107 | QQmlContext *context, | - | ||||||||||||||||||
108 | const QQuickDesignerSupport::PropertyName &propertyName) | - | ||||||||||||||||||
109 | { | - | ||||||||||||||||||
110 | QQuickDesignerCustomObjectData::keepBindingFromGettingDeleted(object, context, propertyName); | - | ||||||||||||||||||
111 | } never executed: end of block | 0 | ||||||||||||||||||
112 | - | |||||||||||||||||||
113 | bool QQuickDesignerSupportProperties::isPropertyQObject(const QMetaProperty &metaProperty) | - | ||||||||||||||||||
114 | { | - | ||||||||||||||||||
115 | return QQmlMetaType::isQObject(metaProperty.userType()); executed 4 times by 1 test: return QQmlMetaType::isQObject(metaProperty.userType()); Executed by:
| 4 | ||||||||||||||||||
116 | } | - | ||||||||||||||||||
117 | - | |||||||||||||||||||
118 | - | |||||||||||||||||||
119 | QObject *QQuickDesignerSupportProperties::readQObjectProperty(const QMetaProperty &metaProperty, QObject *object) | - | ||||||||||||||||||
120 | { | - | ||||||||||||||||||
121 | return QQmlMetaType::toQObject(metaProperty.read(object)); executed 2 times by 1 test: return QQmlMetaType::toQObject(metaProperty.read(object)); Executed by:
| 2 | ||||||||||||||||||
122 | } | - | ||||||||||||||||||
123 | - | |||||||||||||||||||
124 | void QQuickDesignerSupportProperties::getPropertyCache(QObject *object, QQmlEngine *engine) | - | ||||||||||||||||||
125 | { | - | ||||||||||||||||||
126 | QQmlEnginePrivate::get(engine)->cache(object->metaObject()); | - | ||||||||||||||||||
127 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
128 | - | |||||||||||||||||||
129 | QQuickDesignerSupport::PropertyNameList QQuickDesignerSupportProperties::propertyNameListForWritableProperties(QObject *object, | - | ||||||||||||||||||
130 | const QQuickDesignerSupport::PropertyName &baseName, | - | ||||||||||||||||||
131 | QObjectList *inspectedObjects) | - | ||||||||||||||||||
132 | { | - | ||||||||||||||||||
133 | QQuickDesignerSupport::PropertyNameList propertyNameList; | - | ||||||||||||||||||
134 | - | |||||||||||||||||||
135 | QObjectList localObjectList; | - | ||||||||||||||||||
136 | - | |||||||||||||||||||
137 | if (inspectedObjects == nullptr)
| 4-24 | ||||||||||||||||||
138 | inspectedObjects = &localObjectList; executed 4 times by 1 test: inspectedObjects = &localObjectList; Executed by:
| 4 | ||||||||||||||||||
139 | - | |||||||||||||||||||
140 | - | |||||||||||||||||||
141 | if (inspectedObjects->contains(object))
| 4-24 | ||||||||||||||||||
142 | return propertyNameList; executed 4 times by 1 test: return propertyNameList; Executed by:
| 4 | ||||||||||||||||||
143 | - | |||||||||||||||||||
144 | inspectedObjects->append(object); | - | ||||||||||||||||||
145 | - | |||||||||||||||||||
146 | const QMetaObject *metaObject = object->metaObject(); | - | ||||||||||||||||||
147 | for (int index = 0; index < metaObject->propertyCount(); ++index) {
| 24-340 | ||||||||||||||||||
148 | QMetaProperty metaProperty = metaObject->property(index); | - | ||||||||||||||||||
149 | QQmlProperty declarativeProperty(object, QString::fromUtf8(metaProperty.name())); | - | ||||||||||||||||||
150 | if (declarativeProperty.isValid() && !declarativeProperty.isWritable() && declarativeProperty.propertyTypeCategory() == QQmlProperty::Object) {
| 0-340 | ||||||||||||||||||
151 | if (declarativeProperty.name() != QLatin1String("parent")) {
| 0-8 | ||||||||||||||||||
152 | QObject *childObject = QQmlMetaType::toQObject(declarativeProperty.read()); | - | ||||||||||||||||||
153 | if (childObject)
| 0-8 | ||||||||||||||||||
154 | propertyNameList.append(propertyNameListForWritableProperties(childObject, executed 8 times by 1 test: propertyNameList.append(propertyNameListForWritableProperties(childObject, baseName + QQuickDesignerSupport::PropertyName(metaProperty.name()) + '.', inspectedObjects)); Executed by:
| 8 | ||||||||||||||||||
155 | baseName + QQuickDesignerSupport::PropertyName(metaProperty.name()) executed 8 times by 1 test: propertyNameList.append(propertyNameListForWritableProperties(childObject, baseName + QQuickDesignerSupport::PropertyName(metaProperty.name()) + '.', inspectedObjects)); Executed by:
| 8 | ||||||||||||||||||
156 | + '.', inspectedObjects)); executed 8 times by 1 test: propertyNameList.append(propertyNameListForWritableProperties(childObject, baseName + QQuickDesignerSupport::PropertyName(metaProperty.name()) + '.', inspectedObjects)); Executed by:
| 8 | ||||||||||||||||||
157 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
158 | } else if (QQmlValueTypeFactory::valueType(metaProperty.userType())) { executed 8 times by 1 test: end of block Executed by:
| 8-316 | ||||||||||||||||||
159 | QQmlValueType *valueType = QQmlValueTypeFactory::valueType(metaProperty.userType()); | - | ||||||||||||||||||
160 | valueType->setValue(metaProperty.read(object)); | - | ||||||||||||||||||
161 | propertyNameList.append(propertyNameListForWritableProperties(valueType, | - | ||||||||||||||||||
162 | baseName + QQuickDesignerSupport::PropertyName(metaProperty.name()) | - | ||||||||||||||||||
163 | + '.', inspectedObjects)); | - | ||||||||||||||||||
164 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||
165 | - | |||||||||||||||||||
166 | if (metaProperty.isReadable() && metaProperty.isWritable()) {
| 0-340 | ||||||||||||||||||
167 | addToPropertyNameListIfNotBlackListed(&propertyNameList, | - | ||||||||||||||||||
168 | baseName + QQuickDesignerSupport::PropertyName(metaProperty.name())); | - | ||||||||||||||||||
169 | } executed 248 times by 1 test: end of block Executed by:
| 248 | ||||||||||||||||||
170 | } executed 340 times by 1 test: end of block Executed by:
| 340 | ||||||||||||||||||
171 | - | |||||||||||||||||||
172 | return propertyNameList; executed 24 times by 1 test: return propertyNameList; Executed by:
| 24 | ||||||||||||||||||
173 | } | - | ||||||||||||||||||
174 | - | |||||||||||||||||||
175 | bool QQuickDesignerSupportProperties::isPropertyBlackListed(const QQuickDesignerSupport::PropertyName &propertyName) | - | ||||||||||||||||||
176 | { | - | ||||||||||||||||||
177 | if (propertyName.contains(".") && propertyName.contains("__"))
| 0-156 | ||||||||||||||||||
178 | return true; never executed: return true; | 0 | ||||||||||||||||||
179 | - | |||||||||||||||||||
180 | if (propertyName.count(".") > 1)
| 8-252 | ||||||||||||||||||
181 | return true; executed 8 times by 1 test: return true; Executed by:
| 8 | ||||||||||||||||||
182 | - | |||||||||||||||||||
183 | return false; executed 252 times by 1 test: return false; Executed by:
| 252 | ||||||||||||||||||
184 | } | - | ||||||||||||||||||
185 | - | |||||||||||||||||||
186 | QQuickDesignerSupport::PropertyNameList QQuickDesignerSupportProperties::allPropertyNames(QObject *object, | - | ||||||||||||||||||
187 | const QQuickDesignerSupport::PropertyName &baseName, | - | ||||||||||||||||||
188 | QObjectList *inspectedObjects) | - | ||||||||||||||||||
189 | { | - | ||||||||||||||||||
190 | QQuickDesignerSupport::PropertyNameList propertyNameList; | - | ||||||||||||||||||
191 | - | |||||||||||||||||||
192 | QObjectList localObjectList; | - | ||||||||||||||||||
193 | - | |||||||||||||||||||
194 | if (inspectedObjects == nullptr)
| 0 | ||||||||||||||||||
195 | inspectedObjects = &localObjectList; never executed: inspectedObjects = &localObjectList; | 0 | ||||||||||||||||||
196 | - | |||||||||||||||||||
197 | - | |||||||||||||||||||
198 | if (inspectedObjects->contains(object))
| 0 | ||||||||||||||||||
199 | return propertyNameList; never executed: return propertyNameList; | 0 | ||||||||||||||||||
200 | - | |||||||||||||||||||
201 | inspectedObjects->append(object); | - | ||||||||||||||||||
202 | - | |||||||||||||||||||
203 | - | |||||||||||||||||||
204 | const QMetaObject *metaObject = object->metaObject(); | - | ||||||||||||||||||
205 | - | |||||||||||||||||||
206 | QStringList deferredPropertyNames; | - | ||||||||||||||||||
207 | const int namesIndex = metaObject->indexOfClassInfo("DeferredPropertyNames"); | - | ||||||||||||||||||
208 | if (namesIndex != -1) {
| 0 | ||||||||||||||||||
209 | QMetaClassInfo classInfo = metaObject->classInfo(namesIndex); | - | ||||||||||||||||||
210 | deferredPropertyNames = QString::fromUtf8(classInfo.value()).split(QLatin1Char(',')); | - | ||||||||||||||||||
211 | } never executed: end of block | 0 | ||||||||||||||||||
212 | - | |||||||||||||||||||
213 | for (int index = 0; index < metaObject->propertyCount(); ++index) {
| 0 | ||||||||||||||||||
214 | QMetaProperty metaProperty = metaObject->property(index); | - | ||||||||||||||||||
215 | QQmlProperty declarativeProperty(object, QString::fromUtf8(metaProperty.name())); | - | ||||||||||||||||||
216 | if (declarativeProperty.isValid() && declarativeProperty.propertyTypeCategory() == QQmlProperty::Object) {
| 0 | ||||||||||||||||||
217 | if (declarativeProperty.name() != QLatin1String("parent")
| 0 | ||||||||||||||||||
218 | && !deferredPropertyNames.contains(declarativeProperty.name())) {
| 0 | ||||||||||||||||||
219 | QObject *childObject = QQmlMetaType::toQObject(declarativeProperty.read()); | - | ||||||||||||||||||
220 | if (childObject)
| 0 | ||||||||||||||||||
221 | propertyNameList.append(allPropertyNames(childObject, never executed: propertyNameList.append(allPropertyNames(childObject, baseName + QQuickDesignerSupport::PropertyName(metaProperty.name()) + '.', inspectedObjects)); | 0 | ||||||||||||||||||
222 | baseName never executed: propertyNameList.append(allPropertyNames(childObject, baseName + QQuickDesignerSupport::PropertyName(metaProperty.name()) + '.', inspectedObjects)); | 0 | ||||||||||||||||||
223 | + QQuickDesignerSupport::PropertyName(metaProperty.name()) never executed: propertyNameList.append(allPropertyNames(childObject, baseName + QQuickDesignerSupport::PropertyName(metaProperty.name()) + '.', inspectedObjects)); | 0 | ||||||||||||||||||
224 | + '.', inspectedObjects)); never executed: propertyNameList.append(allPropertyNames(childObject, baseName + QQuickDesignerSupport::PropertyName(metaProperty.name()) + '.', inspectedObjects)); | 0 | ||||||||||||||||||
225 | } never executed: end of block | 0 | ||||||||||||||||||
226 | } else if (QQmlValueTypeFactory::valueType(metaProperty.userType())) { never executed: end of block
| 0 | ||||||||||||||||||
227 | QQmlValueType *valueType = QQmlValueTypeFactory::valueType(metaProperty.userType()); | - | ||||||||||||||||||
228 | valueType->setValue(metaProperty.read(object)); | - | ||||||||||||||||||
229 | propertyNameList.append(baseName + QQuickDesignerSupport::PropertyName(metaProperty.name())); | - | ||||||||||||||||||
230 | propertyNameList.append(allPropertyNames(valueType, | - | ||||||||||||||||||
231 | baseName | - | ||||||||||||||||||
232 | + QQuickDesignerSupport::PropertyName(metaProperty.name()) | - | ||||||||||||||||||
233 | + '.', inspectedObjects)); | - | ||||||||||||||||||
234 | } else { never executed: end of block | 0 | ||||||||||||||||||
235 | addToPropertyNameListIfNotBlackListed(&propertyNameList, | - | ||||||||||||||||||
236 | baseName + QQuickDesignerSupport::PropertyName(metaProperty.name())); | - | ||||||||||||||||||
237 | } never executed: end of block | 0 | ||||||||||||||||||
238 | } | - | ||||||||||||||||||
239 | - | |||||||||||||||||||
240 | return propertyNameList; never executed: return propertyNameList; | 0 | ||||||||||||||||||
241 | } | - | ||||||||||||||||||
242 | - | |||||||||||||||||||
243 | - | |||||||||||||||||||
244 | QT_END_NAMESPACE | - | ||||||||||||||||||
245 | - | |||||||||||||||||||
246 | - | |||||||||||||||||||
247 | - | |||||||||||||||||||
248 | - | |||||||||||||||||||
Source code | Switch to Preprocessed file |