Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/types/qqmllistmodel_p_p.h |
Switch to Source code | Preprocessed file |
Line | Source | Count |
---|---|---|
1 | - | |
2 | static_assert(bool(1 == 1), "Required feature " "qml_list_model" " for file " __FILE__ " not available."); | - |
3 | - | |
4 | - | |
5 | - | |
6 | - | |
7 | class DynamicRoleModelNode; | - |
8 | - | |
9 | class DynamicRoleModelNodeMetaObject : public QQmlOpenMetaObject | - |
10 | { | - |
11 | public: | - |
12 | DynamicRoleModelNodeMetaObject(DynamicRoleModelNode *object); | - |
13 | ~DynamicRoleModelNodeMetaObject(); | - |
14 | - | |
15 | bool m_enabled; | - |
16 | - | |
17 | protected: | - |
18 | void propertyWrite(int index) override; | - |
19 | void propertyWritten(int index) override; | - |
20 | - | |
21 | private: | - |
22 | DynamicRoleModelNode *m_owner; | - |
23 | }; | - |
24 | - | |
25 | class DynamicRoleModelNode : public QObject | - |
26 | { | - |
27 | public: | - |
28 | #pragma GCC diagnostic push | - |
29 | - | |
30 | #pragma GCC diagnostic ignored "-Wsuggest-override" | - |
31 | static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: | - |
32 | #pragma GCC diagnostic ignored "-Wattributes" | - |
33 | __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); | - |
34 | #pragma GCC diagnostic pop | - |
35 | struct QPrivateSignal {}; | - |
36 | public: | - |
37 | DynamicRoleModelNode(QQmlListModel *owner, int uid); | - |
38 | - | |
39 | static DynamicRoleModelNode *create(const QVariantMap &obj, QQmlListModel *owner); | - |
40 | - | |
41 | void updateValues(const QVariantMap &object, QVector<int> &roles); | - |
42 | - | |
43 | QVariant getValue(const QString &name) const | - |
44 | { | - |
45 | return executed 102 times by 2 tests: m_meta->value(name.toUtf8());return m_meta->value(name.toUtf8()); Executed by:
executed 102 times by 2 tests: return m_meta->value(name.toUtf8()); Executed by:
| 102 |
46 | } | - |
47 | - | |
48 | bool setValue(const QByteArray &name, const QVariant &val) | - |
49 | { | - |
50 | return executed 1172 times by 2 tests: m_meta->setValue(name, val);return m_meta->setValue(name, val); Executed by:
executed 1172 times by 2 tests: return m_meta->setValue(name, val); Executed by:
| 1172 |
51 | } | - |
52 | - | |
53 | void setNodeUpdatesEnabled(bool enable) | - |
54 | { | - |
55 | m_meta->m_enabled = enable; | - |
56 | } executed 2238 times by 2 tests: end of block Executed by:
| 2238 |
57 | - | |
58 | int getUid() const | - |
59 | { | - |
60 | return executed 3452 times by 1 test: m_uid;return m_uid; Executed by:
executed 3452 times by 1 test: return m_uid; Executed by:
| 3452 |
61 | } | - |
62 | - | |
63 | static QVector<int> sync(DynamicRoleModelNode *src, DynamicRoleModelNode *target); | - |
64 | - | |
65 | private: | - |
66 | QQmlListModel *m_owner; | - |
67 | int m_uid; | - |
68 | DynamicRoleModelNodeMetaObject *m_meta; | - |
69 | - | |
70 | friend class DynamicRoleModelNodeMetaObject; | - |
71 | }; | - |
72 | - | |
73 | class ModelNodeMetaObject : public QQmlOpenMetaObject | - |
74 | { | - |
75 | public: | - |
76 | ModelNodeMetaObject(QObject *object, QQmlListModel *model, int elementIndex); | - |
77 | ~ModelNodeMetaObject(); | - |
78 | - | |
79 | QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *object) override; | - |
80 | - | |
81 | static ModelNodeMetaObject *get(QObject *obj); | - |
82 | - | |
83 | bool m_enabled; | - |
84 | QQmlListModel *m_model; | - |
85 | int m_elementIndex; | - |
86 | - | |
87 | void updateValues(); | - |
88 | void updateValues(const QVector<int> &roles); | - |
89 | - | |
90 | bool initialized() const { return executed 58 times by 2 tests: m_initialized;return m_initialized; Executed by:
executed 58 times by 2 tests: }return m_initialized; Executed by:
| 58 |
91 | - | |
92 | protected: | - |
93 | void propertyWritten(int index) override; | - |
94 | - | |
95 | private: | - |
96 | using QQmlOpenMetaObject::setValue; | - |
97 | - | |
98 | void emitDirectNotifies(const int *changedRoles, int roleCount); | - |
99 | - | |
100 | void initialize(); | - |
101 | bool m_initialized; | - |
102 | }; | - |
103 | - | |
104 | namespace QV4 { | - |
105 | - | |
106 | namespace Heap { | - |
107 | - | |
108 | struct ModelObject : public QObjectWrapper { | - |
109 | void init(QObject *object, QQmlListModel *model) | - |
110 | { | - |
111 | QObjectWrapper::init(object); | - |
112 | m_model = model; | - |
113 | QObjectPrivate *op = QObjectPrivate::get(object); | - |
114 | m_nodeModelMetaObject = static_cast<ModelNodeMetaObject *>(op->metaObject); | - |
115 | } executed 660 times by 8 tests: end of block Executed by:
| 660 |
116 | void destroy() { QObjectWrapper::destroy(); } executed 660 times by 8 tests: end of block Executed by:
| 660 |
117 | int elementIndex() const { return executed 922 times by 8 tests: m_nodeModelMetaObject->m_elementIndex;return m_nodeModelMetaObject->m_elementIndex; Executed by:
executed 922 times by 8 tests: }return m_nodeModelMetaObject->m_elementIndex; Executed by:
| 922 |
118 | QQmlListModel *m_model; | - |
119 | ModelNodeMetaObject *m_nodeModelMetaObject; | - |
120 | }; | - |
121 | - | |
122 | } | - |
123 | - | |
124 | struct ModelObject : public QObjectWrapper | - |
125 | { | - |
126 | private: ModelObject() = delete; ModelObject(const ModelObject &) = delete; ModelObject &operator=(const ModelObject &) = delete; public: template <typename Type> inline void qt_check_for_QMANAGED_macro(const Type *_q_argument) const { int i = qYouForgotTheQ_MANAGED_Macro(this, _q_argument); i = i + 1; } never executed: typedef QV4::Heap::ModelObject Data; typedef QObjectWrapper SuperClass; static const QV4::VTable static_vtbl; static inline const QV4::VTable *staticVTable() { returnend of block executed 1980 times by 8 tests: &static_vtbl;return &static_vtbl; Executed by:
executed 1980 times by 8 tests: } void __dataTest() { static_assert (sizeof(*this) == sizeof(Managed), "Classes derived from Managed can't have own data members."); }return &static_vtbl; Executed by:
never executed: QV4::Heap::ModelObject *d_unchecked() const { returnend of block executed 4102 times by 8 tests: static_cast<QV4::Heap::ModelObject *>(m());return static_cast<QV4::Heap::ModelObject *>(m()); Executed by:
executed 4102 times by 8 tests: } QV4::Heap::ModelObject *d() const { QV4::Heap::ModelObject *dptr = d_unchecked(); dptr->_checkIsInitialized(); returnreturn static_cast<QV4::Heap::ModelObject *>(m()); Executed by:
executed 3442 times by 8 tests: dptr;return dptr; Executed by:
executed 3442 times by 8 tests: } static_assert(bool(std::is_trivial< QV4::Heap::ModelObject >::value), "std::is_trivial< QV4::Heap::ModelObject >::value");return dptr; Executed by:
| 0-4102 |
127 | static void virtualDestroy(QV4::Heap::Base *b) { static_cast<Data *>(b)->destroy(); } executed 660 times by 8 tests: end of block Executed by:
| 660 |
128 | - | |
129 | protected: | - |
130 | static bool virtualPut(Managed *m, PropertyKey id, const Value& value, Value *receiver); | - |
131 | static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); | - |
132 | static void virtualAdvanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes); | - |
133 | }; | - |
134 | - | |
135 | } | - |
136 | - | |
137 | class ListLayout | - |
138 | { | - |
139 | public: | - |
140 | ListLayout() : currentBlock(0), currentBlockOffset(0) {} executed 2584 times by 15 tests: end of block Executed by:
| 2584 |
141 | ListLayout(const ListLayout *other); | - |
142 | ~ListLayout(); | - |
143 | - | |
144 | class Role | - |
145 | { | - |
146 | public: | - |
147 | - | |
148 | Role() : type(Invalid), blockIndex(-1), blockOffset(-1), index(-1), subLayout(0) {} executed 2118 times by 15 tests: end of block Executed by:
| 2118 |
149 | explicit Role(const Role *other); | - |
150 | ~Role(); | - |
151 | - | |
152 | - | |
153 | enum DataType | - |
154 | { | - |
155 | Invalid = -1, | - |
156 | - | |
157 | String, | - |
158 | Number, | - |
159 | Bool, | - |
160 | List, | - |
161 | QObject, | - |
162 | VariantMap, | - |
163 | DateTime, | - |
164 | Function, | - |
165 | - | |
166 | MaxDataType | - |
167 | }; | - |
168 | - | |
169 | QString name; | - |
170 | DataType type; | - |
171 | int blockIndex; | - |
172 | int blockOffset; | - |
173 | int index; | - |
174 | ListLayout *subLayout; | - |
175 | }; | - |
176 | - | |
177 | const Role *getRoleOrCreate(const QString &key, const QVariant &data); | - |
178 | const Role &getRoleOrCreate(QV4::String *key, Role::DataType type); | - |
179 | const Role &getRoleOrCreate(const QString &key, Role::DataType type); | - |
180 | - | |
181 | const Role &getExistingRole(int index) const { return executed 25109 times by 15 tests: *roles.at(index);return *roles.at(index); Executed by:
executed 25109 times by 15 tests: }return *roles.at(index); Executed by:
| 25109 |
182 | const Role *getExistingRole(const QString &key) const; | - |
183 | const Role *getExistingRole(QV4::String *key) const; | - |
184 | - | |
185 | int roleCount() const { return executed 32663 times by 15 tests: roles.count();return roles.count(); Executed by:
executed 32663 times by 15 tests: }return roles.count(); Executed by:
| 32663 |
186 | - | |
187 | static void sync(ListLayout *src, ListLayout *target); | - |
188 | - | |
189 | private: | - |
190 | const Role &createRole(const QString &key, Role::DataType type); | - |
191 | - | |
192 | int currentBlock; | - |
193 | int currentBlockOffset; | - |
194 | QVector<Role *> roles; | - |
195 | QStringHash<Role *> roleHash; | - |
196 | }; | - |
197 | - | |
198 | struct StringOrTranslation | - |
199 | { | - |
200 | explicit StringOrTranslation(const QString &s); | - |
201 | explicit StringOrTranslation(const QV4::CompiledData::Binding *binding); | - |
202 | ~StringOrTranslation(); | - |
203 | bool isSet() const { return executed 14227 times by 14 tests: d.flag();return d.flag(); Executed by:
executed 14227 times by 14 tests: }return d.flag(); Executed by:
| 14227 |
204 | bool isTranslation() const { return executed 6 times by 2 tests: d.isT2();return d.isT2(); Executed by:
executed 6 times by 2 tests: }return d.isT2(); Executed by:
| 6 |
205 | void setString(const QString &s); | - |
206 | void setTranslation(const QV4::CompiledData::Binding *binding); | - |
207 | QString toString(const QQmlListModel *owner) const; | - |
208 | QString asString() const; | - |
209 | private: | - |
210 | void clear(); | - |
211 | QBiPointer<QStringData, const QV4::CompiledData::Binding> d; | - |
212 | }; | - |
213 | - | |
214 | - | |
215 | - | |
216 | - | |
217 | class ListElement | - |
218 | { | - |
219 | public: | - |
220 | - | |
221 | ListElement(); | - |
222 | ListElement(int existingUid); | - |
223 | ~ListElement(); | - |
224 | - | |
225 | static QVector<int> sync(ListElement *src, ListLayout *srcLayout, ListElement *target, ListLayout *targetLayout); | - |
226 | - | |
227 | enum | - |
228 | { | - |
229 | BLOCK_SIZE = 64 - sizeof(int) - sizeof(ListElement *) - sizeof(ModelNodeMetaObject *) | - |
230 | }; | - |
231 | - | |
232 | private: | - |
233 | - | |
234 | void destroy(ListLayout *layout); | - |
235 | - | |
236 | int setVariantProperty(const ListLayout::Role &role, const QVariant &d); | - |
237 | - | |
238 | int setJsProperty(const ListLayout::Role &role, const QV4::Value &d, QV4::ExecutionEngine *eng); | - |
239 | - | |
240 | int setStringProperty(const ListLayout::Role &role, const QString &s); | - |
241 | int setDoubleProperty(const ListLayout::Role &role, double n); | - |
242 | int setBoolProperty(const ListLayout::Role &role, bool b); | - |
243 | int setListProperty(const ListLayout::Role &role, ListModel *m); | - |
244 | int setQObjectProperty(const ListLayout::Role &role, QObject *o); | - |
245 | int setVariantMapProperty(const ListLayout::Role &role, QV4::Object *o); | - |
246 | int setVariantMapProperty(const ListLayout::Role &role, QVariantMap *m); | - |
247 | int setDateTimeProperty(const ListLayout::Role &role, const QDateTime &dt); | - |
248 | int setFunctionProperty(const ListLayout::Role &role, const QJSValue &f); | - |
249 | int setTranslationProperty(const ListLayout::Role &role, const QV4::CompiledData::Binding *b); | - |
250 | - | |
251 | void setStringPropertyFast(const ListLayout::Role &role, const QString &s); | - |
252 | void setDoublePropertyFast(const ListLayout::Role &role, double n); | - |
253 | void setBoolPropertyFast(const ListLayout::Role &role, bool b); | - |
254 | void setQObjectPropertyFast(const ListLayout::Role &role, QObject *o); | - |
255 | void setListPropertyFast(const ListLayout::Role &role, ListModel *m); | - |
256 | void setVariantMapFast(const ListLayout::Role &role, QV4::Object *o); | - |
257 | void setDateTimePropertyFast(const ListLayout::Role &role, const QDateTime &dt); | - |
258 | void setFunctionPropertyFast(const ListLayout::Role &role, const QJSValue &f); | - |
259 | - | |
260 | void clearProperty(const ListLayout::Role &role); | - |
261 | - | |
262 | QVariant getProperty(const ListLayout::Role &role, const QQmlListModel *owner, QV4::ExecutionEngine *eng); | - |
263 | ListModel *getListProperty(const ListLayout::Role &role); | - |
264 | StringOrTranslation *getStringProperty(const ListLayout::Role &role); | - |
265 | QObject *getQObjectProperty(const ListLayout::Role &role); | - |
266 | QPointer<QObject> *getGuardProperty(const ListLayout::Role &role); | - |
267 | QVariantMap *getVariantMapProperty(const ListLayout::Role &role); | - |
268 | QDateTime *getDateTimeProperty(const ListLayout::Role &role); | - |
269 | QJSValue *getFunctionProperty(const ListLayout::Role &role); | - |
270 | - | |
271 | inline char *getPropertyMemory(const ListLayout::Role &role); | - |
272 | - | |
273 | int getUid() const { return executed 2844 times by 1 test: uid;return uid; Executed by:
executed 2844 times by 1 test: }return uid; Executed by:
| 2844 |
274 | - | |
275 | ModelNodeMetaObject *objectCache(); | - |
276 | - | |
277 | char data[BLOCK_SIZE]; | - |
278 | ListElement *next; | - |
279 | - | |
280 | int uid; | - |
281 | QObject *m_objectCache; | - |
282 | - | |
283 | friend class ListModel; | - |
284 | }; | - |
285 | - | |
286 | - | |
287 | - | |
288 | - | |
289 | class ListModel | - |
290 | { | - |
291 | public: | - |
292 | - | |
293 | ListModel(ListLayout *layout, QQmlListModel *modelCache); | - |
294 | ~ListModel() {} | - |
295 | - | |
296 | void destroy(); | - |
297 | - | |
298 | int setOrCreateProperty(int elementIndex, const QString &key, const QVariant &data); | - |
299 | int setExistingProperty(int uid, const QString &key, const QV4::Value &data, QV4::ExecutionEngine *eng); | - |
300 | - | |
301 | QVariant getProperty(int elementIndex, int roleIndex, const QQmlListModel *owner, QV4::ExecutionEngine *eng); | - |
302 | ListModel *getListProperty(int elementIndex, const ListLayout::Role &role); | - |
303 | - | |
304 | int roleCount() const | - |
305 | { | - |
306 | return executed 1952 times by 11 tests: m_layout->roleCount();return m_layout->roleCount(); Executed by:
executed 1952 times by 11 tests: return m_layout->roleCount(); Executed by:
| 1952 |
307 | } | - |
308 | - | |
309 | const ListLayout::Role &getExistingRole(int index) const | - |
310 | { | - |
311 | return executed 1378 times by 11 tests: m_layout->getExistingRole(index);return m_layout->getExistingRole(index); Executed by:
executed 1378 times by 11 tests: return m_layout->getExistingRole(index); Executed by:
| 1378 |
312 | } | - |
313 | - | |
314 | const ListLayout::Role *getExistingRole(QV4::String *key) const | - |
315 | { | - |
316 | return executed 852 times by 8 tests: m_layout->getExistingRole(key);return m_layout->getExistingRole(key); Executed by:
executed 852 times by 8 tests: return m_layout->getExistingRole(key); Executed by:
| 852 |
317 | } | - |
318 | - | |
319 | const ListLayout::Role &getOrCreateListRole(const QString &name) | - |
320 | { | - |
321 | return executed 66 times by 2 tests: m_layout->getRoleOrCreate(name, ListLayout::Role::List);return m_layout->getRoleOrCreate(name, ListLayout::Role::List); Executed by:
executed 66 times by 2 tests: return m_layout->getRoleOrCreate(name, ListLayout::Role::List); Executed by:
| 66 |
322 | } | - |
323 | - | |
324 | int elementCount() const | - |
325 | { | - |
326 | return executed 44602 times by 14 tests: elements.count();return elements.count(); Executed by:
executed 44602 times by 14 tests: return elements.count(); Executed by:
| 44602 |
327 | } | - |
328 | - | |
329 | void set(int elementIndex, QV4::Object *object, QVector<int> *roles); | - |
330 | void set(int elementIndex, QV4::Object *object); | - |
331 | - | |
332 | int append(QV4::Object *object); | - |
333 | void insert(int elementIndex, QV4::Object *object); | - |
334 | - | |
335 | __attribute__ ((__warn_unused_result__)) QVector<std::function<void()>> remove(int index, int count); | - |
336 | - | |
337 | int appendElement(); | - |
338 | void insertElement(int index); | - |
339 | - | |
340 | void move(int from, int to, int n); | - |
341 | - | |
342 | static bool sync(ListModel *src, ListModel *target); | - |
343 | - | |
344 | QObject *getOrCreateModelObject(QQmlListModel *model, int elementIndex); | - |
345 | - | |
346 | private: | - |
347 | QPODVector<ListElement *, 4> elements; | - |
348 | ListLayout *m_layout; | - |
349 | - | |
350 | QQmlListModel *m_modelCache; | - |
351 | - | |
352 | struct ElementSync | - |
353 | { | - |
354 | ListElement *src = nullptr; | - |
355 | ListElement *target = nullptr; | - |
356 | int srcIndex = -1; | - |
357 | int targetIndex = -1; | - |
358 | QVector<int> changedRoles; | - |
359 | }; | - |
360 | - | |
361 | void newElement(int index); | - |
362 | - | |
363 | void updateCacheIndices(int start = 0, int end = -1); | - |
364 | - | |
365 | friend class ListElement; | - |
366 | friend class QQmlListModelWorkerAgent; | - |
367 | friend class QQmlListModelParser; | - |
368 | }; | - |
369 | - | |
370 | - | |
371 | - | |
372 | template <> struct QMetaTypeId< ListModel * > { enum { Defined = 1 }; static int qt_metatype_id() { static QBasicAtomicInt metatype_id = { 0 }; if (const int id = metatype_id.loadAcquire()) return id; const int newId = qRegisterMetaType< ListModel * >("ListModel *", reinterpret_cast< ListModel * *>(quintptr(-1))); metatype_id.storeRelease(newId); return newId; } }; ; | - |
Switch to Source code | Preprocessed file |