OpenCoverage

qqmllistmodel.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/types/qqmllistmodel.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtQml module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qqmllistmodel_p_p.h"-
41#include "qqmllistmodelworkeragent_p.h"-
42#include <private/qqmlopenmetaobject_p.h>-
43#include <private/qqmljsast_p.h>-
44#include <private/qqmljsengine_p.h>-
45#include <private/qjsvalue_p.h>-
46-
47#include <private/qqmlcustomparser_p.h>-
48#include <private/qqmlengine_p.h>-
49#include <private/qqmlnotifier_p.h>-
50-
51#include <private/qv4object_p.h>-
52#include <private/qv4dateobject_p.h>-
53#include <private/qv4objectiterator_p.h>-
54#include <private/qv4alloca_p.h>-
55-
56#include <qqmlcontext.h>-
57#include <qqmlinfo.h>-
58-
59#include <QtCore/qdebug.h>-
60#include <QtCore/qstack.h>-
61#include <QXmlStreamReader>-
62#include <QtCore/qdatetime.h>-
63#include <QScopedValueRollback>-
64-
65Q_DECLARE_METATYPE(const QV4::CompiledData::Binding*);-
66-
67QT_BEGIN_NAMESPACE-
68-
69// Set to 1024 as a debugging aid - easier to distinguish uids from indices of elements/models.-
70enum { MIN_LISTMODEL_UID = 1024 };-
71-
72static QAtomicInt uidCounter(MIN_LISTMODEL_UID);-
73-
74template <typename T>-
75static bool isMemoryUsed(const char *mem)-
76{-
77 for (size_t i=0 ; i < sizeof(T) ; ++i) {
i < sizeof(T)Description
TRUEevaluated 3012 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 344 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
344-3012
78 if (mem[i] != 0)
mem[i] != 0Description
TRUEevaluated 248 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 2764 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
248-2764
79 return true;
executed 248 times by 2 tests: return true;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
248
80 }
executed 2764 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
2764
81-
82 return false;
executed 344 times by 2 tests: return false;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
344
83}-
84-
85static QString roleTypeName(ListLayout::Role::DataType t)-
86{-
87 static const QString roleTypeNames[] = {-
88 QStringLiteral("String"), QStringLiteral("Number"), QStringLiteral("Bool"),-
89 QStringLiteral("List"), QStringLiteral("QObject"), QStringLiteral("VariantMap"),-
90 QStringLiteral("DateTime"), QStringLiteral("Function")-
91 };-
92-
93 if (t > ListLayout::Role::Invalid && t < ListLayout::Role::MaxDataType)
t > ListLayout::Role::InvalidDescription
TRUEevaluated 36 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
t < ListLayout...e::MaxDataTypeDescription
TRUEevaluated 36 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
0-36
94 return roleTypeNames[t];
executed 36 times by 2 tests: return roleTypeNames[t];
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
36
95-
96 return QString();
never executed: return QString();
0
97}-
98-
99const ListLayout::Role &ListLayout::getRoleOrCreate(const QString &key, Role::DataType type)-
100{-
101 QStringHash<Role *>::Node *node = roleHash.findNode(key);-
102 if (node) {
nodeDescription
TRUEevaluated 3656 times by 11 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
FALSEevaluated 910 times by 13 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
910-3656
103 const Role &r = *node->value;-
104 if (type != r.type)
type != r.typeDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 3652 times by 11 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
4-3652
105 qmlWarning(nullptr) << QStringLiteral("Can't assign to existing role '%1' of different type [%2 -> %3]").arg(r.name).arg(roleTypeName(type)).arg(roleTypeName(r.type));
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:
  • tst_qqmllistmodel
executed 4 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qqmllistmodel
4
106 return r;
executed 3656 times by 11 tests: return r;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
3656
107 }-
108-
109 return createRole(key, type);
executed 910 times by 13 tests: return createRole(key, type);
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
910
110}-
111-
112const ListLayout::Role &ListLayout::getRoleOrCreate(QV4::String *key, Role::DataType type)-
113{-
114 QStringHash<Role *>::Node *node = roleHash.findNode(key);-
115 if (node) {
nodeDescription
TRUEevaluated 2740 times by 8 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickvisualdatamodel
FALSEevaluated 1208 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
1208-2740
116 const Role &r = *node->value;-
117 if (type != r.type)
type != r.typeDescription
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 2728 times by 8 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickvisualdatamodel
12-2728
118 qmlWarning(nullptr) << QStringLiteral("Can't assign to existing role '%1' of different type [%2 -> %3]").arg(r.name).arg(roleTypeName(type)).arg(roleTypeName(r.type));
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:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
executed 12 times by 2 tests: return qstring_literal_temp;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12
119 return r;
executed 2740 times by 8 tests: return r;
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickvisualdatamodel
2740
120 }-
121-
122 QString qkey = key->toQString();-
123-
124 return createRole(qkey, type);
executed 1208 times by 7 tests: return createRole(qkey, type);
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
1208
125}-
126-
127const ListLayout::Role &ListLayout::createRole(const QString &key, ListLayout::Role::DataType type)-
128{-
129 const int dataSizes[] = { sizeof(StringOrTranslation), sizeof(double), sizeof(bool), sizeof(ListModel *), sizeof(QPointer<QObject>), sizeof(QVariantMap), sizeof(QDateTime), sizeof(QJSValue) };-
130 const int dataAlignments[] = { sizeof(StringOrTranslation), sizeof(double), sizeof(bool), sizeof(ListModel *), sizeof(QObject *), sizeof(QVariantMap), sizeof(QDateTime), sizeof(QJSValue) };-
131-
132 Role *r = new Role;-
133 r->name = key;-
134 r->type = type;-
135-
136 if (type == Role::List) {
type == Role::ListDescription
TRUEevaluated 128 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
FALSEevaluated 1990 times by 15 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
128-1990
137 r->subLayout = new ListLayout;-
138 } else {
executed 128 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
128
139 r->subLayout = nullptr;-
140 }
executed 1990 times by 15 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
1990
141-
142 int dataSize = dataSizes[type];-
143 int dataAlignment = dataAlignments[type];-
144-
145 int dataOffset = (currentBlockOffset + dataAlignment-1) & ~(dataAlignment-1);-
146 if (dataOffset + dataSize > ListElement::BLOCK_SIZE) {
dataOffset + d...nt::BLOCK_SIZEDescription
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 2112 times by 15 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
6-2112
147 r->blockIndex = ++currentBlock;-
148 r->blockOffset = 0;-
149 currentBlockOffset = dataSize;-
150 } else {
executed 6 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
6
151 r->blockIndex = currentBlock;-
152 r->blockOffset = dataOffset;-
153 currentBlockOffset = dataOffset + dataSize;-
154 }
executed 2112 times by 15 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
2112
155-
156 int roleIndex = roles.count();-
157 r->index = roleIndex;-
158-
159 roles.append(r);-
160 roleHash.insert(key, r);-
161-
162 return *r;
executed 2118 times by 15 tests: return *r;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
2118
163}-
164-
165ListLayout::ListLayout(const ListLayout *other) : currentBlock(0), currentBlockOffset(0)-
166{-
167 const int otherRolesCount = other->roles.count();-
168 roles.reserve(otherRolesCount);-
169 for (int i=0 ; i < otherRolesCount; ++i) {
i < otherRolesCountDescription
TRUEevaluated 90 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 942 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
90-942
170 Role *role = new Role(other->roles[i]);-
171 roles.append(role);-
172 roleHash.insert(role->name, role);-
173 }
executed 90 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
90
174 currentBlockOffset = other->currentBlockOffset;-
175 currentBlock = other->currentBlock;-
176}
executed 942 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
942
177-
178ListLayout::~ListLayout()-
179{-
180 qDeleteAll(roles);-
181}
executed 3516 times by 15 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
3516
182-
183void ListLayout::sync(ListLayout *src, ListLayout *target)-
184{-
185 int roleOffset = target->roles.count();-
186 int newRoleCount = src->roles.count() - roleOffset;-
187-
188 for (int i=0 ; i < newRoleCount ; ++i) {
i < newRoleCountDescription
TRUEevaluated 476 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 926 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
476-926
189 Role *role = new Role(src->roles[roleOffset + i]);-
190 target->roles.append(role);-
191 target->roleHash.insert(role->name, role);-
192 }
executed 476 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
476
193-
194 target->currentBlockOffset = src->currentBlockOffset;-
195 target->currentBlock = src->currentBlock;-
196}
executed 926 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
926
197-
198ListLayout::Role::Role(const Role *other)-
199{-
200 name = other->name;-
201 type = other->type;-
202 blockIndex = other->blockIndex;-
203 blockOffset = other->blockOffset;-
204 index = other->index;-
205 if (other->subLayout)
other->subLayoutDescription
TRUEevaluated 38 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 528 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
38-528
206 subLayout = new ListLayout(other->subLayout);
executed 38 times by 1 test: subLayout = new ListLayout(other->subLayout);
Executed by:
  • tst_qqmllistmodelworkerscript
38
207 else-
208 subLayout = nullptr;
executed 528 times by 1 test: subLayout = nullptr;
Executed by:
  • tst_qqmllistmodelworkerscript
528
209}-
210-
211ListLayout::Role::~Role()-
212{-
213 delete subLayout;-
214}
executed 2672 times by 15 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
2672
215-
216const ListLayout::Role *ListLayout::getRoleOrCreate(const QString &key, const QVariant &data)-
217{-
218 Role::DataType type;-
219-
220 switch (data.type()) {-
221 case QVariant::Double: type = Role::Number; break;
executed 302 times by 4 tests: break;
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qquicklistview
  • tst_qquickrepeater
executed 302 times by 4 tests: case QVariant::Double:
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qquicklistview
  • tst_qquickrepeater
302
222 case QVariant::Int: type = Role::Number; break;
executed 144 times by 4 tests: break;
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
executed 144 times by 4 tests: case QVariant::Int:
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
144
223 case QVariant::Bool: type = Role::Bool; break;
executed 66 times by 3 tests: break;
Executed by:
  • tst_qqmllistmodel
  • tst_qquicklistview
  • tst_qtqmlmodules
executed 66 times by 3 tests: case QVariant::Bool:
Executed by:
  • tst_qqmllistmodel
  • tst_qquicklistview
  • tst_qtqmlmodules
66
224 case QVariant::String: type = Role::String; break;
executed 3944 times by 11 tests: break;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
executed 3944 times by 11 tests: case QVariant::String:
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
3944
225 case QVariant::Map: type = Role::VariantMap; break;
never executed: break;
never executed: case QVariant::Map:
0
226 case QVariant::DateTime: type = Role::DateTime; break;
executed 2 times by 1 test: break;
Executed by:
  • tst_qqmllistmodel
executed 2 times by 1 test: case QVariant::DateTime:
Executed by:
  • tst_qqmllistmodel
2
227 case QVariant::UserType: {
executed 42 times by 4 tests: case QVariant::UserType:
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmltranslation
42
228 if (data.userType() == qMetaTypeId<QJSValue>() &&
data.userType(...Id<QJSValue>()Description
TRUEnever evaluated
FALSEevaluated 42 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmltranslation
0-42
229 data.value<QJSValue>().isCallable()) {
data.value<QJS...).isCallable()Description
TRUEnever evaluated
FALSEnever evaluated
0
230 type = Role::Function;-
231 break;
never executed: break;
0
232 } else if (data.userType() == qMetaTypeId<const QV4::CompiledData::Binding*>()
data.userType(...a::Binding*>()Description
TRUEevaluated 8 times by 3 tests
Evaluated by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmltranslation
FALSEevaluated 34 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
8-34
233 && data.value<const QV4::CompiledData::Binding*>()->isTranslationBinding()) {
data.value<con...ationBinding()Description
TRUEevaluated 8 times by 3 tests
Evaluated by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmltranslation
FALSEnever evaluated
0-8
234 type = Role::String;-
235 break;
executed 8 times by 3 tests: break;
Executed by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmltranslation
8
236 } else {-
237 type = Role::List;-
238 break;
executed 34 times by 2 tests: break;
Executed by:
  • tst_examples
  • tst_qqmllistmodel
34
239 }-
240 }-
241 default: type = Role::Invalid; break;
executed 2 times by 1 test: break;
Executed by:
  • tst_qqmllistmodel
executed 2 times by 1 test: default:
Executed by:
  • tst_qqmllistmodel
2
242 }-
243-
244 if (type == Role::Invalid) {
type == Role::InvalidDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 4500 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
2-4500
245 qmlWarning(nullptr) << "Can't create role for unsupported data type";-
246 return nullptr;
executed 2 times by 1 test: return nullptr;
Executed by:
  • tst_qqmllistmodel
2
247 }-
248-
249 return &getRoleOrCreate(key, type);
executed 4500 times by 14 tests: return &getRoleOrCreate(key, type);
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
4500
250}-
251-
252const ListLayout::Role *ListLayout::getExistingRole(const QString &key) const-
253{-
254 Role *r = nullptr;-
255 QStringHash<Role *>::Node *node = roleHash.findNode(key);-
256 if (node)
nodeDescription
TRUEevaluated 58 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
0-58
257 r = node->value;
executed 58 times by 2 tests: r = node->value;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
58
258 return r;
executed 58 times by 2 tests: return r;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
58
259}-
260-
261const ListLayout::Role *ListLayout::getExistingRole(QV4::String *key) const-
262{-
263 Role *r = nullptr;-
264 QStringHash<Role *>::Node *node = roleHash.findNode(key);-
265 if (node)
nodeDescription
TRUEevaluated 862 times by 8 tests
Evaluated by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
FALSEevaluated 8 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
8-862
266 r = node->value;
executed 862 times by 8 tests: r = node->value;
Executed by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
862
267 return r;
executed 870 times by 8 tests: return r;
Executed by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
870
268}-
269-
270StringOrTranslation::StringOrTranslation(const QString &s)-
271{-
272 d.setFlag();-
273 setString(s);-
274}
executed 1170 times by 8 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickvisualdatamodel
1170
275-
276StringOrTranslation::StringOrTranslation(const QV4::CompiledData::Binding *binding)-
277{-
278 d.setFlag();-
279 clear();-
280 d = binding;-
281}
never executed: end of block
0
282-
283StringOrTranslation::~StringOrTranslation()-
284{-
285 clear();-
286}
executed 5122 times by 14 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
5122
287-
288void StringOrTranslation::setString(const QString &s)-
289{-
290 d.setFlag();-
291 clear();-
292 QStringData *stringData = const_cast<QString &>(s).data_ptr();-
293 d = stringData;-
294 if (stringData)
stringDataDescription
TRUEevaluated 5126 times by 13 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
FALSEnever evaluated
0-5126
295 stringData->ref.ref();
executed 5126 times by 13 tests: stringData->ref.ref();
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
5126
296}
executed 5126 times by 13 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
5126
297-
298void StringOrTranslation::setTranslation(const QV4::CompiledData::Binding *binding)-
299{-
300 d.setFlag();-
301 clear();-
302 d = binding;-
303}
executed 8 times by 3 tests: end of block
Executed by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmltranslation
8
304-
305QString StringOrTranslation::toString(const QQmlListModel *owner) const-
306{-
307 if (d.isNull())
d.isNull()Description
TRUEnever evaluated
FALSEevaluated 10271 times by 12 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickvisualdatamodel
0-10271
308 return QString();
never executed: return QString();
0
309 if (d.isT1()) {
d.isT1()Description
TRUEevaluated 10261 times by 11 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickvisualdatamodel
FALSEevaluated 10 times by 3 tests
Evaluated by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmltranslation
10-10261
310 QStringDataPtr holder = { d.asT1() };-
311 holder.ptr->ref.ref();-
312 return QString(holder);
executed 10261 times by 11 tests: return QString(holder);
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickvisualdatamodel
10261
313 }-
314 if (!owner)
!ownerDescription
TRUEnever evaluated
FALSEevaluated 10 times by 3 tests
Evaluated by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmltranslation
0-10
315 return QString();
never executed: return QString();
0
316 return d.asT2()->valueAsString(owner->m_compilationUnit->data);
executed 10 times by 3 tests: return d.asT2()->valueAsString(owner->m_compilationUnit->data);
Executed by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmltranslation
10
317}-
318-
319QString StringOrTranslation::asString() const-
320{-
321 if (d.isNull())
d.isNull()Description
TRUEnever evaluated
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
0-6
322 return QString();
never executed: return QString();
0
323 if (!d.isT1())
!d.isT1()Description
TRUEnever evaluated
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
0-6
324 return QString();
never executed: return QString();
0
325 QStringDataPtr holder = { d.asT1() };-
326 holder.ptr->ref.ref();-
327 return QString(holder);
executed 6 times by 2 tests: return QString(holder);
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
6
328}-
329-
330void StringOrTranslation::clear()-
331{-
332 if (QStringData *strData = d.isT1() ? d.asT1() : nullptr) {
QStringData *s...T1() : nullptrDescription
TRUEevaluated 5120 times by 13 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
FALSEevaluated 5136 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
d.isT1()Description
TRUEevaluated 10248 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
FALSEevaluated 8 times by 3 tests
Evaluated by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmltranslation
8-10248
333 if (!strData->ref.deref())
!strData->ref.deref()Description
TRUEevaluated 105 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
FALSEevaluated 5015 times by 13 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
105-5015
334 QStringData::deallocate(strData);
executed 105 times by 7 tests: QStringData::deallocate(strData);
Executed by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
105
335 }
executed 5120 times by 13 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
5120
336 d = static_cast<QStringData *>(nullptr);-
337}
executed 10256 times by 14 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
10256
338-
339QObject *ListModel::getOrCreateModelObject(QQmlListModel *model, int elementIndex)-
340{-
341 ListElement *e = elements[elementIndex];-
342 if (e->m_objectCache == nullptr) {
e->m_objectCache == nullptrDescription
TRUEevaluated 660 times by 8 tests
Evaluated by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
FALSEevaluated 298 times by 5 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquicklistview
298-660
343 void *memory = operator new(sizeof(QObject) + sizeof(QQmlData));-
344 void *ddataMemory = ((char *)memory) + sizeof(QObject);-
345 e->m_objectCache = new (memory) QObject;-
346 QQmlData *ddata = new (ddataMemory) QQmlData;-
347 ddata->ownMemory = false;-
348 QObjectPrivate::get(e->m_objectCache)->declarativeData = ddata;-
349 (void)new ModelNodeMetaObject(e->m_objectCache, model, elementIndex);-
350 }
executed 660 times by 8 tests: end of block
Executed by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
660
351 return e->m_objectCache;
executed 958 times by 8 tests: return e->m_objectCache;
Executed by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
958
352}-
353-
354bool ListModel::sync(ListModel *src, ListModel *target)-
355{-
356 // Sanity check-
357-
358 bool hasChanges = false;-
359-
360 // Build hash of elements <-> uid for each of the lists-
361 QHash<int, ElementSync> elementHash;-
362 for (int i = 0; i < target->elements.count(); ++i) {
i < target->elements.count()Description
TRUEevaluated 64 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 926 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
64-926
363 ListElement *e = target->elements.at(i);-
364 int uid = e->getUid();-
365 ElementSync sync;-
366 sync.target = e;-
367 sync.targetIndex = i;-
368 elementHash.insert(uid, sync);-
369 }
executed 64 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
64
370 for (int i = 0; i < src->elements.count(); ++i) {
i < src->elements.count()Description
TRUEevaluated 694 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 926 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
694-926
371 ListElement *e = src->elements.at(i);-
372 int uid = e->getUid();-
373-
374 QHash<int, ElementSync>::iterator it = elementHash.find(uid);-
375 if (it == elementHash.end()) {
it == elementHash.end()Description
TRUEevaluated 634 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 60 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
60-634
376 ElementSync sync;-
377 sync.src = e;-
378 sync.srcIndex = i;-
379 elementHash.insert(uid, sync);-
380 } else {
executed 634 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
634
381 ElementSync &sync = it.value();-
382 sync.src = e;-
383 sync.srcIndex = i;-
384 }
executed 60 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
60
385 }-
386-
387 QQmlListModel *targetModel = target->m_modelCache;-
388-
389 // Get list of elements that are in the target but no longer in the source. These get deleted first.-
390 int rowsRemoved = 0;-
391 for (int i = 0 ; i < target->elements.count() ; ++i) {
i < target->elements.count()Description
TRUEevaluated 64 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 926 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
64-926
392 ListElement *element = target->elements.at(i);-
393 ElementSync &s = elementHash.find(element->getUid()).value();-
394 Q_ASSERT(s.targetIndex >= 0);-
395 // need to update the targetIndex, to keep it correct after removals-
396 s.targetIndex -= rowsRemoved;-
397 if (s.src == nullptr) {
s.src == nullptrDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 60 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
4-60
398 Q_ASSERT(s.targetIndex == i);-
399 hasChanges = true;-
400 if (targetModel)
targetModelDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
0-4
401 targetModel->beginRemoveRows(QModelIndex(), i, i);
executed 4 times by 1 test: targetModel->beginRemoveRows(QModelIndex(), i, i);
Executed by:
  • tst_qqmllistmodelworkerscript
4
402 s.target->destroy(target->m_layout);-
403 target->elements.removeOne(s.target);-
404 delete s.target;-
405 if (targetModel)
targetModelDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
0-4
406 targetModel->endRemoveRows();
executed 4 times by 1 test: targetModel->endRemoveRows();
Executed by:
  • tst_qqmllistmodelworkerscript
4
407 ++rowsRemoved;-
408 --i;-
409 continue;
executed 4 times by 1 test: continue;
Executed by:
  • tst_qqmllistmodelworkerscript
4
410 }-
411 }
executed 60 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
60
412-
413 // Sync the layouts-
414 ListLayout::sync(src->m_layout, target->m_layout);-
415-
416 // Clear the target list, and append in correct order from the source-
417 target->elements.clear();-
418 for (int i = 0; i < src->elements.count(); ++i) {
i < src->elements.count()Description
TRUEevaluated 694 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 926 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
694-926
419 ListElement *srcElement = src->elements.at(i);-
420 ElementSync &s = elementHash.find(srcElement->getUid()).value();-
421 Q_ASSERT(s.srcIndex >= 0);-
422 ListElement *targetElement = s.target;-
423 if (targetElement == nullptr) {
targetElement == nullptrDescription
TRUEevaluated 634 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 60 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
60-634
424 targetElement = new ListElement(srcElement->getUid());-
425 }
executed 634 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
634
426 s.changedRoles = ListElement::sync(srcElement, src->m_layout, targetElement, target->m_layout);-
427 target->elements.append(targetElement);-
428 }
executed 694 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
694
429-
430 target->updateCacheIndices();-
431-
432 // Update values stored in target meta objects-
433 for (int i=0 ; i < target->elements.count() ; ++i) {
i < target->elements.count()Description
TRUEevaluated 694 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 926 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
694-926
434 ListElement *e = target->elements[i];-
435 if (ModelNodeMetaObject *mo = e->objectCache())
ModelNodeMetaO...>objectCache()Description
TRUEnever evaluated
FALSEevaluated 694 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
0-694
436 mo->updateValues();
never executed: mo->updateValues();
0
437 }
executed 694 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
694
438-
439 // now emit the change notifications required. This can be safely done, as we're only emitting changes, moves and inserts,-
440 // so the model indices can't be out of bounds-
441 //-
442 // to ensure things are kept in the correct order, emit inserts and moves first. This shouls ensure all persistent-
443 // model indices are updated correctly-
444 int rowsInserted = 0;-
445 for (int i = 0 ; i < target->elements.count() ; ++i) {
i < target->elements.count()Description
TRUEevaluated 694 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 926 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
694-926
446 ListElement *element = target->elements.at(i);-
447 ElementSync &s = elementHash.find(element->getUid()).value();-
448 Q_ASSERT(s.srcIndex >= 0);-
449 s.srcIndex += rowsInserted;-
450 if (s.srcIndex != s.targetIndex) {
s.srcIndex != s.targetIndexDescription
TRUEevaluated 634 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 60 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
60-634
451 if (targetModel) {
targetModelDescription
TRUEevaluated 544 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 90 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
90-544
452 if (s.targetIndex == -1) {
s.targetIndex == -1Description
TRUEevaluated 544 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
0-544
453 targetModel->beginInsertRows(QModelIndex(), i, i);-
454 targetModel->endInsertRows();-
455 } else {
executed 544 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
544
456 targetModel->beginMoveRows(QModelIndex(), i, i, QModelIndex(), s.srcIndex);-
457 targetModel->endMoveRows();-
458 }
never executed: end of block
0
459 }-
460 hasChanges = true;-
461 ++rowsInserted;-
462 }
executed 634 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
634
463 if (s.targetIndex != -1 && !s.changedRoles.isEmpty()) {
s.targetIndex != -1Description
TRUEevaluated 60 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 634 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
!s.changedRoles.isEmpty()Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 50 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
10-634
464 QModelIndex idx = targetModel->createIndex(i, 0);-
465 if (targetModel)
targetModelDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
0-10
466 targetModel->dataChanged(idx, idx, s.changedRoles);
executed 10 times by 1 test: targetModel->dataChanged(idx, idx, s.changedRoles);
Executed by:
  • tst_qqmllistmodelworkerscript
10
467 hasChanges = true;-
468 }
executed 10 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
10
469 }
executed 694 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
694
470 return hasChanges;
executed 926 times by 2 tests: return hasChanges;
Executed by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
926
471}-
472-
473ListModel::ListModel(ListLayout *layout, QQmlListModel *modelCache) : m_layout(layout), m_modelCache(modelCache)-
474{-
475}
executed 3596 times by 15 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
3596
476-
477void ListModel::destroy()-
478{-
479 for (const auto &destroyer : remove(0, elements.count()))-
480 destroyer();
executed 6288 times by 15 tests: destroyer();
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
6288
481-
482 m_layout = nullptr;-
483 if (m_modelCache && m_modelCache->m_primary == false)
m_modelCacheDescription
TRUEevaluated 3490 times by 15 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
FALSEevaluated 98 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
m_modelCache->...imary == falseDescription
TRUEevaluated 138 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
FALSEevaluated 3352 times by 15 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
98-3490
484 delete m_modelCache;
executed 138 times by 4 tests: delete m_modelCache;
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
138
485 m_modelCache = nullptr;-
486}
executed 3588 times by 15 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
3588
487-
488int ListModel::appendElement()-
489{-
490 int elementIndex = elements.count();-
491 newElement(elementIndex);-
492 return elementIndex;
executed 5560 times by 15 tests: return elementIndex;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
5560
493}-
494-
495void ListModel::insertElement(int index)-
496{-
497 newElement(index);-
498 updateCacheIndices(index);-
499}
executed 460 times by 5 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickvisualdatamodel
460
500-
501void ListModel::move(int from, int to, int n)-
502{-
503 if (from > to) {
from > toDescription
TRUEevaluated 34 times by 4 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
FALSEevaluated 54 times by 4 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickvisualdatamodel
34-54
504 // Only move forwards - flip if backwards moving-
505 int tfrom = from;-
506 int tto = to;-
507 from = tto;-
508 to = tto+n;-
509 n = tfrom-tto;-
510 }
executed 34 times by 4 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
34
511-
512 QPODVector<ListElement *, 4> store;-
513 for (int i=0 ; i < (to-from) ; ++i)
i < (to-from)Description
TRUEevaluated 94 times by 5 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
FALSEevaluated 88 times by 5 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
88-94
514 store.append(elements[from+n+i]);
executed 94 times by 5 tests: store.append(elements[from+n+i]);
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
94
515 for (int i=0 ; i < n ; ++i)
i < nDescription
TRUEevaluated 126 times by 5 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
FALSEevaluated 88 times by 5 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
88-126
516 store.append(elements[from+i]);
executed 126 times by 5 tests: store.append(elements[from+i]);
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
126
517 for (int i=0 ; i < store.count() ; ++i)
i < store.count()Description
TRUEevaluated 220 times by 5 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
FALSEevaluated 88 times by 5 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
88-220
518 elements[from+i] = store[i];
executed 220 times by 5 tests: elements[from+i] = store[i];
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
220
519-
520 updateCacheIndices(from, to + n);-
521}
executed 88 times by 5 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
88
522-
523void ListModel::newElement(int index)-
524{-
525 ListElement *e = new ListElement;-
526 elements.insert(index, e);-
527}
executed 6020 times by 15 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
6020
528-
529void ListModel::updateCacheIndices(int start, int end)-
530{-
531 int count = elements.count();-
532-
533 if (end < 0 || end > count)
end < 0Description
TRUEevaluated 5250 times by 15 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
FALSEevaluated 88 times by 5 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
end > countDescription
TRUEnever evaluated
FALSEevaluated 88 times by 5 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
0-5250
534 end = count;
executed 5250 times by 15 tests: end = count;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
5250
535-
536 for (int i = start; i < end; ++i) {
i < endDescription
TRUEevaluated 3118 times by 6 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
FALSEevaluated 5338 times by 15 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
3118-5338
537 ListElement *e = elements.at(i);-
538 if (ModelNodeMetaObject *mo = e->objectCache())
ModelNodeMetaO...>objectCache()Description
TRUEevaluated 324 times by 3 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qquickgridview
  • tst_qquicklistview
FALSEevaluated 2794 times by 6 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
324-2794
539 mo->m_elementIndex = i;
executed 324 times by 3 tests: mo->m_elementIndex = i;
Executed by:
  • tst_qqmllistmodel
  • tst_qquickgridview
  • tst_qquicklistview
324
540 }
executed 3118 times by 6 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
3118
541}
executed 5338 times by 15 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
5338
542-
543QVariant ListModel::getProperty(int elementIndex, int roleIndex, const QQmlListModel *owner, QV4::ExecutionEngine *eng)-
544{-
545 if (roleIndex >= m_layout->roleCount())
roleIndex >= m...t->roleCount()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 11583 times by 13 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
2-11583
546 return QVariant();
executed 2 times by 1 test: return QVariant();
Executed by:
  • tst_qqmllistmodel
2
547 ListElement *e = elements[elementIndex];-
548 const ListLayout::Role &r = m_layout->getExistingRole(roleIndex);-
549 return e->getProperty(r, owner, eng);
executed 11583 times by 13 tests: return e->getProperty(r, owner, eng);
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
11583
550}-
551-
552ListModel *ListModel::getListProperty(int elementIndex, const ListLayout::Role &role)-
553{-
554 ListElement *e = elements[elementIndex];-
555 return e->getListProperty(role);
executed 62 times by 2 tests: return e->getListProperty(role);
Executed by:
  • tst_examples
  • tst_qqmllistmodel
62
556}-
557-
558void ListModel::set(int elementIndex, QV4::Object *object, QVector<int> *roles)-
559{-
560 ListElement *e = elements[elementIndex];-
561-
562 QV4::ExecutionEngine *v4 = object->engine();-
563 QV4::Scope scope(v4);-
564 QV4::ScopedObject o(scope);-
565-
566 QV4::ObjectIterator it(scope, object, QV4::ObjectIterator::WithProtoChain|QV4::ObjectIterator::EnumerableOnly);-
567 QV4::ScopedString propertyName(scope);-
568 QV4::ScopedValue propertyValue(scope);-
569 while (1) {-
570 propertyName = it.nextPropertyNameAsString(propertyValue);-
571 if (!propertyName)
!propertyNameDescription
TRUEevaluated 122 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 134 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
122-134
572 break;
executed 122 times by 2 tests: break;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
122
573-
574 // Check if this key exists yet-
575 int roleIndex = -1;-
576-
577 // Add the value now-
578 if (const QV4::String *s = propertyValue->as<QV4::String>()) {
const QV4::Str...QV4::String>()Description
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 128 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
6-128
579 const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::String);-
580 roleIndex = e->setStringProperty(r, s->toQString());-
581 } else if (propertyValue->isNumber()) {
executed 6 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
propertyValue->isNumber()Description
TRUEevaluated 68 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 60 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
6-68
582 const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Number);-
583 roleIndex = e->setDoubleProperty(r, propertyValue->asDouble());-
584 } else if (QV4::ArrayObject *a = propertyValue->as<QV4::ArrayObject>()) {
executed 68 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
QV4::ArrayObje...ArrayObject>()Description
TRUEevaluated 22 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 38 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
22-68
585 const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::List);-
586 ListModel *subModel = new ListModel(r.subLayout, nullptr);-
587-
588 int arrayLength = a->getLength();-
589 for (int j=0 ; j < arrayLength ; ++j) {
j < arrayLengthDescription
TRUEevaluated 32 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 22 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
22-32
590 o = a->get(j);-
591 subModel->append(o);-
592 }
executed 32 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
32
593-
594 roleIndex = e->setListProperty(r, subModel);-
595 } else if (propertyValue->isBoolean()) {
executed 22 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
propertyValue->isBoolean()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 34 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
4-34
596 const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Bool);-
597 roleIndex = e->setBoolProperty(r, propertyValue->booleanValue());-
598 } else if (QV4::DateObject *dd = propertyValue->as<QV4::DateObject>()) {
executed 4 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
QV4::DateObjec...:DateObject>()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 32 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
2-32
599 const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::DateTime);-
600 QDateTime dt = dd->toQDateTime();-
601 roleIndex = e->setDateTimeProperty(r, dt);-
602 } else if (QV4::FunctionObject *f = propertyValue->as<QV4::FunctionObject>()) {
executed 2 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
QV4::FunctionO...ctionObject>()Description
TRUEnever evaluated
FALSEevaluated 32 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
0-32
603 const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Function);-
604 QV4::ScopedFunctionObject func(scope, f);-
605 QJSValue jsv;-
606 QJSValuePrivate::setValue(&jsv, v4, func);-
607 roleIndex = e->setFunctionProperty(r, jsv);-
608 } else if (QV4::Object *o = propertyValue->as<QV4::Object>()) {
never executed: end of block
QV4::Object *o...QV4::Object>()Description
TRUEevaluated 20 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
0-20
609 if (QV4::QObjectWrapper *wrapper = o->as<QV4::QObjectWrapper>()) {
QV4::QObjectWr...jectWrapper>()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 18 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
2-18
610 QObject *o = wrapper->object();-
611 const ListLayout::Role &role = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::QObject);-
612 if (role.type == ListLayout::Role::QObject)
role.type == L...:Role::QObjectDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEnever evaluated
0-2
613 roleIndex = e->setQObjectProperty(role, o);
executed 2 times by 1 test: roleIndex = e->setQObjectProperty(role, o);
Executed by:
  • tst_qqmllistmodel
2
614 } else {
executed 2 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
2
615 const ListLayout::Role &role = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::VariantMap);-
616 if (role.type == ListLayout::Role::VariantMap) {
role.type == L...le::VariantMapDescription
TRUEevaluated 18 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
0-18
617 QV4::ScopedObject obj(scope, o);-
618 roleIndex = e->setVariantMapProperty(role, obj);-
619 }
executed 18 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
18
620 }
executed 18 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
18
621 } else if (propertyValue->isNullOrUndefined()) {
propertyValue-...lOrUndefined()Description
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
0-12
622 const ListLayout::Role *r = m_layout->getExistingRole(propertyName);-
623 if (r)
rDescription
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
0-12
624 e->clearProperty(*r);
executed 12 times by 2 tests: e->clearProperty(*r);
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12
625 }
executed 12 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12
626-
627 if (roleIndex != -1)
roleIndex != -1Description
TRUEevaluated 114 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 20 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
20-114
628 roles->append(roleIndex);
executed 114 times by 2 tests: roles->append(roleIndex);
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
114
629 }
executed 134 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
134
630-
631 if (ModelNodeMetaObject *mo = e->objectCache())
ModelNodeMetaO...>objectCache()Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 96 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
26-96
632 mo->updateValues(*roles);
executed 26 times by 1 test: mo->updateValues(*roles);
Executed by:
  • tst_qqmllistmodel
