Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/types/qqmllistmodel.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||
6 | template <> struct QMetaTypeId< const QV4::CompiledData::Binding* > { 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< const QV4::CompiledData::Binding* >("const QV4::CompiledData::Binding*", reinterpret_cast< const QV4::CompiledData::Binding* *>(quintptr(-1))); metatype_id.storeRelease(newId); return newId; } }; ; | - | ||||||||||||||||||||||||
7 | - | |||||||||||||||||||||||||
8 | - | |||||||||||||||||||||||||
9 | - | |||||||||||||||||||||||||
10 | - | |||||||||||||||||||||||||
11 | enum { MIN_LISTMODEL_UID = 1024 }; | - | ||||||||||||||||||||||||
12 | - | |||||||||||||||||||||||||
13 | static QAtomicInt uidCounter(MIN_LISTMODEL_UID); | - | ||||||||||||||||||||||||
14 | - | |||||||||||||||||||||||||
15 | template <typename T> | - | ||||||||||||||||||||||||
16 | static bool isMemoryUsed(const char *mem) | - | ||||||||||||||||||||||||
17 | { | - | ||||||||||||||||||||||||
18 | for (size_t i=0 ; i < sizeof(T)
| 344-3012 | ||||||||||||||||||||||||
19 | if (mem[i] != 0
| 248-2764 | ||||||||||||||||||||||||
20 | return executed 248 times by 2 tests: true;return true; Executed by:
executed 248 times by 2 tests: return true; Executed by:
| 248 | ||||||||||||||||||||||||
21 | } executed 2764 times by 2 tests: end of block Executed by:
| 2764 | ||||||||||||||||||||||||
22 | - | |||||||||||||||||||||||||
23 | return executed 344 times by 2 tests: false;return false; Executed by:
executed 344 times by 2 tests: return false; Executed by:
| 344 | ||||||||||||||||||||||||
24 | } | - | ||||||||||||||||||||||||
25 | - | |||||||||||||||||||||||||
26 | static QString roleTypeName(ListLayout::Role::DataType t) | - | ||||||||||||||||||||||||
27 | { | - | ||||||||||||||||||||||||
28 | static const QString roleTypeNames[] = { | - | ||||||||||||||||||||||||
29 | ([]() noexcept -> QString { enum { Size = sizeof(u"" "String")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "String" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()), ([]() noexcept -> QString { enum { Size = sizeof(u"" "Number")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Number" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()), ([]() noexcept -> QString { enum { Size = sizeof(u"" "Bool")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Bool" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()), | - | ||||||||||||||||||||||||
30 | ([]() noexcept -> QString { enum { Size = sizeof(u"" "List")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "List" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()), ([]() noexcept -> QString { enum { Size = sizeof(u"" "QObject")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "QObject" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()), ([]() noexcept -> QString { enum { Size = sizeof(u"" "VariantMap")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "VariantMap" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()), | - | ||||||||||||||||||||||||
31 | ([]() noexcept -> QString { enum { Size = sizeof(u"" "DateTime")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "DateTime" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()), ([]() noexcept -> QString { enum { Size = sizeof(u"" "Function")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Function" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()) | - | ||||||||||||||||||||||||
32 | }; | - | ||||||||||||||||||||||||
33 | - | |||||||||||||||||||||||||
34 | if (t > ListLayout::Role::Invalid
| 0-36 | ||||||||||||||||||||||||
35 | return executed 36 times by 2 tests: roleTypeNames[t];return roleTypeNames[t]; Executed by:
executed 36 times by 2 tests: return roleTypeNames[t]; Executed by:
| 36 | ||||||||||||||||||||||||
36 | - | |||||||||||||||||||||||||
37 | return never executed: QString();return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||
38 | } | - | ||||||||||||||||||||||||
39 | - | |||||||||||||||||||||||||
40 | const ListLayout::Role &ListLayout::getRoleOrCreate(const QString &key, Role::DataType type) | - | ||||||||||||||||||||||||
41 | { | - | ||||||||||||||||||||||||
42 | QStringHash<Role *>::Node *node = roleHash.findNode(key); | - | ||||||||||||||||||||||||
43 | if (node
| 910-3656 | ||||||||||||||||||||||||
44 | const Role &r = *node->value; | - | ||||||||||||||||||||||||
45 | if (type != r.type
| 4-3652 | ||||||||||||||||||||||||
46 | qmlWarning(nullptr) << ([]() noexcept -> QString { enum { Size = sizeof(u"" "Can't assign to existing role '%1' of different type [%2 -> %3]")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Can't assign to existing role '%1' of different type [%2 -> %3]" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 4 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 4 times by 1 test: }()).arg(r.name).arg(roleTypeName(type)).arg(roleTypeName(r.type));return qstring_literal_temp; Executed by:
executed 4 times by 1 test: qmlWarning(nullptr) << ([]() noexcept -> QString { enum { Size = sizeof(u"" "Can't assign to existing role '%1' of different type [%2 -> %3]")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) ...ign to existing role '%1' of different type [%2 -> %3]" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()).arg(r.name).arg(roleTypeName(type)).arg(roleTypeName(r.type)); Executed by:
| 4 | ||||||||||||||||||||||||
47 | return executed 3656 times by 11 tests: r;return r; Executed by:
executed 3656 times by 11 tests: return r; Executed by:
| 3656 | ||||||||||||||||||||||||
48 | } | - | ||||||||||||||||||||||||
49 | - | |||||||||||||||||||||||||
50 | return executed 910 times by 13 tests: createRole(key, type);return createRole(key, type); Executed by:
executed 910 times by 13 tests: return createRole(key, type); Executed by:
| 910 | ||||||||||||||||||||||||
51 | } | - | ||||||||||||||||||||||||
52 | - | |||||||||||||||||||||||||
53 | const ListLayout::Role &ListLayout::getRoleOrCreate(QV4::String *key, Role::DataType type) | - | ||||||||||||||||||||||||
54 | { | - | ||||||||||||||||||||||||
55 | QStringHash<Role *>::Node *node = roleHash.findNode(key); | - | ||||||||||||||||||||||||
56 | if (node
| 1208-2740 | ||||||||||||||||||||||||
57 | const Role &r = *node->value; | - | ||||||||||||||||||||||||
58 | if (type != r.type
| 12-2728 | ||||||||||||||||||||||||
59 | qmlWarning(nullptr) << ([]() noexcept -> QString { enum { Size = sizeof(u"" "Can't assign to existing role '%1' of different type [%2 -> %3]")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Can't assign to existing role '%1' of different type [%2 -> %3]" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 12 times by 2 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 12 times by 2 tests: }()).arg(r.name).arg(roleTypeName(type)).arg(roleTypeName(r.type));return qstring_literal_temp; Executed by:
executed 12 times by 2 tests: qmlWarning(nullptr) << ([]() noexcept -> QString { enum { Size = sizeof(u"" "Can't assign to existing role '%1' of different type [%2 -> %3]")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) ...ign to existing role '%1' of different type [%2 -> %3]" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()).arg(r.name).arg(roleTypeName(type)).arg(roleTypeName(r.type)); Executed by:
| 12 | ||||||||||||||||||||||||
60 | return executed 2740 times by 8 tests: r;return r; Executed by:
executed 2740 times by 8 tests: return r; Executed by:
| 2740 | ||||||||||||||||||||||||
61 | } | - | ||||||||||||||||||||||||
62 | - | |||||||||||||||||||||||||
63 | QString qkey = key->toQString(); | - | ||||||||||||||||||||||||
64 | - | |||||||||||||||||||||||||
65 | return executed 1208 times by 7 tests: createRole(qkey, type);return createRole(qkey, type); Executed by:
executed 1208 times by 7 tests: return createRole(qkey, type); Executed by:
| 1208 | ||||||||||||||||||||||||
66 | } | - | ||||||||||||||||||||||||
67 | - | |||||||||||||||||||||||||
68 | const ListLayout::Role &ListLayout::createRole(const QString &key, ListLayout::Role::DataType type) | - | ||||||||||||||||||||||||
69 | { | - | ||||||||||||||||||||||||
70 | const int dataSizes[] = { sizeof(StringOrTranslation), sizeof(double), sizeof(bool), sizeof(ListModel *), sizeof(QPointer<QObject>), sizeof(QVariantMap), sizeof(QDateTime), sizeof(QJSValue) }; | - | ||||||||||||||||||||||||
71 | const int dataAlignments[] = { sizeof(StringOrTranslation), sizeof(double), sizeof(bool), sizeof(ListModel *), sizeof(QObject *), sizeof(QVariantMap), sizeof(QDateTime), sizeof(QJSValue) }; | - | ||||||||||||||||||||||||
72 | - | |||||||||||||||||||||||||
73 | Role *r = new Role; | - | ||||||||||||||||||||||||
74 | r->name = key; | - | ||||||||||||||||||||||||
75 | r->type = type; | - | ||||||||||||||||||||||||
76 | - | |||||||||||||||||||||||||
77 | if (type == Role::List
| 128-1990 | ||||||||||||||||||||||||
78 | r->subLayout = new ListLayout; | - | ||||||||||||||||||||||||
79 | } executed 128 times by 4 tests: else {end of block Executed by:
| 128 | ||||||||||||||||||||||||
80 | r->subLayout = nullptr; | - | ||||||||||||||||||||||||
81 | } executed 1990 times by 15 tests: end of block Executed by:
| 1990 | ||||||||||||||||||||||||
82 | - | |||||||||||||||||||||||||
83 | int dataSize = dataSizes[type]; | - | ||||||||||||||||||||||||
84 | int dataAlignment = dataAlignments[type]; | - | ||||||||||||||||||||||||
85 | - | |||||||||||||||||||||||||
86 | int dataOffset = (currentBlockOffset + dataAlignment-1) & ~(dataAlignment-1); | - | ||||||||||||||||||||||||
87 | if (dataOffset + dataSize > ListElement::BLOCK_SIZE
| 6-2112 | ||||||||||||||||||||||||
88 | r->blockIndex = ++currentBlock; | - | ||||||||||||||||||||||||
89 | r->blockOffset = 0; | - | ||||||||||||||||||||||||
90 | currentBlockOffset = dataSize; | - | ||||||||||||||||||||||||
91 | } executed 6 times by 2 tests: else {end of block Executed by:
| 6 | ||||||||||||||||||||||||
92 | r->blockIndex = currentBlock; | - | ||||||||||||||||||||||||
93 | r->blockOffset = dataOffset; | - | ||||||||||||||||||||||||
94 | currentBlockOffset = dataOffset + dataSize; | - | ||||||||||||||||||||||||
95 | } executed 2112 times by 15 tests: end of block Executed by:
| 2112 | ||||||||||||||||||||||||
96 | - | |||||||||||||||||||||||||
97 | int roleIndex = roles.count(); | - | ||||||||||||||||||||||||
98 | r->index = roleIndex; | - | ||||||||||||||||||||||||
99 | - | |||||||||||||||||||||||||
100 | roles.append(r); | - | ||||||||||||||||||||||||
101 | roleHash.insert(key, r); | - | ||||||||||||||||||||||||
102 | - | |||||||||||||||||||||||||
103 | return executed 2118 times by 15 tests: *r;return *r; Executed by:
executed 2118 times by 15 tests: return *r; Executed by:
| 2118 | ||||||||||||||||||||||||
104 | } | - | ||||||||||||||||||||||||
105 | - | |||||||||||||||||||||||||
106 | ListLayout::ListLayout(const ListLayout *other) : currentBlock(0), currentBlockOffset(0) | - | ||||||||||||||||||||||||
107 | { | - | ||||||||||||||||||||||||
108 | const int otherRolesCount = other->roles.count(); | - | ||||||||||||||||||||||||
109 | roles.reserve(otherRolesCount); | - | ||||||||||||||||||||||||
110 | for (int i=0 ; i < otherRolesCount
| 90-942 | ||||||||||||||||||||||||
111 | Role *role = new Role(other->roles[i]); | - | ||||||||||||||||||||||||
112 | roles.append(role); | - | ||||||||||||||||||||||||
113 | roleHash.insert(role->name, role); | - | ||||||||||||||||||||||||
114 | } executed 90 times by 1 test: end of block Executed by:
| 90 | ||||||||||||||||||||||||
115 | currentBlockOffset = other->currentBlockOffset; | - | ||||||||||||||||||||||||
116 | currentBlock = other->currentBlock; | - | ||||||||||||||||||||||||
117 | } executed 942 times by 2 tests: end of block Executed by:
| 942 | ||||||||||||||||||||||||
118 | - | |||||||||||||||||||||||||
119 | ListLayout::~ListLayout() | - | ||||||||||||||||||||||||
120 | { | - | ||||||||||||||||||||||||
121 | qDeleteAll(roles); | - | ||||||||||||||||||||||||
122 | } executed 3516 times by 15 tests: end of block Executed by:
| 3516 | ||||||||||||||||||||||||
123 | - | |||||||||||||||||||||||||
124 | void ListLayout::sync(ListLayout *src, ListLayout *target) | - | ||||||||||||||||||||||||
125 | { | - | ||||||||||||||||||||||||
126 | int roleOffset = target->roles.count(); | - | ||||||||||||||||||||||||
127 | int newRoleCount = src->roles.count() - roleOffset; | - | ||||||||||||||||||||||||
128 | - | |||||||||||||||||||||||||
129 | for (int i=0 ; i < newRoleCount
| 476-926 | ||||||||||||||||||||||||
130 | Role *role = new Role(src->roles[roleOffset + i]); | - | ||||||||||||||||||||||||
131 | target->roles.append(role); | - | ||||||||||||||||||||||||
132 | target->roleHash.insert(role->name, role); | - | ||||||||||||||||||||||||
133 | } executed 476 times by 1 test: end of block Executed by:
| 476 | ||||||||||||||||||||||||
134 | - | |||||||||||||||||||||||||
135 | target->currentBlockOffset = src->currentBlockOffset; | - | ||||||||||||||||||||||||
136 | target->currentBlock = src->currentBlock; | - | ||||||||||||||||||||||||
137 | } executed 926 times by 2 tests: end of block Executed by:
| 926 | ||||||||||||||||||||||||
138 | - | |||||||||||||||||||||||||
139 | ListLayout::Role::Role(const Role *other) | - | ||||||||||||||||||||||||
140 | { | - | ||||||||||||||||||||||||
141 | name = other->name; | - | ||||||||||||||||||||||||
142 | type = other->type; | - | ||||||||||||||||||||||||
143 | blockIndex = other->blockIndex; | - | ||||||||||||||||||||||||
144 | blockOffset = other->blockOffset; | - | ||||||||||||||||||||||||
145 | index = other->index; | - | ||||||||||||||||||||||||
146 | if (other->subLayout
| 38-528 | ||||||||||||||||||||||||
147 | subLayout = new ListLayout(other->subLayout); executed 38 times by 1 test: subLayout = new ListLayout(other->subLayout); Executed by:
| 38 | ||||||||||||||||||||||||
148 | else | - | ||||||||||||||||||||||||
149 | subLayout = nullptr; executed 528 times by 1 test: subLayout = nullptr; Executed by:
| 528 | ||||||||||||||||||||||||
150 | } | - | ||||||||||||||||||||||||
151 | - | |||||||||||||||||||||||||
152 | ListLayout::Role::~Role() | - | ||||||||||||||||||||||||
153 | { | - | ||||||||||||||||||||||||
154 | delete subLayout; | - | ||||||||||||||||||||||||
155 | } executed 2672 times by 15 tests: end of block Executed by:
| 2672 | ||||||||||||||||||||||||
156 | - | |||||||||||||||||||||||||
157 | const ListLayout::Role *ListLayout::getRoleOrCreate(const QString &key, const QVariant &data) | - | ||||||||||||||||||||||||
158 | { | - | ||||||||||||||||||||||||
159 | Role::DataType type; | - | ||||||||||||||||||||||||
160 | - | |||||||||||||||||||||||||
161 | switch (data.type()) { | - | ||||||||||||||||||||||||
162 | case executed 302 times by 4 tests: QVariant::Double:case QVariant::Double: Executed by:
executed 302 times by 4 tests: type = Role::Number; break;case QVariant::Double: Executed by:
executed 302 times by 4 tests: break; Executed by:
| 302 | ||||||||||||||||||||||||
163 | case executed 144 times by 4 tests: QVariant::Int:case QVariant::Int: Executed by:
executed 144 times by 4 tests: type = Role::Number; break;case QVariant::Int: Executed by:
executed 144 times by 4 tests: break; Executed by:
| 144 | ||||||||||||||||||||||||
164 | case executed 66 times by 3 tests: QVariant::Bool:case QVariant::Bool: Executed by:
executed 66 times by 3 tests: type = Role::Bool; break;case QVariant::Bool: Executed by:
executed 66 times by 3 tests: break; Executed by:
| 66 | ||||||||||||||||||||||||
165 | case executed 3944 times by 11 tests: QVariant::String:case QVariant::String: Executed by:
executed 3944 times by 11 tests: type = Role::String; break;case QVariant::String: Executed by:
executed 3944 times by 11 tests: break; Executed by:
| 3944 | ||||||||||||||||||||||||
166 | case never executed: QVariant::Map:case QVariant::Map: never executed: type = Role::VariantMap; break;case QVariant::Map: never executed: break; | 0 | ||||||||||||||||||||||||
167 | case executed 2 times by 1 test: QVariant::DateTime:case QVariant::DateTime: Executed by:
executed 2 times by 1 test: type = Role::DateTime; break;case QVariant::DateTime: Executed by:
executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||
168 | case executed 42 times by 4 tests: QVariant::UserType:case QVariant::UserType: Executed by:
executed 42 times by 4 tests: {case QVariant::UserType: Executed by:
| 42 | ||||||||||||||||||||||||
169 | if (data.userType() == qMetaTypeId<QJSValue>()
| 0-42 | ||||||||||||||||||||||||
170 | data.value<QJSValue>().isCallable()
| 0 | ||||||||||||||||||||||||
171 | type = Role::Function; | - | ||||||||||||||||||||||||
172 | break; never executed: break; | 0 | ||||||||||||||||||||||||
173 | } else if (data.userType() == qMetaTypeId<const QV4::CompiledData::Binding*>()
| 8-34 | ||||||||||||||||||||||||
174 | && data.value<const QV4::CompiledData::Binding*>()->isTranslationBinding()
| 0-8 | ||||||||||||||||||||||||
175 | type = Role::String; | - | ||||||||||||||||||||||||
176 | break; executed 8 times by 3 tests: break; Executed by:
| 8 | ||||||||||||||||||||||||
177 | } else { | - | ||||||||||||||||||||||||
178 | type = Role::List; | - | ||||||||||||||||||||||||
179 | break; executed 34 times by 2 tests: break; Executed by:
| 34 | ||||||||||||||||||||||||
180 | } | - | ||||||||||||||||||||||||
181 | } | - | ||||||||||||||||||||||||
182 | default executed 2 times by 1 test: :default: Executed by:
executed 2 times by 1 test: type = Role::Invalid; break;default: Executed by:
executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||
183 | } | - | ||||||||||||||||||||||||
184 | - | |||||||||||||||||||||||||
185 | if (type == Role::Invalid
| 2-4500 | ||||||||||||||||||||||||
186 | qmlWarning(nullptr) << "Can't create role for unsupported data type"; | - | ||||||||||||||||||||||||
187 | return executed 2 times by 1 test: nullptr;return nullptr; Executed by:
executed 2 times by 1 test: return nullptr; Executed by:
| 2 | ||||||||||||||||||||||||
188 | } | - | ||||||||||||||||||||||||
189 | - | |||||||||||||||||||||||||
190 | return executed 4500 times by 14 tests: &getRoleOrCreate(key, type);return &getRoleOrCreate(key, type); Executed by:
executed 4500 times by 14 tests: return &getRoleOrCreate(key, type); Executed by:
| 4500 | ||||||||||||||||||||||||
191 | } | - | ||||||||||||||||||||||||
192 | - | |||||||||||||||||||||||||
193 | const ListLayout::Role *ListLayout::getExistingRole(const QString &key) const | - | ||||||||||||||||||||||||
194 | { | - | ||||||||||||||||||||||||
195 | Role *r = nullptr; | - | ||||||||||||||||||||||||
196 | QStringHash<Role *>::Node *node = roleHash.findNode(key); | - | ||||||||||||||||||||||||
197 | if (node
| 0-58 | ||||||||||||||||||||||||
198 | r = node->value; executed 58 times by 2 tests: r = node->value; Executed by:
| 58 | ||||||||||||||||||||||||
199 | return executed 58 times by 2 tests: r;return r; Executed by:
executed 58 times by 2 tests: return r; Executed by:
| 58 | ||||||||||||||||||||||||
200 | } | - | ||||||||||||||||||||||||
201 | - | |||||||||||||||||||||||||
202 | const ListLayout::Role *ListLayout::getExistingRole(QV4::String *key) const | - | ||||||||||||||||||||||||
203 | { | - | ||||||||||||||||||||||||
204 | Role *r = nullptr; | - | ||||||||||||||||||||||||
205 | QStringHash<Role *>::Node *node = roleHash.findNode(key); | - | ||||||||||||||||||||||||
206 | if (node
| 8-862 | ||||||||||||||||||||||||
207 | r = node->value; executed 862 times by 8 tests: r = node->value; Executed by:
| 862 | ||||||||||||||||||||||||
208 | return executed 870 times by 8 tests: r;return r; Executed by:
executed 870 times by 8 tests: return r; Executed by:
| 870 | ||||||||||||||||||||||||
209 | } | - | ||||||||||||||||||||||||
210 | - | |||||||||||||||||||||||||
211 | StringOrTranslation::StringOrTranslation(const QString &s) | - | ||||||||||||||||||||||||
212 | { | - | ||||||||||||||||||||||||
213 | d.setFlag(); | - | ||||||||||||||||||||||||
214 | setString(s); | - | ||||||||||||||||||||||||
215 | } executed 1170 times by 8 tests: end of block Executed by:
| 1170 | ||||||||||||||||||||||||
216 | - | |||||||||||||||||||||||||
217 | StringOrTranslation::StringOrTranslation(const QV4::CompiledData::Binding *binding) | - | ||||||||||||||||||||||||
218 | { | - | ||||||||||||||||||||||||
219 | d.setFlag(); | - | ||||||||||||||||||||||||
220 | clear(); | - | ||||||||||||||||||||||||
221 | d = binding; | - | ||||||||||||||||||||||||
222 | } never executed: end of block | 0 | ||||||||||||||||||||||||
223 | - | |||||||||||||||||||||||||
224 | StringOrTranslation::~StringOrTranslation() | - | ||||||||||||||||||||||||
225 | { | - | ||||||||||||||||||||||||
226 | clear(); | - | ||||||||||||||||||||||||
227 | } executed 5122 times by 14 tests: end of block Executed by:
| 5122 | ||||||||||||||||||||||||
228 | - | |||||||||||||||||||||||||
229 | void StringOrTranslation::setString(const QString &s) | - | ||||||||||||||||||||||||
230 | { | - | ||||||||||||||||||||||||
231 | d.setFlag(); | - | ||||||||||||||||||||||||
232 | clear(); | - | ||||||||||||||||||||||||
233 | QStringData *stringData = const_cast<QString &>(s).data_ptr(); | - | ||||||||||||||||||||||||
234 | d = stringData; | - | ||||||||||||||||||||||||
235 | if (stringData
| 0-5126 | ||||||||||||||||||||||||
236 | stringData->ref.ref(); executed 5126 times by 13 tests: stringData->ref.ref(); Executed by:
| 5126 | ||||||||||||||||||||||||
237 | } executed 5126 times by 13 tests: end of block Executed by:
| 5126 | ||||||||||||||||||||||||
238 | - | |||||||||||||||||||||||||
239 | void StringOrTranslation::setTranslation(const QV4::CompiledData::Binding *binding) | - | ||||||||||||||||||||||||
240 | { | - | ||||||||||||||||||||||||
241 | d.setFlag(); | - | ||||||||||||||||||||||||
242 | clear(); | - | ||||||||||||||||||||||||
243 | d = binding; | - | ||||||||||||||||||||||||
244 | } executed 8 times by 3 tests: end of block Executed by:
| 8 | ||||||||||||||||||||||||
245 | - | |||||||||||||||||||||||||
246 | QString StringOrTranslation::toString(const QQmlListModel *owner) const | - | ||||||||||||||||||||||||
247 | { | - | ||||||||||||||||||||||||
248 | if (d.isNull()
| 0-10271 | ||||||||||||||||||||||||
249 | return never executed: QString();return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||
250 | if (d.isT1()
| 10-10261 | ||||||||||||||||||||||||
251 | QStringDataPtr holder = { d.asT1() }; | - | ||||||||||||||||||||||||
252 | holder.ptr->ref.ref(); | - | ||||||||||||||||||||||||
253 | return executed 10261 times by 11 tests: QString(holder);return QString(holder); Executed by:
executed 10261 times by 11 tests: return QString(holder); Executed by:
| 10261 | ||||||||||||||||||||||||
254 | } | - | ||||||||||||||||||||||||
255 | if (!owner
| 0-10 | ||||||||||||||||||||||||
256 | return never executed: QString();return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||
257 | return executed 10 times by 3 tests: d.asT2()->valueAsString(owner->m_compilationUnit->data);return d.asT2()->valueAsString(owner->m_compilationUnit->data); Executed by:
executed 10 times by 3 tests: return d.asT2()->valueAsString(owner->m_compilationUnit->data); Executed by:
| 10 | ||||||||||||||||||||||||
258 | } | - | ||||||||||||||||||||||||
259 | - | |||||||||||||||||||||||||
260 | QString StringOrTranslation::asString() const | - | ||||||||||||||||||||||||
261 | { | - | ||||||||||||||||||||||||
262 | if (d.isNull()
| 0-6 | ||||||||||||||||||||||||
263 | return never executed: QString();return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||
264 | if (!d.isT1()
| 0-6 | ||||||||||||||||||||||||
265 | return never executed: QString();return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||
266 | QStringDataPtr holder = { d.asT1() }; | - | ||||||||||||||||||||||||
267 | holder.ptr->ref.ref(); | - | ||||||||||||||||||||||||
268 | return executed 6 times by 2 tests: QString(holder);return QString(holder); Executed by:
executed 6 times by 2 tests: return QString(holder); Executed by:
| 6 | ||||||||||||||||||||||||
269 | } | - | ||||||||||||||||||||||||
270 | - | |||||||||||||||||||||||||
271 | void StringOrTranslation::clear() | - | ||||||||||||||||||||||||
272 | { | - | ||||||||||||||||||||||||
273 | if (QStringData *strData = d.isT1()
| 8-10248 | ||||||||||||||||||||||||
274 | if (!strData->ref.deref()
| 105-5015 | ||||||||||||||||||||||||
275 | QStringData::deallocate(strData); executed 105 times by 7 tests: QStringData::deallocate(strData); Executed by:
| 105 | ||||||||||||||||||||||||
276 | } executed 5120 times by 13 tests: end of block Executed by:
| 5120 | ||||||||||||||||||||||||
277 | d = static_cast<QStringData *>(nullptr); | - | ||||||||||||||||||||||||
278 | } executed 10256 times by 14 tests: end of block Executed by:
| 10256 | ||||||||||||||||||||||||
279 | - | |||||||||||||||||||||||||
280 | QObject *ListModel::getOrCreateModelObject(QQmlListModel *model, int elementIndex) | - | ||||||||||||||||||||||||
281 | { | - | ||||||||||||||||||||||||
282 | ListElement *e = elements[elementIndex]; | - | ||||||||||||||||||||||||
283 | if (e->m_objectCache == nullptr
| 298-660 | ||||||||||||||||||||||||
284 | void *memory = operator new(sizeof(QObject) + sizeof(QQmlData)); | - | ||||||||||||||||||||||||
285 | void *ddataMemory = ((char *)memory) + sizeof(QObject); | - | ||||||||||||||||||||||||
286 | e->m_objectCache = new (memory) QObject; | - | ||||||||||||||||||||||||
287 | QQmlData *ddata = new (ddataMemory) QQmlData; | - | ||||||||||||||||||||||||
288 | ddata->ownMemory = false; | - | ||||||||||||||||||||||||
289 | QObjectPrivate::get(e->m_objectCache)->declarativeData = ddata; | - | ||||||||||||||||||||||||
290 | (void)new ModelNodeMetaObject(e->m_objectCache, model, elementIndex); | - | ||||||||||||||||||||||||
291 | } executed 660 times by 8 tests: end of block Executed by:
| 660 | ||||||||||||||||||||||||
292 | return executed 958 times by 8 tests: e->m_objectCache;return e->m_objectCache; Executed by:
executed 958 times by 8 tests: return e->m_objectCache; Executed by:
| 958 | ||||||||||||||||||||||||
293 | } | - | ||||||||||||||||||||||||
294 | - | |||||||||||||||||||||||||
295 | bool ListModel::sync(ListModel *src, ListModel *target) | - | ||||||||||||||||||||||||
296 | { | - | ||||||||||||||||||||||||
297 | - | |||||||||||||||||||||||||
298 | - | |||||||||||||||||||||||||
299 | bool hasChanges = false; | - | ||||||||||||||||||||||||
300 | - | |||||||||||||||||||||||||
301 | - | |||||||||||||||||||||||||
302 | QHash<int, ElementSync> elementHash; | - | ||||||||||||||||||||||||
303 | for (int i = 0; i < target->elements.count()
| 64-926 | ||||||||||||||||||||||||
304 | ListElement *e = target->elements.at(i); | - | ||||||||||||||||||||||||
305 | int uid = e->getUid(); | - | ||||||||||||||||||||||||
306 | ElementSync sync; | - | ||||||||||||||||||||||||
307 | sync.target = e; | - | ||||||||||||||||||||||||
308 | sync.targetIndex = i; | - | ||||||||||||||||||||||||
309 | elementHash.insert(uid, sync); | - | ||||||||||||||||||||||||
310 | } executed 64 times by 1 test: end of block Executed by:
| 64 | ||||||||||||||||||||||||
311 | for (int i = 0; i < src->elements.count()
| 694-926 | ||||||||||||||||||||||||
312 | ListElement *e = src->elements.at(i); | - | ||||||||||||||||||||||||
313 | int uid = e->getUid(); | - | ||||||||||||||||||||||||
314 | - | |||||||||||||||||||||||||
315 | QHash<int, ElementSync>::iterator it = elementHash.find(uid); | - | ||||||||||||||||||||||||
316 | if (it == elementHash.end()
| 60-634 | ||||||||||||||||||||||||
317 | ElementSync sync; | - | ||||||||||||||||||||||||
318 | sync.src = e; | - | ||||||||||||||||||||||||
319 | sync.srcIndex = i; | - | ||||||||||||||||||||||||
320 | elementHash.insert(uid, sync); | - | ||||||||||||||||||||||||
321 | } executed 634 times by 1 test: else {end of block Executed by:
| 634 | ||||||||||||||||||||||||
322 | ElementSync &sync = it.value(); | - | ||||||||||||||||||||||||
323 | sync.src = e; | - | ||||||||||||||||||||||||
324 | sync.srcIndex = i; | - | ||||||||||||||||||||||||
325 | } executed 60 times by 1 test: end of block Executed by:
| 60 | ||||||||||||||||||||||||
326 | } | - | ||||||||||||||||||||||||
327 | - | |||||||||||||||||||||||||
328 | QQmlListModel *targetModel = target->m_modelCache; | - | ||||||||||||||||||||||||
329 | - | |||||||||||||||||||||||||
330 | - | |||||||||||||||||||||||||
331 | int rowsRemoved = 0; | - | ||||||||||||||||||||||||
332 | for (int i = 0 ; i < target->elements.count()
| 64-926 | ||||||||||||||||||||||||
333 | ListElement *element = target->elements.at(i); | - | ||||||||||||||||||||||||
334 | ElementSync &s = elementHash.find(element->getUid()).value(); | - | ||||||||||||||||||||||||
335 | ((s.targetIndex >= 0) ? static_cast<void>(0) : qt_assert("s.targetIndex >= 0", __FILE__, 394)); | - | ||||||||||||||||||||||||
336 | - | |||||||||||||||||||||||||
337 | s.targetIndex -= rowsRemoved; | - | ||||||||||||||||||||||||
338 | if (s.src == nullptr
| 4-60 | ||||||||||||||||||||||||
339 | ((s.targetIndex == i) ? static_cast<void>(0) : qt_assert("s.targetIndex == i", __FILE__, 398)); | - | ||||||||||||||||||||||||
340 | hasChanges = true; | - | ||||||||||||||||||||||||
341 | if (targetModel
| 0-4 | ||||||||||||||||||||||||
342 | targetModel->beginRemoveRows(QModelIndex(), i, i); executed 4 times by 1 test: targetModel->beginRemoveRows(QModelIndex(), i, i); Executed by:
| 4 | ||||||||||||||||||||||||
343 | s.target->destroy(target->m_layout); | - | ||||||||||||||||||||||||
344 | target->elements.removeOne(s.target); | - | ||||||||||||||||||||||||
345 | delete s.target; | - | ||||||||||||||||||||||||
346 | if (targetModel
| 0-4 | ||||||||||||||||||||||||
347 | targetModel->endRemoveRows(); executed 4 times by 1 test: targetModel->endRemoveRows(); Executed by:
| 4 | ||||||||||||||||||||||||
348 | ++rowsRemoved; | - | ||||||||||||||||||||||||
349 | --i; | - | ||||||||||||||||||||||||
350 | continue; executed 4 times by 1 test: continue; Executed by:
| 4 | ||||||||||||||||||||||||
351 | } | - | ||||||||||||||||||||||||
352 | } executed 60 times by 1 test: end of block Executed by:
| 60 | ||||||||||||||||||||||||
353 | - | |||||||||||||||||||||||||
354 | - | |||||||||||||||||||||||||
355 | ListLayout::sync(src->m_layout, target->m_layout); | - | ||||||||||||||||||||||||
356 | - | |||||||||||||||||||||||||
357 | - | |||||||||||||||||||||||||
358 | target->elements.clear(); | - | ||||||||||||||||||||||||
359 | for (int i = 0; i < src->elements.count()
| 694-926 | ||||||||||||||||||||||||
360 | ListElement *srcElement = src->elements.at(i); | - | ||||||||||||||||||||||||
361 | ElementSync &s = elementHash.find(srcElement->getUid()).value(); | - | ||||||||||||||||||||||||
362 | ((s.srcIndex >= 0) ? static_cast<void>(0) : qt_assert("s.srcIndex >= 0", __FILE__, 421)); | - | ||||||||||||||||||||||||
363 | ListElement *targetElement = s.target; | - | ||||||||||||||||||||||||
364 | if (targetElement == nullptr
| 60-634 | ||||||||||||||||||||||||
365 | targetElement = new ListElement(srcElement->getUid()); | - | ||||||||||||||||||||||||
366 | } executed 634 times by 1 test: end of block Executed by:
| 634 | ||||||||||||||||||||||||
367 | s.changedRoles = ListElement::sync(srcElement, src->m_layout, targetElement, target->m_layout); | - | ||||||||||||||||||||||||
368 | target->elements.append(targetElement); | - | ||||||||||||||||||||||||
369 | } executed 694 times by 1 test: end of block Executed by:
| 694 | ||||||||||||||||||||||||
370 | - | |||||||||||||||||||||||||
371 | target->updateCacheIndices(); | - | ||||||||||||||||||||||||
372 | - | |||||||||||||||||||||||||
373 | - | |||||||||||||||||||||||||
374 | for (int i=0 ; i < target->elements.count()
| 694-926 | ||||||||||||||||||||||||
375 | ListElement *e = target->elements[i]; | - | ||||||||||||||||||||||||
376 | if (ModelNodeMetaObject *mo = e->objectCache()
| 0-694 | ||||||||||||||||||||||||
377 | mo->updateValues(); never executed: mo->updateValues(); | 0 | ||||||||||||||||||||||||
378 | } executed 694 times by 1 test: end of block Executed by:
| 694 | ||||||||||||||||||||||||
379 | - | |||||||||||||||||||||||||
380 | - | |||||||||||||||||||||||||
381 | - | |||||||||||||||||||||||||
382 | - | |||||||||||||||||||||||||
383 | - | |||||||||||||||||||||||||
384 | - | |||||||||||||||||||||||||
385 | int rowsInserted = 0; | - | ||||||||||||||||||||||||
386 | for (int i = 0 ; i < target->elements.count()
| 694-926 | ||||||||||||||||||||||||
387 | ListElement *element = target->elements.at(i); | - | ||||||||||||||||||||||||
388 | ElementSync &s = elementHash.find(element->getUid()).value(); | - | ||||||||||||||||||||||||
389 | ((s.srcIndex >= 0) ? static_cast<void>(0) : qt_assert("s.srcIndex >= 0", __FILE__, 448)); | - | ||||||||||||||||||||||||
390 | s.srcIndex += rowsInserted; | - | ||||||||||||||||||||||||
391 | if (s.srcIndex != s.targetIndex
| 60-634 | ||||||||||||||||||||||||
392 | if (targetModel
| 90-544 | ||||||||||||||||||||||||
393 | if (s.targetIndex == -1
| 0-544 | ||||||||||||||||||||||||
394 | targetModel->beginInsertRows(QModelIndex(), i, i); | - | ||||||||||||||||||||||||
395 | targetModel->endInsertRows(); | - | ||||||||||||||||||||||||
396 | } executed 544 times by 1 test: else {end of block Executed by:
| 544 | ||||||||||||||||||||||||
397 | targetModel->beginMoveRows(QModelIndex(), i, i, QModelIndex(), s.srcIndex); | - | ||||||||||||||||||||||||
398 | targetModel->endMoveRows(); | - | ||||||||||||||||||||||||
399 | } never executed: end of block | 0 | ||||||||||||||||||||||||
400 | } | - | ||||||||||||||||||||||||
401 | hasChanges = true; | - | ||||||||||||||||||||||||
402 | ++rowsInserted; | - | ||||||||||||||||||||||||
403 | } executed 634 times by 1 test: end of block Executed by:
| 634 | ||||||||||||||||||||||||
404 | if (s.targetIndex != -1
| 10-634 | ||||||||||||||||||||||||
405 | QModelIndex idx = targetModel->createIndex(i, 0); | - | ||||||||||||||||||||||||
406 | if (targetModel
| 0-10 | ||||||||||||||||||||||||
407 | targetModel->dataChanged(idx, idx, s.changedRoles); executed 10 times by 1 test: targetModel->dataChanged(idx, idx, s.changedRoles); Executed by:
| 10 | ||||||||||||||||||||||||
408 | hasChanges = true; | - | ||||||||||||||||||||||||
409 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
410 | } executed 694 times by 1 test: end of block Executed by:
| 694 | ||||||||||||||||||||||||
411 | return executed 926 times by 2 tests: hasChanges;return hasChanges; Executed by:
executed 926 times by 2 tests: return hasChanges; Executed by:
| 926 | ||||||||||||||||||||||||
412 | } | - | ||||||||||||||||||||||||
413 | - | |||||||||||||||||||||||||
414 | ListModel::ListModel(ListLayout *layout, QQmlListModel *modelCache) : m_layout(layout), m_modelCache(modelCache) | - | ||||||||||||||||||||||||
415 | { | - | ||||||||||||||||||||||||
416 | } executed 3596 times by 15 tests: end of block Executed by:
| 3596 | ||||||||||||||||||||||||
417 | - | |||||||||||||||||||||||||
418 | void ListModel::destroy() | - | ||||||||||||||||||||||||
419 | { | - | ||||||||||||||||||||||||
420 | for (const auto &destroyer : remove(0, elements.count())) | - | ||||||||||||||||||||||||
421 | destroyer(); executed 6288 times by 15 tests: destroyer(); Executed by:
| 6288 | ||||||||||||||||||||||||
422 | - | |||||||||||||||||||||||||
423 | m_layout = nullptr; | - | ||||||||||||||||||||||||
424 | if (m_modelCache
| 98-3490 | ||||||||||||||||||||||||
425 | delete m_modelCache; executed 138 times by 4 tests: delete m_modelCache; Executed by:
| 138 | ||||||||||||||||||||||||
426 | m_modelCache = nullptr; | - | ||||||||||||||||||||||||
427 | } executed 3588 times by 15 tests: end of block Executed by:
| 3588 | ||||||||||||||||||||||||
428 | - | |||||||||||||||||||||||||
429 | int ListModel::appendElement() | - | ||||||||||||||||||||||||
430 | { | - | ||||||||||||||||||||||||
431 | int elementIndex = elements.count(); | - | ||||||||||||||||||||||||
432 | newElement(elementIndex); | - | ||||||||||||||||||||||||
433 | return executed 5560 times by 15 tests: elementIndex;return elementIndex; Executed by:
executed 5560 times by 15 tests: return elementIndex; Executed by:
| 5560 | ||||||||||||||||||||||||
434 | } | - | ||||||||||||||||||||||||
435 | - | |||||||||||||||||||||||||
436 | void ListModel::insertElement(int index) | - | ||||||||||||||||||||||||
437 | { | - | ||||||||||||||||||||||||
438 | newElement(index); | - | ||||||||||||||||||||||||
439 | updateCacheIndices(index); | - | ||||||||||||||||||||||||
440 | } executed 460 times by 5 tests: end of block Executed by:
| 460 | ||||||||||||||||||||||||
441 | - | |||||||||||||||||||||||||
442 | void ListModel::move(int from, int to, int n) | - | ||||||||||||||||||||||||
443 | { | - | ||||||||||||||||||||||||
444 | if (from > to
| 34-54 | ||||||||||||||||||||||||
445 | - | |||||||||||||||||||||||||
446 | int tfrom = from; | - | ||||||||||||||||||||||||
447 | int tto = to; | - | ||||||||||||||||||||||||
448 | from = tto; | - | ||||||||||||||||||||||||
449 | to = tto+n; | - | ||||||||||||||||||||||||
450 | n = tfrom-tto; | - | ||||||||||||||||||||||||
451 | } executed 34 times by 4 tests: end of block Executed by:
| 34 | ||||||||||||||||||||||||
452 | - | |||||||||||||||||||||||||
453 | QPODVector<ListElement *, 4> store; | - | ||||||||||||||||||||||||
454 | for (int i=0 ; i < (to-from)
| 88-94 | ||||||||||||||||||||||||
455 | store.append(elements[from+n+i]); executed 94 times by 5 tests: store.append(elements[from+n+i]); Executed by:
| 94 | ||||||||||||||||||||||||
456 | for (int i=0 ; i < n
| 88-126 | ||||||||||||||||||||||||
457 | store.append(elements[from+i]); executed 126 times by 5 tests: store.append(elements[from+i]); Executed by:
| 126 | ||||||||||||||||||||||||
458 | for (int i=0 ; i < store.count()
| 88-220 | ||||||||||||||||||||||||
459 | elements[from+i] = store[i]; executed 220 times by 5 tests: elements[from+i] = store[i]; Executed by:
| 220 | ||||||||||||||||||||||||
460 | - | |||||||||||||||||||||||||
461 | updateCacheIndices(from, to + n); | - | ||||||||||||||||||||||||
462 | } executed 88 times by 5 tests: end of block Executed by:
| 88 | ||||||||||||||||||||||||
463 | - | |||||||||||||||||||||||||
464 | void ListModel::newElement(int index) | - | ||||||||||||||||||||||||
465 | { | - | ||||||||||||||||||||||||
466 | ListElement *e = new ListElement; | - | ||||||||||||||||||||||||
467 | elements.insert(index, e); | - | ||||||||||||||||||||||||
468 | } executed 6020 times by 15 tests: end of block Executed by:
| 6020 | ||||||||||||||||||||||||
469 | - | |||||||||||||||||||||||||
470 | void ListModel::updateCacheIndices(int start, int end) | - | ||||||||||||||||||||||||
471 | { | - | ||||||||||||||||||||||||
472 | int count = elements.count(); | - | ||||||||||||||||||||||||
473 | - | |||||||||||||||||||||||||
474 | if (end < 0
| 0-5250 | ||||||||||||||||||||||||
475 | end = count; executed 5250 times by 15 tests: end = count; Executed by:
| 5250 | ||||||||||||||||||||||||
476 | - | |||||||||||||||||||||||||
477 | for (int i = start; i < end
| 3118-5338 | ||||||||||||||||||||||||
478 | ListElement *e = elements.at(i); | - | ||||||||||||||||||||||||
479 | if (ModelNodeMetaObject *mo = e->objectCache()
| 324-2794 | ||||||||||||||||||||||||
480 | mo->m_elementIndex = i; executed 324 times by 3 tests: mo->m_elementIndex = i; Executed by:
| 324 | ||||||||||||||||||||||||
481 | } executed 3118 times by 6 tests: end of block Executed by:
| 3118 | ||||||||||||||||||||||||
482 | } executed 5338 times by 15 tests: end of block Executed by:
| 5338 | ||||||||||||||||||||||||
483 | - | |||||||||||||||||||||||||
484 | QVariant ListModel::getProperty(int elementIndex, int roleIndex, const QQmlListModel *owner, QV4::ExecutionEngine *eng) | - | ||||||||||||||||||||||||
485 | { | - | ||||||||||||||||||||||||
486 | if (roleIndex >= m_layout->roleCount()
| 2-11583 | ||||||||||||||||||||||||
487 | return executed 2 times by 1 test: QVariant();return QVariant(); Executed by:
executed 2 times by 1 test: return QVariant(); Executed by:
| 2 | ||||||||||||||||||||||||
488 | ListElement *e = elements[elementIndex]; | - | ||||||||||||||||||||||||
489 | const ListLayout::Role &r = m_layout->getExistingRole(roleIndex); | - | ||||||||||||||||||||||||
490 | return executed 11583 times by 13 tests: e->getProperty(r, owner, eng);return e->getProperty(r, owner, eng); Executed by:
executed 11583 times by 13 tests: return e->getProperty(r, owner, eng); Executed by:
| 11583 | ||||||||||||||||||||||||
491 | } | - | ||||||||||||||||||||||||
492 | - | |||||||||||||||||||||||||
493 | ListModel *ListModel::getListProperty(int elementIndex, const ListLayout::Role &role) | - | ||||||||||||||||||||||||
494 | { | - | ||||||||||||||||||||||||
495 | ListElement *e = elements[elementIndex]; | - | ||||||||||||||||||||||||
496 | return executed 62 times by 2 tests: e->getListProperty(role);return e->getListProperty(role); Executed by:
executed 62 times by 2 tests: return e->getListProperty(role); Executed by:
| 62 | ||||||||||||||||||||||||
497 | } | - | ||||||||||||||||||||||||
498 | - | |||||||||||||||||||||||||
499 | void ListModel::set(int elementIndex, QV4::Object *object, QVector<int> *roles) | - | ||||||||||||||||||||||||
500 | { | - | ||||||||||||||||||||||||
501 | ListElement *e = elements[elementIndex]; | - | ||||||||||||||||||||||||
502 | - | |||||||||||||||||||||||||
503 | QV4::ExecutionEngine *v4 = object->engine(); | - | ||||||||||||||||||||||||
504 | QV4::Scope scope(v4); | - | ||||||||||||||||||||||||
505 | QV4::ScopedObject o(scope); | - | ||||||||||||||||||||||||
506 | - | |||||||||||||||||||||||||
507 | QV4::ObjectIterator it(scope, object, QV4::ObjectIterator::WithProtoChain|QV4::ObjectIterator::EnumerableOnly); | - | ||||||||||||||||||||||||
508 | QV4::ScopedString propertyName(scope); | - | ||||||||||||||||||||||||
509 | QV4::ScopedValue propertyValue(scope); | - | ||||||||||||||||||||||||
510 | while (1) { | - | ||||||||||||||||||||||||
511 | propertyName = it.nextPropertyNameAsString(propertyValue); | - | ||||||||||||||||||||||||
512 | if (!propertyName
| 122-134 | ||||||||||||||||||||||||
513 | break; executed 122 times by 2 tests: break; Executed by:
| 122 | ||||||||||||||||||||||||
514 | - | |||||||||||||||||||||||||
515 | - | |||||||||||||||||||||||||
516 | int roleIndex = -1; | - | ||||||||||||||||||||||||
517 | - | |||||||||||||||||||||||||
518 | - | |||||||||||||||||||||||||
519 | if (const
| 6-128 | ||||||||||||||||||||||||
520 | const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::String); | - | ||||||||||||||||||||||||
521 | roleIndex = e->setStringProperty(r, s->toQString()); | - | ||||||||||||||||||||||||
522 | } executed 6 times by 2 tests: else if (propertyValue->isNumber()end of block Executed by:
| 6-68 | ||||||||||||||||||||||||
523 | const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Number); | - | ||||||||||||||||||||||||
524 | roleIndex = e->setDoubleProperty(r, propertyValue->asDouble()); | - | ||||||||||||||||||||||||
525 | } executed 68 times by 2 tests: else if (QV4::ArrayObject *a = propertyValue->as<QV4::ArrayObject>()end of block Executed by:
| 22-68 | ||||||||||||||||||||||||
526 | const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::List); | - | ||||||||||||||||||||||||
527 | ListModel *subModel = new ListModel(r.subLayout, nullptr); | - | ||||||||||||||||||||||||
528 | - | |||||||||||||||||||||||||
529 | int arrayLength = a->getLength(); | - | ||||||||||||||||||||||||
530 | for (int j=0 ; j < arrayLength
| 22-32 | ||||||||||||||||||||||||
531 | o = a->get(j); | - | ||||||||||||||||||||||||
532 | subModel->append(o); | - | ||||||||||||||||||||||||
533 | } executed 32 times by 2 tests: end of block Executed by:
| 32 | ||||||||||||||||||||||||
534 | - | |||||||||||||||||||||||||
535 | roleIndex = e->setListProperty(r, subModel); | - | ||||||||||||||||||||||||
536 | } executed 22 times by 2 tests: else if (propertyValue->isBoolean()end of block Executed by:
| 4-34 | ||||||||||||||||||||||||
537 | const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Bool); | - | ||||||||||||||||||||||||
538 | roleIndex = e->setBoolProperty(r, propertyValue->booleanValue()); | - | ||||||||||||||||||||||||
539 | } executed 4 times by 1 test: else if (QV4::DateObject *dd = propertyValue->as<QV4::DateObject>()end of block Executed by:
| 2-32 | ||||||||||||||||||||||||
540 | const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::DateTime); | - | ||||||||||||||||||||||||
541 | QDateTime dt = dd->toQDateTime(); | - | ||||||||||||||||||||||||
542 | roleIndex = e->setDateTimeProperty(r, dt); | - | ||||||||||||||||||||||||
543 | } executed 2 times by 1 test: else if (QV4::FunctionObject *f = propertyValue->as<QV4::FunctionObject>()end of block Executed by:
| 0-32 | ||||||||||||||||||||||||
544 | const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Function); | - | ||||||||||||||||||||||||
545 | QV4::ScopedFunctionObject func(scope, f); | - | ||||||||||||||||||||||||
546 | QJSValue jsv; | - | ||||||||||||||||||||||||
547 | QJSValuePrivate::setValue(&jsv, v4, func); | - | ||||||||||||||||||||||||
548 | roleIndex = e->setFunctionProperty(r, jsv); | - | ||||||||||||||||||||||||
549 | } never executed: else if (QV4::Object *o = propertyValue->as<QV4::Object>()end of block
| 0-20 | ||||||||||||||||||||||||
550 | if (QV4::QObjectWrapper *wrapper = o->as<QV4::QObjectWrapper>()
| 2-18 | ||||||||||||||||||||||||
551 | QObject *o = wrapper->object(); | - | ||||||||||||||||||||||||
552 | const ListLayout::Role &role = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::QObject); | - | ||||||||||||||||||||||||
553 | if (role.type == ListLayout::Role::QObject
| 0-2 | ||||||||||||||||||||||||
554 | roleIndex = e->setQObjectProperty(role, o); executed 2 times by 1 test: roleIndex = e->setQObjectProperty(role, o); Executed by:
| 2 | ||||||||||||||||||||||||
555 | } executed 2 times by 1 test: else {end of block Executed by:
| 2 | ||||||||||||||||||||||||
556 | const ListLayout::Role &role = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::VariantMap); | - | ||||||||||||||||||||||||
557 | if (role.type == ListLayout::Role::VariantMap
| 0-18 | ||||||||||||||||||||||||
558 | QV4::ScopedObject obj(scope, o); | - | ||||||||||||||||||||||||
559 | roleIndex = e->setVariantMapProperty(role, obj); | - | ||||||||||||||||||||||||
560 | } executed 18 times by 2 tests: end of block Executed by:
| 18 | ||||||||||||||||||||||||
561 | } executed 18 times by 2 tests: end of block Executed by:
| 18 | ||||||||||||||||||||||||
562 | } else if (propertyValue->isNullOrUndefined()
| 0-12 | ||||||||||||||||||||||||
563 | const ListLayout::Role *r = m_layout->getExistingRole(propertyName); | - | ||||||||||||||||||||||||
564 | if (r
| 0-12 | ||||||||||||||||||||||||
565 | e->clearProperty(*r); executed 12 times by 2 tests: e->clearProperty(*r); Executed by:
| 12 | ||||||||||||||||||||||||
566 | } executed 12 times by 2 tests: end of block Executed by:
| 12 | ||||||||||||||||||||||||
567 | - | |||||||||||||||||||||||||
568 | if (roleIndex != -1
| 20-114 | ||||||||||||||||||||||||
569 | roles->append(roleIndex); executed 114 times by 2 tests: roles->append(roleIndex); Executed by:
| 114 | ||||||||||||||||||||||||
570 | } executed 134 times by 2 tests: end of block Executed by:
| 134 | ||||||||||||||||||||||||
571 | - | |||||||||||||||||||||||||
572 | if (ModelNodeMetaObject *mo = e->objectCache()
| 26-96 | ||||||||||||||||||||||||
573 | mo->updateValues(*roles); executed 26 times by 1 test: mo->updateValues(*roles); Executed by:
| 26 | ||||||||||||||||||||||||
574 | } executed 122 times by 2 tests: end of block Executed by:
| 122 | ||||||||||||||||||||||||
575 | - | |||||||||||||||||||||||||
576 | void ListModel::set(int elementIndex, QV4::Object *object) | - | ||||||||||||||||||||||||
577 | { | - | ||||||||||||||||||||||||
578 | if (!object
| 6-2736 | ||||||||||||||||||||||||
579 | return; executed 6 times by 1 test: return; Executed by:
| 6 | ||||||||||||||||||||||||
580 | - | |||||||||||||||||||||||||
581 | ListElement *e = elements[elementIndex]; | - | ||||||||||||||||||||||||
582 | - | |||||||||||||||||||||||||
583 | QV4::ExecutionEngine *v4 = object->engine(); | - | ||||||||||||||||||||||||
584 | QV4::Scope scope(v4); | - | ||||||||||||||||||||||||
585 | - | |||||||||||||||||||||||||
586 | QV4::ObjectIterator it(scope, object, QV4::ObjectIterator::WithProtoChain|QV4::ObjectIterator::EnumerableOnly); | - | ||||||||||||||||||||||||
587 | QV4::ScopedString propertyName(scope); | - | ||||||||||||||||||||||||
588 | QV4::ScopedValue propertyValue(scope); | - | ||||||||||||||||||||||||
589 | QV4::ScopedObject o(scope); | - | ||||||||||||||||||||||||
590 | while (1) { | - | ||||||||||||||||||||||||
591 | propertyName = it.nextPropertyNameAsString(propertyValue); | - | ||||||||||||||||||||||||
592 | if (!propertyName
| 2736-3832 | ||||||||||||||||||||||||
593 | break; executed 2736 times by 9 tests: break; Executed by:
| 2736 | ||||||||||||||||||||||||
594 | - | |||||||||||||||||||||||||
595 | - | |||||||||||||||||||||||||
596 | if (QV4::String *s = propertyValue->stringValue()
| 1176-2656 | ||||||||||||||||||||||||
597 | const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::String); | - | ||||||||||||||||||||||||
598 | if (r.type == ListLayout::Role::String
| 6-1170 | ||||||||||||||||||||||||
599 | e->setStringPropertyFast(r, s->toQString()); executed 1170 times by 8 tests: e->setStringPropertyFast(r, s->toQString()); Executed by:
| 1170 | ||||||||||||||||||||||||
600 | } executed 1176 times by 8 tests: else if (propertyValue->isNumber()end of block Executed by:
| 322-2334 | ||||||||||||||||||||||||
601 | const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Number); | - | ||||||||||||||||||||||||
602 | if (r.type == ListLayout::Role::Number
| 0-2334 | ||||||||||||||||||||||||
603 | e->setDoublePropertyFast(r, propertyValue->asDouble()); | - | ||||||||||||||||||||||||
604 | } executed 2334 times by 5 tests: end of block Executed by:
| 2334 | ||||||||||||||||||||||||
605 | } executed 2334 times by 5 tests: else if (QV4::ArrayObject *a = propertyValue->as<QV4::ArrayObject>()end of block Executed by:
| 126-2334 | ||||||||||||||||||||||||
606 | const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::List); | - | ||||||||||||||||||||||||
607 | if (r.type == ListLayout::Role::List
| 0-126 | ||||||||||||||||||||||||
608 | ListModel *subModel = new ListModel(r.subLayout, nullptr); | - | ||||||||||||||||||||||||
609 | - | |||||||||||||||||||||||||
610 | int arrayLength = a->getLength(); | - | ||||||||||||||||||||||||
611 | for (int j=0 ; j < arrayLength
| 126-344 | ||||||||||||||||||||||||
612 | o = a->get(j); | - | ||||||||||||||||||||||||
613 | subModel->append(o); | - | ||||||||||||||||||||||||
614 | } executed 344 times by 3 tests: end of block Executed by:
| 344 | ||||||||||||||||||||||||
615 | - | |||||||||||||||||||||||||
616 | e->setListPropertyFast(r, subModel); | - | ||||||||||||||||||||||||
617 | } executed 126 times by 3 tests: end of block Executed by:
| 126 | ||||||||||||||||||||||||
618 | } executed 126 times by 3 tests: else if (propertyValue->isBoolean()end of block Executed by:
| 88-126 | ||||||||||||||||||||||||
619 | const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Bool); | - | ||||||||||||||||||||||||
620 | if (r.type == ListLayout::Role::Bool
| 0-88 | ||||||||||||||||||||||||
621 | e->setBoolPropertyFast(r, propertyValue->booleanValue()); | - | ||||||||||||||||||||||||
622 | } executed 88 times by 2 tests: end of block Executed by:
| 88 | ||||||||||||||||||||||||
623 | } executed 88 times by 2 tests: else if (QV4::DateObject *date = propertyValue->as<QV4::DateObject>()end of block Executed by:
| 10-98 | ||||||||||||||||||||||||
624 | const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::DateTime); | - | ||||||||||||||||||||||||
625 | if (r.type == ListLayout::Role::DateTime
| 0-10 | ||||||||||||||||||||||||
626 | QDateTime dt = date->toQDateTime();; | - | ||||||||||||||||||||||||
627 | e->setDateTimePropertyFast(r, dt); | - | ||||||||||||||||||||||||
628 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
629 | } executed 10 times by 1 test: else if (QV4::Object *o = propertyValue->as<QV4::Object>()end of block Executed by:
| 6-92 | ||||||||||||||||||||||||
630 | if (QV4::QObjectWrapper *wrapper = o->as<QV4::QObjectWrapper>()
| 8-84 | ||||||||||||||||||||||||
631 | QObject *o = wrapper->object(); | - | ||||||||||||||||||||||||
632 | const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::QObject); | - | ||||||||||||||||||||||||
633 | if (r.type == ListLayout::Role::QObject
| 0-8 | ||||||||||||||||||||||||
634 | e->setQObjectPropertyFast(r, o); executed 8 times by 1 test: e->setQObjectPropertyFast(r, o); Executed by:
| 8 | ||||||||||||||||||||||||
635 | } executed 8 times by 1 test: else {end of block Executed by:
| 8 | ||||||||||||||||||||||||
636 | const ListLayout::Role &role = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::VariantMap); | - | ||||||||||||||||||||||||
637 | if (role.type == ListLayout::Role::VariantMap
| 0-84 | ||||||||||||||||||||||||
638 | e->setVariantMapFast(role, o); executed 84 times by 2 tests: e->setVariantMapFast(role, o); Executed by:
| 84 | ||||||||||||||||||||||||
639 | } executed 84 times by 2 tests: end of block Executed by:
| 84 | ||||||||||||||||||||||||
640 | } else if (propertyValue->isNullOrUndefined()
| 0-6 | ||||||||||||||||||||||||
641 | const ListLayout::Role *r = m_layout->getExistingRole(propertyName); | - | ||||||||||||||||||||||||
642 | if (r
| 0-6 | ||||||||||||||||||||||||
643 | e->clearProperty(*r); never executed: e->clearProperty(*r); | 0 | ||||||||||||||||||||||||
644 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||||||||
645 | } executed 3832 times by 9 tests: end of block Executed by:
| 3832 | ||||||||||||||||||||||||
646 | } executed 2736 times by 9 tests: end of block Executed by:
| 2736 | ||||||||||||||||||||||||
647 | - | |||||||||||||||||||||||||
648 | QVector<std::function<void()>> ListModel::remove(int index, int count) | - | ||||||||||||||||||||||||
649 | { | - | ||||||||||||||||||||||||
650 | QVector<std::function<void()>> toDestroy; | - | ||||||||||||||||||||||||
651 | auto layout = m_layout; | - | ||||||||||||||||||||||||
652 | for (int i=0 ; i < count
| 3864-6636 | ||||||||||||||||||||||||
653 | auto element = elements[index+i]; | - | ||||||||||||||||||||||||
654 | toDestroy.append([element, layout](){ | - | ||||||||||||||||||||||||
655 | element->destroy(layout); | - | ||||||||||||||||||||||||
656 | delete element; | - | ||||||||||||||||||||||||
657 | } executed 6636 times by 15 tests: );end of block Executed by:
| 6636 | ||||||||||||||||||||||||
658 | } executed 6636 times by 15 tests: end of block Executed by:
| 6636 | ||||||||||||||||||||||||
659 | elements.remove(index, count); | - | ||||||||||||||||||||||||
660 | updateCacheIndices(index); | - | ||||||||||||||||||||||||
661 | return executed 3864 times by 15 tests: toDestroy;return toDestroy; Executed by:
executed 3864 times by 15 tests: return toDestroy; Executed by:
| 3864 | ||||||||||||||||||||||||
662 | } | - | ||||||||||||||||||||||||
663 | - | |||||||||||||||||||||||||
664 | void ListModel::insert(int elementIndex, QV4::Object *object) | - | ||||||||||||||||||||||||
665 | { | - | ||||||||||||||||||||||||
666 | insertElement(elementIndex); | - | ||||||||||||||||||||||||
667 | set(elementIndex, object); | - | ||||||||||||||||||||||||
668 | } executed 460 times by 5 tests: end of block Executed by:
| 460 | ||||||||||||||||||||||||
669 | - | |||||||||||||||||||||||||
670 | int ListModel::append(QV4::Object *object) | - | ||||||||||||||||||||||||
671 | { | - | ||||||||||||||||||||||||
672 | int elementIndex = appendElement(); | - | ||||||||||||||||||||||||
673 | set(elementIndex, object); | - | ||||||||||||||||||||||||
674 | return executed 2282 times by 8 tests: elementIndex;return elementIndex; Executed by:
executed 2282 times by 8 tests: return elementIndex; Executed by:
| 2282 | ||||||||||||||||||||||||
675 | } | - | ||||||||||||||||||||||||
676 | - | |||||||||||||||||||||||||
677 | int ListModel::setOrCreateProperty(int elementIndex, const QString &key, const QVariant &data) | - | ||||||||||||||||||||||||
678 | { | - | ||||||||||||||||||||||||
679 | int roleIndex = -1; | - | ||||||||||||||||||||||||
680 | - | |||||||||||||||||||||||||
681 | if (elementIndex >= 0
| 0-4502 | ||||||||||||||||||||||||
682 | ListElement *e = elements[elementIndex]; | - | ||||||||||||||||||||||||
683 | - | |||||||||||||||||||||||||
684 | const ListLayout::Role *r = m_layout->getRoleOrCreate(key, data); | - | ||||||||||||||||||||||||
685 | if (r
| 2-4500 | ||||||||||||||||||||||||
686 | roleIndex = e->setVariantProperty(*r, data); | - | ||||||||||||||||||||||||
687 | - | |||||||||||||||||||||||||
688 | ModelNodeMetaObject *cache = e->objectCache(); | - | ||||||||||||||||||||||||
689 | - | |||||||||||||||||||||||||
690 | if (roleIndex != -1
| 18-4448 | ||||||||||||||||||||||||
691 | cache->updateValues(QVector<int>(1, roleIndex)); executed 18 times by 3 tests: cache->updateValues(QVector<int>(1, roleIndex)); Executed by:
| 18 | ||||||||||||||||||||||||
692 | } executed 4500 times by 14 tests: end of block Executed by:
| 4500 | ||||||||||||||||||||||||
693 | } executed 4502 times by 14 tests: end of block Executed by:
| 4502 | ||||||||||||||||||||||||
694 | - | |||||||||||||||||||||||||
695 | return executed 4504 times by 14 tests: roleIndex;return roleIndex; Executed by:
executed 4504 times by 14 tests: return roleIndex; Executed by:
| 4504 | ||||||||||||||||||||||||
696 | } | - | ||||||||||||||||||||||||
697 | - | |||||||||||||||||||||||||
698 | int ListModel::setExistingProperty(int elementIndex, const QString &key, const QV4::Value &data, QV4::ExecutionEngine *eng) | - | ||||||||||||||||||||||||
699 | { | - | ||||||||||||||||||||||||
700 | int roleIndex = -1; | - | ||||||||||||||||||||||||
701 | - | |||||||||||||||||||||||||
702 | if (elementIndex >= 0
| 0-58 | ||||||||||||||||||||||||
703 | ListElement *e = elements[elementIndex]; | - | ||||||||||||||||||||||||
704 | const ListLayout::Role *r = m_layout->getExistingRole(key); | - | ||||||||||||||||||||||||
705 | if (r
| 0-58 | ||||||||||||||||||||||||
706 | roleIndex = e->setJsProperty(*r, data, eng); executed 58 times by 2 tests: roleIndex = e->setJsProperty(*r, data, eng); Executed by:
| 58 | ||||||||||||||||||||||||
707 | } executed 58 times by 2 tests: end of block Executed by:
| 58 | ||||||||||||||||||||||||
708 | - | |||||||||||||||||||||||||
709 | return executed 58 times by 2 tests: roleIndex;return roleIndex; Executed by:
executed 58 times by 2 tests: return roleIndex; Executed by:
| 58 | ||||||||||||||||||||||||
710 | } | - | ||||||||||||||||||||||||
711 | - | |||||||||||||||||||||||||
712 | inline char *ListElement::getPropertyMemory(const ListLayout::Role &role) | - | ||||||||||||||||||||||||
713 | { | - | ||||||||||||||||||||||||
714 | ListElement *e = this; | - | ||||||||||||||||||||||||
715 | int blockIndex = 0; | - | ||||||||||||||||||||||||
716 | while (blockIndex < role.blockIndex
| 48-28247 | ||||||||||||||||||||||||
717 | if (e->next == nullptr
| 10-38 | ||||||||||||||||||||||||
718 | e->next = new ListElement; | - | ||||||||||||||||||||||||
719 | e->next->uid = uid; | - | ||||||||||||||||||||||||
720 | } executed 10 times by 2 tests: end of block Executed by:
| 10 | ||||||||||||||||||||||||
721 | e = e->next; | - | ||||||||||||||||||||||||
722 | ++blockIndex; | - | ||||||||||||||||||||||||
723 | } executed 48 times by 2 tests: end of block Executed by:
| 48 | ||||||||||||||||||||||||
724 | - | |||||||||||||||||||||||||
725 | char *mem = &e->data[role.blockOffset]; | - | ||||||||||||||||||||||||
726 | return executed 28247 times by 15 tests: mem;return mem; Executed by:
executed 28247 times by 15 tests: return mem; Executed by:
| 28247 | ||||||||||||||||||||||||
727 | } | - | ||||||||||||||||||||||||
728 | - | |||||||||||||||||||||||||
729 | ModelNodeMetaObject *ListElement::objectCache() | - | ||||||||||||||||||||||||
730 | { | - | ||||||||||||||||||||||||
731 | if (!m_objectCache
| 370-8064 | ||||||||||||||||||||||||
732 | return executed 8064 times by 14 tests: nullptr;return nullptr; Executed by:
executed 8064 times by 14 tests: return nullptr; Executed by:
| 8064 | ||||||||||||||||||||||||
733 | return executed 370 times by 4 tests: ModelNodeMetaObject::get(m_objectCache);return ModelNodeMetaObject::get(m_objectCache); Executed by:
executed 370 times by 4 tests: return ModelNodeMetaObject::get(m_objectCache); Executed by:
| 370 | ||||||||||||||||||||||||
734 | } | - | ||||||||||||||||||||||||
735 | - | |||||||||||||||||||||||||
736 | StringOrTranslation *ListElement::getStringProperty(const ListLayout::Role &role) | - | ||||||||||||||||||||||||
737 | { | - | ||||||||||||||||||||||||
738 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
739 | StringOrTranslation *s = reinterpret_cast<StringOrTranslation *>(mem); | - | ||||||||||||||||||||||||
740 | return executed 5122 times by 14 tests: s;return s; Executed by:
executed 5122 times by 14 tests: return s; Executed by:
| 5122 | ||||||||||||||||||||||||
741 | } | - | ||||||||||||||||||||||||
742 | - | |||||||||||||||||||||||||
743 | QObject *ListElement::getQObjectProperty(const ListLayout::Role &role) | - | ||||||||||||||||||||||||
744 | { | - | ||||||||||||||||||||||||
745 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
746 | QPointer<QObject> *o = reinterpret_cast<QPointer<QObject> *>(mem); | - | ||||||||||||||||||||||||
747 | return never executed: o->data();return o->data(); never executed: return o->data(); | 0 | ||||||||||||||||||||||||
748 | } | - | ||||||||||||||||||||||||
749 | - | |||||||||||||||||||||||||
750 | QVariantMap *ListElement::getVariantMapProperty(const ListLayout::Role &role) | - | ||||||||||||||||||||||||
751 | { | - | ||||||||||||||||||||||||
752 | QVariantMap *map = nullptr; | - | ||||||||||||||||||||||||
753 | - | |||||||||||||||||||||||||
754 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
755 | if (isMemoryUsed<QVariantMap>(mem)
| 172-244 | ||||||||||||||||||||||||
756 | map = reinterpret_cast<QVariantMap *>(mem); executed 172 times by 2 tests: map = reinterpret_cast<QVariantMap *>(mem); Executed by:
| 172 | ||||||||||||||||||||||||
757 | - | |||||||||||||||||||||||||
758 | return executed 416 times by 2 tests: map;return map; Executed by:
executed 416 times by 2 tests: return map; Executed by:
| 416 | ||||||||||||||||||||||||
759 | } | - | ||||||||||||||||||||||||
760 | - | |||||||||||||||||||||||||
761 | QDateTime *ListElement::getDateTimeProperty(const ListLayout::Role &role) | - | ||||||||||||||||||||||||
762 | { | - | ||||||||||||||||||||||||
763 | QDateTime *dt = nullptr; | - | ||||||||||||||||||||||||
764 | - | |||||||||||||||||||||||||
765 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
766 | if (isMemoryUsed<QDateTime>(mem)
| 0-10 | ||||||||||||||||||||||||
767 | dt = reinterpret_cast<QDateTime *>(mem); executed 10 times by 1 test: dt = reinterpret_cast<QDateTime *>(mem); Executed by:
| 10 | ||||||||||||||||||||||||
768 | - | |||||||||||||||||||||||||
769 | return executed 10 times by 1 test: dt;return dt; Executed by:
executed 10 times by 1 test: return dt; Executed by:
| 10 | ||||||||||||||||||||||||
770 | } | - | ||||||||||||||||||||||||
771 | - | |||||||||||||||||||||||||
772 | QJSValue *ListElement::getFunctionProperty(const ListLayout::Role &role) | - | ||||||||||||||||||||||||
773 | { | - | ||||||||||||||||||||||||
774 | QJSValue *f = nullptr; | - | ||||||||||||||||||||||||
775 | - | |||||||||||||||||||||||||
776 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
777 | if (isMemoryUsed<QJSValue>(mem)
| 0 | ||||||||||||||||||||||||
778 | f = reinterpret_cast<QJSValue *>(mem); never executed: f = reinterpret_cast<QJSValue *>(mem); | 0 | ||||||||||||||||||||||||
779 | - | |||||||||||||||||||||||||
780 | return never executed: f;return f; never executed: return f; | 0 | ||||||||||||||||||||||||
781 | } | - | ||||||||||||||||||||||||
782 | - | |||||||||||||||||||||||||
783 | QPointer<QObject> *ListElement::getGuardProperty(const ListLayout::Role &role) | - | ||||||||||||||||||||||||
784 | { | - | ||||||||||||||||||||||||
785 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
786 | - | |||||||||||||||||||||||||
787 | bool existingGuard = false; | - | ||||||||||||||||||||||||
788 | for (size_t i=0 ; i < sizeof(QPointer<QObject>)
| 2-40 | ||||||||||||||||||||||||
789 | if (mem[i] != 0
| 8-32 | ||||||||||||||||||||||||
790 | existingGuard = true; | - | ||||||||||||||||||||||||
791 | break; executed 8 times by 1 test: break; Executed by:
| 8 | ||||||||||||||||||||||||
792 | } | - | ||||||||||||||||||||||||
793 | } executed 32 times by 1 test: end of block Executed by:
| 32 | ||||||||||||||||||||||||
794 | - | |||||||||||||||||||||||||
795 | QPointer<QObject> *o = nullptr; | - | ||||||||||||||||||||||||
796 | - | |||||||||||||||||||||||||
797 | if (existingGuard
| 2-8 | ||||||||||||||||||||||||
798 | o = reinterpret_cast<QPointer<QObject> *>(mem); executed 8 times by 1 test: o = reinterpret_cast<QPointer<QObject> *>(mem); Executed by:
| 8 | ||||||||||||||||||||||||
799 | - | |||||||||||||||||||||||||
800 | return executed 10 times by 1 test: o;return o; Executed by:
executed 10 times by 1 test: return o; Executed by:
| 10 | ||||||||||||||||||||||||
801 | } | - | ||||||||||||||||||||||||
802 | - | |||||||||||||||||||||||||
803 | ListModel *ListElement::getListProperty(const ListLayout::Role &role) | - | ||||||||||||||||||||||||
804 | { | - | ||||||||||||||||||||||||
805 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
806 | ListModel **value = reinterpret_cast<ListModel **>(mem); | - | ||||||||||||||||||||||||
807 | return executed 664 times by 4 tests: *value;return *value; Executed by:
executed 664 times by 4 tests: return *value; Executed by:
| 664 | ||||||||||||||||||||||||
808 | } | - | ||||||||||||||||||||||||
809 | - | |||||||||||||||||||||||||
810 | QVariant ListElement::getProperty(const ListLayout::Role &role, const QQmlListModel *owner, QV4::ExecutionEngine *eng) | - | ||||||||||||||||||||||||
811 | { | - | ||||||||||||||||||||||||
812 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
813 | - | |||||||||||||||||||||||||
814 | QVariant data; | - | ||||||||||||||||||||||||
815 | - | |||||||||||||||||||||||||
816 | switch (role.type) { | - | ||||||||||||||||||||||||
817 | case executed 1848 times by 4 tests: ListLayout::Role::Number:case ListLayout::Role::Number: Executed by:
executed 1848 times by 4 tests: case ListLayout::Role::Number: Executed by:
| 1848 | ||||||||||||||||||||||||
818 | { | - | ||||||||||||||||||||||||
819 | double *value = reinterpret_cast<double *>(mem); | - | ||||||||||||||||||||||||
820 | data = *value; | - | ||||||||||||||||||||||||
821 | } | - | ||||||||||||||||||||||||
822 | break; executed 1848 times by 4 tests: break; Executed by:
| 1848 | ||||||||||||||||||||||||
823 | case executed 10271 times by 12 tests: ListLayout::Role::String:case ListLayout::Role::String: Executed by:
executed 10271 times by 12 tests: case ListLayout::Role::String: Executed by:
| 10271 | ||||||||||||||||||||||||
824 | { | - | ||||||||||||||||||||||||
825 | StringOrTranslation *value = reinterpret_cast<StringOrTranslation *>(mem); | - | ||||||||||||||||||||||||
826 | if (value->isSet()
| 0-10271 | ||||||||||||||||||||||||
827 | data = value->toString(owner); executed 10271 times by 12 tests: data = value->toString(owner); Executed by:
| 10271 | ||||||||||||||||||||||||
828 | } | - | ||||||||||||||||||||||||
829 | break; executed 10271 times by 12 tests: break; Executed by:
| 10271 | ||||||||||||||||||||||||
830 | case executed 122 times by 2 tests: ListLayout::Role::Bool:case ListLayout::Role::Bool: Executed by:
executed 122 times by 2 tests: case ListLayout::Role::Bool: Executed by:
| 122 | ||||||||||||||||||||||||
831 | { | - | ||||||||||||||||||||||||
832 | bool *value = reinterpret_cast<bool *>(mem); | - | ||||||||||||||||||||||||
833 | data = *value; | - | ||||||||||||||||||||||||
834 | } | - | ||||||||||||||||||||||||
835 | break; executed 122 times by 2 tests: break; Executed by:
| 122 | ||||||||||||||||||||||||
836 | case executed 202 times by 4 tests: ListLayout::Role::List:case ListLayout::Role::List: Executed by:
executed 202 times by 4 tests: case ListLayout::Role::List: Executed by:
| 202 | ||||||||||||||||||||||||
837 | { | - | ||||||||||||||||||||||||
838 | ListModel **value = reinterpret_cast<ListModel **>(mem); | - | ||||||||||||||||||||||||
839 | ListModel *model = *value; | - | ||||||||||||||||||||||||
840 | - | |||||||||||||||||||||||||
841 | if (model
| 0-202 | ||||||||||||||||||||||||
842 | if (model->m_modelCache == nullptr
| 64-138 | ||||||||||||||||||||||||
843 | model->m_modelCache = new QQmlListModel(owner, model, eng); | - | ||||||||||||||||||||||||
844 | QQmlEngine::setContextForObject(model->m_modelCache, QQmlEngine::contextForObject(owner)); | - | ||||||||||||||||||||||||
845 | } executed 138 times by 4 tests: end of block Executed by:
| 138 | ||||||||||||||||||||||||
846 | - | |||||||||||||||||||||||||
847 | QObject *object = model->m_modelCache; | - | ||||||||||||||||||||||||
848 | data = QVariant::fromValue(object); | - | ||||||||||||||||||||||||
849 | } executed 202 times by 4 tests: end of block Executed by:
| 202 | ||||||||||||||||||||||||
850 | } | - | ||||||||||||||||||||||||
851 | break; executed 202 times by 4 tests: break; Executed by:
| 202 | ||||||||||||||||||||||||
852 | case executed 4 times by 1 test: ListLayout::Role::QObject:case ListLayout::Role::QObject: Executed by:
executed 4 times by 1 test: case ListLayout::Role::QObject: Executed by:
| 4 | ||||||||||||||||||||||||
853 | { | - | ||||||||||||||||||||||||
854 | QPointer<QObject> *guard = reinterpret_cast<QPointer<QObject> *>(mem); | - | ||||||||||||||||||||||||
855 | QObject *object = guard->data(); | - | ||||||||||||||||||||||||
856 | if (object
| 0-4 | ||||||||||||||||||||||||
857 | data = QVariant::fromValue(object); executed 4 times by 1 test: data = QVariant::fromValue(object); Executed by:
| 4 | ||||||||||||||||||||||||
858 | } | - | ||||||||||||||||||||||||
859 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
860 | case executed 24 times by 2 tests: ListLayout::Role::VariantMap:case ListLayout::Role::VariantMap: Executed by:
executed 24 times by 2 tests: case ListLayout::Role::VariantMap: Executed by:
| 24 | ||||||||||||||||||||||||
861 | { | - | ||||||||||||||||||||||||
862 | if (isMemoryUsed<QVariantMap>(mem)
| 0-24 | ||||||||||||||||||||||||
863 | QVariantMap *map = reinterpret_cast<QVariantMap *>(mem); | - | ||||||||||||||||||||||||
864 | data = *map; | - | ||||||||||||||||||||||||
865 | } executed 24 times by 2 tests: end of block Executed by:
| 24 | ||||||||||||||||||||||||
866 | } | - | ||||||||||||||||||||||||
867 | break; executed 24 times by 2 tests: break; Executed by:
| 24 | ||||||||||||||||||||||||
868 | case executed 10 times by 1 test: ListLayout::Role::DateTime:case ListLayout::Role::DateTime: Executed by:
executed 10 times by 1 test: case ListLayout::Role::DateTime: Executed by:
| 10 | ||||||||||||||||||||||||
869 | { | - | ||||||||||||||||||||||||
870 | if (isMemoryUsed<QDateTime>(mem)
| 0-10 | ||||||||||||||||||||||||
871 | QDateTime *dt = reinterpret_cast<QDateTime *>(mem); | - | ||||||||||||||||||||||||
872 | data = *dt; | - | ||||||||||||||||||||||||
873 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
874 | } | - | ||||||||||||||||||||||||
875 | break; executed 10 times by 1 test: break; Executed by:
| 10 | ||||||||||||||||||||||||
876 | case never executed: ListLayout::Role::Function:case ListLayout::Role::Function: never executed: case ListLayout::Role::Function: | 0 | ||||||||||||||||||||||||
877 | { | - | ||||||||||||||||||||||||
878 | if (isMemoryUsed<QJSValue>(mem)
| 0 | ||||||||||||||||||||||||
879 | QJSValue *func = reinterpret_cast<QJSValue *>(mem); | - | ||||||||||||||||||||||||
880 | data = QVariant::fromValue(*func); | - | ||||||||||||||||||||||||
881 | } never executed: end of block | 0 | ||||||||||||||||||||||||
882 | } | - | ||||||||||||||||||||||||
883 | break; never executed: break; | 0 | ||||||||||||||||||||||||
884 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||
885 | break; never executed: break; | 0 | ||||||||||||||||||||||||
886 | } | - | ||||||||||||||||||||||||
887 | - | |||||||||||||||||||||||||
888 | return executed 12481 times by 13 tests: data;return data; Executed by:
executed 12481 times by 13 tests: return data; Executed by:
| 12481 | ||||||||||||||||||||||||
889 | } | - | ||||||||||||||||||||||||
890 | - | |||||||||||||||||||||||||
891 | int ListElement::setStringProperty(const ListLayout::Role &role, const QString &s) | - | ||||||||||||||||||||||||
892 | { | - | ||||||||||||||||||||||||
893 | int roleIndex = -1; | - | ||||||||||||||||||||||||
894 | - | |||||||||||||||||||||||||
895 | if (role.type == ListLayout::Role::String
| 0-3956 | ||||||||||||||||||||||||
896 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
897 | StringOrTranslation *c = reinterpret_cast<StringOrTranslation *>(mem); | - | ||||||||||||||||||||||||
898 | bool changed; | - | ||||||||||||||||||||||||
899 | if (!c->isSet()
| 0-3950 | ||||||||||||||||||||||||
900 | changed = true; executed 3950 times by 12 tests: changed = true; Executed by:
| 3950 | ||||||||||||||||||||||||
901 | else | - | ||||||||||||||||||||||||
902 | changed = c->asString().compare(s) != 0; executed 6 times by 2 tests: changed = c->asString().compare(s) != 0; Executed by:
| 6 | ||||||||||||||||||||||||
903 | c->setString(s); | - | ||||||||||||||||||||||||
904 | if (changed
| 0-3956 | ||||||||||||||||||||||||
905 | roleIndex = role.index; executed 3956 times by 12 tests: roleIndex = role.index; Executed by:
| 3956 | ||||||||||||||||||||||||
906 | } executed 3956 times by 12 tests: end of block Executed by:
| 3956 | ||||||||||||||||||||||||
907 | - | |||||||||||||||||||||||||
908 | return executed 3956 times by 12 tests: roleIndex;return roleIndex; Executed by:
executed 3956 times by 12 tests: return roleIndex; Executed by:
| 3956 | ||||||||||||||||||||||||
909 | } | - | ||||||||||||||||||||||||
910 | - | |||||||||||||||||||||||||
911 | int ListElement::setDoubleProperty(const ListLayout::Role &role, double d) | - | ||||||||||||||||||||||||
912 | { | - | ||||||||||||||||||||||||
913 | int roleIndex = -1; | - | ||||||||||||||||||||||||
914 | - | |||||||||||||||||||||||||
915 | if (role.type == ListLayout::Role::Number
| 6-1446 | ||||||||||||||||||||||||
916 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
917 | double *value = reinterpret_cast<double *>(mem); | - | ||||||||||||||||||||||||
918 | bool changed = *value != d; | - | ||||||||||||||||||||||||
919 | *value = d; | - | ||||||||||||||||||||||||
920 | if (changed
| 236-1210 | ||||||||||||||||||||||||
921 | roleIndex = role.index; executed 1210 times by 5 tests: roleIndex = role.index; Executed by:
| 1210 | ||||||||||||||||||||||||
922 | } executed 1446 times by 5 tests: end of block Executed by:
| 1446 | ||||||||||||||||||||||||
923 | - | |||||||||||||||||||||||||
924 | return executed 1452 times by 5 tests: roleIndex;return roleIndex; Executed by:
executed 1452 times by 5 tests: return roleIndex; Executed by:
| 1452 | ||||||||||||||||||||||||
925 | } | - | ||||||||||||||||||||||||
926 | - | |||||||||||||||||||||||||
927 | int ListElement::setBoolProperty(const ListLayout::Role &role, bool b) | - | ||||||||||||||||||||||||
928 | { | - | ||||||||||||||||||||||||
929 | int roleIndex = -1; | - | ||||||||||||||||||||||||
930 | - | |||||||||||||||||||||||||
931 | if (role.type == ListLayout::Role::Bool
| 0-70 | ||||||||||||||||||||||||
932 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
933 | bool *value = reinterpret_cast<bool *>(mem); | - | ||||||||||||||||||||||||
934 | bool changed = *value != b; | - | ||||||||||||||||||||||||
935 | *value = b; | - | ||||||||||||||||||||||||
936 | if (changed
| 30-40 | ||||||||||||||||||||||||
937 | roleIndex = role.index; executed 40 times by 3 tests: roleIndex = role.index; Executed by:
| 40 | ||||||||||||||||||||||||
938 | } executed 70 times by 3 tests: end of block Executed by:
| 70 | ||||||||||||||||||||||||
939 | - | |||||||||||||||||||||||||
940 | return executed 70 times by 3 tests: roleIndex;return roleIndex; Executed by:
executed 70 times by 3 tests: return roleIndex; Executed by:
| 70 | ||||||||||||||||||||||||
941 | } | - | ||||||||||||||||||||||||
942 | - | |||||||||||||||||||||||||
943 | int ListElement::setListProperty(const ListLayout::Role &role, ListModel *m) | - | ||||||||||||||||||||||||
944 | { | - | ||||||||||||||||||||||||
945 | int roleIndex = -1; | - | ||||||||||||||||||||||||
946 | - | |||||||||||||||||||||||||
947 | if (role.type == ListLayout::Role::List
| 0-68 | ||||||||||||||||||||||||
948 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
949 | ListModel **value = reinterpret_cast<ListModel **>(mem); | - | ||||||||||||||||||||||||
950 | if (*
| 0-46 | ||||||||||||||||||||||||
951 | (*value)->destroy(); | - | ||||||||||||||||||||||||
952 | delete *value; | - | ||||||||||||||||||||||||
953 | } executed 22 times by 2 tests: end of block Executed by:
| 22 | ||||||||||||||||||||||||
954 | *value = m; | - | ||||||||||||||||||||||||
955 | roleIndex = role.index; | - | ||||||||||||||||||||||||
956 | } executed 68 times by 3 tests: end of block Executed by:
| 68 | ||||||||||||||||||||||||
957 | - | |||||||||||||||||||||||||
958 | return executed 68 times by 3 tests: roleIndex;return roleIndex; Executed by:
executed 68 times by 3 tests: return roleIndex; Executed by:
| 68 | ||||||||||||||||||||||||
959 | } | - | ||||||||||||||||||||||||
960 | - | |||||||||||||||||||||||||
961 | int ListElement::setQObjectProperty(const ListLayout::Role &role, QObject *o) | - | ||||||||||||||||||||||||
962 | { | - | ||||||||||||||||||||||||
963 | int roleIndex = -1; | - | ||||||||||||||||||||||||
964 | - | |||||||||||||||||||||||||
965 | if (role.type == ListLayout::Role::QObject
| 0-2 | ||||||||||||||||||||||||
966 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
967 | QPointer<QObject> *g = reinterpret_cast<QPointer<QObject> *>(mem); | - | ||||||||||||||||||||||||
968 | bool existingGuard = false; | - | ||||||||||||||||||||||||
969 | for (size_t i=0 ; i < sizeof(QPointer<QObject>)
| 0-2 | ||||||||||||||||||||||||
970 | if (mem[i] != 0
| 0-2 | ||||||||||||||||||||||||
971 | existingGuard = true; | - | ||||||||||||||||||||||||
972 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||
973 | } | - | ||||||||||||||||||||||||
974 | } never executed: end of block | 0 | ||||||||||||||||||||||||
975 | bool changed; | - | ||||||||||||||||||||||||
976 | if (existingGuard
| 0-2 | ||||||||||||||||||||||||
977 | changed = g->data() != o; | - | ||||||||||||||||||||||||
978 | g->~QPointer(); | - | ||||||||||||||||||||||||
979 | } executed 2 times by 1 test: else {end of block Executed by:
| 2 | ||||||||||||||||||||||||
980 | changed = true; | - | ||||||||||||||||||||||||
981 | } never executed: end of block | 0 | ||||||||||||||||||||||||
982 | new (mem) QPointer<QObject>(o); | - | ||||||||||||||||||||||||
983 | if (changed
| 0-2 | ||||||||||||||||||||||||
984 | roleIndex = role.index; executed 2 times by 1 test: roleIndex = role.index; Executed by:
| 2 | ||||||||||||||||||||||||
985 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
986 | - | |||||||||||||||||||||||||
987 | return executed 2 times by 1 test: roleIndex;return roleIndex; Executed by:
executed 2 times by 1 test: return roleIndex; Executed by:
| 2 | ||||||||||||||||||||||||
988 | } | - | ||||||||||||||||||||||||
989 | - | |||||||||||||||||||||||||
990 | int ListElement::setVariantMapProperty(const ListLayout::Role &role, QV4::Object *o) | - | ||||||||||||||||||||||||
991 | { | - | ||||||||||||||||||||||||
992 | int roleIndex = -1; | - | ||||||||||||||||||||||||
993 | - | |||||||||||||||||||||||||
994 | if (role.type == ListLayout::Role::VariantMap
| 0-18 | ||||||||||||||||||||||||
995 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
996 | if (isMemoryUsed<QVariantMap>(mem)
| 6-12 | ||||||||||||||||||||||||
997 | QVariantMap *map = reinterpret_cast<QVariantMap *>(mem); | - | ||||||||||||||||||||||||
998 | map->~QMap(); | - | ||||||||||||||||||||||||
999 | } executed 12 times by 2 tests: end of block Executed by:
| 12 | ||||||||||||||||||||||||
1000 | new (mem) QVariantMap(o->engine()->variantMapFromJS(o)); | - | ||||||||||||||||||||||||
1001 | roleIndex = role.index; | - | ||||||||||||||||||||||||
1002 | } executed 18 times by 2 tests: end of block Executed by:
| 18 | ||||||||||||||||||||||||
1003 | - | |||||||||||||||||||||||||
1004 | return executed 18 times by 2 tests: roleIndex;return roleIndex; Executed by:
executed 18 times by 2 tests: return roleIndex; Executed by:
| 18 | ||||||||||||||||||||||||
1005 | } | - | ||||||||||||||||||||||||
1006 | - | |||||||||||||||||||||||||
1007 | int ListElement::setVariantMapProperty(const ListLayout::Role &role, QVariantMap *m) | - | ||||||||||||||||||||||||
1008 | { | - | ||||||||||||||||||||||||
1009 | int roleIndex = -1; | - | ||||||||||||||||||||||||
1010 | - | |||||||||||||||||||||||||
1011 | if (role.type == ListLayout::Role::VariantMap
| 0-106 | ||||||||||||||||||||||||
1012 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
1013 | if (isMemoryUsed<QVariantMap>(mem)
| 12-94 | ||||||||||||||||||||||||
1014 | QVariantMap *map = reinterpret_cast<QVariantMap *>(mem); | - | ||||||||||||||||||||||||
1015 | if (m
| 0-6 | ||||||||||||||||||||||||
1016 | return executed 6 times by 1 test: roleIndex;return roleIndex; Executed by:
executed 6 times by 1 test: return roleIndex; Executed by:
| 6 | ||||||||||||||||||||||||
1017 | map->~QMap(); | - | ||||||||||||||||||||||||
1018 | } executed 6 times by 2 tests: else if (!mend of block Executed by:
| 6-56 | ||||||||||||||||||||||||
1019 | return executed 56 times by 1 test: roleIndex;return roleIndex; Executed by:
executed 56 times by 1 test: return roleIndex; Executed by:
| 56 | ||||||||||||||||||||||||
1020 | } | - | ||||||||||||||||||||||||
1021 | if (m
| 6-38 | ||||||||||||||||||||||||
1022 | new executed 38 times by 1 test: (mem) QVariantMap(*m);new (mem) QVariantMap(*m); Executed by:
executed 38 times by 1 test: new (mem) QVariantMap(*m); Executed by:
| 38 | ||||||||||||||||||||||||
1023 | else | - | ||||||||||||||||||||||||
1024 | new executed 6 times by 2 tests: (mem) QVariantMap;new (mem) QVariantMap; Executed by:
executed 6 times by 2 tests: new (mem) QVariantMap; Executed by:
| 6 | ||||||||||||||||||||||||
1025 | roleIndex = role.index; | - | ||||||||||||||||||||||||
1026 | } executed 44 times by 2 tests: end of block Executed by:
| 44 | ||||||||||||||||||||||||
1027 | - | |||||||||||||||||||||||||
1028 | return executed 44 times by 2 tests: roleIndex;return roleIndex; Executed by:
executed 44 times by 2 tests: return roleIndex; Executed by:
| 44 | ||||||||||||||||||||||||
1029 | } | - | ||||||||||||||||||||||||
1030 | - | |||||||||||||||||||||||||
1031 | int ListElement::setDateTimeProperty(const ListLayout::Role &role, const QDateTime &dt) | - | ||||||||||||||||||||||||
1032 | { | - | ||||||||||||||||||||||||
1033 | int roleIndex = -1; | - | ||||||||||||||||||||||||
1034 | - | |||||||||||||||||||||||||
1035 | if (role.type == ListLayout::Role::DateTime
| 0-8 | ||||||||||||||||||||||||
1036 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
1037 | if (isMemoryUsed<QDateTime>(mem)
| 0-8 | ||||||||||||||||||||||||
1038 | QDateTime *dt = reinterpret_cast<QDateTime *>(mem); | - | ||||||||||||||||||||||||
1039 | dt->~QDateTime(); | - | ||||||||||||||||||||||||
1040 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
1041 | new (mem) QDateTime(dt); | - | ||||||||||||||||||||||||
1042 | roleIndex = role.index; | - | ||||||||||||||||||||||||
1043 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
1044 | - | |||||||||||||||||||||||||
1045 | return executed 8 times by 1 test: roleIndex;return roleIndex; Executed by:
executed 8 times by 1 test: return roleIndex; Executed by:
| 8 | ||||||||||||||||||||||||
1046 | } | - | ||||||||||||||||||||||||
1047 | - | |||||||||||||||||||||||||
1048 | int ListElement::setFunctionProperty(const ListLayout::Role &role, const QJSValue &f) | - | ||||||||||||||||||||||||
1049 | { | - | ||||||||||||||||||||||||
1050 | int roleIndex = -1; | - | ||||||||||||||||||||||||
1051 | - | |||||||||||||||||||||||||
1052 | if (role.type == ListLayout::Role::Function
| 0 | ||||||||||||||||||||||||
1053 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
1054 | if (isMemoryUsed<QJSValue>(mem)
| 0 | ||||||||||||||||||||||||
1055 | QJSValue *f = reinterpret_cast<QJSValue *>(mem); | - | ||||||||||||||||||||||||
1056 | f->~QJSValue(); | - | ||||||||||||||||||||||||
1057 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1058 | new (mem) QJSValue(f); | - | ||||||||||||||||||||||||
1059 | roleIndex = role.index; | - | ||||||||||||||||||||||||
1060 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1061 | - | |||||||||||||||||||||||||
1062 | return never executed: roleIndex;return roleIndex; never executed: return roleIndex; | 0 | ||||||||||||||||||||||||
1063 | } | - | ||||||||||||||||||||||||
1064 | - | |||||||||||||||||||||||||
1065 | int ListElement::setTranslationProperty(const ListLayout::Role &role, const QV4::CompiledData::Binding *b) | - | ||||||||||||||||||||||||
1066 | { | - | ||||||||||||||||||||||||
1067 | int roleIndex = -1; | - | ||||||||||||||||||||||||
1068 | - | |||||||||||||||||||||||||
1069 | if (role.type == ListLayout::Role::String
| 0-8 | ||||||||||||||||||||||||
1070 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
1071 | StringOrTranslation *s = reinterpret_cast<StringOrTranslation *>(mem); | - | ||||||||||||||||||||||||
1072 | s->setTranslation(b); | - | ||||||||||||||||||||||||
1073 | roleIndex = role.index; | - | ||||||||||||||||||||||||
1074 | } executed 8 times by 3 tests: end of block Executed by:
| 8 | ||||||||||||||||||||||||
1075 | - | |||||||||||||||||||||||||
1076 | return executed 8 times by 3 tests: roleIndex;return roleIndex; Executed by:
executed 8 times by 3 tests: return roleIndex; Executed by:
| 8 | ||||||||||||||||||||||||
1077 | } | - | ||||||||||||||||||||||||
1078 | - | |||||||||||||||||||||||||
1079 | - | |||||||||||||||||||||||||
1080 | void ListElement::setStringPropertyFast(const ListLayout::Role &role, const QString &s) | - | ||||||||||||||||||||||||
1081 | { | - | ||||||||||||||||||||||||
1082 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
1083 | new (mem) StringOrTranslation(s); | - | ||||||||||||||||||||||||
1084 | } executed 1170 times by 8 tests: end of block Executed by:
| 1170 | ||||||||||||||||||||||||
1085 | - | |||||||||||||||||||||||||
1086 | void ListElement::setDoublePropertyFast(const ListLayout::Role &role, double d) | - | ||||||||||||||||||||||||
1087 | { | - | ||||||||||||||||||||||||
1088 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
1089 | double *value = new (mem) double; | - | ||||||||||||||||||||||||
1090 | *value = d; | - | ||||||||||||||||||||||||
1091 | } executed 2334 times by 5 tests: end of block Executed by:
| 2334 | ||||||||||||||||||||||||
1092 | - | |||||||||||||||||||||||||
1093 | void ListElement::setBoolPropertyFast(const ListLayout::Role &role, bool b) | - | ||||||||||||||||||||||||
1094 | { | - | ||||||||||||||||||||||||
1095 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
1096 | bool *value = new (mem) bool; | - | ||||||||||||||||||||||||
1097 | *value = b; | - | ||||||||||||||||||||||||
1098 | } executed 88 times by 2 tests: end of block Executed by:
| 88 | ||||||||||||||||||||||||
1099 | - | |||||||||||||||||||||||||
1100 | void ListElement::setQObjectPropertyFast(const ListLayout::Role &role, QObject *o) | - | ||||||||||||||||||||||||
1101 | { | - | ||||||||||||||||||||||||
1102 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
1103 | new (mem) QPointer<QObject>(o); | - | ||||||||||||||||||||||||
1104 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
1105 | - | |||||||||||||||||||||||||
1106 | void ListElement::setListPropertyFast(const ListLayout::Role &role, ListModel *m) | - | ||||||||||||||||||||||||
1107 | { | - | ||||||||||||||||||||||||
1108 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
1109 | ListModel **value = new (mem) ListModel *; | - | ||||||||||||||||||||||||
1110 | *value = m; | - | ||||||||||||||||||||||||
1111 | } executed 168 times by 3 tests: end of block Executed by:
| 168 | ||||||||||||||||||||||||
1112 | - | |||||||||||||||||||||||||
1113 | void ListElement::setVariantMapFast(const ListLayout::Role &role, QV4::Object *o) | - | ||||||||||||||||||||||||
1114 | { | - | ||||||||||||||||||||||||
1115 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
1116 | QVariantMap *map = new (mem) QVariantMap; | - | ||||||||||||||||||||||||
1117 | *map = o->engine()->variantMapFromJS(o); | - | ||||||||||||||||||||||||
1118 | } executed 84 times by 2 tests: end of block Executed by:
| 84 | ||||||||||||||||||||||||
1119 | - | |||||||||||||||||||||||||
1120 | void ListElement::setDateTimePropertyFast(const ListLayout::Role &role, const QDateTime &dt) | - | ||||||||||||||||||||||||
1121 | { | - | ||||||||||||||||||||||||
1122 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
1123 | new (mem) QDateTime(dt); | - | ||||||||||||||||||||||||
1124 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
1125 | - | |||||||||||||||||||||||||
1126 | void ListElement::setFunctionPropertyFast(const ListLayout::Role &role, const QJSValue &f) | - | ||||||||||||||||||||||||
1127 | { | - | ||||||||||||||||||||||||
1128 | char *mem = getPropertyMemory(role); | - | ||||||||||||||||||||||||
1129 | new (mem) QJSValue(f); | - | ||||||||||||||||||||||||
1130 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1131 | - | |||||||||||||||||||||||||
1132 | void ListElement::clearProperty(const ListLayout::Role &role) | - | ||||||||||||||||||||||||
1133 | { | - | ||||||||||||||||||||||||
1134 | switch (role.type) { | - | ||||||||||||||||||||||||
1135 | case never executed: ListLayout::Role::String:case ListLayout::Role::String: never executed: case ListLayout::Role::String: | 0 | ||||||||||||||||||||||||
1136 | setStringProperty(role, QString()); | - | ||||||||||||||||||||||||
1137 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1138 | case executed 6 times by 2 tests: ListLayout::Role::Number:case ListLayout::Role::Number: Executed by:
executed 6 times by 2 tests: case ListLayout::Role::Number: Executed by:
| 6 | ||||||||||||||||||||||||
1139 | setDoubleProperty(role, 0.0); | - | ||||||||||||||||||||||||
1140 | break; executed 6 times by 2 tests: break; Executed by:
| 6 | ||||||||||||||||||||||||
1141 | case never executed: ListLayout::Role::Bool:case ListLayout::Role::Bool: never executed: case ListLayout::Role::Bool: | 0 | ||||||||||||||||||||||||
1142 | setBoolProperty(role, false); | - | ||||||||||||||||||||||||
1143 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1144 | case never executed: ListLayout::Role::List:case ListLayout::Role::List: never executed: case ListLayout::Role::List: | 0 | ||||||||||||||||||||||||
1145 | setListProperty(role, nullptr); | - | ||||||||||||||||||||||||
1146 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1147 | case never executed: ListLayout::Role::QObject:case ListLayout::Role::QObject: never executed: case ListLayout::Role::QObject: | 0 | ||||||||||||||||||||||||
1148 | setQObjectProperty(role, nullptr); | - | ||||||||||||||||||||||||
1149 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1150 | case executed 2 times by 1 test: ListLayout::Role::DateTime:case ListLayout::Role::DateTime: Executed by:
executed 2 times by 1 test: case ListLayout::Role::DateTime: Executed by:
| 2 | ||||||||||||||||||||||||
1151 | setDateTimeProperty(role, QDateTime()); | - | ||||||||||||||||||||||||
1152 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||
1153 | case executed 6 times by 2 tests: ListLayout::Role::VariantMap:case ListLayout::Role::VariantMap: Executed by:
executed 6 times by 2 tests: case ListLayout::Role::VariantMap: Executed by:
| 6 | ||||||||||||||||||||||||
1154 | setVariantMapProperty(role, (QVariantMap *)nullptr); | - | ||||||||||||||||||||||||
1155 | break; executed 6 times by 2 tests: break; Executed by:
| 6 | ||||||||||||||||||||||||
1156 | case never executed: ListLayout::Role::Function:case ListLayout::Role::Function: never executed: case ListLayout::Role::Function: | 0 | ||||||||||||||||||||||||
1157 | setFunctionProperty(role, QJSValue()); | - | ||||||||||||||||||||||||
1158 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1159 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||
1160 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1161 | } | - | ||||||||||||||||||||||||
1162 | } | - | ||||||||||||||||||||||||
1163 | - | |||||||||||||||||||||||||
1164 | ListElement::ListElement() | - | ||||||||||||||||||||||||
1165 | { | - | ||||||||||||||||||||||||
1166 | m_objectCache = nullptr; | - | ||||||||||||||||||||||||
1167 | uid = uidCounter.fetchAndAddOrdered(1); | - | ||||||||||||||||||||||||
1168 | next = nullptr; | - | ||||||||||||||||||||||||
1169 | memset(data, 0, sizeof(data)); | - | ||||||||||||||||||||||||
1170 | } executed 6030 times by 15 tests: end of block Executed by:
| 6030 | ||||||||||||||||||||||||
1171 | - | |||||||||||||||||||||||||
1172 | ListElement::ListElement(int existingUid) | - | ||||||||||||||||||||||||
1173 | { | - | ||||||||||||||||||||||||
1174 | m_objectCache = nullptr; | - | ||||||||||||||||||||||||
1175 | uid = existingUid; | - | ||||||||||||||||||||||||
1176 | next = nullptr; | - | ||||||||||||||||||||||||
1177 | memset(data, 0, sizeof(data)); | - | ||||||||||||||||||||||||
1178 | } executed 634 times by 1 test: end of block Executed by:
| 634 | ||||||||||||||||||||||||
1179 | - | |||||||||||||||||||||||||
1180 | ListElement::~ListElement() | - | ||||||||||||||||||||||||
1181 | { | - | ||||||||||||||||||||||||
1182 | delete next; | - | ||||||||||||||||||||||||
1183 | } executed 6650 times by 15 tests: end of block Executed by:
| 6650 | ||||||||||||||||||||||||
1184 | - | |||||||||||||||||||||||||
1185 | QVector<int> ListElement::sync(ListElement *src, ListLayout *srcLayout, ListElement *target, ListLayout *targetLayout) | - | ||||||||||||||||||||||||
1186 | { | - | ||||||||||||||||||||||||
1187 | QVector<int> changedRoles; | - | ||||||||||||||||||||||||
1188 | for (int i=0 ; i < srcLayout->roleCount()
| 694-1104 | ||||||||||||||||||||||||
1189 | const ListLayout::Role &srcRole = srcLayout->getExistingRole(i); | - | ||||||||||||||||||||||||
1190 | const ListLayout::Role &targetRole = targetLayout->getExistingRole(i); | - | ||||||||||||||||||||||||
1191 | - | |||||||||||||||||||||||||
1192 | int roleIndex = -1; | - | ||||||||||||||||||||||||
1193 | switch (srcRole.type) { | - | ||||||||||||||||||||||||
1194 | case executed 106 times by 1 test: ListLayout::Role::List:case ListLayout::Role::List: Executed by:
executed 106 times by 1 test: case ListLayout::Role::List: Executed by:
| 106 | ||||||||||||||||||||||||
1195 | { | - | ||||||||||||||||||||||||
1196 | ListModel *srcSubModel = src->getListProperty(srcRole); | - | ||||||||||||||||||||||||
1197 | ListModel *targetSubModel = target->getListProperty(targetRole); | - | ||||||||||||||||||||||||
1198 | - | |||||||||||||||||||||||||
1199 | if (srcSubModel
| 50-56 | ||||||||||||||||||||||||
1200 | if (targetSubModel == nullptr
| 14-42 | ||||||||||||||||||||||||
1201 | targetSubModel = new ListModel(targetRole.subLayout, nullptr); | - | ||||||||||||||||||||||||
1202 | target->setListPropertyFast(targetRole, targetSubModel); | - | ||||||||||||||||||||||||
1203 | } executed 42 times by 1 test: end of block Executed by:
| 42 | ||||||||||||||||||||||||
1204 | if (ListModel::sync(srcSubModel, targetSubModel)
| 14-42 | ||||||||||||||||||||||||
1205 | roleIndex = targetRole.index; executed 42 times by 1 test: roleIndex = targetRole.index; Executed by:
| 42 | ||||||||||||||||||||||||
1206 | } executed 56 times by 1 test: end of block Executed by:
| 56 | ||||||||||||||||||||||||
1207 | } | - | ||||||||||||||||||||||||
1208 | break; executed 106 times by 1 test: break; Executed by:
| 106 | ||||||||||||||||||||||||
1209 | case never executed: ListLayout::Role::QObject:case ListLayout::Role::QObject: never executed: case ListLayout::Role::QObject: | 0 | ||||||||||||||||||||||||
1210 | { | - | ||||||||||||||||||||||||
1211 | QObject *object = src->getQObjectProperty(srcRole); | - | ||||||||||||||||||||||||
1212 | roleIndex = target->setQObjectProperty(targetRole, object); | - | ||||||||||||||||||||||||
1213 | } | - | ||||||||||||||||||||||||
1214 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1215 | case executed 8 times by 1 test: ListLayout::Role::String:case ListLayout::Role::String: Executed by:
executed 8 times by 1 test: case ListLayout::Role::String: Executed by:
| 8 | ||||||||||||||||||||||||
1216 | case executed 890 times by 1 test: ListLayout::Role::Number:case ListLayout::Role::Number: Executed by:
executed 890 times by 1 test: case ListLayout::Role::Number: Executed by:
| 890 | ||||||||||||||||||||||||
1217 | case never executed: ListLayout::Role::Bool:case ListLayout::Role::Bool: never executed: case ListLayout::Role::Bool: | 0 | ||||||||||||||||||||||||
1218 | case never executed: ListLayout::Role::DateTime:case ListLayout::Role::DateTime: never executed: case ListLayout::Role::DateTime: | 0 | ||||||||||||||||||||||||
1219 | case never executed: ListLayout::Role::Function:case ListLayout::Role::Function: never executed: case ListLayout::Role::Function: | 0 | ||||||||||||||||||||||||
1220 | { | - | ||||||||||||||||||||||||
1221 | QVariant v = src->getProperty(srcRole, nullptr, nullptr); | - | ||||||||||||||||||||||||
1222 | roleIndex = target->setVariantProperty(targetRole, v); | - | ||||||||||||||||||||||||
1223 | } | - | ||||||||||||||||||||||||
1224 | break; executed 898 times by 1 test: break; Executed by:
| 898 | ||||||||||||||||||||||||
1225 | case executed 100 times by 1 test: ListLayout::Role::VariantMap:case ListLayout::Role::VariantMap: Executed by:
executed 100 times by 1 test: case ListLayout::Role::VariantMap: Executed by:
| 100 | ||||||||||||||||||||||||
1226 | { | - | ||||||||||||||||||||||||
1227 | QVariantMap *map = src->getVariantMapProperty(srcRole); | - | ||||||||||||||||||||||||
1228 | roleIndex = target->setVariantMapProperty(targetRole, map); | - | ||||||||||||||||||||||||
1229 | } | - | ||||||||||||||||||||||||
1230 | break; executed 100 times by 1 test: break; Executed by:
| 100 | ||||||||||||||||||||||||
1231 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||
1232 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1233 | } | - | ||||||||||||||||||||||||
1234 | if (roleIndex >= 0
| 338-766 | ||||||||||||||||||||||||
1235 | changedRoles << roleIndex; executed 766 times by 1 test: changedRoles << roleIndex; Executed by:
| 766 | ||||||||||||||||||||||||
1236 | } executed 1104 times by 1 test: end of block Executed by:
| 1104 | ||||||||||||||||||||||||
1237 | - | |||||||||||||||||||||||||
1238 | return executed 694 times by 1 test: changedRoles;return changedRoles; Executed by:
executed 694 times by 1 test: return changedRoles; Executed by:
| 694 | ||||||||||||||||||||||||
1239 | } | - | ||||||||||||||||||||||||
1240 | - | |||||||||||||||||||||||||
1241 | void ListElement::destroy(ListLayout *layout) | - | ||||||||||||||||||||||||
1242 | { | - | ||||||||||||||||||||||||
1243 | if (layout
| 10-6640 | ||||||||||||||||||||||||
1244 | for (int i=0 ; i < layout->roleCount()
| 6640-9940 | ||||||||||||||||||||||||
1245 | const ListLayout::Role &r = layout->getExistingRole(i); | - | ||||||||||||||||||||||||
1246 | - | |||||||||||||||||||||||||
1247 | switch (r.type) { | - | ||||||||||||||||||||||||
1248 | case executed 5122 times by 14 tests: ListLayout::Role::String:case ListLayout::Role::String: Executed by:
executed 5122 times by 14 tests: case ListLayout::Role::String: Executed by:
| 5122 | ||||||||||||||||||||||||
1249 | { | - | ||||||||||||||||||||||||
1250 | StringOrTranslation *string = getStringProperty(r); | - | ||||||||||||||||||||||||
1251 | if (string
| 0-5122 | ||||||||||||||||||||||||
1252 | string->~StringOrTranslation(); executed 5122 times by 14 tests: string->~StringOrTranslation(); Executed by:
| 5122 | ||||||||||||||||||||||||
1253 | } | - | ||||||||||||||||||||||||
1254 | break; executed 5122 times by 14 tests: break; Executed by:
| 5122 | ||||||||||||||||||||||||
1255 | case executed 390 times by 4 tests: ListLayout::Role::List:case ListLayout::Role::List: Executed by:
executed 390 times by 4 tests: case ListLayout::Role::List: Executed by:
| 390 | ||||||||||||||||||||||||
1256 | { | - | ||||||||||||||||||||||||
1257 | ListModel *model = getListProperty(r); | - | ||||||||||||||||||||||||
1258 | if (model
| 176-214 | ||||||||||||||||||||||||
1259 | model->destroy(); | - | ||||||||||||||||||||||||
1260 | delete model; | - | ||||||||||||||||||||||||
1261 | } executed 214 times by 4 tests: end of block Executed by:
| 214 | ||||||||||||||||||||||||
1262 | } | - | ||||||||||||||||||||||||
1263 | break; executed 390 times by 4 tests: break; Executed by:
| 390 | ||||||||||||||||||||||||
1264 | case executed 10 times by 1 test: ListLayout::Role::QObject:case ListLayout::Role::QObject: Executed by:
executed 10 times by 1 test: case ListLayout::Role::QObject: Executed by:
| 10 | ||||||||||||||||||||||||
1265 | { | - | ||||||||||||||||||||||||
1266 | QPointer<QObject> *guard = getGuardProperty(r); | - | ||||||||||||||||||||||||
1267 | if (guard
| 2-8 | ||||||||||||||||||||||||
1268 | guard->~QPointer(); executed 8 times by 1 test: guard->~QPointer(); Executed by:
| 8 | ||||||||||||||||||||||||
1269 | } | - | ||||||||||||||||||||||||
1270 | break; executed 10 times by 1 test: break; Executed by:
| 10 | ||||||||||||||||||||||||
1271 | case executed 316 times by 2 tests: ListLayout::Role::VariantMap:case ListLayout::Role::VariantMap: Executed by:
executed 316 times by 2 tests: case ListLayout::Role::VariantMap: Executed by:
| 316 | ||||||||||||||||||||||||
1272 | { | - | ||||||||||||||||||||||||
1273 | QVariantMap *map = getVariantMapProperty(r); | - | ||||||||||||||||||||||||
1274 | if (map
| 128-188 | ||||||||||||||||||||||||
1275 | map->~QMap(); executed 128 times by 2 tests: map->~QMap(); Executed by:
| 128 | ||||||||||||||||||||||||
1276 | } | - | ||||||||||||||||||||||||
1277 | break; executed 316 times by 2 tests: break; Executed by:
| 316 | ||||||||||||||||||||||||
1278 | case executed 10 times by 1 test: ListLayout::Role::DateTime:case ListLayout::Role::DateTime: Executed by:
executed 10 times by 1 test: case ListLayout::Role::DateTime: Executed by:
| 10 | ||||||||||||||||||||||||
1279 | { | - | ||||||||||||||||||||||||
1280 | QDateTime *dt = getDateTimeProperty(r); | - | ||||||||||||||||||||||||
1281 | if (dt
| 0-10 | ||||||||||||||||||||||||
1282 | dt->~QDateTime(); executed 10 times by 1 test: dt->~QDateTime(); Executed by:
| 10 | ||||||||||||||||||||||||
1283 | } | - | ||||||||||||||||||||||||
1284 | break; executed 10 times by 1 test: break; Executed by:
| 10 | ||||||||||||||||||||||||
1285 | case never executed: ListLayout::Role::Function:case ListLayout::Role::Function: never executed: case ListLayout::Role::Function: | 0 | ||||||||||||||||||||||||
1286 | { | - | ||||||||||||||||||||||||
1287 | QJSValue *f = getFunctionProperty(r); | - | ||||||||||||||||||||||||
1288 | if (f
| 0 | ||||||||||||||||||||||||
1289 | f->~QJSValue(); never executed: f->~QJSValue(); | 0 | ||||||||||||||||||||||||
1290 | } | - | ||||||||||||||||||||||||
1291 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1292 | default executed 4092 times by 6 tests: :default: Executed by:
executed 4092 times by 6 tests: default: Executed by:
| 4092 | ||||||||||||||||||||||||
1293 | - | |||||||||||||||||||||||||
1294 | break; executed 4092 times by 6 tests: break; Executed by:
| 4092 | ||||||||||||||||||||||||
1295 | } | - | ||||||||||||||||||||||||
1296 | } | - | ||||||||||||||||||||||||
1297 | - | |||||||||||||||||||||||||
1298 | delete m_objectCache; | - | ||||||||||||||||||||||||
1299 | } executed 6640 times by 15 tests: end of block Executed by:
| 6640 | ||||||||||||||||||||||||
1300 | - | |||||||||||||||||||||||||
1301 | if (next
| 10-6640 | ||||||||||||||||||||||||
1302 | next->destroy(nullptr); executed 10 times by 2 tests: next->destroy(nullptr); Executed by:
| 10 | ||||||||||||||||||||||||
1303 | uid = -1; | - | ||||||||||||||||||||||||
1304 | } executed 6650 times by 15 tests: end of block Executed by:
| 6650 | ||||||||||||||||||||||||
1305 | - | |||||||||||||||||||||||||
1306 | int ListElement::setVariantProperty(const ListLayout::Role &role, const QVariant &d) | - | ||||||||||||||||||||||||
1307 | { | - | ||||||||||||||||||||||||
1308 | int roleIndex = -1; | - | ||||||||||||||||||||||||
1309 | - | |||||||||||||||||||||||||
1310 | switch (role.type) { | - | ||||||||||||||||||||||||
1311 | case executed 1338 times by 5 tests: ListLayout::Role::Number:case ListLayout::Role::Number: Executed by:
executed 1338 times by 5 tests: case ListLayout::Role::Number: Executed by:
| 1338 | ||||||||||||||||||||||||
1312 | roleIndex = setDoubleProperty(role, d.toDouble()); | - | ||||||||||||||||||||||||
1313 | break; executed 1338 times by 5 tests: break; Executed by:
| 1338 | ||||||||||||||||||||||||
1314 | case executed 3958 times by 13 tests: ListLayout::Role::String:case ListLayout::Role::String: Executed by:
executed 3958 times by 13 tests: case ListLayout::Role::String: Executed by:
| 3958 | ||||||||||||||||||||||||
1315 | if (d.userType() == qMetaTypeId<const QV4::CompiledData::Binding *>()
| 8-3950 | ||||||||||||||||||||||||
1316 | roleIndex = setTranslationProperty(role, d.value<const QV4::CompiledData::Binding*>()); executed 8 times by 3 tests: roleIndex = setTranslationProperty(role, d.value<const QV4::CompiledData::Binding*>()); Executed by:
| 8 | ||||||||||||||||||||||||
1317 | else | - | ||||||||||||||||||||||||
1318 | roleIndex = setStringProperty(role, d.toString()); executed 3950 times by 12 tests: roleIndex = setStringProperty(role, d.toString()); Executed by:
| 3950 | ||||||||||||||||||||||||
1319 | break; executed 3958 times by 13 tests: break; Executed by:
| 3958 | ||||||||||||||||||||||||
1320 | case executed 66 times by 3 tests: ListLayout::Role::Bool:case ListLayout::Role::Bool: Executed by:
executed 66 times by 3 tests: case ListLayout::Role::Bool: Executed by:
| 66 | ||||||||||||||||||||||||
1321 | roleIndex = setBoolProperty(role, d.toBool()); | - | ||||||||||||||||||||||||
1322 | break; executed 66 times by 3 tests: break; Executed by:
| 66 | ||||||||||||||||||||||||
1323 | case executed 34 times by 2 tests: ListLayout::Role::List:case ListLayout::Role::List: Executed by:
executed 34 times by 2 tests: case ListLayout::Role::List: Executed by:
| 34 | ||||||||||||||||||||||||
1324 | roleIndex = setListProperty(role, d.value<ListModel *>()); | - | ||||||||||||||||||||||||
1325 | break; executed 34 times by 2 tests: break; Executed by:
| 34 | ||||||||||||||||||||||||
1326 | case never executed: ListLayout::Role::VariantMap:case ListLayout::Role::VariantMap: never executed: {case ListLayout::Role::VariantMap: | 0 | ||||||||||||||||||||||||
1327 | QVariantMap map = d.toMap(); | - | ||||||||||||||||||||||||
1328 | roleIndex = setVariantMapProperty(role, &map); | - | ||||||||||||||||||||||||
1329 | } | - | ||||||||||||||||||||||||
1330 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1331 | case executed 2 times by 1 test: ListLayout::Role::DateTime:case ListLayout::Role::DateTime: Executed by:
executed 2 times by 1 test: case ListLayout::Role::DateTime: Executed by:
| 2 | ||||||||||||||||||||||||
1332 | roleIndex = setDateTimeProperty(role, d.toDateTime()); | - | ||||||||||||||||||||||||
1333 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||
1334 | case never executed: ListLayout::Role::Function:case ListLayout::Role::Function: never executed: case ListLayout::Role::Function: | 0 | ||||||||||||||||||||||||
1335 | roleIndex = setFunctionProperty(role, d.value<QJSValue>()); | - | ||||||||||||||||||||||||
1336 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1337 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||
1338 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1339 | } | - | ||||||||||||||||||||||||
1340 | - | |||||||||||||||||||||||||
1341 | return executed 5398 times by 14 tests: roleIndex;return roleIndex; Executed by:
executed 5398 times by 14 tests: return roleIndex; Executed by:
| 5398 | ||||||||||||||||||||||||
1342 | } | - | ||||||||||||||||||||||||
1343 | - | |||||||||||||||||||||||||
1344 | int ListElement::setJsProperty(const ListLayout::Role &role, const QV4::Value &d, QV4::ExecutionEngine *eng) | - | ||||||||||||||||||||||||
1345 | { | - | ||||||||||||||||||||||||
1346 | - | |||||||||||||||||||||||||
1347 | int roleIndex = -1; | - | ||||||||||||||||||||||||
1348 | - | |||||||||||||||||||||||||
1349 | QV4::Scope scope(eng); | - | ||||||||||||||||||||||||
1350 | - | |||||||||||||||||||||||||
1351 | - | |||||||||||||||||||||||||
1352 | if (d.isString()
| 0-58 | ||||||||||||||||||||||||
1353 | QString qstr = d.toQString(); | - | ||||||||||||||||||||||||
1354 | roleIndex = setStringProperty(role, qstr); | - | ||||||||||||||||||||||||
1355 | } never executed: else if (d.isNumber()end of block
| 0-40 | ||||||||||||||||||||||||
1356 | roleIndex = setDoubleProperty(role, d.asDouble()); | - | ||||||||||||||||||||||||
1357 | } executed 40 times by 2 tests: else if (d.as<QV4::ArrayObject>()end of block Executed by:
| 4-40 | ||||||||||||||||||||||||
1358 | QV4::ScopedArrayObject a(scope, d); | - | ||||||||||||||||||||||||
1359 | if (role.type == ListLayout::Role::List
| 2-12 | ||||||||||||||||||||||||
1360 | QV4::Scope scope(a->engine()); | - | ||||||||||||||||||||||||
1361 | QV4::ScopedObject o(scope); | - | ||||||||||||||||||||||||
1362 | - | |||||||||||||||||||||||||
1363 | ListModel *subModel = new ListModel(role.subLayout, nullptr); | - | ||||||||||||||||||||||||
1364 | int arrayLength = a->getLength(); | - | ||||||||||||||||||||||||
1365 | for (int j=0 ; j < arrayLength
| 12-24 | ||||||||||||||||||||||||
1366 | o = a->get(j); | - | ||||||||||||||||||||||||
1367 | subModel->append(o); | - | ||||||||||||||||||||||||
1368 | } executed 24 times by 2 tests: end of block Executed by:
| 24 | ||||||||||||||||||||||||
1369 | roleIndex = setListProperty(role, subModel); | - | ||||||||||||||||||||||||
1370 | } executed 12 times by 2 tests: else {end of block Executed by:
| 12 | ||||||||||||||||||||||||
1371 | qmlWarning(nullptr) << ([]() noexcept -> QString { enum { Size = sizeof(u"" "Can't assign to existing role '%1' of different type [%2 -> %3]")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Can't assign to existing role '%1' of different type [%2 -> %3]" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 2 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 2 times by 1 test: }()).arg(role.name).arg(roleTypeName(role.type)).arg(roleTypeName(ListLayout::Role::List));return qstring_literal_temp; Executed by:
| 2 | ||||||||||||||||||||||||
1372 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1373 | } else if (d.isBoolean()
| 0-4 | ||||||||||||||||||||||||
1374 | roleIndex = setBoolProperty(role, d.booleanValue()); | - | ||||||||||||||||||||||||
1375 | } never executed: else if (d.as<QV4::DateObject>()end of block
| 0-2 | ||||||||||||||||||||||||
1376 | QV4::Scoped<QV4::DateObject> dd(scope, d); | - | ||||||||||||||||||||||||
1377 | QDateTime dt = dd->toQDateTime(); | - | ||||||||||||||||||||||||
1378 | roleIndex = setDateTimeProperty(role, dt); | - | ||||||||||||||||||||||||
1379 | } executed 2 times by 1 test: else if (d.as<QV4::FunctionObject>()end of block Executed by:
| 0-2 | ||||||||||||||||||||||||
1380 | QV4::ScopedFunctionObject f(scope, d); | - | ||||||||||||||||||||||||
1381 | QJSValue jsv; | - | ||||||||||||||||||||||||
1382 | QJSValuePrivate::setValue(&jsv, eng, f); | - | ||||||||||||||||||||||||
1383 | roleIndex = setFunctionProperty(role, jsv); | - | ||||||||||||||||||||||||
1384 | } never executed: else if (d.isObject()end of block
| 0-2 | ||||||||||||||||||||||||
1385 | QV4::ScopedObject o(scope, d); | - | ||||||||||||||||||||||||
1386 | QV4::QObjectWrapper *wrapper = o->as<QV4::QObjectWrapper>(); | - | ||||||||||||||||||||||||
1387 | if (role.type == ListLayout::Role::QObject
| 0 | ||||||||||||||||||||||||
1388 | QObject *o = wrapper->object(); | - | ||||||||||||||||||||||||
1389 | roleIndex = setQObjectProperty(role, o); | - | ||||||||||||||||||||||||
1390 | } never executed: else if (role.type == ListLayout::Role::VariantMapend of block
| 0 | ||||||||||||||||||||||||
1391 | roleIndex = setVariantMapProperty(role, o); | - | ||||||||||||||||||||||||
1392 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1393 | } never executed: else if (d.isNullOrUndefined()end of block
| 0-2 | ||||||||||||||||||||||||
1394 | clearProperty(role); | - | ||||||||||||||||||||||||
1395 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1396 | - | |||||||||||||||||||||||||
1397 | return executed 58 times by 2 tests: roleIndex;return roleIndex; Executed by:
executed 58 times by 2 tests: return roleIndex; Executed by:
| 58 | ||||||||||||||||||||||||
1398 | } | - | ||||||||||||||||||||||||
1399 | - | |||||||||||||||||||||||||
1400 | ModelNodeMetaObject::ModelNodeMetaObject(QObject *object, QQmlListModel *model, int elementIndex) | - | ||||||||||||||||||||||||
1401 | : QQmlOpenMetaObject(object), m_enabled(false), m_model(model), m_elementIndex(elementIndex), m_initialized(false) | - | ||||||||||||||||||||||||
1402 | {} executed 660 times by 8 tests: end of block Executed by:
| 660 | ||||||||||||||||||||||||
1403 | - | |||||||||||||||||||||||||
1404 | void ModelNodeMetaObject::initialize() | - | ||||||||||||||||||||||||
1405 | { | - | ||||||||||||||||||||||||
1406 | const int roleCount = m_model->m_listModel->roleCount(); | - | ||||||||||||||||||||||||
1407 | QVector<QByteArray> properties; | - | ||||||||||||||||||||||||
1408 | properties.reserve(roleCount); | - | ||||||||||||||||||||||||
1409 | for (int i = 0 ; i < roleCount
| 36-104 | ||||||||||||||||||||||||
1410 | const ListLayout::Role &role = m_model->m_listModel->getExistingRole(i); | - | ||||||||||||||||||||||||
1411 | QByteArray name = role.name.toUtf8(); | - | ||||||||||||||||||||||||
1412 | properties << name; | - | ||||||||||||||||||||||||
1413 | } executed 104 times by 1 test: end of block Executed by:
| 104 | ||||||||||||||||||||||||
1414 | type()->createProperties(properties); | - | ||||||||||||||||||||||||
1415 | updateValues(); | - | ||||||||||||||||||||||||
1416 | m_enabled = true; | - | ||||||||||||||||||||||||
1417 | } executed 36 times by 1 test: end of block Executed by:
| 36 | ||||||||||||||||||||||||
1418 | - | |||||||||||||||||||||||||
1419 | ModelNodeMetaObject::~ModelNodeMetaObject() | - | ||||||||||||||||||||||||
1420 | { | - | ||||||||||||||||||||||||
1421 | } | - | ||||||||||||||||||||||||
1422 | - | |||||||||||||||||||||||||
1423 | QAbstractDynamicMetaObject *ModelNodeMetaObject::toDynamicMetaObject(QObject *object) | - | ||||||||||||||||||||||||
1424 | { | - | ||||||||||||||||||||||||
1425 | if (!m_initialized
| 36-412 | ||||||||||||||||||||||||
1426 | m_initialized = true; | - | ||||||||||||||||||||||||
1427 | initialize(); | - | ||||||||||||||||||||||||
1428 | } executed 36 times by 1 test: end of block Executed by:
| 36 | ||||||||||||||||||||||||
1429 | return executed 448 times by 1 test: QQmlOpenMetaObject::toDynamicMetaObject(object);return QQmlOpenMetaObject::toDynamicMetaObject(object); Executed by:
executed 448 times by 1 test: return QQmlOpenMetaObject::toDynamicMetaObject(object); Executed by:
| 448 | ||||||||||||||||||||||||
1430 | } | - | ||||||||||||||||||||||||
1431 | - | |||||||||||||||||||||||||
1432 | ModelNodeMetaObject *ModelNodeMetaObject::get(QObject *obj) | - | ||||||||||||||||||||||||
1433 | { | - | ||||||||||||||||||||||||
1434 | QObjectPrivate *op = QObjectPrivate::get(obj); | - | ||||||||||||||||||||||||
1435 | return executed 428 times by 4 tests: static_cast<ModelNodeMetaObject*>(op->metaObject);return static_cast<ModelNodeMetaObject*>(op->metaObject); Executed by:
executed 428 times by 4 tests: return static_cast<ModelNodeMetaObject*>(op->metaObject); Executed by:
| 428 | ||||||||||||||||||||||||
1436 | } | - | ||||||||||||||||||||||||
1437 | - | |||||||||||||||||||||||||
1438 | void ModelNodeMetaObject::updateValues() | - | ||||||||||||||||||||||||
1439 | { | - | ||||||||||||||||||||||||
1440 | const int roleCount = m_model->m_listModel->roleCount(); | - | ||||||||||||||||||||||||
1441 | if (!m_initialized
| 0-36 | ||||||||||||||||||||||||
1442 | if (roleCount
| 0 | ||||||||||||||||||||||||
1443 | int *changedRoles = 0; changedRoles = static_cast<int*>( | - | ||||||||||||||||||||||||
1444 | __builtin_alloca ( | - | ||||||||||||||||||||||||
1445 | roleCount * sizeof(int) | - | ||||||||||||||||||||||||
1446 | ) | - | ||||||||||||||||||||||||
1447 | ); | - | ||||||||||||||||||||||||
1448 | for (int i = 0; i < roleCount
| 0 | ||||||||||||||||||||||||
1449 | changedRoles[i] = i; never executed: changedRoles[i] = i; | 0 | ||||||||||||||||||||||||
1450 | emitDirectNotifies(changedRoles, roleCount); | - | ||||||||||||||||||||||||
1451 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1452 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1453 | } | - | ||||||||||||||||||||||||
1454 | for (int i=0 ; i < roleCount
| 36-104 | ||||||||||||||||||||||||
1455 | const ListLayout::Role &role = m_model->m_listModel->getExistingRole(i); | - | ||||||||||||||||||||||||
1456 | QByteArray name = role.name.toUtf8(); | - | ||||||||||||||||||||||||
1457 | const QVariant &data = m_model->data(m_elementIndex, i); | - | ||||||||||||||||||||||||
1458 | setValue(name, data, role.type == ListLayout::Role::List); | - | ||||||||||||||||||||||||
1459 | } executed 104 times by 1 test: end of block Executed by:
| 104 | ||||||||||||||||||||||||
1460 | } executed 36 times by 1 test: end of block Executed by:
| 36 | ||||||||||||||||||||||||
1461 | - | |||||||||||||||||||||||||
1462 | void ModelNodeMetaObject::updateValues(const QVector<int> &roles) | - | ||||||||||||||||||||||||
1463 | { | - | ||||||||||||||||||||||||
1464 | if (!m_initialized
| 18-26 | ||||||||||||||||||||||||
1465 | emitDirectNotifies(roles.constData(), roles.count()); | - | ||||||||||||||||||||||||
1466 | return; executed 18 times by 3 tests: return; Executed by:
| 18 | ||||||||||||||||||||||||
1467 | } | - | ||||||||||||||||||||||||
1468 | int roleCount = roles.count(); | - | ||||||||||||||||||||||||
1469 | for (int i=0 ; i < roleCount
| 24-26 | ||||||||||||||||||||||||
1470 | int roleIndex = roles.at(i); | - | ||||||||||||||||||||||||
1471 | const ListLayout::Role &role = m_model->m_listModel->getExistingRole(roleIndex); | - | ||||||||||||||||||||||||
1472 | QByteArray name = role.name.toUtf8(); | - | ||||||||||||||||||||||||
1473 | const QVariant &data = m_model->data(m_elementIndex, roleIndex); | - | ||||||||||||||||||||||||
1474 | setValue(name, data, role.type == ListLayout::Role::List); | - | ||||||||||||||||||||||||
1475 | } executed 24 times by 1 test: end of block Executed by:
| 24 | ||||||||||||||||||||||||
1476 | } executed 26 times by 1 test: end of block Executed by:
| 26 | ||||||||||||||||||||||||
1477 | - | |||||||||||||||||||||||||
1478 | void ModelNodeMetaObject::propertyWritten(int index) | - | ||||||||||||||||||||||||
1479 | { | - | ||||||||||||||||||||||||
1480 | if (!m_enabled
| 0 | ||||||||||||||||||||||||
1481 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1482 | - | |||||||||||||||||||||||||
1483 | QString propName = QString::fromUtf8(name(index)); | - | ||||||||||||||||||||||||
1484 | const QVariant value = this->value(index); | - | ||||||||||||||||||||||||
1485 | - | |||||||||||||||||||||||||
1486 | QV4::Scope scope(m_model->engine()); | - | ||||||||||||||||||||||||
1487 | QV4::ScopedValue v(scope, scope.engine->fromVariant(value)); | - | ||||||||||||||||||||||||
1488 | - | |||||||||||||||||||||||||
1489 | int roleIndex = m_model->m_listModel->setExistingProperty(m_elementIndex, propName, v, scope.engine); | - | ||||||||||||||||||||||||
1490 | if (roleIndex != -1
| 0 | ||||||||||||||||||||||||
1491 | m_model->emitItemsChanged(m_elementIndex, 1, QVector<int>(1, roleIndex)); never executed: m_model->emitItemsChanged(m_elementIndex, 1, QVector<int>(1, roleIndex)); | 0 | ||||||||||||||||||||||||
1492 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1493 | - | |||||||||||||||||||||||||
1494 | - | |||||||||||||||||||||||||
1495 | void ModelNodeMetaObject::emitDirectNotifies(const int *changedRoles, int roleCount) | - | ||||||||||||||||||||||||
1496 | { | - | ||||||||||||||||||||||||
1497 | ((!m_initialized) ? static_cast<void>(0) : qt_assert("!m_initialized", __FILE__, 1552)); | - | ||||||||||||||||||||||||
1498 | QQmlData *ddata = QQmlData::get(object(), false); | - | ||||||||||||||||||||||||
1499 | if (!ddata
| 0-18 | ||||||||||||||||||||||||
1500 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1501 | - | |||||||||||||||||||||||||
1502 | if (!qmlEngine(m_model)
| 4-14 | ||||||||||||||||||||||||
1503 | return; executed 4 times by 1 test: return; Executed by:
| 4 | ||||||||||||||||||||||||
1504 | for (int i = 0; i < roleCount
| 14 | ||||||||||||||||||||||||
1505 | const int changedRole = changedRoles[i]; | - | ||||||||||||||||||||||||
1506 | QQmlNotifier::notify(ddata, changedRole); | - | ||||||||||||||||||||||||
1507 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||||||||||||||
1508 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||||||||||||||
1509 | - | |||||||||||||||||||||||||
1510 | namespace QV4 { | - | ||||||||||||||||||||||||
1511 | - | |||||||||||||||||||||||||
1512 | bool ModelObject::virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver) | - | ||||||||||||||||||||||||
1513 | { | - | ||||||||||||||||||||||||
1514 | if (!id.isString()
| 0-58 | ||||||||||||||||||||||||
1515 | return never executed: Object::virtualPut(m, id, value, receiver);return Object::virtualPut(m, id, value, receiver); never executed: return Object::virtualPut(m, id, value, receiver); | 0 | ||||||||||||||||||||||||
1516 | QString propName = id.toQString(); | - | ||||||||||||||||||||||||
1517 | - | |||||||||||||||||||||||||
1518 | ModelObject *that = static_cast<ModelObject*>(m); | - | ||||||||||||||||||||||||
1519 | - | |||||||||||||||||||||||||
1520 | ExecutionEngine *eng = that->engine(); | - | ||||||||||||||||||||||||
1521 | const int elementIndex = that->d()->elementIndex(); | - | ||||||||||||||||||||||||
1522 | int roleIndex = that->d()->m_model->m_listModel->setExistingProperty(elementIndex, propName, value, eng); | - | ||||||||||||||||||||||||
1523 | if (roleIndex != -1
| 4-54 | ||||||||||||||||||||||||
1524 | that->d()->m_model->emitItemsChanged(elementIndex, 1, QVector<int>(1, roleIndex)); executed 54 times by 2 tests: that->d()->m_model->emitItemsChanged(elementIndex, 1, QVector<int>(1, roleIndex)); Executed by:
| 54 | ||||||||||||||||||||||||
1525 | - | |||||||||||||||||||||||||
1526 | ModelNodeMetaObject *mo = ModelNodeMetaObject::get(that->object()); | - | ||||||||||||||||||||||||
1527 | if (mo->initialized()
| 4-54 | ||||||||||||||||||||||||
1528 | mo->emitPropertyNotification(propName.toUtf8()); executed 4 times by 1 test: mo->emitPropertyNotification(propName.toUtf8()); Executed by:
| 4 | ||||||||||||||||||||||||
1529 | return executed 58 times by 2 tests: true;return true; Executed by:
executed 58 times by 2 tests: return true; Executed by:
| 58 | ||||||||||||||||||||||||
1530 | } | - | ||||||||||||||||||||||||
1531 | - | |||||||||||||||||||||||||
1532 | ReturnedValue ModelObject::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty) | - | ||||||||||||||||||||||||
1533 | { | - | ||||||||||||||||||||||||
1534 | if (!id.isString()
| 0-852 | ||||||||||||||||||||||||
1535 | return never executed: QObjectWrapper::virtualGet(m, id, receiver, hasProperty);return QObjectWrapper::virtualGet(m, id, receiver, hasProperty); never executed: return QObjectWrapper::virtualGet(m, id, receiver, hasProperty); | 0 | ||||||||||||||||||||||||
1536 | - | |||||||||||||||||||||||||
1537 | const ModelObject *that = static_cast<const ModelObject*>(m); | - | ||||||||||||||||||||||||
1538 | Scope scope(that); | - | ||||||||||||||||||||||||
1539 | ScopedString name(scope, id.asStringOrSymbol()); | - | ||||||||||||||||||||||||
1540 | const ListLayout::Role *role = that->d()->m_model->m_listModel->getExistingRole(name); | - | ||||||||||||||||||||||||
1541 | if (!role
| 2-850 | ||||||||||||||||||||||||
1542 | return executed 2 times by 1 test: QObjectWrapper::virtualGet(m, id, receiver, hasProperty);return QObjectWrapper::virtualGet(m, id, receiver, hasProperty); Executed by:
executed 2 times by 1 test: return QObjectWrapper::virtualGet(m, id, receiver, hasProperty); Executed by:
| 2 | ||||||||||||||||||||||||
1543 | if (hasProperty
| 0-850 | ||||||||||||||||||||||||
1544 | * never executed: hasProperty = true;*hasProperty = true; never executed: *hasProperty = true; | 0 | ||||||||||||||||||||||||
1545 | - | |||||||||||||||||||||||||
1546 | if (QQmlEngine *qmlEngine = that->engine()->qmlEngine()
| 114-736 | ||||||||||||||||||||||||
1547 | QQmlEnginePrivate *ep = QQmlEnginePrivate::get(qmlEngine); | - | ||||||||||||||||||||||||
1548 | if (ep
| 0-736 | ||||||||||||||||||||||||
1549 | ep->propertyCapture->captureProperty(that->object(), -1, role->index, executed 58 times by 3 tests: ep->propertyCapture->captureProperty(that->object(), -1, role->index, QQmlPropertyCapture::OnlyOnce, false); Executed by:
| 58 | ||||||||||||||||||||||||
1550 | QQmlPropertyCapture::OnlyOnce, false); executed 58 times by 3 tests: ep->propertyCapture->captureProperty(that->object(), -1, role->index, QQmlPropertyCapture::OnlyOnce, false); Executed by:
| 58 | ||||||||||||||||||||||||
1551 | } executed 736 times by 8 tests: end of block Executed by:
| 736 | ||||||||||||||||||||||||
1552 | - | |||||||||||||||||||||||||
1553 | const int elementIndex = that->d()->elementIndex(); | - | ||||||||||||||||||||||||
1554 | QVariant value = that->d()->m_model->data(elementIndex, role->index); | - | ||||||||||||||||||||||||
1555 | return executed 850 times by 8 tests: that->engine()->fromVariant(value);return that->engine()->fromVariant(value); Executed by:
executed 850 times by 8 tests: return that->engine()->fromVariant(value); Executed by:
| 850 | ||||||||||||||||||||||||
1556 | } | - | ||||||||||||||||||||||||
1557 | - | |||||||||||||||||||||||||
1558 | void ModelObject::virtualAdvanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes) | - | ||||||||||||||||||||||||
1559 | { | - | ||||||||||||||||||||||||
1560 | ModelObject *that = static_cast<ModelObject*>(m); | - | ||||||||||||||||||||||||
1561 | ExecutionEngine *v4 = that->engine(); | - | ||||||||||||||||||||||||
1562 | name->setM(nullptr); | - | ||||||||||||||||||||||||
1563 | *index = | - | ||||||||||||||||||||||||
1564 | (0x7fffffff * 2U + 1U) | - | ||||||||||||||||||||||||
1565 | ; | - | ||||||||||||||||||||||||
1566 | if (it->arrayIndex < uint(that->d()->m_model->m_listModel->roleCount())
| 4-14 | ||||||||||||||||||||||||
1567 | Scope scope(that->engine()); | - | ||||||||||||||||||||||||
1568 | const ListLayout::Role &role = that->d()->m_model->m_listModel->getExistingRole(it->arrayIndex); | - | ||||||||||||||||||||||||
1569 | ++it->arrayIndex; | - | ||||||||||||||||||||||||
1570 | ScopedString roleName(scope, v4->newString(role.name)); | - | ||||||||||||||||||||||||
1571 | name->setM(roleName->d()); | - | ||||||||||||||||||||||||
1572 | *attributes = QV4::Attr_Data; | - | ||||||||||||||||||||||||
1573 | QVariant value = that->d()->m_model->data(that->d()->elementIndex(), role.index); | - | ||||||||||||||||||||||||
1574 | p->value = v4->fromVariant(value); | - | ||||||||||||||||||||||||
1575 | return; executed 14 times by 1 test: return; Executed by:
| 14 | ||||||||||||||||||||||||
1576 | } | - | ||||||||||||||||||||||||
1577 | - | |||||||||||||||||||||||||
1578 | - | |||||||||||||||||||||||||
1579 | - | |||||||||||||||||||||||||
1580 | QV4::Object::virtualAdvanceIterator(m, it, name, index, p, attributes); | - | ||||||||||||||||||||||||
1581 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
1582 | - | |||||||||||||||||||||||||
1583 | const QV4::VTable ModelObject::static_vtbl = { (std::is_same<ModelObject::SuperClass, Object>::value) ? nullptr : &ModelObject::SuperClass::static_vtbl, (sizeof(ModelObject::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), (sizeof(ModelObject::Data) + (ModelObject::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) - (sizeof(ModelObject::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), ModelObject::IsExecutionContext, ModelObject::IsString, ModelObject::IsObject, ModelObject::IsFunctionObject, ModelObject::IsErrorObject, ModelObject::IsArrayData, ModelObject::IsStringOrSymbol, ModelObject::MyType, { 0, 0, 0, 0 }, "ModelObject", ModelObject::virtualDestroy, ModelObject::Data::markObjects, ModelObject::virtualIsEqualTo, ModelObject::virtualGet, ModelObject::virtualPut, ModelObject::virtualDeleteProperty, ModelObject::virtualHasProperty, ModelObject::virtualGetOwnProperty, ModelObject::virtualDefineOwnProperty, ModelObject::virtualIsExtensible, ModelObject::virtualPreventExtensions, ModelObject::virtualGetPrototypeOf, ModelObject::virtualSetPrototypeOf, ModelObject::virtualGetLength, ModelObject::virtualAdvanceIterator, ModelObject::virtualInstanceOf, ModelObject::virtualCall, ModelObject::virtualCallAsConstructor, }; | - | ||||||||||||||||||||||||
1584 | - | |||||||||||||||||||||||||
1585 | } | - | ||||||||||||||||||||||||
1586 | - | |||||||||||||||||||||||||
1587 | DynamicRoleModelNode::DynamicRoleModelNode(QQmlListModel *owner, int uid) : m_owner(owner), m_uid(uid), m_meta(new DynamicRoleModelNodeMetaObject(this)) | - | ||||||||||||||||||||||||
1588 | { | - | ||||||||||||||||||||||||
1589 | setNodeUpdatesEnabled(true); | - | ||||||||||||||||||||||||
1590 | } executed 2238 times by 2 tests: end of block Executed by:
| 2238 | ||||||||||||||||||||||||
1591 | - | |||||||||||||||||||||||||
1592 | DynamicRoleModelNode *DynamicRoleModelNode::create(const QVariantMap &obj, QQmlListModel *owner) | - | ||||||||||||||||||||||||
1593 | { | - | ||||||||||||||||||||||||
1594 | DynamicRoleModelNode *object = new DynamicRoleModelNode(owner, uidCounter.fetchAndAddOrdered(1)); | - | ||||||||||||||||||||||||
1595 | QVector<int> roles; | - | ||||||||||||||||||||||||
1596 | object->updateValues(obj, roles); | - | ||||||||||||||||||||||||
1597 | return executed 1514 times by 2 tests: object;return object; Executed by:
executed 1514 times by 2 tests: return object; Executed by:
| 1514 | ||||||||||||||||||||||||
1598 | } | - | ||||||||||||||||||||||||
1599 | - | |||||||||||||||||||||||||
1600 | QVector<int> DynamicRoleModelNode::sync(DynamicRoleModelNode *src, DynamicRoleModelNode *target) | - | ||||||||||||||||||||||||
1601 | { | - | ||||||||||||||||||||||||
1602 | QVector<int> changedRoles; | - | ||||||||||||||||||||||||
1603 | for (int i = 0; i < src->m_meta->count()
| 824-1116 | ||||||||||||||||||||||||
1604 | const QByteArray &name = src->m_meta->name(i); | - | ||||||||||||||||||||||||
1605 | QVariant value = src->m_meta->value(i); | - | ||||||||||||||||||||||||
1606 | - | |||||||||||||||||||||||||
1607 | QQmlListModel *srcModel = qobject_cast<QQmlListModel *>(value.value<QObject *>()); | - | ||||||||||||||||||||||||
1608 | QQmlListModel *targetModel = qobject_cast<QQmlListModel *>(target->m_meta->value(i).value<QObject *>()); | - | ||||||||||||||||||||||||
1609 | - | |||||||||||||||||||||||||
1610 | bool modelHasChanges = false; | - | ||||||||||||||||||||||||
1611 | if (srcModel
| 82-1034 | ||||||||||||||||||||||||
1612 | if (targetModel == nullptr
| 26-56 | ||||||||||||||||||||||||
1613 | targetModel = QQmlListModel::createWithOwner(target->m_owner); executed 56 times by 1 test: targetModel = QQmlListModel::createWithOwner(target->m_owner); Executed by:
| 56 | ||||||||||||||||||||||||
1614 | - | |||||||||||||||||||||||||
1615 | modelHasChanges = QQmlListModel::sync(srcModel, targetModel); | - | ||||||||||||||||||||||||
1616 | - | |||||||||||||||||||||||||
1617 | QObject *targetModelObject = targetModel; | - | ||||||||||||||||||||||||
1618 | value = QVariant::fromValue(targetModelObject); | - | ||||||||||||||||||||||||
1619 | } executed 82 times by 1 test: else if (targetModelend of block Executed by:
| 2-1032 | ||||||||||||||||||||||||
1620 | delete targetModel; | - | ||||||||||||||||||||||||
1621 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1622 | - | |||||||||||||||||||||||||
1623 | if (target->setValue(name, value)
| 14-944 | ||||||||||||||||||||||||
1624 | changedRoles << target->m_owner->m_roles.indexOf(QString::fromUtf8(name)); executed 958 times by 1 test: changedRoles << target->m_owner->m_roles.indexOf(QString::fromUtf8(name)); Executed by:
| 958 | ||||||||||||||||||||||||
1625 | } executed 1116 times by 1 test: end of block Executed by:
| 1116 | ||||||||||||||||||||||||
1626 | return executed 824 times by 1 test: changedRoles;return changedRoles; Executed by:
executed 824 times by 1 test: return changedRoles; Executed by:
| 824 | ||||||||||||||||||||||||
1627 | } | - | ||||||||||||||||||||||||
1628 | - | |||||||||||||||||||||||||
1629 | void DynamicRoleModelNode::updateValues(const QVariantMap &object, QVector<int> &roles) | - | ||||||||||||||||||||||||
1630 | { | - | ||||||||||||||||||||||||
1631 | for (auto it = object.cbegin(), end = object.cend(); it != end
| 1652-2284 | ||||||||||||||||||||||||
1632 | const QString &key = it.key(); | - | ||||||||||||||||||||||||
1633 | - | |||||||||||||||||||||||||
1634 | int roleIndex = m_owner->m_roles.indexOf(key); | - | ||||||||||||||||||||||||
1635 | if (roleIndex == -1
| 766-1518 | ||||||||||||||||||||||||
1636 | roleIndex = m_owner->m_roles.count(); | - | ||||||||||||||||||||||||
1637 | m_owner->m_roles.append(key); | - | ||||||||||||||||||||||||
1638 | } executed 1518 times by 2 tests: end of block Executed by:
| 1518 | ||||||||||||||||||||||||
1639 | - | |||||||||||||||||||||||||
1640 | QVariant value = it.value(); | - | ||||||||||||||||||||||||
1641 | - | |||||||||||||||||||||||||
1642 | - | |||||||||||||||||||||||||
1643 | - | |||||||||||||||||||||||||
1644 | if (value.userType() == qMetaTypeId<QJSValue>()
| 0-2284 | ||||||||||||||||||||||||
1645 | value = value.value<QJSValue>().toVariant(); never executed: value = value.value<QJSValue>().toVariant(); | 0 | ||||||||||||||||||||||||
1646 | - | |||||||||||||||||||||||||
1647 | if (value.type() == QVariant::List
| 164-2120 | ||||||||||||||||||||||||
1648 | QQmlListModel *subModel = QQmlListModel::createWithOwner(m_owner); | - | ||||||||||||||||||||||||
1649 | - | |||||||||||||||||||||||||
1650 | QVariantList subArray = value.toList(); | - | ||||||||||||||||||||||||
1651 | QVariantList::const_iterator subIt = subArray.cbegin(); | - | ||||||||||||||||||||||||
1652 | QVariantList::const_iterator subEnd = subArray.cend(); | - | ||||||||||||||||||||||||
1653 | while (subIt != subEnd
| 164-414 | ||||||||||||||||||||||||
1654 | const QVariantMap &subObject = subIt->toMap(); | - | ||||||||||||||||||||||||
1655 | subModel->m_modelObjects.append(DynamicRoleModelNode::create(subObject, subModel)); | - | ||||||||||||||||||||||||
1656 | ++subIt; | - | ||||||||||||||||||||||||
1657 | } executed 414 times by 2 tests: end of block Executed by:
| 414 | ||||||||||||||||||||||||
1658 | - | |||||||||||||||||||||||||
1659 | QObject *subModelObject = subModel; | - | ||||||||||||||||||||||||
1660 | value = QVariant::fromValue(subModelObject); | - | ||||||||||||||||||||||||
1661 | } executed 164 times by 2 tests: end of block Executed by:
| 164 | ||||||||||||||||||||||||
1662 | - | |||||||||||||||||||||||||
1663 | const QByteArray &keyUtf8 = key.toUtf8(); | - | ||||||||||||||||||||||||
1664 | - | |||||||||||||||||||||||||
1665 | QQmlListModel *existingModel = qobject_cast<QQmlListModel *>(m_meta->value(keyUtf8).value<QObject *>()); | - | ||||||||||||||||||||||||
1666 | delete existingModel; | - | ||||||||||||||||||||||||
1667 | - | |||||||||||||||||||||||||
1668 | if (m_meta->setValue(keyUtf8, value)
| 94-2190 | ||||||||||||||||||||||||
1669 | roles << roleIndex; executed 2190 times by 2 tests: roles << roleIndex; Executed by:
| 2190 | ||||||||||||||||||||||||
1670 | } executed 2284 times by 2 tests: end of block Executed by:
| 2284 | ||||||||||||||||||||||||
1671 | } executed 1652 times by 2 tests: end of block Executed by:
| 1652 | ||||||||||||||||||||||||
1672 | - | |||||||||||||||||||||||||
1673 | DynamicRoleModelNodeMetaObject::DynamicRoleModelNodeMetaObject(DynamicRoleModelNode *object) | - | ||||||||||||||||||||||||
1674 | : QQmlOpenMetaObject(object), m_enabled(false), m_owner(object) | - | ||||||||||||||||||||||||
1675 | { | - | ||||||||||||||||||||||||
1676 | } executed 2238 times by 2 tests: end of block Executed by:
| 2238 | ||||||||||||||||||||||||
1677 | - | |||||||||||||||||||||||||
1678 | DynamicRoleModelNodeMetaObject::~DynamicRoleModelNodeMetaObject() | - | ||||||||||||||||||||||||
1679 | { | - | ||||||||||||||||||||||||
1680 | for (int i=0 ; i < count()
| 2238-3096 | ||||||||||||||||||||||||
1681 | QQmlListModel *subModel = qobject_cast<QQmlListModel *>(value(i).value<QObject *>()); | - | ||||||||||||||||||||||||
1682 | delete subModel; | - | ||||||||||||||||||||||||
1683 | } executed 3096 times by 2 tests: end of block Executed by:
| 3096 | ||||||||||||||||||||||||
1684 | } executed 2238 times by 2 tests: end of block Executed by:
| 2238 | ||||||||||||||||||||||||
1685 | - | |||||||||||||||||||||||||
1686 | void DynamicRoleModelNodeMetaObject::propertyWrite(int index) | - | ||||||||||||||||||||||||
1687 | { | - | ||||||||||||||||||||||||
1688 | if (!m_enabled
| 0-58 | ||||||||||||||||||||||||
1689 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1690 | - | |||||||||||||||||||||||||
1691 | QVariant v = value(index); | - | ||||||||||||||||||||||||
1692 | QQmlListModel *model = qobject_cast<QQmlListModel *>(v.value<QObject *>()); | - | ||||||||||||||||||||||||
1693 | delete model; | - | ||||||||||||||||||||||||
1694 | } executed 58 times by 2 tests: end of block Executed by:
| 58 | ||||||||||||||||||||||||
1695 | - | |||||||||||||||||||||||||
1696 | void DynamicRoleModelNodeMetaObject::propertyWritten(int index) | - | ||||||||||||||||||||||||
1697 | { | - | ||||||||||||||||||||||||
1698 | if (!m_enabled
| 0-58 | ||||||||||||||||||||||||
1699 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1700 | - | |||||||||||||||||||||||||
1701 | QQmlListModel *parentModel = m_owner->m_owner; | - | ||||||||||||||||||||||||
1702 | - | |||||||||||||||||||||||||
1703 | QVariant v = value(index); | - | ||||||||||||||||||||||||
1704 | - | |||||||||||||||||||||||||
1705 | - | |||||||||||||||||||||||||
1706 | - | |||||||||||||||||||||||||
1707 | if (v.userType() == qMetaTypeId<QJSValue>()
| 12-46 | ||||||||||||||||||||||||
1708 | v= v.value<QJSValue>().toVariant(); executed 12 times by 2 tests: v= v.value<QJSValue>().toVariant(); Executed by:
| 12 | ||||||||||||||||||||||||
1709 | - | |||||||||||||||||||||||||
1710 | if (v.type() == QVariant::List
| 12-46 | ||||||||||||||||||||||||
1711 | QQmlListModel *subModel = QQmlListModel::createWithOwner(parentModel); | - | ||||||||||||||||||||||||
1712 | - | |||||||||||||||||||||||||
1713 | QVariantList subArray = v.toList(); | - | ||||||||||||||||||||||||
1714 | QVariantList::const_iterator subIt = subArray.cbegin(); | - | ||||||||||||||||||||||||
1715 | QVariantList::const_iterator subEnd = subArray.cend(); | - | ||||||||||||||||||||||||
1716 | while (subIt != subEnd
| 12-24 | ||||||||||||||||||||||||
1717 | const QVariantMap &subObject = subIt->toMap(); | - | ||||||||||||||||||||||||
1718 | subModel->m_modelObjects.append(DynamicRoleModelNode::create(subObject, subModel)); | - | ||||||||||||||||||||||||
1719 | ++subIt; | - | ||||||||||||||||||||||||
1720 | } executed 24 times by 2 tests: end of block Executed by:
| 24 | ||||||||||||||||||||||||
1721 | - | |||||||||||||||||||||||||
1722 | QObject *subModelObject = subModel; | - | ||||||||||||||||||||||||
1723 | v = QVariant::fromValue(subModelObject); | - | ||||||||||||||||||||||||
1724 | - | |||||||||||||||||||||||||
1725 | setValue(index, v); | - | ||||||||||||||||||||||||
1726 | } executed 12 times by 2 tests: end of block Executed by:
| 12 | ||||||||||||||||||||||||
1727 | - | |||||||||||||||||||||||||
1728 | int elementIndex = parentModel->m_modelObjects.indexOf(m_owner); | - | ||||||||||||||||||||||||
1729 | if (elementIndex != -1
| 0-58 | ||||||||||||||||||||||||
1730 | int roleIndex = parentModel->m_roles.indexOf(QString::fromLatin1(name(index).constData())); | - | ||||||||||||||||||||||||
1731 | if (roleIndex != -1
| 0-58 | ||||||||||||||||||||||||
1732 | parentModel->emitItemsChanged(elementIndex, 1, QVector<int>(1, roleIndex)); executed 58 times by 2 tests: parentModel->emitItemsChanged(elementIndex, 1, QVector<int>(1, roleIndex)); Executed by:
| 58 | ||||||||||||||||||||||||
1733 | } executed 58 times by 2 tests: end of block Executed by:
| 58 | ||||||||||||||||||||||||
1734 | } executed 58 times by 2 tests: end of block Executed by:
| 58 | ||||||||||||||||||||||||
1735 | QQmlListModel::QQmlListModel(QObject *parent) | - | ||||||||||||||||||||||||
1736 | : QAbstractListModel(parent) | - | ||||||||||||||||||||||||
1737 | { | - | ||||||||||||||||||||||||
1738 | m_mainThread = true; | - | ||||||||||||||||||||||||
1739 | m_primary = true; | - | ||||||||||||||||||||||||
1740 | m_agent = nullptr; | - | ||||||||||||||||||||||||
1741 | m_dynamicRoles = false; | - | ||||||||||||||||||||||||
1742 | - | |||||||||||||||||||||||||
1743 | m_layout = new ListLayout; | - | ||||||||||||||||||||||||
1744 | m_listModel = new ListModel(m_layout, this); | - | ||||||||||||||||||||||||
1745 | - | |||||||||||||||||||||||||
1746 | m_engine = nullptr; | - | ||||||||||||||||||||||||
1747 | } executed 2456 times by 15 tests: end of block Executed by:
| 2456 | ||||||||||||||||||||||||
1748 | - | |||||||||||||||||||||||||
1749 | QQmlListModel::QQmlListModel(const QQmlListModel *owner, ListModel *data, QV4::ExecutionEngine *engine, QObject *parent) | - | ||||||||||||||||||||||||
1750 | : QAbstractListModel(parent) | - | ||||||||||||||||||||||||
1751 | { | - | ||||||||||||||||||||||||
1752 | m_mainThread = owner->m_mainThread; | - | ||||||||||||||||||||||||
1753 | m_primary = false; | - | ||||||||||||||||||||||||
1754 | m_agent = owner->m_agent; | - | ||||||||||||||||||||||||
1755 | - | |||||||||||||||||||||||||
1756 | ((owner->m_dynamicRoles == false) ? static_cast<void>(0) : qt_assert("owner->m_dynamicRoles == false", __FILE__, 1904)); | - | ||||||||||||||||||||||||
1757 | m_dynamicRoles = false; | - | ||||||||||||||||||||||||
1758 | m_layout = nullptr; | - | ||||||||||||||||||||||||
1759 | m_listModel = data; | - | ||||||||||||||||||||||||
1760 | - | |||||||||||||||||||||||||
1761 | m_engine = engine; | - | ||||||||||||||||||||||||
1762 | m_compilationUnit = owner->m_compilationUnit; | - | ||||||||||||||||||||||||
1763 | } executed 138 times by 4 tests: end of block Executed by:
| 138 | ||||||||||||||||||||||||
1764 | - | |||||||||||||||||||||||||
1765 | QQmlListModel::QQmlListModel(QQmlListModel *orig, QQmlListModelWorkerAgent *agent) | - | ||||||||||||||||||||||||
1766 | : QAbstractListModel(agent) | - | ||||||||||||||||||||||||
1767 | { | - | ||||||||||||||||||||||||
1768 | m_mainThread = false; | - | ||||||||||||||||||||||||
1769 | m_primary = true; | - | ||||||||||||||||||||||||
1770 | m_agent = agent; | - | ||||||||||||||||||||||||
1771 | m_dynamicRoles = orig->m_dynamicRoles; | - | ||||||||||||||||||||||||
1772 | - | |||||||||||||||||||||||||
1773 | m_layout = new ListLayout(orig->m_layout); | - | ||||||||||||||||||||||||
1774 | m_listModel = new ListModel(m_layout, this); | - | ||||||||||||||||||||||||
1775 | - | |||||||||||||||||||||||||
1776 | if (m_dynamicRoles
| 436-468 | ||||||||||||||||||||||||
1777 | sync(orig, this); executed 468 times by 1 test: sync(orig, this); Executed by:
| 468 | ||||||||||||||||||||||||
1778 | else | - | ||||||||||||||||||||||||
1779 | ListModel::sync(orig->m_listModel, m_listModel); executed 436 times by 2 tests: ListModel::sync(orig->m_listModel, m_listModel); Executed by:
| 436 | ||||||||||||||||||||||||
1780 | - | |||||||||||||||||||||||||
1781 | m_engine = nullptr; | - | ||||||||||||||||||||||||
1782 | m_compilationUnit = orig->m_compilationUnit; | - | ||||||||||||||||||||||||
1783 | } executed 904 times by 2 tests: end of block Executed by:
| 904 | ||||||||||||||||||||||||
1784 | - | |||||||||||||||||||||||||
1785 | QQmlListModel::~QQmlListModel() | - | ||||||||||||||||||||||||
1786 | { | - | ||||||||||||||||||||||||
1787 | qDeleteAll(m_modelObjects); | - | ||||||||||||||||||||||||
1788 | - | |||||||||||||||||||||||||
1789 | if (m_primary
| 138-3352 | ||||||||||||||||||||||||
1790 | m_listModel->destroy(); | - | ||||||||||||||||||||||||
1791 | delete m_listModel; | - | ||||||||||||||||||||||||
1792 | - | |||||||||||||||||||||||||
1793 | if (m_mainThread
| 934-2378 | ||||||||||||||||||||||||
1794 | m_agent->modelDestroyed(); | - | ||||||||||||||||||||||||
1795 | m_agent->release(); | - | ||||||||||||||||||||||||
1796 | } executed 934 times by 2 tests: end of block Executed by:
| 934 | ||||||||||||||||||||||||
1797 | } executed 3352 times by 15 tests: end of block Executed by:
| 3352 | ||||||||||||||||||||||||
1798 | - | |||||||||||||||||||||||||
1799 | m_listModel = nullptr; | - | ||||||||||||||||||||||||
1800 | - | |||||||||||||||||||||||||
1801 | delete m_layout; | - | ||||||||||||||||||||||||
1802 | m_layout = nullptr; | - | ||||||||||||||||||||||||
1803 | } executed 3490 times by 15 tests: end of block Executed by:
| 3490 | ||||||||||||||||||||||||
1804 | - | |||||||||||||||||||||||||
1805 | QQmlListModel *QQmlListModel::createWithOwner(QQmlListModel *newOwner) | - | ||||||||||||||||||||||||
1806 | { | - | ||||||||||||||||||||||||
1807 | QQmlListModel *model = new QQmlListModel; | - | ||||||||||||||||||||||||
1808 | - | |||||||||||||||||||||||||
1809 | model->m_mainThread = newOwner->m_mainThread; | - | ||||||||||||||||||||||||
1810 | model->m_engine = newOwner->m_engine; | - | ||||||||||||||||||||||||
1811 | model->m_agent = newOwner->m_agent; | - | ||||||||||||||||||||||||
1812 | model->m_dynamicRoles = newOwner->m_dynamicRoles; | - | ||||||||||||||||||||||||
1813 | - | |||||||||||||||||||||||||
1814 | if (model->m_mainThread
| 30-160 | ||||||||||||||||||||||||
1815 | model->m_agent->addref(); executed 30 times by 1 test: model->m_agent->addref(); Executed by:
| 30 | ||||||||||||||||||||||||
1816 | - | |||||||||||||||||||||||||
1817 | QQmlEngine::setContextForObject(model, QQmlEngine::contextForObject(newOwner)); | - | ||||||||||||||||||||||||
1818 | - | |||||||||||||||||||||||||
1819 | return executed 232 times by 2 tests: model;return model; Executed by:
executed 232 times by 2 tests: return model; Executed by:
| 232 | ||||||||||||||||||||||||
1820 | } | - | ||||||||||||||||||||||||
1821 | - | |||||||||||||||||||||||||
1822 | QV4::ExecutionEngine *QQmlListModel::engine() const | - | ||||||||||||||||||||||||
1823 | { | - | ||||||||||||||||||||||||
1824 | if (m_engine == nullptr
| 640-12779 | ||||||||||||||||||||||||
1825 | m_engine = qmlEngine(this)->handle(); | - | ||||||||||||||||||||||||
1826 | } executed 640 times by 7 tests: end of block Executed by:
| 640 | ||||||||||||||||||||||||
1827 | - | |||||||||||||||||||||||||
1828 | return executed 13419 times by 13 tests: m_engine;return m_engine; Executed by:
executed 13419 times by 13 tests: return m_engine; Executed by:
| 13419 | ||||||||||||||||||||||||
1829 | } | - | ||||||||||||||||||||||||
1830 | - | |||||||||||||||||||||||||
1831 | bool QQmlListModel::sync(QQmlListModel *src, QQmlListModel *target) | - | ||||||||||||||||||||||||
1832 | { | - | ||||||||||||||||||||||||
1833 | ((src->m_dynamicRoles && target->m_dynamicRoles) ? static_cast<void>(0) : qt_assert("src->m_dynamicRoles && target->m_dynamicRoles", __FILE__, 1981)); | - | ||||||||||||||||||||||||
1834 | - | |||||||||||||||||||||||||
1835 | bool hasChanges = false; | - | ||||||||||||||||||||||||
1836 | - | |||||||||||||||||||||||||
1837 | target->m_roles = src->m_roles; | - | ||||||||||||||||||||||||
1838 | - | |||||||||||||||||||||||||
1839 | - | |||||||||||||||||||||||||
1840 | QHash<int, ElementSync> elementHash; | - | ||||||||||||||||||||||||
1841 | for (int i = 0 ; i < target->m_modelObjects.count()
| 128-1018 | ||||||||||||||||||||||||
1842 | DynamicRoleModelNode *e = target->m_modelObjects.at(i); | - | ||||||||||||||||||||||||
1843 | int uid = e->getUid(); | - | ||||||||||||||||||||||||
1844 | ElementSync sync; | - | ||||||||||||||||||||||||
1845 | sync.target = e; | - | ||||||||||||||||||||||||
1846 | sync.targetIndex = i; | - | ||||||||||||||||||||||||
1847 | elementHash.insert(uid, sync); | - | ||||||||||||||||||||||||
1848 | } executed 128 times by 1 test: end of block Executed by:
| 128 | ||||||||||||||||||||||||
1849 | for (int i = 0 ; i < src->m_modelObjects.count()
| 824-1018 | ||||||||||||||||||||||||
1850 | DynamicRoleModelNode *e = src->m_modelObjects.at(i); | - | ||||||||||||||||||||||||
1851 | int uid = e->getUid(); | - | ||||||||||||||||||||||||
1852 | - | |||||||||||||||||||||||||
1853 | QHash<int, ElementSync>::iterator it = elementHash.find(uid); | - | ||||||||||||||||||||||||
1854 | if (it == elementHash.end()
| 100-724 | ||||||||||||||||||||||||
1855 | ElementSync sync; | - | ||||||||||||||||||||||||
1856 | sync.src = e; | - | ||||||||||||||||||||||||
1857 | sync.srcIndex = i; | - | ||||||||||||||||||||||||
1858 | elementHash.insert(uid, sync); | - | ||||||||||||||||||||||||
1859 | } executed 724 times by 1 test: else {end of block Executed by:
| 724 | ||||||||||||||||||||||||
1860 | ElementSync &sync = it.value(); | - | ||||||||||||||||||||||||
1861 | sync.src = e; | - | ||||||||||||||||||||||||
1862 | sync.srcIndex = i; | - | ||||||||||||||||||||||||
1863 | } executed 100 times by 1 test: end of block Executed by:
| 100 | ||||||||||||||||||||||||
1864 | } | - | ||||||||||||||||||||||||
1865 | - | |||||||||||||||||||||||||
1866 | - | |||||||||||||||||||||||||
1867 | int rowsRemoved = 0; | - | ||||||||||||||||||||||||
1868 | for (int i = 0 ; i < target->m_modelObjects.count()
| 128-1018 | ||||||||||||||||||||||||
1869 | DynamicRoleModelNode *element = target->m_modelObjects.at(i); | - | ||||||||||||||||||||||||
1870 | ElementSync &s = elementHash.find(element->getUid()).value(); | - | ||||||||||||||||||||||||
1871 | ((s.targetIndex >= 0) ? static_cast<void>(0) : qt_assert("s.targetIndex >= 0", __FILE__, 2019)); | - | ||||||||||||||||||||||||
1872 | - | |||||||||||||||||||||||||
1873 | s.targetIndex -= rowsRemoved; | - | ||||||||||||||||||||||||
1874 | if (s.src == nullptr
| 28-100 | ||||||||||||||||||||||||
1875 | ((s.targetIndex == i) ? static_cast<void>(0) : qt_assert("s.targetIndex == i", __FILE__, 2023)); | - | ||||||||||||||||||||||||
1876 | hasChanges = true; | - | ||||||||||||||||||||||||
1877 | target->beginRemoveRows(QModelIndex(), i, i); | - | ||||||||||||||||||||||||
1878 | target->m_modelObjects.remove(i, 1); | - | ||||||||||||||||||||||||
1879 | target->endRemoveRows(); | - | ||||||||||||||||||||||||
1880 | delete s.target; | - | ||||||||||||||||||||||||
1881 | ++rowsRemoved; | - | ||||||||||||||||||||||||
1882 | --i; | - | ||||||||||||||||||||||||
1883 | continue; executed 28 times by 1 test: continue; Executed by:
| 28 | ||||||||||||||||||||||||
1884 | } | - | ||||||||||||||||||||||||
1885 | } executed 100 times by 1 test: end of block Executed by:
| 100 | ||||||||||||||||||||||||
1886 | - | |||||||||||||||||||||||||
1887 | - | |||||||||||||||||||||||||
1888 | target->m_modelObjects.clear(); | - | ||||||||||||||||||||||||
1889 | for (int i = 0 ; i < src->m_modelObjects.count()
| 824-1018 | ||||||||||||||||||||||||
1890 | DynamicRoleModelNode *element = src->m_modelObjects.at(i); | - | ||||||||||||||||||||||||
1891 | ElementSync &s = elementHash.find(element->getUid()).value(); | - | ||||||||||||||||||||||||
1892 | ((s.srcIndex >= 0) ? static_cast<void>(0) : qt_assert("s.srcIndex >= 0", __FILE__, 2040)); | - | ||||||||||||||||||||||||
1893 | DynamicRoleModelNode *targetElement = s.target; | - | ||||||||||||||||||||||||
1894 | if (targetElement == nullptr
| 100-724 | ||||||||||||||||||||||||
1895 | targetElement = new DynamicRoleModelNode(target, element->getUid()); | - | ||||||||||||||||||||||||
1896 | } executed 724 times by 1 test: end of block Executed by:
| 724 | ||||||||||||||||||||||||
1897 | s.changedRoles = DynamicRoleModelNode::sync(element, targetElement); | - | ||||||||||||||||||||||||
1898 | target->m_modelObjects.append(targetElement); | - | ||||||||||||||||||||||||
1899 | } executed 824 times by 1 test: end of block Executed by:
| 824 | ||||||||||||||||||||||||
1900 | - | |||||||||||||||||||||||||
1901 | - | |||||||||||||||||||||||||
1902 | - | |||||||||||||||||||||||||
1903 | - | |||||||||||||||||||||||||
1904 | - | |||||||||||||||||||||||||
1905 | - | |||||||||||||||||||||||||
1906 | int rowsInserted = 0; | - | ||||||||||||||||||||||||
1907 | for (int i = 0 ; i < target->m_modelObjects.count()
| 824-1018 | ||||||||||||||||||||||||
1908 | DynamicRoleModelNode *element = target->m_modelObjects.at(i); | - | ||||||||||||||||||||||||
1909 | ElementSync &s = elementHash.find(element->getUid()).value(); | - | ||||||||||||||||||||||||
1910 | ((s.srcIndex >= 0) ? static_cast<void>(0) : qt_assert("s.srcIndex >= 0", __FILE__, 2058)); | - | ||||||||||||||||||||||||
1911 | s.srcIndex += rowsInserted; | - | ||||||||||||||||||||||||
1912 | if (s.srcIndex != s.targetIndex
| 100-724 | ||||||||||||||||||||||||
1913 | if (s.targetIndex == -1
| 0-724 | ||||||||||||||||||||||||
1914 | target->beginInsertRows(QModelIndex(), i, i); | - | ||||||||||||||||||||||||
1915 | target->endInsertRows(); | - | ||||||||||||||||||||||||
1916 | } executed 724 times by 1 test: else {end of block Executed by:
| 724 | ||||||||||||||||||||||||
1917 | target->beginMoveRows(QModelIndex(), i, i, QModelIndex(), s.srcIndex); | - | ||||||||||||||||||||||||
1918 | target->endMoveRows(); | - | ||||||||||||||||||||||||
1919 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1920 | hasChanges = true; | - | ||||||||||||||||||||||||
1921 | ++rowsInserted; | - | ||||||||||||||||||||||||
1922 | } executed 724 times by 1 test: end of block Executed by:
| 724 | ||||||||||||||||||||||||
1923 | if (s.targetIndex != -1
| 38-724 | ||||||||||||||||||||||||
1924 | QModelIndex idx = target->createIndex(i, 0); | - | ||||||||||||||||||||||||
1925 | target->dataChanged(idx, idx, s.changedRoles); | - | ||||||||||||||||||||||||
1926 | hasChanges = true; | - | ||||||||||||||||||||||||
1927 | } executed 38 times by 1 test: end of block Executed by:
| 38 | ||||||||||||||||||||||||
1928 | } executed 824 times by 1 test: end of block Executed by:
| 824 | ||||||||||||||||||||||||
1929 | return executed 1018 times by 1 test: hasChanges;return hasChanges; Executed by:
executed 1018 times by 1 test: return hasChanges; Executed by:
| 1018 | ||||||||||||||||||||||||
1930 | } | - | ||||||||||||||||||||||||
1931 | - | |||||||||||||||||||||||||
1932 | void QQmlListModel::emitItemsChanged(int index, int count, const QVector<int> &roles) | - | ||||||||||||||||||||||||
1933 | { | - | ||||||||||||||||||||||||
1934 | if (count <= 0
| 0-458 | ||||||||||||||||||||||||
1935 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1936 | - | |||||||||||||||||||||||||
1937 | if (m_mainThread
| 206-252 | ||||||||||||||||||||||||
1938 | dataChanged(createIndex(index, 0), createIndex(index + count - 1, 0), roles); executed 252 times by 3 tests: ;dataChanged(createIndex(index, 0), createIndex(index + count - 1, 0), roles); Executed by:
| 252 | ||||||||||||||||||||||||
1939 | } executed 458 times by 3 tests: end of block Executed by:
| 458 | ||||||||||||||||||||||||
1940 | - | |||||||||||||||||||||||||
1941 | void QQmlListModel::emitItemsAboutToBeInserted(int index, int count) | - | ||||||||||||||||||||||||
1942 | { | - | ||||||||||||||||||||||||
1943 | ((index >= 0 && count >= 0) ? static_cast<void>(0) : qt_assert("index >= 0 && count >= 0", __FILE__, 2091)); | - | ||||||||||||||||||||||||
1944 | if (m_mainThread
| 1098-2224 | ||||||||||||||||||||||||
1945 | beginInsertRows(QModelIndex(), index, index + count - 1); executed 2224 times by 9 tests: beginInsertRows(QModelIndex(), index, index + count - 1); Executed by:
| 2224 | ||||||||||||||||||||||||
1946 | } executed 3322 times by 9 tests: end of block Executed by:
| 3322 | ||||||||||||||||||||||||
1947 | - | |||||||||||||||||||||||||
1948 | void QQmlListModel::emitItemsInserted() | - | ||||||||||||||||||||||||
1949 | { | - | ||||||||||||||||||||||||
1950 | if (m_mainThread
| 1098-2224 | ||||||||||||||||||||||||
1951 | endInsertRows(); | - | ||||||||||||||||||||||||
1952 | countChanged(); | - | ||||||||||||||||||||||||
1953 | } executed 2224 times by 9 tests: end of block Executed by:
| 2224 | ||||||||||||||||||||||||
1954 | } executed 3322 times by 9 tests: end of block Executed by:
| 3322 | ||||||||||||||||||||||||
1955 | - | |||||||||||||||||||||||||
1956 | QQmlListModelWorkerAgent *QQmlListModel::agent() | - | ||||||||||||||||||||||||
1957 | { | - | ||||||||||||||||||||||||
1958 | if (m_agent
| 904-952 | ||||||||||||||||||||||||
1959 | return executed 952 times by 2 tests: m_agent;return m_agent; Executed by:
executed 952 times by 2 tests: return m_agent; Executed by:
| 952 | ||||||||||||||||||||||||
1960 | - | |||||||||||||||||||||||||
1961 | m_agent = new QQmlListModelWorkerAgent(this); | - | ||||||||||||||||||||||||
1962 | return executed 904 times by 2 tests: m_agent;return m_agent; Executed by:
executed 904 times by 2 tests: return m_agent; Executed by:
| 904 | ||||||||||||||||||||||||
1963 | } | - | ||||||||||||||||||||||||
1964 | - | |||||||||||||||||||||||||
1965 | QModelIndex QQmlListModel::index(int row, int column, const QModelIndex &parent) const | - | ||||||||||||||||||||||||
1966 | { | - | ||||||||||||||||||||||||
1967 | return executed 10815 times by 9 tests: row >= 0 && row < count() && column == 0 && !parent.isValid()return row >= 0 && row < count() && column == 0 && !parent.isValid() ? createIndex(row, column) : QModelIndex(); Executed by:
executed 10815 times by 9 tests: return row >= 0 && row < count() && column == 0 && !parent.isValid() ? createIndex(row, column) : QModelIndex(); Executed by:
| 10815 | ||||||||||||||||||||||||
1968 | ? createIndex(row, column) executed 10815 times by 9 tests: return row >= 0 && row < count() && column == 0 && !parent.isValid() ? createIndex(row, column) : QModelIndex(); Executed by:
| 10815 | ||||||||||||||||||||||||
1969 | : QModelIndex(); executed 10815 times by 9 tests: return row >= 0 && row < count() && column == 0 && !parent.isValid() ? createIndex(row, column) : QModelIndex(); Executed by:
| 10815 | ||||||||||||||||||||||||
1970 | } | - | ||||||||||||||||||||||||
1971 | - | |||||||||||||||||||||||||
1972 | int QQmlListModel::rowCount(const QModelIndex &parent) const | - | ||||||||||||||||||||||||
1973 | { | - | ||||||||||||||||||||||||
1974 | return executed 18716 times by 12 tests: !parent.isValid() ? count() : 0;return !parent.isValid() ? count() : 0; Executed by:
executed 18716 times by 12 tests: return !parent.isValid() ? count() : 0; Executed by:
| 18716 | ||||||||||||||||||||||||
1975 | } | - | ||||||||||||||||||||||||
1976 | - | |||||||||||||||||||||||||
1977 | QVariant QQmlListModel::data(const QModelIndex &index, int role) const | - | ||||||||||||||||||||||||
1978 | { | - | ||||||||||||||||||||||||
1979 | return executed 10503 times by 9 tests: data(index.row(), role);return data(index.row(), role); Executed by:
executed 10503 times by 9 tests: return data(index.row(), role); Executed by:
| 10503 | ||||||||||||||||||||||||
1980 | } | - | ||||||||||||||||||||||||
1981 | - | |||||||||||||||||||||||||
1982 | bool QQmlListModel::setData(const QModelIndex &index, const QVariant &value, int role) | - | ||||||||||||||||||||||||
1983 | { | - | ||||||||||||||||||||||||
1984 | const int row = index.row(); | - | ||||||||||||||||||||||||
1985 | if (row >= count()
| 0-4 | ||||||||||||||||||||||||
1986 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
1987 | - | |||||||||||||||||||||||||
1988 | if (m_dynamicRoles
| 0-4 | ||||||||||||||||||||||||
1989 | const QByteArray property = m_roles.at(role).toUtf8(); | - | ||||||||||||||||||||||||
1990 | if (m_modelObjects[row]->setValue(property, value)
| 0 | ||||||||||||||||||||||||
1991 | emitItemsChanged(row, 1, QVector<int>(1, role)); | - | ||||||||||||||||||||||||
1992 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
1993 | } | - | ||||||||||||||||||||||||
1994 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1995 | const ListLayout::Role &r = m_listModel->getExistingRole(role); | - | ||||||||||||||||||||||||
1996 | const int roleIndex = m_listModel->setOrCreateProperty(row, r.name, value); | - | ||||||||||||||||||||||||
1997 | if (roleIndex != -1
| 0-4 | ||||||||||||||||||||||||
1998 | emitItemsChanged(row, 1, QVector<int>(1, role)); | - | ||||||||||||||||||||||||
1999 | return executed 4 times by 1 test: true;return true; Executed by:
executed 4 times by 1 test: return true; Executed by:
| 4 | ||||||||||||||||||||||||
2000 | } | - | ||||||||||||||||||||||||
2001 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2002 | - | |||||||||||||||||||||||||
2003 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
2004 | } | - | ||||||||||||||||||||||||
2005 | - | |||||||||||||||||||||||||
2006 | QVariant QQmlListModel::data(int index, int role) const | - | ||||||||||||||||||||||||
2007 | { | - | ||||||||||||||||||||||||
2008 | QVariant v; | - | ||||||||||||||||||||||||
2009 | - | |||||||||||||||||||||||||
2010 | if (index >= count()
| 0-11687 | ||||||||||||||||||||||||
2011 | return never executed: v;return v; never executed: return v; | 0 | ||||||||||||||||||||||||
2012 | - | |||||||||||||||||||||||||
2013 | if (m_dynamicRoles
| 102-11585 | ||||||||||||||||||||||||
2014 | v = m_modelObjects[index]->getValue(m_roles[role]); executed 102 times by 2 tests: v = m_modelObjects[index]->getValue(m_roles[role]); Executed by:
| 102 | ||||||||||||||||||||||||
2015 | else | - | ||||||||||||||||||||||||
2016 | v = m_listModel->getProperty(index, role, this, engine()); executed 11585 times by 13 tests: v = m_listModel->getProperty(index, role, this, engine()); Executed by:
| 11585 | ||||||||||||||||||||||||
2017 | - | |||||||||||||||||||||||||
2018 | return executed 11687 times by 13 tests: v;return v; Executed by:
executed 11687 times by 13 tests: return v; Executed by:
| 11687 | ||||||||||||||||||||||||
2019 | } | - | ||||||||||||||||||||||||
2020 | - | |||||||||||||||||||||||||
2021 | QHash<int, QByteArray> QQmlListModel::roleNames() const | - | ||||||||||||||||||||||||
2022 | { | - | ||||||||||||||||||||||||
2023 | QHash<int, QByteArray> roleNames; | - | ||||||||||||||||||||||||
2024 | - | |||||||||||||||||||||||||
2025 | if (m_dynamicRoles
| 88-734 | ||||||||||||||||||||||||
2026 | for (int i = 0 ; i < m_roles.count()
| 88-300 | ||||||||||||||||||||||||
2027 | roleNames.insert(i, m_roles.at(i).toUtf8()); executed 300 times by 2 tests: roleNames.insert(i, m_roles.at(i).toUtf8()); Executed by:
| 300 | ||||||||||||||||||||||||
2028 | } executed 88 times by 2 tests: else {end of block Executed by:
| 88 | ||||||||||||||||||||||||
2029 | for (int i = 0 ; i < m_listModel->roleCount()
| 734-1128 | ||||||||||||||||||||||||
2030 | const ListLayout::Role &r = m_listModel->getExistingRole(i); | - | ||||||||||||||||||||||||
2031 | roleNames.insert(i, r.name.toUtf8()); | - | ||||||||||||||||||||||||
2032 | } executed 1128 times by 11 tests: end of block Executed by:
| 1128 | ||||||||||||||||||||||||
2033 | } executed 734 times by 11 tests: end of block Executed by:
| 734 | ||||||||||||||||||||||||
2034 | - | |||||||||||||||||||||||||
2035 | return executed 822 times by 11 tests: roleNames;return roleNames; Executed by:
executed 822 times by 11 tests: return roleNames; Executed by:
| 822 | ||||||||||||||||||||||||
2036 | } | - | ||||||||||||||||||||||||
2037 | void QQmlListModel::setDynamicRoles(bool enableDynamicRoles) | - | ||||||||||||||||||||||||
2038 | { | - | ||||||||||||||||||||||||
2039 | if (m_mainThread
| 0-1454 | ||||||||||||||||||||||||
2040 | if (enableDynamicRoles
| 706-748 | ||||||||||||||||||||||||
2041 | if (m_layout->roleCount()
| 2-746 | ||||||||||||||||||||||||
2042 | qmlWarning(this) << tr("unable to enable dynamic roles as this model is not empty"); executed 2 times by 1 test: qmlWarning(this) << tr("unable to enable dynamic roles as this model is not empty"); Executed by:
| 2 | ||||||||||||||||||||||||
2043 | else | - | ||||||||||||||||||||||||
2044 | m_dynamicRoles = true; executed 746 times by 2 tests: m_dynamicRoles = true; Executed by:
| 746 | ||||||||||||||||||||||||
2045 | } else { | - | ||||||||||||||||||||||||
2046 | if (m_roles.count()
| 2-704 | ||||||||||||||||||||||||
2047 | qmlWarning(this) << tr("unable to enable static roles as this model is not empty"); | - | ||||||||||||||||||||||||
2048 | } executed 2 times by 1 test: else {end of block Executed by:
| 2 | ||||||||||||||||||||||||
2049 | m_dynamicRoles = false; | - | ||||||||||||||||||||||||
2050 | } executed 704 times by 2 tests: end of block Executed by:
| 704 | ||||||||||||||||||||||||
2051 | } | - | ||||||||||||||||||||||||
2052 | } else { | - | ||||||||||||||||||||||||
2053 | qmlWarning(this) << tr("dynamic role setting must be made from the main thread, before any worker scripts are created"); | - | ||||||||||||||||||||||||
2054 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2055 | } | - | ||||||||||||||||||||||||
2056 | - | |||||||||||||||||||||||||
2057 | - | |||||||||||||||||||||||||
2058 | - | |||||||||||||||||||||||||
2059 | - | |||||||||||||||||||||||||
2060 | - | |||||||||||||||||||||||||
2061 | int QQmlListModel::count() const | - | ||||||||||||||||||||||||
2062 | { | - | ||||||||||||||||||||||||
2063 | return executed 48668 times by 14 tests: m_dynamicRoles ? m_modelObjects.count() : m_listModel->elementCount();return m_dynamicRoles ? m_modelObjects.count() : m_listModel->elementCount(); Executed by:
executed 48668 times by 14 tests: return m_dynamicRoles ? m_modelObjects.count() : m_listModel->elementCount(); Executed by:
| 48668 | ||||||||||||||||||||||||
2064 | } | - | ||||||||||||||||||||||||
2065 | void QQmlListModel::clear() | - | ||||||||||||||||||||||||
2066 | { | - | ||||||||||||||||||||||||
2067 | removeElements(0, count()); | - | ||||||||||||||||||||||||
2068 | } executed 80 times by 4 tests: end of block Executed by:
| 80 | ||||||||||||||||||||||||
2069 | void QQmlListModel::remove(QQmlV4Function *args) | - | ||||||||||||||||||||||||
2070 | { | - | ||||||||||||||||||||||||
2071 | int argLength = args->length(); | - | ||||||||||||||||||||||||
2072 | - | |||||||||||||||||||||||||
2073 | if (argLength == 1
| 24-238 | ||||||||||||||||||||||||
2074 | QV4::Scope scope(args->v4engine()); | - | ||||||||||||||||||||||||
2075 | int index = QV4::ScopedValue(scope, (*args)[0])->toInt32(); | - | ||||||||||||||||||||||||
2076 | int removeCount = (argLength == 2
| 190-214 | ||||||||||||||||||||||||
2077 | - | |||||||||||||||||||||||||
2078 | if (index < 0
| 12-392 | ||||||||||||||||||||||||
2079 | qmlWarning(this) << tr("remove: indices [%1 - %2] out of range [0 - %3]").arg(index).arg(index+removeCount).arg(count()); | - | ||||||||||||||||||||||||
2080 | return; executed 72 times by 2 tests: return; Executed by:
| 72 | ||||||||||||||||||||||||
2081 | } | - | ||||||||||||||||||||||||
2082 | - | |||||||||||||||||||||||||
2083 | removeElements(index, removeCount); | - | ||||||||||||||||||||||||
2084 | } executed 332 times by 6 tests: else {end of block Executed by:
| 332 | ||||||||||||||||||||||||
2085 | qmlWarning(this) << tr("remove: incorrect number of arguments"); | - | ||||||||||||||||||||||||
2086 | } executed 24 times by 2 tests: end of block Executed by:
| 24 | ||||||||||||||||||||||||
2087 | } | - | ||||||||||||||||||||||||
2088 | - | |||||||||||||||||||||||||
2089 | void QQmlListModel::removeElements(int index, int removeCount) | - | ||||||||||||||||||||||||
2090 | { | - | ||||||||||||||||||||||||
2091 | ((index >= 0 && removeCount >= 0) ? static_cast<void>(0) : qt_assert("index >= 0 && removeCount >= 0", __FILE__, 2282)); | - | ||||||||||||||||||||||||
2092 | - | |||||||||||||||||||||||||
2093 | if (!removeCount
| 4-408 | ||||||||||||||||||||||||
2094 | return; executed 4 times by 1 test: return; Executed by:
| 4 | ||||||||||||||||||||||||
2095 | - | |||||||||||||||||||||||||
2096 | if (m_mainThread
| 148-260 | ||||||||||||||||||||||||
2097 | beginRemoveRows(QModelIndex(), index, index + removeCount - 1); executed 260 times by 6 tests: beginRemoveRows(QModelIndex(), index, index + removeCount - 1); Executed by:
| 260 | ||||||||||||||||||||||||
2098 | - | |||||||||||||||||||||||||
2099 | QVector<std::function<void()>> toDestroy; | - | ||||||||||||||||||||||||
2100 | if (m_dynamicRoles
| 132-276 | ||||||||||||||||||||||||
2101 | for (int i=0 ; i < removeCount
| 132-158 | ||||||||||||||||||||||||
2102 | auto modelObject = m_modelObjects[index+i]; | - | ||||||||||||||||||||||||
2103 | toDestroy.append([modelObject](){ | - | ||||||||||||||||||||||||
2104 | delete modelObject; | - | ||||||||||||||||||||||||
2105 | } executed 158 times by 2 tests: );end of block Executed by:
| 158 | ||||||||||||||||||||||||
2106 | } executed 158 times by 2 tests: end of block Executed by:
| 158 | ||||||||||||||||||||||||
2107 | m_modelObjects.remove(index, removeCount); | - | ||||||||||||||||||||||||
2108 | } executed 132 times by 2 tests: else {end of block Executed by:
| 132 | ||||||||||||||||||||||||
2109 | toDestroy = m_listModel->remove(index, removeCount); | - | ||||||||||||||||||||||||
2110 | } executed 276 times by 6 tests: end of block Executed by:
| 276 | ||||||||||||||||||||||||
2111 | - | |||||||||||||||||||||||||
2112 | if (m_mainThread
| 148-260 | ||||||||||||||||||||||||
2113 | endRemoveRows(); | - | ||||||||||||||||||||||||
2114 | countChanged(); | - | ||||||||||||||||||||||||
2115 | } executed 260 times by 6 tests: end of block Executed by:
| 260 | ||||||||||||||||||||||||
2116 | for (const auto &destroyer : toDestroy) | - | ||||||||||||||||||||||||
2117 | destroyer(); executed 506 times by 6 tests: destroyer(); Executed by:
| 506 | ||||||||||||||||||||||||
2118 | } executed 408 times by 6 tests: end of block Executed by:
| 408 | ||||||||||||||||||||||||
2119 | void QQmlListModel::insert(QQmlV4Function *args) | - | ||||||||||||||||||||||||
2120 | { | - | ||||||||||||||||||||||||
2121 | if (args->length() == 2
| 12-538 | ||||||||||||||||||||||||
2122 | QV4::Scope scope(args->v4engine()); | - | ||||||||||||||||||||||||
2123 | QV4::ScopedValue arg0(scope, (*args)[0]); | - | ||||||||||||||||||||||||
2124 | int index = arg0->toInt32(); | - | ||||||||||||||||||||||||
2125 | - | |||||||||||||||||||||||||
2126 | if (index < 0
| 12-526 | ||||||||||||||||||||||||
2127 | qmlWarning(this) << tr("insert: index %1 out of range").arg(index); | - | ||||||||||||||||||||||||
2128 | return; executed 24 times by 2 tests: return; Executed by:
| 24 | ||||||||||||||||||||||||
2129 | } | - | ||||||||||||||||||||||||
2130 | - | |||||||||||||||||||||||||
2131 | QV4::ScopedObject argObject(scope, (*args)[1]); | - | ||||||||||||||||||||||||
2132 | QV4::ScopedArrayObject objectArray(scope, (*args)[1]); | - | ||||||||||||||||||||||||
2133 | if (objectArray
| 24-490 | ||||||||||||||||||||||||
2134 | QV4::ScopedObject argObject(scope); | - | ||||||||||||||||||||||||
2135 | - | |||||||||||||||||||||||||
2136 | int objectArrayLength = objectArray->getLength(); | - | ||||||||||||||||||||||||
2137 | emitItemsAboutToBeInserted(index, objectArrayLength); | - | ||||||||||||||||||||||||
2138 | for (int i=0 ; i < objectArrayLength
| 24-72 | ||||||||||||||||||||||||
2139 | argObject = objectArray->get(i); | - | ||||||||||||||||||||||||
2140 | - | |||||||||||||||||||||||||
2141 | if (m_dynamicRoles
| 36 | ||||||||||||||||||||||||
2142 | m_modelObjects.insert(index+i, DynamicRoleModelNode::create(scope.engine->variantMapFromJS(argObject), this)); | - | ||||||||||||||||||||||||
2143 | } executed 36 times by 2 tests: else {end of block Executed by:
| 36 | ||||||||||||||||||||||||
2144 | m_listModel->insert(index+i, argObject); | - | ||||||||||||||||||||||||
2145 | } executed 36 times by 2 tests: end of block Executed by:
| 36 | ||||||||||||||||||||||||
2146 | } | - | ||||||||||||||||||||||||
2147 | emitItemsInserted(); | - | ||||||||||||||||||||||||
2148 | } executed 24 times by 2 tests: else if (argObjectend of block Executed by:
| 24-466 | ||||||||||||||||||||||||
2149 | emitItemsAboutToBeInserted(index, 1); | - | ||||||||||||||||||||||||
2150 | - | |||||||||||||||||||||||||
2151 | if (m_dynamicRoles
| 54-412 | ||||||||||||||||||||||||
2152 | m_modelObjects.insert(index, DynamicRoleModelNode::create(scope.engine->variantMapFromJS(argObject), this)); | - | ||||||||||||||||||||||||
2153 | } executed 54 times by 2 tests: else {end of block Executed by:
| 54 | ||||||||||||||||||||||||
2154 | m_listModel->insert(index, argObject); | - | ||||||||||||||||||||||||
2155 | } executed 412 times by 5 tests: end of block Executed by:
| 412 | ||||||||||||||||||||||||
2156 | - | |||||||||||||||||||||||||
2157 | emitItemsInserted(); | - | ||||||||||||||||||||||||
2158 | } executed 466 times by 5 tests: else {end of block Executed by:
| 466 | ||||||||||||||||||||||||
2159 | qmlWarning(this) << tr("insert: value is not an object"); | - | ||||||||||||||||||||||||
2160 | } executed 24 times by 2 tests: end of block Executed by:
| 24 | ||||||||||||||||||||||||
2161 | } else { | - | ||||||||||||||||||||||||
2162 | qmlWarning(this) << tr("insert: value is not an object"); | - | ||||||||||||||||||||||||
2163 | } executed 12 times by 2 tests: end of block Executed by:
| 12 | ||||||||||||||||||||||||
2164 | } | - | ||||||||||||||||||||||||
2165 | void QQmlListModel::move(int from, int to, int n) | - | ||||||||||||||||||||||||
2166 | { | - | ||||||||||||||||||||||||
2167 | if (n == 0
| 0-190 | ||||||||||||||||||||||||
2168 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2169 | if (!canMove(from, to, n)
| 48-142 | ||||||||||||||||||||||||
2170 | qmlWarning(this) << tr("move: out of range"); | - | ||||||||||||||||||||||||
2171 | return; executed 48 times by 2 tests: return; Executed by:
| 48 | ||||||||||||||||||||||||
2172 | } | - | ||||||||||||||||||||||||
2173 | - | |||||||||||||||||||||||||
2174 | if (m_mainThread
| 70-72 | ||||||||||||||||||||||||
2175 | beginMoveRows(QModelIndex(), from, from + n - 1, QModelIndex(), to > from ? to + n : to); executed 70 times by 4 tests: beginMoveRows(QModelIndex(), from, from + n - 1, QModelIndex(), to > from ? to + n : to); Executed by:
| 70 | ||||||||||||||||||||||||
2176 | - | |||||||||||||||||||||||||
2177 | if (m_dynamicRoles
| 54-88 | ||||||||||||||||||||||||
2178 | - | |||||||||||||||||||||||||
2179 | int realFrom = from; | - | ||||||||||||||||||||||||
2180 | int realTo = to; | - | ||||||||||||||||||||||||
2181 | int realN = n; | - | ||||||||||||||||||||||||
2182 | - | |||||||||||||||||||||||||
2183 | if (from > to
| 12-42 | ||||||||||||||||||||||||
2184 | - | |||||||||||||||||||||||||
2185 | int tfrom = from; | - | ||||||||||||||||||||||||
2186 | int tto = to; | - | ||||||||||||||||||||||||
2187 | realFrom = tto; | - | ||||||||||||||||||||||||
2188 | realTo = tto+n; | - | ||||||||||||||||||||||||
2189 | realN = tfrom-tto; | - | ||||||||||||||||||||||||
2190 | } executed 12 times by 2 tests: end of block Executed by:
| 12 | ||||||||||||||||||||||||
2191 | - | |||||||||||||||||||||||||
2192 | QPODVector<DynamicRoleModelNode *, 4> store; | - | ||||||||||||||||||||||||
2193 | for (int i=0 ; i < (realTo-realFrom)
| 54 | ||||||||||||||||||||||||
2194 | store.append(m_modelObjects[realFrom+realN+i]); executed 54 times by 2 tests: store.append(m_modelObjects[realFrom+realN+i]); Executed by:
| 54 | ||||||||||||||||||||||||
2195 | for (int i=0 ; i < realN
| 54-78 | ||||||||||||||||||||||||
2196 | store.append(m_modelObjects[realFrom+i]); executed 78 times by 2 tests: store.append(m_modelObjects[realFrom+i]); Executed by:
| 78 | ||||||||||||||||||||||||
2197 | for (int i=0 ; i < store.count()
| 54-132 | ||||||||||||||||||||||||
2198 | m_modelObjects[realFrom+i] = store[i]; executed 132 times by 2 tests: m_modelObjects[realFrom+i] = store[i]; Executed by:
| 132 | ||||||||||||||||||||||||
2199 | - | |||||||||||||||||||||||||
2200 | } executed 54 times by 2 tests: else {end of block Executed by:
| 54 | ||||||||||||||||||||||||
2201 | m_listModel->move(from, to, n); | - | ||||||||||||||||||||||||
2202 | } executed 88 times by 5 tests: end of block Executed by:
| 88 | ||||||||||||||||||||||||
2203 | - | |||||||||||||||||||||||||
2204 | if (m_mainThread
| 70-72 | ||||||||||||||||||||||||
2205 | endMoveRows(); executed 70 times by 4 tests: endMoveRows(); Executed by:
| 70 | ||||||||||||||||||||||||
2206 | } executed 142 times by 5 tests: end of block Executed by:
| 142 | ||||||||||||||||||||||||
2207 | void QQmlListModel::append(QQmlV4Function *args) | - | ||||||||||||||||||||||||
2208 | { | - | ||||||||||||||||||||||||
2209 | if (args->length() == 1
| 12-2834 | ||||||||||||||||||||||||
2210 | QV4::Scope scope(args->v4engine()); | - | ||||||||||||||||||||||||
2211 | QV4::ScopedObject argObject(scope, (*args)[0]); | - | ||||||||||||||||||||||||
2212 | QV4::ScopedArrayObject objectArray(scope, (*args)[0]); | - | ||||||||||||||||||||||||
2213 | - | |||||||||||||||||||||||||
2214 | if (objectArray
| 26-2808 | ||||||||||||||||||||||||
2215 | QV4::ScopedObject argObject(scope); | - | ||||||||||||||||||||||||
2216 | - | |||||||||||||||||||||||||
2217 | int objectArrayLength = objectArray->getLength(); | - | ||||||||||||||||||||||||
2218 | if (objectArrayLength > 0
| 2-24 | ||||||||||||||||||||||||
2219 | int index = count(); | - | ||||||||||||||||||||||||
2220 | emitItemsAboutToBeInserted(index, objectArrayLength); | - | ||||||||||||||||||||||||
2221 | - | |||||||||||||||||||||||||
2222 | for (int i=0 ; i < objectArrayLength
| 24-72 | ||||||||||||||||||||||||
2223 | argObject = objectArray->get(i); | - | ||||||||||||||||||||||||
2224 | - | |||||||||||||||||||||||||
2225 | if (m_dynamicRoles
| 36 | ||||||||||||||||||||||||
2226 | m_modelObjects.append(DynamicRoleModelNode::create(scope.engine->variantMapFromJS(argObject), this)); | - | ||||||||||||||||||||||||
2227 | } executed 36 times by 2 tests: else {end of block Executed by:
| 36 | ||||||||||||||||||||||||
2228 | m_listModel->append(argObject); | - | ||||||||||||||||||||||||
2229 | } executed 36 times by 2 tests: end of block Executed by:
| 36 | ||||||||||||||||||||||||
2230 | } | - | ||||||||||||||||||||||||
2231 | - | |||||||||||||||||||||||||
2232 | emitItemsInserted(); | - | ||||||||||||||||||||||||
2233 | } executed 24 times by 2 tests: end of block Executed by:
| 24 | ||||||||||||||||||||||||
2234 | } executed 26 times by 2 tests: else if (argObjectend of block Executed by:
| 24-2784 | ||||||||||||||||||||||||
2235 | int index; | - | ||||||||||||||||||||||||
2236 | - | |||||||||||||||||||||||||
2237 | if (m_dynamicRoles
| 938-1846 | ||||||||||||||||||||||||
2238 | index = m_modelObjects.count(); | - | ||||||||||||||||||||||||
2239 | emitItemsAboutToBeInserted(index, 1); | - | ||||||||||||||||||||||||
2240 | m_modelObjects.append(DynamicRoleModelNode::create(scope.engine->variantMapFromJS(argObject), this)); | - | ||||||||||||||||||||||||
2241 | } executed 938 times by 2 tests: else {end of block Executed by:
| 938 | ||||||||||||||||||||||||
2242 | index = m_listModel->elementCount(); | - | ||||||||||||||||||||||||
2243 | emitItemsAboutToBeInserted(index, 1); | - | ||||||||||||||||||||||||
2244 | m_listModel->append(argObject); | - | ||||||||||||||||||||||||
2245 | } executed 1846 times by 8 tests: end of block Executed by:
| 1846 | ||||||||||||||||||||||||
2246 | - | |||||||||||||||||||||||||
2247 | emitItemsInserted(); | - | ||||||||||||||||||||||||
2248 | } executed 2784 times by 8 tests: else {end of block Executed by:
| 2784 | ||||||||||||||||||||||||
2249 | qmlWarning(this) << tr("append: value is not an object"); | - | ||||||||||||||||||||||||
2250 | } executed 24 times by 2 tests: end of block Executed by:
| 24 | ||||||||||||||||||||||||
2251 | } else { | - | ||||||||||||||||||||||||
2252 | qmlWarning(this) << tr("append: value is not an object"); | - | ||||||||||||||||||||||||
2253 | } executed 12 times by 2 tests: end of block Executed by:
| 12 | ||||||||||||||||||||||||
2254 | } | - | ||||||||||||||||||||||||
2255 | QQmlV4Handle QQmlListModel::get(int index) const | - | ||||||||||||||||||||||||
2256 | { | - | ||||||||||||||||||||||||
2257 | QV4::Scope scope(engine()); | - | ||||||||||||||||||||||||
2258 | QV4::ScopedValue result(scope, QV4::Primitive::undefinedValue()); | - | ||||||||||||||||||||||||
2259 | - | |||||||||||||||||||||||||
2260 | if (index >= 0
| 12-1514 | ||||||||||||||||||||||||
2261 | - | |||||||||||||||||||||||||
2262 | if (m_dynamicRoles
| 544-958 | ||||||||||||||||||||||||
2263 | DynamicRoleModelNode *object = m_modelObjects[index]; | - | ||||||||||||||||||||||||
2264 | result = QV4::QObjectWrapper::wrap(scope.engine, object); | - | ||||||||||||||||||||||||
2265 | } executed 544 times by 2 tests: else {end of block Executed by:
| 544 | ||||||||||||||||||||||||
2266 | QObject *object = m_listModel->getOrCreateModelObject(const_cast<QQmlListModel *>(this), index); | - | ||||||||||||||||||||||||
2267 | QQmlData *ddata = QQmlData::get(object); | - | ||||||||||||||||||||||||
2268 | if (ddata->jsWrapper.isNullOrUndefined()
| 298-660 | ||||||||||||||||||||||||
2269 | result = scope.engine->memoryManager->allocate<QV4::ModelObject>(object, const_cast<QQmlListModel *>(this)); | - | ||||||||||||||||||||||||
2270 | - | |||||||||||||||||||||||||
2271 | ddata->jsWrapper.set(scope.engine, result); | - | ||||||||||||||||||||||||
2272 | } executed 660 times by 8 tests: else {end of block Executed by:
| 660 | ||||||||||||||||||||||||
2273 | result = ddata->jsWrapper.value(); | - | ||||||||||||||||||||||||
2274 | } executed 298 times by 5 tests: end of block Executed by:
| 298 | ||||||||||||||||||||||||
2275 | } | - | ||||||||||||||||||||||||
2276 | } | - | ||||||||||||||||||||||||
2277 | - | |||||||||||||||||||||||||
2278 | return executed 1526 times by 8 tests: QQmlV4Handle(result);return QQmlV4Handle(result); Executed by:
executed 1526 times by 8 tests: return QQmlV4Handle(result); Executed by:
| 1526 | ||||||||||||||||||||||||
2279 | } | - | ||||||||||||||||||||||||
2280 | void QQmlListModel::set(int index, const QQmlV4Handle &handle) | - | ||||||||||||||||||||||||
2281 | { | - | ||||||||||||||||||||||||
2282 | QV4::Scope scope(engine()); | - | ||||||||||||||||||||||||
2283 | QV4::ScopedObject object(scope, handle); | - | ||||||||||||||||||||||||
2284 | - | |||||||||||||||||||||||||
2285 | if (!object
| 12-296 | ||||||||||||||||||||||||
2286 | qmlWarning(this) << tr("set: value is not an object"); | - | ||||||||||||||||||||||||
2287 | return; executed 12 times by 2 tests: return; Executed by:
| 12 | ||||||||||||||||||||||||
2288 | } | - | ||||||||||||||||||||||||
2289 | if (index > count()
| 0-296 | ||||||||||||||||||||||||
2290 | qmlWarning(this) << tr("set: index %1 out of range").arg(index); | - | ||||||||||||||||||||||||
2291 | return; executed 12 times by 2 tests: return; Executed by:
| 12 | ||||||||||||||||||||||||
2292 | } | - | ||||||||||||||||||||||||
2293 | - | |||||||||||||||||||||||||
2294 | - | |||||||||||||||||||||||||
2295 | if (index == count()
| 24-260 | ||||||||||||||||||||||||
2296 | emitItemsAboutToBeInserted(index, 1); | - | ||||||||||||||||||||||||
2297 | - | |||||||||||||||||||||||||
2298 | if (m_dynamicRoles
| 12 | ||||||||||||||||||||||||
2299 | m_modelObjects.append(DynamicRoleModelNode::create(scope.engine->variantMapFromJS(object), this)); | - | ||||||||||||||||||||||||
2300 | } executed 12 times by 2 tests: else {end of block Executed by:
| 12 | ||||||||||||||||||||||||
2301 | m_listModel->insert(index, object); | - | ||||||||||||||||||||||||
2302 | } executed 12 times by 2 tests: end of block Executed by:
| 12 | ||||||||||||||||||||||||
2303 | - | |||||||||||||||||||||||||
2304 | emitItemsInserted(); | - | ||||||||||||||||||||||||
2305 | } executed 24 times by 2 tests: else {end of block Executed by:
| 24 | ||||||||||||||||||||||||
2306 | - | |||||||||||||||||||||||||
2307 | QVector<int> roles; | - | ||||||||||||||||||||||||
2308 | - | |||||||||||||||||||||||||
2309 | if (m_dynamicRoles
| 122-138 | ||||||||||||||||||||||||
2310 | m_modelObjects[index]->updateValues(scope.engine->variantMapFromJS(object), roles); | - | ||||||||||||||||||||||||
2311 | } executed 138 times by 2 tests: else {end of block Executed by:
| 138 | ||||||||||||||||||||||||
2312 | m_listModel->set(index, object, &roles); | - | ||||||||||||||||||||||||
2313 | } executed 122 times by 2 tests: end of block Executed by:
| 122 | ||||||||||||||||||||||||
2314 | - | |||||||||||||||||||||||||
2315 | if (roles.count()
| 30-230 | ||||||||||||||||||||||||
2316 | emitItemsChanged(index, 1, roles); executed 230 times by 2 tests: emitItemsChanged(index, 1, roles); Executed by:
| 230 | ||||||||||||||||||||||||
2317 | } executed 260 times by 2 tests: end of block Executed by:
| 260 | ||||||||||||||||||||||||
2318 | } | - | ||||||||||||||||||||||||
2319 | void QQmlListModel::setProperty(int index, const QString& property, const QVariant& value) | - | ||||||||||||||||||||||||
2320 | { | - | ||||||||||||||||||||||||
2321 | if (count() == 0
| 0-132 | ||||||||||||||||||||||||
2322 | qmlWarning(this) << tr("set: index %1 out of range").arg(index); | - | ||||||||||||||||||||||||
2323 | return; executed 36 times by 2 tests: return; Executed by:
| 36 | ||||||||||||||||||||||||
2324 | } | - | ||||||||||||||||||||||||
2325 | - | |||||||||||||||||||||||||
2326 | if (m_dynamicRoles
| 56-64 | ||||||||||||||||||||||||
2327 | int roleIndex = m_roles.indexOf(property); | - | ||||||||||||||||||||||||
2328 | if (roleIndex == -1
| 0-56 | ||||||||||||||||||||||||
2329 | roleIndex = m_roles.count(); | - | ||||||||||||||||||||||||
2330 | m_roles.append(property); | - | ||||||||||||||||||||||||
2331 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2332 | if (m_modelObjects[index]->setValue(property.toUtf8(), value)
| 4-52 | ||||||||||||||||||||||||
2333 | emitItemsChanged(index, 1, QVector<int>(1, roleIndex)); executed 52 times by 2 tests: emitItemsChanged(index, 1, QVector<int>(1, roleIndex)); Executed by:
| 52 | ||||||||||||||||||||||||
2334 | } executed 56 times by 2 tests: else {end of block Executed by:
| 56 | ||||||||||||||||||||||||
2335 | int roleIndex = m_listModel->setOrCreateProperty(index, property, value); | - | ||||||||||||||||||||||||
2336 | if (roleIndex != -1
| 4-60 | ||||||||||||||||||||||||
2337 | emitItemsChanged(index, 1, QVector<int>(1, roleIndex)); executed 60 times by 3 tests: emitItemsChanged(index, 1, QVector<int>(1, roleIndex)); Executed by:
| 60 | ||||||||||||||||||||||||
2338 | } executed 64 times by 3 tests: end of block Executed by:
| 64 | ||||||||||||||||||||||||
2339 | } | - | ||||||||||||||||||||||||
2340 | - | |||||||||||||||||||||||||
2341 | - | |||||||||||||||||||||||||
2342 | - | |||||||||||||||||||||||||
2343 | - | |||||||||||||||||||||||||
2344 | - | |||||||||||||||||||||||||
2345 | - | |||||||||||||||||||||||||
2346 | - | |||||||||||||||||||||||||
2347 | void QQmlListModel::sync() | - | ||||||||||||||||||||||||
2348 | { | - | ||||||||||||||||||||||||
2349 | - | |||||||||||||||||||||||||
2350 | - | |||||||||||||||||||||||||
2351 | - | |||||||||||||||||||||||||
2352 | qmlWarning(this) << "List sync() can only be called from a WorkerScript"; | - | ||||||||||||||||||||||||
2353 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
2354 | - | |||||||||||||||||||||||||
2355 | bool QQmlListModelParser::verifyProperty(const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding) | - | ||||||||||||||||||||||||
2356 | { | - | ||||||||||||||||||||||||
2357 | if (binding->type >= QV4::CompiledData::Binding::Type_Object
| 1928-2826 | ||||||||||||||||||||||||
2358 | const quint32 targetObjectIndex = binding->value.objectIndex; | - | ||||||||||||||||||||||||
2359 | const QV4::CompiledData::Object *target = qmlUnit->objectAt(targetObjectIndex); | - | ||||||||||||||||||||||||
2360 | QString objName = qmlUnit->stringAt(target->inheritedTypeNameIndex); | - | ||||||||||||||||||||||||
2361 | if (objName != listElementTypeName
| 388-1540 | ||||||||||||||||||||||||
2362 | const QMetaObject *mo = resolveType(objName); | - | ||||||||||||||||||||||||
2363 | if (mo != &QQmlListElement::staticMetaObject
| 2-386 | ||||||||||||||||||||||||
2364 | error(target, QQmlListModel::tr("ListElement: cannot contain nested elements")); | - | ||||||||||||||||||||||||
2365 | return executed 2 times by 1 test: false;return false; Executed by:
executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||||||||||||||
2366 | } | - | ||||||||||||||||||||||||
2367 | listElementTypeName = objName; | - | ||||||||||||||||||||||||
2368 | } executed 386 times by 14 tests: end of block Executed by:
| 386 | ||||||||||||||||||||||||
2369 | - | |||||||||||||||||||||||||
2370 | if (!qmlUnit->stringAt(target->idNameIndex).isEmpty()
| 2-1924 | ||||||||||||||||||||||||
2371 | error(target->locationOfIdProperty, QQmlListModel::tr("ListElement: cannot use reserved \"id\" property")); | - | ||||||||||||||||||||||||
2372 | return executed 2 times by 1 test: false;return false; Executed by:
executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||||||||||||||
2373 | } | - | ||||||||||||||||||||||||
2374 | - | |||||||||||||||||||||||||
2375 | const QV4::CompiledData::Binding *binding = target->bindingTable(); | - | ||||||||||||||||||||||||
2376 | for (quint32 i = 0; i < target->nBindings
| 1912-2896 | ||||||||||||||||||||||||
2377 | QString propName = qmlUnit->stringAt(binding->propertyNameIndex); | - | ||||||||||||||||||||||||
2378 | if (propName.isEmpty()
| 2-2894 | ||||||||||||||||||||||||
2379 | error(binding, QQmlListModel::tr("ListElement: cannot contain nested elements")); | - | ||||||||||||||||||||||||
2380 | return executed 2 times by 1 test: false;return false; Executed by:
executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||||||||||||||
2381 | } | - | ||||||||||||||||||||||||
2382 | if (!verifyProperty(qmlUnit, binding)
| 10-2884 | ||||||||||||||||||||||||
2383 | return executed 10 times by 1 test: false;return false; Executed by:
executed 10 times by 1 test: return false; Executed by:
| 10 | ||||||||||||||||||||||||
2384 | } executed 2884 times by 14 tests: end of block Executed by:
| 2884 | ||||||||||||||||||||||||
2385 | } executed 1912 times by 14 tests: else if (binding->type == QV4::CompiledData::Binding::Type_Scriptend of block Executed by:
| 100-2726 | ||||||||||||||||||||||||
2386 | QString scriptStr = binding->valueAsScriptString(qmlUnit); | - | ||||||||||||||||||||||||
2387 | if (!binding->isFunctionExpression()
| 0-100 | ||||||||||||||||||||||||
2388 | QByteArray script = scriptStr.toUtf8(); | - | ||||||||||||||||||||||||
2389 | bool ok; | - | ||||||||||||||||||||||||
2390 | evaluateEnum(script, &ok); | - | ||||||||||||||||||||||||
2391 | if (!ok
| 8-90 | ||||||||||||||||||||||||
2392 | error(binding, QQmlListModel::tr("ListElement: cannot use script for property value")); | - | ||||||||||||||||||||||||
2393 | return executed 8 times by 1 test: false;return false; Executed by:
executed 8 times by 1 test: return false; Executed by:
| 8 | ||||||||||||||||||||||||
2394 | } | - | ||||||||||||||||||||||||
2395 | } executed 90 times by 2 tests: end of block Executed by:
| 90 | ||||||||||||||||||||||||
2396 | } executed 92 times by 2 tests: end of block Executed by:
| 92 | ||||||||||||||||||||||||
2397 | - | |||||||||||||||||||||||||
2398 | return executed 4730 times by 14 tests: true;return true; Executed by:
executed 4730 times by 14 tests: return true; Executed by:
| 4730 | ||||||||||||||||||||||||
2399 | } | - | ||||||||||||||||||||||||
2400 | - | |||||||||||||||||||||||||
2401 | bool QQmlListModelParser::applyProperty(QV4::CompiledData::CompilationUnit *compilationUnit, const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding, ListModel *model, int outterElementIndex) | - | ||||||||||||||||||||||||
2402 | { | - | ||||||||||||||||||||||||
2403 | const QString elementName = qmlUnit->stringAt(binding->propertyNameIndex); | - | ||||||||||||||||||||||||
2404 | - | |||||||||||||||||||||||||
2405 | bool roleSet = false; | - | ||||||||||||||||||||||||
2406 | if (binding->type >= QV4::CompiledData::Binding::Type_Object
| 3280-4404 | ||||||||||||||||||||||||
2407 | const quint32 targetObjectIndex = binding->value.objectIndex; | - | ||||||||||||||||||||||||
2408 | const QV4::CompiledData::Object *target = qmlUnit->objectAt(targetObjectIndex); | - | ||||||||||||||||||||||||
2409 | - | |||||||||||||||||||||||||
2410 | ListModel *subModel = nullptr; | - | ||||||||||||||||||||||||
2411 | if (outterElementIndex == -1
| 64-3216 | ||||||||||||||||||||||||
2412 | subModel = model; | - | ||||||||||||||||||||||||
2413 | } executed 3216 times by 13 tests: else {end of block Executed by:
| 3216 | ||||||||||||||||||||||||
2414 | const ListLayout::Role &role = model->getOrCreateListRole(elementName); | - | ||||||||||||||||||||||||
2415 | if (role.type == ListLayout::Role::List
| 2-62 | ||||||||||||||||||||||||
2416 | subModel = model->getListProperty(outterElementIndex, role); | - | ||||||||||||||||||||||||
2417 | if (subModel == nullptr
| 30-32 | ||||||||||||||||||||||||
2418 | subModel = new ListModel(role.subLayout, nullptr); | - | ||||||||||||||||||||||||
2419 | QVariant vModel = QVariant::fromValue(subModel); | - | ||||||||||||||||||||||||
2420 | model->setOrCreateProperty(outterElementIndex, elementName, vModel); | - | ||||||||||||||||||||||||
2421 | } executed 32 times by 2 tests: end of block Executed by:
| 32 | ||||||||||||||||||||||||
2422 | } executed 62 times by 2 tests: end of block Executed by:
| 62 | ||||||||||||||||||||||||
2423 | } executed 64 times by 2 tests: end of block Executed by:
| 64 | ||||||||||||||||||||||||
2424 | - | |||||||||||||||||||||||||
2425 | int elementIndex = subModel
| 2-3278 | ||||||||||||||||||||||||
2426 | - | |||||||||||||||||||||||||
2427 | const QV4::CompiledData::Binding *subBinding = target->bindingTable(); | - | ||||||||||||||||||||||||
2428 | for (quint32 i = 0; i < target->nBindings
| 3280-4468 | ||||||||||||||||||||||||
2429 | roleSet |= applyProperty(compilationUnit, qmlUnit, subBinding, subModel, elementIndex); | - | ||||||||||||||||||||||||
2430 | } executed 4468 times by 13 tests: end of block Executed by:
| 4468 | ||||||||||||||||||||||||
2431 | - | |||||||||||||||||||||||||
2432 | } executed 3280 times by 13 tests: else {end of block Executed by:
| 3280 | ||||||||||||||||||||||||
2433 | QVariant value; | - | ||||||||||||||||||||||||
2434 | - | |||||||||||||||||||||||||
2435 | if (binding->isTranslationBinding()
| 8-4396 | ||||||||||||||||||||||||
2436 | value = QVariant::fromValue<const QV4::CompiledData::Binding*>(binding); | - | ||||||||||||||||||||||||
2437 | } executed 8 times by 3 tests: else if (binding->evaluatesToString()end of block Executed by:
| 8-3944 | ||||||||||||||||||||||||
2438 | value = binding->valueAsString(qmlUnit); | - | ||||||||||||||||||||||||
2439 | } executed 3944 times by 11 tests: else if (binding->type == QV4::CompiledData::Binding::Type_Numberend of block Executed by:
| 148-3944 | ||||||||||||||||||||||||
2440 | value = binding->valueAsNumber(); | - | ||||||||||||||||||||||||
2441 | } executed 304 times by 4 tests: else if (binding->type == QV4::CompiledData::Binding::Type_Booleanend of block Executed by:
| 56-304 | ||||||||||||||||||||||||
2442 | value = binding->valueAsBoolean(); | - | ||||||||||||||||||||||||
2443 | } executed 56 times by 3 tests: else if (binding->type == QV4::CompiledData::Binding::Type_Scriptend of block Executed by:
| 0-92 | ||||||||||||||||||||||||
2444 | QString scriptStr = binding->valueAsScriptString(qmlUnit); | - | ||||||||||||||||||||||||
2445 | if (definesEmptyList(scriptStr)
| 2-90 | ||||||||||||||||||||||||
2446 | const ListLayout::Role &role = model->getOrCreateListRole(elementName); | - | ||||||||||||||||||||||||
2447 | ListModel *emptyModel = new ListModel(role.subLayout, nullptr); | - | ||||||||||||||||||||||||
2448 | value = QVariant::fromValue(emptyModel); | - | ||||||||||||||||||||||||
2449 | } executed 2 times by 1 test: else if (binding->isFunctionExpression()end of block Executed by:
| 0-90 | ||||||||||||||||||||||||
2450 | QQmlBinding::Identifier id = binding->value.compiledScriptIndex; | - | ||||||||||||||||||||||||
2451 | ((id != QQmlBinding::Invalid) ? static_cast<void>(0) : qt_assert("id != QQmlBinding::Invalid", __FILE__, 2750)); | - | ||||||||||||||||||||||||
2452 | - | |||||||||||||||||||||||||
2453 | auto v4 = compilationUnit->engine; | - | ||||||||||||||||||||||||
2454 | QV4::Scope scope(v4); | - | ||||||||||||||||||||||||
2455 | - | |||||||||||||||||||||||||
2456 | QV4::ScopedContext context(scope, QV4::QmlContext::create(v4->rootContext(), QQmlContextData::get(qmlContext(model->m_modelCache)), nullptr)); | - | ||||||||||||||||||||||||
2457 | QV4::ScopedFunctionObject function(scope, QV4::FunctionObject::createScriptFunction(context, compilationUnit->runtimeFunctions[id])); | - | ||||||||||||||||||||||||
2458 | - | |||||||||||||||||||||||||
2459 | QV4::ReturnedValue result = function->call(v4->globalObject, nullptr, 0); | - | ||||||||||||||||||||||||
2460 | - | |||||||||||||||||||||||||
2461 | QJSValue v; | - | ||||||||||||||||||||||||
2462 | QJSValuePrivate::setValue(&v, v4, result); | - | ||||||||||||||||||||||||
2463 | value.setValue<QJSValue>(v); | - | ||||||||||||||||||||||||
2464 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2465 | QByteArray script = scriptStr.toUtf8(); | - | ||||||||||||||||||||||||
2466 | bool ok; | - | ||||||||||||||||||||||||
2467 | value = evaluateEnum(script, &ok); | - | ||||||||||||||||||||||||
2468 | } executed 90 times by 2 tests: end of block Executed by:
| 90 | ||||||||||||||||||||||||
2469 | } else { | - | ||||||||||||||||||||||||
2470 | do { ((false) ? static_cast<void>(0) : qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached", __FILE__, 2769)); __builtin_unreachable(); } while (false); | - | ||||||||||||||||||||||||
2471 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2472 | - | |||||||||||||||||||||||||
2473 | model->setOrCreateProperty(outterElementIndex, elementName, value); | - | ||||||||||||||||||||||||
2474 | roleSet = true; | - | ||||||||||||||||||||||||
2475 | } executed 4404 times by 13 tests: end of block Executed by:
| 4404 | ||||||||||||||||||||||||
2476 | return executed 7684 times by 13 tests: roleSet;return roleSet; Executed by:
executed 7684 times by 13 tests: return roleSet; Executed by:
| 7684 | ||||||||||||||||||||||||
2477 | } | - | ||||||||||||||||||||||||
2478 | - | |||||||||||||||||||||||||
2479 | void QQmlListModelParser::verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &bindings) | - | ||||||||||||||||||||||||
2480 | { | - | ||||||||||||||||||||||||
2481 | listElementTypeName = QString(); | - | ||||||||||||||||||||||||
2482 | - | |||||||||||||||||||||||||
2483 | for (const QV4::CompiledData::Binding *binding : bindings) { | - | ||||||||||||||||||||||||
2484 | QString propName = qmlUnit->stringAt(binding->propertyNameIndex); | - | ||||||||||||||||||||||||
2485 | if (!propName.isEmpty()
| 2-1860 | ||||||||||||||||||||||||
2486 | error(binding, QQmlListModel::tr("ListModel: undefined property '%1'").arg(propName)); | - | ||||||||||||||||||||||||
2487 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
2488 | } | - | ||||||||||||||||||||||||
2489 | if (!verifyProperty(qmlUnit, binding)
| 14-1846 | ||||||||||||||||||||||||
2490 | return; executed 14 times by 1 test: return; Executed by:
| 14 | ||||||||||||||||||||||||
2491 | } executed 1846 times by 14 tests: end of block Executed by:
| 1846 | ||||||||||||||||||||||||
2492 | } executed 372 times by 14 tests: end of block Executed by:
| 372 | ||||||||||||||||||||||||
2493 | - | |||||||||||||||||||||||||
2494 | void QQmlListModelParser::applyBindings(QObject *obj, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) | - | ||||||||||||||||||||||||
2495 | { | - | ||||||||||||||||||||||||
2496 | QQmlListModel *rv = static_cast<QQmlListModel *>(obj); | - | ||||||||||||||||||||||||
2497 | - | |||||||||||||||||||||||||
2498 | rv->m_engine = qmlEngine(rv)->handle(); | - | ||||||||||||||||||||||||
2499 | rv->m_compilationUnit = compilationUnit; | - | ||||||||||||||||||||||||
2500 | - | |||||||||||||||||||||||||
2501 | const QV4::CompiledData::Unit *qmlUnit = compilationUnit->data; | - | ||||||||||||||||||||||||
2502 | - | |||||||||||||||||||||||||
2503 | bool setRoles = false; | - | ||||||||||||||||||||||||
2504 | - | |||||||||||||||||||||||||
2505 | for (const QV4::CompiledData::Binding *binding : bindings) { | - | ||||||||||||||||||||||||
2506 | if (binding->type != QV4::CompiledData::Binding::Type_Object
| 0-3216 | ||||||||||||||||||||||||
2507 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
2508 | setRoles |= applyProperty(compilationUnit, qmlUnit, binding, rv->m_listModel, -1); | - | ||||||||||||||||||||||||
2509 | } executed 3216 times by 13 tests: end of block Executed by:
| 3216 | ||||||||||||||||||||||||
2510 | - | |||||||||||||||||||||||||
2511 | if (setRoles == false
| 4-696 | ||||||||||||||||||||||||
2512 | qmlWarning(obj) << "All ListElement declarations are empty, no roles can be created unless dynamicRoles is set."; executed 4 times by 1 test: qmlWarning(obj) << "All ListElement declarations are empty, no roles can be created unless dynamicRoles is set."; Executed by:
| 4 | ||||||||||||||||||||||||
2513 | } executed 700 times by 13 tests: end of block Executed by:
| 700 | ||||||||||||||||||||||||
2514 | - | |||||||||||||||||||||||||
2515 | bool QQmlListModelParser::definesEmptyList(const QString &s) | - | ||||||||||||||||||||||||
2516 | { | - | ||||||||||||||||||||||||
2517 | if (s.startsWith(QLatin1Char('['))
| 0-188 | ||||||||||||||||||||||||
2518 | for (int i=1; i<s.length()-1
| 4-56 | ||||||||||||||||||||||||
2519 | if (!s[i].isSpace()
| 0-56 | ||||||||||||||||||||||||
2520 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
2521 | } executed 56 times by 1 test: end of block Executed by:
| 56 | ||||||||||||||||||||||||
2522 | return executed 4 times by 1 test: true;return true; Executed by:
executed 4 times by 1 test: return true; Executed by:
| 4 | ||||||||||||||||||||||||
2523 | } | - | ||||||||||||||||||||||||
2524 | return executed 188 times by 2 tests: false;return false; Executed by:
executed 188 times by 2 tests: return false; Executed by:
| 188 | ||||||||||||||||||||||||
2525 | } | - | ||||||||||||||||||||||||
2526 | - | |||||||||||||||||||||||||
2527 | - | |||||||||||||||||||||||||
Switch to Source code | Preprocessed file |