26
633}
executed 122 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
122
634-
635void ListModel::set(int elementIndex, QV4::Object *object)-
636{-
637 if (!object)
!objectDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 2736 times by 9 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
6-2736
638 return;
executed 6 times by 1 test: return;
Executed by:
  • tst_qqmllistmodel
6
639-
640 ListElement *e = elements[elementIndex];-
641-
642 QV4::ExecutionEngine *v4 = object->engine();-
643 QV4::Scope scope(v4);-
644-
645 QV4::ObjectIterator it(scope, object, QV4::ObjectIterator::WithProtoChain|QV4::ObjectIterator::EnumerableOnly);-
646 QV4::ScopedString propertyName(scope);-
647 QV4::ScopedValue propertyValue(scope);-
648 QV4::ScopedObject o(scope);-
649 while (1) {-
650 propertyName = it.nextPropertyNameAsString(propertyValue);-
651 if (!propertyName)
!propertyNameDescription
TRUEevaluated 2736 times by 9 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
FALSEevaluated 3832 times by 9 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
2736-3832
652 break;
executed 2736 times by 9 tests: break;
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
2736
653-
654 // Add the value now-
655 if (QV4::String *s = propertyValue->stringValue()) {
QV4::String *s...>stringValue()Description
TRUEevaluated 1176 times by 8 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickvisualdatamodel
FALSEevaluated 2656 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
1176-2656
656 const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::String);-
657 if (r.type == ListLayout::Role::String)
r.type == List...::Role::StringDescription
TRUEevaluated 1170 times by 8 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickvisualdatamodel
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
6-1170
658 e->setStringPropertyFast(r, s->toQString());
executed 1170 times by 8 tests: e->setStringPropertyFast(r, s->toQString());
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickvisualdatamodel
1170
659 } else if (propertyValue->isNumber()) {
executed 1176 times by 8 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickvisualdatamodel
propertyValue->isNumber()Description
TRUEevaluated 2334 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
FALSEevaluated 322 times by 4 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
322-2334
660 const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Number);-
661 if (r.type == ListLayout::Role::Number) {
r.type == List...::Role::NumberDescription
TRUEevaluated 2334 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
FALSEnever evaluated
0-2334
662 e->setDoublePropertyFast(r, propertyValue->asDouble());-
663 }
executed 2334 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
2334
664 } else if (QV4::ArrayObject *a = propertyValue->as<QV4::ArrayObject>()) {
executed 2334 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
QV4::ArrayObje...ArrayObject>()Description
TRUEevaluated 126 times by 3 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
FALSEevaluated 196 times by 3 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
126-2334
665 const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::List);-
666 if (r.type == ListLayout::Role::List) {
r.type == List...ut::Role::ListDescription
TRUEevaluated 126 times by 3 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
FALSEnever evaluated
0-126
667 ListModel *subModel = new ListModel(r.subLayout, nullptr);-
668-
669 int arrayLength = a->getLength();-
670 for (int j=0 ; j < arrayLength ; ++j) {
j < arrayLengthDescription
TRUEevaluated 344 times by 3 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
FALSEevaluated 126 times by 3 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
126-344
671 o = a->get(j);-
672 subModel->append(o);-
673 }
executed 344 times by 3 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
344
674-
675 e->setListPropertyFast(r, subModel);-
676 }
executed 126 times by 3 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
126
677 } else if (propertyValue->isBoolean()) {
executed 126 times by 3 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
propertyValue->isBoolean()Description
TRUEevaluated 88 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qquicklistview
FALSEevaluated 108 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
88-126
678 const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Bool);-
679 if (r.type == ListLayout::Role::Bool) {
r.type == List...ut::Role::BoolDescription
TRUEevaluated 88 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qquicklistview
FALSEnever evaluated
0-88
680 e->setBoolPropertyFast(r, propertyValue->booleanValue());-
681 }
executed 88 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qquicklistview
88
682 } else if (QV4::DateObject *date = propertyValue->as<QV4::DateObject>()) {
executed 88 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qquicklistview
QV4::DateObjec...:DateObject>()Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 98 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
10-98
683 const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::DateTime);-
684 if (r.type == ListLayout::Role::DateTime) {
r.type == List...Role::DateTimeDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEnever evaluated
0-10
685 QDateTime dt = date->toQDateTime();;-
686 e->setDateTimePropertyFast(r, dt);-
687 }
executed 10 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
10
688 } else if (QV4::Object *o = propertyValue->as<QV4::Object>()) {
executed 10 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
QV4::Object *o...QV4::Object>()Description
TRUEevaluated 92 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
6-92
689 if (QV4::QObjectWrapper *wrapper = o->as<QV4::QObjectWrapper>()) {
QV4::QObjectWr...jectWrapper>()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 84 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
8-84
690 QObject *o = wrapper->object();-
691 const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::QObject);-
692 if (r.type == ListLayout::Role::QObject)
r.type == List...:Role::QObjectDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEnever evaluated
0-8
693 e->setQObjectPropertyFast(r, o);
executed 8 times by 1 test: e->setQObjectPropertyFast(r, o);
Executed by:
  • tst_qqmllistmodel
8
694 } else {
executed 8 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
8
695 const ListLayout::Role &role = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::VariantMap);-
696 if (role.type == ListLayout::Role::VariantMap)
role.type == L...le::VariantMapDescription
TRUEevaluated 84 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
0-84
697 e->setVariantMapFast(role, o);
executed 84 times by 2 tests: e->setVariantMapFast(role, o);
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
84
698 }
executed 84 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
84
699 } else if (propertyValue->isNullOrUndefined()) {
propertyValue-...lOrUndefined()Description
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
0-6
700 const ListLayout::Role *r = m_layout->getExistingRole(propertyName);-
701 if (r)
rDescription
TRUEnever evaluated
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
0-6
702 e->clearProperty(*r);
never executed: e->clearProperty(*r);
0
703 }
executed 6 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
6
704 }
executed 3832 times by 9 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
3832
705}
executed 2736 times by 9 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
2736
706-
707QVector<std::function<void()>> ListModel::remove(int index, int count)-
708{-
709 QVector<std::function<void()>> toDestroy;-
710 auto layout = m_layout;-
711 for (int i=0 ; i < count ; ++i) {
i < countDescription
TRUEevaluated 6636 times by 15 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
FALSEevaluated 3864 times by 15 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
3864-6636
712 auto element = elements[index+i];-
713 toDestroy.append([element, layout](){-
714 element->destroy(layout);-
715 delete element;-
716 });
executed 6636 times by 15 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
6636
717 }
executed 6636 times by 15 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
6636
718 elements.remove(index, count);-
719 updateCacheIndices(index);-
720 return toDestroy;
executed 3864 times by 15 tests: return toDestroy;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
3864
721}-
722-
723void ListModel::insert(int elementIndex, QV4::Object *object)-
724{-
725 insertElement(elementIndex);-
726 set(elementIndex, object);-
727}
executed 460 times by 5 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickvisualdatamodel
460
728-
729int ListModel::append(QV4::Object *object)-
730{-
731 int elementIndex = appendElement();-
732 set(elementIndex, object);-
733 return elementIndex;
executed 2282 times by 8 tests: return elementIndex;
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
2282
734}-
735-
736int ListModel::setOrCreateProperty(int elementIndex, const QString &key, const QVariant &data)-
737{-
738 int roleIndex = -1;-
739-
740 if (elementIndex >= 0 && elementIndex < elements.count()) {
elementIndex >= 0Description
TRUEevaluated 4502 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
elementIndex <...ements.count()Description
TRUEevaluated 4502 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
FALSEnever evaluated
0-4502
741 ListElement *e = elements[elementIndex];-
742-
743 const ListLayout::Role *r = m_layout->getRoleOrCreate(key, data);-
744 if (r) {
rDescription
TRUEevaluated 4500 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
2-4500
745 roleIndex = e->setVariantProperty(*r, data);-
746-
747 ModelNodeMetaObject *cache = e->objectCache();-
748-
749 if (roleIndex != -1 && cache)
roleIndex != -1Description
TRUEevaluated 4448 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
FALSEevaluated 52 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qquicklistview
  • tst_qquickrepeater
cacheDescription
TRUEevaluated 18 times by 3 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
FALSEevaluated 4430 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
18-4448
750 cache->updateValues(QVector<int>(1, roleIndex));
executed 18 times by 3 tests: cache->updateValues(QVector<int>(1, roleIndex));
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
18
751 }
executed 4500 times by 14 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
4500
752 }
executed 4502 times by 14 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
4502
753-
754 return roleIndex;
executed 4504 times by 14 tests: return roleIndex;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
4504
755}-
756-
757int ListModel::setExistingProperty(int elementIndex, const QString &key, const QV4::Value &data, QV4::ExecutionEngine *eng)-
758{-
759 int roleIndex = -1;-
760-
761 if (elementIndex >= 0 && elementIndex < elements.count()) {
elementIndex >= 0Description
TRUEevaluated 58 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
elementIndex <...ements.count()Description
TRUEevaluated 58 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
0-58
762 ListElement *e = elements[elementIndex];-
763 const ListLayout::Role *r = m_layout->getExistingRole(key);-
764 if (r)
rDescription
TRUEevaluated 58 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
0-58
765 roleIndex = e->setJsProperty(*r, data, eng);
executed 58 times by 2 tests: roleIndex = e->setJsProperty(*r, data, eng);
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
58
766 }
executed 58 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
58
767-
768 return roleIndex;
executed 58 times by 2 tests: return roleIndex;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
58
769}-
770-
771inline char *ListElement::getPropertyMemory(const ListLayout::Role &role)-
772{-
773 ListElement *e = this;-
774 int blockIndex = 0;-
775 while (blockIndex < role.blockIndex) {
blockIndex < role.blockIndexDescription
TRUEevaluated 48 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 28247 times by 15 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
48-28247
776 if (e->next == nullptr) {
e->next == nullptrDescription
TRUEevaluated 10 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 38 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
10-38
777 e->next = new ListElement;-
778 e->next->uid = uid;-
779 }
executed 10 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
10
780 e = e->next;-
781 ++blockIndex;-
782 }
executed 48 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
48
783-
784 char *mem = &e->data[role.blockOffset];-
785 return mem;
executed 28247 times by 15 tests: return mem;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
28247
786}-
787-
788ModelNodeMetaObject *ListElement::objectCache()-
789{-
790 if (!m_objectCache)
!m_objectCacheDescription
TRUEevaluated 8064 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
FALSEevaluated 370 times by 4 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
370-8064
791 return nullptr;
executed 8064 times by 14 tests: return nullptr;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
8064
792 return ModelNodeMetaObject::get(m_objectCache);
executed 370 times by 4 tests: return ModelNodeMetaObject::get(m_objectCache);
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
370
793}-
794-
795StringOrTranslation *ListElement::getStringProperty(const ListLayout::Role &role)-
796{-
797 char *mem = getPropertyMemory(role);-
798 StringOrTranslation *s = reinterpret_cast<StringOrTranslation *>(mem);-
799 return s;
executed 5122 times by 14 tests: return s;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
5122
800}-
801-
802QObject *ListElement::getQObjectProperty(const ListLayout::Role &role)-
803{-
804 char *mem = getPropertyMemory(role);-
805 QPointer<QObject> *o = reinterpret_cast<QPointer<QObject> *>(mem);-
806 return o->data();
never executed: return o->data();
0
807}-
808-
809QVariantMap *ListElement::getVariantMapProperty(const ListLayout::Role &role)-
810{-
811 QVariantMap *map = nullptr;-
812-
813 char *mem = getPropertyMemory(role);-
814 if (isMemoryUsed<QVariantMap>(mem))
isMemoryUsed<QVariantMap>(mem)Description
TRUEevaluated 172 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 244 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
172-244
815 map = reinterpret_cast<QVariantMap *>(mem);
executed 172 times by 2 tests: map = reinterpret_cast<QVariantMap *>(mem);
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
172
816-
817 return map;
executed 416 times by 2 tests: return map;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
416
818}-
819-
820QDateTime *ListElement::getDateTimeProperty(const ListLayout::Role &role)-
821{-
822 QDateTime *dt = nullptr;-
823-
824 char *mem = getPropertyMemory(role);-
825 if (isMemoryUsed<QDateTime>(mem))
isMemoryUsed<QDateTime>(mem)Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEnever evaluated
0-10
826 dt = reinterpret_cast<QDateTime *>(mem);
executed 10 times by 1 test: dt = reinterpret_cast<QDateTime *>(mem);
Executed by:
  • tst_qqmllistmodel
10
827-
828 return dt;
executed 10 times by 1 test: return dt;
Executed by:
  • tst_qqmllistmodel
10
829}-
830-
831QJSValue *ListElement::getFunctionProperty(const ListLayout::Role &role)-
832{-
833 QJSValue *f = nullptr;-
834-
835 char *mem = getPropertyMemory(role);-
836 if (isMemoryUsed<QJSValue>(mem))
isMemoryUsed<QJSValue>(mem)Description
TRUEnever evaluated
FALSEnever evaluated
0
837 f = reinterpret_cast<QJSValue *>(mem);
never executed: f = reinterpret_cast<QJSValue *>(mem);
0
838-
839 return f;
never executed: return f;
0
840}-
841-
842QPointer<QObject> *ListElement::getGuardProperty(const ListLayout::Role &role)-
843{-
844 char *mem = getPropertyMemory(role);-
845-
846 bool existingGuard = false;-
847 for (size_t i=0 ; i < sizeof(QPointer<QObject>) ; ++i) {
i < sizeof(QPointer<QObject>)Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
2-40
848 if (mem[i] != 0) {
mem[i] != 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 32 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
8-32
849 existingGuard = true;-
850 break;
executed 8 times by 1 test: break;
Executed by:
  • tst_qqmllistmodel
8
851 }-
852 }
executed 32 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
32
853-
854 QPointer<QObject> *o = nullptr;-
855-
856 if (existingGuard)
existingGuardDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
2-8
857 o = reinterpret_cast<QPointer<QObject> *>(mem);
executed 8 times by 1 test: o = reinterpret_cast<QPointer<QObject> *>(mem);
Executed by:
  • tst_qqmllistmodel
8
858-
859 return o;
executed 10 times by 1 test: return o;
Executed by:
  • tst_qqmllistmodel
10
860}-
861-
862ListModel *ListElement::getListProperty(const ListLayout::Role &role)-
863{-
864 char *mem = getPropertyMemory(role);-
865 ListModel **value = reinterpret_cast<ListModel **>(mem);-
866 return *value;
executed 664 times by 4 tests: return *value;
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
664
867}-
868-
869QVariant ListElement::getProperty(const ListLayout::Role &role, const QQmlListModel *owner, QV4::ExecutionEngine *eng)-
870{-
871 char *mem = getPropertyMemory(role);-
872-
873 QVariant data;-
874-
875 switch (role.type) {-
876 case ListLayout::Role::Number:
executed 1848 times by 4 tests: case ListLayout::Role::Number:
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
1848
877 {-
878 double *value = reinterpret_cast<double *>(mem);-
879 data = *value;-
880 }-
881 break;
executed 1848 times by 4 tests: break;
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
1848
882 case ListLayout::Role::String:
executed 10271 times by 12 tests: case ListLayout::Role::String:
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickvisualdatamodel
10271
883 {-
884 StringOrTranslation *value = reinterpret_cast<StringOrTranslation *>(mem);-
885 if (value->isSet())
value->isSet()Description
TRUEevaluated 10271 times by 12 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickvisualdatamodel
FALSEnever evaluated
0-10271
886 data = value->toString(owner);
executed 10271 times by 12 tests: data = value->toString(owner);
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickvisualdatamodel
10271
887 }-
888 break;
executed 10271 times by 12 tests: break;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickvisualdatamodel
10271
889 case ListLayout::Role::Bool:
executed 122 times by 2 tests: case ListLayout::Role::Bool:
Executed by:
  • tst_qqmllistmodel
  • tst_qquicklistview
122
890 {-
891 bool *value = reinterpret_cast<bool *>(mem);-
892 data = *value;-
893 }-
894 break;
executed 122 times by 2 tests: break;
Executed by:
  • tst_qqmllistmodel
  • tst_qquicklistview
122
895 case ListLayout::Role::List:
executed 202 times by 4 tests: case ListLayout::Role::List:
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
202
896 {-
897 ListModel **value = reinterpret_cast<ListModel **>(mem);-
898 ListModel *model = *value;-
899-
900 if (model) {
modelDescription
TRUEevaluated 202 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
FALSEnever evaluated
0-202
901 if (model->m_modelCache == nullptr) {
model->m_modelCache == nullptrDescription
TRUEevaluated 138 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
FALSEevaluated 64 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
64-138
902 model->m_modelCache = new QQmlListModel(owner, model, eng);-
903 QQmlEngine::setContextForObject(model->m_modelCache, QQmlEngine::contextForObject(owner));-
904 }
executed 138 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
138
905-
906 QObject *object = model->m_modelCache;-
907 data = QVariant::fromValue(object);-
908 }
executed 202 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
202
909 }-
910 break;
executed 202 times by 4 tests: break;
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
202
911 case ListLayout::Role::QObject:
executed 4 times by 1 test: case ListLayout::Role::QObject:
Executed by:
  • tst_qqmllistmodel
4
912 {-
913 QPointer<QObject> *guard = reinterpret_cast<QPointer<QObject> *>(mem);-
914 QObject *object = guard->data();-
915 if (object)
objectDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEnever evaluated
0-4
916 data = QVariant::fromValue(object);
executed 4 times by 1 test: data = QVariant::fromValue(object);
Executed by:
  • tst_qqmllistmodel
4
917 }-
918 break;
executed 4 times by 1 test: break;
Executed by:
  • tst_qqmllistmodel
4
919 case ListLayout::Role::VariantMap:
executed 24 times by 2 tests: case ListLayout::Role::VariantMap:
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
24
920 {-
921 if (isMemoryUsed<QVariantMap>(mem)) {
isMemoryUsed<QVariantMap>(mem)Description
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
0-24
922 QVariantMap *map = reinterpret_cast<QVariantMap *>(mem);-
923 data = *map;-
924 }
executed 24 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
24
925 }-
926 break;
executed 24 times by 2 tests: break;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
24
927 case ListLayout::Role::DateTime:
executed 10 times by 1 test: case ListLayout::Role::DateTime:
Executed by:
  • tst_qqmllistmodel
10
928 {-
929 if (isMemoryUsed<QDateTime>(mem)) {
isMemoryUsed<QDateTime>(mem)Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEnever evaluated
0-10
930 QDateTime *dt = reinterpret_cast<QDateTime *>(mem);-
931 data = *dt;-
932 }
executed 10 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
10
933 }-
934 break;
executed 10 times by 1 test: break;
Executed by:
  • tst_qqmllistmodel
10
935 case ListLayout::Role::Function:
never executed: case ListLayout::Role::Function:
0
936 {-
937 if (isMemoryUsed<QJSValue>(mem)) {
isMemoryUsed<QJSValue>(mem)Description
TRUEnever evaluated
FALSEnever evaluated
0
938 QJSValue *func = reinterpret_cast<QJSValue *>(mem);-
939 data = QVariant::fromValue(*func);-
940 }
never executed: end of block
0
941 }-
942 break;
never executed: break;
0
943 default:
never executed: default:
0
944 break;
never executed: break;
0
945 }-
946-
947 return data;
executed 12481 times by 13 tests: return data;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
12481
948}-
949-
950int ListElement::setStringProperty(const ListLayout::Role &role, const QString &s)-
951{-
952 int roleIndex = -1;-
953-
954 if (role.type == ListLayout::Role::String) {
role.type == L...::Role::StringDescription
TRUEevaluated 3956 times by 12 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
FALSEnever evaluated
0-3956
955 char *mem = getPropertyMemory(role);-
956 StringOrTranslation *c = reinterpret_cast<StringOrTranslation *>(mem);-
957 bool changed;-
958 if (!c->isSet() || c->isTranslation())
!c->isSet()Description
TRUEevaluated 3950 times by 12 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
c->isTranslation()Description
TRUEnever evaluated
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
0-3950
959 changed = true;
executed 3950 times by 12 tests: changed = true;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
3950
960 else-
961 changed = c->asString().compare(s) != 0;
executed 6 times by 2 tests: changed = c->asString().compare(s) != 0;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
6
962 c->setString(s);-
963 if (changed)
changedDescription
TRUEevaluated 3956 times by 12 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
FALSEnever evaluated
0-3956
964 roleIndex = role.index;
executed 3956 times by 12 tests: roleIndex = role.index;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
3956
965 }
executed 3956 times by 12 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
3956
966-
967 return roleIndex;
executed 3956 times by 12 tests: return roleIndex;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
3956
968}-
969-
970int ListElement::setDoubleProperty(const ListLayout::Role &role, double d)-
971{-
972 int roleIndex = -1;-
973-
974 if (role.type == ListLayout::Role::Number) {
role.type == L...::Role::NumberDescription
TRUEevaluated 1446 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
6-1446
975 char *mem = getPropertyMemory(role);-
976 double *value = reinterpret_cast<double *>(mem);-
977 bool changed = *value != d;-
978 *value = d;-
979 if (changed)
changedDescription
TRUEevaluated 1210 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
FALSEevaluated 236 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
236-1210
980 roleIndex = role.index;
executed 1210 times by 5 tests: roleIndex = role.index;
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
1210
981 }
executed 1446 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
1446
982-
983 return roleIndex;
executed 1452 times by 5 tests: return roleIndex;
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
1452
984}-
985-
986int ListElement::setBoolProperty(const ListLayout::Role &role, bool b)-
987{-
988 int roleIndex = -1;-
989-
990 if (role.type == ListLayout::Role::Bool) {
role.type == L...ut::Role::BoolDescription
TRUEevaluated 70 times by 3 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qquicklistview
  • tst_qtqmlmodules
FALSEnever evaluated
0-70
991 char *mem = getPropertyMemory(role);-
992 bool *value = reinterpret_cast<bool *>(mem);-
993 bool changed = *value != b;-
994 *value = b;-
995 if (changed)
changedDescription
TRUEevaluated 40 times by 3 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qquicklistview
  • tst_qtqmlmodules
FALSEevaluated 30 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
30-40
996 roleIndex = role.index;
executed 40 times by 3 tests: roleIndex = role.index;
Executed by:
  • tst_qqmllistmodel
  • tst_qquicklistview
  • tst_qtqmlmodules
40
997 }
executed 70 times by 3 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qquicklistview
  • tst_qtqmlmodules
70
998-
999 return roleIndex;
executed 70 times by 3 tests: return roleIndex;
Executed by:
  • tst_qqmllistmodel
  • tst_qquicklistview
  • tst_qtqmlmodules
70
1000}-
1001-
1002int ListElement::setListProperty(const ListLayout::Role &role, ListModel *m)-
1003{-
1004 int roleIndex = -1;-
1005-
1006 if (role.type == ListLayout::Role::List) {
role.type == L...ut::Role::ListDescription
TRUEevaluated 68 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
0-68
1007 char *mem = getPropertyMemory(role);-
1008 ListModel **value = reinterpret_cast<ListModel **>(mem);-
1009 if (*value && *value != m) {
*valueDescription
TRUEevaluated 22 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 46 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
*value != mDescription
TRUEevaluated 22 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
0-46
1010 (*value)->destroy();-
1011 delete *value;-
1012 }
executed 22 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
22
1013 *value = m;-
1014 roleIndex = role.index;-
1015 }
executed 68 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
68
1016-
1017 return roleIndex;
executed 68 times by 3 tests: return roleIndex;
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
68
1018}-
1019-
1020int ListElement::setQObjectProperty(const ListLayout::Role &role, QObject *o)-
1021{-
1022 int roleIndex = -1;-
1023-
1024 if (role.type == ListLayout::Role::QObject) {
role.type == L...:Role::QObjectDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEnever evaluated
0-2
1025 char *mem = getPropertyMemory(role);-
1026 QPointer<QObject> *g = reinterpret_cast<QPointer<QObject> *>(mem);-
1027 bool existingGuard = false;-
1028 for (size_t i=0 ; i < sizeof(QPointer<QObject>) ; ++i) {
i < sizeof(QPointer<QObject>)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEnever evaluated
0-2
1029 if (mem[i] != 0) {
mem[i] != 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEnever evaluated
0-2
1030 existingGuard = true;-
1031 break;
executed 2 times by 1 test: break;
Executed by:
  • tst_qqmllistmodel
2
1032 }-
1033 }
never executed: end of block
0
1034 bool changed;-
1035 if (existingGuard) {
existingGuardDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEnever evaluated
0-2
1036 changed = g->data() != o;-
1037 g->~QPointer();-
1038 } else {
executed 2 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
2
1039 changed = true;-
1040 }
never executed: end of block
0
1041 new (mem) QPointer<QObject>(o);-
1042 if (changed)
changedDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEnever evaluated
0-2
1043 roleIndex = role.index;
executed 2 times by 1 test: roleIndex = role.index;
Executed by:
  • tst_qqmllistmodel
2
1044 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
2
1045-
1046 return roleIndex;
executed 2 times by 1 test: return roleIndex;
Executed by:
  • tst_qqmllistmodel
2
1047}-
1048-
1049int ListElement::setVariantMapProperty(const ListLayout::Role &role, QV4::Object *o)-
1050{-
1051 int roleIndex = -1;-
1052-
1053 if (role.type == ListLayout::Role::VariantMap) {
role.type == L...le::VariantMapDescription
TRUEevaluated 18 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
0-18
1054 char *mem = getPropertyMemory(role);-
1055 if (isMemoryUsed<QVariantMap>(mem)) {
isMemoryUsed<QVariantMap>(mem)Description
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
6-12
1056 QVariantMap *map = reinterpret_cast<QVariantMap *>(mem);-
1057 map->~QMap();-
1058 }
executed 12 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12
1059 new (mem) QVariantMap(o->engine()->variantMapFromJS(o));-
1060 roleIndex = role.index;-
1061 }
executed 18 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
18
1062-
1063 return roleIndex;
executed 18 times by 2 tests: return roleIndex;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
18
1064}-
1065-
1066int ListElement::setVariantMapProperty(const ListLayout::Role &role, QVariantMap *m)-
1067{-
1068 int roleIndex = -1;-
1069-
1070 if (role.type == ListLayout::Role::VariantMap) {
role.type == L...le::VariantMapDescription
TRUEevaluated 106 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
0-106
1071 char *mem = getPropertyMemory(role);-
1072 if (isMemoryUsed<QVariantMap>(mem)) {
isMemoryUsed<QVariantMap>(mem)Description
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 94 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
12-94
1073 QVariantMap *map = reinterpret_cast<QVariantMap *>(mem);-
1074 if (m && map->isSharedWith(*m))
mDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
map->isSharedWith(*m)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
0-6
1075 return roleIndex;
executed 6 times by 1 test: return roleIndex;
Executed by:
  • tst_qqmllistmodelworkerscript
6
1076 map->~QMap();-
1077 } else if (!m) {
executed 6 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
!mDescription
TRUEevaluated 56 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 38 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
6-56
1078 return roleIndex;
executed 56 times by 1 test: return roleIndex;
Executed by:
  • tst_qqmllistmodelworkerscript
56
1079 }-
1080 if (m)
mDescription
TRUEevaluated 38 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
6-38
1081 new (mem) QVariantMap(*m);
executed 38 times by 1 test: new (mem) QVariantMap(*m);
Executed by:
  • tst_qqmllistmodelworkerscript
38
1082 else-
1083 new (mem) QVariantMap;
executed 6 times by 2 tests: new (mem) QVariantMap;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
6
1084 roleIndex = role.index;-
1085 }
executed 44 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
44
1086-
1087 return roleIndex;
executed 44 times by 2 tests: return roleIndex;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
44
1088}-
1089-
1090int ListElement::setDateTimeProperty(const ListLayout::Role &role, const QDateTime &dt)-
1091{-
1092 int roleIndex = -1;-
1093-
1094 if (role.type == ListLayout::Role::DateTime) {
role.type == L...Role::DateTimeDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEnever evaluated
0-8
1095 char *mem = getPropertyMemory(role);-
1096 if (isMemoryUsed<QDateTime>(mem)) {
isMemoryUsed<QDateTime>(mem)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEnever evaluated
0-8
1097 QDateTime *dt = reinterpret_cast<QDateTime *>(mem);-
1098 dt->~QDateTime();-
1099 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
8
1100 new (mem) QDateTime(dt);-
1101 roleIndex = role.index;-
1102 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
8
1103-
1104 return roleIndex;
executed 8 times by 1 test: return roleIndex;
Executed by:
  • tst_qqmllistmodel
8
1105}-
1106-
1107int ListElement::setFunctionProperty(const ListLayout::Role &role, const QJSValue &f)-
1108{-
1109 int roleIndex = -1;-
1110-
1111 if (role.type == ListLayout::Role::Function) {
role.type == L...Role::FunctionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1112 char *mem = getPropertyMemory(role);-
1113 if (isMemoryUsed<QJSValue>(mem)) {
isMemoryUsed<QJSValue>(mem)Description
TRUEnever evaluated
FALSEnever evaluated
0
1114 QJSValue *f = reinterpret_cast<QJSValue *>(mem);-
1115 f->~QJSValue();-
1116 }
never executed: end of block
0
1117 new (mem) QJSValue(f);-
1118 roleIndex = role.index;-
1119 }
never executed: end of block
0
1120-
1121 return roleIndex;
never executed: return roleIndex;
0
1122}-
1123-
1124int ListElement::setTranslationProperty(const ListLayout::Role &role, const QV4::CompiledData::Binding *b)-
1125{-
1126 int roleIndex = -1;-
1127-
1128 if (role.type == ListLayout::Role::String) {
role.type == L...::Role::StringDescription
TRUEevaluated 8 times by 3 tests
Evaluated by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmltranslation
FALSEnever evaluated
0-8
1129 char *mem = getPropertyMemory(role);-
1130 StringOrTranslation *s = reinterpret_cast<StringOrTranslation *>(mem);-
1131 s->setTranslation(b);-
1132 roleIndex = role.index;-
1133 }
executed 8 times by 3 tests: end of block
Executed by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmltranslation
8
1134-
1135 return roleIndex;
executed 8 times by 3 tests: return roleIndex;
Executed by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmltranslation
8
1136}-
1137-
1138-
1139void ListElement::setStringPropertyFast(const ListLayout::Role &role, const QString &s)-
1140{-
1141 char *mem = getPropertyMemory(role);-
1142 new (mem) StringOrTranslation(s);-
1143}
executed 1170 times by 8 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickvisualdatamodel
1170
1144-
1145void ListElement::setDoublePropertyFast(const ListLayout::Role &role, double d)-
1146{-
1147 char *mem = getPropertyMemory(role);-
1148 double *value = new (mem) double;-
1149 *value = d;-
1150}
executed 2334 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
2334
1151-
1152void ListElement::setBoolPropertyFast(const ListLayout::Role &role, bool b)-
1153{-
1154 char *mem = getPropertyMemory(role);-
1155 bool *value = new (mem) bool;-
1156 *value = b;-
1157}
executed 88 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qquicklistview
88
1158-
1159void ListElement::setQObjectPropertyFast(const ListLayout::Role &role, QObject *o)-
1160{-
1161 char *mem = getPropertyMemory(role);-
1162 new (mem) QPointer<QObject>(o);-
1163}
executed 8 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
8
1164-
1165void ListElement::setListPropertyFast(const ListLayout::Role &role, ListModel *m)-
1166{-
1167 char *mem = getPropertyMemory(role);-
1168 ListModel **value = new (mem) ListModel *;-
1169 *value = m;-
1170}
executed 168 times by 3 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
168
1171-
1172void ListElement::setVariantMapFast(const ListLayout::Role &role, QV4::Object *o)-
1173{-
1174 char *mem = getPropertyMemory(role);-
1175 QVariantMap *map = new (mem) QVariantMap;-
1176 *map = o->engine()->variantMapFromJS(o);-
1177}
executed 84 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
84
1178-
1179void ListElement::setDateTimePropertyFast(const ListLayout::Role &role, const QDateTime &dt)-
1180{-
1181 char *mem = getPropertyMemory(role);-
1182 new (mem) QDateTime(dt);-
1183}
executed 10 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
10
1184-
1185void ListElement::setFunctionPropertyFast(const ListLayout::Role &role, const QJSValue &f)-
1186{-
1187 char *mem = getPropertyMemory(role);-
1188 new (mem) QJSValue(f);-
1189}
never executed: end of block
0
1190-
1191void ListElement::clearProperty(const ListLayout::Role &role)-
1192{-
1193 switch (role.type) {-
1194 case ListLayout::Role::String:
never executed: case ListLayout::Role::String:
0
1195 setStringProperty(role, QString());-
1196 break;
never executed: break;
0
1197 case ListLayout::Role::Number:
executed 6 times by 2 tests: case ListLayout::Role::Number:
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
6
1198 setDoubleProperty(role, 0.0);-
1199 break;
executed 6 times by 2 tests: break;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
6
1200 case ListLayout::Role::Bool:
never executed: case ListLayout::Role::Bool:
0
1201 setBoolProperty(role, false);-
1202 break;
never executed: break;
0
1203 case ListLayout::Role::List:
never executed: case ListLayout::Role::List:
0
1204 setListProperty(role, nullptr);-
1205 break;
never executed: break;
0
1206 case ListLayout::Role::QObject:
never executed: case ListLayout::Role::QObject:
0
1207 setQObjectProperty(role, nullptr);-
1208 break;
never executed: break;
0
1209 case ListLayout::Role::DateTime:
executed 2 times by 1 test: case ListLayout::Role::DateTime:
Executed by:
  • tst_qqmllistmodel
2
1210 setDateTimeProperty(role, QDateTime());-
1211 break;
executed 2 times by 1 test: break;
Executed by:
  • tst_qqmllistmodel
2
1212 case ListLayout::Role::VariantMap:
executed 6 times by 2 tests: case ListLayout::Role::VariantMap:
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
6
1213 setVariantMapProperty(role, (QVariantMap *)nullptr);-
1214 break;
executed 6 times by 2 tests: break;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
6
1215 case ListLayout::Role::Function:
never executed: case ListLayout::Role::Function:
0
1216 setFunctionProperty(role, QJSValue());-
1217 break;
never executed: break;
0
1218 default:
never executed: default:
0
1219 break;
never executed: break;
0
1220 }-
1221}-
1222-
1223ListElement::ListElement()-
1224{-
1225 m_objectCache = nullptr;-
1226 uid = uidCounter.fetchAndAddOrdered(1);-
1227 next = nullptr;-
1228 memset(data, 0, sizeof(data));-
1229}
executed 6030 times by 15 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
6030
1230-
1231ListElement::ListElement(int existingUid)-
1232{-
1233 m_objectCache = nullptr;-
1234 uid = existingUid;-
1235 next = nullptr;-
1236 memset(data, 0, sizeof(data));-
1237}
executed 634 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
634
1238-
1239ListElement::~ListElement()-
1240{-
1241 delete next;-
1242}
executed 6650 times by 15 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
6650
1243-
1244QVector<int> ListElement::sync(ListElement *src, ListLayout *srcLayout, ListElement *target, ListLayout *targetLayout)-
1245{-
1246 QVector<int> changedRoles;-
1247 for (int i=0 ; i < srcLayout->roleCount() ; ++i) {
i < srcLayout->roleCount()Description
TRUEevaluated 1104 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 694 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
694-1104
1248 const ListLayout::Role &srcRole = srcLayout->getExistingRole(i);-
1249 const ListLayout::Role &targetRole = targetLayout->getExistingRole(i);-
1250-
1251 int roleIndex = -1;-
1252 switch (srcRole.type) {-
1253 case ListLayout::Role::List:
executed 106 times by 1 test: case ListLayout::Role::List:
Executed by:
  • tst_qqmllistmodelworkerscript
106
1254 {-
1255 ListModel *srcSubModel = src->getListProperty(srcRole);-
1256 ListModel *targetSubModel = target->getListProperty(targetRole);-
1257-
1258 if (srcSubModel) {
srcSubModelDescription
TRUEevaluated 56 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 50 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
50-56
1259 if (targetSubModel == nullptr) {
targetSubModel == nullptrDescription
TRUEevaluated 42 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
14-42
1260 targetSubModel = new ListModel(targetRole.subLayout, nullptr);-
1261 target->setListPropertyFast(targetRole, targetSubModel);-
1262 }
executed 42 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
42
1263 if (ListModel::sync(srcSubModel, targetSubModel))
ListModel::syn...argetSubModel)Description
TRUEevaluated 42 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
14-42
1264 roleIndex = targetRole.index;
executed 42 times by 1 test: roleIndex = targetRole.index;
Executed by:
  • tst_qqmllistmodelworkerscript
42
1265 }
executed 56 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
56
1266 }-
1267 break;
executed 106 times by 1 test: break;
Executed by:
  • tst_qqmllistmodelworkerscript
106
1268 case ListLayout::Role::QObject:
never executed: case ListLayout::Role::QObject:
0
1269 {-
1270 QObject *object = src->getQObjectProperty(srcRole);-
1271 roleIndex = target->setQObjectProperty(targetRole, object);-
1272 }-
1273 break;
never executed: break;
0
1274 case ListLayout::Role::String:
executed 8 times by 1 test: case ListLayout::Role::String:
Executed by:
  • tst_qqmllistmodelworkerscript
8
1275 case ListLayout::Role::Number:
executed 890 times by 1 test: case ListLayout::Role::Number:
Executed by:
  • tst_qqmllistmodelworkerscript
890
1276 case ListLayout::Role::Bool:
never executed: case ListLayout::Role::Bool:
0
1277 case ListLayout::Role::DateTime:
never executed: case ListLayout::Role::DateTime:
0
1278 case ListLayout::Role::Function:
never executed: case ListLayout::Role::Function:
0
1279 {-
1280 QVariant v = src->getProperty(srcRole, nullptr, nullptr);-
1281 roleIndex = target->setVariantProperty(targetRole, v);-
1282 }-
1283 break;
executed 898 times by 1 test: break;
Executed by:
  • tst_qqmllistmodelworkerscript
898
1284 case ListLayout::Role::VariantMap:
executed 100 times by 1 test: case ListLayout::Role::VariantMap:
Executed by:
  • tst_qqmllistmodelworkerscript
100
1285 {-
1286 QVariantMap *map = src->getVariantMapProperty(srcRole);-
1287 roleIndex = target->setVariantMapProperty(targetRole, map);-
1288 }-
1289 break;
executed 100 times by 1 test: break;
Executed by:
  • tst_qqmllistmodelworkerscript
100
1290 default:
never executed: default:
0
1291 break;
never executed: break;
0
1292 }-
1293 if (roleIndex >= 0)
roleIndex >= 0Description
TRUEevaluated 766 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 338 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
338-766
1294 changedRoles << roleIndex;
executed 766 times by 1 test: changedRoles << roleIndex;
Executed by:
  • tst_qqmllistmodelworkerscript
766
1295 }
executed 1104 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
1104
1296-
1297 return changedRoles;
executed 694 times by 1 test: return changedRoles;
Executed by:
  • tst_qqmllistmodelworkerscript
694
1298}-
1299-
1300void ListElement::destroy(ListLayout *layout)-
1301{-
1302 if (layout) {
layoutDescription
TRUEevaluated 6640 times by 15 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
FALSEevaluated 10 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
10-6640
1303 for (int i=0 ; i < layout->roleCount() ; ++i) {
i < layout->roleCount()Description
TRUEevaluated 9940 times by 15 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
FALSEevaluated 6640 times by 15 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
6640-9940
1304 const ListLayout::Role &r = layout->getExistingRole(i);-
1305-
1306 switch (r.type) {-
1307 case ListLayout::Role::String:
executed 5122 times by 14 tests: case ListLayout::Role::String:
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
5122
1308 {-
1309 StringOrTranslation *string = getStringProperty(r);-
1310 if (string)
stringDescription
TRUEevaluated 5122 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
FALSEnever evaluated
0-5122
1311 string->~StringOrTranslation();
executed 5122 times by 14 tests: string->~StringOrTranslation();
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
5122
1312 }-
1313 break;
executed 5122 times by 14 tests: break;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
5122
1314 case ListLayout::Role::List:
executed 390 times by 4 tests: case ListLayout::Role::List:
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
390
1315 {-
1316 ListModel *model = getListProperty(r);-
1317 if (model) {
modelDescription
TRUEevaluated 214 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
FALSEevaluated 176 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
176-214
1318 model->destroy();-
1319 delete model;-
1320 }
executed 214 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
214
1321 }-
1322 break;
executed 390 times by 4 tests: break;
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
390
1323 case ListLayout::Role::QObject:
executed 10 times by 1 test: case ListLayout::Role::QObject:
Executed by:
  • tst_qqmllistmodel
10
1324 {-
1325 QPointer<QObject> *guard = getGuardProperty(r);-
1326 if (guard)
guardDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
2-8
1327 guard->~QPointer();
executed 8 times by 1 test: guard->~QPointer();
Executed by:
  • tst_qqmllistmodel
8
1328 }-
1329 break;
executed 10 times by 1 test: break;
Executed by:
  • tst_qqmllistmodel
10
1330 case ListLayout::Role::VariantMap:
executed 316 times by 2 tests: case ListLayout::Role::VariantMap:
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
316
1331 {-
1332 QVariantMap *map = getVariantMapProperty(r);-
1333 if (map)
mapDescription
TRUEevaluated 128 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 188 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
128-188
1334 map->~QMap();
executed 128 times by 2 tests: map->~QMap();
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
128
1335 }-
1336 break;
executed 316 times by 2 tests: break;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
316
1337 case ListLayout::Role::DateTime:
executed 10 times by 1 test: case ListLayout::Role::DateTime:
Executed by:
  • tst_qqmllistmodel
10
1338 {-
1339 QDateTime *dt = getDateTimeProperty(r);-
1340 if (dt)
dtDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEnever evaluated
0-10
1341 dt->~QDateTime();
executed 10 times by 1 test: dt->~QDateTime();
Executed by:
  • tst_qqmllistmodel
10
1342 }-
1343 break;
executed 10 times by 1 test: break;
Executed by:
  • tst_qqmllistmodel
10
1344 case ListLayout::Role::Function:
never executed: case ListLayout::Role::Function:
0
1345 {-
1346 QJSValue *f = getFunctionProperty(r);-
1347 if (f)
fDescription
TRUEnever evaluated
FALSEnever evaluated
0
1348 f->~QJSValue();
never executed: f->~QJSValue();
0
1349 }-
1350 break;
never executed: break;
0
1351 default:
executed 4092 times by 6 tests: default:
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qtqmlmodules
4092
1352 // other types don't need explicit cleanup.-
1353 break;
executed 4092 times by 6 tests: break;
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qtqmlmodules
4092
1354 }-
1355 }-
1356-
1357 delete m_objectCache;-
1358 }
executed 6640 times by 15 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
6640
1359-
1360 if (next)
nextDescription
TRUEevaluated 10 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 6640 times by 15 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
10-6640
1361 next->destroy(nullptr);
executed 10 times by 2 tests: next->destroy(nullptr);
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
10
1362 uid = -1;-
1363}
executed 6650 times by 15 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
6650
1364-
1365int ListElement::setVariantProperty(const ListLayout::Role &role, const QVariant &d)-
1366{-
1367 int roleIndex = -1;-
1368-
1369 switch (role.type) {-
1370 case ListLayout::Role::Number:
executed 1338 times by 5 tests: case ListLayout::Role::Number:
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
1338
1371 roleIndex = setDoubleProperty(role, d.toDouble());-
1372 break;
executed 1338 times by 5 tests: break;
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
1338
1373 case ListLayout::Role::String:
executed 3958 times by 13 tests: case ListLayout::Role::String:
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
3958
1374 if (d.userType() == qMetaTypeId<const QV4::CompiledData::Binding *>())
d.userType() =...::Binding *>()Description
TRUEevaluated 8 times by 3 tests
Evaluated by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmltranslation
FALSEevaluated 3950 times by 12 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
8-3950
1375 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:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmltranslation
8
1376 else-
1377 roleIndex = setStringProperty(role, d.toString());
executed 3950 times by 12 tests: roleIndex = setStringProperty(role, d.toString());
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
3950
1378 break;
executed 3958 times by 13 tests: break;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
3958
1379 case ListLayout::Role::Bool:
executed 66 times by 3 tests: case ListLayout::Role::Bool:
Executed by:
  • tst_qqmllistmodel
  • tst_qquicklistview
  • tst_qtqmlmodules
66
1380 roleIndex = setBoolProperty(role, d.toBool());-
1381 break;
executed 66 times by 3 tests: break;
Executed by:
  • tst_qqmllistmodel
  • tst_qquicklistview
  • tst_qtqmlmodules
66
1382 case ListLayout::Role::List:
executed 34 times by 2 tests: case ListLayout::Role::List:
Executed by:
  • tst_examples
  • tst_qqmllistmodel
34
1383 roleIndex = setListProperty(role, d.value<ListModel *>());-
1384 break;
executed 34 times by 2 tests: break;
Executed by:
  • tst_examples
  • tst_qqmllistmodel
34
1385 case ListLayout::Role::VariantMap: {
never executed: case ListLayout::Role::VariantMap:
0
1386 QVariantMap map = d.toMap();-
1387 roleIndex = setVariantMapProperty(role, &map);-
1388 }-
1389 break;
never executed: break;
0
1390 case ListLayout::Role::DateTime:
executed 2 times by 1 test: case ListLayout::Role::DateTime:
Executed by:
  • tst_qqmllistmodel
2
1391 roleIndex = setDateTimeProperty(role, d.toDateTime());-
1392 break;
executed 2 times by 1 test: break;
Executed by:
  • tst_qqmllistmodel
2
1393 case ListLayout::Role::Function:
never executed: case ListLayout::Role::Function:
0
1394 roleIndex = setFunctionProperty(role, d.value<QJSValue>());-
1395 break;
never executed: break;
0
1396 default:
never executed: default:
0
1397 break;
never executed: break;
0
1398 }-
1399-
1400 return roleIndex;
executed 5398 times by 14 tests: return roleIndex;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
5398
1401}-
1402-
1403int ListElement::setJsProperty(const ListLayout::Role &role, const QV4::Value &d, QV4::ExecutionEngine *eng)-
1404{-
1405 // Check if this key exists yet-
1406 int roleIndex = -1;-
1407-
1408 QV4::Scope scope(eng);-
1409-
1410 // Add the value now-
1411 if (d.isString()) {
d.isString()Description
TRUEnever evaluated
FALSEevaluated 58 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
0-58
1412 QString qstr = d.toQString();-
1413 roleIndex = setStringProperty(role, qstr);-
1414 } else if (d.isNumber()) {
never executed: end of block
d.isNumber()Description
TRUEevaluated 40 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 18 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
0-40
1415 roleIndex = setDoubleProperty(role, d.asDouble());-
1416 } else if (d.as<QV4::ArrayObject>()) {
executed 40 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
d.as<QV4::ArrayObject>()Description
TRUEevaluated 14 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
4-40
1417 QV4::ScopedArrayObject a(scope, d);-
1418 if (role.type == ListLayout::Role::List) {
role.type == L...ut::Role::ListDescription
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
2-12
1419 QV4::Scope scope(a->engine());-
1420 QV4::ScopedObject o(scope);-
1421-
1422 ListModel *subModel = new ListModel(role.subLayout, nullptr);-
1423 int arrayLength = a->getLength();-
1424 for (int j=0 ; j < arrayLength ; ++j) {
j < arrayLengthDescription
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12-24
1425 o = a->get(j);-
1426 subModel->append(o);-
1427 }
executed 24 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
24
1428 roleIndex = setListProperty(role, subModel);-
1429 } else {
executed 12 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12
1430 qmlWarning(nullptr) << QStringLiteral("Can't assign to existing role '%1' of different type [%2 -> %3]").arg(role.name).arg(roleTypeName(role.type)).arg(roleTypeName(ListLayout::Role::List));
executed 2 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qqmllistmodel
2
1431 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
2
1432 } else if (d.isBoolean()) {
d.isBoolean()Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
0-4
1433 roleIndex = setBoolProperty(role, d.booleanValue());-
1434 } else if (d.as<QV4::DateObject>()) {
never executed: end of block
d.as<QV4::DateObject>()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
0-2
1435 QV4::Scoped<QV4::DateObject> dd(scope, d);-
1436 QDateTime dt = dd->toQDateTime();-
1437 roleIndex = setDateTimeProperty(role, dt);-
1438 } else if (d.as<QV4::FunctionObject>()) {
executed 2 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
d.as<QV4::FunctionObject>()Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
0-2
1439 QV4::ScopedFunctionObject f(scope, d);-
1440 QJSValue jsv;-
1441 QJSValuePrivate::setValue(&jsv, eng, f);-
1442 roleIndex = setFunctionProperty(role, jsv);-
1443 } else if (d.isObject()) {
never executed: end of block
d.isObject()Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
0-2
1444 QV4::ScopedObject o(scope, d);-
1445 QV4::QObjectWrapper *wrapper = o->as<QV4::QObjectWrapper>();-
1446 if (role.type == ListLayout::Role::QObject && wrapper) {
role.type == L...:Role::QObjectDescription
TRUEnever evaluated
FALSEnever evaluated
wrapperDescription
TRUEnever evaluated
FALSEnever evaluated
0
1447 QObject *o = wrapper->object();-
1448 roleIndex = setQObjectProperty(role, o);-
1449 } else if (role.type == ListLayout::Role::VariantMap) {
never executed: end of block
role.type == L...le::VariantMapDescription
TRUEnever evaluated
FALSEnever evaluated
0
1450 roleIndex = setVariantMapProperty(role, o);-
1451 }
never executed: end of block
0
1452 } else if (d.isNullOrUndefined()) {
never executed: end of block
d.isNullOrUndefined()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEnever evaluated
0-2
1453 clearProperty(role);-
1454 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
2
1455-
1456 return roleIndex;
executed 58 times by 2 tests: return roleIndex;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
58
1457}-
1458-
1459ModelNodeMetaObject::ModelNodeMetaObject(QObject *object, QQmlListModel *model, int elementIndex)-
1460: QQmlOpenMetaObject(object), m_enabled(false), m_model(model), m_elementIndex(elementIndex), m_initialized(false)-
1461{}
executed 660 times by 8 tests: end of block
Executed by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
660
1462-
1463void ModelNodeMetaObject::initialize()-
1464{-
1465 const int roleCount = m_model->m_listModel->roleCount();-
1466 QVector<QByteArray> properties;-
1467 properties.reserve(roleCount);-
1468 for (int i = 0 ; i < roleCount ; ++i) {
i < roleCountDescription
TRUEevaluated 104 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 36 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
36-104
1469 const ListLayout::Role &role = m_model->m_listModel->getExistingRole(i);-
1470 QByteArray name = role.name.toUtf8();-
1471 properties << name;-
1472 }
executed 104 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
104
1473 type()->createProperties(properties);-
1474 updateValues();-
1475 m_enabled = true;-
1476}
executed 36 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
36
1477-
1478ModelNodeMetaObject::~ModelNodeMetaObject()-
1479{-
1480}-
1481-
1482QAbstractDynamicMetaObject *ModelNodeMetaObject::toDynamicMetaObject(QObject *object)-
1483{-
1484 if (!m_initialized) {
!m_initializedDescription
TRUEevaluated 36 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 412 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
36-412
1485 m_initialized = true;-
1486 initialize();-
1487 }
executed 36 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
36
1488 return QQmlOpenMetaObject::toDynamicMetaObject(object);
executed 448 times by 1 test: return QQmlOpenMetaObject::toDynamicMetaObject(object);
Executed by:
  • tst_qqmllistmodel
448
1489}-
1490-
1491ModelNodeMetaObject *ModelNodeMetaObject::get(QObject *obj)-
1492{-
1493 QObjectPrivate *op = QObjectPrivate::get(obj);-
1494 return static_cast<ModelNodeMetaObject*>(op->metaObject);
executed 428 times by 4 tests: return static_cast<ModelNodeMetaObject*>(op->metaObject);
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
428
1495}-
1496-
1497void ModelNodeMetaObject::updateValues()-
1498{-
1499 const int roleCount = m_model->m_listModel->roleCount();-
1500 if (!m_initialized) {
!m_initializedDescription
TRUEnever evaluated
FALSEevaluated 36 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
0-36
1501 if (roleCount) {
roleCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1502 Q_ALLOCA_VAR(int, changedRoles, roleCount * sizeof(int));-
1503 for (int i = 0; i < roleCount; ++i)
i < roleCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1504 changedRoles[i] = i;
never executed: changedRoles[i] = i;
0
1505 emitDirectNotifies(changedRoles, roleCount);-
1506 }
never executed: end of block
0
1507 return;
never executed: return;
0
1508 }-
1509 for (int i=0 ; i < roleCount ; ++i) {
i < roleCountDescription
TRUEevaluated 104 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 36 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
36-104
1510 const ListLayout::Role &role = m_model->m_listModel->getExistingRole(i);-
1511 QByteArray name = role.name.toUtf8();-
1512 const QVariant &data = m_model->data(m_elementIndex, i);-
1513 setValue(name, data, role.type == ListLayout::Role::List);-
1514 }
executed 104 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
104
1515}
executed 36 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
36
1516-
1517void ModelNodeMetaObject::updateValues(const QVector<int> &roles)-
1518{-
1519 if (!m_initialized) {
!m_initializedDescription
TRUEevaluated 18 times by 3 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
18-26
1520 emitDirectNotifies(roles.constData(), roles.count());-
1521 return;
executed 18 times by 3 tests: return;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
18
1522 }-
1523 int roleCount = roles.count();-
1524 for (int i=0 ; i < roleCount ; ++i) {
i < roleCountDescription
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
24-26
1525 int roleIndex = roles.at(i);-
1526 const ListLayout::Role &role = m_model->m_listModel->getExistingRole(roleIndex);-
1527 QByteArray name = role.name.toUtf8();-
1528 const QVariant &data = m_model->data(m_elementIndex, roleIndex);-
1529 setValue(name, data, role.type == ListLayout::Role::List);-
1530 }
executed 24 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
24
1531}
executed 26 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
26
1532-
1533void ModelNodeMetaObject::propertyWritten(int index)-
1534{-
1535 if (!m_enabled)
!m_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1536 return;
never executed: return;
0
1537-
1538 QString propName = QString::fromUtf8(name(index));-
1539 const QVariant value = this->value(index);-
1540-
1541 QV4::Scope scope(m_model->engine());-
1542 QV4::ScopedValue v(scope, scope.engine->fromVariant(value));-
1543-
1544 int roleIndex = m_model->m_listModel->setExistingProperty(m_elementIndex, propName, v, scope.engine);-
1545 if (roleIndex != -1)
roleIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1546 m_model->emitItemsChanged(m_elementIndex, 1, QVector<int>(1, roleIndex));
never executed: m_model->emitItemsChanged(m_elementIndex, 1, QVector<int>(1, roleIndex));
0
1547}
never executed: end of block
0
1548-
1549// Does the emission of the notifiers when we haven't created the meta-object yet-
1550void ModelNodeMetaObject::emitDirectNotifies(const int *changedRoles, int roleCount)-
1551{-
1552 Q_ASSERT(!m_initialized);-
1553 QQmlData *ddata = QQmlData::get(object(), /*create*/false);-
1554 if (!ddata)
!ddataDescription
TRUEnever evaluated
FALSEevaluated 18 times by 3 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
0-18
1555 return;
never executed: return;
0
1556 // There's nothing to emit if we're a list model in a worker thread.-
1557 if (!qmlEngine(m_model))
!qmlEngine(m_model)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 14 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qquicklistview
4-14
1558 return;
executed 4 times by 1 test: return;
Executed by:
  • tst_qqmllistmodelworkerscript
4
1559 for (int i = 0; i < roleCount; ++i) {
i < roleCountDescription
TRUEevaluated 14 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qquicklistview
FALSEevaluated 14 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qquicklistview
14
1560 const int changedRole = changedRoles[i];-
1561 QQmlNotifier::notify(ddata, changedRole);-
1562 }
executed 14 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qquicklistview
14
1563}
executed 14 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qquicklistview
14
1564-
1565namespace QV4 {-
1566-
1567bool ModelObject::virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver)-
1568{-
1569 if (!id.isString())
!id.isString()Description
TRUEnever evaluated
FALSEevaluated 58 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
0-58
1570 return Object::virtualPut(m, id, value, receiver);
never executed: return Object::virtualPut(m, id, value, receiver);
0
1571 QString propName = id.toQString();-
1572-
1573 ModelObject *that = static_cast<ModelObject*>(m);-
1574-
1575 ExecutionEngine *eng = that->engine();-
1576 const int elementIndex = that->d()->elementIndex();-
1577 int roleIndex = that->d()->m_model->m_listModel->setExistingProperty(elementIndex, propName, value, eng);-
1578 if (roleIndex != -1)
roleIndex != -1Description
TRUEevaluated 54 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
4-54
1579 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:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
54
1580-
1581 ModelNodeMetaObject *mo = ModelNodeMetaObject::get(that->object());-
1582 if (mo->initialized())
mo->initialized()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 54 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
4-54
1583 mo->emitPropertyNotification(propName.toUtf8());
executed 4 times by 1 test: mo->emitPropertyNotification(propName.toUtf8());
Executed by:
  • tst_qqmllistmodel
4
1584 return true;
executed 58 times by 2 tests: return true;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
58
1585}-
1586-
1587ReturnedValue ModelObject::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)-
1588{-
1589 if (!id.isString())
!id.isString()Description
TRUEnever evaluated
FALSEevaluated 852 times by 8 tests
Evaluated by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
0-852
1590 return QObjectWrapper::virtualGet(m, id, receiver, hasProperty);
never executed: return QObjectWrapper::virtualGet(m, id, receiver, hasProperty);
0
1591-
1592 const ModelObject *that = static_cast<const ModelObject*>(m);-
1593 Scope scope(that);-
1594 ScopedString name(scope, id.asStringOrSymbol());-
1595 const ListLayout::Role *role = that->d()->m_model->m_listModel->getExistingRole(name);-
1596 if (!role)
!roleDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 850 times by 8 tests
Evaluated by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
2-850
1597 return QObjectWrapper::virtualGet(m, id, receiver, hasProperty);
executed 2 times by 1 test: return QObjectWrapper::virtualGet(m, id, receiver, hasProperty);
Executed by:
  • tst_qqmllistmodel
2
1598 if (hasProperty)
hasPropertyDescription
TRUEnever evaluated
FALSEevaluated 850 times by 8 tests
Evaluated by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
0-850
1599 *hasProperty = true;
never executed: *hasProperty = true;
0
1600-
1601 if (QQmlEngine *qmlEngine = that->engine()->qmlEngine()) {
QQmlEngine *qm...)->qmlEngine()Description
TRUEevaluated 736 times by 8 tests
Evaluated by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
FALSEevaluated 114 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
114-736
1602 QQmlEnginePrivate *ep = QQmlEnginePrivate::get(qmlEngine);-
1603 if (ep && ep->propertyCapture)
epDescription
TRUEevaluated 736 times by 8 tests
Evaluated by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
FALSEnever evaluated
ep->propertyCaptureDescription
TRUEevaluated 58 times by 3 tests
Evaluated by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmltranslation
FALSEevaluated 678 times by 6 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
0-736
1604 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:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmltranslation
58
1605 QQmlPropertyCapture::OnlyOnce, false);
executed 58 times by 3 tests: ep->propertyCapture->captureProperty(that->object(), -1, role->index, QQmlPropertyCapture::OnlyOnce, false);
Executed by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmltranslation
58
1606 }
executed 736 times by 8 tests: end of block
Executed by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
736
1607-
1608 const int elementIndex = that->d()->elementIndex();-
1609 QVariant value = that->d()->m_model->data(elementIndex, role->index);-
1610 return that->engine()->fromVariant(value);
executed 850 times by 8 tests: return that->engine()->fromVariant(value);
Executed by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
850
1611}-
1612-
1613void ModelObject::virtualAdvanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes)-
1614{-
1615 ModelObject *that = static_cast<ModelObject*>(m);-
1616 ExecutionEngine *v4 = that->engine();-
1617 name->setM(nullptr);-
1618 *index = UINT_MAX;-
1619 if (it->arrayIndex < uint(that->d()->m_model->m_listModel->roleCount())) {
it->arrayIndex...->roleCount())Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
4-14
1620 Scope scope(that->engine());-
1621 const ListLayout::Role &role = that->d()->m_model->m_listModel->getExistingRole(it->arrayIndex);-
1622 ++it->arrayIndex;-
1623 ScopedString roleName(scope, v4->newString(role.name));-
1624 name->setM(roleName->d());-
1625 *attributes = QV4::Attr_Data;-
1626 QVariant value = that->d()->m_model->data(that->d()->elementIndex(), role.index);-
1627 p->value = v4->fromVariant(value);-
1628 return;
executed 14 times by 1 test: return;
Executed by:
  • tst_qqmllistmodel
14
1629 }-
1630 // Fall back to QV4::Object as opposed to QV4::QObjectWrapper otherwise it will add-
1631 // unnecessary entries that relate to the roles used. These just create extra work-
1632 // later on as they will just be ignored.-
1633 QV4::Object::virtualAdvanceIterator(m, it, name, index, p, attributes);-
1634}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
4
1635-
1636DEFINE_OBJECT_VTABLE(ModelObject);-
1637-
1638} // namespace QV4-
1639-
1640DynamicRoleModelNode::DynamicRoleModelNode(QQmlListModel *owner, int uid) : m_owner(owner), m_uid(uid), m_meta(new DynamicRoleModelNodeMetaObject(this))-
1641{-
1642 setNodeUpdatesEnabled(true);-
1643}
executed 2238 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
2238
1644-
1645DynamicRoleModelNode *DynamicRoleModelNode::create(const QVariantMap &obj, QQmlListModel *owner)-
1646{-
1647 DynamicRoleModelNode *object = new DynamicRoleModelNode(owner, uidCounter.fetchAndAddOrdered(1));-
1648 QVector<int> roles;-
1649 object->updateValues(obj, roles);-
1650 return object;
executed 1514 times by 2 tests: return object;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
1514
1651}-
1652-
1653QVector<int> DynamicRoleModelNode::sync(DynamicRoleModelNode *src, DynamicRoleModelNode *target)-
1654{-
1655 QVector<int> changedRoles;-
1656 for (int i = 0; i < src->m_meta->count(); ++i) {
i < src->m_meta->count()Description
TRUEevaluated 1116 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 824 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
824-1116
1657 const QByteArray &name = src->m_meta->name(i);-
1658 QVariant value = src->m_meta->value(i);-
1659-
1660 QQmlListModel *srcModel = qobject_cast<QQmlListModel *>(value.value<QObject *>());-
1661 QQmlListModel *targetModel = qobject_cast<QQmlListModel *>(target->m_meta->value(i).value<QObject *>());-
1662-
1663 bool modelHasChanges = false;-
1664 if (srcModel) {
srcModelDescription
TRUEevaluated 82 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 1034 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
82-1034
1665 if (targetModel == nullptr)
targetModel == nullptrDescription
TRUEevaluated 56 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
26-56
1666 targetModel = QQmlListModel::createWithOwner(target->m_owner);
executed 56 times by 1 test: targetModel = QQmlListModel::createWithOwner(target->m_owner);
Executed by:
  • tst_qqmllistmodelworkerscript
56
1667-
1668 modelHasChanges = QQmlListModel::sync(srcModel, targetModel);-
1669-
1670 QObject *targetModelObject = targetModel;-
1671 value = QVariant::fromValue(targetModelObject);-
1672 } else if (targetModel) {
executed 82 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
targetModelDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 1032 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
2-1032
1673 delete targetModel;-
1674 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
2
1675-
1676 if (target->setValue(name, value) || modelHasChanges)
target->setValue(name, value)Description
TRUEevaluated 944 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 172 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
modelHasChangesDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 158 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
14-944
1677 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:
  • tst_qqmllistmodelworkerscript
958
1678 }
executed 1116 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
1116
1679 return changedRoles;
executed 824 times by 1 test: return changedRoles;
Executed by:
  • tst_qqmllistmodelworkerscript
824
1680}-
1681-
1682void DynamicRoleModelNode::updateValues(const QVariantMap &object, QVector<int> &roles)-
1683{-
1684 for (auto it = object.cbegin(), end = object.cend(); it != end; ++it) {
it != endDescription
TRUEevaluated 2284 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 1652 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
1652-2284
1685 const QString &key = it.key();-
1686-
1687 int roleIndex = m_owner->m_roles.indexOf(key);-
1688 if (roleIndex == -1) {
roleIndex == -1Description
TRUEevaluated 1518 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 766 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
766-1518
1689 roleIndex = m_owner->m_roles.count();-
1690 m_owner->m_roles.append(key);-
1691 }
executed 1518 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
1518
1692-
1693 QVariant value = it.value();-
1694-
1695 // A JS array/object is translated into a (hierarchical) QQmlListModel,-
1696 // so translate to a variant map/list first with toVariant().-
1697 if (value.userType() == qMetaTypeId<QJSValue>())
value.userType...Id<QJSValue>()Description
TRUEnever evaluated
FALSEevaluated 2284 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
0-2284
1698 value = value.value<QJSValue>().toVariant();
never executed: value = value.value<QJSValue>().toVariant();
0
1699-
1700 if (value.type() == QVariant::List) {
value.type() == QVariant::ListDescription
TRUEevaluated 164 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 2120 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
164-2120
1701 QQmlListModel *subModel = QQmlListModel::createWithOwner(m_owner);-
1702-
1703 QVariantList subArray = value.toList();-
1704 QVariantList::const_iterator subIt = subArray.cbegin();-
1705 QVariantList::const_iterator subEnd = subArray.cend();-
1706 while (subIt != subEnd) {
subIt != subEndDescription
TRUEevaluated 414 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 164 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
164-414
1707 const QVariantMap &subObject = subIt->toMap();-
1708 subModel->m_modelObjects.append(DynamicRoleModelNode::create(subObject, subModel));-
1709 ++subIt;-
1710 }
executed 414 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
414
1711-
1712 QObject *subModelObject = subModel;-
1713 value = QVariant::fromValue(subModelObject);-
1714 }
executed 164 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
164
1715-
1716 const QByteArray &keyUtf8 = key.toUtf8();-
1717-
1718 QQmlListModel *existingModel = qobject_cast<QQmlListModel *>(m_meta->value(keyUtf8).value<QObject *>());-
1719 delete existingModel;-
1720-
1721 if (m_meta->setValue(keyUtf8, value))
m_meta->setVal...eyUtf8, value)Description
TRUEevaluated 2190 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 94 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
94-2190
1722 roles << roleIndex;
executed 2190 times by 2 tests: roles << roleIndex;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
2190
1723 }
executed 2284 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
2284
1724}
executed 1652 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
1652
1725-
1726DynamicRoleModelNodeMetaObject::DynamicRoleModelNodeMetaObject(DynamicRoleModelNode *object)-
1727 : QQmlOpenMetaObject(object), m_enabled(false), m_owner(object)-
1728{-
1729}
executed 2238 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
2238
1730-
1731DynamicRoleModelNodeMetaObject::~DynamicRoleModelNodeMetaObject()-
1732{-
1733 for (int i=0 ; i < count() ; ++i) {
i < count()Description
TRUEevaluated 3096 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 2238 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
2238-3096
1734 QQmlListModel *subModel = qobject_cast<QQmlListModel *>(value(i).value<QObject *>());-
1735 delete subModel;-
1736 }
executed 3096 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
3096
1737}
executed 2238 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
2238
1738-
1739void DynamicRoleModelNodeMetaObject::propertyWrite(int index)-
1740{-
1741 if (!m_enabled)
!m_enabledDescription
TRUEnever evaluated
FALSEevaluated 58 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
0-58
1742 return;
never executed: return;
0
1743-
1744 QVariant v = value(index);-
1745 QQmlListModel *model = qobject_cast<QQmlListModel *>(v.value<QObject *>());-
1746 delete model;-
1747}
executed 58 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
58
1748-
1749void DynamicRoleModelNodeMetaObject::propertyWritten(int index)-
1750{-
1751 if (!m_enabled)
!m_enabledDescription
TRUEnever evaluated
FALSEevaluated 58 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
0-58
1752 return;
never executed: return;
0
1753-
1754 QQmlListModel *parentModel = m_owner->m_owner;-
1755-
1756 QVariant v = value(index);-
1757-
1758 // A JS array/object is translated into a (hierarchical) QQmlListModel,-
1759 // so translate to a variant map/list first with toVariant().-
1760 if (v.userType() == qMetaTypeId<QJSValue>())
v.userType() =...Id<QJSValue>()Description
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 46 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12-46
1761 v= v.value<QJSValue>().toVariant();
executed 12 times by 2 tests: v= v.value<QJSValue>().toVariant();
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12
1762-
1763 if (v.type() == QVariant::List) {
v.type() == QVariant::ListDescription
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 46 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12-46
1764 QQmlListModel *subModel = QQmlListModel::createWithOwner(parentModel);-
1765-
1766 QVariantList subArray = v.toList();-
1767 QVariantList::const_iterator subIt = subArray.cbegin();-
1768 QVariantList::const_iterator subEnd = subArray.cend();-
1769 while (subIt != subEnd) {
subIt != subEndDescription
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12-24
1770 const QVariantMap &subObject = subIt->toMap();-
1771 subModel->m_modelObjects.append(DynamicRoleModelNode::create(subObject, subModel));-
1772 ++subIt;-
1773 }
executed 24 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
24
1774-
1775 QObject *subModelObject = subModel;-
1776 v = QVariant::fromValue(subModelObject);-
1777-
1778 setValue(index, v);-
1779 }
executed 12 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12
1780-
1781 int elementIndex = parentModel->m_modelObjects.indexOf(m_owner);-
1782 if (elementIndex != -1) {
elementIndex != -1Description
TRUEevaluated 58 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
0-58
1783 int roleIndex = parentModel->m_roles.indexOf(QString::fromLatin1(name(index).constData()));-
1784 if (roleIndex != -1)
roleIndex != -1Description
TRUEevaluated 58 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
0-58
1785 parentModel->emitItemsChanged(elementIndex, 1, QVector<int>(1, roleIndex));
executed 58 times by 2 tests: parentModel->emitItemsChanged(elementIndex, 1, QVector<int>(1, roleIndex));
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
58
1786 }
executed 58 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
58
1787}
executed 58 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
58
1788-
1789/*!-
1790 \qmltype ListModel-
1791 \instantiates QQmlListModel-
1792 \inqmlmodule QtQml.Models-
1793 \ingroup qtquick-models-
1794 \brief Defines a free-form list data source.-
1795-
1796 The ListModel is a simple container of ListElement definitions, each-
1797 containing data roles. The contents can be defined dynamically, or-
1798 explicitly in QML.-
1799-
1800 The number of elements in the model can be obtained from its \l count property.-
1801 A number of familiar methods are also provided to manipulate the contents of the-
1802 model, including append(), insert(), move(), remove() and set(). These methods-
1803 accept dictionaries as their arguments; these are translated to ListElement objects-
1804 by the model.-
1805-
1806 Elements can be manipulated via the model using the setProperty() method, which-
1807 allows the roles of the specified element to be set and changed.-
1808-
1809 \section1 Example Usage-
1810-
1811 The following example shows a ListModel containing three elements, with the roles-
1812 "name" and "cost".-
1813-
1814 \div {class="float-right"}-
1815 \inlineimage listmodel.png-
1816 \enddiv-
1817-
1818 \snippet qml/listmodel/listmodel.qml 0-
1819-
1820 Roles (properties) in each element must begin with a lower-case letter and-
1821 should be common to all elements in a model. The ListElement documentation-
1822 provides more guidelines for how elements should be defined.-
1823-
1824 Since the example model contains an \c id property, it can be referenced-
1825 by views, such as the ListView in this example:-
1826-
1827 \snippet qml/listmodel/listmodel-simple.qml 0-
1828 \dots 8-
1829 \snippet qml/listmodel/listmodel-simple.qml 1-
1830-
1831 It is possible for roles to contain list data. In the following example we-
1832 create a list of fruit attributes:-
1833-
1834 \snippet qml/listmodel/listmodel-nested.qml model-
1835-
1836 The delegate displays all the fruit attributes:-
1837-
1838 \div {class="float-right"}-
1839 \inlineimage listmodel-nested.png-
1840 \enddiv-
1841-
1842 \snippet qml/listmodel/listmodel-nested.qml delegate-
1843-
1844 \section1 Modifying List Models-
1845-
1846 The content of a ListModel may be created and modified using the clear(),-
1847 append(), set(), insert() and setProperty() methods. For example:-
1848-
1849 \snippet qml/listmodel/listmodel-modify.qml delegate-
1850-
1851 Note that when creating content dynamically the set of available properties-
1852 cannot be changed once set. Whatever properties are first added to the model-
1853 are the only permitted properties in the model.-
1854-
1855 \section1 Using Threaded List Models with WorkerScript-
1856-
1857 ListModel can be used together with WorkerScript access a list model-
1858 from multiple threads. This is useful if list modifications are-
1859 synchronous and take some time: the list operations can be moved to a-
1860 different thread to avoid blocking of the main GUI thread.-
1861-
1862 Here is an example that uses WorkerScript to periodically append the-
1863 current time to a list model:-
1864-
1865 \snippet ../quick/threading/threadedlistmodel/timedisplay.qml 0-
1866-
1867 The included file, \tt dataloader.js, looks like this:-
1868-
1869 \snippet ../quick/threading/threadedlistmodel/dataloader.js 0-
1870-
1871 The timer in the main example sends messages to the worker script by calling-
1872 \l WorkerScript::sendMessage(). When this message is received,-
1873 \c WorkerScript.onMessage() is invoked in \c dataloader.js,-
1874 which appends the current time to the list model.-
1875-
1876 Note the call to sync() from the external thread.-
1877 You must call sync() or else the changes made to the list from that-
1878 thread will not be reflected in the list model in the main thread.-
1879-
1880 \sa {qml-data-models}{Data Models}, {Qt Quick Examples - Threading}, {Qt QML}-
1881*/-
1882-
1883QQmlListModel::QQmlListModel(QObject *parent)-
1884: QAbstractListModel(parent)-
1885{-
1886 m_mainThread = true;-
1887 m_primary = true;-
1888 m_agent = nullptr;-
1889 m_dynamicRoles = false;-
1890-
1891 m_layout = new ListLayout;-
1892 m_listModel = new ListModel(m_layout, this);-
1893-
1894 m_engine = nullptr;-
1895}
executed 2456 times by 15 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
2456
1896-
1897QQmlListModel::QQmlListModel(const QQmlListModel *owner, ListModel *data, QV4::ExecutionEngine *engine, QObject *parent)-
1898: QAbstractListModel(parent)-
1899{-
1900 m_mainThread = owner->m_mainThread;-
1901 m_primary = false;-
1902 m_agent = owner->m_agent;-
1903-
1904 Q_ASSERT(owner->m_dynamicRoles == false);-
1905 m_dynamicRoles = false;-
1906 m_layout = nullptr;-
1907 m_listModel = data;-
1908-
1909 m_engine = engine;-
1910 m_compilationUnit = owner->m_compilationUnit;-
1911}
executed 138 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
138
1912-
1913QQmlListModel::QQmlListModel(QQmlListModel *orig, QQmlListModelWorkerAgent *agent)-
1914: QAbstractListModel(agent)-
1915{-
1916 m_mainThread = false;-
1917 m_primary = true;-
1918 m_agent = agent;-
1919 m_dynamicRoles = orig->m_dynamicRoles;-
1920-
1921 m_layout = new ListLayout(orig->m_layout);-
1922 m_listModel = new ListModel(m_layout, this);-
1923-
1924 if (m_dynamicRoles)
m_dynamicRolesDescription
TRUEevaluated 468 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 436 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
436-468
1925 sync(orig, this);
executed 468 times by 1 test: sync(orig, this);
Executed by:
  • tst_qqmllistmodelworkerscript
468
1926 else-
1927 ListModel::sync(orig->m_listModel, m_listModel);
executed 436 times by 2 tests: ListModel::sync(orig->m_listModel, m_listModel);
Executed by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
436
1928-
1929 m_engine = nullptr;-
1930 m_compilationUnit = orig->m_compilationUnit;-
1931}
executed 904 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
904
1932-
1933QQmlListModel::~QQmlListModel()-
1934{-
1935 qDeleteAll(m_modelObjects);-
1936-
1937 if (m_primary) {
m_primaryDescription
TRUEevaluated 3352 times by 15 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
FALSEevaluated 138 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickrepeater
138-3352
1938 m_listModel->destroy();-
1939 delete m_listModel;-
1940-
1941 if (m_mainThread && m_agent) {
m_mainThreadDescription
TRUEevaluated 2378 times by 15 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
FALSEevaluated 974 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
m_agentDescription
TRUEevaluated 934 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
FALSEevaluated 1444 times by 15 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
934-2378
1942 m_agent->modelDestroyed();-
1943 m_agent->release();-
1944 }
executed 934 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
934
1945 }
executed 3352 times by 15 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
3352
1946-
1947 m_listModel = nullptr;-
1948-
1949 delete m_layout;-
1950 m_layout = nullptr;-
1951}
executed 3490 times by 15 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
3490
1952-
1953QQmlListModel *QQmlListModel::createWithOwner(QQmlListModel *newOwner)-
1954{-
1955 QQmlListModel *model = new QQmlListModel;-
1956-
1957 model->m_mainThread = newOwner->m_mainThread;-
1958 model->m_engine = newOwner->m_engine;-
1959 model->m_agent = newOwner->m_agent;-
1960 model->m_dynamicRoles = newOwner->m_dynamicRoles;-
1961-
1962 if (model->m_mainThread && model->m_agent)
model->m_mainThreadDescription
TRUEevaluated 160 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 72 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
model->m_agentDescription
TRUEevaluated 30 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 130 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
30-160
1963 model->m_agent->addref();
executed 30 times by 1 test: model->m_agent->addref();
Executed by:
  • tst_qqmllistmodelworkerscript
30
1964-
1965 QQmlEngine::setContextForObject(model, QQmlEngine::contextForObject(newOwner));-
1966-
1967 return model;
executed 232 times by 2 tests: return model;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
232
1968}-
1969-
1970QV4::ExecutionEngine *QQmlListModel::engine() const-
1971{-
1972 if (m_engine == nullptr) {
m_engine == nullptrDescription
TRUEevaluated 640 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
FALSEevaluated 12779 times by 13 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
640-12779
1973 m_engine = qmlEngine(this)->handle();-
1974 }
executed 640 times by 7 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
640
1975-
1976 return m_engine;
executed 13419 times by 13 tests: return m_engine;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
13419
1977}-
1978-
1979bool QQmlListModel::sync(QQmlListModel *src, QQmlListModel *target)-
1980{-
1981 Q_ASSERT(src->m_dynamicRoles && target->m_dynamicRoles);-
1982-
1983 bool hasChanges = false;-
1984-
1985 target->m_roles = src->m_roles;-
1986-
1987 // Build hash of elements <-> uid for each of the lists-
1988 QHash<int, ElementSync> elementHash;-
1989 for (int i = 0 ; i < target->m_modelObjects.count(); ++i) {
i < target->m_...bjects.count()Description
TRUEevaluated 128 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 1018 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
128-1018
1990 DynamicRoleModelNode *e = target->m_modelObjects.at(i);-
1991 int uid = e->getUid();-
1992 ElementSync sync;-
1993 sync.target = e;-
1994 sync.targetIndex = i;-
1995 elementHash.insert(uid, sync);-
1996 }
executed 128 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
128
1997 for (int i = 0 ; i < src->m_modelObjects.count(); ++i) {
i < src->m_mod...bjects.count()Description
TRUEevaluated 824 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 1018 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
824-1018
1998 DynamicRoleModelNode *e = src->m_modelObjects.at(i);-
1999 int uid = e->getUid();-
2000-
2001 QHash<int, ElementSync>::iterator it = elementHash.find(uid);-
2002 if (it == elementHash.end()) {
it == elementHash.end()Description
TRUEevaluated 724 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 100 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
100-724
2003 ElementSync sync;-
2004 sync.src = e;-
2005 sync.srcIndex = i;-
2006 elementHash.insert(uid, sync);-
2007 } else {
executed 724 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
724
2008 ElementSync &sync = it.value();-
2009 sync.src = e;-
2010 sync.srcIndex = i;-
2011 }
executed 100 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
100
2012 }-
2013-
2014 // Get list of elements that are in the target but no longer in the source. These get deleted first.-
2015 int rowsRemoved = 0;-
2016 for (int i = 0 ; i < target->m_modelObjects.count() ; ++i) {
i < target->m_...bjects.count()Description
TRUEevaluated 128 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 1018 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
128-1018
2017 DynamicRoleModelNode *element = target->m_modelObjects.at(i);-
2018 ElementSync &s = elementHash.find(element->getUid()).value();-
2019 Q_ASSERT(s.targetIndex >= 0);-
2020 // need to update the targetIndex, to keep it correct after removals-
2021 s.targetIndex -= rowsRemoved;-
2022 if (s.src == nullptr) {
s.src == nullptrDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 100 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
28-100
2023 Q_ASSERT(s.targetIndex == i);-
2024 hasChanges = true;-
2025 target->beginRemoveRows(QModelIndex(), i, i);-
2026 target->m_modelObjects.remove(i, 1);-
2027 target->endRemoveRows();-
2028 delete s.target;-
2029 ++rowsRemoved;-
2030 --i;-
2031 continue;
executed 28 times by 1 test: continue;
Executed by:
  • tst_qqmllistmodelworkerscript
28
2032 }-
2033 }
executed 100 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
100
2034-
2035 // Clear the target list, and append in correct order from the source-
2036 target->m_modelObjects.clear();-
2037 for (int i = 0 ; i < src->m_modelObjects.count() ; ++i) {
i < src->m_mod...bjects.count()Description
TRUEevaluated 824 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 1018 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
824-1018
2038 DynamicRoleModelNode *element = src->m_modelObjects.at(i);-
2039 ElementSync &s = elementHash.find(element->getUid()).value();-
2040 Q_ASSERT(s.srcIndex >= 0);-
2041 DynamicRoleModelNode *targetElement = s.target;-
2042 if (targetElement == nullptr) {
targetElement == nullptrDescription
TRUEevaluated 724 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 100 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
100-724
2043 targetElement = new DynamicRoleModelNode(target, element->getUid());-
2044 }
executed 724 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
724
2045 s.changedRoles = DynamicRoleModelNode::sync(element, targetElement);-
2046 target->m_modelObjects.append(targetElement);-
2047 }
executed 824 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
824
2048-
2049 // now emit the change notifications required. This can be safely done, as we're only emitting changes, moves and inserts,-
2050 // so the model indices can't be out of bounds-
2051 //-
2052 // to ensure things are kept in the correct order, emit inserts and moves first. This shouls ensure all persistent-
2053 // model indices are updated correctly-
2054 int rowsInserted = 0;-
2055 for (int i = 0 ; i < target->m_modelObjects.count() ; ++i) {
i < target->m_...bjects.count()Description
TRUEevaluated 824 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 1018 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
824-1018
2056 DynamicRoleModelNode *element = target->m_modelObjects.at(i);-
2057 ElementSync &s = elementHash.find(element->getUid()).value();-
2058 Q_ASSERT(s.srcIndex >= 0);-
2059 s.srcIndex += rowsInserted;-
2060 if (s.srcIndex != s.targetIndex) {
s.srcIndex != s.targetIndexDescription
TRUEevaluated 724 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 100 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
100-724
2061 if (s.targetIndex == -1) {
s.targetIndex == -1Description
TRUEevaluated 724 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
0-724
2062 target->beginInsertRows(QModelIndex(), i, i);-
2063 target->endInsertRows();-
2064 } else {
executed 724 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
724
2065 target->beginMoveRows(QModelIndex(), i, i, QModelIndex(), s.srcIndex);-
2066 target->endMoveRows();-
2067 }
never executed: end of block
0
2068 hasChanges = true;-
2069 ++rowsInserted;-
2070 }
executed 724 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
724
2071 if (s.targetIndex != -1 && !s.changedRoles.isEmpty()) {
s.targetIndex != -1Description
TRUEevaluated 100 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 724 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
!s.changedRoles.isEmpty()Description
TRUEevaluated 38 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
FALSEevaluated 62 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
38-724
2072 QModelIndex idx = target->createIndex(i, 0);-
2073 emit target->dataChanged(idx, idx, s.changedRoles);-
2074 hasChanges = true;-
2075 }
executed 38 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
38
2076 }
executed 824 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodelworkerscript
824
2077 return hasChanges;
executed 1018 times by 1 test: return hasChanges;
Executed by:
  • tst_qqmllistmodelworkerscript
1018
2078}-
2079-
2080void QQmlListModel::emitItemsChanged(int index, int count, const QVector<int> &roles)-
2081{-
2082 if (count <= 0)
count <= 0Description
TRUEnever evaluated
FALSEevaluated 458 times by 3 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
0-458
2083 return;
never executed: return;
0
2084-
2085 if (m_mainThread)
m_mainThreadDescription
TRUEevaluated 252 times by 3 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
FALSEevaluated 206 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
206-252
2086 emit 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:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
252
2087}
executed 458 times by 3 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
458
2088-
2089void QQmlListModel::emitItemsAboutToBeInserted(int index, int count)-
2090{-
2091 Q_ASSERT(index >= 0 && count >= 0);-
2092 if (m_mainThread)
m_mainThreadDescription
TRUEevaluated 2224 times by 9 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
FALSEevaluated 1098 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
1098-2224
2093 beginInsertRows(QModelIndex(), index, index + count - 1);
executed 2224 times by 9 tests: beginInsertRows(QModelIndex(), index, index + count - 1);
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
2224
2094}
executed 3322 times by 9 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
3322
2095-
2096void QQmlListModel::emitItemsInserted()-
2097{-
2098 if (m_mainThread) {
m_mainThreadDescription
TRUEevaluated 2224 times by 9 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
FALSEevaluated 1098 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
1098-2224
2099 endInsertRows();-
2100 emit countChanged();-
2101 }
executed 2224 times by 9 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
2224
2102}
executed 3322 times by 9 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
3322
2103-
2104QQmlListModelWorkerAgent *QQmlListModel::agent()-
2105{-
2106 if (m_agent)
m_agentDescription
TRUEevaluated 952 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
FALSEevaluated 904 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
904-952
2107 return m_agent;
executed 952 times by 2 tests: return m_agent;
Executed by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
952
2108-
2109 m_agent = new QQmlListModelWorkerAgent(this);-
2110 return m_agent;
executed 904 times by 2 tests: return m_agent;
Executed by:
  • tst_examples
  • tst_qqmllistmodelworkerscript
904
2111}-
2112-
2113QModelIndex QQmlListModel::index(int row, int column, const QModelIndex &parent) const-
2114{-
2115 return row >= 0 && row < count() && column == 0 && !parent.isValid()
executed 10815 times by 9 tests: return row >= 0 && row < count() && column == 0 && !parent.isValid() ? createIndex(row, column) : QModelIndex();
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickvisualdatamodel
10815
2116 ? createIndex(row, column)
executed 10815 times by 9 tests: return row >= 0 && row < count() && column == 0 && !parent.isValid() ? createIndex(row, column) : QModelIndex();
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickvisualdatamodel
10815
2117 : QModelIndex();
executed 10815 times by 9 tests: return row >= 0 && row < count() && column == 0 && !parent.isValid() ? createIndex(row, column) : QModelIndex();
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickvisualdatamodel
10815
2118}-
2119-
2120int QQmlListModel::rowCount(const QModelIndex &parent) const-
2121{-
2122 return !parent.isValid() ? count() : 0;
executed 18716 times by 12 tests: return !parent.isValid() ? count() : 0;
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
18716
2123}-
2124-
2125QVariant QQmlListModel::data(const QModelIndex &index, int role) const-
2126{-
2127 return data(index.row(), role);
executed 10503 times by 9 tests: return data(index.row(), role);
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickvisualdatamodel
10503
2128}-
2129-
2130bool QQmlListModel::setData(const QModelIndex &index, const QVariant &value, int role)-
2131{-
2132 const int row = index.row();-
2133 if (row >= count() || row < 0)
row >= count()Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
row < 0Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
0-4
2134 return false;
never executed: return false;
0
2135-
2136 if (m_dynamicRoles) {
m_dynamicRolesDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
0-4
2137 const QByteArray property = m_roles.at(role).toUtf8();-
2138 if (m_modelObjects[row]->setValue(property, value)) {
m_modelObjects...operty, value)Description
TRUEnever evaluated
FALSEnever evaluated
0
2139 emitItemsChanged(row, 1, QVector<int>(1, role));-
2140 return true;
never executed: return true;
0
2141 }-
2142 } else {
never executed: end of block
0
2143 const ListLayout::Role &r = m_listModel->getExistingRole(role);-
2144 const int roleIndex = m_listModel->setOrCreateProperty(row, r.name, value);-
2145 if (roleIndex != -1) {
roleIndex != -1Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEnever evaluated
0-4
2146 emitItemsChanged(row, 1, QVector<int>(1, role));-
2147 return true;
executed 4 times by 1 test: return true;
Executed by:
  • tst_qqmllistmodel
4
2148 }-
2149 }
never executed: end of block
0
2150-
2151 return false;
never executed: return false;
0
2152}-
2153-
2154QVariant QQmlListModel::data(int index, int role) const-
2155{-
2156 QVariant v;-
2157-
2158 if (index >= count() || index < 0)
index >= count()Description
TRUEnever evaluated
FALSEevaluated 11687 times by 13 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
index < 0Description
TRUEnever evaluated
FALSEevaluated 11687 times by 13 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
0-11687
2159 return v;
never executed: return v;
0
2160-
2161 if (m_dynamicRoles)
m_dynamicRolesDescription
TRUEevaluated 102 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 11585 times by 13 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
102-11585
2162 v = m_modelObjects[index]->getValue(m_roles[role]);
executed 102 times by 2 tests: v = m_modelObjects[index]->getValue(m_roles[role]);
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
102
2163 else-
2164 v = m_listModel->getProperty(index, role, this, engine());
executed 11585 times by 13 tests: v = m_listModel->getProperty(index, role, this, engine());
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
11585
2165-
2166 return v;
executed 11687 times by 13 tests: return v;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
11687
2167}-
2168-
2169QHash<int, QByteArray> QQmlListModel::roleNames() const-
2170{-
2171 QHash<int, QByteArray> roleNames;-
2172-
2173 if (m_dynamicRoles) {
m_dynamicRolesDescription
TRUEevaluated 88 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 734 times by 11 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
88-734
2174 for (int i = 0 ; i < m_roles.count() ; ++i)
i < m_roles.count()Description
TRUEevaluated 300 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 88 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
88-300
2175 roleNames.insert(i, m_roles.at(i).toUtf8());
executed 300 times by 2 tests: roleNames.insert(i, m_roles.at(i).toUtf8());
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
300
2176 } else {
executed 88 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
88
2177 for (int i = 0 ; i < m_listModel->roleCount() ; ++i) {
i < m_listModel->roleCount()Description
TRUEevaluated 1128 times by 11 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
FALSEevaluated 734 times by 11 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
734-1128
2178 const ListLayout::Role &r = m_listModel->getExistingRole(i);-
2179 roleNames.insert(i, r.name.toUtf8());-
2180 }
executed 1128 times by 11 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
1128
2181 }
executed 734 times by 11 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
734
2182-
2183 return roleNames;
executed 822 times by 11 tests: return roleNames;
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
822
2184}-
2185-
2186/*!-
2187 \qmlproperty bool ListModel::dynamicRoles-
2188-
2189 By default, the type of a role is fixed the first time-
2190 the role is used. For example, if you create a role called-
2191 "data" and assign a number to it, you can no longer assign-
2192 a string to the "data" role. However, when the dynamicRoles-
2193 property is enabled, the type of a given role is not fixed-
2194 and can be different between elements.-
2195-
2196 The dynamicRoles property must be set before any data is-
2197 added to the ListModel, and must be set from the main-
2198 thread.-
2199-
2200 A ListModel that has data statically defined (via the-
2201 ListElement QML syntax) cannot have the dynamicRoles-
2202 property enabled.-
2203-
2204 There is a significant performance cost to using a-
2205 ListModel with dynamic roles enabled. The cost varies-
2206 from platform to platform but is typically somewhere-
2207 between 4-6x slower than using static role types.-
2208-
2209 Due to the performance cost of using dynamic roles,-
2210 they are disabled by default.-
2211*/-
2212void QQmlListModel::setDynamicRoles(bool enableDynamicRoles)-
2213{-
2214 if (m_mainThread && m_agent == nullptr) {
m_mainThreadDescription
TRUEevaluated 1454 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
m_agent == nullptrDescription
TRUEevaluated 1454 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEnever evaluated
0-1454
2215 if (enableDynamicRoles) {
enableDynamicRolesDescription
TRUEevaluated 748 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 706 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
706-748
2216 if (m_layout->roleCount())
m_layout->roleCount()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 746 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
2-746
2217 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:
  • tst_qqmllistmodel
2
2218 else-
2219 m_dynamicRoles = true;
executed 746 times by 2 tests: m_dynamicRoles = true;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
746
2220 } else {-
2221 if (m_roles.count()) {
m_roles.count()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 704 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
2-704
2222 qmlWarning(this) << tr("unable to enable static roles as this model is not empty");-
2223 } else {
executed 2 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
2
2224 m_dynamicRoles = false;-
2225 }
executed 704 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
704
2226 }-
2227 } else {-
2228 qmlWarning(this) << tr("dynamic role setting must be made from the main thread, before any worker scripts are created");-
2229 }
never executed: end of block
0
2230}-
2231-
2232/*!-
2233 \qmlproperty int ListModel::count-
2234 The number of data entries in the model.-
2235*/-
2236int QQmlListModel::count() const-
2237{-
2238 return m_dynamicRoles ? m_modelObjects.count() : m_listModel->elementCount();
executed 48668 times by 14 tests: return m_dynamicRoles ? m_modelObjects.count() : m_listModel->elementCount();
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
48668
2239}-
2240-
2241/*!-
2242 \qmlmethod ListModel::clear()-
2243-
2244 Deletes all content from the model.-
2245-
2246 \sa append(), remove()-
2247*/-
2248void QQmlListModel::clear()-
2249{-
2250 removeElements(0, count());-
2251}
executed 80 times by 4 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
80
2252-
2253/*!-
2254 \qmlmethod ListModel::remove(int index, int count = 1)-
2255-
2256 Deletes the content at \a index from the model.-
2257-
2258 \sa clear()-
2259*/-
2260void QQmlListModel::remove(QQmlV4Function *args)-
2261{-
2262 int argLength = args->length();-
2263-
2264 if (argLength == 1 || argLength == 2) {
argLength == 1Description
TRUEevaluated 190 times by 6 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
FALSEevaluated 238 times by 5 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickvisualdatamodel
argLength == 2Description
TRUEevaluated 214 times by 5 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickvisualdatamodel
FALSEevaluated 24 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
24-238
2265 QV4::Scope scope(args->v4engine());-
2266 int index = QV4::ScopedValue(scope, (*args)[0])->toInt32();-
2267 int removeCount = (argLength == 2 ? QV4::ScopedValue(scope, (*args)[1])->toInt32() : 1);
argLength == 2Description
TRUEevaluated 214 times by 5 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickvisualdatamodel
FALSEevaluated 190 times by 6 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
190-214
2268-
2269 if (index < 0 || index+removeCount > count() || removeCount <= 0) {
index < 0Description
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 392 times by 6 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
index+removeCount > count()Description
TRUEevaluated 36 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 356 times by 6 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
removeCount <= 0Description
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 332 times by 6 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
12-392
2270 qmlWarning(this) << tr("remove: indices [%1 - %2] out of range [0 - %3]").arg(index).arg(index+removeCount).arg(count());-
2271 return;
executed 72 times by 2 tests: return;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
72
2272 }-
2273-
2274 removeElements(index, removeCount);-
2275 } else {
executed 332 times by 6 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
332
2276 qmlWarning(this) << tr("remove: incorrect number of arguments");-
2277 }
executed 24 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
24
2278}-
2279-
2280void QQmlListModel::removeElements(int index, int removeCount)-
2281{-
2282 Q_ASSERT(index >= 0 && removeCount >= 0);-
2283-
2284 if (!removeCount)
!removeCountDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 408 times by 6 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
4-408
2285 return;
executed 4 times by 1 test: return;
Executed by:
  • tst_qqmllistmodel
4
2286-
2287 if (m_mainThread)
m_mainThreadDescription
TRUEevaluated 260 times by 6 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
FALSEevaluated 148 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
148-260
2288 beginRemoveRows(QModelIndex(), index, index + removeCount - 1);
executed 260 times by 6 tests: beginRemoveRows(QModelIndex(), index, index + removeCount - 1);
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
260
2289-
2290 QVector<std::function<void()>> toDestroy;-
2291 if (m_dynamicRoles) {
m_dynamicRolesDescription
TRUEevaluated 132 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 276 times by 6 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
132-276
2292 for (int i=0 ; i < removeCount ; ++i) {
i < removeCountDescription
TRUEevaluated 158 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 132 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
132-158
2293 auto modelObject = m_modelObjects[index+i];-
2294 toDestroy.append([modelObject](){-
2295 delete modelObject;-
2296 });
executed 158 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
158
2297 }
executed 158 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
158
2298 m_modelObjects.remove(index, removeCount);-
2299 } else {
executed 132 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
132
2300 toDestroy = m_listModel->remove(index, removeCount);-
2301 }
executed 276 times by 6 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
276
2302-
2303 if (m_mainThread) {
m_mainThreadDescription
TRUEevaluated 260 times by 6 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
FALSEevaluated 148 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
148-260
2304 endRemoveRows();-
2305 emit countChanged();-
2306 }
executed 260 times by 6 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
260
2307 for (const auto &destroyer : toDestroy)-
2308 destroyer();
executed 506 times by 6 tests: destroyer();
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
506
2309}
executed 408 times by 6 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
408
2310-
2311/*!-
2312 \qmlmethod ListModel::insert(int index, jsobject dict)-
2313-
2314 Adds a new item to the list model at position \a index, with the-
2315 values in \a dict.-
2316-
2317 \code-
2318 fruitModel.insert(2, {"cost": 5.95, "name":"Pizza"})-
2319 \endcode-
2320-
2321 The \a index must be to an existing item in the list, or one past-
2322 the end of the list (equivalent to append).-
2323-
2324 \sa set(), append()-
2325*/-
2326-
2327void QQmlListModel::insert(QQmlV4Function *args)-
2328{-
2329 if (args->length() == 2) {
args->length() == 2Description
TRUEevaluated 538 times by 5 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickvisualdatamodel
FALSEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12-538
2330 QV4::Scope scope(args->v4engine());-
2331 QV4::ScopedValue arg0(scope, (*args)[0]);-
2332 int index = arg0->toInt32();-
2333-
2334 if (index < 0 || index > count()) {
index < 0Description
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 526 times by 5 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickvisualdatamodel
index > count()Description
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 514 times by 5 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickvisualdatamodel
12-526
2335 qmlWarning(this) << tr("insert: index %1 out of range").arg(index);-
2336 return;
executed 24 times by 2 tests: return;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
24
2337 }-
2338-
2339 QV4::ScopedObject argObject(scope, (*args)[1]);-
2340 QV4::ScopedArrayObject objectArray(scope, (*args)[1]);-
2341 if (objectArray) {
objectArrayDescription
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 490 times by 5 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickvisualdatamodel
24-490
2342 QV4::ScopedObject argObject(scope);-
2343-
2344 int objectArrayLength = objectArray->getLength();-
2345 emitItemsAboutToBeInserted(index, objectArrayLength);-
2346 for (int i=0 ; i < objectArrayLength ; ++i) {
i < objectArrayLengthDescription
TRUEevaluated 72 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 24 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
24-72
2347 argObject = objectArray->get(i);-
2348-
2349 if (m_dynamicRoles) {
m_dynamicRolesDescription
TRUEevaluated 36 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 36 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
36
2350 m_modelObjects.insert(index+i, DynamicRoleModelNode::create(scope.engine->variantMapFromJS(argObject), this));-
2351 } else {
executed 36 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
36
2352 m_listModel->insert(index+i, argObject);-
2353 }
executed 36 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
36
2354 }-
2355 emitItemsInserted();-
2356 } else if (argObject) {
executed 24 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
argObjectDescription
TRUEevaluated 466 times by 5 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickvisualdatamodel
FALSEevaluated 24 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
24-466
2357 emitItemsAboutToBeInserted(index, 1);-
2358-
2359 if (m_dynamicRoles) {
m_dynamicRolesDescription
TRUEevaluated 54 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 412 times by 5 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickvisualdatamodel
54-412
2360 m_modelObjects.insert(index, DynamicRoleModelNode::create(scope.engine->variantMapFromJS(argObject), this));-
2361 } else {
executed 54 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
54
2362 m_listModel->insert(index, argObject);-
2363 }
executed 412 times by 5 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickvisualdatamodel
412
2364-
2365 emitItemsInserted();-
2366 } else {
executed 466 times by 5 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickvisualdatamodel
466
2367 qmlWarning(this) << tr("insert: value is not an object");-
2368 }
executed 24 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
24
2369 } else {-
2370 qmlWarning(this) << tr("insert: value is not an object");-
2371 }
executed 12 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12
2372}-
2373-
2374/*!-
2375 \qmlmethod ListModel::move(int from, int to, int n)-
2376-
2377 Moves \a n items \a from one position \a to another.-
2378-
2379 The from and to ranges must exist; for example, to move the first 3 items-
2380 to the end of the list:-
2381-
2382 \code-
2383 fruitModel.move(0, fruitModel.count - 3, 3)-
2384 \endcode-
2385-
2386 \sa append()-
2387*/-
2388void QQmlListModel::move(int from, int to, int n)-
2389{-
2390 if (n == 0 || from == to)
n == 0Description
TRUEnever evaluated
FALSEevaluated 190 times by 5 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
from == toDescription
TRUEnever evaluated
FALSEevaluated 190 times by 5 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
0-190
2391 return;
never executed: return;
0
2392 if (!canMove(from, to, n)) {
!canMove(from, to, n)Description
TRUEevaluated 48 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 142 times by 5 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
48-142
2393 qmlWarning(this) << tr("move: out of range");-
2394 return;
executed 48 times by 2 tests: return;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
48
2395 }-
2396-
2397 if (m_mainThread)
m_mainThreadDescription
TRUEevaluated 70 times by 4 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
FALSEevaluated 72 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
70-72
2398 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:
  • tst_qqmllistmodel
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
70
2399-
2400 if (m_dynamicRoles) {
m_dynamicRolesDescription
TRUEevaluated 54 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 88 times by 5 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
54-88
2401-
2402 int realFrom = from;-
2403 int realTo = to;-
2404 int realN = n;-
2405-
2406 if (from > to) {
from > toDescription
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 42 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12-42
2407 // Only move forwards - flip if backwards moving-
2408 int tfrom = from;-
2409 int tto = to;-
2410 realFrom = tto;-
2411 realTo = tto+n;-
2412 realN = tfrom-tto;-
2413 }
executed 12 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12
2414-
2415 QPODVector<DynamicRoleModelNode *, 4> store;-
2416 for (int i=0 ; i < (realTo-realFrom) ; ++i)
i < (realTo-realFrom)Description
TRUEevaluated 54 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 54 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
54
2417 store.append(m_modelObjects[realFrom+realN+i]);
executed 54 times by 2 tests: store.append(m_modelObjects[realFrom+realN+i]);
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
54
2418 for (int i=0 ; i < realN ; ++i)
i < realNDescription
TRUEevaluated 78 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 54 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
54-78
2419 store.append(m_modelObjects[realFrom+i]);
executed 78 times by 2 tests: store.append(m_modelObjects[realFrom+i]);
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
78
2420 for (int i=0 ; i < store.count() ; ++i)
i < store.count()Description
TRUEevaluated 132 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 54 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
54-132
2421 m_modelObjects[realFrom+i] = store[i];
executed 132 times by 2 tests: m_modelObjects[realFrom+i] = store[i];
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
132
2422-
2423 } else {
executed 54 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
54
2424 m_listModel->move(from, to, n);-
2425 }
executed 88 times by 5 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
88
2426-
2427 if (m_mainThread)
m_mainThreadDescription
TRUEevaluated 70 times by 4 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
FALSEevaluated 72 times by 1 test
Evaluated by:
  • tst_qqmllistmodelworkerscript
70-72
2428 endMoveRows();
executed 70 times by 4 tests: endMoveRows();
Executed by:
  • tst_qqmllistmodel
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
70
2429}
executed 142 times by 5 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
142
2430-
2431/*!-
2432 \qmlmethod ListModel::append(jsobject dict)-
2433-
2434 Adds a new item to the end of the list model, with the-
2435 values in \a dict.-
2436-
2437 \code-
2438 fruitModel.append({"cost": 5.95, "name":"Pizza"})-
2439 \endcode-
2440-
2441 \sa set(), remove()-
2442*/-
2443void QQmlListModel::append(QQmlV4Function *args)-
2444{-
2445 if (args->length() == 1) {
args->length() == 1Description
TRUEevaluated 2834 times by 8 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
FALSEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12-2834
2446 QV4::Scope scope(args->v4engine());-
2447 QV4::ScopedObject argObject(scope, (*args)[0]);-
2448 QV4::ScopedArrayObject objectArray(scope, (*args)[0]);-
2449-
2450 if (objectArray) {
objectArrayDescription
TRUEevaluated 26 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 2808 times by 8 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
26-2808
2451 QV4::ScopedObject argObject(scope);-
2452-
2453 int objectArrayLength = objectArray->getLength();-
2454 if (objectArrayLength > 0) {
objectArrayLength > 0Description
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
2-24
2455 int index = count();-
2456 emitItemsAboutToBeInserted(index, objectArrayLength);-
2457-
2458 for (int i=0 ; i < objectArrayLength ; ++i) {
i < objectArrayLengthDescription
TRUEevaluated 72 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 24 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
24-72
2459 argObject = objectArray->get(i);-
2460-
2461 if (m_dynamicRoles) {
m_dynamicRolesDescription
TRUEevaluated 36 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 36 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
36
2462 m_modelObjects.append(DynamicRoleModelNode::create(scope.engine->variantMapFromJS(argObject), this));-
2463 } else {
executed 36 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
36
2464 m_listModel->append(argObject);-
2465 }
executed 36 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
36
2466 }-
2467-
2468 emitItemsInserted();-
2469 }
executed 24 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
24
2470 } else if (argObject) {
executed 26 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
argObjectDescription
TRUEevaluated 2784 times by 8 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
FALSEevaluated 24 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
24-2784
2471 int index;-
2472-
2473 if (m_dynamicRoles) {
m_dynamicRolesDescription
TRUEevaluated 938 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 1846 times by 8 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
938-1846
2474 index = m_modelObjects.count();-
2475 emitItemsAboutToBeInserted(index, 1);-
2476 m_modelObjects.append(DynamicRoleModelNode::create(scope.engine->variantMapFromJS(argObject), this));-
2477 } else {
executed 938 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
938
2478 index = m_listModel->elementCount();-
2479 emitItemsAboutToBeInserted(index, 1);-
2480 m_listModel->append(argObject);-
2481 }
executed 1846 times by 8 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
1846
2482-
2483 emitItemsInserted();-
2484 } else {
executed 2784 times by 8 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
2784
2485 qmlWarning(this) << tr("append: value is not an object");-
2486 }
executed 24 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
24
2487 } else {-
2488 qmlWarning(this) << tr("append: value is not an object");-
2489 }
executed 12 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12
2490}-
2491-
2492/*!-
2493 \qmlmethod object ListModel::get(int index)-
2494-
2495 Returns the item at \a index in the list model. This allows the item-
2496 data to be accessed or modified from JavaScript:-
2497-
2498 \code-
2499 Component.onCompleted: {-
2500 fruitModel.append({"cost": 5.95, "name":"Jackfruit"});-
2501 console.log(fruitModel.get(0).cost);-
2502 fruitModel.get(0).cost = 10.95;-
2503 }-
2504 \endcode-
2505-
2506 The \a index must be an element in the list.-
2507-
2508 Note that properties of the returned object that are themselves objects-
2509 will also be models, and this get() method is used to access elements:-
2510-
2511 \code-
2512 fruitModel.append(..., "attributes":-
2513 [{"name":"spikes","value":"7mm"},-
2514 {"name":"color","value":"green"}]);-
2515 fruitModel.get(0).attributes.get(1).value; // == "green"-
2516 \endcode-
2517-
2518 \warning The returned object is not guaranteed to remain valid. It-
2519 should not be used in \l{Property Binding}{property bindings}.-
2520-
2521 \sa append()-
2522*/-
2523QQmlV4Handle QQmlListModel::get(int index) const-
2524{-
2525 QV4::Scope scope(engine());-
2526 QV4::ScopedValue result(scope, QV4::Primitive::undefinedValue());-
2527-
2528 if (index >= 0 && index < count()) {
index >= 0Description
TRUEevaluated 1514 times by 8 tests
Evaluated by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
FALSEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
index < count()Description
TRUEevaluated 1502 times by 8 tests
Evaluated by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
FALSEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12-1514
2529-
2530 if (m_dynamicRoles) {
m_dynamicRolesDescription
TRUEevaluated 544 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 958 times by 8 tests
Evaluated by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
544-958
2531 DynamicRoleModelNode *object = m_modelObjects[index];-
2532 result = QV4::QObjectWrapper::wrap(scope.engine, object);-
2533 } else {
executed 544 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
544
2534 QObject *object = m_listModel->getOrCreateModelObject(const_cast<QQmlListModel *>(this), index);-
2535 QQmlData *ddata = QQmlData::get(object);-
2536 if (ddata->jsWrapper.isNullOrUndefined()) {
ddata->jsWrapp...lOrUndefined()Description
TRUEevaluated 660 times by 8 tests
Evaluated by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
FALSEevaluated 298 times by 5 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquicklistview
298-660
2537 result = scope.engine->memoryManager->allocate<QV4::ModelObject>(object, const_cast<QQmlListModel *>(this));-
2538 // Keep track of the QObjectWrapper in persistent value storage-
2539 ddata->jsWrapper.set(scope.engine, result);-
2540 } else {
executed 660 times by 8 tests: end of block
Executed by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
660
2541 result = ddata->jsWrapper.value();-
2542 }
executed 298 times by 5 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquicklistview
298
2543 }-
2544 }-
2545-
2546 return QQmlV4Handle(result);
executed 1526 times by 8 tests: return QQmlV4Handle(result);
Executed by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickrepeater
1526
2547}-
2548-
2549/*!-
2550 \qmlmethod ListModel::set(int index, jsobject dict)-
2551-
2552 Changes the item at \a index in the list model with the-
2553 values in \a dict. Properties not appearing in \a dict-
2554 are left unchanged.-
2555-
2556 \code-
2557 fruitModel.set(3, {"cost": 5.95, "name":"Pizza"})-
2558 \endcode-
2559-
2560 If \a index is equal to count() then a new item is appended to the-
2561 list. Otherwise, \a index must be an element in the list.-
2562-
2563 \sa append()-
2564*/-
2565void QQmlListModel::set(int index, const QQmlV4Handle &handle)-
2566{-
2567 QV4::Scope scope(engine());-
2568 QV4::ScopedObject object(scope, handle);-
2569-
2570 if (!object) {
!objectDescription
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 296 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12-296
2571 qmlWarning(this) << tr("set: value is not an object");-
2572 return;
executed 12 times by 2 tests: return;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12
2573 }-
2574 if (index > count() || index < 0) {
index > count()Description
TRUEnever evaluated
FALSEevaluated 296 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
index < 0Description
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 284 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
0-296
2575 qmlWarning(this) << tr("set: index %1 out of range").arg(index);-
2576 return;
executed 12 times by 2 tests: return;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12
2577 }-
2578-
2579-
2580 if (index == count()) {
index == count()Description
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 260 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
24-260
2581 emitItemsAboutToBeInserted(index, 1);-
2582-
2583 if (m_dynamicRoles) {
m_dynamicRolesDescription
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12
2584 m_modelObjects.append(DynamicRoleModelNode::create(scope.engine->variantMapFromJS(object), this));-
2585 } else {
executed 12 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12
2586 m_listModel->insert(index, object);-
2587 }
executed 12 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
12
2588-
2589 emitItemsInserted();-
2590 } else {
executed 24 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
24
2591-
2592 QVector<int> roles;-
2593-
2594 if (m_dynamicRoles) {
m_dynamicRolesDescription
TRUEevaluated 138 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 122 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
122-138
2595 m_modelObjects[index]->updateValues(scope.engine->variantMapFromJS(object), roles);-
2596 } else {
executed 138 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
138
2597 m_listModel->set(index, object, &roles);-
2598 }
executed 122 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
122
2599-
2600 if (roles.count())
roles.count()Description
TRUEevaluated 230 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 30 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
30-230
2601 emitItemsChanged(index, 1, roles);
executed 230 times by 2 tests: emitItemsChanged(index, 1, roles);
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
230
2602 }
executed 260 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
260
2603}-
2604-
2605/*!-
2606 \qmlmethod ListModel::setProperty(int index, string property, variant value)-
2607-
2608 Changes the \a property of the item at \a index in the list model to \a value.-
2609-
2610 \code-
2611 fruitModel.setProperty(3, "cost", 5.95)-
2612 \endcode-
2613-
2614 The \a index must be an element in the list.-
2615-
2616 \sa append()-
2617*/-
2618void QQmlListModel::setProperty(int index, const QString& property, const QVariant& value)-
2619{-
2620 if (count() == 0 || index >= count() || index < 0) {
count() == 0Description
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 132 times by 3 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
index >= count()Description
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 120 times by 3 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
index < 0Description
TRUEnever evaluated
FALSEevaluated 120 times by 3 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
0-132
2621 qmlWarning(this) << tr("set: index %1 out of range").arg(index);-
2622 return;
executed 36 times by 2 tests: return;
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
36
2623 }-
2624-
2625 if (m_dynamicRoles) {
m_dynamicRolesDescription
TRUEevaluated 56 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 64 times by 3 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
56-64
2626 int roleIndex = m_roles.indexOf(property);-
2627 if (roleIndex == -1) {
roleIndex == -1Description
TRUEnever evaluated
FALSEevaluated 56 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
0-56
2628 roleIndex = m_roles.count();-
2629 m_roles.append(property);-
2630 }
never executed: end of block
0
2631 if (m_modelObjects[index]->setValue(property.toUtf8(), value))
m_modelObjects...Utf8(), value)Description
TRUEevaluated 52 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
4-52
2632 emitItemsChanged(index, 1, QVector<int>(1, roleIndex));
executed 52 times by 2 tests: emitItemsChanged(index, 1, QVector<int>(1, roleIndex));
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
52
2633 } else {
executed 56 times by 2 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
56
2634 int roleIndex = m_listModel->setOrCreateProperty(index, property, value);-
2635 if (roleIndex != -1)
roleIndex != -1Description
TRUEevaluated 60 times by 3 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
4-60
2636 emitItemsChanged(index, 1, QVector<int>(1, roleIndex));
executed 60 times by 3 tests: emitItemsChanged(index, 1, QVector<int>(1, roleIndex));
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
60
2637 }
executed 64 times by 3 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
64
2638}-
2639-
2640/*!-
2641 \qmlmethod ListModel::sync()-
2642-
2643 Writes any unsaved changes to the list model after it has been modified-
2644 from a worker script.-
2645*/-
2646void QQmlListModel::sync()-
2647{-
2648 // This is just a dummy method to make it look like sync() exists in-
2649 // ListModel (and not just QQmlListModelWorkerAgent) and to let-
2650 // us document sync().-
2651 qmlWarning(this) << "List sync() can only be called from a WorkerScript";-
2652}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
2
2653-
2654bool QQmlListModelParser::verifyProperty(const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding)-
2655{-
2656 if (binding->type >= QV4::CompiledData::Binding::Type_Object) {
binding->type ...g::Type_ObjectDescription
TRUEevaluated 1928 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
FALSEevaluated 2826 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
1928-2826
2657 const quint32 targetObjectIndex = binding->value.objectIndex;-
2658 const QV4::CompiledData::Object *target = qmlUnit->objectAt(targetObjectIndex);-
2659 QString objName = qmlUnit->stringAt(target->inheritedTypeNameIndex);-
2660 if (objName != listElementTypeName) {
objName != listElementTypeNameDescription
TRUEevaluated 388 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
FALSEevaluated 1540 times by 11 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlenginecleanup
  • tst_qqmllistmodel
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
388-1540
2661 const QMetaObject *mo = resolveType(objName);-
2662 if (mo != &QQmlListElement::staticMetaObject) {
mo != &QQmlLis...aticMetaObjectDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 386 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
2-386
2663 error(target, QQmlListModel::tr("ListElement: cannot contain nested elements"));-
2664 return false;
executed 2 times by 1 test: return false;
Executed by:
  • tst_qqmllistmodel
2
2665 }-
2666 listElementTypeName = objName; // cache right name for next time-
2667 }
executed 386 times by 14 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
386
2668-
2669 if (!qmlUnit->stringAt(target->idNameIndex).isEmpty()) {
!qmlUnit->stri...dex).isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 1924 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
2-1924
2670 error(target->locationOfIdProperty, QQmlListModel::tr("ListElement: cannot use reserved \"id\" property"));-
2671 return false;
executed 2 times by 1 test: return false;
Executed by:
  • tst_qqmllistmodel
2
2672 }-
2673-
2674 const QV4::CompiledData::Binding *binding = target->bindingTable();-
2675 for (quint32 i = 0; i < target->nBindings; ++i, ++binding) {
i < target->nBindingsDescription
TRUEevaluated 2896 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
FALSEevaluated 1912 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
1912-2896
2676 QString propName = qmlUnit->stringAt(binding->propertyNameIndex);-
2677 if (propName.isEmpty()) {
propName.isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 2894 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
2-2894
2678 error(binding, QQmlListModel::tr("ListElement: cannot contain nested elements"));-
2679 return false;
executed 2 times by 1 test: return false;
Executed by:
  • tst_qqmllistmodel
2
2680 }-
2681 if (!verifyProperty(qmlUnit, binding))
!verifyPropert...Unit, binding)Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 2884 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
10-2884
2682 return false;
executed 10 times by 1 test: return false;
Executed by:
  • tst_qqmllistmodel
10
2683 }
executed 2884 times by 14 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
2884
2684 } else if (binding->type == QV4::CompiledData::Binding::Type_Script) {
executed 1912 times by 14 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
binding->type ...g::Type_ScriptDescription
TRUEevaluated 100 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
FALSEevaluated 2726 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
100-2726
2685 QString scriptStr = binding->valueAsScriptString(qmlUnit);-
2686 if (!binding->isFunctionExpression() && !definesEmptyList(scriptStr)) {
!binding->isFu...onExpression()Description
TRUEevaluated 100 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
FALSEnever evaluated
!definesEmptyList(scriptStr)Description
TRUEevaluated 98 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
0-100
2687 QByteArray script = scriptStr.toUtf8();-
2688 bool ok;-
2689 evaluateEnum(script, &ok);-
2690 if (!ok) {
!okDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 90 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
8-90
2691 error(binding, QQmlListModel::tr("ListElement: cannot use script for property value"));-
2692 return false;
executed 8 times by 1 test: return false;
Executed by:
  • tst_qqmllistmodel
8
2693 }-
2694 }
executed 90 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
90
2695 }
executed 92 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
92
2696-
2697 return true;
executed 4730 times by 14 tests: return true;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
4730
2698}-
2699-
2700bool QQmlListModelParser::applyProperty(QV4::CompiledData::CompilationUnit *compilationUnit, const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding, ListModel *model, int outterElementIndex)-
2701{-
2702 const QString elementName = qmlUnit->stringAt(binding->propertyNameIndex);-
2703-
2704 bool roleSet = false;-
2705 if (binding->type >= QV4::CompiledData::Binding::Type_Object) {
binding->type ...g::Type_ObjectDescription
TRUEevaluated 3280 times by 13 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
FALSEevaluated 4404 times by 13 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
3280-4404
2706 const quint32 targetObjectIndex = binding->value.objectIndex;-
2707 const QV4::CompiledData::Object *target = qmlUnit->objectAt(targetObjectIndex);-
2708-
2709 ListModel *subModel = nullptr;-
2710 if (outterElementIndex == -1) {
outterElementIndex == -1Description
TRUEevaluated 3216 times by 13 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
FALSEevaluated 64 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
64-3216
2711 subModel = model;-
2712 } else {
executed 3216 times by 13 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
3216
2713 const ListLayout::Role &role = model->getOrCreateListRole(elementName);-
2714 if (role.type == ListLayout::Role::List) {
role.type == L...ut::Role::ListDescription
TRUEevaluated 62 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
2-62
2715 subModel = model->getListProperty(outterElementIndex, role);-
2716 if (subModel == nullptr) {
subModel == nullptrDescription
TRUEevaluated 32 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
FALSEevaluated 30 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
30-32
2717 subModel = new ListModel(role.subLayout, nullptr);-
2718 QVariant vModel = QVariant::fromValue(subModel);-
2719 model->setOrCreateProperty(outterElementIndex, elementName, vModel);-
2720 }
executed 32 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
32
2721 }
executed 62 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
62
2722 }
executed 64 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
64
2723-
2724 int elementIndex = subModel ? subModel->appendElement() : -1;
subModelDescription
TRUEevaluated 3278 times by 13 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
2-3278
2725-
2726 const QV4::CompiledData::Binding *subBinding = target->bindingTable();-
2727 for (quint32 i = 0; i < target->nBindings; ++i, ++subBinding) {
i < target->nBindingsDescription
TRUEevaluated 4468 times by 13 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
FALSEevaluated 3280 times by 13 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
3280-4468
2728 roleSet |= applyProperty(compilationUnit, qmlUnit, subBinding, subModel, elementIndex);-
2729 }
executed 4468 times by 13 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
4468
2730-
2731 } else {
executed 3280 times by 13 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
3280
2732 QVariant value;-
2733-
2734 if (binding->isTranslationBinding()) {
binding->isTra...ationBinding()Description
TRUEevaluated 8 times by 3 tests
Evaluated by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmltranslation
FALSEevaluated 4396 times by 12 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
8-4396
2735 value = QVariant::fromValue<const QV4::CompiledData::Binding*>(binding);-
2736 } else if (binding->evaluatesToString()) {
executed 8 times by 3 tests: end of block
Executed by:
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmltranslation
binding->evaluatesToString()Description
TRUEevaluated 3944 times by 11 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
FALSEevaluated 452 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qtqmlmodules
8-3944
2737 value = binding->valueAsString(qmlUnit);-
2738 } else if (binding->type == QV4::CompiledData::Binding::Type_Number) {
executed 3944 times by 11 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
binding->type ...g::Type_NumberDescription
TRUEevaluated 304 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qquicklistview
  • tst_qquickrepeater
FALSEevaluated 148 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qquicklistview
  • tst_qtqmlmodules
148-3944
2739 value = binding->valueAsNumber();-
2740 } else if (binding->type == QV4::CompiledData::Binding::Type_Boolean) {
executed 304 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
  • tst_qquicklistview
  • tst_qquickrepeater
binding->type ...::Type_BooleanDescription
TRUEevaluated 56 times by 3 tests
Evaluated by:
  • tst_qqmllistmodel
  • tst_qquicklistview
  • tst_qtqmlmodules
FALSEevaluated 92 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
56-304
2741 value = binding->valueAsBoolean();-
2742 } else if (binding->type == QV4::CompiledData::Binding::Type_Script) {
executed 56 times by 3 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qquicklistview
  • tst_qtqmlmodules
binding->type ...g::Type_ScriptDescription
TRUEevaluated 92 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
FALSEnever evaluated
0-92
2743 QString scriptStr = binding->valueAsScriptString(qmlUnit);-
2744 if (definesEmptyList(scriptStr)) {
definesEmptyList(scriptStr)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 90 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
2-90
2745 const ListLayout::Role &role = model->getOrCreateListRole(elementName);-
2746 ListModel *emptyModel = new ListModel(role.subLayout, nullptr);-
2747 value = QVariant::fromValue(emptyModel);-
2748 } else if (binding->isFunctionExpression()) {
executed 2 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
binding->isFun...onExpression()Description
TRUEnever evaluated
FALSEevaluated 90 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
0-90
2749 QQmlBinding::Identifier id = binding->value.compiledScriptIndex;-
2750 Q_ASSERT(id != QQmlBinding::Invalid);-
2751-
2752 auto v4 = compilationUnit->engine;-
2753 QV4::Scope scope(v4);-
2754 // for now we do not provide a context object; data from the ListElement must be passed to the function-
2755 QV4::ScopedContext context(scope, QV4::QmlContext::create(v4->rootContext(), QQmlContextData::get(qmlContext(model->m_modelCache)), nullptr));-
2756 QV4::ScopedFunctionObject function(scope, QV4::FunctionObject::createScriptFunction(context, compilationUnit->runtimeFunctions[id]));-
2757-
2758 QV4::ReturnedValue result = function->call(v4->globalObject, nullptr, 0);-
2759-
2760 QJSValue v;-
2761 QJSValuePrivate::setValue(&v, v4, result);-
2762 value.setValue<QJSValue>(v);-
2763 } else {
never executed: end of block
0
2764 QByteArray script = scriptStr.toUtf8();-
2765 bool ok;-
2766 value = evaluateEnum(script, &ok);-
2767 }
executed 90 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmllistmodel
90
2768 } else {-
2769 Q_UNREACHABLE();-
2770 }
never executed: end of block
0
2771-
2772 model->setOrCreateProperty(outterElementIndex, elementName, value);-
2773 roleSet = true;-
2774 }
executed 4404 times by 13 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
4404
2775 return roleSet;
executed 7684 times by 13 tests: return roleSet;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
7684
2776}-
2777-
2778void QQmlListModelParser::verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &bindings)-
2779{-
2780 listElementTypeName = QString(); // unknown-
2781-
2782 for (const QV4::CompiledData::Binding *binding : bindings) {-
2783 QString propName = qmlUnit->stringAt(binding->propertyNameIndex);-
2784 if (!propName.isEmpty()) { // isn't default property
!propName.isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 1860 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
2-1860
2785 error(binding, QQmlListModel::tr("ListModel: undefined property '%1'").arg(propName));-
2786 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_qqmllistmodel
2
2787 }-
2788 if (!verifyProperty(qmlUnit, binding))
!verifyPropert...Unit, binding)Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 1846 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
14-1846
2789 return;
executed 14 times by 1 test: return;
Executed by:
  • tst_qqmllistmodel
14
2790 }
executed 1846 times by 14 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
1846
2791}
executed 372 times by 14 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
372
2792-
2793void QQmlListModelParser::applyBindings(QObject *obj, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings)-
2794{-
2795 QQmlListModel *rv = static_cast<QQmlListModel *>(obj);-
2796-
2797 rv->m_engine = qmlEngine(rv)->handle();-
2798 rv->m_compilationUnit = compilationUnit;-
2799-
2800 const QV4::CompiledData::Unit *qmlUnit = compilationUnit->data;-
2801-
2802 bool setRoles = false;-
2803-
2804 for (const QV4::CompiledData::Binding *binding : bindings) {-
2805 if (binding->type != QV4::CompiledData::Binding::Type_Object)
binding->type ...g::Type_ObjectDescription
TRUEnever evaluated
FALSEevaluated 3216 times by 13 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
0-3216
2806 continue;
never executed: continue;
0
2807 setRoles |= applyProperty(compilationUnit, qmlUnit, binding, rv->m_listModel, /*outter element index*/-1);-
2808 }
executed 3216 times by 13 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
3216
2809-
2810 if (setRoles == false)
setRoles == falseDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 696 times by 13 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
4-696
2811 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:
  • tst_qqmllistmodel
4
2812}
executed 700 times by 13 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmltranslation
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquickvisualdatamodel
  • tst_qtqmlmodules
700
2813-
2814bool QQmlListModelParser::definesEmptyList(const QString &s)-
2815{-
2816 if (s.startsWith(QLatin1Char('[')) && s.endsWith(QLatin1Char(']'))) {
s.startsWith(QLatin1Char('['))Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 188 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmllistmodel
s.endsWith(QLatin1Char(']'))Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEnever evaluated
0-188
2817 for (int i=1; i<s.length()-1; i++) {
i<s.length()-1Description
TRUEevaluated 56 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
4-56
2818 if (!s[i].isSpace())
!s[i].isSpace()Description
TRUEnever evaluated
FALSEevaluated 56 times by 1 test
Evaluated by:
  • tst_qqmllistmodel
0-56
2819 return false;
never executed: return false;
0
2820 }
executed 56 times by 1 test: end of block
Executed by:
  • tst_qqmllistmodel
56
2821 return true;
executed 4 times by 1 test: return true;
Executed by:
  • tst_qqmllistmodel
4
2822 }-
2823 return false;
executed 188 times by 2 tests: return false;
Executed by:
  • tst_examples
  • tst_qqmllistmodel
188
2824}-
2825-
2826-
2827/*!-
2828 \qmltype ListElement-
2829 \instantiates QQmlListElement-
2830 \inqmlmodule QtQml.Models-
2831 \brief Defines a data item in a ListModel.-
2832 \ingroup qtquick-models-
2833-
2834 List elements are defined inside ListModel definitions, and represent items in a-
2835 list that will be displayed using ListView or \l Repeater items.-
2836-
2837 List elements are defined like other QML elements except that they contain-
2838 a collection of \e role definitions instead of properties. Using the same-
2839 syntax as property definitions, roles both define how the data is accessed-
2840 and include the data itself.-
2841-
2842 The names used for roles must begin with a lower-case letter and should be-
2843 common to all elements in a given model. Values must be simple constants; either-
2844 strings (quoted and optionally within a call to QT_TR_NOOP), boolean values-
2845 (true, false), numbers, or enumeration values (such as AlignText.AlignHCenter).-
2846-
2847 Beginning with Qt 5.11 ListElement also allows assigning a function declaration to-
2848 a role. This allows the definition of ListElements with callable actions.-
2849-
2850 \section1 Referencing Roles-
2851-
2852 The role names are used by delegates to obtain data from list elements.-
2853 Each role name is accessible in the delegate's scope, and refers to the-
2854 corresponding role in the current element. Where a role name would be-
2855 ambiguous to use, it can be accessed via the \l{ListView::}{model}-
2856 property (e.g., \c{model.cost} instead of \c{cost}).-
2857-
2858 \section1 Example Usage-
2859-
2860 The following model defines a series of list elements, each of which-
2861 contain "name" and "cost" roles and their associated values.-
2862-
2863 \snippet qml/listmodel/listelements.qml model-
2864-
2865 The delegate obtains the name and cost for each element by simply referring-
2866 to \c name and \c cost:-
2867-
2868 \snippet qml/listmodel/listelements.qml view-
2869-
2870 \sa ListModel-
2871*/-
2872-
2873QT_END_NAMESPACE-
2874-
2875#include "moc_qqmllistmodel_p.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0