Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/types/qqmldelegatemodel.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||||||||
2 | ** | - | ||||||||||||||||||||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||||||||
5 | ** | - | ||||||||||||||||||||||||
6 | ** This file is part of the 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 "qqmldelegatemodel_p_p.h" | - | ||||||||||||||||||||||||
41 | - | |||||||||||||||||||||||||
42 | #include <QtQml/qqmlinfo.h> | - | ||||||||||||||||||||||||
43 | - | |||||||||||||||||||||||||
44 | #include <private/qquickpackage_p.h> | - | ||||||||||||||||||||||||
45 | #include <private/qmetaobjectbuilder_p.h> | - | ||||||||||||||||||||||||
46 | #include <private/qqmladaptormodel_p.h> | - | ||||||||||||||||||||||||
47 | #include <private/qqmlchangeset_p.h> | - | ||||||||||||||||||||||||
48 | #include <private/qqmlengine_p.h> | - | ||||||||||||||||||||||||
49 | #include <private/qqmlcomponent_p.h> | - | ||||||||||||||||||||||||
50 | #include <private/qqmlincubator_p.h> | - | ||||||||||||||||||||||||
51 | - | |||||||||||||||||||||||||
52 | #include <private/qv4value_p.h> | - | ||||||||||||||||||||||||
53 | #include <private/qv4functionobject_p.h> | - | ||||||||||||||||||||||||
54 | #include <qv4objectiterator_p.h> | - | ||||||||||||||||||||||||
55 | - | |||||||||||||||||||||||||
56 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
57 | - | |||||||||||||||||||||||||
58 | class QQmlDelegateModelItem; | - | ||||||||||||||||||||||||
59 | - | |||||||||||||||||||||||||
60 | namespace QV4 { | - | ||||||||||||||||||||||||
61 | - | |||||||||||||||||||||||||
62 | namespace Heap { | - | ||||||||||||||||||||||||
63 | - | |||||||||||||||||||||||||
64 | struct DelegateModelGroupFunction : FunctionObject { | - | ||||||||||||||||||||||||
65 | void init(QV4::ExecutionContext *scope, uint flag, QV4::ReturnedValue (*code)(QQmlDelegateModelItem *item, uint flag, const QV4::Value &arg)); | - | ||||||||||||||||||||||||
66 | - | |||||||||||||||||||||||||
67 | QV4::ReturnedValue (*code)(QQmlDelegateModelItem *item, uint flag, const QV4::Value &arg); | - | ||||||||||||||||||||||||
68 | uint flag; | - | ||||||||||||||||||||||||
69 | }; | - | ||||||||||||||||||||||||
70 | - | |||||||||||||||||||||||||
71 | struct QQmlDelegateModelGroupChange : Object { | - | ||||||||||||||||||||||||
72 | void init() { Object::init(); } executed 166 times by 1 test: end of block Executed by:
| 166 | ||||||||||||||||||||||||
73 | - | |||||||||||||||||||||||||
74 | QQmlChangeSet::ChangeData change; | - | ||||||||||||||||||||||||
75 | }; | - | ||||||||||||||||||||||||
76 | - | |||||||||||||||||||||||||
77 | struct QQmlDelegateModelGroupChangeArray : Object { | - | ||||||||||||||||||||||||
78 | void init(const QVector<QQmlChangeSet::Change> &changes); | - | ||||||||||||||||||||||||
79 | void destroy() { | - | ||||||||||||||||||||||||
80 | delete changes; | - | ||||||||||||||||||||||||
81 | Object::destroy(); | - | ||||||||||||||||||||||||
82 | } executed 164 times by 2 tests: end of block Executed by:
| 164 | ||||||||||||||||||||||||
83 | - | |||||||||||||||||||||||||
84 | QVector<QQmlChangeSet::Change> *changes; | - | ||||||||||||||||||||||||
85 | }; | - | ||||||||||||||||||||||||
86 | - | |||||||||||||||||||||||||
87 | - | |||||||||||||||||||||||||
88 | } | - | ||||||||||||||||||||||||
89 | - | |||||||||||||||||||||||||
90 | struct DelegateModelGroupFunction : QV4::FunctionObject | - | ||||||||||||||||||||||||
91 | { | - | ||||||||||||||||||||||||
92 | V4_OBJECT2(DelegateModelGroupFunction, FunctionObject) never executed: end of block never executed: end of block executed 16290 times by 2 tests: return &static_vtbl; Executed by:
executed 51424 times by 2 tests: return static_cast<QV4::Heap::DelegateModelGroupFunction *>(m()); Executed by:
executed 45994 times by 2 tests: return dptr; Executed by:
| 0-51424 | ||||||||||||||||||||||||
93 | - | |||||||||||||||||||||||||
94 | static Heap::DelegateModelGroupFunction *create(QV4::ExecutionContext *scope, uint flag, QV4::ReturnedValue (*code)(QQmlDelegateModelItem *item, uint flag, const QV4::Value &arg)) | - | ||||||||||||||||||||||||
95 | { | - | ||||||||||||||||||||||||
96 | return scope->engine()->memoryManager->allocate<DelegateModelGroupFunction>(scope, flag, code); executed 5430 times by 2 tests: return scope->engine()->memoryManager->allocate<DelegateModelGroupFunction>(scope, flag, code); Executed by:
| 5430 | ||||||||||||||||||||||||
97 | } | - | ||||||||||||||||||||||||
98 | - | |||||||||||||||||||||||||
99 | static ReturnedValue virtualCall(const QV4::FunctionObject *that, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||||||||||||||
100 | { | - | ||||||||||||||||||||||||
101 | QV4::Scope scope(that->engine()); | - | ||||||||||||||||||||||||
102 | QV4::Scoped<DelegateModelGroupFunction> f(scope, static_cast<const DelegateModelGroupFunction *>(that)); | - | ||||||||||||||||||||||||
103 | QV4::Scoped<QQmlDelegateModelItemObject> o(scope, thisObject); | - | ||||||||||||||||||||||||
104 | if (!o)
| 0-20282 | ||||||||||||||||||||||||
105 | return scope.engine->throwTypeError(QStringLiteral("Not a valid VisualData object")); never executed: return scope.engine->throwTypeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Not a valid VisualData object")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Not a valid VisualData object" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||||||||
106 | - | |||||||||||||||||||||||||
107 | QV4::ScopedValue v(scope, argc ? argv[0] : Primitive::undefinedValue()); | - | ||||||||||||||||||||||||
108 | return f->d()->code(o->d()->item, f->d()->flag, v); executed 20282 times by 2 tests: return f->d()->code(o->d()->item, f->d()->flag, v); Executed by:
| 20282 | ||||||||||||||||||||||||
109 | } | - | ||||||||||||||||||||||||
110 | }; | - | ||||||||||||||||||||||||
111 | - | |||||||||||||||||||||||||
112 | void Heap::DelegateModelGroupFunction::init(QV4::ExecutionContext *scope, uint flag, QV4::ReturnedValue (*code)(QQmlDelegateModelItem *item, uint flag, const QV4::Value &arg)) | - | ||||||||||||||||||||||||
113 | { | - | ||||||||||||||||||||||||
114 | QV4::Heap::FunctionObject::init(scope, QStringLiteral("DelegateModelGroupFunction")); executed 5430 times by 2 tests: return qstring_literal_temp; Executed by:
| 5430 | ||||||||||||||||||||||||
115 | this->flag = flag; | - | ||||||||||||||||||||||||
116 | this->code = code; | - | ||||||||||||||||||||||||
117 | } executed 5430 times by 2 tests: end of block Executed by:
| 5430 | ||||||||||||||||||||||||
118 | - | |||||||||||||||||||||||||
119 | } | - | ||||||||||||||||||||||||
120 | - | |||||||||||||||||||||||||
121 | DEFINE_OBJECT_VTABLE(QV4::DelegateModelGroupFunction); | - | ||||||||||||||||||||||||
122 | - | |||||||||||||||||||||||||
123 | - | |||||||||||||||||||||||||
124 | - | |||||||||||||||||||||||||
125 | class QQmlDelegateModelEngineData : public QV8Engine::Deletable | - | ||||||||||||||||||||||||
126 | { | - | ||||||||||||||||||||||||
127 | public: | - | ||||||||||||||||||||||||
128 | QQmlDelegateModelEngineData(QV4::ExecutionEngine *v4); | - | ||||||||||||||||||||||||
129 | ~QQmlDelegateModelEngineData(); | - | ||||||||||||||||||||||||
130 | - | |||||||||||||||||||||||||
131 | QV4::ReturnedValue array(QV4::ExecutionEngine *engine, | - | ||||||||||||||||||||||||
132 | const QVector<QQmlChangeSet::Change> &changes); | - | ||||||||||||||||||||||||
133 | - | |||||||||||||||||||||||||
134 | QV4::PersistentValue changeProto; | - | ||||||||||||||||||||||||
135 | }; | - | ||||||||||||||||||||||||
136 | - | |||||||||||||||||||||||||
137 | V4_DEFINE_EXTENSION(QQmlDelegateModelEngineData, engineData) executed 4 times by 2 tests: extensionId = QV8Engine::registerExtension(); Executed by:
executed 4 times by 2 tests: end of block Executed by:
executed 4 times by 2 tests: end of block Executed by:
executed 330 times by 2 tests: return rv; Executed by:
| 0-330 | ||||||||||||||||||||||||
138 | - | |||||||||||||||||||||||||
139 | - | |||||||||||||||||||||||||
140 | void QQmlDelegateModelPartsMetaObject::propertyCreated(int, QMetaPropertyBuilder &prop) | - | ||||||||||||||||||||||||
141 | { | - | ||||||||||||||||||||||||
142 | prop.setWritable(false); | - | ||||||||||||||||||||||||
143 | } executed 368 times by 6 tests: end of block Executed by:
| 368 | ||||||||||||||||||||||||
144 | - | |||||||||||||||||||||||||
145 | QVariant QQmlDelegateModelPartsMetaObject::initialValue(int id) | - | ||||||||||||||||||||||||
146 | { | - | ||||||||||||||||||||||||
147 | QQmlDelegateModelParts *parts = static_cast<QQmlDelegateModelParts *>(object()); | - | ||||||||||||||||||||||||
148 | QQmlPartsModel *m = new QQmlPartsModel( | - | ||||||||||||||||||||||||
149 | parts->model, QString::fromUtf8(name(id)), parts); | - | ||||||||||||||||||||||||
150 | parts->models.append(m); | - | ||||||||||||||||||||||||
151 | return QVariant::fromValue(static_cast<QObject *>(m)); executed 368 times by 6 tests: return QVariant::fromValue(static_cast<QObject *>(m)); Executed by:
| 368 | ||||||||||||||||||||||||
152 | } | - | ||||||||||||||||||||||||
153 | - | |||||||||||||||||||||||||
154 | QQmlDelegateModelParts::QQmlDelegateModelParts(QQmlDelegateModel *parent) | - | ||||||||||||||||||||||||
155 | : QObject(parent), model(parent) | - | ||||||||||||||||||||||||
156 | { | - | ||||||||||||||||||||||||
157 | new QQmlDelegateModelPartsMetaObject(this); | - | ||||||||||||||||||||||||
158 | } executed 352 times by 6 tests: end of block Executed by:
| 352 | ||||||||||||||||||||||||
159 | - | |||||||||||||||||||||||||
160 | //--------------------------------------------------------------------------- | - | ||||||||||||||||||||||||
161 | - | |||||||||||||||||||||||||
162 | /*! | - | ||||||||||||||||||||||||
163 | \qmltype VisualDataModel | - | ||||||||||||||||||||||||
164 | \instantiates QQmlDelegateModel | - | ||||||||||||||||||||||||
165 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||
166 | \ingroup qtquick-models | - | ||||||||||||||||||||||||
167 | \brief Encapsulates a model and delegate. | - | ||||||||||||||||||||||||
168 | - | |||||||||||||||||||||||||
169 | The VisualDataModel type encapsulates a model and the delegate that will | - | ||||||||||||||||||||||||
170 | be instantiated for items in a model. | - | ||||||||||||||||||||||||
171 | - | |||||||||||||||||||||||||
172 | This type is provided by the \l{Qt QML} module due to compatibility reasons. | - | ||||||||||||||||||||||||
173 | The same implementation is now primarily available as DelegateModel in the | - | ||||||||||||||||||||||||
174 | \l{Qt QML Models QML Types}{Qt QML Models} module. | - | ||||||||||||||||||||||||
175 | - | |||||||||||||||||||||||||
176 | \sa {QtQml.Models::DelegateModel} | - | ||||||||||||||||||||||||
177 | */ | - | ||||||||||||||||||||||||
178 | /*! | - | ||||||||||||||||||||||||
179 | \qmltype DelegateModel | - | ||||||||||||||||||||||||
180 | \instantiates QQmlDelegateModel | - | ||||||||||||||||||||||||
181 | \inqmlmodule QtQml.Models | - | ||||||||||||||||||||||||
182 | \brief Encapsulates a model and delegate. | - | ||||||||||||||||||||||||
183 | - | |||||||||||||||||||||||||
184 | The DelegateModel type encapsulates a model and the delegate that will | - | ||||||||||||||||||||||||
185 | be instantiated for items in the model. | - | ||||||||||||||||||||||||
186 | - | |||||||||||||||||||||||||
187 | It is usually not necessary to create a DelegateModel. | - | ||||||||||||||||||||||||
188 | However, it can be useful for manipulating and accessing the \l modelIndex | - | ||||||||||||||||||||||||
189 | when a QAbstractItemModel subclass is used as the | - | ||||||||||||||||||||||||
190 | model. Also, DelegateModel is used together with \l Package to | - | ||||||||||||||||||||||||
191 | provide delegates to multiple views, and with DelegateModelGroup to sort and filter | - | ||||||||||||||||||||||||
192 | delegate items. | - | ||||||||||||||||||||||||
193 | - | |||||||||||||||||||||||||
194 | The example below illustrates using a DelegateModel with a ListView. | - | ||||||||||||||||||||||||
195 | - | |||||||||||||||||||||||||
196 | \snippet delegatemodel/visualdatamodel.qml 0 | - | ||||||||||||||||||||||||
197 | - | |||||||||||||||||||||||||
198 | \note This type is also available as \l VisualDataModel in the \l{Qt QML} | - | ||||||||||||||||||||||||
199 | module due to compatibility reasons. | - | ||||||||||||||||||||||||
200 | */ | - | ||||||||||||||||||||||||
201 | - | |||||||||||||||||||||||||
202 | QQmlDelegateModelPrivate::QQmlDelegateModelPrivate(QQmlContext *ctxt) | - | ||||||||||||||||||||||||
203 | : m_cacheMetaType(nullptr) | - | ||||||||||||||||||||||||
204 | , m_context(ctxt) | - | ||||||||||||||||||||||||
205 | , m_parts(nullptr) | - | ||||||||||||||||||||||||
206 | , m_filterGroup(QStringLiteral("items")) | - | ||||||||||||||||||||||||
207 | , m_count(0) | - | ||||||||||||||||||||||||
208 | , m_groupCount(Compositor::MinimumGroupCount) | - | ||||||||||||||||||||||||
209 | , m_compositorGroup(Compositor::Cache) | - | ||||||||||||||||||||||||
210 | , m_complete(false) | - | ||||||||||||||||||||||||
211 | , m_delegateValidated(false) | - | ||||||||||||||||||||||||
212 | , m_reset(false) | - | ||||||||||||||||||||||||
213 | , m_transaction(false) | - | ||||||||||||||||||||||||
214 | , m_incubatorCleanupScheduled(false) | - | ||||||||||||||||||||||||
215 | , m_waitingToFetchMore(false) | - | ||||||||||||||||||||||||
216 | , m_useFirstColumnOnly(true) | - | ||||||||||||||||||||||||
217 | , m_cacheItems(nullptr) | - | ||||||||||||||||||||||||
218 | , m_items(nullptr) | - | ||||||||||||||||||||||||
219 | , m_persistedItems(nullptr) | - | ||||||||||||||||||||||||
220 | { | - | ||||||||||||||||||||||||
221 | } executed 5622 times by 27 tests: end of block Executed by:
| 5622 | ||||||||||||||||||||||||
222 | - | |||||||||||||||||||||||||
223 | QQmlDelegateModelPrivate::~QQmlDelegateModelPrivate() | - | ||||||||||||||||||||||||
224 | { | - | ||||||||||||||||||||||||
225 | qDeleteAll(m_finishedIncubating); | - | ||||||||||||||||||||||||
226 | - | |||||||||||||||||||||||||
227 | if (m_cacheMetaType)
| 0-5556 | ||||||||||||||||||||||||
228 | m_cacheMetaType->release(); executed 5556 times by 25 tests: m_cacheMetaType->release(); Executed by:
| 5556 | ||||||||||||||||||||||||
229 | } executed 5556 times by 25 tests: end of block Executed by:
| 5556 | ||||||||||||||||||||||||
230 | - | |||||||||||||||||||||||||
231 | int QQmlDelegateModelPrivate::adaptorModelCount() const | - | ||||||||||||||||||||||||
232 | { | - | ||||||||||||||||||||||||
233 | return m_useFirstColumnOnly ? m_adaptorModel.rowCount() : m_adaptorModel.count(); executed 6348 times by 27 tests: return m_useFirstColumnOnly ? m_adaptorModel.rowCount() : m_adaptorModel.count(); Executed by:
| 6348 | ||||||||||||||||||||||||
234 | } | - | ||||||||||||||||||||||||
235 | - | |||||||||||||||||||||||||
236 | void QQmlDelegateModelPrivate::requestMoreIfNecessary() | - | ||||||||||||||||||||||||
237 | { | - | ||||||||||||||||||||||||
238 | Q_Q(QQmlDelegateModel); | - | ||||||||||||||||||||||||
239 | if (!m_waitingToFetchMore && m_adaptorModel.canFetchMore()) {
| 2-14881 | ||||||||||||||||||||||||
240 | m_waitingToFetchMore = true; | - | ||||||||||||||||||||||||
241 | QCoreApplication::postEvent(q, new QEvent(QEvent::UpdateRequest)); | - | ||||||||||||||||||||||||
242 | } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||||||||
243 | } executed 14883 times by 27 tests: end of block Executed by:
| 14883 | ||||||||||||||||||||||||
244 | - | |||||||||||||||||||||||||
245 | void QQmlDelegateModelPrivate::init() | - | ||||||||||||||||||||||||
246 | { | - | ||||||||||||||||||||||||
247 | Q_Q(QQmlDelegateModel); | - | ||||||||||||||||||||||||
248 | m_compositor.setRemoveGroups(Compositor::GroupMask & ~Compositor::PersistedFlag); | - | ||||||||||||||||||||||||
249 | - | |||||||||||||||||||||||||
250 | m_items = new QQmlDelegateModelGroup(QStringLiteral("items"), q, Compositor::Default, q); executed 5622 times by 27 tests: return qstring_literal_temp; Executed by:
| 5622 | ||||||||||||||||||||||||
251 | m_items->setDefaultInclude(true); | - | ||||||||||||||||||||||||
252 | m_persistedItems = new QQmlDelegateModelGroup(QStringLiteral("persistedItems"), q, Compositor::Persisted, q); executed 5622 times by 27 tests: return qstring_literal_temp; Executed by:
| 5622 | ||||||||||||||||||||||||
253 | QQmlDelegateModelGroupPrivate::get(m_items)->emitters.insert(this); | - | ||||||||||||||||||||||||
254 | } executed 5622 times by 27 tests: end of block Executed by:
| 5622 | ||||||||||||||||||||||||
255 | - | |||||||||||||||||||||||||
256 | QQmlDelegateModel::QQmlDelegateModel() | - | ||||||||||||||||||||||||
257 | : QQmlDelegateModel(nullptr, nullptr) | - | ||||||||||||||||||||||||
258 | { | - | ||||||||||||||||||||||||
259 | } executed 760 times by 7 tests: end of block Executed by:
| 760 | ||||||||||||||||||||||||
260 | - | |||||||||||||||||||||||||
261 | QQmlDelegateModel::QQmlDelegateModel(QQmlContext *ctxt, QObject *parent) | - | ||||||||||||||||||||||||
262 | : QQmlInstanceModel(*(new QQmlDelegateModelPrivate(ctxt)), parent) | - | ||||||||||||||||||||||||
263 | { | - | ||||||||||||||||||||||||
264 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
265 | d->init(); | - | ||||||||||||||||||||||||
266 | } executed 5622 times by 27 tests: end of block Executed by:
| 5622 | ||||||||||||||||||||||||
267 | - | |||||||||||||||||||||||||
268 | QQmlDelegateModel::~QQmlDelegateModel() | - | ||||||||||||||||||||||||
269 | { | - | ||||||||||||||||||||||||
270 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
271 | d->m_adaptorModel.setObject(nullptr, this); | - | ||||||||||||||||||||||||
272 | - | |||||||||||||||||||||||||
273 | for (QQmlDelegateModelItem *cacheItem : qAsConst(d->m_cache)) { | - | ||||||||||||||||||||||||
274 | if (cacheItem->object) {
| 91-65876 | ||||||||||||||||||||||||
275 | delete cacheItem->object; | - | ||||||||||||||||||||||||
276 | - | |||||||||||||||||||||||||
277 | cacheItem->object = nullptr; | - | ||||||||||||||||||||||||
278 | cacheItem->contextData->invalidate(); | - | ||||||||||||||||||||||||
279 | Q_ASSERT(cacheItem->contextData->refCount == 1); | - | ||||||||||||||||||||||||
280 | cacheItem->contextData = nullptr; | - | ||||||||||||||||||||||||
281 | cacheItem->scriptRef -= 1; | - | ||||||||||||||||||||||||
282 | } executed 65876 times by 23 tests: end of block Executed by:
| 65876 | ||||||||||||||||||||||||
283 | cacheItem->groups &= ~Compositor::UnresolvedFlag; | - | ||||||||||||||||||||||||
284 | cacheItem->objectRef = 0; | - | ||||||||||||||||||||||||
285 | if (!cacheItem->isReferenced())
| 2022-63945 | ||||||||||||||||||||||||
286 | delete cacheItem; executed 63945 times by 23 tests: delete cacheItem; Executed by:
| 63945 | ||||||||||||||||||||||||
287 | else if (cacheItem->incubationTask)
| 36-1986 | ||||||||||||||||||||||||
288 | cacheItem->incubationTask->vdm = nullptr; executed 36 times by 2 tests: cacheItem->incubationTask->vdm = nullptr; Executed by:
| 36 | ||||||||||||||||||||||||
289 | } executed 65967 times by 23 tests: end of block Executed by:
| 65967 | ||||||||||||||||||||||||
290 | } executed 5556 times by 25 tests: end of block Executed by:
| 5556 | ||||||||||||||||||||||||
291 | - | |||||||||||||||||||||||||
292 | - | |||||||||||||||||||||||||
293 | void QQmlDelegateModel::classBegin() | - | ||||||||||||||||||||||||
294 | { | - | ||||||||||||||||||||||||
295 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
296 | if (!d->m_context)
| 16-760 | ||||||||||||||||||||||||
297 | d->m_context = qmlContext(this); executed 760 times by 7 tests: d->m_context = qmlContext(this); Executed by:
| 760 | ||||||||||||||||||||||||
298 | } executed 776 times by 8 tests: end of block Executed by:
| 776 | ||||||||||||||||||||||||
299 | - | |||||||||||||||||||||||||
300 | void QQmlDelegateModel::componentComplete() | - | ||||||||||||||||||||||||
301 | { | - | ||||||||||||||||||||||||
302 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
303 | d->m_complete = true; | - | ||||||||||||||||||||||||
304 | - | |||||||||||||||||||||||||
305 | int defaultGroups = 0; | - | ||||||||||||||||||||||||
306 | QStringList groupNames; | - | ||||||||||||||||||||||||
307 | groupNames.append(QStringLiteral("items")); executed 5622 times by 27 tests: return qstring_literal_temp; Executed by:
| 5622 | ||||||||||||||||||||||||
308 | groupNames.append(QStringLiteral("persistedItems")); executed 5622 times by 27 tests: return qstring_literal_temp; Executed by:
| 5622 | ||||||||||||||||||||||||
309 | if (QQmlDelegateModelGroupPrivate::get(d->m_items)->defaultInclude)
| 2-5620 | ||||||||||||||||||||||||
310 | defaultGroups |= Compositor::DefaultFlag; executed 5620 times by 27 tests: defaultGroups |= Compositor::DefaultFlag; Executed by:
| 5620 | ||||||||||||||||||||||||
311 | if (QQmlDelegateModelGroupPrivate::get(d->m_persistedItems)->defaultInclude)
| 2-5620 | ||||||||||||||||||||||||
312 | defaultGroups |= Compositor::PersistedFlag; executed 2 times by 1 test: defaultGroups |= Compositor::PersistedFlag; Executed by:
| 2 | ||||||||||||||||||||||||
313 | for (int i = Compositor::MinimumGroupCount; i < d->m_groupCount; ++i) {
| 1076-5622 | ||||||||||||||||||||||||
314 | QString name = d->m_groups[i]->name(); | - | ||||||||||||||||||||||||
315 | if (name.isEmpty()) {
| 2-1074 | ||||||||||||||||||||||||
316 | d->m_groups[i] = d->m_groups[d->m_groupCount - 1]; | - | ||||||||||||||||||||||||
317 | --d->m_groupCount; | - | ||||||||||||||||||||||||
318 | --i; | - | ||||||||||||||||||||||||
319 | } else if (name.at(0).isUpper()) { executed 2 times by 1 test: end of block Executed by:
| 2-1072 | ||||||||||||||||||||||||
320 | qmlWarning(d->m_groups[i]) << QQmlDelegateModelGroup::tr("Group names must start with a lower case letter"); | - | ||||||||||||||||||||||||
321 | d->m_groups[i] = d->m_groups[d->m_groupCount - 1]; | - | ||||||||||||||||||||||||
322 | --d->m_groupCount; | - | ||||||||||||||||||||||||
323 | --i; | - | ||||||||||||||||||||||||
324 | } else { executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
325 | groupNames.append(name); | - | ||||||||||||||||||||||||
326 | - | |||||||||||||||||||||||||
327 | QQmlDelegateModelGroupPrivate *group = QQmlDelegateModelGroupPrivate::get(d->m_groups[i]); | - | ||||||||||||||||||||||||
328 | group->setModel(this, Compositor::Group(i)); | - | ||||||||||||||||||||||||
329 | if (group->defaultInclude)
| 536 | ||||||||||||||||||||||||
330 | defaultGroups |= (1 << i); executed 536 times by 2 tests: defaultGroups |= (1 << i); Executed by:
| 536 | ||||||||||||||||||||||||
331 | } executed 1072 times by 2 tests: end of block Executed by:
| 1072 | ||||||||||||||||||||||||
332 | } | - | ||||||||||||||||||||||||
333 | - | |||||||||||||||||||||||||
334 | d->m_cacheMetaType = new QQmlDelegateModelItemMetaType( | - | ||||||||||||||||||||||||
335 | d->m_context->engine()->handle(), this, groupNames); | - | ||||||||||||||||||||||||
336 | - | |||||||||||||||||||||||||
337 | d->m_compositor.setGroupCount(d->m_groupCount); | - | ||||||||||||||||||||||||
338 | d->m_compositor.setDefaultGroups(defaultGroups); | - | ||||||||||||||||||||||||
339 | d->updateFilterGroup(); | - | ||||||||||||||||||||||||
340 | - | |||||||||||||||||||||||||
341 | while (!d->m_pendingParts.isEmpty())
| 0-5622 | ||||||||||||||||||||||||
342 | static_cast<QQmlPartsModel *>(d->m_pendingParts.first())->updateFilterGroup(); never executed: static_cast<QQmlPartsModel *>(d->m_pendingParts.first())->updateFilterGroup(); | 0 | ||||||||||||||||||||||||
343 | - | |||||||||||||||||||||||||
344 | QVector<Compositor::Insert> inserts; | - | ||||||||||||||||||||||||
345 | d->m_count = d->adaptorModelCount(); | - | ||||||||||||||||||||||||
346 | d->m_compositor.append( | - | ||||||||||||||||||||||||
347 | &d->m_adaptorModel, | - | ||||||||||||||||||||||||
348 | 0, | - | ||||||||||||||||||||||||
349 | d->m_count, | - | ||||||||||||||||||||||||
350 | defaultGroups | Compositor::AppendFlag | Compositor::PrependFlag, | - | ||||||||||||||||||||||||
351 | &inserts); | - | ||||||||||||||||||||||||
352 | d->itemsInserted(inserts); | - | ||||||||||||||||||||||||
353 | d->emitChanges(); | - | ||||||||||||||||||||||||
354 | d->requestMoreIfNecessary(); | - | ||||||||||||||||||||||||
355 | } executed 5622 times by 27 tests: end of block Executed by:
| 5622 | ||||||||||||||||||||||||
356 | - | |||||||||||||||||||||||||
357 | /*! | - | ||||||||||||||||||||||||
358 | \qmlproperty model QtQml.Models::DelegateModel::model | - | ||||||||||||||||||||||||
359 | This property holds the model providing data for the DelegateModel. | - | ||||||||||||||||||||||||
360 | - | |||||||||||||||||||||||||
361 | The model provides a set of data that is used to create the items | - | ||||||||||||||||||||||||
362 | for a view. For large or dynamic datasets the model is usually | - | ||||||||||||||||||||||||
363 | provided by a C++ model object. The C++ model object must be a \l | - | ||||||||||||||||||||||||
364 | {QAbstractItemModel} subclass or a simple list. | - | ||||||||||||||||||||||||
365 | - | |||||||||||||||||||||||||
366 | Models can also be created directly in QML, using a \l{ListModel} or | - | ||||||||||||||||||||||||
367 | \l{XmlListModel}. | - | ||||||||||||||||||||||||
368 | - | |||||||||||||||||||||||||
369 | \sa {qml-data-models}{Data Models} | - | ||||||||||||||||||||||||
370 | */ | - | ||||||||||||||||||||||||
371 | QVariant QQmlDelegateModel::model() const | - | ||||||||||||||||||||||||
372 | { | - | ||||||||||||||||||||||||
373 | Q_D(const QQmlDelegateModel); | - | ||||||||||||||||||||||||
374 | return d->m_adaptorModel.model(); executed 8 times by 1 test: return d->m_adaptorModel.model(); Executed by:
| 8 | ||||||||||||||||||||||||
375 | } | - | ||||||||||||||||||||||||
376 | - | |||||||||||||||||||||||||
377 | void QQmlDelegateModel::setModel(const QVariant &model) | - | ||||||||||||||||||||||||
378 | { | - | ||||||||||||||||||||||||
379 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
380 | - | |||||||||||||||||||||||||
381 | if (d->m_complete)
| 648-4316 | ||||||||||||||||||||||||
382 | _q_itemsRemoved(0, d->m_count); executed 648 times by 12 tests: _q_itemsRemoved(0, d->m_count); Executed by:
| 648 | ||||||||||||||||||||||||
383 | - | |||||||||||||||||||||||||
384 | d->m_adaptorModel.setModel(model, this, d->m_context->engine()); | - | ||||||||||||||||||||||||
385 | d->m_adaptorModel.replaceWatchedRoles(QList<QByteArray>(), d->m_watchedRoles); | - | ||||||||||||||||||||||||
386 | for (int i = 0; d->m_parts && i < d->m_parts->models.count(); ++i) {
| 136-4828 | ||||||||||||||||||||||||
387 | d->m_adaptorModel.replaceWatchedRoles( | - | ||||||||||||||||||||||||
388 | QList<QByteArray>(), d->m_parts->models.at(i)->watchedRoles()); | - | ||||||||||||||||||||||||
389 | } executed 146 times by 5 tests: end of block Executed by:
| 146 | ||||||||||||||||||||||||
390 | - | |||||||||||||||||||||||||
391 | if (d->m_complete) {
| 648-4316 | ||||||||||||||||||||||||
392 | _q_itemsInserted(0, d->adaptorModelCount()); | - | ||||||||||||||||||||||||
393 | d->requestMoreIfNecessary(); | - | ||||||||||||||||||||||||
394 | } executed 648 times by 12 tests: end of block Executed by:
| 648 | ||||||||||||||||||||||||
395 | } executed 4964 times by 25 tests: end of block Executed by:
| 4964 | ||||||||||||||||||||||||
396 | - | |||||||||||||||||||||||||
397 | /*! | - | ||||||||||||||||||||||||
398 | \qmlproperty Component QtQml.Models::DelegateModel::delegate | - | ||||||||||||||||||||||||
399 | - | |||||||||||||||||||||||||
400 | The delegate provides a template defining each item instantiated by a view. | - | ||||||||||||||||||||||||
401 | The index is exposed as an accessible \c index property. Properties of the | - | ||||||||||||||||||||||||
402 | model are also available depending upon the type of \l {qml-data-models}{Data Model}. | - | ||||||||||||||||||||||||
403 | */ | - | ||||||||||||||||||||||||
404 | QQmlComponent *QQmlDelegateModel::delegate() const | - | ||||||||||||||||||||||||
405 | { | - | ||||||||||||||||||||||||
406 | Q_D(const QQmlDelegateModel); | - | ||||||||||||||||||||||||
407 | return d->m_delegate; executed 91304 times by 25 tests: return d->m_delegate; Executed by:
| 91304 | ||||||||||||||||||||||||
408 | } | - | ||||||||||||||||||||||||
409 | - | |||||||||||||||||||||||||
410 | void QQmlDelegateModel::setDelegate(QQmlComponent *delegate) | - | ||||||||||||||||||||||||
411 | { | - | ||||||||||||||||||||||||
412 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
413 | if (d->m_transaction) {
| 0-5616 | ||||||||||||||||||||||||
414 | qmlWarning(this) << tr("The delegate of a DelegateModel cannot be changed within onUpdated."); | - | ||||||||||||||||||||||||
415 | return; never executed: return; | 0 | ||||||||||||||||||||||||
416 | } | - | ||||||||||||||||||||||||
417 | bool wasValid = d->m_delegate != nullptr; | - | ||||||||||||||||||||||||
418 | d->m_delegate.setObject(delegate, this); | - | ||||||||||||||||||||||||
419 | d->m_delegateValidated = false; | - | ||||||||||||||||||||||||
420 | if (wasValid && d->m_complete) {
| 0-5598 | ||||||||||||||||||||||||
421 | for (int i = 1; i < d->m_groupCount; ++i) {
| 18-36 | ||||||||||||||||||||||||
422 | QQmlDelegateModelGroupPrivate::get(d->m_groups[i])->changeSet.remove( | - | ||||||||||||||||||||||||
423 | 0, d->m_compositor.count(Compositor::Group(i))); | - | ||||||||||||||||||||||||
424 | } executed 36 times by 5 tests: end of block Executed by:
| 36 | ||||||||||||||||||||||||
425 | } executed 18 times by 5 tests: end of block Executed by:
| 18 | ||||||||||||||||||||||||
426 | if (d->m_complete && d->m_delegate) {
| 20-5596 | ||||||||||||||||||||||||
427 | for (int i = 1; i < d->m_groupCount; ++i) {
| 14-28 | ||||||||||||||||||||||||
428 | QQmlDelegateModelGroupPrivate::get(d->m_groups[i])->changeSet.insert( | - | ||||||||||||||||||||||||
429 | 0, d->m_compositor.count(Compositor::Group(i))); | - | ||||||||||||||||||||||||
430 | } executed 28 times by 4 tests: end of block Executed by:
| 28 | ||||||||||||||||||||||||
431 | } executed 14 times by 4 tests: end of block Executed by:
| 14 | ||||||||||||||||||||||||
432 | d->emitChanges(); | - | ||||||||||||||||||||||||
433 | } executed 5616 times by 26 tests: end of block Executed by:
| 5616 | ||||||||||||||||||||||||
434 | - | |||||||||||||||||||||||||
435 | /*! | - | ||||||||||||||||||||||||
436 | \qmlproperty QModelIndex QtQml.Models::DelegateModel::rootIndex | - | ||||||||||||||||||||||||
437 | - | |||||||||||||||||||||||||
438 | QAbstractItemModel provides a hierarchical tree of data, whereas | - | ||||||||||||||||||||||||
439 | QML only operates on list data. \c rootIndex allows the children of | - | ||||||||||||||||||||||||
440 | any node in a QAbstractItemModel to be provided by this model. | - | ||||||||||||||||||||||||
441 | - | |||||||||||||||||||||||||
442 | This property only affects models of type QAbstractItemModel that | - | ||||||||||||||||||||||||
443 | are hierarchical (e.g, a tree model). | - | ||||||||||||||||||||||||
444 | - | |||||||||||||||||||||||||
445 | For example, here is a simple interactive file system browser. | - | ||||||||||||||||||||||||
446 | When a directory name is clicked, the view's \c rootIndex is set to the | - | ||||||||||||||||||||||||
447 | QModelIndex node of the clicked directory, thus updating the view to show | - | ||||||||||||||||||||||||
448 | the new directory's contents. | - | ||||||||||||||||||||||||
449 | - | |||||||||||||||||||||||||
450 | \c main.cpp: | - | ||||||||||||||||||||||||
451 | \snippet delegatemodel/visualdatamodel_rootindex/main.cpp 0 | - | ||||||||||||||||||||||||
452 | - | |||||||||||||||||||||||||
453 | \c view.qml: | - | ||||||||||||||||||||||||
454 | \snippet delegatemodel/visualdatamodel_rootindex/view.qml 0 | - | ||||||||||||||||||||||||
455 | - | |||||||||||||||||||||||||
456 | If the \l model is a QAbstractItemModel subclass, the delegate can also | - | ||||||||||||||||||||||||
457 | reference a \c hasModelChildren property (optionally qualified by a | - | ||||||||||||||||||||||||
458 | \e model. prefix) that indicates whether the delegate's model item has | - | ||||||||||||||||||||||||
459 | any child nodes. | - | ||||||||||||||||||||||||
460 | - | |||||||||||||||||||||||||
461 | - | |||||||||||||||||||||||||
462 | \sa modelIndex(), parentModelIndex() | - | ||||||||||||||||||||||||
463 | */ | - | ||||||||||||||||||||||||
464 | QVariant QQmlDelegateModel::rootIndex() const | - | ||||||||||||||||||||||||
465 | { | - | ||||||||||||||||||||||||
466 | Q_D(const QQmlDelegateModel); | - | ||||||||||||||||||||||||
467 | return QVariant::fromValue(QModelIndex(d->m_adaptorModel.rootIndex)); executed 22 times by 1 test: return QVariant::fromValue(QModelIndex(d->m_adaptorModel.rootIndex)); Executed by:
| 22 | ||||||||||||||||||||||||
468 | } | - | ||||||||||||||||||||||||
469 | - | |||||||||||||||||||||||||
470 | void QQmlDelegateModel::setRootIndex(const QVariant &root) | - | ||||||||||||||||||||||||
471 | { | - | ||||||||||||||||||||||||
472 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
473 | - | |||||||||||||||||||||||||
474 | QModelIndex modelIndex = qvariant_cast<QModelIndex>(root); | - | ||||||||||||||||||||||||
475 | const bool changed = d->m_adaptorModel.rootIndex != modelIndex; | - | ||||||||||||||||||||||||
476 | if (changed || !d->m_adaptorModel.isValid()) {
| 2-24 | ||||||||||||||||||||||||
477 | const int oldCount = d->m_count; | - | ||||||||||||||||||||||||
478 | d->m_adaptorModel.rootIndex = modelIndex; | - | ||||||||||||||||||||||||
479 | if (!d->m_adaptorModel.isValid() && d->m_adaptorModel.aim()) // The previous root index was invalidated, so we need to reconnect the model.
| 0-24 | ||||||||||||||||||||||||
480 | d->m_adaptorModel.setModel(d->m_adaptorModel.list.list(), this, d->m_context->engine()); executed 2 times by 1 test: d->m_adaptorModel.setModel(d->m_adaptorModel.list.list(), this, d->m_context->engine()); Executed by:
| 2 | ||||||||||||||||||||||||
481 | if (d->m_adaptorModel.canFetchMore())
| 0-26 | ||||||||||||||||||||||||
482 | d->m_adaptorModel.fetchMore(); never executed: d->m_adaptorModel.fetchMore(); | 0 | ||||||||||||||||||||||||
483 | if (d->m_complete) {
| 0-26 | ||||||||||||||||||||||||
484 | const int newCount = d->adaptorModelCount(); | - | ||||||||||||||||||||||||
485 | if (oldCount)
| 4-22 | ||||||||||||||||||||||||
486 | _q_itemsRemoved(0, oldCount); executed 22 times by 3 tests: _q_itemsRemoved(0, oldCount); Executed by:
| 22 | ||||||||||||||||||||||||
487 | if (newCount)
| 6-20 | ||||||||||||||||||||||||
488 | _q_itemsInserted(0, newCount); executed 20 times by 3 tests: _q_itemsInserted(0, newCount); Executed by:
| 20 | ||||||||||||||||||||||||
489 | } executed 26 times by 3 tests: end of block Executed by:
| 26 | ||||||||||||||||||||||||
490 | if (changed)
| 2-24 | ||||||||||||||||||||||||
491 | emit rootIndexChanged(); executed 24 times by 3 tests: rootIndexChanged(); Executed by:
| 24 | ||||||||||||||||||||||||
492 | } executed 26 times by 3 tests: end of block Executed by:
| 26 | ||||||||||||||||||||||||
493 | } executed 28 times by 3 tests: end of block Executed by:
| 28 | ||||||||||||||||||||||||
494 | - | |||||||||||||||||||||||||
495 | /*! | - | ||||||||||||||||||||||||
496 | \qmlproperty int QtQml.Models::DelegateModel::rows | - | ||||||||||||||||||||||||
497 | - | |||||||||||||||||||||||||
498 | Contains the number of rows in the model. If the model | - | ||||||||||||||||||||||||
499 | is a list of items, it will be equal to the number of items | - | ||||||||||||||||||||||||
500 | in the list. | - | ||||||||||||||||||||||||
501 | - | |||||||||||||||||||||||||
502 | \since QtQml.Models 2.12 | - | ||||||||||||||||||||||||
503 | */ | - | ||||||||||||||||||||||||
504 | int QQmlDelegateModel::rows() const | - | ||||||||||||||||||||||||
505 | { | - | ||||||||||||||||||||||||
506 | Q_D(const QQmlDelegateModel); | - | ||||||||||||||||||||||||
507 | return d->m_adaptorModel.rowCount(); executed 102 times by 1 test: return d->m_adaptorModel.rowCount(); Executed by:
| 102 | ||||||||||||||||||||||||
508 | } | - | ||||||||||||||||||||||||
509 | - | |||||||||||||||||||||||||
510 | /*! | - | ||||||||||||||||||||||||
511 | \qmlproperty int QtQml.Models::DelegateModel::columns | - | ||||||||||||||||||||||||
512 | - | |||||||||||||||||||||||||
513 | Contains the number of columns in the model. If the model | - | ||||||||||||||||||||||||
514 | is a list of items, it will be equal to \c 1. | - | ||||||||||||||||||||||||
515 | - | |||||||||||||||||||||||||
516 | \since QtQml.Models 2.12 | - | ||||||||||||||||||||||||
517 | */ | - | ||||||||||||||||||||||||
518 | int QQmlDelegateModel::columns() const | - | ||||||||||||||||||||||||
519 | { | - | ||||||||||||||||||||||||
520 | Q_D(const QQmlDelegateModel); | - | ||||||||||||||||||||||||
521 | return d->m_adaptorModel.columnCount(); executed 102 times by 1 test: return d->m_adaptorModel.columnCount(); Executed by:
| 102 | ||||||||||||||||||||||||
522 | } | - | ||||||||||||||||||||||||
523 | - | |||||||||||||||||||||||||
524 | /*! | - | ||||||||||||||||||||||||
525 | \qmlmethod QModelIndex QtQml.Models::DelegateModel::modelIndex(int index) | - | ||||||||||||||||||||||||
526 | - | |||||||||||||||||||||||||
527 | QAbstractItemModel provides a hierarchical tree of data, whereas | - | ||||||||||||||||||||||||
528 | QML only operates on list data. This function assists in using | - | ||||||||||||||||||||||||
529 | tree models in QML. | - | ||||||||||||||||||||||||
530 | - | |||||||||||||||||||||||||
531 | Returns a QModelIndex for the specified index. | - | ||||||||||||||||||||||||
532 | This value can be assigned to rootIndex. | - | ||||||||||||||||||||||||
533 | - | |||||||||||||||||||||||||
534 | \sa rootIndex | - | ||||||||||||||||||||||||
535 | */ | - | ||||||||||||||||||||||||
536 | QVariant QQmlDelegateModel::modelIndex(int idx) const | - | ||||||||||||||||||||||||
537 | { | - | ||||||||||||||||||||||||
538 | Q_D(const QQmlDelegateModel); | - | ||||||||||||||||||||||||
539 | return d->m_adaptorModel.modelIndex(idx); executed 6 times by 2 tests: return d->m_adaptorModel.modelIndex(idx); Executed by:
| 6 | ||||||||||||||||||||||||
540 | } | - | ||||||||||||||||||||||||
541 | - | |||||||||||||||||||||||||
542 | /*! | - | ||||||||||||||||||||||||
543 | \qmlmethod QModelIndex QtQml.Models::DelegateModel::parentModelIndex() | - | ||||||||||||||||||||||||
544 | - | |||||||||||||||||||||||||
545 | QAbstractItemModel provides a hierarchical tree of data, whereas | - | ||||||||||||||||||||||||
546 | QML only operates on list data. This function assists in using | - | ||||||||||||||||||||||||
547 | tree models in QML. | - | ||||||||||||||||||||||||
548 | - | |||||||||||||||||||||||||
549 | Returns a QModelIndex for the parent of the current rootIndex. | - | ||||||||||||||||||||||||
550 | This value can be assigned to rootIndex. | - | ||||||||||||||||||||||||
551 | - | |||||||||||||||||||||||||
552 | \sa rootIndex | - | ||||||||||||||||||||||||
553 | */ | - | ||||||||||||||||||||||||
554 | QVariant QQmlDelegateModel::parentModelIndex() const | - | ||||||||||||||||||||||||
555 | { | - | ||||||||||||||||||||||||
556 | Q_D(const QQmlDelegateModel); | - | ||||||||||||||||||||||||
557 | return d->m_adaptorModel.parentModelIndex(); executed 2 times by 1 test: return d->m_adaptorModel.parentModelIndex(); Executed by:
| 2 | ||||||||||||||||||||||||
558 | } | - | ||||||||||||||||||||||||
559 | - | |||||||||||||||||||||||||
560 | /*! | - | ||||||||||||||||||||||||
561 | \qmlproperty int QtQml.Models::DelegateModel::count | - | ||||||||||||||||||||||||
562 | */ | - | ||||||||||||||||||||||||
563 | - | |||||||||||||||||||||||||
564 | int QQmlDelegateModel::count() const | - | ||||||||||||||||||||||||
565 | { | - | ||||||||||||||||||||||||
566 | Q_D(const QQmlDelegateModel); | - | ||||||||||||||||||||||||
567 | if (!d->m_delegate)
| 3754-457981 | ||||||||||||||||||||||||
568 | return 0; executed 3754 times by 14 tests: return 0; Executed by:
| 3754 | ||||||||||||||||||||||||
569 | return d->m_compositor.count(d->m_compositorGroup); executed 457981 times by 25 tests: return d->m_compositor.count(d->m_compositorGroup); Executed by:
| 457981 | ||||||||||||||||||||||||
570 | } | - | ||||||||||||||||||||||||
571 | - | |||||||||||||||||||||||||
572 | QQmlDelegateModel::ReleaseFlags QQmlDelegateModelPrivate::release(QObject *object) | - | ||||||||||||||||||||||||
573 | { | - | ||||||||||||||||||||||||
574 | if (!object)
| 2-103163 | ||||||||||||||||||||||||
575 | return QQmlDelegateModel::ReleaseFlags(0); executed 2 times by 1 test: return QQmlDelegateModel::ReleaseFlags(0); Executed by:
| 2 | ||||||||||||||||||||||||
576 | - | |||||||||||||||||||||||||
577 | QQmlDelegateModelItem *cacheItem = QQmlDelegateModelItem::dataForObject(object); | - | ||||||||||||||||||||||||
578 | if (!cacheItem)
| 36665-66498 | ||||||||||||||||||||||||
579 | return QQmlDelegateModel::ReleaseFlags(0); executed 66498 times by 23 tests: return QQmlDelegateModel::ReleaseFlags(0); Executed by:
| 66498 | ||||||||||||||||||||||||
580 | - | |||||||||||||||||||||||||
581 | if (!cacheItem->releaseObject())
| 14407-22258 | ||||||||||||||||||||||||
582 | return QQmlDelegateModel::Referenced; executed 14407 times by 19 tests: return QQmlDelegateModel::Referenced; Executed by:
| 14407 | ||||||||||||||||||||||||
583 | - | |||||||||||||||||||||||||
584 | cacheItem->destroyObject(); | - | ||||||||||||||||||||||||
585 | emitDestroyingItem(object); | - | ||||||||||||||||||||||||
586 | if (cacheItem->incubationTask) {
| 0-22258 | ||||||||||||||||||||||||
587 | releaseIncubator(cacheItem->incubationTask); | - | ||||||||||||||||||||||||
588 | cacheItem->incubationTask = nullptr; | - | ||||||||||||||||||||||||
589 | } never executed: end of block | 0 | ||||||||||||||||||||||||
590 | cacheItem->Dispose(); | - | ||||||||||||||||||||||||
591 | return QQmlInstanceModel::Destroyed; executed 22258 times by 12 tests: return QQmlInstanceModel::Destroyed; Executed by:
| 22258 | ||||||||||||||||||||||||
592 | } | - | ||||||||||||||||||||||||
593 | - | |||||||||||||||||||||||||
594 | /* | - | ||||||||||||||||||||||||
595 | Returns ReleaseStatus flags. | - | ||||||||||||||||||||||||
596 | */ | - | ||||||||||||||||||||||||
597 | - | |||||||||||||||||||||||||
598 | QQmlDelegateModel::ReleaseFlags QQmlDelegateModel::release(QObject *item) | - | ||||||||||||||||||||||||
599 | { | - | ||||||||||||||||||||||||
600 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
601 | QQmlInstanceModel::ReleaseFlags stat = d->release(item); | - | ||||||||||||||||||||||||
602 | return stat; executed 99859 times by 24 tests: return stat; Executed by:
| 99859 | ||||||||||||||||||||||||
603 | } | - | ||||||||||||||||||||||||
604 | - | |||||||||||||||||||||||||
605 | // Cancel a requested async item | - | ||||||||||||||||||||||||
606 | void QQmlDelegateModel::cancel(int index) | - | ||||||||||||||||||||||||
607 | { | - | ||||||||||||||||||||||||
608 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
609 | if (!d->m_delegate || index < 0 || index >= d->m_compositor.count(d->m_compositorGroup)) {
| 0-50 | ||||||||||||||||||||||||
610 | qWarning() << "DelegateModel::cancel: index out range" << index << d->m_compositor.count(d->m_compositorGroup); | - | ||||||||||||||||||||||||
611 | return; executed 50 times by 2 tests: return; Executed by:
| 50 | ||||||||||||||||||||||||
612 | } | - | ||||||||||||||||||||||||
613 | - | |||||||||||||||||||||||||
614 | Compositor::iterator it = d->m_compositor.find(d->m_compositorGroup, index); | - | ||||||||||||||||||||||||
615 | QQmlDelegateModelItem *cacheItem = it->inCache() ? d->m_cache.at(it.cacheIndex) : 0;
| 0-31 | ||||||||||||||||||||||||
616 | if (cacheItem) {
| 0-31 | ||||||||||||||||||||||||
617 | if (cacheItem->incubationTask && !cacheItem->isObjectReferenced()) {
| 0-31 | ||||||||||||||||||||||||
618 | d->releaseIncubator(cacheItem->incubationTask); | - | ||||||||||||||||||||||||
619 | cacheItem->incubationTask = nullptr; | - | ||||||||||||||||||||||||
620 | - | |||||||||||||||||||||||||
621 | if (cacheItem->object) {
| 0-31 | ||||||||||||||||||||||||
622 | QObject *object = cacheItem->object; | - | ||||||||||||||||||||||||
623 | cacheItem->destroyObject(); | - | ||||||||||||||||||||||||
624 | if (QQuickPackage *package = qmlobject_cast<QQuickPackage *>(object))
| 0 | ||||||||||||||||||||||||
625 | d->emitDestroyingPackage(package); never executed: d->emitDestroyingPackage(package); | 0 | ||||||||||||||||||||||||
626 | else | - | ||||||||||||||||||||||||
627 | d->emitDestroyingItem(object); never executed: d->emitDestroyingItem(object); | 0 | ||||||||||||||||||||||||
628 | } | - | ||||||||||||||||||||||||
629 | - | |||||||||||||||||||||||||
630 | cacheItem->scriptRef -= 1; | - | ||||||||||||||||||||||||
631 | } executed 31 times by 3 tests: end of block Executed by:
| 31 | ||||||||||||||||||||||||
632 | if (!cacheItem->isReferenced()) {
| 0-31 | ||||||||||||||||||||||||
633 | d->m_compositor.clearFlags(Compositor::Cache, it.cacheIndex, 1, Compositor::CacheFlag); | - | ||||||||||||||||||||||||
634 | d->m_cache.removeAt(it.cacheIndex); | - | ||||||||||||||||||||||||
635 | delete cacheItem; | - | ||||||||||||||||||||||||
636 | Q_ASSERT(d->m_cache.count() == d->m_compositor.count(Compositor::Cache)); | - | ||||||||||||||||||||||||
637 | } executed 31 times by 3 tests: end of block Executed by:
| 31 | ||||||||||||||||||||||||
638 | } executed 31 times by 3 tests: end of block Executed by:
| 31 | ||||||||||||||||||||||||
639 | } executed 31 times by 3 tests: end of block Executed by:
| 31 | ||||||||||||||||||||||||
640 | - | |||||||||||||||||||||||||
641 | void QQmlDelegateModelPrivate::group_append( | - | ||||||||||||||||||||||||
642 | QQmlListProperty<QQmlDelegateModelGroup> *property, QQmlDelegateModelGroup *group) | - | ||||||||||||||||||||||||
643 | { | - | ||||||||||||||||||||||||
644 | QQmlDelegateModelPrivate *d = static_cast<QQmlDelegateModelPrivate *>(property->data); | - | ||||||||||||||||||||||||
645 | if (d->m_complete)
| 0-1076 | ||||||||||||||||||||||||
646 | return; never executed: return; | 0 | ||||||||||||||||||||||||
647 | if (d->m_groupCount == Compositor::MaximumGroupCount) {
| 0-1076 | ||||||||||||||||||||||||
648 | qmlWarning(d->q_func()) << QQmlDelegateModel::tr("The maximum number of supported DelegateModelGroups is 8"); | - | ||||||||||||||||||||||||
649 | return; never executed: return; | 0 | ||||||||||||||||||||||||
650 | } | - | ||||||||||||||||||||||||
651 | d->m_groups[d->m_groupCount] = group; | - | ||||||||||||||||||||||||
652 | d->m_groupCount += 1; | - | ||||||||||||||||||||||||
653 | } executed 1076 times by 2 tests: end of block Executed by:
| 1076 | ||||||||||||||||||||||||
654 | - | |||||||||||||||||||||||||
655 | int QQmlDelegateModelPrivate::group_count( | - | ||||||||||||||||||||||||
656 | QQmlListProperty<QQmlDelegateModelGroup> *property) | - | ||||||||||||||||||||||||
657 | { | - | ||||||||||||||||||||||||
658 | QQmlDelegateModelPrivate *d = static_cast<QQmlDelegateModelPrivate *>(property->data); | - | ||||||||||||||||||||||||
659 | return d->m_groupCount - 1; executed 10 times by 1 test: return d->m_groupCount - 1; Executed by:
| 10 | ||||||||||||||||||||||||
660 | } | - | ||||||||||||||||||||||||
661 | - | |||||||||||||||||||||||||
662 | QQmlDelegateModelGroup *QQmlDelegateModelPrivate::group_at( | - | ||||||||||||||||||||||||
663 | QQmlListProperty<QQmlDelegateModelGroup> *property, int index) | - | ||||||||||||||||||||||||
664 | { | - | ||||||||||||||||||||||||
665 | QQmlDelegateModelPrivate *d = static_cast<QQmlDelegateModelPrivate *>(property->data); | - | ||||||||||||||||||||||||
666 | return index >= 0 && index < d->m_groupCount - 1 executed 8 times by 1 test: return index >= 0 && index < d->m_groupCount - 1 ? d->m_groups[index + 1] : nullptr; Executed by:
| 8 | ||||||||||||||||||||||||
667 | ? d->m_groups[index + 1] executed 8 times by 1 test: return index >= 0 && index < d->m_groupCount - 1 ? d->m_groups[index + 1] : nullptr; Executed by:
| 8 | ||||||||||||||||||||||||
668 | : nullptr; executed 8 times by 1 test: return index >= 0 && index < d->m_groupCount - 1 ? d->m_groups[index + 1] : nullptr; Executed by:
| 8 | ||||||||||||||||||||||||
669 | } | - | ||||||||||||||||||||||||
670 | - | |||||||||||||||||||||||||
671 | /*! | - | ||||||||||||||||||||||||
672 | \qmlproperty list<DelegateModelGroup> QtQml.Models::DelegateModel::groups | - | ||||||||||||||||||||||||
673 | - | |||||||||||||||||||||||||
674 | This property holds a delegate model's group definitions. | - | ||||||||||||||||||||||||
675 | - | |||||||||||||||||||||||||
676 | Groups define a sub-set of the items in a delegate model and can be used to filter | - | ||||||||||||||||||||||||
677 | a model. | - | ||||||||||||||||||||||||
678 | - | |||||||||||||||||||||||||
679 | For every group defined in a DelegateModel two attached properties are added to each | - | ||||||||||||||||||||||||
680 | delegate item. The first of the form DelegateModel.in\e{GroupName} holds whether the | - | ||||||||||||||||||||||||
681 | item belongs to the group and the second DelegateModel.\e{groupName}Index holds the | - | ||||||||||||||||||||||||
682 | index of the item in that group. | - | ||||||||||||||||||||||||
683 | - | |||||||||||||||||||||||||
684 | The following example illustrates using groups to select items in a model. | - | ||||||||||||||||||||||||
685 | - | |||||||||||||||||||||||||
686 | \snippet delegatemodel/visualdatagroup.qml 0 | - | ||||||||||||||||||||||||
687 | */ | - | ||||||||||||||||||||||||
688 | - | |||||||||||||||||||||||||
689 | QQmlListProperty<QQmlDelegateModelGroup> QQmlDelegateModel::groups() | - | ||||||||||||||||||||||||
690 | { | - | ||||||||||||||||||||||||
691 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
692 | return QQmlListProperty<QQmlDelegateModelGroup>( executed 548 times by 2 tests: return QQmlListProperty<QQmlDelegateModelGroup>( this, d, QQmlDelegateModelPrivate::group_append, QQmlDelegateModelPrivate::group_count, QQmlDelegateModelPrivate::group_at, nullptr); Executed by:
| 548 | ||||||||||||||||||||||||
693 | this, executed 548 times by 2 tests: return QQmlListProperty<QQmlDelegateModelGroup>( this, d, QQmlDelegateModelPrivate::group_append, QQmlDelegateModelPrivate::group_count, QQmlDelegateModelPrivate::group_at, nullptr); Executed by:
| 548 | ||||||||||||||||||||||||
694 | d, executed 548 times by 2 tests: return QQmlListProperty<QQmlDelegateModelGroup>( this, d, QQmlDelegateModelPrivate::group_append, QQmlDelegateModelPrivate::group_count, QQmlDelegateModelPrivate::group_at, nullptr); Executed by:
| 548 | ||||||||||||||||||||||||
695 | QQmlDelegateModelPrivate::group_append, executed 548 times by 2 tests: return QQmlListProperty<QQmlDelegateModelGroup>( this, d, QQmlDelegateModelPrivate::group_append, QQmlDelegateModelPrivate::group_count, QQmlDelegateModelPrivate::group_at, nullptr); Executed by:
| 548 | ||||||||||||||||||||||||
696 | QQmlDelegateModelPrivate::group_count, executed 548 times by 2 tests: return QQmlListProperty<QQmlDelegateModelGroup>( this, d, QQmlDelegateModelPrivate::group_append, QQmlDelegateModelPrivate::group_count, QQmlDelegateModelPrivate::group_at, nullptr); Executed by:
| 548 | ||||||||||||||||||||||||
697 | QQmlDelegateModelPrivate::group_at, executed 548 times by 2 tests: return QQmlListProperty<QQmlDelegateModelGroup>( this, d, QQmlDelegateModelPrivate::group_append, QQmlDelegateModelPrivate::group_count, QQmlDelegateModelPrivate::group_at, nullptr); Executed by:
| 548 | ||||||||||||||||||||||||
698 | nullptr); executed 548 times by 2 tests: return QQmlListProperty<QQmlDelegateModelGroup>( this, d, QQmlDelegateModelPrivate::group_append, QQmlDelegateModelPrivate::group_count, QQmlDelegateModelPrivate::group_at, nullptr); Executed by:
| 548 | ||||||||||||||||||||||||
699 | } | - | ||||||||||||||||||||||||
700 | - | |||||||||||||||||||||||||
701 | /*! | - | ||||||||||||||||||||||||
702 | \qmlproperty DelegateModelGroup QtQml.Models::DelegateModel::items | - | ||||||||||||||||||||||||
703 | - | |||||||||||||||||||||||||
704 | This property holds visual data model's default group to which all new items are added. | - | ||||||||||||||||||||||||
705 | */ | - | ||||||||||||||||||||||||
706 | - | |||||||||||||||||||||||||
707 | QQmlDelegateModelGroup *QQmlDelegateModel::items() | - | ||||||||||||||||||||||||
708 | { | - | ||||||||||||||||||||||||
709 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
710 | return d->m_items; executed 25934 times by 3 tests: return d->m_items; Executed by:
| 25934 | ||||||||||||||||||||||||
711 | } | - | ||||||||||||||||||||||||
712 | - | |||||||||||||||||||||||||
713 | /*! | - | ||||||||||||||||||||||||
714 | \qmlproperty DelegateModelGroup QtQml.Models::DelegateModel::persistedItems | - | ||||||||||||||||||||||||
715 | - | |||||||||||||||||||||||||
716 | This property holds visual data model's persisted items group. | - | ||||||||||||||||||||||||
717 | - | |||||||||||||||||||||||||
718 | Items in this group are not destroyed when released by a view, instead they are persisted | - | ||||||||||||||||||||||||
719 | until removed from the group. | - | ||||||||||||||||||||||||
720 | - | |||||||||||||||||||||||||
721 | An item can be removed from the persistedItems group by setting the | - | ||||||||||||||||||||||||
722 | DelegateModel.inPersistedItems property to false. If the item is not referenced by a view | - | ||||||||||||||||||||||||
723 | at that time it will be destroyed. Adding an item to this group will not create a new | - | ||||||||||||||||||||||||
724 | instance. | - | ||||||||||||||||||||||||
725 | - | |||||||||||||||||||||||||
726 | Items returned by the \l QtQml.Models::DelegateModelGroup::create() function are automatically added | - | ||||||||||||||||||||||||
727 | to this group. | - | ||||||||||||||||||||||||
728 | */ | - | ||||||||||||||||||||||||
729 | - | |||||||||||||||||||||||||
730 | QQmlDelegateModelGroup *QQmlDelegateModel::persistedItems() | - | ||||||||||||||||||||||||
731 | { | - | ||||||||||||||||||||||||
732 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
733 | return d->m_persistedItems; executed 536 times by 1 test: return d->m_persistedItems; Executed by:
| 536 | ||||||||||||||||||||||||
734 | } | - | ||||||||||||||||||||||||
735 | - | |||||||||||||||||||||||||
736 | /*! | - | ||||||||||||||||||||||||
737 | \qmlproperty string QtQml.Models::DelegateModel::filterOnGroup | - | ||||||||||||||||||||||||
738 | - | |||||||||||||||||||||||||
739 | This property holds the name of the group used to filter the visual data model. | - | ||||||||||||||||||||||||
740 | - | |||||||||||||||||||||||||
741 | Only items which belong to this group are visible to a view. | - | ||||||||||||||||||||||||
742 | - | |||||||||||||||||||||||||
743 | By default this is the \l items group. | - | ||||||||||||||||||||||||
744 | */ | - | ||||||||||||||||||||||||
745 | - | |||||||||||||||||||||||||
746 | QString QQmlDelegateModel::filterGroup() const | - | ||||||||||||||||||||||||
747 | { | - | ||||||||||||||||||||||||
748 | Q_D(const QQmlDelegateModel); | - | ||||||||||||||||||||||||
749 | return d->m_filterGroup; executed 8 times by 1 test: return d->m_filterGroup; Executed by:
| 8 | ||||||||||||||||||||||||
750 | } | - | ||||||||||||||||||||||||
751 | - | |||||||||||||||||||||||||
752 | void QQmlDelegateModel::setFilterGroup(const QString &group) | - | ||||||||||||||||||||||||
753 | { | - | ||||||||||||||||||||||||
754 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
755 | - | |||||||||||||||||||||||||
756 | if (d->m_transaction) {
| 0-6 | ||||||||||||||||||||||||
757 | qmlWarning(this) << tr("The group of a DelegateModel cannot be changed within onChanged"); | - | ||||||||||||||||||||||||
758 | return; never executed: return; | 0 | ||||||||||||||||||||||||
759 | } | - | ||||||||||||||||||||||||
760 | - | |||||||||||||||||||||||||
761 | if (d->m_filterGroup != group) {
| 0-6 | ||||||||||||||||||||||||
762 | d->m_filterGroup = group; | - | ||||||||||||||||||||||||
763 | d->updateFilterGroup(); | - | ||||||||||||||||||||||||
764 | emit filterGroupChanged(); | - | ||||||||||||||||||||||||
765 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
766 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
767 | - | |||||||||||||||||||||||||
768 | void QQmlDelegateModel::resetFilterGroup() | - | ||||||||||||||||||||||||
769 | { | - | ||||||||||||||||||||||||
770 | setFilterGroup(QStringLiteral("items")); executed 2 times by 1 test: return qstring_literal_temp; Executed by:
| 2 | ||||||||||||||||||||||||
771 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
772 | - | |||||||||||||||||||||||||
773 | void QQmlDelegateModelPrivate::updateFilterGroup() | - | ||||||||||||||||||||||||
774 | { | - | ||||||||||||||||||||||||
775 | Q_Q(QQmlDelegateModel); | - | ||||||||||||||||||||||||
776 | if (!m_cacheMetaType)
| 0-5628 | ||||||||||||||||||||||||
777 | return; never executed: return; | 0 | ||||||||||||||||||||||||
778 | - | |||||||||||||||||||||||||
779 | QQmlListCompositor::Group previousGroup = m_compositorGroup; | - | ||||||||||||||||||||||||
780 | m_compositorGroup = Compositor::Default; | - | ||||||||||||||||||||||||
781 | for (int i = 1; i < m_groupCount; ++i) {
| 0-5638 | ||||||||||||||||||||||||
782 | if (m_filterGroup == m_cacheMetaType->groupNames.at(i - 1)) {
| 10-5628 | ||||||||||||||||||||||||
783 | m_compositorGroup = Compositor::Group(i); | - | ||||||||||||||||||||||||
784 | break; executed 5628 times by 27 tests: break; Executed by:
| 5628 | ||||||||||||||||||||||||
785 | } | - | ||||||||||||||||||||||||
786 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
787 | - | |||||||||||||||||||||||||
788 | QQmlDelegateModelGroupPrivate::get(m_groups[m_compositorGroup])->emitters.insert(this); | - | ||||||||||||||||||||||||
789 | if (m_compositorGroup != previousGroup) {
| 0-5628 | ||||||||||||||||||||||||
790 | QVector<QQmlChangeSet::Change> removes; | - | ||||||||||||||||||||||||
791 | QVector<QQmlChangeSet::Change> inserts; | - | ||||||||||||||||||||||||
792 | m_compositor.transition(previousGroup, m_compositorGroup, &removes, &inserts); | - | ||||||||||||||||||||||||
793 | - | |||||||||||||||||||||||||
794 | QQmlChangeSet changeSet; | - | ||||||||||||||||||||||||
795 | changeSet.move(removes, inserts); | - | ||||||||||||||||||||||||
796 | emit q->modelUpdated(changeSet, false); | - | ||||||||||||||||||||||||
797 | - | |||||||||||||||||||||||||
798 | if (changeSet.difference() != 0)
| 6-5622 | ||||||||||||||||||||||||
799 | emit q->countChanged(); executed 6 times by 1 test: q->countChanged(); Executed by:
| 6 | ||||||||||||||||||||||||
800 | - | |||||||||||||||||||||||||
801 | if (m_parts) {
| 352-5276 | ||||||||||||||||||||||||
802 | auto partsCopy = m_parts->models; // deliberate; this may alter m_parts | - | ||||||||||||||||||||||||
803 | for (QQmlPartsModel *model : qAsConst(partsCopy)) | - | ||||||||||||||||||||||||
804 | model->updateFilterGroup(m_compositorGroup, changeSet); executed 368 times by 6 tests: model->updateFilterGroup(m_compositorGroup, changeSet); Executed by:
| 368 | ||||||||||||||||||||||||
805 | } executed 352 times by 6 tests: end of block Executed by:
| 352 | ||||||||||||||||||||||||
806 | } executed 5628 times by 27 tests: end of block Executed by:
| 5628 | ||||||||||||||||||||||||
807 | } executed 5628 times by 27 tests: end of block Executed by:
| 5628 | ||||||||||||||||||||||||
808 | - | |||||||||||||||||||||||||
809 | /*! | - | ||||||||||||||||||||||||
810 | \qmlproperty object QtQml.Models::DelegateModel::parts | - | ||||||||||||||||||||||||
811 | - | |||||||||||||||||||||||||
812 | The \a parts property selects a DelegateModel which creates | - | ||||||||||||||||||||||||
813 | delegates from the part named. This is used in conjunction with | - | ||||||||||||||||||||||||
814 | the \l Package type. | - | ||||||||||||||||||||||||
815 | - | |||||||||||||||||||||||||
816 | For example, the code below selects a model which creates | - | ||||||||||||||||||||||||
817 | delegates named \e list from a \l Package: | - | ||||||||||||||||||||||||
818 | - | |||||||||||||||||||||||||
819 | \code | - | ||||||||||||||||||||||||
820 | DelegateModel { | - | ||||||||||||||||||||||||
821 | id: visualModel | - | ||||||||||||||||||||||||
822 | delegate: Package { | - | ||||||||||||||||||||||||
823 | Item { Package.name: "list" } | - | ||||||||||||||||||||||||
824 | } | - | ||||||||||||||||||||||||
825 | model: myModel | - | ||||||||||||||||||||||||
826 | } | - | ||||||||||||||||||||||||
827 | - | |||||||||||||||||||||||||
828 | ListView { | - | ||||||||||||||||||||||||
829 | width: 200; height:200 | - | ||||||||||||||||||||||||
830 | model: visualModel.parts.list | - | ||||||||||||||||||||||||
831 | } | - | ||||||||||||||||||||||||
832 | \endcode | - | ||||||||||||||||||||||||
833 | - | |||||||||||||||||||||||||
834 | \sa Package | - | ||||||||||||||||||||||||
835 | */ | - | ||||||||||||||||||||||||
836 | - | |||||||||||||||||||||||||
837 | QObject *QQmlDelegateModel::parts() | - | ||||||||||||||||||||||||
838 | { | - | ||||||||||||||||||||||||
839 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
840 | if (!d->m_parts)
| 30-352 | ||||||||||||||||||||||||
841 | d->m_parts = new QQmlDelegateModelParts(this); executed 352 times by 6 tests: d->m_parts = new QQmlDelegateModelParts(this); Executed by:
| 352 | ||||||||||||||||||||||||
842 | return d->m_parts; executed 382 times by 6 tests: return d->m_parts; Executed by:
| 382 | ||||||||||||||||||||||||
843 | } | - | ||||||||||||||||||||||||
844 | - | |||||||||||||||||||||||||
845 | const QAbstractItemModel *QQmlDelegateModel::abstractItemModel() const | - | ||||||||||||||||||||||||
846 | { | - | ||||||||||||||||||||||||
847 | return d_func()->m_adaptorModel.aim(); never executed: return d_func()->m_adaptorModel.aim(); | 0 | ||||||||||||||||||||||||
848 | } | - | ||||||||||||||||||||||||
849 | - | |||||||||||||||||||||||||
850 | void QQmlDelegateModelPrivate::emitCreatedPackage(QQDMIncubationTask *incubationTask, QQuickPackage *package) | - | ||||||||||||||||||||||||
851 | { | - | ||||||||||||||||||||||||
852 | for (int i = 1; i < m_groupCount; ++i)
| 4962-12098 | ||||||||||||||||||||||||
853 | QQmlDelegateModelGroupPrivate::get(m_groups[i])->createdPackage(incubationTask->index[i], package); executed 12098 times by 6 tests: QQmlDelegateModelGroupPrivate::get(m_groups[i])->createdPackage(incubationTask->index[i], package); Executed by:
| 12098 | ||||||||||||||||||||||||
854 | } executed 4962 times by 6 tests: end of block Executed by:
| 4962 | ||||||||||||||||||||||||
855 | - | |||||||||||||||||||||||||
856 | void QQmlDelegateModelPrivate::emitInitPackage(QQDMIncubationTask *incubationTask, QQuickPackage *package) | - | ||||||||||||||||||||||||
857 | { | - | ||||||||||||||||||||||||
858 | for (int i = 1; i < m_groupCount; ++i)
| 4962-12098 | ||||||||||||||||||||||||
859 | QQmlDelegateModelGroupPrivate::get(m_groups[i])->initPackage(incubationTask->index[i], package); executed 12098 times by 6 tests: QQmlDelegateModelGroupPrivate::get(m_groups[i])->initPackage(incubationTask->index[i], package); Executed by:
| 12098 | ||||||||||||||||||||||||
860 | } executed 4962 times by 6 tests: end of block Executed by:
| 4962 | ||||||||||||||||||||||||
861 | - | |||||||||||||||||||||||||
862 | void QQmlDelegateModelPrivate::emitDestroyingPackage(QQuickPackage *package) | - | ||||||||||||||||||||||||
863 | { | - | ||||||||||||||||||||||||
864 | for (int i = 1; i < m_groupCount; ++i)
| 1658-3324 | ||||||||||||||||||||||||
865 | QQmlDelegateModelGroupPrivate::get(m_groups[i])->destroyingPackage(package); executed 3324 times by 3 tests: QQmlDelegateModelGroupPrivate::get(m_groups[i])->destroyingPackage(package); Executed by:
| 3324 | ||||||||||||||||||||||||
866 | } executed 1658 times by 3 tests: end of block Executed by:
| 1658 | ||||||||||||||||||||||||
867 | - | |||||||||||||||||||||||||
868 | static bool isDoneIncubating(QQmlIncubator::Status status) | - | ||||||||||||||||||||||||
869 | { | - | ||||||||||||||||||||||||
870 | return status == QQmlIncubator::Ready || status == QQmlIncubator::Error; executed 265128 times by 25 tests: return status == QQmlIncubator::Ready || status == QQmlIncubator::Error; Executed by:
| 265128 | ||||||||||||||||||||||||
871 | } | - | ||||||||||||||||||||||||
872 | - | |||||||||||||||||||||||||
873 | void QQDMIncubationTask::statusChanged(Status status) | - | ||||||||||||||||||||||||
874 | { | - | ||||||||||||||||||||||||
875 | if (vdm) {
| 29-265099 | ||||||||||||||||||||||||
876 | vdm->incubatorStatusChanged(this, status); | - | ||||||||||||||||||||||||
877 | } else if (isDoneIncubating(status)) { executed 265099 times by 25 tests: end of block Executed by:
| 0-265099 | ||||||||||||||||||||||||
878 | Q_ASSERT(incubating); | - | ||||||||||||||||||||||||
879 | // The model was deleted from under our feet, cleanup ourselves | - | ||||||||||||||||||||||||
880 | delete incubating->object; | - | ||||||||||||||||||||||||
881 | incubating->object = nullptr; | - | ||||||||||||||||||||||||
882 | if (incubating->contextData) {
| 0-29 | ||||||||||||||||||||||||
883 | incubating->contextData->invalidate(); | - | ||||||||||||||||||||||||
884 | Q_ASSERT(incubating->contextData->refCount == 1); | - | ||||||||||||||||||||||||
885 | incubating->contextData = nullptr; | - | ||||||||||||||||||||||||
886 | } executed 29 times by 2 tests: end of block Executed by:
| 29 | ||||||||||||||||||||||||
887 | incubating->scriptRef = 0; | - | ||||||||||||||||||||||||
888 | incubating->deleteLater(); | - | ||||||||||||||||||||||||
889 | } executed 29 times by 2 tests: end of block Executed by:
| 29 | ||||||||||||||||||||||||
890 | } executed 265128 times by 25 tests: end of block Executed by:
| 265128 | ||||||||||||||||||||||||
891 | - | |||||||||||||||||||||||||
892 | void QQmlDelegateModelPrivate::releaseIncubator(QQDMIncubationTask *incubationTask) | - | ||||||||||||||||||||||||
893 | { | - | ||||||||||||||||||||||||
894 | Q_Q(QQmlDelegateModel); | - | ||||||||||||||||||||||||
895 | if (!incubationTask->isError())
| 0-88371 | ||||||||||||||||||||||||
896 | incubationTask->clear(); executed 88371 times by 25 tests: incubationTask->clear(); Executed by:
| 88371 | ||||||||||||||||||||||||
897 | m_finishedIncubating.append(incubationTask); | - | ||||||||||||||||||||||||
898 | if (!m_incubatorCleanupScheduled) {
| 9109-79262 | ||||||||||||||||||||||||
899 | m_incubatorCleanupScheduled = true; | - | ||||||||||||||||||||||||
900 | QCoreApplication::postEvent(q, new QEvent(QEvent::User)); | - | ||||||||||||||||||||||||
901 | } executed 9109 times by 25 tests: end of block Executed by:
| 9109 | ||||||||||||||||||||||||
902 | } executed 88371 times by 25 tests: end of block Executed by:
| 88371 | ||||||||||||||||||||||||
903 | - | |||||||||||||||||||||||||
904 | void QQmlDelegateModelPrivate::addCacheItem(QQmlDelegateModelItem *item, Compositor::iterator it) | - | ||||||||||||||||||||||||
905 | { | - | ||||||||||||||||||||||||
906 | m_cache.insert(it.cacheIndex, item); | - | ||||||||||||||||||||||||
907 | m_compositor.setFlags(it, 1, Compositor::CacheFlag); | - | ||||||||||||||||||||||||
908 | Q_ASSERT(m_cache.count() == m_compositor.count(Compositor::Cache)); | - | ||||||||||||||||||||||||
909 | } executed 87987 times by 25 tests: end of block Executed by:
| 87987 | ||||||||||||||||||||||||
910 | - | |||||||||||||||||||||||||
911 | void QQmlDelegateModelPrivate::removeCacheItem(QQmlDelegateModelItem *cacheItem) | - | ||||||||||||||||||||||||
912 | { | - | ||||||||||||||||||||||||
913 | int cidx = m_cache.lastIndexOf(cacheItem); | - | ||||||||||||||||||||||||
914 | if (cidx >= 0) {
| 0-22297 | ||||||||||||||||||||||||
915 | m_compositor.clearFlags(Compositor::Cache, cidx, 1, Compositor::CacheFlag); | - | ||||||||||||||||||||||||
916 | m_cache.removeAt(cidx); | - | ||||||||||||||||||||||||
917 | } executed 22297 times by 12 tests: end of block Executed by:
| 22297 | ||||||||||||||||||||||||
918 | Q_ASSERT(m_cache.count() == m_compositor.count(Compositor::Cache)); | - | ||||||||||||||||||||||||
919 | } executed 22297 times by 12 tests: end of block Executed by:
| 22297 | ||||||||||||||||||||||||
920 | - | |||||||||||||||||||||||||
921 | void QQmlDelegateModelPrivate::incubatorStatusChanged(QQDMIncubationTask *incubationTask, QQmlIncubator::Status status) | - | ||||||||||||||||||||||||
922 | { | - | ||||||||||||||||||||||||
923 | if (!isDoneIncubating(status))
| 88321-176778 | ||||||||||||||||||||||||
924 | return; executed 176778 times by 25 tests: return; Executed by:
| 176778 | ||||||||||||||||||||||||
925 | - | |||||||||||||||||||||||||
926 | const QList<QQmlError> incubationTaskErrors = incubationTask->errors(); | - | ||||||||||||||||||||||||
927 | - | |||||||||||||||||||||||||
928 | QQmlDelegateModelItem *cacheItem = incubationTask->incubating; | - | ||||||||||||||||||||||||
929 | cacheItem->incubationTask = nullptr; | - | ||||||||||||||||||||||||
930 | incubationTask->incubating = nullptr; | - | ||||||||||||||||||||||||
931 | releaseIncubator(incubationTask); | - | ||||||||||||||||||||||||
932 | - | |||||||||||||||||||||||||
933 | if (status == QQmlIncubator::Ready) {
| 0-88321 | ||||||||||||||||||||||||
934 | cacheItem->referenceObject(); | - | ||||||||||||||||||||||||
935 | if (QQuickPackage *package = qmlobject_cast<QQuickPackage *>(cacheItem->object))
| 4962-83359 | ||||||||||||||||||||||||
936 | emitCreatedPackage(incubationTask, package); executed 4962 times by 6 tests: emitCreatedPackage(incubationTask, package); Executed by:
| 4962 | ||||||||||||||||||||||||
937 | else | - | ||||||||||||||||||||||||
938 | emitCreatedItem(incubationTask, cacheItem->object); executed 83359 times by 25 tests: emitCreatedItem(incubationTask, cacheItem->object); Executed by:
| 83359 | ||||||||||||||||||||||||
939 | cacheItem->releaseObject(); | - | ||||||||||||||||||||||||
940 | } else if (status == QQmlIncubator::Error) { executed 88321 times by 25 tests: end of block Executed by:
| 0-88321 | ||||||||||||||||||||||||
941 | qmlWarning(m_delegate, incubationTaskErrors + m_delegate->errors()) << "Error creating delegate"; | - | ||||||||||||||||||||||||
942 | } never executed: end of block | 0 | ||||||||||||||||||||||||
943 | - | |||||||||||||||||||||||||
944 | if (!cacheItem->isObjectReferenced()) {
| 33-88288 | ||||||||||||||||||||||||
945 | if (QQuickPackage *package = qmlobject_cast<QQuickPackage *>(cacheItem->object))
| 0-33 | ||||||||||||||||||||||||
946 | emitDestroyingPackage(package); never executed: emitDestroyingPackage(package); | 0 | ||||||||||||||||||||||||
947 | else | - | ||||||||||||||||||||||||
948 | emitDestroyingItem(cacheItem->object); executed 33 times by 3 tests: emitDestroyingItem(cacheItem->object); Executed by:
| 33 | ||||||||||||||||||||||||
949 | delete cacheItem->object; | - | ||||||||||||||||||||||||
950 | cacheItem->object = nullptr; | - | ||||||||||||||||||||||||
951 | cacheItem->scriptRef -= 1; | - | ||||||||||||||||||||||||
952 | if (cacheItem->contextData) {
| 0-33 | ||||||||||||||||||||||||
953 | cacheItem->contextData->invalidate(); | - | ||||||||||||||||||||||||
954 | Q_ASSERT(cacheItem->contextData->refCount == 1); | - | ||||||||||||||||||||||||
955 | } executed 33 times by 3 tests: end of block Executed by:
| 33 | ||||||||||||||||||||||||
956 | cacheItem->contextData = nullptr; | - | ||||||||||||||||||||||||
957 | - | |||||||||||||||||||||||||
958 | if (!cacheItem->isReferenced()) {
| 0-33 | ||||||||||||||||||||||||
959 | removeCacheItem(cacheItem); | - | ||||||||||||||||||||||||
960 | delete cacheItem; | - | ||||||||||||||||||||||||
961 | } executed 33 times by 3 tests: end of block Executed by:
| 33 | ||||||||||||||||||||||||
962 | } executed 33 times by 3 tests: end of block Executed by:
| 33 | ||||||||||||||||||||||||
963 | } executed 88321 times by 25 tests: end of block Executed by:
| 88321 | ||||||||||||||||||||||||
964 | - | |||||||||||||||||||||||||
965 | void QQDMIncubationTask::setInitialState(QObject *o) | - | ||||||||||||||||||||||||
966 | { | - | ||||||||||||||||||||||||
967 | vdm->setInitialState(this, o); | - | ||||||||||||||||||||||||
968 | } executed 88321 times by 25 tests: end of block Executed by:
| 88321 | ||||||||||||||||||||||||
969 | - | |||||||||||||||||||||||||
970 | void QQmlDelegateModelPrivate::setInitialState(QQDMIncubationTask *incubationTask, QObject *o) | - | ||||||||||||||||||||||||
971 | { | - | ||||||||||||||||||||||||
972 | QQmlDelegateModelItem *cacheItem = incubationTask->incubating; | - | ||||||||||||||||||||||||
973 | cacheItem->object = o; | - | ||||||||||||||||||||||||
974 | - | |||||||||||||||||||||||||
975 | if (QQuickPackage *package = qmlobject_cast<QQuickPackage *>(cacheItem->object))
| 4962-83359 | ||||||||||||||||||||||||
976 | emitInitPackage(incubationTask, package); executed 4962 times by 6 tests: emitInitPackage(incubationTask, package); Executed by:
| 4962 | ||||||||||||||||||||||||
977 | else | - | ||||||||||||||||||||||||
978 | emitInitItem(incubationTask, cacheItem->object); executed 83359 times by 25 tests: emitInitItem(incubationTask, cacheItem->object); Executed by:
| 83359 | ||||||||||||||||||||||||
979 | } | - | ||||||||||||||||||||||||
980 | - | |||||||||||||||||||||||||
981 | QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, QQmlIncubator::IncubationMode incubationMode) | - | ||||||||||||||||||||||||
982 | { | - | ||||||||||||||||||||||||
983 | if (!m_delegate || index < 0 || index >= m_compositor.count(group)) {
| 0-109307 | ||||||||||||||||||||||||
984 | qWarning() << "DelegateModel::item: index out range" << index << m_compositor.count(group); | - | ||||||||||||||||||||||||
985 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
986 | } else if (!m_context || !m_context->isValid()) {
| 0-109307 | ||||||||||||||||||||||||
987 | return nullptr; executed 2 times by 1 test: return nullptr; Executed by:
| 2 | ||||||||||||||||||||||||
988 | } | - | ||||||||||||||||||||||||
989 | - | |||||||||||||||||||||||||
990 | Compositor::iterator it = m_compositor.find(group, index); | - | ||||||||||||||||||||||||
991 | - | |||||||||||||||||||||||||
992 | QQmlDelegateModelItem *cacheItem = it->inCache() ? m_cache.at(it.cacheIndex) : 0;
| 21318-87987 | ||||||||||||||||||||||||
993 | - | |||||||||||||||||||||||||
994 | if (!cacheItem) {
| 21318-87987 | ||||||||||||||||||||||||
995 | cacheItem = m_adaptorModel.createItem(m_cacheMetaType, it.modelIndex()); | - | ||||||||||||||||||||||||
996 | if (!cacheItem)
| 0-87987 | ||||||||||||||||||||||||
997 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
998 | - | |||||||||||||||||||||||||
999 | cacheItem->groups = it->flags; | - | ||||||||||||||||||||||||
1000 | addCacheItem(cacheItem, it); | - | ||||||||||||||||||||||||
1001 | } executed 87987 times by 25 tests: end of block Executed by:
| 87987 | ||||||||||||||||||||||||
1002 | - | |||||||||||||||||||||||||
1003 | // Bump the reference counts temporarily so neither the content data or the delegate object | - | ||||||||||||||||||||||||
1004 | // are deleted if incubatorStatusChanged() is called synchronously. | - | ||||||||||||||||||||||||
1005 | cacheItem->scriptRef += 1; | - | ||||||||||||||||||||||||
1006 | cacheItem->referenceObject(); | - | ||||||||||||||||||||||||
1007 | - | |||||||||||||||||||||||||
1008 | if (cacheItem->incubationTask) {
| 170-109135 | ||||||||||||||||||||||||
1009 | bool sync = (incubationMode == QQmlIncubator::Synchronous || incubationMode == QQmlIncubator::AsynchronousIfNested);
| 0-170 | ||||||||||||||||||||||||
1010 | if (sync && cacheItem->incubationTask->incubationMode() == QQmlIncubator::Asynchronous) {
| 2-168 | ||||||||||||||||||||||||
1011 | // previously requested async - now needed immediately | - | ||||||||||||||||||||||||
1012 | cacheItem->incubationTask->forceCompletion(); | - | ||||||||||||||||||||||||
1013 | } executed 162 times by 3 tests: end of block Executed by:
| 162 | ||||||||||||||||||||||||
1014 | } else if (!cacheItem->object) { executed 170 times by 3 tests: end of block Executed by:
| 170-88407 | ||||||||||||||||||||||||
1015 | QQmlContext *creationContext = m_delegate->creationContext(); | - | ||||||||||||||||||||||||
1016 | - | |||||||||||||||||||||||||
1017 | cacheItem->scriptRef += 1; | - | ||||||||||||||||||||||||
1018 | - | |||||||||||||||||||||||||
1019 | cacheItem->incubationTask = new QQDMIncubationTask(this, incubationMode); | - | ||||||||||||||||||||||||
1020 | cacheItem->incubationTask->incubating = cacheItem; | - | ||||||||||||||||||||||||
1021 | cacheItem->incubationTask->clear(); | - | ||||||||||||||||||||||||
1022 | - | |||||||||||||||||||||||||
1023 | for (int i = 1; i < m_groupCount; ++i)
| 88407-182034 | ||||||||||||||||||||||||
1024 | cacheItem->incubationTask->index[i] = it.index[i]; executed 182034 times by 25 tests: cacheItem->incubationTask->index[i] = it.index[i]; Executed by:
| 182034 | ||||||||||||||||||||||||
1025 | - | |||||||||||||||||||||||||
1026 | QQmlContextData *ctxt = new QQmlContextData; | - | ||||||||||||||||||||||||
1027 | ctxt->setParent(QQmlContextData::get(creationContext ? creationContext : m_context.data())); | - | ||||||||||||||||||||||||
1028 | ctxt->contextObject = cacheItem; | - | ||||||||||||||||||||||||
1029 | cacheItem->contextData = ctxt; | - | ||||||||||||||||||||||||
1030 | - | |||||||||||||||||||||||||
1031 | if (m_adaptorModel.hasProxyObject()) {
| 9985-78422 | ||||||||||||||||||||||||
1032 | if (QQmlAdaptorModelProxyInterface *proxy
| 472-77950 | ||||||||||||||||||||||||
1033 | = qobject_cast<QQmlAdaptorModelProxyInterface *>(cacheItem)) {
| 472-77950 | ||||||||||||||||||||||||
1034 | ctxt = new QQmlContextData; | - | ||||||||||||||||||||||||
1035 | ctxt->setParent(cacheItem->contextData, /*stronglyReferencedByParent*/true); | - | ||||||||||||||||||||||||
1036 | ctxt->contextObject = proxy->proxiedObject(); | - | ||||||||||||||||||||||||
1037 | } executed 472 times by 3 tests: end of block Executed by:
| 472 | ||||||||||||||||||||||||
1038 | } executed 78422 times by 12 tests: end of block Executed by:
| 78422 | ||||||||||||||||||||||||
1039 | - | |||||||||||||||||||||||||
1040 | QQmlComponentPrivate *cp = QQmlComponentPrivate::get(m_delegate); | - | ||||||||||||||||||||||||
1041 | cp->incubateObject( | - | ||||||||||||||||||||||||
1042 | cacheItem->incubationTask, | - | ||||||||||||||||||||||||
1043 | m_delegate, | - | ||||||||||||||||||||||||
1044 | m_context->engine(), | - | ||||||||||||||||||||||||
1045 | ctxt, | - | ||||||||||||||||||||||||
1046 | QQmlContextData::get(m_context)); | - | ||||||||||||||||||||||||
1047 | } executed 88407 times by 25 tests: end of block Executed by:
| 88407 | ||||||||||||||||||||||||
1048 | - | |||||||||||||||||||||||||
1049 | if (index == m_compositor.count(group) - 1)
| 8613-100692 | ||||||||||||||||||||||||
1050 | requestMoreIfNecessary(); executed 8613 times by 24 tests: requestMoreIfNecessary(); Executed by:
| 8613 | ||||||||||||||||||||||||
1051 | - | |||||||||||||||||||||||||
1052 | // Remove the temporary reference count. | - | ||||||||||||||||||||||||
1053 | cacheItem->scriptRef -= 1; | - | ||||||||||||||||||||||||
1054 | if (cacheItem->object && (!cacheItem->incubationTask || isDoneIncubating(cacheItem->incubationTask->status())))
| 0-106373 | ||||||||||||||||||||||||
1055 | return cacheItem->object; executed 106373 times by 25 tests: return cacheItem->object; Executed by:
| 106373 | ||||||||||||||||||||||||
1056 | - | |||||||||||||||||||||||||
1057 | cacheItem->releaseObject(); | - | ||||||||||||||||||||||||
1058 | if (!cacheItem->isReferenced()) {
| 0-2932 | ||||||||||||||||||||||||
1059 | removeCacheItem(cacheItem); | - | ||||||||||||||||||||||||
1060 | delete cacheItem; | - | ||||||||||||||||||||||||
1061 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1062 | - | |||||||||||||||||||||||||
1063 | return nullptr; executed 2932 times by 7 tests: return nullptr; Executed by:
| 2932 | ||||||||||||||||||||||||
1064 | } | - | ||||||||||||||||||||||||
1065 | - | |||||||||||||||||||||||||
1066 | /* | - | ||||||||||||||||||||||||
1067 | If asynchronous is true or the component is being loaded asynchronously due | - | ||||||||||||||||||||||||
1068 | to an ancestor being loaded asynchronously, object() may return 0. In this | - | ||||||||||||||||||||||||
1069 | case createdItem() will be emitted when the object is available. The object | - | ||||||||||||||||||||||||
1070 | at this stage does not have any references, so object() must be called again | - | ||||||||||||||||||||||||
1071 | to ensure a reference is held. Any call to object() which returns a valid object | - | ||||||||||||||||||||||||
1072 | must be matched by a call to release() in order to destroy the object. | - | ||||||||||||||||||||||||
1073 | */ | - | ||||||||||||||||||||||||
1074 | QObject *QQmlDelegateModel::object(int index, QQmlIncubator::IncubationMode incubationMode) | - | ||||||||||||||||||||||||
1075 | { | - | ||||||||||||||||||||||||
1076 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
1077 | if (!d->m_delegate || index < 0 || index >= d->m_compositor.count(d->m_compositorGroup)) {
| 0-103029 | ||||||||||||||||||||||||
1078 | qWarning() << "DelegateModel::item: index out range" << index << d->m_compositor.count(d->m_compositorGroup); | - | ||||||||||||||||||||||||
1079 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
1080 | } | - | ||||||||||||||||||||||||
1081 | - | |||||||||||||||||||||||||
1082 | return d->object(d->m_compositorGroup, index, incubationMode); executed 103029 times by 25 tests: return d->object(d->m_compositorGroup, index, incubationMode); Executed by:
| 103029 | ||||||||||||||||||||||||
1083 | } | - | ||||||||||||||||||||||||
1084 | - | |||||||||||||||||||||||||
1085 | QQmlIncubator::Status QQmlDelegateModel::incubationStatus(int index) | - | ||||||||||||||||||||||||
1086 | { | - | ||||||||||||||||||||||||
1087 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
1088 | Compositor::iterator it = d->m_compositor.find(d->m_compositorGroup, index); | - | ||||||||||||||||||||||||
1089 | if (!it->inCache())
| 0-2770 | ||||||||||||||||||||||||
1090 | return QQmlIncubator::Null; never executed: return QQmlIncubator::Null; | 0 | ||||||||||||||||||||||||
1091 | - | |||||||||||||||||||||||||
1092 | if (auto incubationTask = d->m_cache.at(it.cacheIndex)->incubationTask)
| 0-2770 | ||||||||||||||||||||||||
1093 | return incubationTask->status(); executed 2770 times by 4 tests: return incubationTask->status(); Executed by:
| 2770 | ||||||||||||||||||||||||
1094 | - | |||||||||||||||||||||||||
1095 | return QQmlIncubator::Ready; never executed: return QQmlIncubator::Ready; | 0 | ||||||||||||||||||||||||
1096 | } | - | ||||||||||||||||||||||||
1097 | - | |||||||||||||||||||||||||
1098 | QString QQmlDelegateModelPrivate::stringValue(Compositor::Group group, int index, const QString &name) | - | ||||||||||||||||||||||||
1099 | { | - | ||||||||||||||||||||||||
1100 | Compositor::iterator it = m_compositor.find(group, index); | - | ||||||||||||||||||||||||
1101 | if (QQmlAdaptorModel *model = it.list<QQmlAdaptorModel>()) {
| 0-7412 | ||||||||||||||||||||||||
1102 | QString role = name; | - | ||||||||||||||||||||||||
1103 | int dot = name.indexOf(QLatin1Char('.')); | - | ||||||||||||||||||||||||
1104 | if (dot > 0)
| 8-7404 | ||||||||||||||||||||||||
1105 | role = name.left(dot); executed 8 times by 1 test: role = name.left(dot); Executed by:
| 8 | ||||||||||||||||||||||||
1106 | QVariant value = model->value(it.modelIndex(), role); | - | ||||||||||||||||||||||||
1107 | while (dot > 0) {
| 8-7412 | ||||||||||||||||||||||||
1108 | QObject *obj = qvariant_cast<QObject*>(value); | - | ||||||||||||||||||||||||
1109 | if (!obj)
| 0-8 | ||||||||||||||||||||||||
1110 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||
1111 | int from = dot+1; | - | ||||||||||||||||||||||||
1112 | dot = name.indexOf(QLatin1Char('.'), from); | - | ||||||||||||||||||||||||
1113 | value = obj->property(name.midRef(from, dot - from).toUtf8()); | - | ||||||||||||||||||||||||
1114 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
1115 | return value.toString(); executed 7412 times by 4 tests: return value.toString(); Executed by:
| 7412 | ||||||||||||||||||||||||
1116 | } | - | ||||||||||||||||||||||||
1117 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||
1118 | } | - | ||||||||||||||||||||||||
1119 | - | |||||||||||||||||||||||||
1120 | QString QQmlDelegateModel::stringValue(int index, const QString &name) | - | ||||||||||||||||||||||||
1121 | { | - | ||||||||||||||||||||||||
1122 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
1123 | return d->stringValue(d->m_compositorGroup, index, name); executed 7008 times by 4 tests: return d->stringValue(d->m_compositorGroup, index, name); Executed by:
| 7008 | ||||||||||||||||||||||||
1124 | } | - | ||||||||||||||||||||||||
1125 | - | |||||||||||||||||||||||||
1126 | int QQmlDelegateModel::indexOf(QObject *item, QObject *) const | - | ||||||||||||||||||||||||
1127 | { | - | ||||||||||||||||||||||||
1128 | Q_D(const QQmlDelegateModel); | - | ||||||||||||||||||||||||
1129 | if (QQmlDelegateModelItem *cacheItem = QQmlDelegateModelItem::dataForObject(item))
| 44930-54689 | ||||||||||||||||||||||||
1130 | return cacheItem->groupIndex(d->m_compositorGroup); executed 44930 times by 3 tests: return cacheItem->groupIndex(d->m_compositorGroup); Executed by:
| 44930 | ||||||||||||||||||||||||
1131 | return -1; executed 54689 times by 10 tests: return -1; Executed by:
| 54689 | ||||||||||||||||||||||||
1132 | } | - | ||||||||||||||||||||||||
1133 | - | |||||||||||||||||||||||||
1134 | void QQmlDelegateModel::setWatchedRoles(const QList<QByteArray> &roles) | - | ||||||||||||||||||||||||
1135 | { | - | ||||||||||||||||||||||||
1136 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
1137 | d->m_adaptorModel.replaceWatchedRoles(d->m_watchedRoles, roles); | - | ||||||||||||||||||||||||
1138 | d->m_watchedRoles = roles; | - | ||||||||||||||||||||||||
1139 | } executed 1620 times by 11 tests: end of block Executed by:
| 1620 | ||||||||||||||||||||||||
1140 | - | |||||||||||||||||||||||||
1141 | void QQmlDelegateModelPrivate::addGroups( | - | ||||||||||||||||||||||||
1142 | Compositor::iterator from, int count, Compositor::Group group, int groupFlags) | - | ||||||||||||||||||||||||
1143 | { | - | ||||||||||||||||||||||||
1144 | QVector<Compositor::Insert> inserts; | - | ||||||||||||||||||||||||
1145 | m_compositor.setFlags(from, count, group, groupFlags, &inserts); | - | ||||||||||||||||||||||||
1146 | itemsInserted(inserts); | - | ||||||||||||||||||||||||
1147 | emitChanges(); | - | ||||||||||||||||||||||||
1148 | } executed 22 times by 1 test: end of block Executed by:
| 22 | ||||||||||||||||||||||||
1149 | - | |||||||||||||||||||||||||
1150 | void QQmlDelegateModelPrivate::removeGroups( | - | ||||||||||||||||||||||||
1151 | Compositor::iterator from, int count, Compositor::Group group, int groupFlags) | - | ||||||||||||||||||||||||
1152 | { | - | ||||||||||||||||||||||||
1153 | QVector<Compositor::Remove> removes; | - | ||||||||||||||||||||||||
1154 | m_compositor.clearFlags(from, count, group, groupFlags, &removes); | - | ||||||||||||||||||||||||
1155 | itemsRemoved(removes); | - | ||||||||||||||||||||||||
1156 | emitChanges(); | - | ||||||||||||||||||||||||
1157 | } executed 40 times by 1 test: end of block Executed by:
| 40 | ||||||||||||||||||||||||
1158 | - | |||||||||||||||||||||||||
1159 | void QQmlDelegateModelPrivate::setGroups( | - | ||||||||||||||||||||||||
1160 | Compositor::iterator from, int count, Compositor::Group group, int groupFlags) | - | ||||||||||||||||||||||||
1161 | { | - | ||||||||||||||||||||||||
1162 | QVector<Compositor::Remove> removes; | - | ||||||||||||||||||||||||
1163 | QVector<Compositor::Insert> inserts; | - | ||||||||||||||||||||||||
1164 | - | |||||||||||||||||||||||||
1165 | m_compositor.setFlags(from, count, group, groupFlags, &inserts); | - | ||||||||||||||||||||||||
1166 | itemsInserted(inserts); | - | ||||||||||||||||||||||||
1167 | const int removeFlags = ~groupFlags & Compositor::GroupMask; | - | ||||||||||||||||||||||||
1168 | - | |||||||||||||||||||||||||
1169 | from = m_compositor.find(from.group, from.index[from.group]); | - | ||||||||||||||||||||||||
1170 | m_compositor.clearFlags(from, count, group, removeFlags, &removes); | - | ||||||||||||||||||||||||
1171 | itemsRemoved(removes); | - | ||||||||||||||||||||||||
1172 | emitChanges(); | - | ||||||||||||||||||||||||
1173 | } executed 36 times by 2 tests: end of block Executed by:
| 36 | ||||||||||||||||||||||||
1174 | - | |||||||||||||||||||||||||
1175 | bool QQmlDelegateModel::event(QEvent *e) | - | ||||||||||||||||||||||||
1176 | { | - | ||||||||||||||||||||||||
1177 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
1178 | if (e->type() == QEvent::UpdateRequest) {
| 18-19111 | ||||||||||||||||||||||||
1179 | d->m_waitingToFetchMore = false; | - | ||||||||||||||||||||||||
1180 | d->m_adaptorModel.fetchMore(); | - | ||||||||||||||||||||||||
1181 | } else if (e->type() == QEvent::User) { executed 18 times by 1 test: end of block Executed by:
| 18-12226 | ||||||||||||||||||||||||
1182 | d->m_incubatorCleanupScheduled = false; | - | ||||||||||||||||||||||||
1183 | qDeleteAll(d->m_finishedIncubating); | - | ||||||||||||||||||||||||
1184 | d->m_finishedIncubating.clear(); | - | ||||||||||||||||||||||||
1185 | } executed 6885 times by 22 tests: end of block Executed by:
| 6885 | ||||||||||||||||||||||||
1186 | return QQmlInstanceModel::event(e); executed 19129 times by 27 tests: return QQmlInstanceModel::event(e); Executed by:
| 19129 | ||||||||||||||||||||||||
1187 | } | - | ||||||||||||||||||||||||
1188 | - | |||||||||||||||||||||||||
1189 | void QQmlDelegateModelPrivate::itemsChanged(const QVector<Compositor::Change> &changes) | - | ||||||||||||||||||||||||
1190 | { | - | ||||||||||||||||||||||||
1191 | if (!m_delegate)
| 0-426 | ||||||||||||||||||||||||
1192 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1193 | - | |||||||||||||||||||||||||
1194 | QVarLengthArray<QVector<QQmlChangeSet::Change>, Compositor::MaximumGroupCount> translatedChanges(m_groupCount); | - | ||||||||||||||||||||||||
1195 | - | |||||||||||||||||||||||||
1196 | for (const Compositor::Change &change : changes) { | - | ||||||||||||||||||||||||
1197 | for (int i = 1; i < m_groupCount; ++i) {
| 426-852 | ||||||||||||||||||||||||
1198 | if (change.inGroup(i)) {
| 426 | ||||||||||||||||||||||||
1199 | translatedChanges[i].append(QQmlChangeSet::Change(change.index[i], change.count)); | - | ||||||||||||||||||||||||
1200 | } executed 426 times by 2 tests: end of block Executed by:
| 426 | ||||||||||||||||||||||||
1201 | } executed 852 times by 2 tests: end of block Executed by:
| 852 | ||||||||||||||||||||||||
1202 | } executed 426 times by 2 tests: end of block Executed by:
| 426 | ||||||||||||||||||||||||
1203 | - | |||||||||||||||||||||||||
1204 | for (int i = 1; i < m_groupCount; ++i)
| 426-852 | ||||||||||||||||||||||||
1205 | QQmlDelegateModelGroupPrivate::get(m_groups[i])->changeSet.change(translatedChanges.at(i)); executed 852 times by 2 tests: QQmlDelegateModelGroupPrivate::get(m_groups[i])->changeSet.change(translatedChanges.at(i)); Executed by:
| 852 | ||||||||||||||||||||||||
1206 | } executed 426 times by 2 tests: end of block Executed by:
| 426 | ||||||||||||||||||||||||
1207 | - | |||||||||||||||||||||||||
1208 | void QQmlDelegateModel::_q_itemsChanged(int index, int count, const QVector<int> &roles) | - | ||||||||||||||||||||||||
1209 | { | - | ||||||||||||||||||||||||
1210 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
1211 | if (count <= 0 || !d->m_complete)
| 0-494 | ||||||||||||||||||||||||
1212 | return; executed 4 times by 1 test: return; Executed by:
| 4 | ||||||||||||||||||||||||
1213 | - | |||||||||||||||||||||||||
1214 | if (d->m_adaptorModel.notify(d->m_cache, index, count, roles)) {
| 68-426 | ||||||||||||||||||||||||
1215 | QVector<Compositor::Change> changes; | - | ||||||||||||||||||||||||
1216 | d->m_compositor.listItemsChanged(&d->m_adaptorModel, index, count, &changes); | - | ||||||||||||||||||||||||
1217 | d->itemsChanged(changes); | - | ||||||||||||||||||||||||
1218 | d->emitChanges(); | - | ||||||||||||||||||||||||
1219 | } executed 426 times by 2 tests: end of block Executed by:
| 426 | ||||||||||||||||||||||||
1220 | } executed 494 times by 5 tests: end of block Executed by:
| 494 | ||||||||||||||||||||||||
1221 | - | |||||||||||||||||||||||||
1222 | static void incrementIndexes(QQmlDelegateModelItem *cacheItem, int count, const int *deltas) | - | ||||||||||||||||||||||||
1223 | { | - | ||||||||||||||||||||||||
1224 | if (QQDMIncubationTask *incubationTask = cacheItem->incubationTask) {
| 322-120409 | ||||||||||||||||||||||||
1225 | for (int i = 1; i < count; ++i)
| 322-644 | ||||||||||||||||||||||||
1226 | incubationTask->index[i] += deltas[i]; executed 644 times by 3 tests: incubationTask->index[i] += deltas[i]; Executed by:
| 644 | ||||||||||||||||||||||||
1227 | } executed 322 times by 3 tests: end of block Executed by:
| 322 | ||||||||||||||||||||||||
1228 | if (QQmlDelegateModelAttached *attached = cacheItem->attached) {
| 2518-118213 | ||||||||||||||||||||||||
1229 | for (int i = 1; i < qMin<int>(count, Compositor::MaximumGroupCount); ++i)
| 2518-10040 | ||||||||||||||||||||||||
1230 | attached->m_currentIndex[i] += deltas[i]; executed 10040 times by 1 test: attached->m_currentIndex[i] += deltas[i]; Executed by:
| 10040 | ||||||||||||||||||||||||
1231 | } executed 2518 times by 1 test: end of block Executed by:
| 2518 | ||||||||||||||||||||||||
1232 | } executed 120731 times by 8 tests: end of block Executed by:
| 120731 | ||||||||||||||||||||||||
1233 | - | |||||||||||||||||||||||||
1234 | void QQmlDelegateModelPrivate::itemsInserted( | - | ||||||||||||||||||||||||
1235 | const QVector<Compositor::Insert> &inserts, | - | ||||||||||||||||||||||||
1236 | QVarLengthArray<QVector<QQmlChangeSet::Change>, Compositor::MaximumGroupCount> *translatedInserts, | - | ||||||||||||||||||||||||
1237 | QHash<int, QList<QQmlDelegateModelItem *> > *movedItems) | - | ||||||||||||||||||||||||
1238 | { | - | ||||||||||||||||||||||||
1239 | int cacheIndex = 0; | - | ||||||||||||||||||||||||
1240 | - | |||||||||||||||||||||||||
1241 | int inserted[Compositor::MaximumGroupCount]; | - | ||||||||||||||||||||||||
1242 | for (int i = 1; i < m_groupCount; ++i)
| 16130-36072 | ||||||||||||||||||||||||
1243 | inserted[i] = 0; executed 36072 times by 27 tests: inserted[i] = 0; Executed by:
| 36072 | ||||||||||||||||||||||||
1244 | - | |||||||||||||||||||||||||
1245 | for (const Compositor::Insert &insert : inserts) { | - | ||||||||||||||||||||||||
1246 | for (; cacheIndex < insert.cacheIndex; ++cacheIndex)
| 16086-45018 | ||||||||||||||||||||||||
1247 | incrementIndexes(m_cache.at(cacheIndex), m_groupCount, inserted); executed 45018 times by 8 tests: incrementIndexes(m_cache.at(cacheIndex), m_groupCount, inserted); Executed by:
| 45018 | ||||||||||||||||||||||||
1248 | - | |||||||||||||||||||||||||
1249 | for (int i = 1; i < m_groupCount; ++i) {
| 16086-35768 | ||||||||||||||||||||||||
1250 | if (insert.inGroup(i)) {
| 16816-18952 | ||||||||||||||||||||||||
1251 | (*translatedInserts)[i].append( | - | ||||||||||||||||||||||||
1252 | QQmlChangeSet::Change(insert.index[i], insert.count, insert.moveId)); | - | ||||||||||||||||||||||||
1253 | inserted[i] += insert.count; | - | ||||||||||||||||||||||||
1254 | } executed 16816 times by 27 tests: end of block Executed by:
| 16816 | ||||||||||||||||||||||||
1255 | } executed 35768 times by 27 tests: end of block Executed by:
| 35768 | ||||||||||||||||||||||||
1256 | - | |||||||||||||||||||||||||
1257 | if (!insert.inCache())
| 1608-14478 | ||||||||||||||||||||||||
1258 | continue; executed 14478 times by 27 tests: continue; Executed by:
| 14478 | ||||||||||||||||||||||||
1259 | - | |||||||||||||||||||||||||
1260 | if (movedItems && insert.isMove()) {
| 0-1018 | ||||||||||||||||||||||||
1261 | QList<QQmlDelegateModelItem *> items = movedItems->take(insert.moveId); | - | ||||||||||||||||||||||||
1262 | Q_ASSERT(items.count() == insert.count); | - | ||||||||||||||||||||||||
1263 | m_cache = m_cache.mid(0, insert.cacheIndex) + items + m_cache.mid(insert.cacheIndex); | - | ||||||||||||||||||||||||
1264 | } executed 1018 times by 6 tests: end of block Executed by:
| 1018 | ||||||||||||||||||||||||
1265 | if (insert.inGroup()) {
| 0-1608 | ||||||||||||||||||||||||
1266 | for (int offset = 0; cacheIndex < insert.cacheIndex + insert.count; ++cacheIndex, ++offset) {
| 1608-2764 | ||||||||||||||||||||||||
1267 | QQmlDelegateModelItem *cacheItem = m_cache.at(cacheIndex); | - | ||||||||||||||||||||||||
1268 | cacheItem->groups |= insert.flags & Compositor::GroupMask; | - | ||||||||||||||||||||||||
1269 | - | |||||||||||||||||||||||||
1270 | if (QQDMIncubationTask *incubationTask = cacheItem->incubationTask) {
| 6-2758 | ||||||||||||||||||||||||
1271 | for (int i = 1; i < m_groupCount; ++i)
| 6-12 | ||||||||||||||||||||||||
1272 | incubationTask->index[i] = cacheItem->groups & (1 << i) executed 12 times by 2 tests: incubationTask->index[i] = cacheItem->groups & (1 << i) ? insert.index[i] + offset : insert.index[i]; Executed by:
| 6-12 | ||||||||||||||||||||||||
1273 | ? insert.index[i] + offset executed 12 times by 2 tests: incubationTask->index[i] = cacheItem->groups & (1 << i) ? insert.index[i] + offset : insert.index[i]; Executed by:
| 12 | ||||||||||||||||||||||||
1274 | : insert.index[i]; executed 12 times by 2 tests: incubationTask->index[i] = cacheItem->groups & (1 << i) ? insert.index[i] + offset : insert.index[i]; Executed by:
| 12 | ||||||||||||||||||||||||
1275 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||||||||
1276 | if (QQmlDelegateModelAttached *attached = cacheItem->attached) {
| 100-2664 | ||||||||||||||||||||||||
1277 | for (int i = 1; i < m_groupCount; ++i)
| 100-388 | ||||||||||||||||||||||||
1278 | attached->m_currentIndex[i] = cacheItem->groups & (1 << i) executed 388 times by 2 tests: attached->m_currentIndex[i] = cacheItem->groups & (1 << i) ? insert.index[i] + offset : insert.index[i]; Executed by:
| 164-388 | ||||||||||||||||||||||||
1279 | ? insert.index[i] + offset executed 388 times by 2 tests: attached->m_currentIndex[i] = cacheItem->groups & (1 << i) ? insert.index[i] + offset : insert.index[i]; Executed by:
| 388 | ||||||||||||||||||||||||
1280 | : insert.index[i]; executed 388 times by 2 tests: attached->m_currentIndex[i] = cacheItem->groups & (1 << i) ? insert.index[i] + offset : insert.index[i]; Executed by:
| 388 | ||||||||||||||||||||||||
1281 | } executed 100 times by 2 tests: end of block Executed by:
| 100 | ||||||||||||||||||||||||
1282 | } executed 2764 times by 6 tests: end of block Executed by:
| 2764 | ||||||||||||||||||||||||
1283 | } else { executed 1608 times by 6 tests: end of block Executed by:
| 1608 | ||||||||||||||||||||||||
1284 | cacheIndex = insert.cacheIndex + insert.count; | - | ||||||||||||||||||||||||
1285 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1286 | } | - | ||||||||||||||||||||||||
1287 | for (const QList<QQmlDelegateModelItem *> cache = m_cache; cacheIndex < cache.count(); ++cacheIndex)
| 16130-25798 | ||||||||||||||||||||||||
1288 | incrementIndexes(cache.at(cacheIndex), m_groupCount, inserted); executed 25798 times by 8 tests: incrementIndexes(cache.at(cacheIndex), m_groupCount, inserted); Executed by:
| 25798 | ||||||||||||||||||||||||
1289 | } executed 16130 times by 27 tests: end of block Executed by:
| 16130 | ||||||||||||||||||||||||
1290 | - | |||||||||||||||||||||||||
1291 | void QQmlDelegateModelPrivate::itemsInserted(const QVector<Compositor::Insert> &inserts) | - | ||||||||||||||||||||||||
1292 | { | - | ||||||||||||||||||||||||
1293 | QVarLengthArray<QVector<QQmlChangeSet::Change>, Compositor::MaximumGroupCount> translatedInserts(m_groupCount); | - | ||||||||||||||||||||||||
1294 | itemsInserted(inserts, &translatedInserts); | - | ||||||||||||||||||||||||
1295 | Q_ASSERT(m_cache.count() == m_compositor.count(Compositor::Cache)); | - | ||||||||||||||||||||||||
1296 | if (!m_delegate)
| 42-14782 | ||||||||||||||||||||||||
1297 | return; executed 42 times by 7 tests: return; Executed by:
| 42 | ||||||||||||||||||||||||
1298 | - | |||||||||||||||||||||||||
1299 | for (int i = 1; i < m_groupCount; ++i)
| 14782-33018 | ||||||||||||||||||||||||
1300 | QQmlDelegateModelGroupPrivate::get(m_groups[i])->changeSet.insert(translatedInserts.at(i)); executed 33018 times by 26 tests: QQmlDelegateModelGroupPrivate::get(m_groups[i])->changeSet.insert(translatedInserts.at(i)); Executed by:
| 33018 | ||||||||||||||||||||||||
1301 | } executed 14782 times by 26 tests: end of block Executed by:
| 14782 | ||||||||||||||||||||||||
1302 | - | |||||||||||||||||||||||||
1303 | void QQmlDelegateModel::_q_itemsInserted(int index, int count) | - | ||||||||||||||||||||||||
1304 | { | - | ||||||||||||||||||||||||
1305 | - | |||||||||||||||||||||||||
1306 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
1307 | if (count <= 0 || !d->m_complete)
| 72-8148 | ||||||||||||||||||||||||
1308 | return; executed 232 times by 10 tests: return; Executed by:
| 232 | ||||||||||||||||||||||||
1309 | - | |||||||||||||||||||||||||
1310 | d->m_count += count; | - | ||||||||||||||||||||||||
1311 | - | |||||||||||||||||||||||||
1312 | const QList<QQmlDelegateModelItem *> cache = d->m_cache; | - | ||||||||||||||||||||||||
1313 | for (int i = 0, c = cache.count(); i < c; ++i) {
| 8076-48762 | ||||||||||||||||||||||||
1314 | QQmlDelegateModelItem *item = cache.at(i); | - | ||||||||||||||||||||||||
1315 | if (item->modelIndex() >= index)
| 12234-36528 | ||||||||||||||||||||||||
1316 | item->setModelIndex(item->modelIndex() + count); executed 12234 times by 7 tests: item->setModelIndex(item->modelIndex() + count); Executed by:
| 12234 | ||||||||||||||||||||||||
1317 | } executed 48762 times by 7 tests: end of block Executed by:
| 48762 | ||||||||||||||||||||||||
1318 | - | |||||||||||||||||||||||||
1319 | QVector<Compositor::Insert> inserts; | - | ||||||||||||||||||||||||
1320 | d->m_compositor.listItemsInserted(&d->m_adaptorModel, index, count, &inserts); | - | ||||||||||||||||||||||||
1321 | d->itemsInserted(inserts); | - | ||||||||||||||||||||||||
1322 | d->emitChanges(); | - | ||||||||||||||||||||||||
1323 | } executed 8076 times by 13 tests: end of block Executed by:
| 8076 | ||||||||||||||||||||||||
1324 | - | |||||||||||||||||||||||||
1325 | //### This method should be split in two. It will remove delegates, and it will re-render the list. | - | ||||||||||||||||||||||||
1326 | // When e.g. QQmlListModel::remove is called, the removal of the delegates should be done on | - | ||||||||||||||||||||||||
1327 | // QAbstractItemModel::rowsAboutToBeRemoved, and the re-rendering on | - | ||||||||||||||||||||||||
1328 | // QAbstractItemModel::rowsRemoved. Currently both are done on the latter signal. The problem is | - | ||||||||||||||||||||||||
1329 | // that the destruction of an item will emit a changed signal that ends up at the delegate, which | - | ||||||||||||||||||||||||
1330 | // in turn will try to load the data from the model (which should have already freed it), resulting | - | ||||||||||||||||||||||||
1331 | // in a use-after-free. See QTBUG-59256. | - | ||||||||||||||||||||||||
1332 | void QQmlDelegateModelPrivate::itemsRemoved( | - | ||||||||||||||||||||||||
1333 | const QVector<Compositor::Remove> &removes, | - | ||||||||||||||||||||||||
1334 | QVarLengthArray<QVector<QQmlChangeSet::Change>, Compositor::MaximumGroupCount> *translatedRemoves, | - | ||||||||||||||||||||||||
1335 | QHash<int, QList<QQmlDelegateModelItem *> > *movedItems) | - | ||||||||||||||||||||||||
1336 | { | - | ||||||||||||||||||||||||
1337 | int cacheIndex = 0; | - | ||||||||||||||||||||||||
1338 | int removedCache = 0; | - | ||||||||||||||||||||||||
1339 | - | |||||||||||||||||||||||||
1340 | int removed[Compositor::MaximumGroupCount]; | - | ||||||||||||||||||||||||
1341 | for (int i = 1; i < m_groupCount; ++i)
| 4074-8912 | ||||||||||||||||||||||||
1342 | removed[i] = 0; executed 8912 times by 12 tests: removed[i] = 0; Executed by:
| 8912 | ||||||||||||||||||||||||
1343 | - | |||||||||||||||||||||||||
1344 | for (const Compositor::Remove &remove : removes) { | - | ||||||||||||||||||||||||
1345 | for (; cacheIndex < remove.cacheIndex; ++cacheIndex)
| 4484-21509 | ||||||||||||||||||||||||
1346 | incrementIndexes(m_cache.at(cacheIndex), m_groupCount, removed); executed 21509 times by 6 tests: incrementIndexes(m_cache.at(cacheIndex), m_groupCount, removed); Executed by:
| 21509 | ||||||||||||||||||||||||
1347 | - | |||||||||||||||||||||||||
1348 | for (int i = 1; i < m_groupCount; ++i) {
| 4484-9788 | ||||||||||||||||||||||||
1349 | if (remove.inGroup(i)) {
| 4688-5100 | ||||||||||||||||||||||||
1350 | (*translatedRemoves)[i].append( | - | ||||||||||||||||||||||||
1351 | QQmlChangeSet::Change(remove.index[i], remove.count, remove.moveId)); | - | ||||||||||||||||||||||||
1352 | removed[i] -= remove.count; | - | ||||||||||||||||||||||||
1353 | } executed 4688 times by 12 tests: end of block Executed by:
| 4688 | ||||||||||||||||||||||||
1354 | } executed 9788 times by 12 tests: end of block Executed by:
| 9788 | ||||||||||||||||||||||||
1355 | - | |||||||||||||||||||||||||
1356 | if (!remove.inCache())
| 1221-3263 | ||||||||||||||||||||||||
1357 | continue; executed 1221 times by 9 tests: continue; Executed by:
| 1221 | ||||||||||||||||||||||||
1358 | - | |||||||||||||||||||||||||
1359 | if (movedItems && remove.isMove()) {
| 44-2201 | ||||||||||||||||||||||||
1360 | movedItems->insert(remove.moveId, m_cache.mid(remove.cacheIndex, remove.count)); | - | ||||||||||||||||||||||||
1361 | QList<QQmlDelegateModelItem *>::iterator begin = m_cache.begin() + remove.cacheIndex; | - | ||||||||||||||||||||||||
1362 | QList<QQmlDelegateModelItem *>::iterator end = begin + remove.count; | - | ||||||||||||||||||||||||
1363 | m_cache.erase(begin, end); | - | ||||||||||||||||||||||||
1364 | } else { executed 1018 times by 6 tests: end of block Executed by:
| 1018 | ||||||||||||||||||||||||
1365 | for (; cacheIndex < remove.cacheIndex + remove.count - removedCache; ++cacheIndex) {
| 2245-5184 | ||||||||||||||||||||||||
1366 | QQmlDelegateModelItem *cacheItem = m_cache.at(cacheIndex); | - | ||||||||||||||||||||||||
1367 | if (remove.inGroup(Compositor::Persisted) && cacheItem->objectRef == 0 && cacheItem->object) {
| 12-5140 | ||||||||||||||||||||||||
1368 | QObject *object = cacheItem->object; | - | ||||||||||||||||||||||||
1369 | cacheItem->destroyObject(); | - | ||||||||||||||||||||||||
1370 | if (QQuickPackage *package = qmlobject_cast<QQuickPackage *>(object))
| 4-6 | ||||||||||||||||||||||||
1371 | emitDestroyingPackage(package); executed 4 times by 1 test: emitDestroyingPackage(package); Executed by:
| 4 | ||||||||||||||||||||||||
1372 | else | - | ||||||||||||||||||||||||
1373 | emitDestroyingItem(object); executed 6 times by 1 test: emitDestroyingItem(object); Executed by:
| 6 | ||||||||||||||||||||||||
1374 | cacheItem->scriptRef -= 1; | - | ||||||||||||||||||||||||
1375 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
1376 | if (!cacheItem->isReferenced()) {
| 2-5182 | ||||||||||||||||||||||||
1377 | m_compositor.clearFlags(Compositor::Cache, cacheIndex, 1, Compositor::CacheFlag); | - | ||||||||||||||||||||||||
1378 | m_cache.removeAt(cacheIndex); | - | ||||||||||||||||||||||||
1379 | delete cacheItem; | - | ||||||||||||||||||||||||
1380 | --cacheIndex; | - | ||||||||||||||||||||||||
1381 | ++removedCache; | - | ||||||||||||||||||||||||
1382 | Q_ASSERT(m_cache.count() == m_compositor.count(Compositor::Cache)); | - | ||||||||||||||||||||||||
1383 | } else if (remove.groups() == cacheItem->groups) { executed 2 times by 1 test: end of block Executed by:
| 0-5182 | ||||||||||||||||||||||||
1384 | cacheItem->groups = 0; | - | ||||||||||||||||||||||||
1385 | if (QQDMIncubationTask *incubationTask = cacheItem->incubationTask) {
| 0 | ||||||||||||||||||||||||
1386 | for (int i = 1; i < m_groupCount; ++i)
| 0 | ||||||||||||||||||||||||
1387 | incubationTask->index[i] = -1; never executed: incubationTask->index[i] = -1; | 0 | ||||||||||||||||||||||||
1388 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1389 | if (QQmlDelegateModelAttached *attached = cacheItem->attached) {
| 0 | ||||||||||||||||||||||||
1390 | for (int i = 1; i < m_groupCount; ++i)
| 0 | ||||||||||||||||||||||||
1391 | attached->m_currentIndex[i] = -1; never executed: attached->m_currentIndex[i] = -1; | 0 | ||||||||||||||||||||||||
1392 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1393 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
1394 | if (QQDMIncubationTask *incubationTask = cacheItem->incubationTask) {
| 21-5161 | ||||||||||||||||||||||||
1395 | if (!cacheItem->isObjectReferenced()) {
| 2-19 | ||||||||||||||||||||||||
1396 | releaseIncubator(cacheItem->incubationTask); | - | ||||||||||||||||||||||||
1397 | cacheItem->incubationTask = nullptr; | - | ||||||||||||||||||||||||
1398 | if (cacheItem->object) {
| 0-19 | ||||||||||||||||||||||||
1399 | QObject *object = cacheItem->object; | - | ||||||||||||||||||||||||
1400 | cacheItem->destroyObject(); | - | ||||||||||||||||||||||||
1401 | if (QQuickPackage *package = qmlobject_cast<QQuickPackage *>(object))
| 0 | ||||||||||||||||||||||||
1402 | emitDestroyingPackage(package); never executed: emitDestroyingPackage(package); | 0 | ||||||||||||||||||||||||
1403 | else | - | ||||||||||||||||||||||||
1404 | emitDestroyingItem(object); never executed: emitDestroyingItem(object); | 0 | ||||||||||||||||||||||||
1405 | } | - | ||||||||||||||||||||||||
1406 | cacheItem->scriptRef -= 1; | - | ||||||||||||||||||||||||
1407 | } else { executed 19 times by 3 tests: end of block Executed by:
| 19 | ||||||||||||||||||||||||
1408 | for (int i = 1; i < m_groupCount; ++i) {
| 2-4 | ||||||||||||||||||||||||
1409 | if (remove.inGroup(i))
| 2 | ||||||||||||||||||||||||
1410 | incubationTask->index[i] = remove.index[i]; executed 2 times by 1 test: incubationTask->index[i] = remove.index[i]; Executed by:
| 2 | ||||||||||||||||||||||||
1411 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
1412 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1413 | } | - | ||||||||||||||||||||||||
1414 | if (QQmlDelegateModelAttached *attached = cacheItem->attached) {
| 60-5122 | ||||||||||||||||||||||||
1415 | for (int i = 1; i < m_groupCount; ++i) {
| 60-224 | ||||||||||||||||||||||||
1416 | if (remove.inGroup(i))
| 72-152 | ||||||||||||||||||||||||
1417 | attached->m_currentIndex[i] = remove.index[i]; executed 72 times by 1 test: attached->m_currentIndex[i] = remove.index[i]; Executed by:
| 72 | ||||||||||||||||||||||||
1418 | } executed 224 times by 1 test: end of block Executed by:
| 224 | ||||||||||||||||||||||||
1419 | } executed 60 times by 1 test: end of block Executed by:
| 60 | ||||||||||||||||||||||||
1420 | cacheItem->groups &= ~remove.flags; | - | ||||||||||||||||||||||||
1421 | } executed 5182 times by 8 tests: end of block Executed by:
| 5182 | ||||||||||||||||||||||||
1422 | } | - | ||||||||||||||||||||||||
1423 | } executed 2245 times by 8 tests: end of block Executed by:
| 2245 | ||||||||||||||||||||||||
1424 | } | - | ||||||||||||||||||||||||
1425 | - | |||||||||||||||||||||||||
1426 | for (const QList<QQmlDelegateModelItem *> cache = m_cache; cacheIndex < cache.count(); ++cacheIndex)
| 4074-28406 | ||||||||||||||||||||||||
1427 | incrementIndexes(cache.at(cacheIndex), m_groupCount, removed); executed 28406 times by 8 tests: incrementIndexes(cache.at(cacheIndex), m_groupCount, removed); Executed by:
| 28406 | ||||||||||||||||||||||||
1428 | } executed 4074 times by 12 tests: end of block Executed by:
| 4074 | ||||||||||||||||||||||||
1429 | - | |||||||||||||||||||||||||
1430 | void QQmlDelegateModelPrivate::itemsRemoved(const QVector<Compositor::Remove> &removes) | - | ||||||||||||||||||||||||
1431 | { | - | ||||||||||||||||||||||||
1432 | QVarLengthArray<QVector<QQmlChangeSet::Change>, Compositor::MaximumGroupCount> translatedRemoves(m_groupCount); | - | ||||||||||||||||||||||||
1433 | itemsRemoved(removes, &translatedRemoves); | - | ||||||||||||||||||||||||
1434 | Q_ASSERT(m_cache.count() == m_compositor.count(Compositor::Cache)); | - | ||||||||||||||||||||||||
1435 | if (!m_delegate)
| 4-2764 | ||||||||||||||||||||||||
1436 | return; executed 4 times by 1 test: return; Executed by:
| 4 | ||||||||||||||||||||||||
1437 | - | |||||||||||||||||||||||||
1438 | for (int i = 1; i < m_groupCount; ++i)
| 2764-5938 | ||||||||||||||||||||||||
1439 | QQmlDelegateModelGroupPrivate::get(m_groups[i])->changeSet.remove(translatedRemoves.at(i)); executed 5938 times by 12 tests: QQmlDelegateModelGroupPrivate::get(m_groups[i])->changeSet.remove(translatedRemoves.at(i)); Executed by:
| 5938 | ||||||||||||||||||||||||
1440 | } executed 2764 times by 12 tests: end of block Executed by:
| 2764 | ||||||||||||||||||||||||
1441 | - | |||||||||||||||||||||||||
1442 | void QQmlDelegateModel::_q_itemsRemoved(int index, int count) | - | ||||||||||||||||||||||||
1443 | { | - | ||||||||||||||||||||||||
1444 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
1445 | if (count <= 0|| !d->m_complete)
| 0-2558 | ||||||||||||||||||||||||
1446 | return; executed 390 times by 10 tests: return; Executed by:
| 390 | ||||||||||||||||||||||||
1447 | - | |||||||||||||||||||||||||
1448 | d->m_count -= count; | - | ||||||||||||||||||||||||
1449 | const QList<QQmlDelegateModelItem *> cache = d->m_cache; | - | ||||||||||||||||||||||||
1450 | for (int i = 0, c = cache.count(); i < c; ++i) {
| 2558-36723 | ||||||||||||||||||||||||
1451 | QQmlDelegateModelItem *item = cache.at(i); | - | ||||||||||||||||||||||||
1452 | // layout change triggered by removal of a previous item might have | - | ||||||||||||||||||||||||
1453 | // already invalidated this item in d->m_cache and deleted it | - | ||||||||||||||||||||||||
1454 | if (!d->m_cache.contains(item))
| 0-36723 | ||||||||||||||||||||||||
1455 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
1456 | - | |||||||||||||||||||||||||
1457 | if (item->modelIndex() >= index + count)
| 14731-21992 | ||||||||||||||||||||||||
1458 | item->setModelIndex(item->modelIndex() - count); executed 14731 times by 7 tests: item->setModelIndex(item->modelIndex() - count); Executed by:
| 14731 | ||||||||||||||||||||||||
1459 | else if (item->modelIndex() >= index)
| 4482-17510 | ||||||||||||||||||||||||
1460 | item->setModelIndex(-1); executed 4482 times by 7 tests: item->setModelIndex(-1); Executed by:
| 4482 | ||||||||||||||||||||||||
1461 | } executed 36723 times by 7 tests: end of block Executed by:
| 36723 | ||||||||||||||||||||||||
1462 | - | |||||||||||||||||||||||||
1463 | QVector<Compositor::Remove> removes; | - | ||||||||||||||||||||||||
1464 | d->m_compositor.listItemsRemoved(&d->m_adaptorModel, index, count, &removes); | - | ||||||||||||||||||||||||
1465 | d->itemsRemoved(removes); | - | ||||||||||||||||||||||||
1466 | - | |||||||||||||||||||||||||
1467 | d->emitChanges(); | - | ||||||||||||||||||||||||
1468 | } executed 2558 times by 11 tests: end of block Executed by:
| 2558 | ||||||||||||||||||||||||
1469 | - | |||||||||||||||||||||||||
1470 | void QQmlDelegateModelPrivate::itemsMoved( | - | ||||||||||||||||||||||||
1471 | const QVector<Compositor::Remove> &removes, const QVector<Compositor::Insert> &inserts) | - | ||||||||||||||||||||||||
1472 | { | - | ||||||||||||||||||||||||
1473 | QHash<int, QList<QQmlDelegateModelItem *> > movedItems; | - | ||||||||||||||||||||||||
1474 | - | |||||||||||||||||||||||||
1475 | QVarLengthArray<QVector<QQmlChangeSet::Change>, Compositor::MaximumGroupCount> translatedRemoves(m_groupCount); | - | ||||||||||||||||||||||||
1476 | itemsRemoved(removes, &translatedRemoves, &movedItems); | - | ||||||||||||||||||||||||
1477 | - | |||||||||||||||||||||||||
1478 | QVarLengthArray<QVector<QQmlChangeSet::Change>, Compositor::MaximumGroupCount> translatedInserts(m_groupCount); | - | ||||||||||||||||||||||||
1479 | itemsInserted(inserts, &translatedInserts, &movedItems); | - | ||||||||||||||||||||||||
1480 | Q_ASSERT(m_cache.count() == m_compositor.count(Compositor::Cache)); | - | ||||||||||||||||||||||||
1481 | Q_ASSERT(movedItems.isEmpty()); | - | ||||||||||||||||||||||||
1482 | if (!m_delegate)
| 0-1306 | ||||||||||||||||||||||||
1483 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1484 | - | |||||||||||||||||||||||||
1485 | for (int i = 1; i < m_groupCount; ++i) {
| 1306-2966 | ||||||||||||||||||||||||
1486 | QQmlDelegateModelGroupPrivate::get(m_groups[i])->changeSet.move( | - | ||||||||||||||||||||||||
1487 | translatedRemoves.at(i), | - | ||||||||||||||||||||||||
1488 | translatedInserts.at(i)); | - | ||||||||||||||||||||||||
1489 | } executed 2966 times by 6 tests: end of block Executed by:
| 2966 | ||||||||||||||||||||||||
1490 | } executed 1306 times by 6 tests: end of block Executed by:
| 1306 | ||||||||||||||||||||||||
1491 | - | |||||||||||||||||||||||||
1492 | void QQmlDelegateModel::_q_itemsMoved(int from, int to, int count) | - | ||||||||||||||||||||||||
1493 | { | - | ||||||||||||||||||||||||
1494 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
1495 | if (count <= 0 || !d->m_complete)
| 0-1080 | ||||||||||||||||||||||||
1496 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1497 | - | |||||||||||||||||||||||||
1498 | const int minimum = qMin(from, to); | - | ||||||||||||||||||||||||
1499 | const int maximum = qMax(from, to) + count; | - | ||||||||||||||||||||||||
1500 | const int difference = from > to ? count : -count;
| 534-546 | ||||||||||||||||||||||||
1501 | - | |||||||||||||||||||||||||
1502 | const QList<QQmlDelegateModelItem *> cache = d->m_cache; | - | ||||||||||||||||||||||||
1503 | for (int i = 0, c = cache.count(); i < c; ++i) {
| 1080-17670 | ||||||||||||||||||||||||
1504 | QQmlDelegateModelItem *item = cache.at(i); | - | ||||||||||||||||||||||||
1505 | if (item->modelIndex() >= from && item->modelIndex() < from + count)
| 1958-11564 | ||||||||||||||||||||||||
1506 | item->setModelIndex(item->modelIndex() - from + to); executed 1958 times by 5 tests: item->setModelIndex(item->modelIndex() - from + to); Executed by:
| 1958 | ||||||||||||||||||||||||
1507 | else if (item->modelIndex() >= minimum && item->modelIndex() < maximum)
| 2336-13376 | ||||||||||||||||||||||||
1508 | item->setModelIndex(item->modelIndex() + difference); executed 8144 times by 5 tests: item->setModelIndex(item->modelIndex() + difference); Executed by:
| 8144 | ||||||||||||||||||||||||
1509 | } executed 17670 times by 5 tests: end of block Executed by:
| 17670 | ||||||||||||||||||||||||
1510 | - | |||||||||||||||||||||||||
1511 | QVector<Compositor::Remove> removes; | - | ||||||||||||||||||||||||
1512 | QVector<Compositor::Insert> inserts; | - | ||||||||||||||||||||||||
1513 | d->m_compositor.listItemsMoved(&d->m_adaptorModel, from, to, count, &removes, &inserts); | - | ||||||||||||||||||||||||
1514 | d->itemsMoved(removes, inserts); | - | ||||||||||||||||||||||||
1515 | d->emitChanges(); | - | ||||||||||||||||||||||||
1516 | } executed 1080 times by 5 tests: end of block Executed by:
| 1080 | ||||||||||||||||||||||||
1517 | - | |||||||||||||||||||||||||
1518 | void QQmlDelegateModelPrivate::emitModelUpdated(const QQmlChangeSet &changeSet, bool reset) | - | ||||||||||||||||||||||||
1519 | { | - | ||||||||||||||||||||||||
1520 | Q_Q(QQmlDelegateModel); | - | ||||||||||||||||||||||||
1521 | emit q->modelUpdated(changeSet, reset); | - | ||||||||||||||||||||||||
1522 | if (changeSet.difference() != 0)
| 3630-15250 | ||||||||||||||||||||||||
1523 | emit q->countChanged(); executed 15250 times by 25 tests: q->countChanged(); Executed by:
| 15250 | ||||||||||||||||||||||||
1524 | } executed 18880 times by 27 tests: end of block Executed by:
| 18880 | ||||||||||||||||||||||||
1525 | - | |||||||||||||||||||||||||
1526 | void QQmlDelegateModelPrivate::emitChanges() | - | ||||||||||||||||||||||||
1527 | { | - | ||||||||||||||||||||||||
1528 | if (m_transaction || !m_complete || !m_context || !m_context->isValid())
| 0-24480 | ||||||||||||||||||||||||
1529 | return; executed 5636 times by 26 tests: return; Executed by:
| 5636 | ||||||||||||||||||||||||
1530 | - | |||||||||||||||||||||||||
1531 | m_transaction = true; | - | ||||||||||||||||||||||||
1532 | QV4::ExecutionEngine *engine = m_context->engine()->handle(); | - | ||||||||||||||||||||||||
1533 | for (int i = 1; i < m_groupCount; ++i)
| 18880-41120 | ||||||||||||||||||||||||
1534 | QQmlDelegateModelGroupPrivate::get(m_groups[i])->emitChanges(engine); executed 41120 times by 27 tests: QQmlDelegateModelGroupPrivate::get(m_groups[i])->emitChanges(engine); Executed by:
| 41120 | ||||||||||||||||||||||||
1535 | m_transaction = false; | - | ||||||||||||||||||||||||
1536 | - | |||||||||||||||||||||||||
1537 | const bool reset = m_reset; | - | ||||||||||||||||||||||||
1538 | m_reset = false; | - | ||||||||||||||||||||||||
1539 | for (int i = 1; i < m_groupCount; ++i)
| 18880-41120 | ||||||||||||||||||||||||
1540 | QQmlDelegateModelGroupPrivate::get(m_groups[i])->emitModelUpdated(reset); executed 41120 times by 27 tests: QQmlDelegateModelGroupPrivate::get(m_groups[i])->emitModelUpdated(reset); Executed by:
| 41120 | ||||||||||||||||||||||||
1541 | - | |||||||||||||||||||||||||
1542 | auto cacheCopy = m_cache; // deliberate; emitChanges may alter m_cache | - | ||||||||||||||||||||||||
1543 | for (QQmlDelegateModelItem *cacheItem : qAsConst(cacheCopy)) { | - | ||||||||||||||||||||||||
1544 | if (cacheItem->attached)
| 2324-113699 | ||||||||||||||||||||||||
1545 | cacheItem->attached->emitChanges(); executed 2324 times by 2 tests: cacheItem->attached->emitChanges(); Executed by:
| 2324 | ||||||||||||||||||||||||
1546 | } executed 116023 times by 8 tests: end of block Executed by:
| 116023 | ||||||||||||||||||||||||
1547 | } executed 18880 times by 27 tests: end of block Executed by:
| 18880 | ||||||||||||||||||||||||
1548 | - | |||||||||||||||||||||||||
1549 | void QQmlDelegateModel::_q_modelReset() | - | ||||||||||||||||||||||||
1550 | { | - | ||||||||||||||||||||||||
1551 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
1552 | if (!d->m_delegate)
| 0-54 | ||||||||||||||||||||||||
1553 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1554 | - | |||||||||||||||||||||||||
1555 | int oldCount = d->m_count; | - | ||||||||||||||||||||||||
1556 | d->m_adaptorModel.rootIndex = QModelIndex(); | - | ||||||||||||||||||||||||
1557 | - | |||||||||||||||||||||||||
1558 | if (d->m_complete) {
| 2-52 | ||||||||||||||||||||||||
1559 | d->m_count = d->adaptorModelCount(); | - | ||||||||||||||||||||||||
1560 | - | |||||||||||||||||||||||||
1561 | const QList<QQmlDelegateModelItem *> cache = d->m_cache; | - | ||||||||||||||||||||||||
1562 | for (int i = 0, c = cache.count(); i < c; ++i) {
| 52-516 | ||||||||||||||||||||||||
1563 | QQmlDelegateModelItem *item = cache.at(i); | - | ||||||||||||||||||||||||
1564 | if (item->modelIndex() != -1)
| 0-516 | ||||||||||||||||||||||||
1565 | item->setModelIndex(-1); executed 516 times by 4 tests: item->setModelIndex(-1); Executed by:
| 516 | ||||||||||||||||||||||||
1566 | } executed 516 times by 4 tests: end of block Executed by:
| 516 | ||||||||||||||||||||||||
1567 | - | |||||||||||||||||||||||||
1568 | QVector<Compositor::Remove> removes; | - | ||||||||||||||||||||||||
1569 | QVector<Compositor::Insert> inserts; | - | ||||||||||||||||||||||||
1570 | if (oldCount)
| 8-44 | ||||||||||||||||||||||||
1571 | d->m_compositor.listItemsRemoved(&d->m_adaptorModel, 0, oldCount, &removes); executed 44 times by 4 tests: d->m_compositor.listItemsRemoved(&d->m_adaptorModel, 0, oldCount, &removes); Executed by:
| 44 | ||||||||||||||||||||||||
1572 | if (d->m_count)
| 6-46 | ||||||||||||||||||||||||
1573 | d->m_compositor.listItemsInserted(&d->m_adaptorModel, 0, d->m_count, &inserts); executed 46 times by 4 tests: d->m_compositor.listItemsInserted(&d->m_adaptorModel, 0, d->m_count, &inserts); Executed by:
| 46 | ||||||||||||||||||||||||
1574 | d->itemsMoved(removes, inserts); | - | ||||||||||||||||||||||||
1575 | d->m_reset = true; | - | ||||||||||||||||||||||||
1576 | - | |||||||||||||||||||||||||
1577 | if (d->m_adaptorModel.canFetchMore())
| 0-52 | ||||||||||||||||||||||||
1578 | d->m_adaptorModel.fetchMore(); never executed: d->m_adaptorModel.fetchMore(); | 0 | ||||||||||||||||||||||||
1579 | - | |||||||||||||||||||||||||
1580 | d->emitChanges(); | - | ||||||||||||||||||||||||
1581 | } executed 52 times by 5 tests: end of block Executed by:
| 52 | ||||||||||||||||||||||||
1582 | emit rootIndexChanged(); | - | ||||||||||||||||||||||||
1583 | } executed 54 times by 5 tests: end of block Executed by:
| 54 | ||||||||||||||||||||||||
1584 | - | |||||||||||||||||||||||||
1585 | void QQmlDelegateModel::_q_rowsInserted(const QModelIndex &parent, int begin, int end) | - | ||||||||||||||||||||||||
1586 | { | - | ||||||||||||||||||||||||
1587 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
1588 | if (parent == d->m_adaptorModel.rootIndex)
| 2-7638 | ||||||||||||||||||||||||
1589 | _q_itemsInserted(begin, end - begin + 1); executed 7638 times by 8 tests: _q_itemsInserted(begin, end - begin + 1); Executed by:
| 7638 | ||||||||||||||||||||||||
1590 | } executed 7640 times by 8 tests: end of block Executed by:
| 7640 | ||||||||||||||||||||||||
1591 | - | |||||||||||||||||||||||||
1592 | void QQmlDelegateModel::_q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end) | - | ||||||||||||||||||||||||
1593 | { | - | ||||||||||||||||||||||||
1594 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
1595 | if (!d->m_adaptorModel.rootIndex.isValid())
| 8-2272 | ||||||||||||||||||||||||
1596 | return; executed 2272 times by 7 tests: return; Executed by:
| 2272 | ||||||||||||||||||||||||
1597 | const QModelIndex index = d->m_adaptorModel.rootIndex; | - | ||||||||||||||||||||||||
1598 | if (index.parent() == parent && index.row() >= begin && index.row() <= end) {
| 0-4 | ||||||||||||||||||||||||
1599 | const int oldCount = d->m_count; | - | ||||||||||||||||||||||||
1600 | d->m_count = 0; | - | ||||||||||||||||||||||||
1601 | d->m_adaptorModel.invalidateModel(this); | - | ||||||||||||||||||||||||
1602 | - | |||||||||||||||||||||||||
1603 | if (d->m_complete && oldCount > 0) {
| 0-2 | ||||||||||||||||||||||||
1604 | QVector<Compositor::Remove> removes; | - | ||||||||||||||||||||||||
1605 | d->m_compositor.listItemsRemoved(&d->m_adaptorModel, 0, oldCount, &removes); | - | ||||||||||||||||||||||||
1606 | d->itemsRemoved(removes); | - | ||||||||||||||||||||||||
1607 | d->emitChanges(); | - | ||||||||||||||||||||||||
1608 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1609 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1610 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
1611 | - | |||||||||||||||||||||||||
1612 | void QQmlDelegateModel::_q_rowsRemoved(const QModelIndex &parent, int begin, int end) | - | ||||||||||||||||||||||||
1613 | { | - | ||||||||||||||||||||||||
1614 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
1615 | if (parent == d->m_adaptorModel.rootIndex)
| 2-2276 | ||||||||||||||||||||||||
1616 | _q_itemsRemoved(begin, end - begin + 1); executed 2276 times by 7 tests: _q_itemsRemoved(begin, end - begin + 1); Executed by:
| 2276 | ||||||||||||||||||||||||
1617 | } executed 2278 times by 7 tests: end of block Executed by:
| 2278 | ||||||||||||||||||||||||
1618 | - | |||||||||||||||||||||||||
1619 | void QQmlDelegateModel::_q_rowsMoved( | - | ||||||||||||||||||||||||
1620 | const QModelIndex &sourceParent, int sourceStart, int sourceEnd, | - | ||||||||||||||||||||||||
1621 | const QModelIndex &destinationParent, int destinationRow) | - | ||||||||||||||||||||||||
1622 | { | - | ||||||||||||||||||||||||
1623 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
1624 | const int count = sourceEnd - sourceStart + 1; | - | ||||||||||||||||||||||||
1625 | if (destinationParent == d->m_adaptorModel.rootIndex && sourceParent == d->m_adaptorModel.rootIndex) {
| 2-1082 | ||||||||||||||||||||||||
1626 | _q_itemsMoved(sourceStart, sourceStart > destinationRow ? destinationRow : destinationRow - count, count); | - | ||||||||||||||||||||||||
1627 | } else if (sourceParent == d->m_adaptorModel.rootIndex) { executed 1080 times by 5 tests: end of block Executed by:
| 2-1080 | ||||||||||||||||||||||||
1628 | _q_itemsRemoved(sourceStart, count); | - | ||||||||||||||||||||||||
1629 | } else if (destinationParent == d->m_adaptorModel.rootIndex) { executed 2 times by 1 test: end of block Executed by:
| 2-4 | ||||||||||||||||||||||||
1630 | _q_itemsInserted(destinationRow, count); | - | ||||||||||||||||||||||||
1631 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1632 | } executed 1088 times by 5 tests: end of block Executed by:
| 1088 | ||||||||||||||||||||||||
1633 | - | |||||||||||||||||||||||||
1634 | void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles) | - | ||||||||||||||||||||||||
1635 | { | - | ||||||||||||||||||||||||
1636 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
1637 | if (begin.parent() != d->m_adaptorModel.rootIndex)
| 0-316 | ||||||||||||||||||||||||
1638 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1639 | - | |||||||||||||||||||||||||
1640 | int rowCount = end.row() - begin.row() + 1; | - | ||||||||||||||||||||||||
1641 | - | |||||||||||||||||||||||||
1642 | for (int col = begin.column(); col <= end.column(); ++col) {
| 316 | ||||||||||||||||||||||||
1643 | int startIndex = d->m_adaptorModel.indexAt(begin.row(), col); | - | ||||||||||||||||||||||||
1644 | _q_itemsChanged(startIndex, rowCount, roles); | - | ||||||||||||||||||||||||
1645 | } executed 316 times by 5 tests: end of block Executed by:
| 316 | ||||||||||||||||||||||||
1646 | } executed 316 times by 5 tests: end of block Executed by:
| 316 | ||||||||||||||||||||||||
1647 | - | |||||||||||||||||||||||||
1648 | bool QQmlDelegateModel::isDescendantOf(const QPersistentModelIndex& desc, const QList< QPersistentModelIndex >& parents) const | - | ||||||||||||||||||||||||
1649 | { | - | ||||||||||||||||||||||||
1650 | for (int i = 0, c = parents.count(); i < c; ++i) {
| 0 | ||||||||||||||||||||||||
1651 | for (QPersistentModelIndex parent = desc; parent.isValid(); parent = parent.parent()) {
| 0 | ||||||||||||||||||||||||
1652 | if (parent == parents[i])
| 0 | ||||||||||||||||||||||||
1653 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
1654 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1655 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1656 | - | |||||||||||||||||||||||||
1657 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
1658 | } | - | ||||||||||||||||||||||||
1659 | - | |||||||||||||||||||||||||
1660 | void QQmlDelegateModel::_q_layoutChanged(const QList<QPersistentModelIndex> &parents, QAbstractItemModel::LayoutChangeHint hint) | - | ||||||||||||||||||||||||
1661 | { | - | ||||||||||||||||||||||||
1662 | Q_D(QQmlDelegateModel); | - | ||||||||||||||||||||||||
1663 | if (!d->m_complete)
| 0-186 | ||||||||||||||||||||||||
1664 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1665 | - | |||||||||||||||||||||||||
1666 | if (hint == QAbstractItemModel::VerticalSortHint) {
| 4-182 | ||||||||||||||||||||||||
1667 | if (!parents.isEmpty() && d->m_adaptorModel.rootIndex.isValid() && !isDescendantOf(d->m_adaptorModel.rootIndex, parents)) {
| 0-166 | ||||||||||||||||||||||||
1668 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1669 | } | - | ||||||||||||||||||||||||
1670 | - | |||||||||||||||||||||||||
1671 | // mark all items as changed | - | ||||||||||||||||||||||||
1672 | _q_itemsChanged(0, d->m_count, QVector<int>()); | - | ||||||||||||||||||||||||
1673 | - | |||||||||||||||||||||||||
1674 | } else if (hint == QAbstractItemModel::HorizontalSortHint) { executed 182 times by 2 tests: end of block Executed by:
| 0-182 | ||||||||||||||||||||||||
1675 | // Ignored | - | ||||||||||||||||||||||||
1676 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
1677 | // We don't know what's going on, so reset the model | - | ||||||||||||||||||||||||
1678 | _q_modelReset(); | - | ||||||||||||||||||||||||
1679 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
1680 | } | - | ||||||||||||||||||||||||
1681 | - | |||||||||||||||||||||||||
1682 | QQmlDelegateModelAttached *QQmlDelegateModel::qmlAttachedProperties(QObject *obj) | - | ||||||||||||||||||||||||
1683 | { | - | ||||||||||||||||||||||||
1684 | if (QQmlDelegateModelItem *cacheItem = QQmlDelegateModelItem::dataForObject(obj)) {
| 2-2292 | ||||||||||||||||||||||||
1685 | if (cacheItem->object == obj) { // Don't create attached item for child objects.
| 2-2290 | ||||||||||||||||||||||||
1686 | cacheItem->attached = new QQmlDelegateModelAttached(cacheItem, obj); | - | ||||||||||||||||||||||||
1687 | return cacheItem->attached; executed 2290 times by 3 tests: return cacheItem->attached; Executed by:
| 2290 | ||||||||||||||||||||||||
1688 | } | - | ||||||||||||||||||||||||
1689 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1690 | return new QQmlDelegateModelAttached(obj); executed 4 times by 1 test: return new QQmlDelegateModelAttached(obj); Executed by:
| 4 | ||||||||||||||||||||||||
1691 | } | - | ||||||||||||||||||||||||
1692 | - | |||||||||||||||||||||||||
1693 | bool QQmlDelegateModelPrivate::insert(Compositor::insert_iterator &before, const QV4::Value &object, int groups) | - | ||||||||||||||||||||||||
1694 | { | - | ||||||||||||||||||||||||
1695 | if (!m_context || !m_context->isValid())
| 0-416 | ||||||||||||||||||||||||
1696 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
1697 | - | |||||||||||||||||||||||||
1698 | QQmlDelegateModelItem *cacheItem = m_adaptorModel.createItem(m_cacheMetaType, -1); | - | ||||||||||||||||||||||||
1699 | if (!cacheItem)
| 12-404 | ||||||||||||||||||||||||
1700 | return false; executed 12 times by 1 test: return false; Executed by:
| 12 | ||||||||||||||||||||||||
1701 | if (!object.isObject())
| 0-404 | ||||||||||||||||||||||||
1702 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
1703 | - | |||||||||||||||||||||||||
1704 | QV4::ExecutionEngine *v4 = object.as<QV4::Object>()->engine(); | - | ||||||||||||||||||||||||
1705 | QV4::Scope scope(v4); | - | ||||||||||||||||||||||||
1706 | QV4::ScopedObject o(scope, object); | - | ||||||||||||||||||||||||
1707 | if (!o)
| 0-404 | ||||||||||||||||||||||||
1708 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
1709 | - | |||||||||||||||||||||||||
1710 | QV4::ObjectIterator it(scope, o, QV4::ObjectIterator::EnumerableOnly|QV4::ObjectIterator::WithProtoChain); | - | ||||||||||||||||||||||||
1711 | QV4::ScopedValue propertyName(scope); | - | ||||||||||||||||||||||||
1712 | QV4::ScopedValue v(scope); | - | ||||||||||||||||||||||||
1713 | while (1) { | - | ||||||||||||||||||||||||
1714 | propertyName = it.nextPropertyNameAsString(v); | - | ||||||||||||||||||||||||
1715 | if (propertyName->isNull())
| 404 | ||||||||||||||||||||||||
1716 | break; executed 404 times by 1 test: break; Executed by:
| 404 | ||||||||||||||||||||||||
1717 | cacheItem->setValue(propertyName->toQStringNoThrow(), scope.engine->toVariant(v, QVariant::Invalid)); | - | ||||||||||||||||||||||||
1718 | } executed 404 times by 1 test: end of block Executed by:
| 404 | ||||||||||||||||||||||||
1719 | - | |||||||||||||||||||||||||
1720 | cacheItem->groups = groups | Compositor::UnresolvedFlag | Compositor::CacheFlag; | - | ||||||||||||||||||||||||
1721 | - | |||||||||||||||||||||||||
1722 | // Must be before the new object is inserted into the cache or its indexes will be adjusted too. | - | ||||||||||||||||||||||||
1723 | itemsInserted(QVector<Compositor::Insert>(1, Compositor::Insert(before, 1, cacheItem->groups & ~Compositor::CacheFlag))); | - | ||||||||||||||||||||||||
1724 | - | |||||||||||||||||||||||||
1725 | before = m_compositor.insert(before, nullptr, 0, 1, cacheItem->groups); | - | ||||||||||||||||||||||||
1726 | m_cache.insert(before.cacheIndex, cacheItem); | - | ||||||||||||||||||||||||
1727 | - | |||||||||||||||||||||||||
1728 | return true; executed 404 times by 1 test: return true; Executed by:
| 404 | ||||||||||||||||||||||||
1729 | } | - | ||||||||||||||||||||||||
1730 | - | |||||||||||||||||||||||||
1731 | //============================================================================ | - | ||||||||||||||||||||||||
1732 | - | |||||||||||||||||||||||||
1733 | QQmlDelegateModelItemMetaType::QQmlDelegateModelItemMetaType( | - | ||||||||||||||||||||||||
1734 | QV4::ExecutionEngine *engine, QQmlDelegateModel *model, const QStringList &groupNames) | - | ||||||||||||||||||||||||
1735 | : model(model) | - | ||||||||||||||||||||||||
1736 | , groupCount(groupNames.count() + 1) | - | ||||||||||||||||||||||||
1737 | , v4Engine(engine) | - | ||||||||||||||||||||||||
1738 | , metaObject(nullptr) | - | ||||||||||||||||||||||||
1739 | , groupNames(groupNames) | - | ||||||||||||||||||||||||
1740 | { | - | ||||||||||||||||||||||||
1741 | } executed 5622 times by 27 tests: end of block Executed by:
| 5622 | ||||||||||||||||||||||||
1742 | - | |||||||||||||||||||||||||
1743 | QQmlDelegateModelItemMetaType::~QQmlDelegateModelItemMetaType() | - | ||||||||||||||||||||||||
1744 | { | - | ||||||||||||||||||||||||
1745 | if (metaObject)
| 438-5111 | ||||||||||||||||||||||||
1746 | metaObject->release(); executed 438 times by 3 tests: metaObject->release(); Executed by:
| 438 | ||||||||||||||||||||||||
1747 | } executed 5549 times by 25 tests: end of block Executed by:
| 5549 | ||||||||||||||||||||||||
1748 | - | |||||||||||||||||||||||||
1749 | void QQmlDelegateModelItemMetaType::initializeMetaObject() | - | ||||||||||||||||||||||||
1750 | { | - | ||||||||||||||||||||||||
1751 | QMetaObjectBuilder builder; | - | ||||||||||||||||||||||||
1752 | builder.setFlags(QMetaObjectBuilder::DynamicMetaObject); | - | ||||||||||||||||||||||||
1753 | builder.setClassName(QQmlDelegateModelAttached::staticMetaObject.className()); | - | ||||||||||||||||||||||||
1754 | builder.setSuperClass(&QQmlDelegateModelAttached::staticMetaObject); | - | ||||||||||||||||||||||||
1755 | - | |||||||||||||||||||||||||
1756 | int notifierId = 0; | - | ||||||||||||||||||||||||
1757 | for (int i = 0; i < groupNames.count(); ++i, ++notifierId) {
| 438-1730 | ||||||||||||||||||||||||
1758 | QString propertyName = QLatin1String("in") + groupNames.at(i); | - | ||||||||||||||||||||||||
1759 | propertyName.replace(2, 1, propertyName.at(2).toUpper()); | - | ||||||||||||||||||||||||
1760 | builder.addSignal("__" + propertyName.toUtf8() + "Changed()"); | - | ||||||||||||||||||||||||
1761 | QMetaPropertyBuilder propertyBuilder = builder.addProperty( | - | ||||||||||||||||||||||||
1762 | propertyName.toUtf8(), "bool", notifierId); | - | ||||||||||||||||||||||||
1763 | propertyBuilder.setWritable(true); | - | ||||||||||||||||||||||||
1764 | } executed 1730 times by 3 tests: end of block Executed by:
| 1730 | ||||||||||||||||||||||||
1765 | for (int i = 0; i < groupNames.count(); ++i, ++notifierId) {
| 438-1730 | ||||||||||||||||||||||||
1766 | const QString propertyName = groupNames.at(i) + QLatin1String("Index"); | - | ||||||||||||||||||||||||
1767 | builder.addSignal("__" + propertyName.toUtf8() + "Changed()"); | - | ||||||||||||||||||||||||
1768 | QMetaPropertyBuilder propertyBuilder = builder.addProperty( | - | ||||||||||||||||||||||||
1769 | propertyName.toUtf8(), "int", notifierId); | - | ||||||||||||||||||||||||
1770 | propertyBuilder.setWritable(true); | - | ||||||||||||||||||||||||
1771 | } executed 1730 times by 3 tests: end of block Executed by:
| 1730 | ||||||||||||||||||||||||
1772 | - | |||||||||||||||||||||||||
1773 | metaObject = new QQmlDelegateModelAttachedMetaObject(this, builder.toMetaObject()); | - | ||||||||||||||||||||||||
1774 | } executed 438 times by 3 tests: end of block Executed by:
| 438 | ||||||||||||||||||||||||
1775 | - | |||||||||||||||||||||||||
1776 | void QQmlDelegateModelItemMetaType::initializePrototype() | - | ||||||||||||||||||||||||
1777 | { | - | ||||||||||||||||||||||||
1778 | QV4::Scope scope(v4Engine); | - | ||||||||||||||||||||||||
1779 | - | |||||||||||||||||||||||||
1780 | QV4::ScopedObject proto(scope, v4Engine->newObject()); | - | ||||||||||||||||||||||||
1781 | proto->defineAccessorProperty(QStringLiteral("model"), QQmlDelegateModelItem::get_model, nullptr); executed 420 times by 2 tests: return qstring_literal_temp; Executed by:
| 420 | ||||||||||||||||||||||||
1782 | proto->defineAccessorProperty(QStringLiteral("groups"), QQmlDelegateModelItem::get_groups, QQmlDelegateModelItem::set_groups); executed 420 times by 2 tests: return qstring_literal_temp; Executed by:
| 420 | ||||||||||||||||||||||||
1783 | QV4::ScopedString s(scope); | - | ||||||||||||||||||||||||
1784 | QV4::ScopedProperty p(scope); | - | ||||||||||||||||||||||||
1785 | - | |||||||||||||||||||||||||
1786 | s = v4Engine->newString(QStringLiteral("isUnresolved")); executed 420 times by 2 tests: return qstring_literal_temp; Executed by:
| 420 | ||||||||||||||||||||||||
1787 | QV4::ScopedFunctionObject f(scope); | - | ||||||||||||||||||||||||
1788 | QV4::ExecutionContext *global = scope.engine->rootContext(); | - | ||||||||||||||||||||||||
1789 | p->setGetter((f = QV4::DelegateModelGroupFunction::create(global, 30, QQmlDelegateModelItem::get_member))); | - | ||||||||||||||||||||||||
1790 | p->setSetter(nullptr); | - | ||||||||||||||||||||||||
1791 | proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); | - | ||||||||||||||||||||||||
1792 | - | |||||||||||||||||||||||||
1793 | s = v4Engine->newString(QStringLiteral("inItems")); executed 420 times by 2 tests: return qstring_literal_temp; Executed by:
| 420 | ||||||||||||||||||||||||
1794 | p->setGetter((f = QV4::DelegateModelGroupFunction::create(global, QQmlListCompositor::Default, QQmlDelegateModelItem::get_member))); | - | ||||||||||||||||||||||||
1795 | p->setSetter((f = QV4::DelegateModelGroupFunction::create(global, QQmlListCompositor::Default, QQmlDelegateModelItem::set_member))); | - | ||||||||||||||||||||||||
1796 | proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); | - | ||||||||||||||||||||||||
1797 | - | |||||||||||||||||||||||||
1798 | s = v4Engine->newString(QStringLiteral("inPersistedItems")); executed 420 times by 2 tests: return qstring_literal_temp; Executed by:
| 420 | ||||||||||||||||||||||||
1799 | p->setGetter((f = QV4::DelegateModelGroupFunction::create(global, QQmlListCompositor::Persisted, QQmlDelegateModelItem::get_member))); | - | ||||||||||||||||||||||||
1800 | p->setSetter((f = QV4::DelegateModelGroupFunction::create(global, QQmlListCompositor::Persisted, QQmlDelegateModelItem::set_member))); | - | ||||||||||||||||||||||||
1801 | proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); | - | ||||||||||||||||||||||||
1802 | - | |||||||||||||||||||||||||
1803 | s = v4Engine->newString(QStringLiteral("itemsIndex")); executed 420 times by 2 tests: return qstring_literal_temp; Executed by:
| 420 | ||||||||||||||||||||||||
1804 | p->setGetter((f = QV4::DelegateModelGroupFunction::create(global, QQmlListCompositor::Default, QQmlDelegateModelItem::get_index))); | - | ||||||||||||||||||||||||
1805 | proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); | - | ||||||||||||||||||||||||
1806 | - | |||||||||||||||||||||||||
1807 | s = v4Engine->newString(QStringLiteral("persistedItemsIndex")); executed 420 times by 2 tests: return qstring_literal_temp; Executed by:
| 420 | ||||||||||||||||||||||||
1808 | p->setGetter((f = QV4::DelegateModelGroupFunction::create(global, QQmlListCompositor::Persisted, QQmlDelegateModelItem::get_index))); | - | ||||||||||||||||||||||||
1809 | p->setSetter(nullptr); | - | ||||||||||||||||||||||||
1810 | proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); | - | ||||||||||||||||||||||||
1811 | - | |||||||||||||||||||||||||
1812 | for (int i = 2; i < groupNames.count(); ++i) {
| 420-830 | ||||||||||||||||||||||||
1813 | QString propertyName = QLatin1String("in") + groupNames.at(i); | - | ||||||||||||||||||||||||
1814 | propertyName.replace(2, 1, propertyName.at(2).toUpper()); | - | ||||||||||||||||||||||||
1815 | s = v4Engine->newString(propertyName); | - | ||||||||||||||||||||||||
1816 | p->setGetter((f = QV4::DelegateModelGroupFunction::create(global, i + 1, QQmlDelegateModelItem::get_member))); | - | ||||||||||||||||||||||||
1817 | p->setSetter((f = QV4::DelegateModelGroupFunction::create(global, i + 1, QQmlDelegateModelItem::set_member))); | - | ||||||||||||||||||||||||
1818 | proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); | - | ||||||||||||||||||||||||
1819 | } executed 830 times by 2 tests: end of block Executed by:
| 830 | ||||||||||||||||||||||||
1820 | for (int i = 2; i < groupNames.count(); ++i) {
| 420-830 | ||||||||||||||||||||||||
1821 | const QString propertyName = groupNames.at(i) + QLatin1String("Index"); | - | ||||||||||||||||||||||||
1822 | s = v4Engine->newString(propertyName); | - | ||||||||||||||||||||||||
1823 | p->setGetter((f = QV4::DelegateModelGroupFunction::create(global, i + 1, QQmlDelegateModelItem::get_index))); | - | ||||||||||||||||||||||||
1824 | p->setSetter(nullptr); | - | ||||||||||||||||||||||||
1825 | proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); | - | ||||||||||||||||||||||||
1826 | } executed 830 times by 2 tests: end of block Executed by:
| 830 | ||||||||||||||||||||||||
1827 | modelItemProto.set(v4Engine, proto); | - | ||||||||||||||||||||||||
1828 | } executed 420 times by 2 tests: end of block Executed by:
| 420 | ||||||||||||||||||||||||
1829 | - | |||||||||||||||||||||||||
1830 | int QQmlDelegateModelItemMetaType::parseGroups(const QStringList &groups) const | - | ||||||||||||||||||||||||
1831 | { | - | ||||||||||||||||||||||||
1832 | int groupFlags = 0; | - | ||||||||||||||||||||||||
1833 | for (const QString &groupName : groups) { | - | ||||||||||||||||||||||||
1834 | int index = groupNames.indexOf(groupName); | - | ||||||||||||||||||||||||
1835 | if (index != -1)
| 0-2 | ||||||||||||||||||||||||
1836 | groupFlags |= 2 << index; executed 2 times by 1 test: groupFlags |= 2 << index; Executed by:
| 2 | ||||||||||||||||||||||||
1837 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1838 | return groupFlags; executed 2 times by 1 test: return groupFlags; Executed by:
| 2 | ||||||||||||||||||||||||
1839 | } | - | ||||||||||||||||||||||||
1840 | - | |||||||||||||||||||||||||
1841 | int QQmlDelegateModelItemMetaType::parseGroups(const QV4::Value &groups) const | - | ||||||||||||||||||||||||
1842 | { | - | ||||||||||||||||||||||||
1843 | int groupFlags = 0; | - | ||||||||||||||||||||||||
1844 | QV4::Scope scope(v4Engine); | - | ||||||||||||||||||||||||
1845 | - | |||||||||||||||||||||||||
1846 | QV4::ScopedString s(scope, groups); | - | ||||||||||||||||||||||||
1847 | if (s) {
| 32-126 | ||||||||||||||||||||||||
1848 | const QString groupName = s->toQString(); | - | ||||||||||||||||||||||||
1849 | int index = groupNames.indexOf(groupName); | - | ||||||||||||||||||||||||
1850 | if (index != -1)
| 0-126 | ||||||||||||||||||||||||
1851 | groupFlags |= 2 << index; executed 126 times by 2 tests: groupFlags |= 2 << index; Executed by:
| 126 | ||||||||||||||||||||||||
1852 | return groupFlags; executed 126 times by 2 tests: return groupFlags; Executed by:
| 126 | ||||||||||||||||||||||||
1853 | } | - | ||||||||||||||||||||||||
1854 | - | |||||||||||||||||||||||||
1855 | QV4::ScopedArrayObject array(scope, groups); | - | ||||||||||||||||||||||||
1856 | if (array) {
| 0-32 | ||||||||||||||||||||||||
1857 | QV4::ScopedValue v(scope); | - | ||||||||||||||||||||||||
1858 | uint arrayLength = array->getLength(); | - | ||||||||||||||||||||||||
1859 | for (uint i = 0; i < arrayLength; ++i) {
| 32-64 | ||||||||||||||||||||||||
1860 | v = array->get(i); | - | ||||||||||||||||||||||||
1861 | const QString groupName = v->toQString(); | - | ||||||||||||||||||||||||
1862 | int index = groupNames.indexOf(groupName); | - | ||||||||||||||||||||||||
1863 | if (index != -1)
| 8-56 | ||||||||||||||||||||||||
1864 | groupFlags |= 2 << index; executed 56 times by 1 test: groupFlags |= 2 << index; Executed by:
| 56 | ||||||||||||||||||||||||
1865 | } executed 64 times by 1 test: end of block Executed by:
| 64 | ||||||||||||||||||||||||
1866 | } executed 32 times by 1 test: end of block Executed by:
| 32 | ||||||||||||||||||||||||
1867 | return groupFlags; executed 32 times by 1 test: return groupFlags; Executed by:
| 32 | ||||||||||||||||||||||||
1868 | } | - | ||||||||||||||||||||||||
1869 | - | |||||||||||||||||||||||||
1870 | QV4::ReturnedValue QQmlDelegateModelItem::get_model(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) | - | ||||||||||||||||||||||||
1871 | { | - | ||||||||||||||||||||||||
1872 | QV4::Scope scope(b); | - | ||||||||||||||||||||||||
1873 | QV4::Scoped<QQmlDelegateModelItemObject> o(scope, thisObject->as<QQmlDelegateModelItemObject>()); | - | ||||||||||||||||||||||||
1874 | if (!o)
| 0-5276 | ||||||||||||||||||||||||
1875 | return b->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object")); never executed: return b->engine()->throwTypeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Not a valid VisualData object")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Not a valid VisualData object" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||||||||
1876 | if (!o->d()->item->metaType->model)
| 0-5276 | ||||||||||||||||||||||||
1877 | RETURN_UNDEFINED(); never executed: return QV4::Encode::undefined(); | 0 | ||||||||||||||||||||||||
1878 | - | |||||||||||||||||||||||||
1879 | return o->d()->item->get(); executed 5276 times by 2 tests: return o->d()->item->get(); Executed by:
| 5276 | ||||||||||||||||||||||||
1880 | } | - | ||||||||||||||||||||||||
1881 | - | |||||||||||||||||||||||||
1882 | QV4::ReturnedValue QQmlDelegateModelItem::get_groups(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) | - | ||||||||||||||||||||||||
1883 | { | - | ||||||||||||||||||||||||
1884 | QV4::Scope scope(b); | - | ||||||||||||||||||||||||
1885 | QV4::Scoped<QQmlDelegateModelItemObject> o(scope, thisObject->as<QQmlDelegateModelItemObject>()); | - | ||||||||||||||||||||||||
1886 | if (!o)
| 0-1176 | ||||||||||||||||||||||||
1887 | return scope.engine->throwTypeError(QStringLiteral("Not a valid VisualData object")); never executed: return scope.engine->throwTypeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Not a valid VisualData object")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Not a valid VisualData object" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||||||||
1888 | - | |||||||||||||||||||||||||
1889 | QStringList groups; | - | ||||||||||||||||||||||||
1890 | for (int i = 1; i < o->d()->item->metaType->groupCount; ++i) {
| 1176-4704 | ||||||||||||||||||||||||
1891 | if (o->d()->item->groups & (1 << i))
| 2124-2580 | ||||||||||||||||||||||||
1892 | groups.append(o->d()->item->metaType->groupNames.at(i - 1)); executed 2580 times by 1 test: groups.append(o->d()->item->metaType->groupNames.at(i - 1)); Executed by:
| 2580 | ||||||||||||||||||||||||
1893 | } executed 4704 times by 1 test: end of block Executed by:
| 4704 | ||||||||||||||||||||||||
1894 | - | |||||||||||||||||||||||||
1895 | return scope.engine->fromVariant(groups); executed 1176 times by 1 test: return scope.engine->fromVariant(groups); Executed by:
| 1176 | ||||||||||||||||||||||||
1896 | } | - | ||||||||||||||||||||||||
1897 | - | |||||||||||||||||||||||||
1898 | QV4::ReturnedValue QQmlDelegateModelItem::set_groups(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) | - | ||||||||||||||||||||||||
1899 | { | - | ||||||||||||||||||||||||
1900 | QV4::Scope scope(b); | - | ||||||||||||||||||||||||
1901 | QV4::Scoped<QQmlDelegateModelItemObject> o(scope, thisObject->as<QQmlDelegateModelItemObject>()); | - | ||||||||||||||||||||||||
1902 | if (!o)
| 0-20 | ||||||||||||||||||||||||
1903 | return scope.engine->throwTypeError(QStringLiteral("Not a valid VisualData object")); never executed: return scope.engine->throwTypeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Not a valid VisualData object")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Not a valid VisualData object" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||||||||
1904 | - | |||||||||||||||||||||||||
1905 | if (!argc)
| 0-20 | ||||||||||||||||||||||||
1906 | THROW_TYPE_ERROR(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
1907 | - | |||||||||||||||||||||||||
1908 | if (!o->d()->item->metaType->model)
| 0-20 | ||||||||||||||||||||||||
1909 | RETURN_UNDEFINED(); never executed: return QV4::Encode::undefined(); | 0 | ||||||||||||||||||||||||
1910 | QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(o->d()->item->metaType->model); | - | ||||||||||||||||||||||||
1911 | - | |||||||||||||||||||||||||
1912 | const int groupFlags = model->m_cacheMetaType->parseGroups(argv[0]); | - | ||||||||||||||||||||||||
1913 | const int cacheIndex = model->m_cache.indexOf(o->d()->item); | - | ||||||||||||||||||||||||
1914 | Compositor::iterator it = model->m_compositor.find(Compositor::Cache, cacheIndex); | - | ||||||||||||||||||||||||
1915 | model->setGroups(it, 1, Compositor::Cache, groupFlags); | - | ||||||||||||||||||||||||
1916 | return QV4::Encode::undefined(); executed 20 times by 2 tests: return QV4::Encode::undefined(); Executed by:
| 20 | ||||||||||||||||||||||||
1917 | } | - | ||||||||||||||||||||||||
1918 | - | |||||||||||||||||||||||||
1919 | QV4::ReturnedValue QQmlDelegateModelItem::get_member(QQmlDelegateModelItem *thisItem, uint flag, const QV4::Value &) | - | ||||||||||||||||||||||||
1920 | { | - | ||||||||||||||||||||||||
1921 | return QV4::Encode(bool(thisItem->groups & (1 << flag))); executed 11120 times by 1 test: return QV4::Encode(bool(thisItem->groups & (1 << flag))); Executed by:
| 11120 | ||||||||||||||||||||||||
1922 | } | - | ||||||||||||||||||||||||
1923 | - | |||||||||||||||||||||||||
1924 | QV4::ReturnedValue QQmlDelegateModelItem::set_member(QQmlDelegateModelItem *cacheItem, uint flag, const QV4::Value &arg) | - | ||||||||||||||||||||||||
1925 | { | - | ||||||||||||||||||||||||
1926 | if (!cacheItem->metaType->model)
| 0-16 | ||||||||||||||||||||||||
1927 | return QV4::Encode::undefined(); never executed: return QV4::Encode::undefined(); | 0 | ||||||||||||||||||||||||
1928 | - | |||||||||||||||||||||||||
1929 | QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(cacheItem->metaType->model); | - | ||||||||||||||||||||||||
1930 | - | |||||||||||||||||||||||||
1931 | bool member = arg.toBoolean(); | - | ||||||||||||||||||||||||
1932 | uint groupFlag = (1 << flag); | - | ||||||||||||||||||||||||
1933 | if (member == ((cacheItem->groups & groupFlag) != 0))
| 0-16 | ||||||||||||||||||||||||
1934 | return QV4::Encode::undefined(); never executed: return QV4::Encode::undefined(); | 0 | ||||||||||||||||||||||||
1935 | - | |||||||||||||||||||||||||
1936 | const int cacheIndex = model->m_cache.indexOf(cacheItem); | - | ||||||||||||||||||||||||
1937 | Compositor::iterator it = model->m_compositor.find(Compositor::Cache, cacheIndex); | - | ||||||||||||||||||||||||
1938 | if (member)
| 2-14 | ||||||||||||||||||||||||
1939 | model->addGroups(it, 1, Compositor::Cache, groupFlag); executed 2 times by 1 test: model->addGroups(it, 1, Compositor::Cache, groupFlag); Executed by:
| 2 | ||||||||||||||||||||||||
1940 | else | - | ||||||||||||||||||||||||
1941 | model->removeGroups(it, 1, Compositor::Cache, groupFlag); executed 14 times by 1 test: model->removeGroups(it, 1, Compositor::Cache, groupFlag); Executed by:
| 14 | ||||||||||||||||||||||||
1942 | return QV4::Encode::undefined(); executed 16 times by 1 test: return QV4::Encode::undefined(); Executed by:
| 16 | ||||||||||||||||||||||||
1943 | } | - | ||||||||||||||||||||||||
1944 | - | |||||||||||||||||||||||||
1945 | QV4::ReturnedValue QQmlDelegateModelItem::get_index(QQmlDelegateModelItem *thisItem, uint flag, const QV4::Value &) | - | ||||||||||||||||||||||||
1946 | { | - | ||||||||||||||||||||||||
1947 | return QV4::Encode((int)thisItem->groupIndex(Compositor::Group(flag))); executed 9146 times by 2 tests: return QV4::Encode((int)thisItem->groupIndex(Compositor::Group(flag))); Executed by:
| 9146 | ||||||||||||||||||||||||
1948 | } | - | ||||||||||||||||||||||||
1949 | - | |||||||||||||||||||||||||
1950 | - | |||||||||||||||||||||||||
1951 | //--------------------------------------------------------------------------- | - | ||||||||||||||||||||||||
1952 | - | |||||||||||||||||||||||||
1953 | DEFINE_OBJECT_VTABLE(QQmlDelegateModelItemObject); | - | ||||||||||||||||||||||||
1954 | - | |||||||||||||||||||||||||
1955 | void QV4::Heap::QQmlDelegateModelItemObject::destroy() | - | ||||||||||||||||||||||||
1956 | { | - | ||||||||||||||||||||||||
1957 | item->Dispose(); | - | ||||||||||||||||||||||||
1958 | Object::destroy(); | - | ||||||||||||||||||||||||
1959 | } executed 31966 times by 2 tests: end of block Executed by:
| 31966 | ||||||||||||||||||||||||
1960 | - | |||||||||||||||||||||||||
1961 | - | |||||||||||||||||||||||||
1962 | QQmlDelegateModelItem::QQmlDelegateModelItem( | - | ||||||||||||||||||||||||
1963 | QQmlDelegateModelItemMetaType *metaType, int modelIndex) | - | ||||||||||||||||||||||||
1964 | : v4(metaType->v4Engine) | - | ||||||||||||||||||||||||
1965 | , metaType(metaType) | - | ||||||||||||||||||||||||
1966 | , contextData(nullptr) | - | ||||||||||||||||||||||||
1967 | , object(nullptr) | - | ||||||||||||||||||||||||
1968 | , attached(nullptr) | - | ||||||||||||||||||||||||
1969 | , incubationTask(nullptr) | - | ||||||||||||||||||||||||
1970 | , objectRef(0) | - | ||||||||||||||||||||||||
1971 | , scriptRef(0) | - | ||||||||||||||||||||||||
1972 | , groups(0) | - | ||||||||||||||||||||||||
1973 | , index(modelIndex) | - | ||||||||||||||||||||||||
1974 | , row(QQmlDelegateModelPrivate::get(metaType->model)->m_adaptorModel.rowAt(modelIndex)) | - | ||||||||||||||||||||||||
1975 | , column(QQmlDelegateModelPrivate::get(metaType->model)->m_adaptorModel.columnAt(modelIndex)) | - | ||||||||||||||||||||||||
1976 | { | - | ||||||||||||||||||||||||
1977 | metaType->addref(); | - | ||||||||||||||||||||||||
1978 | } executed 88443 times by 25 tests: end of block Executed by:
| 88443 | ||||||||||||||||||||||||
1979 | - | |||||||||||||||||||||||||
1980 | QQmlDelegateModelItem::~QQmlDelegateModelItem() | - | ||||||||||||||||||||||||
1981 | { | - | ||||||||||||||||||||||||
1982 | Q_ASSERT(scriptRef == 0); | - | ||||||||||||||||||||||||
1983 | Q_ASSERT(objectRef == 0); | - | ||||||||||||||||||||||||
1984 | Q_ASSERT(!object); | - | ||||||||||||||||||||||||
1985 | - | |||||||||||||||||||||||||
1986 | if (incubationTask) {
| 29-88261 | ||||||||||||||||||||||||
1987 | if (metaType->model)
| 0-29 | ||||||||||||||||||||||||
1988 | QQmlDelegateModelPrivate::get(metaType->model)->releaseIncubator(incubationTask); never executed: QQmlDelegateModelPrivate::get(metaType->model)->releaseIncubator(incubationTask); | 0 | ||||||||||||||||||||||||
1989 | else | - | ||||||||||||||||||||||||
1990 | delete incubationTask; executed 29 times by 2 tests: delete incubationTask; Executed by:
| 29 | ||||||||||||||||||||||||
1991 | } | - | ||||||||||||||||||||||||
1992 | - | |||||||||||||||||||||||||
1993 | metaType->release(); | - | ||||||||||||||||||||||||
1994 | - | |||||||||||||||||||||||||
1995 | } executed 88290 times by 24 tests: end of block Executed by:
| 88290 | ||||||||||||||||||||||||
1996 | - | |||||||||||||||||||||||||
1997 | void QQmlDelegateModelItem::Dispose() | - | ||||||||||||||||||||||||
1998 | { | - | ||||||||||||||||||||||||
1999 | --scriptRef; | - | ||||||||||||||||||||||||
2000 | if (isReferenced())
| 24250-29974 | ||||||||||||||||||||||||
2001 | return; executed 29974 times by 2 tests: return; Executed by:
| 29974 | ||||||||||||||||||||||||
2002 | - | |||||||||||||||||||||||||
2003 | if (metaType->model) {
| 1986-22264 | ||||||||||||||||||||||||
2004 | QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(metaType->model); | - | ||||||||||||||||||||||||
2005 | model->removeCacheItem(this); | - | ||||||||||||||||||||||||
2006 | } executed 22264 times by 12 tests: end of block Executed by:
| 22264 | ||||||||||||||||||||||||
2007 | delete this; | - | ||||||||||||||||||||||||
2008 | } executed 24250 times by 13 tests: end of block Executed by:
| 24250 | ||||||||||||||||||||||||
2009 | - | |||||||||||||||||||||||||
2010 | void QQmlDelegateModelItem::setModelIndex(int idx) | - | ||||||||||||||||||||||||
2011 | { | - | ||||||||||||||||||||||||
2012 | if (idx == index)
| 0-42185 | ||||||||||||||||||||||||
2013 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2014 | - | |||||||||||||||||||||||||
2015 | const int prevRow = row; | - | ||||||||||||||||||||||||
2016 | const int prevColumn = column; | - | ||||||||||||||||||||||||
2017 | const QQmlAdaptorModel &adaptorModel = QQmlDelegateModelPrivate::get(metaType->model)->m_adaptorModel; | - | ||||||||||||||||||||||||
2018 | - | |||||||||||||||||||||||||
2019 | index = idx; | - | ||||||||||||||||||||||||
2020 | row = adaptorModel.rowAt(idx); | - | ||||||||||||||||||||||||
2021 | column = adaptorModel.columnAt(idx); | - | ||||||||||||||||||||||||
2022 | - | |||||||||||||||||||||||||
2023 | Q_EMIT modelIndexChanged(); | - | ||||||||||||||||||||||||
2024 | - | |||||||||||||||||||||||||
2025 | if (row != prevRow)
| 18-42167 | ||||||||||||||||||||||||
2026 | emit rowChanged(); executed 42167 times by 7 tests: rowChanged(); Executed by:
| 42167 | ||||||||||||||||||||||||
2027 | if (column != prevColumn)
| 1193-40992 | ||||||||||||||||||||||||
2028 | emit columnChanged(); executed 1193 times by 5 tests: columnChanged(); Executed by:
| 1193 | ||||||||||||||||||||||||
2029 | } executed 42185 times by 7 tests: end of block Executed by:
| 42185 | ||||||||||||||||||||||||
2030 | - | |||||||||||||||||||||||||
2031 | void QQmlDelegateModelItem::destroyObject() | - | ||||||||||||||||||||||||
2032 | { | - | ||||||||||||||||||||||||
2033 | Q_ASSERT(object); | - | ||||||||||||||||||||||||
2034 | Q_ASSERT(contextData); | - | ||||||||||||||||||||||||
2035 | - | |||||||||||||||||||||||||
2036 | QQmlData *data = QQmlData::get(object); | - | ||||||||||||||||||||||||
2037 | Q_ASSERT(data); | - | ||||||||||||||||||||||||
2038 | if (data->ownContext) {
| 0-22268 | ||||||||||||||||||||||||
2039 | data->ownContext->clearContext(); | - | ||||||||||||||||||||||||
2040 | if (data->ownContext->contextObject == object)
| 0-22268 | ||||||||||||||||||||||||
2041 | data->ownContext->contextObject = nullptr; executed 22268 times by 12 tests: data->ownContext->contextObject = nullptr; Executed by:
| 22268 | ||||||||||||||||||||||||
2042 | data->ownContext = nullptr; | - | ||||||||||||||||||||||||
2043 | data->context = nullptr; | - | ||||||||||||||||||||||||
2044 | } executed 22268 times by 12 tests: end of block Executed by:
| 22268 | ||||||||||||||||||||||||
2045 | object->deleteLater(); | - | ||||||||||||||||||||||||
2046 | - | |||||||||||||||||||||||||
2047 | if (attached) {
| 12-22256 | ||||||||||||||||||||||||
2048 | attached->m_cacheItem = nullptr; | - | ||||||||||||||||||||||||
2049 | attached = nullptr; | - | ||||||||||||||||||||||||
2050 | } executed 12 times by 2 tests: end of block Executed by:
| 12 | ||||||||||||||||||||||||
2051 | - | |||||||||||||||||||||||||
2052 | contextData->invalidate(); | - | ||||||||||||||||||||||||
2053 | contextData = nullptr; | - | ||||||||||||||||||||||||
2054 | object = nullptr; | - | ||||||||||||||||||||||||
2055 | } executed 22268 times by 12 tests: end of block Executed by:
| 22268 | ||||||||||||||||||||||||
2056 | - | |||||||||||||||||||||||||
2057 | QQmlDelegateModelItem *QQmlDelegateModelItem::dataForObject(QObject *object) | - | ||||||||||||||||||||||||
2058 | { | - | ||||||||||||||||||||||||
2059 | QQmlData *d = QQmlData::get(object); | - | ||||||||||||||||||||||||
2060 | QQmlContextData *context = d ? d->context : nullptr;
| 0-205348 | ||||||||||||||||||||||||
2061 | for (context = context ? context->parent : nullptr; context; context = context->parent) {
| 84803-121461 | ||||||||||||||||||||||||
2062 | if (QQmlDelegateModelItem *cacheItem = qobject_cast<QQmlDelegateModelItem *>(
| 916-83887 | ||||||||||||||||||||||||
2063 | context->contextObject)) {
| 916-83887 | ||||||||||||||||||||||||
2064 | return cacheItem; executed 83887 times by 20 tests: return cacheItem; Executed by:
| 83887 | ||||||||||||||||||||||||
2065 | } | - | ||||||||||||||||||||||||
2066 | } executed 916 times by 4 tests: end of block Executed by:
| 916 | ||||||||||||||||||||||||
2067 | return nullptr; executed 121461 times by 23 tests: return nullptr; Executed by:
| 121461 | ||||||||||||||||||||||||
2068 | } | - | ||||||||||||||||||||||||
2069 | - | |||||||||||||||||||||||||
2070 | int QQmlDelegateModelItem::groupIndex(Compositor::Group group) | - | ||||||||||||||||||||||||
2071 | { | - | ||||||||||||||||||||||||
2072 | if (QQmlDelegateModelPrivate * const model = metaType->model
| 0-54076 | ||||||||||||||||||||||||
2073 | ? QQmlDelegateModelPrivate::get(metaType->model)
| 0-54076 | ||||||||||||||||||||||||
2074 | : nullptr) {
| 0-54076 | ||||||||||||||||||||||||
2075 | return model->m_compositor.find(Compositor::Cache, model->m_cache.indexOf(this)).index[group]; executed 54076 times by 4 tests: return model->m_compositor.find(Compositor::Cache, model->m_cache.indexOf(this)).index[group]; Executed by:
| 54076 | ||||||||||||||||||||||||
2076 | } | - | ||||||||||||||||||||||||
2077 | return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
2078 | } | - | ||||||||||||||||||||||||
2079 | - | |||||||||||||||||||||||||
2080 | //--------------------------------------------------------------------------- | - | ||||||||||||||||||||||||
2081 | - | |||||||||||||||||||||||||
2082 | QQmlDelegateModelAttachedMetaObject::QQmlDelegateModelAttachedMetaObject( | - | ||||||||||||||||||||||||
2083 | QQmlDelegateModelItemMetaType *metaType, QMetaObject *metaObject) | - | ||||||||||||||||||||||||
2084 | : metaType(metaType) | - | ||||||||||||||||||||||||
2085 | , metaObject(metaObject) | - | ||||||||||||||||||||||||
2086 | , memberPropertyOffset(QQmlDelegateModelAttached::staticMetaObject.propertyCount()) | - | ||||||||||||||||||||||||
2087 | , indexPropertyOffset(QQmlDelegateModelAttached::staticMetaObject.propertyCount() + metaType->groupNames.count()) | - | ||||||||||||||||||||||||
2088 | { | - | ||||||||||||||||||||||||
2089 | // Don't reference count the meta-type here as that would create a circular reference. | - | ||||||||||||||||||||||||
2090 | // Instead we rely the fact that the meta-type's reference count can't reach 0 without first | - | ||||||||||||||||||||||||
2091 | // destroying all delegates with attached objects. | - | ||||||||||||||||||||||||
2092 | *static_cast<QMetaObject *>(this) = *metaObject; | - | ||||||||||||||||||||||||
2093 | } executed 438 times by 3 tests: end of block Executed by:
| 438 | ||||||||||||||||||||||||
2094 | - | |||||||||||||||||||||||||
2095 | QQmlDelegateModelAttachedMetaObject::~QQmlDelegateModelAttachedMetaObject() | - | ||||||||||||||||||||||||
2096 | { | - | ||||||||||||||||||||||||
2097 | ::free(metaObject); | - | ||||||||||||||||||||||||
2098 | } executed 438 times by 3 tests: end of block Executed by:
| 438 | ||||||||||||||||||||||||
2099 | - | |||||||||||||||||||||||||
2100 | void QQmlDelegateModelAttachedMetaObject::objectDestroyed(QObject *) | - | ||||||||||||||||||||||||
2101 | { | - | ||||||||||||||||||||||||
2102 | release(); | - | ||||||||||||||||||||||||
2103 | } executed 2290 times by 3 tests: end of block Executed by:
| 2290 | ||||||||||||||||||||||||
2104 | - | |||||||||||||||||||||||||
2105 | int QQmlDelegateModelAttachedMetaObject::metaCall(QObject *object, QMetaObject::Call call, int _id, void **arguments) | - | ||||||||||||||||||||||||
2106 | { | - | ||||||||||||||||||||||||
2107 | QQmlDelegateModelAttached *attached = static_cast<QQmlDelegateModelAttached *>(object); | - | ||||||||||||||||||||||||
2108 | if (call == QMetaObject::ReadProperty) {
| 82-20306 | ||||||||||||||||||||||||
2109 | if (_id >= indexPropertyOffset) {
| 9276-11030 | ||||||||||||||||||||||||
2110 | Compositor::Group group = Compositor::Group(_id - indexPropertyOffset + 1); | - | ||||||||||||||||||||||||
2111 | *static_cast<int *>(arguments[0]) = attached->m_currentIndex[group]; | - | ||||||||||||||||||||||||
2112 | return -1; executed 9276 times by 3 tests: return -1; Executed by:
| 9276 | ||||||||||||||||||||||||
2113 | } else if (_id >= memberPropertyOffset) {
| 2240-8790 | ||||||||||||||||||||||||
2114 | Compositor::Group group = Compositor::Group(_id - memberPropertyOffset + 1); | - | ||||||||||||||||||||||||
2115 | *static_cast<bool *>(arguments[0]) = attached->m_cacheItem->groups & (1 << group); | - | ||||||||||||||||||||||||
2116 | return -1; executed 8790 times by 2 tests: return -1; Executed by:
| 8790 | ||||||||||||||||||||||||
2117 | } | - | ||||||||||||||||||||||||
2118 | } else if (call == QMetaObject::WriteProperty) { executed 2240 times by 1 test: end of block Executed by:
| 0-2240 | ||||||||||||||||||||||||
2119 | if (_id >= memberPropertyOffset) {
| 2-80 | ||||||||||||||||||||||||
2120 | if (!metaType->model)
| 0-80 | ||||||||||||||||||||||||
2121 | return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
2122 | QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(metaType->model); | - | ||||||||||||||||||||||||
2123 | Compositor::Group group = Compositor::Group(_id - memberPropertyOffset + 1); | - | ||||||||||||||||||||||||
2124 | const int groupFlag = 1 << group; | - | ||||||||||||||||||||||||
2125 | const bool member = attached->m_cacheItem->groups & groupFlag; | - | ||||||||||||||||||||||||
2126 | if (member && !*static_cast<bool *>(arguments[0])) {
| 4-76 | ||||||||||||||||||||||||
2127 | Compositor::iterator it = model->m_compositor.find( | - | ||||||||||||||||||||||||
2128 | group, attached->m_currentIndex[group]); | - | ||||||||||||||||||||||||
2129 | model->removeGroups(it, 1, group, groupFlag); | - | ||||||||||||||||||||||||
2130 | } else if (!member && *static_cast<bool *>(arguments[0])) { executed 6 times by 1 test: end of block Executed by:
| 0-70 | ||||||||||||||||||||||||
2131 | for (int i = 1; i < metaType->groupCount; ++i) {
| 0-4 | ||||||||||||||||||||||||
2132 | if (attached->m_cacheItem->groups & (1 << i)) {
| 0-4 | ||||||||||||||||||||||||
2133 | Compositor::iterator it = model->m_compositor.find( | - | ||||||||||||||||||||||||
2134 | Compositor::Group(i), attached->m_currentIndex[i]); | - | ||||||||||||||||||||||||
2135 | model->addGroups(it, 1, Compositor::Group(i), groupFlag); | - | ||||||||||||||||||||||||
2136 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
2137 | } | - | ||||||||||||||||||||||||
2138 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2139 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
2140 | return -1; executed 80 times by 2 tests: return -1; Executed by:
| 80 | ||||||||||||||||||||||||
2141 | } | - | ||||||||||||||||||||||||
2142 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
2143 | return attached->qt_metacall(call, _id, arguments); executed 2242 times by 1 test: return attached->qt_metacall(call, _id, arguments); Executed by:
| 2242 | ||||||||||||||||||||||||
2144 | } | - | ||||||||||||||||||||||||
2145 | - | |||||||||||||||||||||||||
2146 | QQmlDelegateModelAttached::QQmlDelegateModelAttached(QObject *parent) | - | ||||||||||||||||||||||||
2147 | : m_cacheItem(nullptr) | - | ||||||||||||||||||||||||
2148 | , m_previousGroups(0) | - | ||||||||||||||||||||||||
2149 | { | - | ||||||||||||||||||||||||
2150 | QQml_setParent_noEvent(this, parent); | - | ||||||||||||||||||||||||
2151 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
2152 | - | |||||||||||||||||||||||||
2153 | QQmlDelegateModelAttached::QQmlDelegateModelAttached( | - | ||||||||||||||||||||||||
2154 | QQmlDelegateModelItem *cacheItem, QObject *parent) | - | ||||||||||||||||||||||||
2155 | : m_cacheItem(cacheItem) | - | ||||||||||||||||||||||||
2156 | , m_previousGroups(cacheItem->groups) | - | ||||||||||||||||||||||||
2157 | { | - | ||||||||||||||||||||||||
2158 | QQml_setParent_noEvent(this, parent); | - | ||||||||||||||||||||||||
2159 | resetCurrentIndex(); | - | ||||||||||||||||||||||||
2160 | // Let m_previousIndex be equal to m_currentIndex | - | ||||||||||||||||||||||||
2161 | std::copy(std::begin(m_currentIndex), std::end(m_currentIndex), std::begin(m_previousIndex)); | - | ||||||||||||||||||||||||
2162 | - | |||||||||||||||||||||||||
2163 | if (!cacheItem->metaType->metaObject)
| 438-1852 | ||||||||||||||||||||||||
2164 | cacheItem->metaType->initializeMetaObject(); executed 438 times by 3 tests: cacheItem->metaType->initializeMetaObject(); Executed by:
| 438 | ||||||||||||||||||||||||
2165 | - | |||||||||||||||||||||||||
2166 | QObjectPrivate::get(this)->metaObject = cacheItem->metaType->metaObject; | - | ||||||||||||||||||||||||
2167 | cacheItem->metaType->metaObject->addref(); | - | ||||||||||||||||||||||||
2168 | } executed 2290 times by 3 tests: end of block Executed by:
| 2290 | ||||||||||||||||||||||||
2169 | - | |||||||||||||||||||||||||
2170 | void QQmlDelegateModelAttached::resetCurrentIndex() | - | ||||||||||||||||||||||||
2171 | { | - | ||||||||||||||||||||||||
2172 | if (QQDMIncubationTask *incubationTask = m_cacheItem->incubationTask) {
| 288-2002 | ||||||||||||||||||||||||
2173 | for (int i = 1; i < qMin<int>(m_cacheItem->metaType->groupCount, Compositor::MaximumGroupCount); ++i)
| 288-982 | ||||||||||||||||||||||||
2174 | m_currentIndex[i] = incubationTask->index[i]; executed 982 times by 2 tests: m_currentIndex[i] = incubationTask->index[i]; Executed by:
| 982 | ||||||||||||||||||||||||
2175 | } else { executed 288 times by 2 tests: end of block Executed by:
| 288 | ||||||||||||||||||||||||
2176 | QQmlDelegateModelPrivate * const model = QQmlDelegateModelPrivate::get(m_cacheItem->metaType->model); | - | ||||||||||||||||||||||||
2177 | Compositor::iterator it = model->m_compositor.find( | - | ||||||||||||||||||||||||
2178 | Compositor::Cache, model->m_cache.indexOf(m_cacheItem)); | - | ||||||||||||||||||||||||
2179 | for (int i = 1; i < m_cacheItem->metaType->groupCount; ++i)
| 2002-7980 | ||||||||||||||||||||||||
2180 | m_currentIndex[i] = it.index[i]; executed 7980 times by 2 tests: m_currentIndex[i] = it.index[i]; Executed by:
| 7980 | ||||||||||||||||||||||||
2181 | } executed 2002 times by 2 tests: end of block Executed by:
| 2002 | ||||||||||||||||||||||||
2182 | } | - | ||||||||||||||||||||||||
2183 | - | |||||||||||||||||||||||||
2184 | /*! | - | ||||||||||||||||||||||||
2185 | \qmlattachedproperty int QtQml.Models::DelegateModel::model | - | ||||||||||||||||||||||||
2186 | - | |||||||||||||||||||||||||
2187 | This attached property holds the visual data model this delegate instance belongs to. | - | ||||||||||||||||||||||||
2188 | - | |||||||||||||||||||||||||
2189 | It is attached to each instance of the delegate. | - | ||||||||||||||||||||||||
2190 | */ | - | ||||||||||||||||||||||||
2191 | - | |||||||||||||||||||||||||
2192 | QQmlDelegateModel *QQmlDelegateModelAttached::model() const | - | ||||||||||||||||||||||||
2193 | { | - | ||||||||||||||||||||||||
2194 | return m_cacheItem ? m_cacheItem->metaType->model : nullptr; executed 6 times by 1 test: return m_cacheItem ? m_cacheItem->metaType->model : nullptr; Executed by:
| 6 | ||||||||||||||||||||||||
2195 | } | - | ||||||||||||||||||||||||
2196 | - | |||||||||||||||||||||||||
2197 | /*! | - | ||||||||||||||||||||||||
2198 | \qmlattachedproperty stringlist QtQml.Models::DelegateModel::groups | - | ||||||||||||||||||||||||
2199 | - | |||||||||||||||||||||||||
2200 | This attached property holds the name of DelegateModelGroups the item belongs to. | - | ||||||||||||||||||||||||
2201 | - | |||||||||||||||||||||||||
2202 | It is attached to each instance of the delegate. | - | ||||||||||||||||||||||||
2203 | */ | - | ||||||||||||||||||||||||
2204 | - | |||||||||||||||||||||||||
2205 | QStringList QQmlDelegateModelAttached::groups() const | - | ||||||||||||||||||||||||
2206 | { | - | ||||||||||||||||||||||||
2207 | QStringList groups; | - | ||||||||||||||||||||||||
2208 | - | |||||||||||||||||||||||||
2209 | if (!m_cacheItem)
| 0-250 | ||||||||||||||||||||||||
2210 | return groups; never executed: return groups; | 0 | ||||||||||||||||||||||||
2211 | for (int i = 1; i < m_cacheItem->metaType->groupCount; ++i) {
| 250-1000 | ||||||||||||||||||||||||
2212 | if (m_cacheItem->groups & (1 << i))
| 480-520 | ||||||||||||||||||||||||
2213 | groups.append(m_cacheItem->metaType->groupNames.at(i - 1)); executed 480 times by 1 test: groups.append(m_cacheItem->metaType->groupNames.at(i - 1)); Executed by:
| 480 | ||||||||||||||||||||||||
2214 | } executed 1000 times by 1 test: end of block Executed by:
| 1000 | ||||||||||||||||||||||||
2215 | return groups; executed 250 times by 1 test: return groups; Executed by:
| 250 | ||||||||||||||||||||||||
2216 | } | - | ||||||||||||||||||||||||
2217 | - | |||||||||||||||||||||||||
2218 | void QQmlDelegateModelAttached::setGroups(const QStringList &groups) | - | ||||||||||||||||||||||||
2219 | { | - | ||||||||||||||||||||||||
2220 | if (!m_cacheItem)
| 0-2 | ||||||||||||||||||||||||
2221 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2222 | - | |||||||||||||||||||||||||
2223 | QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(m_cacheItem->metaType->model); | - | ||||||||||||||||||||||||
2224 | - | |||||||||||||||||||||||||
2225 | const int groupFlags = model->m_cacheMetaType->parseGroups(groups); | - | ||||||||||||||||||||||||
2226 | const int cacheIndex = model->m_cache.indexOf(m_cacheItem); | - | ||||||||||||||||||||||||
2227 | Compositor::iterator it = model->m_compositor.find(Compositor::Cache, cacheIndex); | - | ||||||||||||||||||||||||
2228 | model->setGroups(it, 1, Compositor::Cache, groupFlags); | - | ||||||||||||||||||||||||
2229 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
2230 | - | |||||||||||||||||||||||||
2231 | /*! | - | ||||||||||||||||||||||||
2232 | \qmlattachedproperty bool QtQml.Models::DelegateModel::isUnresolved | - | ||||||||||||||||||||||||
2233 | - | |||||||||||||||||||||||||
2234 | This attached property holds whether the visual item is bound to a data model index. | - | ||||||||||||||||||||||||
2235 | Returns true if the item is not bound to the model, and false if it is. | - | ||||||||||||||||||||||||
2236 | - | |||||||||||||||||||||||||
2237 | An unresolved item can be bound to the data model using the DelegateModelGroup::resolve() | - | ||||||||||||||||||||||||
2238 | function. | - | ||||||||||||||||||||||||
2239 | - | |||||||||||||||||||||||||
2240 | It is attached to each instance of the delegate. | - | ||||||||||||||||||||||||
2241 | */ | - | ||||||||||||||||||||||||
2242 | - | |||||||||||||||||||||||||
2243 | bool QQmlDelegateModelAttached::isUnresolved() const | - | ||||||||||||||||||||||||
2244 | { | - | ||||||||||||||||||||||||
2245 | if (!m_cacheItem)
| 0-1988 | ||||||||||||||||||||||||
2246 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
2247 | - | |||||||||||||||||||||||||
2248 | return m_cacheItem->groups & Compositor::UnresolvedFlag; executed 1988 times by 1 test: return m_cacheItem->groups & Compositor::UnresolvedFlag; Executed by:
| 1988 | ||||||||||||||||||||||||
2249 | } | - | ||||||||||||||||||||||||
2250 | - | |||||||||||||||||||||||||
2251 | /*! | - | ||||||||||||||||||||||||
2252 | \qmlattachedproperty int QtQml.Models::DelegateModel::inItems | - | ||||||||||||||||||||||||
2253 | - | |||||||||||||||||||||||||
2254 | This attached property holds whether the item belongs to the default \l items DelegateModelGroup. | - | ||||||||||||||||||||||||
2255 | - | |||||||||||||||||||||||||
2256 | Changing this property will add or remove the item from the items group. | - | ||||||||||||||||||||||||
2257 | - | |||||||||||||||||||||||||
2258 | It is attached to each instance of the delegate. | - | ||||||||||||||||||||||||
2259 | */ | - | ||||||||||||||||||||||||
2260 | - | |||||||||||||||||||||||||
2261 | /*! | - | ||||||||||||||||||||||||
2262 | \qmlattachedproperty int QtQml.Models::DelegateModel::itemsIndex | - | ||||||||||||||||||||||||
2263 | - | |||||||||||||||||||||||||
2264 | This attached property holds the index of the item in the default \l items DelegateModelGroup. | - | ||||||||||||||||||||||||
2265 | - | |||||||||||||||||||||||||
2266 | It is attached to each instance of the delegate. | - | ||||||||||||||||||||||||
2267 | */ | - | ||||||||||||||||||||||||
2268 | - | |||||||||||||||||||||||||
2269 | /*! | - | ||||||||||||||||||||||||
2270 | \qmlattachedproperty int QtQml.Models::DelegateModel::inPersistedItems | - | ||||||||||||||||||||||||
2271 | - | |||||||||||||||||||||||||
2272 | This attached property holds whether the item belongs to the \l persistedItems DelegateModelGroup. | - | ||||||||||||||||||||||||
2273 | - | |||||||||||||||||||||||||
2274 | Changing this property will add or remove the item from the items group. Change with caution | - | ||||||||||||||||||||||||
2275 | as removing an item from the persistedItems group will destroy the current instance if it is | - | ||||||||||||||||||||||||
2276 | not referenced by a model. | - | ||||||||||||||||||||||||
2277 | - | |||||||||||||||||||||||||
2278 | It is attached to each instance of the delegate. | - | ||||||||||||||||||||||||
2279 | */ | - | ||||||||||||||||||||||||
2280 | - | |||||||||||||||||||||||||
2281 | /*! | - | ||||||||||||||||||||||||
2282 | \qmlattachedproperty int QtQml.Models::DelegateModel::persistedItemsIndex | - | ||||||||||||||||||||||||
2283 | - | |||||||||||||||||||||||||
2284 | This attached property holds the index of the item in the \l persistedItems DelegateModelGroup. | - | ||||||||||||||||||||||||
2285 | - | |||||||||||||||||||||||||
2286 | It is attached to each instance of the delegate. | - | ||||||||||||||||||||||||
2287 | */ | - | ||||||||||||||||||||||||
2288 | - | |||||||||||||||||||||||||
2289 | void QQmlDelegateModelAttached::emitChanges() | - | ||||||||||||||||||||||||
2290 | { | - | ||||||||||||||||||||||||
2291 | const int groupChanges = m_previousGroups ^ m_cacheItem->groups; | - | ||||||||||||||||||||||||
2292 | m_previousGroups = m_cacheItem->groups; | - | ||||||||||||||||||||||||
2293 | - | |||||||||||||||||||||||||
2294 | int indexChanges = 0; | - | ||||||||||||||||||||||||
2295 | for (int i = 1; i < m_cacheItem->metaType->groupCount; ++i) {
| 2324-9240 | ||||||||||||||||||||||||
2296 | if (m_previousIndex[i] != m_currentIndex[i]) {
| 1294-7946 | ||||||||||||||||||||||||
2297 | m_previousIndex[i] = m_currentIndex[i]; | - | ||||||||||||||||||||||||
2298 | indexChanges |= (1 << i); | - | ||||||||||||||||||||||||
2299 | } executed 1294 times by 2 tests: end of block Executed by:
| 1294 | ||||||||||||||||||||||||
2300 | } executed 9240 times by 2 tests: end of block Executed by:
| 9240 | ||||||||||||||||||||||||
2301 | - | |||||||||||||||||||||||||
2302 | int notifierId = 0; | - | ||||||||||||||||||||||||
2303 | const QMetaObject *meta = metaObject(); | - | ||||||||||||||||||||||||
2304 | for (int i = 1; i < m_cacheItem->metaType->groupCount; ++i, ++notifierId) {
| 2324-9240 | ||||||||||||||||||||||||
2305 | if (groupChanges & (1 << i))
| 112-9128 | ||||||||||||||||||||||||
2306 | QMetaObject::activate(this, meta, notifierId, nullptr); executed 112 times by 1 test: QMetaObject::activate(this, meta, notifierId, nullptr); Executed by:
| 112 | ||||||||||||||||||||||||
2307 | } executed 9240 times by 2 tests: end of block Executed by:
| 9240 | ||||||||||||||||||||||||
2308 | for (int i = 1; i < m_cacheItem->metaType->groupCount; ++i, ++notifierId) {
| 2324-9240 | ||||||||||||||||||||||||
2309 | if (indexChanges & (1 << i))
| 1294-7946 | ||||||||||||||||||||||||
2310 | QMetaObject::activate(this, meta, notifierId, nullptr); executed 1294 times by 2 tests: QMetaObject::activate(this, meta, notifierId, nullptr); Executed by:
| 1294 | ||||||||||||||||||||||||
2311 | } executed 9240 times by 2 tests: end of block Executed by:
| 9240 | ||||||||||||||||||||||||
2312 | - | |||||||||||||||||||||||||
2313 | if (groupChanges)
| 92-2232 | ||||||||||||||||||||||||
2314 | emit groupsChanged(); executed 92 times by 1 test: groupsChanged(); Executed by:
| 92 | ||||||||||||||||||||||||
2315 | } executed 2324 times by 2 tests: end of block Executed by:
| 2324 | ||||||||||||||||||||||||
2316 | - | |||||||||||||||||||||||||
2317 | //============================================================================ | - | ||||||||||||||||||||||||
2318 | - | |||||||||||||||||||||||||
2319 | void QQmlDelegateModelGroupPrivate::setModel(QQmlDelegateModel *m, Compositor::Group g) | - | ||||||||||||||||||||||||
2320 | { | - | ||||||||||||||||||||||||
2321 | Q_ASSERT(!model); | - | ||||||||||||||||||||||||
2322 | model = m; | - | ||||||||||||||||||||||||
2323 | group = g; | - | ||||||||||||||||||||||||
2324 | } executed 12316 times by 27 tests: end of block Executed by:
| 12316 | ||||||||||||||||||||||||
2325 | - | |||||||||||||||||||||||||
2326 | bool QQmlDelegateModelGroupPrivate::isChangedConnected() | - | ||||||||||||||||||||||||
2327 | { | - | ||||||||||||||||||||||||
2328 | Q_Q(QQmlDelegateModelGroup); | - | ||||||||||||||||||||||||
2329 | IS_SIGNAL_CONNECTED(q, QQmlDelegateModelGroup, changed, (const QQmlV4Handle &,const QQmlV4Handle &)); executed 41120 times by 27 tests: return QObjectPrivate::get(sender)->isSignalConnected(signalIdx); Executed by:
| 41120 | ||||||||||||||||||||||||
2330 | } | - | ||||||||||||||||||||||||
2331 | - | |||||||||||||||||||||||||
2332 | void QQmlDelegateModelGroupPrivate::emitChanges(QV4::ExecutionEngine *v4) | - | ||||||||||||||||||||||||
2333 | { | - | ||||||||||||||||||||||||
2334 | Q_Q(QQmlDelegateModelGroup); | - | ||||||||||||||||||||||||
2335 | if (isChangedConnected() && !changeSet.isEmpty()) {
| 46-40992 | ||||||||||||||||||||||||
2336 | QV4::Scope scope(v4); | - | ||||||||||||||||||||||||
2337 | QV4::ScopedValue removed(scope, engineData(scope.engine)->array(v4, changeSet.removes())); | - | ||||||||||||||||||||||||
2338 | QV4::ScopedValue inserted(scope, engineData(scope.engine)->array(v4, changeSet.inserts())); | - | ||||||||||||||||||||||||
2339 | emit q->changed(QQmlV4Handle(removed), QQmlV4Handle(inserted)); | - | ||||||||||||||||||||||||
2340 | } executed 82 times by 2 tests: end of block Executed by:
| 82 | ||||||||||||||||||||||||
2341 | if (changeSet.difference() != 0)
| 16458-24662 | ||||||||||||||||||||||||
2342 | emit q->countChanged(); executed 16458 times by 25 tests: q->countChanged(); Executed by:
| 16458 | ||||||||||||||||||||||||
2343 | } executed 41120 times by 27 tests: end of block Executed by:
| 41120 | ||||||||||||||||||||||||
2344 | - | |||||||||||||||||||||||||
2345 | void QQmlDelegateModelGroupPrivate::emitModelUpdated(bool reset) | - | ||||||||||||||||||||||||
2346 | { | - | ||||||||||||||||||||||||
2347 | for (QQmlDelegateModelGroupEmitterList::iterator it = emitters.begin(); it != emitters.end(); ++it)
| 20350-41120 | ||||||||||||||||||||||||
2348 | it->emitModelUpdated(changeSet, reset); executed 20350 times by 27 tests: it->emitModelUpdated(changeSet, reset); Executed by:
| 20350 | ||||||||||||||||||||||||
2349 | changeSet.clear(); | - | ||||||||||||||||||||||||
2350 | } executed 41120 times by 27 tests: end of block Executed by:
| 41120 | ||||||||||||||||||||||||
2351 | - | |||||||||||||||||||||||||
2352 | typedef QQmlDelegateModelGroupEmitterList::iterator GroupEmitterListIt; | - | ||||||||||||||||||||||||
2353 | - | |||||||||||||||||||||||||
2354 | void QQmlDelegateModelGroupPrivate::createdPackage(int index, QQuickPackage *package) | - | ||||||||||||||||||||||||
2355 | { | - | ||||||||||||||||||||||||
2356 | for (GroupEmitterListIt it = emitters.begin(), end = emitters.end(); it != end; ++it)
| 10188-12098 | ||||||||||||||||||||||||
2357 | it->createdPackage(index, package); executed 10188 times by 6 tests: it->createdPackage(index, package); Executed by:
| 10188 | ||||||||||||||||||||||||
2358 | } executed 12098 times by 6 tests: end of block Executed by:
| 12098 | ||||||||||||||||||||||||
2359 | - | |||||||||||||||||||||||||
2360 | void QQmlDelegateModelGroupPrivate::initPackage(int index, QQuickPackage *package) | - | ||||||||||||||||||||||||
2361 | { | - | ||||||||||||||||||||||||
2362 | for (GroupEmitterListIt it = emitters.begin(), end = emitters.end(); it != end; ++it)
| 10188-12098 | ||||||||||||||||||||||||
2363 | it->initPackage(index, package); executed 10188 times by 6 tests: it->initPackage(index, package); Executed by:
| 10188 | ||||||||||||||||||||||||
2364 | } executed 12098 times by 6 tests: end of block Executed by:
| 12098 | ||||||||||||||||||||||||
2365 | - | |||||||||||||||||||||||||
2366 | void QQmlDelegateModelGroupPrivate::destroyingPackage(QQuickPackage *package) | - | ||||||||||||||||||||||||
2367 | { | - | ||||||||||||||||||||||||
2368 | for (GroupEmitterListIt it = emitters.begin(), end = emitters.end(); it != end; ++it)
| 3324-3356 | ||||||||||||||||||||||||
2369 | it->destroyingPackage(package); executed 3356 times by 3 tests: it->destroyingPackage(package); Executed by:
| 3356 | ||||||||||||||||||||||||
2370 | } executed 3324 times by 3 tests: end of block Executed by:
| 3324 | ||||||||||||||||||||||||
2371 | - | |||||||||||||||||||||||||
2372 | /*! | - | ||||||||||||||||||||||||
2373 | \qmltype VisualDataGroup | - | ||||||||||||||||||||||||
2374 | \instantiates QQmlDelegateModelGroup | - | ||||||||||||||||||||||||
2375 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||
2376 | \ingroup qtquick-models | - | ||||||||||||||||||||||||
2377 | \brief Encapsulates a filtered set of visual data items. | - | ||||||||||||||||||||||||
2378 | - | |||||||||||||||||||||||||
2379 | The VisualDataGroup type provides a means to address the model data of a | - | ||||||||||||||||||||||||
2380 | model's delegate items, as well as sort and filter these delegate items. | - | ||||||||||||||||||||||||
2381 | - | |||||||||||||||||||||||||
2382 | This type is provided by the \l{Qt QML} module due to compatibility reasons. | - | ||||||||||||||||||||||||
2383 | The same implementation is now primarily available as \l DelegateModelGroup | - | ||||||||||||||||||||||||
2384 | in the \l{Qt QML Models QML Types}{Qt QML Models} module. | - | ||||||||||||||||||||||||
2385 | - | |||||||||||||||||||||||||
2386 | \sa {QtQml.Models::DelegateModelGroup} | - | ||||||||||||||||||||||||
2387 | */ | - | ||||||||||||||||||||||||
2388 | /*! | - | ||||||||||||||||||||||||
2389 | \qmltype DelegateModelGroup | - | ||||||||||||||||||||||||
2390 | \instantiates QQmlDelegateModelGroup | - | ||||||||||||||||||||||||
2391 | \inqmlmodule QtQml.Models | - | ||||||||||||||||||||||||
2392 | \ingroup qtquick-models | - | ||||||||||||||||||||||||
2393 | \brief Encapsulates a filtered set of visual data items. | - | ||||||||||||||||||||||||
2394 | - | |||||||||||||||||||||||||
2395 | The DelegateModelGroup type provides a means to address the model data of a | - | ||||||||||||||||||||||||
2396 | DelegateModel's delegate items, as well as sort and filter these delegate | - | ||||||||||||||||||||||||
2397 | items. | - | ||||||||||||||||||||||||
2398 | - | |||||||||||||||||||||||||
2399 | The initial set of instantiable delegate items in a DelegateModel is represented | - | ||||||||||||||||||||||||
2400 | by its \l {QtQml.Models::DelegateModel::items}{items} group, which normally directly reflects | - | ||||||||||||||||||||||||
2401 | the contents of the model assigned to DelegateModel::model. This set can be changed to | - | ||||||||||||||||||||||||
2402 | the contents of any other member of DelegateModel::groups by assigning the \l name of that | - | ||||||||||||||||||||||||
2403 | DelegateModelGroup to the DelegateModel::filterOnGroup property. | - | ||||||||||||||||||||||||
2404 | - | |||||||||||||||||||||||||
2405 | The data of an item in a DelegateModelGroup can be accessed using the get() function, which returns | - | ||||||||||||||||||||||||
2406 | information about group membership and indexes as well as model data. In combination | - | ||||||||||||||||||||||||
2407 | with the move() function this can be used to implement view sorting, with remove() to filter | - | ||||||||||||||||||||||||
2408 | items out of a view, or with setGroups() and \l Package delegates to categorize items into | - | ||||||||||||||||||||||||
2409 | different views. | - | ||||||||||||||||||||||||
2410 | - | |||||||||||||||||||||||||
2411 | Data from models can be supplemented by inserting data directly into a DelegateModelGroup | - | ||||||||||||||||||||||||
2412 | with the insert() function. This can be used to introduce mock items into a view, or | - | ||||||||||||||||||||||||
2413 | placeholder items that are later \l {resolve()}{resolved} to real model data when it becomes | - | ||||||||||||||||||||||||
2414 | available. | - | ||||||||||||||||||||||||
2415 | - | |||||||||||||||||||||||||
2416 | Delegate items can also be instantiated directly from a DelegateModelGroup using the | - | ||||||||||||||||||||||||
2417 | create() function, making it possible to use DelegateModel without an accompanying view | - | ||||||||||||||||||||||||
2418 | type or to cherry-pick specific items that should be instantiated irregardless of whether | - | ||||||||||||||||||||||||
2419 | they're currently within a view's visible area. | - | ||||||||||||||||||||||||
2420 | - | |||||||||||||||||||||||||
2421 | \note This type is also available as \l VisualDataGroup in the \l{Qt QML} | - | ||||||||||||||||||||||||
2422 | module due to compatibility reasons. | - | ||||||||||||||||||||||||
2423 | - | |||||||||||||||||||||||||
2424 | \sa {QML Dynamic View Ordering Tutorial} | - | ||||||||||||||||||||||||
2425 | */ | - | ||||||||||||||||||||||||
2426 | QQmlDelegateModelGroup::QQmlDelegateModelGroup(QObject *parent) | - | ||||||||||||||||||||||||
2427 | : QObject(*new QQmlDelegateModelGroupPrivate, parent) | - | ||||||||||||||||||||||||
2428 | { | - | ||||||||||||||||||||||||
2429 | } executed 12322 times by 27 tests: end of block Executed by:
| 12322 | ||||||||||||||||||||||||
2430 | - | |||||||||||||||||||||||||
2431 | QQmlDelegateModelGroup::QQmlDelegateModelGroup( | - | ||||||||||||||||||||||||
2432 | const QString &name, QQmlDelegateModel *model, int index, QObject *parent) | - | ||||||||||||||||||||||||
2433 | : QQmlDelegateModelGroup(parent) | - | ||||||||||||||||||||||||
2434 | { | - | ||||||||||||||||||||||||
2435 | Q_D(QQmlDelegateModelGroup); | - | ||||||||||||||||||||||||
2436 | d->name = name; | - | ||||||||||||||||||||||||
2437 | d->setModel(model, Compositor::Group(index)); | - | ||||||||||||||||||||||||
2438 | } executed 11244 times by 27 tests: end of block Executed by:
| 11244 | ||||||||||||||||||||||||
2439 | - | |||||||||||||||||||||||||
2440 | QQmlDelegateModelGroup::~QQmlDelegateModelGroup() | - | ||||||||||||||||||||||||
2441 | { | - | ||||||||||||||||||||||||
2442 | } | - | ||||||||||||||||||||||||
2443 | - | |||||||||||||||||||||||||
2444 | /*! | - | ||||||||||||||||||||||||
2445 | \qmlproperty string QtQml.Models::DelegateModelGroup::name | - | ||||||||||||||||||||||||
2446 | - | |||||||||||||||||||||||||
2447 | This property holds the name of the group. | - | ||||||||||||||||||||||||
2448 | - | |||||||||||||||||||||||||
2449 | Each group in a model must have a unique name starting with a lower case letter. | - | ||||||||||||||||||||||||
2450 | */ | - | ||||||||||||||||||||||||
2451 | - | |||||||||||||||||||||||||
2452 | QString QQmlDelegateModelGroup::name() const | - | ||||||||||||||||||||||||
2453 | { | - | ||||||||||||||||||||||||
2454 | Q_D(const QQmlDelegateModelGroup); | - | ||||||||||||||||||||||||
2455 | return d->name; executed 1084 times by 2 tests: return d->name; Executed by:
| 1084 | ||||||||||||||||||||||||
2456 | } | - | ||||||||||||||||||||||||
2457 | - | |||||||||||||||||||||||||
2458 | void QQmlDelegateModelGroup::setName(const QString &name) | - | ||||||||||||||||||||||||
2459 | { | - | ||||||||||||||||||||||||
2460 | Q_D(QQmlDelegateModelGroup); | - | ||||||||||||||||||||||||
2461 | if (d->model)
| 0-1074 | ||||||||||||||||||||||||
2462 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2463 | if (d->name != name) {
| 0-1074 | ||||||||||||||||||||||||
2464 | d->name = name; | - | ||||||||||||||||||||||||
2465 | emit nameChanged(); | - | ||||||||||||||||||||||||
2466 | } executed 1074 times by 2 tests: end of block Executed by:
| 1074 | ||||||||||||||||||||||||
2467 | } executed 1074 times by 2 tests: end of block Executed by:
| 1074 | ||||||||||||||||||||||||
2468 | - | |||||||||||||||||||||||||
2469 | /*! | - | ||||||||||||||||||||||||
2470 | \qmlproperty int QtQml.Models::DelegateModelGroup::count | - | ||||||||||||||||||||||||
2471 | - | |||||||||||||||||||||||||
2472 | This property holds the number of items in the group. | - | ||||||||||||||||||||||||
2473 | */ | - | ||||||||||||||||||||||||
2474 | - | |||||||||||||||||||||||||
2475 | int QQmlDelegateModelGroup::count() const | - | ||||||||||||||||||||||||
2476 | { | - | ||||||||||||||||||||||||
2477 | Q_D(const QQmlDelegateModelGroup); | - | ||||||||||||||||||||||||
2478 | if (!d->model)
| 0-2110 | ||||||||||||||||||||||||
2479 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
2480 | return QQmlDelegateModelPrivate::get(d->model)->m_compositor.count(d->group); executed 2110 times by 2 tests: return QQmlDelegateModelPrivate::get(d->model)->m_compositor.count(d->group); Executed by:
| 2110 | ||||||||||||||||||||||||
2481 | } | - | ||||||||||||||||||||||||
2482 | - | |||||||||||||||||||||||||
2483 | /*! | - | ||||||||||||||||||||||||
2484 | \qmlproperty bool QtQml.Models::DelegateModelGroup::includeByDefault | - | ||||||||||||||||||||||||
2485 | - | |||||||||||||||||||||||||
2486 | This property holds whether new items are assigned to this group by default. | - | ||||||||||||||||||||||||
2487 | */ | - | ||||||||||||||||||||||||
2488 | - | |||||||||||||||||||||||||
2489 | bool QQmlDelegateModelGroup::defaultInclude() const | - | ||||||||||||||||||||||||
2490 | { | - | ||||||||||||||||||||||||
2491 | Q_D(const QQmlDelegateModelGroup); | - | ||||||||||||||||||||||||
2492 | return d->defaultInclude; never executed: return d->defaultInclude; | 0 | ||||||||||||||||||||||||
2493 | } | - | ||||||||||||||||||||||||
2494 | - | |||||||||||||||||||||||||
2495 | void QQmlDelegateModelGroup::setDefaultInclude(bool include) | - | ||||||||||||||||||||||||
2496 | { | - | ||||||||||||||||||||||||
2497 | Q_D(QQmlDelegateModelGroup); | - | ||||||||||||||||||||||||
2498 | if (d->defaultInclude != include) {
| 0-6164 | ||||||||||||||||||||||||
2499 | d->defaultInclude = include; | - | ||||||||||||||||||||||||
2500 | - | |||||||||||||||||||||||||
2501 | if (d->model) {
| 536-5628 | ||||||||||||||||||||||||
2502 | if (include)
| 4-5624 | ||||||||||||||||||||||||
2503 | QQmlDelegateModelPrivate::get(d->model)->m_compositor.setDefaultGroup(d->group); executed 5624 times by 27 tests: QQmlDelegateModelPrivate::get(d->model)->m_compositor.setDefaultGroup(d->group); Executed by:
| 5624 | ||||||||||||||||||||||||
2504 | else | - | ||||||||||||||||||||||||
2505 | QQmlDelegateModelPrivate::get(d->model)->m_compositor.clearDefaultGroup(d->group); executed 4 times by 2 tests: QQmlDelegateModelPrivate::get(d->model)->m_compositor.clearDefaultGroup(d->group); Executed by:
| 4 | ||||||||||||||||||||||||
2506 | } | - | ||||||||||||||||||||||||
2507 | emit defaultIncludeChanged(); | - | ||||||||||||||||||||||||
2508 | } executed 6164 times by 27 tests: end of block Executed by:
| 6164 | ||||||||||||||||||||||||
2509 | } executed 6164 times by 27 tests: end of block Executed by:
| 6164 | ||||||||||||||||||||||||
2510 | - | |||||||||||||||||||||||||
2511 | /*! | - | ||||||||||||||||||||||||
2512 | \qmlmethod object QtQml.Models::DelegateModelGroup::get(int index) | - | ||||||||||||||||||||||||
2513 | - | |||||||||||||||||||||||||
2514 | Returns a javascript object describing the item at \a index in the group. | - | ||||||||||||||||||||||||
2515 | - | |||||||||||||||||||||||||
2516 | The returned object contains the same information that is available to a delegate from the | - | ||||||||||||||||||||||||
2517 | DelegateModel attached as well as the model for that item. It has the properties: | - | ||||||||||||||||||||||||
2518 | - | |||||||||||||||||||||||||
2519 | \list | - | ||||||||||||||||||||||||
2520 | \li \b model The model data of the item. This is the same as the model context property in | - | ||||||||||||||||||||||||
2521 | a delegate | - | ||||||||||||||||||||||||
2522 | \li \b groups A list the of names of groups the item is a member of. This property can be | - | ||||||||||||||||||||||||
2523 | written to change the item's membership. | - | ||||||||||||||||||||||||
2524 | \li \b inItems Whether the item belongs to the \l {QtQml.Models::DelegateModel::items}{items} group. | - | ||||||||||||||||||||||||
2525 | Writing to this property will add or remove the item from the group. | - | ||||||||||||||||||||||||
2526 | \li \b itemsIndex The index of the item within the \l {QtQml.Models::DelegateModel::items}{items} group. | - | ||||||||||||||||||||||||
2527 | \li \b {in<GroupName>} Whether the item belongs to the dynamic group \e groupName. Writing to | - | ||||||||||||||||||||||||
2528 | this property will add or remove the item from the group. | - | ||||||||||||||||||||||||
2529 | \li \b {<groupName>Index} The index of the item within the dynamic group \e groupName. | - | ||||||||||||||||||||||||
2530 | \li \b isUnresolved Whether the item is bound to an index in the model assigned to | - | ||||||||||||||||||||||||
2531 | DelegateModel::model. Returns true if the item is not bound to the model, and false if it is. | - | ||||||||||||||||||||||||
2532 | \endlist | - | ||||||||||||||||||||||||
2533 | */ | - | ||||||||||||||||||||||||
2534 | - | |||||||||||||||||||||||||
2535 | QQmlV4Handle QQmlDelegateModelGroup::get(int index) | - | ||||||||||||||||||||||||
2536 | { | - | ||||||||||||||||||||||||
2537 | Q_D(QQmlDelegateModelGroup); | - | ||||||||||||||||||||||||
2538 | if (!d->model)
| 0-26788 | ||||||||||||||||||||||||
2539 | return QQmlV4Handle(QV4::Encode::undefined()); never executed: return QQmlV4Handle(QV4::Encode::undefined()); | 0 | ||||||||||||||||||||||||
2540 | - | |||||||||||||||||||||||||
2541 | QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(d->model); | - | ||||||||||||||||||||||||
2542 | if (!model->m_context || !model->m_context->isValid()) {
| 0-26788 | ||||||||||||||||||||||||
2543 | return QQmlV4Handle(QV4::Encode::undefined()); never executed: return QQmlV4Handle(QV4::Encode::undefined()); | 0 | ||||||||||||||||||||||||
2544 | } else if (index < 0 || index >= model->m_compositor.count(d->group)) {
| 0-26788 | ||||||||||||||||||||||||
2545 | qmlWarning(this) << tr("get: index out of range"); | - | ||||||||||||||||||||||||
2546 | return QQmlV4Handle(QV4::Encode::undefined()); executed 2 times by 1 test: return QQmlV4Handle(QV4::Encode::undefined()); Executed by:
| 2 | ||||||||||||||||||||||||
2547 | } | - | ||||||||||||||||||||||||
2548 | - | |||||||||||||||||||||||||
2549 | Compositor::iterator it = model->m_compositor.find(d->group, index); | - | ||||||||||||||||||||||||
2550 | QQmlDelegateModelItem *cacheItem = it->inCache()
| 52-26734 | ||||||||||||||||||||||||
2551 | ? model->m_cache.at(it.cacheIndex) | - | ||||||||||||||||||||||||
2552 | : 0; | - | ||||||||||||||||||||||||
2553 | - | |||||||||||||||||||||||||
2554 | if (!cacheItem) {
| 52-26734 | ||||||||||||||||||||||||
2555 | cacheItem = model->m_adaptorModel.createItem( | - | ||||||||||||||||||||||||
2556 | model->m_cacheMetaType, it.modelIndex()); | - | ||||||||||||||||||||||||
2557 | if (!cacheItem)
| 0-52 | ||||||||||||||||||||||||
2558 | return QQmlV4Handle(QV4::Encode::undefined()); never executed: return QQmlV4Handle(QV4::Encode::undefined()); | 0 | ||||||||||||||||||||||||
2559 | cacheItem->groups = it->flags; | - | ||||||||||||||||||||||||
2560 | - | |||||||||||||||||||||||||
2561 | model->m_cache.insert(it.cacheIndex, cacheItem); | - | ||||||||||||||||||||||||
2562 | model->m_compositor.setFlags(it, 1, Compositor::CacheFlag); | - | ||||||||||||||||||||||||
2563 | } executed 52 times by 2 tests: end of block Executed by:
| 52 | ||||||||||||||||||||||||
2564 | - | |||||||||||||||||||||||||
2565 | if (model->m_cacheMetaType->modelItemProto.isUndefined())
| 420-26366 | ||||||||||||||||||||||||
2566 | model->m_cacheMetaType->initializePrototype(); executed 420 times by 2 tests: model->m_cacheMetaType->initializePrototype(); Executed by:
| 420 | ||||||||||||||||||||||||
2567 | QV4::ExecutionEngine *v4 = model->m_cacheMetaType->v4Engine; | - | ||||||||||||||||||||||||
2568 | QV4::Scope scope(v4); | - | ||||||||||||||||||||||||
2569 | QV4::ScopedObject o(scope, v4->memoryManager->allocate<QQmlDelegateModelItemObject>(cacheItem)); | - | ||||||||||||||||||||||||
2570 | QV4::ScopedObject p(scope, model->m_cacheMetaType->modelItemProto.value()); | - | ||||||||||||||||||||||||
2571 | o->setPrototypeOf(p); | - | ||||||||||||||||||||||||
2572 | ++cacheItem->scriptRef; | - | ||||||||||||||||||||||||
2573 | - | |||||||||||||||||||||||||
2574 | return QQmlV4Handle(o); executed 26786 times by 2 tests: return QQmlV4Handle(o); Executed by:
| 26786 | ||||||||||||||||||||||||
2575 | } | - | ||||||||||||||||||||||||
2576 | - | |||||||||||||||||||||||||
2577 | bool QQmlDelegateModelGroupPrivate::parseIndex(const QV4::Value &value, int *index, Compositor::Group *group) const | - | ||||||||||||||||||||||||
2578 | { | - | ||||||||||||||||||||||||
2579 | if (value.isNumber()) {
| 186-1260 | ||||||||||||||||||||||||
2580 | *index = value.toInt32(); | - | ||||||||||||||||||||||||
2581 | return true; executed 1260 times by 3 tests: return true; Executed by:
| 1260 | ||||||||||||||||||||||||
2582 | } | - | ||||||||||||||||||||||||
2583 | - | |||||||||||||||||||||||||
2584 | if (!value.isObject())
| 10-176 | ||||||||||||||||||||||||
2585 | return false; executed 10 times by 1 test: return false; Executed by:
| 10 | ||||||||||||||||||||||||
2586 | - | |||||||||||||||||||||||||
2587 | QV4::ExecutionEngine *v4 = value.as<QV4::Object>()->engine(); | - | ||||||||||||||||||||||||
2588 | QV4::Scope scope(v4); | - | ||||||||||||||||||||||||
2589 | QV4::Scoped<QQmlDelegateModelItemObject> object(scope, value); | - | ||||||||||||||||||||||||
2590 | - | |||||||||||||||||||||||||
2591 | if (object) {
| 88 | ||||||||||||||||||||||||
2592 | QQmlDelegateModelItem * const cacheItem = object->d()->item; | - | ||||||||||||||||||||||||
2593 | if (QQmlDelegateModelPrivate *model = cacheItem->metaType->model
| 0-88 | ||||||||||||||||||||||||
2594 | ? QQmlDelegateModelPrivate::get(cacheItem->metaType->model)
| 0-88 | ||||||||||||||||||||||||
2595 | : nullptr) {
| 0-88 | ||||||||||||||||||||||||
2596 | *index = model->m_cache.indexOf(cacheItem); | - | ||||||||||||||||||||||||
2597 | *group = Compositor::Cache; | - | ||||||||||||||||||||||||
2598 | return true; executed 88 times by 1 test: return true; Executed by:
| 88 | ||||||||||||||||||||||||
2599 | } | - | ||||||||||||||||||||||||
2600 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2601 | return false; executed 88 times by 1 test: return false; Executed by:
| 88 | ||||||||||||||||||||||||
2602 | } | - | ||||||||||||||||||||||||
2603 | - | |||||||||||||||||||||||||
2604 | /*! | - | ||||||||||||||||||||||||
2605 | \qmlmethod QtQml.Models::DelegateModelGroup::insert(int index, jsdict data, array groups = undefined) | - | ||||||||||||||||||||||||
2606 | \qmlmethod QtQml.Models::DelegateModelGroup::insert(jsdict data, var groups = undefined) | - | ||||||||||||||||||||||||
2607 | - | |||||||||||||||||||||||||
2608 | Creates a new entry at \a index in a DelegateModel with the values from \a data that | - | ||||||||||||||||||||||||
2609 | correspond to roles in the model assigned to DelegateModel::model. | - | ||||||||||||||||||||||||
2610 | - | |||||||||||||||||||||||||
2611 | If no index is supplied the data is appended to the model. | - | ||||||||||||||||||||||||
2612 | - | |||||||||||||||||||||||||
2613 | The optional \a groups parameter identifies the groups the new entry should belong to, | - | ||||||||||||||||||||||||
2614 | if unspecified this is equal to the group insert was called on. | - | ||||||||||||||||||||||||
2615 | - | |||||||||||||||||||||||||
2616 | Data inserted into a DelegateModel can later be merged with an existing entry in | - | ||||||||||||||||||||||||
2617 | DelegateModel::model using the \l resolve() function. This can be used to create placeholder | - | ||||||||||||||||||||||||
2618 | items that are later replaced by actual data. | - | ||||||||||||||||||||||||
2619 | */ | - | ||||||||||||||||||||||||
2620 | - | |||||||||||||||||||||||||
2621 | void QQmlDelegateModelGroup::insert(QQmlV4Function *args) | - | ||||||||||||||||||||||||
2622 | { | - | ||||||||||||||||||||||||
2623 | Q_D(QQmlDelegateModelGroup); | - | ||||||||||||||||||||||||
2624 | QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(d->model); | - | ||||||||||||||||||||||||
2625 | - | |||||||||||||||||||||||||
2626 | int index = model->m_compositor.count(d->group); | - | ||||||||||||||||||||||||
2627 | Compositor::Group group = d->group; | - | ||||||||||||||||||||||||
2628 | - | |||||||||||||||||||||||||
2629 | if (args->length() == 0)
| 0-284 | ||||||||||||||||||||||||
2630 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2631 | - | |||||||||||||||||||||||||
2632 | int i = 0; | - | ||||||||||||||||||||||||
2633 | QV4::Scope scope(args->v4engine()); | - | ||||||||||||||||||||||||
2634 | QV4::ScopedValue v(scope, (*args)[i]); | - | ||||||||||||||||||||||||
2635 | if (d->parseIndex(v, &index, &group)) {
| 72-212 | ||||||||||||||||||||||||
2636 | if (index < 0 || index > model->m_compositor.count(group)) {
| 2-210 | ||||||||||||||||||||||||
2637 | qmlWarning(this) << tr("insert: index out of range"); | - | ||||||||||||||||||||||||
2638 | return; executed 4 times by 1 test: return; Executed by:
| 4 | ||||||||||||||||||||||||
2639 | } | - | ||||||||||||||||||||||||
2640 | if (++i == args->length())
| 0-208 | ||||||||||||||||||||||||
2641 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2642 | v = (*args)[i]; | - | ||||||||||||||||||||||||
2643 | } executed 208 times by 1 test: end of block Executed by:
| 208 | ||||||||||||||||||||||||
2644 | - | |||||||||||||||||||||||||
2645 | Compositor::insert_iterator before = index < model->m_compositor.count(group)
| 84-196 | ||||||||||||||||||||||||
2646 | ? model->m_compositor.findInsertPosition(group, index) | - | ||||||||||||||||||||||||
2647 | : model->m_compositor.end(); | - | ||||||||||||||||||||||||
2648 | - | |||||||||||||||||||||||||
2649 | int groups = 1 << d->group; | - | ||||||||||||||||||||||||
2650 | if (++i < args->length()) {
| 12-268 | ||||||||||||||||||||||||
2651 | QV4::ScopedValue val(scope, (*args)[i]); | - | ||||||||||||||||||||||||
2652 | groups |= model->m_cacheMetaType->parseGroups(val); | - | ||||||||||||||||||||||||
2653 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||
2654 | - | |||||||||||||||||||||||||
2655 | if (v->as<QV4::ArrayObject>()) {
| 0-280 | ||||||||||||||||||||||||
2656 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2657 | } else if (v->as<QV4::Object>()) {
| 0-280 | ||||||||||||||||||||||||
2658 | model->insert(before, v, groups); | - | ||||||||||||||||||||||||
2659 | model->emitChanges(); | - | ||||||||||||||||||||||||
2660 | } executed 280 times by 1 test: end of block Executed by:
| 280 | ||||||||||||||||||||||||
2661 | } executed 280 times by 1 test: end of block Executed by:
| 280 | ||||||||||||||||||||||||
2662 | - | |||||||||||||||||||||||||
2663 | /*! | - | ||||||||||||||||||||||||
2664 | \qmlmethod QtQml.Models::DelegateModelGroup::create(int index) | - | ||||||||||||||||||||||||
2665 | \qmlmethod QtQml.Models::DelegateModelGroup::create(int index, jsdict data, array groups = undefined) | - | ||||||||||||||||||||||||
2666 | \qmlmethod QtQml.Models::DelegateModelGroup::create(jsdict data, array groups = undefined) | - | ||||||||||||||||||||||||
2667 | - | |||||||||||||||||||||||||
2668 | Returns a reference to the instantiated item at \a index in the group. | - | ||||||||||||||||||||||||
2669 | - | |||||||||||||||||||||||||
2670 | If a \a data object is provided it will be \l {insert}{inserted} at \a index and an item | - | ||||||||||||||||||||||||
2671 | referencing this new entry will be returned. The optional \a groups parameter identifies | - | ||||||||||||||||||||||||
2672 | the groups the new entry should belong to, if unspecified this is equal to the group create() | - | ||||||||||||||||||||||||
2673 | was called on. | - | ||||||||||||||||||||||||
2674 | - | |||||||||||||||||||||||||
2675 | All items returned by create are added to the | - | ||||||||||||||||||||||||
2676 | \l {QtQml.Models::DelegateModel::persistedItems}{persistedItems} group. Items in this | - | ||||||||||||||||||||||||
2677 | group remain instantiated when not referenced by any view. | - | ||||||||||||||||||||||||
2678 | */ | - | ||||||||||||||||||||||||
2679 | - | |||||||||||||||||||||||||
2680 | void QQmlDelegateModelGroup::create(QQmlV4Function *args) | - | ||||||||||||||||||||||||
2681 | { | - | ||||||||||||||||||||||||
2682 | Q_D(QQmlDelegateModelGroup); | - | ||||||||||||||||||||||||
2683 | if (!d->model)
| 0-536 | ||||||||||||||||||||||||
2684 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2685 | - | |||||||||||||||||||||||||
2686 | if (args->length() == 0)
| 0-536 | ||||||||||||||||||||||||
2687 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2688 | - | |||||||||||||||||||||||||
2689 | QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(d->model); | - | ||||||||||||||||||||||||
2690 | - | |||||||||||||||||||||||||
2691 | int index = model->m_compositor.count(d->group); | - | ||||||||||||||||||||||||
2692 | Compositor::Group group = d->group; | - | ||||||||||||||||||||||||
2693 | - | |||||||||||||||||||||||||
2694 | int i = 0; | - | ||||||||||||||||||||||||
2695 | QV4::Scope scope(args->v4engine()); | - | ||||||||||||||||||||||||
2696 | QV4::ScopedValue v(scope, (*args)[i]); | - | ||||||||||||||||||||||||
2697 | if (d->parseIndex(v, &index, &group))
| 16-520 | ||||||||||||||||||||||||
2698 | ++i; executed 520 times by 1 test: ++i; Executed by:
| 520 | ||||||||||||||||||||||||
2699 | - | |||||||||||||||||||||||||
2700 | if (i < args->length() && index >= 0 && index <= model->m_compositor.count(group)) {
| 2-396 | ||||||||||||||||||||||||
2701 | v = (*args)[i]; | - | ||||||||||||||||||||||||
2702 | if (v->as<QV4::Object>()) {
| 0-136 | ||||||||||||||||||||||||
2703 | int groups = 1 << d->group; | - | ||||||||||||||||||||||||
2704 | if (++i < args->length()) {
| 12-124 | ||||||||||||||||||||||||
2705 | QV4::ScopedValue val(scope, (*args)[i]); | - | ||||||||||||||||||||||||
2706 | groups |= model->m_cacheMetaType->parseGroups(val); | - | ||||||||||||||||||||||||
2707 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||
2708 | - | |||||||||||||||||||||||||
2709 | Compositor::insert_iterator before = index < model->m_compositor.count(group)
| 16-120 | ||||||||||||||||||||||||
2710 | ? model->m_compositor.findInsertPosition(group, index) | - | ||||||||||||||||||||||||
2711 | : model->m_compositor.end(); | - | ||||||||||||||||||||||||
2712 | - | |||||||||||||||||||||||||
2713 | index = before.index[d->group]; | - | ||||||||||||||||||||||||
2714 | group = d->group; | - | ||||||||||||||||||||||||
2715 | - | |||||||||||||||||||||||||
2716 | if (!model->insert(before, v, groups)) {
| 0-136 | ||||||||||||||||||||||||
2717 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2718 | } | - | ||||||||||||||||||||||||
2719 | } executed 136 times by 1 test: end of block Executed by:
| 136 | ||||||||||||||||||||||||
2720 | } executed 136 times by 1 test: end of block Executed by:
| 136 | ||||||||||||||||||||||||
2721 | if (index < 0 || index >= model->m_compositor.count(group)) {
| 2-534 | ||||||||||||||||||||||||
2722 | qmlWarning(this) << tr("create: index out of range"); | - | ||||||||||||||||||||||||
2723 | return; executed 4 times by 1 test: return; Executed by:
| 4 | ||||||||||||||||||||||||
2724 | } | - | ||||||||||||||||||||||||
2725 | - | |||||||||||||||||||||||||
2726 | QObject *object = model->object(group, index, QQmlIncubator::AsynchronousIfNested); | - | ||||||||||||||||||||||||
2727 | if (object) {
| 0-532 | ||||||||||||||||||||||||
2728 | QVector<Compositor::Insert> inserts; | - | ||||||||||||||||||||||||
2729 | Compositor::iterator it = model->m_compositor.find(group, index); | - | ||||||||||||||||||||||||
2730 | model->m_compositor.setFlags(it, 1, d->group, Compositor::PersistedFlag, &inserts); | - | ||||||||||||||||||||||||
2731 | model->itemsInserted(inserts); | - | ||||||||||||||||||||||||
2732 | model->m_cache.at(it.cacheIndex)->releaseObject(); | - | ||||||||||||||||||||||||
2733 | } executed 532 times by 1 test: end of block Executed by:
| 532 | ||||||||||||||||||||||||
2734 | - | |||||||||||||||||||||||||
2735 | args->setReturnValue(QV4::QObjectWrapper::wrap(args->v4engine(), object)); | - | ||||||||||||||||||||||||
2736 | model->emitChanges(); | - | ||||||||||||||||||||||||
2737 | } executed 532 times by 1 test: end of block Executed by:
| 532 | ||||||||||||||||||||||||
2738 | - | |||||||||||||||||||||||||
2739 | /*! | - | ||||||||||||||||||||||||
2740 | \qmlmethod QtQml.Models::DelegateModelGroup::resolve(int from, int to) | - | ||||||||||||||||||||||||
2741 | - | |||||||||||||||||||||||||
2742 | Binds an unresolved item at \a from to an item in DelegateModel::model at index \a to. | - | ||||||||||||||||||||||||
2743 | - | |||||||||||||||||||||||||
2744 | Unresolved items are entries whose data has been \l {insert()}{inserted} into a DelegateModelGroup | - | ||||||||||||||||||||||||
2745 | instead of being derived from a DelegateModel::model index. Resolving an item will replace | - | ||||||||||||||||||||||||
2746 | the item at the target index with the unresolved item. A resolved an item will reflect the data | - | ||||||||||||||||||||||||
2747 | of the source model at its bound index and will move when that index moves like any other item. | - | ||||||||||||||||||||||||
2748 | - | |||||||||||||||||||||||||
2749 | If a new item is replaced in the DelegateModelGroup onChanged() handler its insertion and | - | ||||||||||||||||||||||||
2750 | replacement will be communicated to views as an atomic operation, creating the appearance | - | ||||||||||||||||||||||||
2751 | that the model contents have not changed, or if the unresolved and model item are not adjacent | - | ||||||||||||||||||||||||
2752 | that the previously unresolved item has simply moved. | - | ||||||||||||||||||||||||
2753 | - | |||||||||||||||||||||||||
2754 | */ | - | ||||||||||||||||||||||||
2755 | void QQmlDelegateModelGroup::resolve(QQmlV4Function *args) | - | ||||||||||||||||||||||||
2756 | { | - | ||||||||||||||||||||||||
2757 | Q_D(QQmlDelegateModelGroup); | - | ||||||||||||||||||||||||
2758 | if (!d->model)
| 0-148 | ||||||||||||||||||||||||
2759 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2760 | - | |||||||||||||||||||||||||
2761 | QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(d->model); | - | ||||||||||||||||||||||||
2762 | - | |||||||||||||||||||||||||
2763 | if (args->length() < 2)
| 0-148 | ||||||||||||||||||||||||
2764 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2765 | - | |||||||||||||||||||||||||
2766 | int from = -1; | - | ||||||||||||||||||||||||
2767 | int to = -1; | - | ||||||||||||||||||||||||
2768 | Compositor::Group fromGroup = d->group; | - | ||||||||||||||||||||||||
2769 | Compositor::Group toGroup = d->group; | - | ||||||||||||||||||||||||
2770 | - | |||||||||||||||||||||||||
2771 | QV4::Scope scope(args->v4engine()); | - | ||||||||||||||||||||||||
2772 | QV4::ScopedValue v(scope, (*args)[0]); | - | ||||||||||||||||||||||||
2773 | if (d->parseIndex(v, &from, &fromGroup)) {
| 2-146 | ||||||||||||||||||||||||
2774 | if (from < 0 || from >= model->m_compositor.count(fromGroup)) {
| 2-144 | ||||||||||||||||||||||||
2775 | qmlWarning(this) << tr("resolve: from index out of range"); | - | ||||||||||||||||||||||||
2776 | return; executed 4 times by 1 test: return; Executed by:
| 4 | ||||||||||||||||||||||||
2777 | } | - | ||||||||||||||||||||||||
2778 | } else { executed 142 times by 1 test: end of block Executed by:
| 142 | ||||||||||||||||||||||||
2779 | qmlWarning(this) << tr("resolve: from index invalid"); | - | ||||||||||||||||||||||||
2780 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
2781 | } | - | ||||||||||||||||||||||||
2782 | - | |||||||||||||||||||||||||
2783 | v = (*args)[1]; | - | ||||||||||||||||||||||||
2784 | if (d->parseIndex(v, &to, &toGroup)) {
| 2-140 | ||||||||||||||||||||||||
2785 | if (to < 0 || to >= model->m_compositor.count(toGroup)) {
| 2-138 | ||||||||||||||||||||||||
2786 | qmlWarning(this) << tr("resolve: to index out of range"); | - | ||||||||||||||||||||||||
2787 | return; executed 4 times by 1 test: return; Executed by:
| 4 | ||||||||||||||||||||||||
2788 | } | - | ||||||||||||||||||||||||
2789 | } else { executed 136 times by 1 test: end of block Executed by:
| 136 | ||||||||||||||||||||||||
2790 | qmlWarning(this) << tr("resolve: to index invalid"); | - | ||||||||||||||||||||||||
2791 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
2792 | } | - | ||||||||||||||||||||||||
2793 | - | |||||||||||||||||||||||||
2794 | Compositor::iterator fromIt = model->m_compositor.find(fromGroup, from); | - | ||||||||||||||||||||||||
2795 | Compositor::iterator toIt = model->m_compositor.find(toGroup, to); | - | ||||||||||||||||||||||||
2796 | - | |||||||||||||||||||||||||
2797 | if (!fromIt->isUnresolved()) {
| 2-134 | ||||||||||||||||||||||||
2798 | qmlWarning(this) << tr("resolve: from is not an unresolved item"); | - | ||||||||||||||||||||||||
2799 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
2800 | } | - | ||||||||||||||||||||||||
2801 | if (!toIt->list) {
| 2-132 | ||||||||||||||||||||||||
2802 | qmlWarning(this) << tr("resolve: to is not a model item"); | - | ||||||||||||||||||||||||
2803 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
2804 | } | - | ||||||||||||||||||||||||
2805 | - | |||||||||||||||||||||||||
2806 | const int unresolvedFlags = fromIt->flags; | - | ||||||||||||||||||||||||
2807 | const int resolvedFlags = toIt->flags; | - | ||||||||||||||||||||||||
2808 | const int resolvedIndex = toIt.modelIndex(); | - | ||||||||||||||||||||||||
2809 | void * const resolvedList = toIt->list; | - | ||||||||||||||||||||||||
2810 | - | |||||||||||||||||||||||||
2811 | QQmlDelegateModelItem *cacheItem = model->m_cache.at(fromIt.cacheIndex); | - | ||||||||||||||||||||||||
2812 | cacheItem->groups &= ~Compositor::UnresolvedFlag; | - | ||||||||||||||||||||||||
2813 | - | |||||||||||||||||||||||||
2814 | if (toIt.cacheIndex > fromIt.cacheIndex)
| 64-68 | ||||||||||||||||||||||||
2815 | toIt.decrementIndexes(1, unresolvedFlags); executed 68 times by 1 test: toIt.decrementIndexes(1, unresolvedFlags); Executed by:
| 68 | ||||||||||||||||||||||||
2816 | if (!toIt->inGroup(fromGroup) || toIt.index[fromGroup] > from)
| 0-132 | ||||||||||||||||||||||||
2817 | from += 1; executed 12 times by 1 test: from += 1; Executed by:
| 12 | ||||||||||||||||||||||||
2818 | - | |||||||||||||||||||||||||
2819 | model->itemsMoved( | - | ||||||||||||||||||||||||
2820 | QVector<Compositor::Remove>(1, Compositor::Remove(fromIt, 1, unresolvedFlags, 0)), | - | ||||||||||||||||||||||||
2821 | QVector<Compositor::Insert>(1, Compositor::Insert(toIt, 1, unresolvedFlags, 0))); | - | ||||||||||||||||||||||||
2822 | model->itemsInserted( | - | ||||||||||||||||||||||||
2823 | QVector<Compositor::Insert>(1, Compositor::Insert(toIt, 1, (resolvedFlags & ~unresolvedFlags) | Compositor::CacheFlag))); | - | ||||||||||||||||||||||||
2824 | toIt.incrementIndexes(1, resolvedFlags | unresolvedFlags); | - | ||||||||||||||||||||||||
2825 | model->itemsRemoved(QVector<Compositor::Remove>(1, Compositor::Remove(toIt, 1, resolvedFlags))); | - | ||||||||||||||||||||||||
2826 | - | |||||||||||||||||||||||||
2827 | model->m_compositor.setFlags(toGroup, to, 1, unresolvedFlags & ~Compositor::UnresolvedFlag); | - | ||||||||||||||||||||||||
2828 | model->m_compositor.clearFlags(fromGroup, from, 1, unresolvedFlags); | - | ||||||||||||||||||||||||
2829 | - | |||||||||||||||||||||||||
2830 | if (resolvedFlags & Compositor::CacheFlag)
| 60-72 | ||||||||||||||||||||||||
2831 | model->m_compositor.insert(Compositor::Cache, toIt.cacheIndex, resolvedList, resolvedIndex, 1, Compositor::CacheFlag); executed 72 times by 1 test: model->m_compositor.insert(Compositor::Cache, toIt.cacheIndex, resolvedList, resolvedIndex, 1, Compositor::CacheFlag); Executed by:
| 72 | ||||||||||||||||||||||||
2832 | - | |||||||||||||||||||||||||
2833 | Q_ASSERT(model->m_cache.count() == model->m_compositor.count(Compositor::Cache)); | - | ||||||||||||||||||||||||
2834 | - | |||||||||||||||||||||||||
2835 | if (!cacheItem->isReferenced()) {
| 0-132 | ||||||||||||||||||||||||
2836 | Q_ASSERT(toIt.cacheIndex == model->m_cache.indexOf(cacheItem)); | - | ||||||||||||||||||||||||
2837 | model->m_cache.removeAt(toIt.cacheIndex); | - | ||||||||||||||||||||||||
2838 | model->m_compositor.clearFlags(Compositor::Cache, toIt.cacheIndex, 1, Compositor::CacheFlag); | - | ||||||||||||||||||||||||
2839 | delete cacheItem; | - | ||||||||||||||||||||||||
2840 | Q_ASSERT(model->m_cache.count() == model->m_compositor.count(Compositor::Cache)); | - | ||||||||||||||||||||||||
2841 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
2842 | cacheItem->resolveIndex(model->m_adaptorModel, resolvedIndex); | - | ||||||||||||||||||||||||
2843 | if (cacheItem->attached)
| 0-132 | ||||||||||||||||||||||||
2844 | cacheItem->attached->emitUnresolvedChanged(); never executed: cacheItem->attached->emitUnresolvedChanged(); | 0 | ||||||||||||||||||||||||
2845 | } executed 132 times by 1 test: end of block Executed by:
| 132 | ||||||||||||||||||||||||
2846 | - | |||||||||||||||||||||||||
2847 | model->emitChanges(); | - | ||||||||||||||||||||||||
2848 | } executed 132 times by 1 test: end of block Executed by:
| 132 | ||||||||||||||||||||||||
2849 | - | |||||||||||||||||||||||||
2850 | /*! | - | ||||||||||||||||||||||||
2851 | \qmlmethod QtQml.Models::DelegateModelGroup::remove(int index, int count) | - | ||||||||||||||||||||||||
2852 | - | |||||||||||||||||||||||||
2853 | Removes \a count items starting at \a index from the group. | - | ||||||||||||||||||||||||
2854 | */ | - | ||||||||||||||||||||||||
2855 | - | |||||||||||||||||||||||||
2856 | void QQmlDelegateModelGroup::remove(QQmlV4Function *args) | - | ||||||||||||||||||||||||
2857 | { | - | ||||||||||||||||||||||||
2858 | Q_D(QQmlDelegateModelGroup); | - | ||||||||||||||||||||||||
2859 | if (!d->model)
| 0-44 | ||||||||||||||||||||||||
2860 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2861 | Compositor::Group group = d->group; | - | ||||||||||||||||||||||||
2862 | int index = -1; | - | ||||||||||||||||||||||||
2863 | int count = 1; | - | ||||||||||||||||||||||||
2864 | - | |||||||||||||||||||||||||
2865 | if (args->length() == 0)
| 0-44 | ||||||||||||||||||||||||
2866 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2867 | - | |||||||||||||||||||||||||
2868 | int i = 0; | - | ||||||||||||||||||||||||
2869 | QV4::Scope scope(args->v4engine()); | - | ||||||||||||||||||||||||
2870 | QV4::ScopedValue v(scope, (*args)[0]); | - | ||||||||||||||||||||||||
2871 | if (!d->parseIndex(v, &index, &group)) {
| 2-42 | ||||||||||||||||||||||||
2872 | qmlWarning(this) << tr("remove: invalid index"); | - | ||||||||||||||||||||||||
2873 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
2874 | } | - | ||||||||||||||||||||||||
2875 | - | |||||||||||||||||||||||||
2876 | if (++i < args->length()) {
| 6-36 | ||||||||||||||||||||||||
2877 | v = (*args)[i]; | - | ||||||||||||||||||||||||
2878 | if (v->isNumber())
| 0-36 | ||||||||||||||||||||||||
2879 | count = v->toInt32(); executed 36 times by 1 test: count = v->toInt32(); Executed by:
| 36 | ||||||||||||||||||||||||
2880 | } executed 36 times by 1 test: end of block Executed by:
| 36 | ||||||||||||||||||||||||
2881 | - | |||||||||||||||||||||||||
2882 | QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(d->model); | - | ||||||||||||||||||||||||
2883 | if (index < 0 || index >= model->m_compositor.count(group)) {
| 6-36 | ||||||||||||||||||||||||
2884 | qmlWarning(this) << tr("remove: index out of range"); | - | ||||||||||||||||||||||||
2885 | } else if (count != 0) { executed 16 times by 1 test: end of block Executed by:
| 0-26 | ||||||||||||||||||||||||
2886 | Compositor::iterator it = model->m_compositor.find(group, index); | - | ||||||||||||||||||||||||
2887 | if (count < 0 || count > model->m_compositor.count(d->group) - it.index[d->group]) {
| 6-20 | ||||||||||||||||||||||||
2888 | qmlWarning(this) << tr("remove: invalid count"); | - | ||||||||||||||||||||||||
2889 | } else { executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||
2890 | model->removeGroups(it, count, d->group, 1 << d->group); | - | ||||||||||||||||||||||||
2891 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||||||||
2892 | } | - | ||||||||||||||||||||||||
2893 | } executed 42 times by 1 test: end of block Executed by:
| 42 | ||||||||||||||||||||||||
2894 | - | |||||||||||||||||||||||||
2895 | bool QQmlDelegateModelGroupPrivate::parseGroupArgs( | - | ||||||||||||||||||||||||
2896 | QQmlV4Function *args, Compositor::Group *group, int *index, int *count, int *groups) const | - | ||||||||||||||||||||||||
2897 | { | - | ||||||||||||||||||||||||
2898 | if (!model || !QQmlDelegateModelPrivate::get(model)->m_cacheMetaType)
| 0-124 | ||||||||||||||||||||||||
2899 | return false; executed 10 times by 2 tests: return false; Executed by:
| 10 | ||||||||||||||||||||||||
2900 | - | |||||||||||||||||||||||||
2901 | if (args->length() < 2)
| 0-114 | ||||||||||||||||||||||||
2902 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
2903 | - | |||||||||||||||||||||||||
2904 | int i = 0; | - | ||||||||||||||||||||||||
2905 | QV4::Scope scope(args->v4engine()); | - | ||||||||||||||||||||||||
2906 | QV4::ScopedValue v(scope, (*args)[i]); | - | ||||||||||||||||||||||||
2907 | if (!parseIndex(v, index, group))
| 0-114 | ||||||||||||||||||||||||
2908 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
2909 | - | |||||||||||||||||||||||||
2910 | v = (*args)[++i]; | - | ||||||||||||||||||||||||
2911 | if (v->isNumber()) {
| 20-94 | ||||||||||||||||||||||||
2912 | *count = v->toInt32(); | - | ||||||||||||||||||||||||
2913 | - | |||||||||||||||||||||||||
2914 | if (++i == args->length())
| 0-94 | ||||||||||||||||||||||||
2915 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
2916 | v = (*args)[i]; | - | ||||||||||||||||||||||||
2917 | } executed 94 times by 1 test: end of block Executed by:
| 94 | ||||||||||||||||||||||||
2918 | - | |||||||||||||||||||||||||
2919 | *groups = QQmlDelegateModelPrivate::get(model)->m_cacheMetaType->parseGroups(v); | - | ||||||||||||||||||||||||
2920 | - | |||||||||||||||||||||||||
2921 | return true; executed 114 times by 1 test: return true; Executed by:
| 114 | ||||||||||||||||||||||||
2922 | } | - | ||||||||||||||||||||||||
2923 | - | |||||||||||||||||||||||||
2924 | /*! | - | ||||||||||||||||||||||||
2925 | \qmlmethod QtQml.Models::DelegateModelGroup::addGroups(int index, int count, stringlist groups) | - | ||||||||||||||||||||||||
2926 | - | |||||||||||||||||||||||||
2927 | Adds \a count items starting at \a index to \a groups. | - | ||||||||||||||||||||||||
2928 | */ | - | ||||||||||||||||||||||||
2929 | - | |||||||||||||||||||||||||
2930 | void QQmlDelegateModelGroup::addGroups(QQmlV4Function *args) | - | ||||||||||||||||||||||||
2931 | { | - | ||||||||||||||||||||||||
2932 | Q_D(QQmlDelegateModelGroup); | - | ||||||||||||||||||||||||
2933 | Compositor::Group group = d->group; | - | ||||||||||||||||||||||||
2934 | int index = -1; | - | ||||||||||||||||||||||||
2935 | int count = 1; | - | ||||||||||||||||||||||||
2936 | int groups = 0; | - | ||||||||||||||||||||||||
2937 | - | |||||||||||||||||||||||||
2938 | if (!d->parseGroupArgs(args, &group, &index, &count, &groups))
| 2-42 | ||||||||||||||||||||||||
2939 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
2940 | - | |||||||||||||||||||||||||
2941 | QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(d->model); | - | ||||||||||||||||||||||||
2942 | if (index < 0 || index >= model->m_compositor.count(group)) {
| 6-36 | ||||||||||||||||||||||||
2943 | qmlWarning(this) << tr("addGroups: index out of range"); | - | ||||||||||||||||||||||||
2944 | } else if (count != 0) { executed 14 times by 1 test: end of block Executed by:
| 0-28 | ||||||||||||||||||||||||
2945 | Compositor::iterator it = model->m_compositor.find(group, index); | - | ||||||||||||||||||||||||
2946 | if (count < 0 || count > model->m_compositor.count(d->group) - it.index[d->group]) {
| 6-22 | ||||||||||||||||||||||||
2947 | qmlWarning(this) << tr("addGroups: invalid count"); | - | ||||||||||||||||||||||||
2948 | } else { executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||
2949 | model->addGroups(it, count, d->group, groups); | - | ||||||||||||||||||||||||
2950 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||||||||
2951 | } | - | ||||||||||||||||||||||||
2952 | } executed 42 times by 1 test: end of block Executed by:
| 42 | ||||||||||||||||||||||||
2953 | - | |||||||||||||||||||||||||
2954 | /*! | - | ||||||||||||||||||||||||
2955 | \qmlmethod QtQml.Models::DelegateModelGroup::removeGroups(int index, int count, stringlist groups) | - | ||||||||||||||||||||||||
2956 | - | |||||||||||||||||||||||||
2957 | Removes \a count items starting at \a index from \a groups. | - | ||||||||||||||||||||||||
2958 | */ | - | ||||||||||||||||||||||||
2959 | - | |||||||||||||||||||||||||
2960 | void QQmlDelegateModelGroup::removeGroups(QQmlV4Function *args) | - | ||||||||||||||||||||||||
2961 | { | - | ||||||||||||||||||||||||
2962 | Q_D(QQmlDelegateModelGroup); | - | ||||||||||||||||||||||||
2963 | Compositor::Group group = d->group; | - | ||||||||||||||||||||||||
2964 | int index = -1; | - | ||||||||||||||||||||||||
2965 | int count = 1; | - | ||||||||||||||||||||||||
2966 | int groups = 0; | - | ||||||||||||||||||||||||
2967 | - | |||||||||||||||||||||||||
2968 | if (!d->parseGroupArgs(args, &group, &index, &count, &groups))
| 2-32 | ||||||||||||||||||||||||
2969 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
2970 | - | |||||||||||||||||||||||||
2971 | QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(d->model); | - | ||||||||||||||||||||||||
2972 | if (index < 0 || index >= model->m_compositor.count(group)) {
| 6-26 | ||||||||||||||||||||||||
2973 | qmlWarning(this) << tr("removeGroups: index out of range"); | - | ||||||||||||||||||||||||
2974 | } else if (count != 0) { executed 14 times by 1 test: end of block Executed by:
| 0-18 | ||||||||||||||||||||||||
2975 | Compositor::iterator it = model->m_compositor.find(group, index); | - | ||||||||||||||||||||||||
2976 | if (count < 0 || count > model->m_compositor.count(d->group) - it.index[d->group]) {
| 6-12 | ||||||||||||||||||||||||
2977 | qmlWarning(this) << tr("removeGroups: invalid count"); | - | ||||||||||||||||||||||||
2978 | } else { executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||
2979 | model->removeGroups(it, count, d->group, groups); | - | ||||||||||||||||||||||||
2980 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
2981 | } | - | ||||||||||||||||||||||||
2982 | } executed 32 times by 1 test: end of block Executed by:
| 32 | ||||||||||||||||||||||||
2983 | - | |||||||||||||||||||||||||
2984 | /*! | - | ||||||||||||||||||||||||
2985 | \qmlmethod QtQml.Models::DelegateModelGroup::setGroups(int index, int count, stringlist groups) | - | ||||||||||||||||||||||||
2986 | - | |||||||||||||||||||||||||
2987 | Sets the \a groups \a count items starting at \a index belong to. | - | ||||||||||||||||||||||||
2988 | */ | - | ||||||||||||||||||||||||
2989 | - | |||||||||||||||||||||||||
2990 | void QQmlDelegateModelGroup::setGroups(QQmlV4Function *args) | - | ||||||||||||||||||||||||
2991 | { | - | ||||||||||||||||||||||||
2992 | Q_D(QQmlDelegateModelGroup); | - | ||||||||||||||||||||||||
2993 | Compositor::Group group = d->group; | - | ||||||||||||||||||||||||
2994 | int index = -1; | - | ||||||||||||||||||||||||
2995 | int count = 1; | - | ||||||||||||||||||||||||
2996 | int groups = 0; | - | ||||||||||||||||||||||||
2997 | - | |||||||||||||||||||||||||
2998 | if (!d->parseGroupArgs(args, &group, &index, &count, &groups))
| 6-40 | ||||||||||||||||||||||||
2999 | return; executed 6 times by 2 tests: return; Executed by:
| 6 | ||||||||||||||||||||||||
3000 | - | |||||||||||||||||||||||||
3001 | QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(d->model); | - | ||||||||||||||||||||||||
3002 | if (index < 0 || index >= model->m_compositor.count(group)) {
| 6-34 | ||||||||||||||||||||||||
3003 | qmlWarning(this) << tr("setGroups: index out of range"); | - | ||||||||||||||||||||||||
3004 | } else if (count != 0) { executed 14 times by 1 test: end of block Executed by:
| 0-26 | ||||||||||||||||||||||||
3005 | Compositor::iterator it = model->m_compositor.find(group, index); | - | ||||||||||||||||||||||||
3006 | if (count < 0 || count > model->m_compositor.count(d->group) - it.index[d->group]) {
| 6-20 | ||||||||||||||||||||||||
3007 | qmlWarning(this) << tr("setGroups: invalid count"); | - | ||||||||||||||||||||||||
3008 | } else { executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||
3009 | model->setGroups(it, count, d->group, groups); | - | ||||||||||||||||||||||||
3010 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||||||||
3011 | } | - | ||||||||||||||||||||||||
3012 | } executed 40 times by 1 test: end of block Executed by:
| 40 | ||||||||||||||||||||||||
3013 | - | |||||||||||||||||||||||||
3014 | /*! | - | ||||||||||||||||||||||||
3015 | \qmlmethod QtQml.Models::DelegateModelGroup::setGroups(int index, int count, stringlist groups) | - | ||||||||||||||||||||||||
3016 | - | |||||||||||||||||||||||||
3017 | Sets the \a groups \a count items starting at \a index belong to. | - | ||||||||||||||||||||||||
3018 | */ | - | ||||||||||||||||||||||||
3019 | - | |||||||||||||||||||||||||
3020 | /*! | - | ||||||||||||||||||||||||
3021 | \qmlmethod QtQml.Models::DelegateModelGroup::move(var from, var to, int count) | - | ||||||||||||||||||||||||
3022 | - | |||||||||||||||||||||||||
3023 | Moves \a count at \a from in a group \a to a new position. | - | ||||||||||||||||||||||||
3024 | */ | - | ||||||||||||||||||||||||
3025 | - | |||||||||||||||||||||||||
3026 | void QQmlDelegateModelGroup::move(QQmlV4Function *args) | - | ||||||||||||||||||||||||
3027 | { | - | ||||||||||||||||||||||||
3028 | Q_D(QQmlDelegateModelGroup); | - | ||||||||||||||||||||||||
3029 | - | |||||||||||||||||||||||||
3030 | if (args->length() < 2)
| 0-90 | ||||||||||||||||||||||||
3031 | return; never executed: return; | 0 | ||||||||||||||||||||||||
3032 | - | |||||||||||||||||||||||||
3033 | Compositor::Group fromGroup = d->group; | - | ||||||||||||||||||||||||
3034 | Compositor::Group toGroup = d->group; | - | ||||||||||||||||||||||||
3035 | int from = -1; | - | ||||||||||||||||||||||||
3036 | int to = -1; | - | ||||||||||||||||||||||||
3037 | int count = 1; | - | ||||||||||||||||||||||||
3038 | - | |||||||||||||||||||||||||
3039 | QV4::Scope scope(args->v4engine()); | - | ||||||||||||||||||||||||
3040 | QV4::ScopedValue v(scope, (*args)[0]); | - | ||||||||||||||||||||||||
3041 | if (!d->parseIndex(v, &from, &fromGroup)) {
| 2-88 | ||||||||||||||||||||||||
3042 | qmlWarning(this) << tr("move: invalid from index"); | - | ||||||||||||||||||||||||
3043 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
3044 | } | - | ||||||||||||||||||||||||
3045 | - | |||||||||||||||||||||||||
3046 | v = (*args)[1]; | - | ||||||||||||||||||||||||
3047 | if (!d->parseIndex(v, &to, &toGroup)) {
| 2-86 | ||||||||||||||||||||||||
3048 | qmlWarning(this) << tr("move: invalid to index"); | - | ||||||||||||||||||||||||
3049 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
3050 | } | - | ||||||||||||||||||||||||
3051 | - | |||||||||||||||||||||||||
3052 | if (args->length() > 2) {
| 30-56 | ||||||||||||||||||||||||
3053 | v = (*args)[2]; | - | ||||||||||||||||||||||||
3054 | if (v->isNumber())
| 0-56 | ||||||||||||||||||||||||
3055 | count = v->toInt32(); executed 56 times by 1 test: count = v->toInt32(); Executed by:
| 56 | ||||||||||||||||||||||||
3056 | } executed 56 times by 1 test: end of block Executed by:
| 56 | ||||||||||||||||||||||||
3057 | - | |||||||||||||||||||||||||
3058 | QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(d->model); | - | ||||||||||||||||||||||||
3059 | - | |||||||||||||||||||||||||
3060 | if (count < 0) {
| 6-80 | ||||||||||||||||||||||||
3061 | qmlWarning(this) << tr("move: invalid count"); | - | ||||||||||||||||||||||||
3062 | } else if (from < 0 || from + count > model->m_compositor.count(fromGroup)) { executed 6 times by 1 test: end of block Executed by:
| 6-74 | ||||||||||||||||||||||||
3063 | qmlWarning(this) << tr("move: from index out of range"); | - | ||||||||||||||||||||||||
3064 | } else if (!model->m_compositor.verifyMoveTo(fromGroup, from, toGroup, to, count, d->group)) { executed 20 times by 1 test: end of block Executed by:
| 18-42 | ||||||||||||||||||||||||
3065 | qmlWarning(this) << tr("move: to index out of range"); | - | ||||||||||||||||||||||||
3066 | } else if (count > 0) { executed 18 times by 1 test: end of block Executed by:
| 0-42 | ||||||||||||||||||||||||
3067 | QVector<Compositor::Remove> removes; | - | ||||||||||||||||||||||||
3068 | QVector<Compositor::Insert> inserts; | - | ||||||||||||||||||||||||
3069 | - | |||||||||||||||||||||||||
3070 | model->m_compositor.move(fromGroup, from, toGroup, to, count, d->group, &removes, &inserts); | - | ||||||||||||||||||||||||
3071 | model->itemsMoved(removes, inserts); | - | ||||||||||||||||||||||||
3072 | model->emitChanges(); | - | ||||||||||||||||||||||||
3073 | } executed 42 times by 3 tests: end of block Executed by:
| 42 | ||||||||||||||||||||||||
3074 | - | |||||||||||||||||||||||||
3075 | } executed 86 times by 3 tests: end of block Executed by:
| 86 | ||||||||||||||||||||||||
3076 | - | |||||||||||||||||||||||||
3077 | /*! | - | ||||||||||||||||||||||||
3078 | \qmlsignal QtQml.Models::DelegateModelGroup::changed(array removed, array inserted) | - | ||||||||||||||||||||||||
3079 | - | |||||||||||||||||||||||||
3080 | This signal is emitted when items have been removed from or inserted into the group. | - | ||||||||||||||||||||||||
3081 | - | |||||||||||||||||||||||||
3082 | Each object in the \a removed and \a inserted arrays has two values; the \e index of the first | - | ||||||||||||||||||||||||
3083 | item inserted or removed and a \e count of the number of consecutive items inserted or removed. | - | ||||||||||||||||||||||||
3084 | - | |||||||||||||||||||||||||
3085 | Each index is adjusted for previous changes with all removed items preceding any inserted | - | ||||||||||||||||||||||||
3086 | items. | - | ||||||||||||||||||||||||
3087 | - | |||||||||||||||||||||||||
3088 | The corresponding handler is \c onChanged. | - | ||||||||||||||||||||||||
3089 | */ | - | ||||||||||||||||||||||||
3090 | - | |||||||||||||||||||||||||
3091 | //============================================================================ | - | ||||||||||||||||||||||||
3092 | - | |||||||||||||||||||||||||
3093 | QQmlPartsModel::QQmlPartsModel(QQmlDelegateModel *model, const QString &part, QObject *parent) | - | ||||||||||||||||||||||||
3094 | : QQmlInstanceModel(*new QObjectPrivate, parent) | - | ||||||||||||||||||||||||
3095 | , m_model(model) | - | ||||||||||||||||||||||||
3096 | , m_part(part) | - | ||||||||||||||||||||||||
3097 | , m_compositorGroup(Compositor::Cache) | - | ||||||||||||||||||||||||
3098 | , m_inheritGroup(true) | - | ||||||||||||||||||||||||
3099 | { | - | ||||||||||||||||||||||||
3100 | QQmlDelegateModelPrivate *d = QQmlDelegateModelPrivate::get(m_model); | - | ||||||||||||||||||||||||
3101 | if (d->m_cacheMetaType) {
| 0-368 | ||||||||||||||||||||||||
3102 | QQmlDelegateModelGroupPrivate::get(d->m_groups[1])->emitters.insert(this); | - | ||||||||||||||||||||||||
3103 | m_compositorGroup = Compositor::Default; | - | ||||||||||||||||||||||||
3104 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
3105 | d->m_pendingParts.insert(this); | - | ||||||||||||||||||||||||
3106 | } executed 368 times by 6 tests: end of block Executed by:
| 368 | ||||||||||||||||||||||||
3107 | } | - | ||||||||||||||||||||||||
3108 | - | |||||||||||||||||||||||||
3109 | QQmlPartsModel::~QQmlPartsModel() | - | ||||||||||||||||||||||||
3110 | { | - | ||||||||||||||||||||||||
3111 | } | - | ||||||||||||||||||||||||
3112 | - | |||||||||||||||||||||||||
3113 | QString QQmlPartsModel::filterGroup() const | - | ||||||||||||||||||||||||
3114 | { | - | ||||||||||||||||||||||||
3115 | if (m_inheritGroup)
| 2-4 | ||||||||||||||||||||||||
3116 | return m_model->filterGroup(); executed 2 times by 1 test: return m_model->filterGroup(); Executed by:
| 2 | ||||||||||||||||||||||||
3117 | return m_filterGroup; executed 4 times by 1 test: return m_filterGroup; Executed by:
| 4 | ||||||||||||||||||||||||
3118 | } | - | ||||||||||||||||||||||||
3119 | - | |||||||||||||||||||||||||
3120 | void QQmlPartsModel::setFilterGroup(const QString &group) | - | ||||||||||||||||||||||||
3121 | { | - | ||||||||||||||||||||||||
3122 | if (QQmlDelegateModelPrivate::get(m_model)->m_transaction) {
| 0-6 | ||||||||||||||||||||||||
3123 | qmlWarning(this) << tr("The group of a DelegateModel cannot be changed within onChanged"); | - | ||||||||||||||||||||||||
3124 | return; never executed: return; | 0 | ||||||||||||||||||||||||
3125 | } | - | ||||||||||||||||||||||||
3126 | - | |||||||||||||||||||||||||
3127 | if (m_filterGroup != group || m_inheritGroup) {
| 0-6 | ||||||||||||||||||||||||
3128 | m_filterGroup = group; | - | ||||||||||||||||||||||||
3129 | m_inheritGroup = false; | - | ||||||||||||||||||||||||
3130 | updateFilterGroup(); | - | ||||||||||||||||||||||||
3131 | - | |||||||||||||||||||||||||
3132 | emit filterGroupChanged(); | - | ||||||||||||||||||||||||
3133 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||||||||
3134 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||||||||
3135 | - | |||||||||||||||||||||||||
3136 | void QQmlPartsModel::resetFilterGroup() | - | ||||||||||||||||||||||||
3137 | { | - | ||||||||||||||||||||||||
3138 | if (!m_inheritGroup) {
| 0-2 | ||||||||||||||||||||||||
3139 | m_inheritGroup = true; | - | ||||||||||||||||||||||||
3140 | updateFilterGroup(); | - | ||||||||||||||||||||||||
3141 | emit filterGroupChanged(); | - | ||||||||||||||||||||||||
3142 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
3143 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
3144 | - | |||||||||||||||||||||||||
3145 | void QQmlPartsModel::updateFilterGroup() | - | ||||||||||||||||||||||||
3146 | { | - | ||||||||||||||||||||||||
3147 | QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(m_model); | - | ||||||||||||||||||||||||
3148 | if (!model->m_cacheMetaType)
| 0-8 | ||||||||||||||||||||||||
3149 | return; never executed: return; | 0 | ||||||||||||||||||||||||
3150 | - | |||||||||||||||||||||||||
3151 | if (m_inheritGroup) {
| 2-6 | ||||||||||||||||||||||||
3152 | if (m_filterGroup == model->m_filterGroup)
| 0-2 | ||||||||||||||||||||||||
3153 | return; never executed: return; | 0 | ||||||||||||||||||||||||
3154 | m_filterGroup = model->m_filterGroup; | - | ||||||||||||||||||||||||
3155 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
3156 | - | |||||||||||||||||||||||||
3157 | QQmlListCompositor::Group previousGroup = m_compositorGroup; | - | ||||||||||||||||||||||||
3158 | m_compositorGroup = Compositor::Default; | - | ||||||||||||||||||||||||
3159 | QQmlDelegateModelGroupPrivate::get(model->m_groups[Compositor::Default])->emitters.insert(this); | - | ||||||||||||||||||||||||
3160 | for (int i = 1; i < model->m_groupCount; ++i) {
| 0-22 | ||||||||||||||||||||||||
3161 | if (m_filterGroup == model->m_cacheMetaType->groupNames.at(i - 1)) {
| 8-14 | ||||||||||||||||||||||||
3162 | m_compositorGroup = Compositor::Group(i); | - | ||||||||||||||||||||||||
3163 | break; executed 8 times by 2 tests: break; Executed by:
| 8 | ||||||||||||||||||||||||
3164 | } | - | ||||||||||||||||||||||||
3165 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||||||||||||||
3166 | - | |||||||||||||||||||||||||
3167 | QQmlDelegateModelGroupPrivate::get(model->m_groups[m_compositorGroup])->emitters.insert(this); | - | ||||||||||||||||||||||||
3168 | if (m_compositorGroup != previousGroup) {
| 0-8 | ||||||||||||||||||||||||
3169 | QVector<QQmlChangeSet::Change> removes; | - | ||||||||||||||||||||||||
3170 | QVector<QQmlChangeSet::Change> inserts; | - | ||||||||||||||||||||||||
3171 | model->m_compositor.transition(previousGroup, m_compositorGroup, &removes, &inserts); | - | ||||||||||||||||||||||||
3172 | - | |||||||||||||||||||||||||
3173 | QQmlChangeSet changeSet; | - | ||||||||||||||||||||||||
3174 | changeSet.move(removes, inserts); | - | ||||||||||||||||||||||||
3175 | if (!changeSet.isEmpty())
| 0-8 | ||||||||||||||||||||||||
3176 | emit modelUpdated(changeSet, false); executed 8 times by 2 tests: modelUpdated(changeSet, false); Executed by:
| 8 | ||||||||||||||||||||||||
3177 | - | |||||||||||||||||||||||||
3178 | if (changeSet.difference() != 0)
| 0-8 | ||||||||||||||||||||||||
3179 | emit countChanged(); executed 8 times by 2 tests: countChanged(); Executed by:
| 8 | ||||||||||||||||||||||||
3180 | } executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||||||||||||||||||||
3181 | } executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||||||||||||||||||||
3182 | - | |||||||||||||||||||||||||
3183 | void QQmlPartsModel::updateFilterGroup( | - | ||||||||||||||||||||||||
3184 | Compositor::Group group, const QQmlChangeSet &changeSet) | - | ||||||||||||||||||||||||
3185 | { | - | ||||||||||||||||||||||||
3186 | if (!m_inheritGroup)
| 0-368 | ||||||||||||||||||||||||
3187 | return; never executed: return; | 0 | ||||||||||||||||||||||||
3188 | - | |||||||||||||||||||||||||
3189 | m_compositorGroup = group; | - | ||||||||||||||||||||||||
3190 | QQmlDelegateModelGroupPrivate::get(QQmlDelegateModelPrivate::get(m_model)->m_groups[m_compositorGroup])->emitters.insert(this); | - | ||||||||||||||||||||||||
3191 | - | |||||||||||||||||||||||||
3192 | if (!changeSet.isEmpty())
| 0-368 | ||||||||||||||||||||||||
3193 | emit modelUpdated(changeSet, false); never executed: modelUpdated(changeSet, false); | 0 | ||||||||||||||||||||||||
3194 | - | |||||||||||||||||||||||||
3195 | if (changeSet.difference() != 0)
| 0-368 | ||||||||||||||||||||||||
3196 | emit countChanged(); never executed: countChanged(); | 0 | ||||||||||||||||||||||||
3197 | - | |||||||||||||||||||||||||
3198 | emit filterGroupChanged(); | - | ||||||||||||||||||||||||
3199 | } executed 368 times by 6 tests: end of block Executed by:
| 368 | ||||||||||||||||||||||||
3200 | - | |||||||||||||||||||||||||
3201 | int QQmlPartsModel::count() const | - | ||||||||||||||||||||||||
3202 | { | - | ||||||||||||||||||||||||
3203 | QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(m_model); | - | ||||||||||||||||||||||||
3204 | return model->m_delegate executed 26425 times by 6 tests: return model->m_delegate ? model->m_compositor.count(m_compositorGroup) : 0; Executed by:
| 26425 | ||||||||||||||||||||||||
3205 | ? model->m_compositor.count(m_compositorGroup) executed 26425 times by 6 tests: return model->m_delegate ? model->m_compositor.count(m_compositorGroup) : 0; Executed by:
| 26425 | ||||||||||||||||||||||||
3206 | : 0; executed 26425 times by 6 tests: return model->m_delegate ? model->m_compositor.count(m_compositorGroup) : 0; Executed by:
| 26425 | ||||||||||||||||||||||||
3207 | } | - | ||||||||||||||||||||||||
3208 | - | |||||||||||||||||||||||||
3209 | bool QQmlPartsModel::isValid() const | - | ||||||||||||||||||||||||
3210 | { | - | ||||||||||||||||||||||||
3211 | return m_model->isValid(); executed 4899 times by 6 tests: return m_model->isValid(); Executed by:
| 4899 | ||||||||||||||||||||||||
3212 | } | - | ||||||||||||||||||||||||
3213 | - | |||||||||||||||||||||||||
3214 | QObject *QQmlPartsModel::object(int index, QQmlIncubator::IncubationMode incubationMode) | - | ||||||||||||||||||||||||
3215 | { | - | ||||||||||||||||||||||||
3216 | QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(m_model); | - | ||||||||||||||||||||||||
3217 | - | |||||||||||||||||||||||||
3218 | if (!model->m_delegate || index < 0 || index >= model->m_compositor.count(m_compositorGroup)) {
| 0-5744 | ||||||||||||||||||||||||
3219 | qWarning() << "DelegateModel::item: index out range" << index << model->m_compositor.count(m_compositorGroup); | - | ||||||||||||||||||||||||
3220 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
3221 | } | - | ||||||||||||||||||||||||
3222 | - | |||||||||||||||||||||||||
3223 | QObject *object = model->object(m_compositorGroup, index, incubationMode); | - | ||||||||||||||||||||||||
3224 | - | |||||||||||||||||||||||||
3225 | if (QQuickPackage *package = qmlobject_cast<QQuickPackage *>(object)) {
| 2-5742 | ||||||||||||||||||||||||
3226 | QObject *part = package->part(m_part); | - | ||||||||||||||||||||||||
3227 | if (!part)
| 0-5742 | ||||||||||||||||||||||||
3228 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
3229 | m_packaged.insertMulti(part, package); | - | ||||||||||||||||||||||||
3230 | return part; executed 5742 times by 6 tests: return part; Executed by:
| 5742 | ||||||||||||||||||||||||
3231 | } | - | ||||||||||||||||||||||||
3232 | - | |||||||||||||||||||||||||
3233 | model->release(object); | - | ||||||||||||||||||||||||
3234 | if (!model->m_delegateValidated) {
| 0-2 | ||||||||||||||||||||||||
3235 | if (object)
| 0-2 | ||||||||||||||||||||||||
3236 | qmlWarning(model->m_delegate) << tr("Delegate component must be Package type."); never executed: qmlWarning(model->m_delegate) << tr("Delegate component must be Package type."); | 0 | ||||||||||||||||||||||||
3237 | model->m_delegateValidated = true; | - | ||||||||||||||||||||||||
3238 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
3239 | - | |||||||||||||||||||||||||
3240 | return nullptr; executed 2 times by 1 test: return nullptr; Executed by:
| 2 | ||||||||||||||||||||||||
3241 | } | - | ||||||||||||||||||||||||
3242 | - | |||||||||||||||||||||||||
3243 | QQmlInstanceModel::ReleaseFlags QQmlPartsModel::release(QObject *item) | - | ||||||||||||||||||||||||
3244 | { | - | ||||||||||||||||||||||||
3245 | QQmlInstanceModel::ReleaseFlags flags = nullptr; | - | ||||||||||||||||||||||||
3246 | - | |||||||||||||||||||||||||
3247 | QHash<QObject *, QQuickPackage *>::iterator it = m_packaged.find(item); | - | ||||||||||||||||||||||||
3248 | if (it != m_packaged.end()) {
| 0-3302 | ||||||||||||||||||||||||
3249 | QQuickPackage *package = *it; | - | ||||||||||||||||||||||||
3250 | QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(m_model); | - | ||||||||||||||||||||||||
3251 | flags = model->release(package); | - | ||||||||||||||||||||||||
3252 | m_packaged.erase(it); | - | ||||||||||||||||||||||||
3253 | if (!m_packaged.contains(item))
| 566-2736 | ||||||||||||||||||||||||
3254 | flags &= ~Referenced; executed 2736 times by 4 tests: flags &= ~Referenced; Executed by:
| 2736 | ||||||||||||||||||||||||
3255 | if (flags & Destroyed)
| 1648-1654 | ||||||||||||||||||||||||
3256 | QQmlDelegateModelPrivate::get(m_model)->emitDestroyingPackage(package); executed 1654 times by 3 tests: QQmlDelegateModelPrivate::get(m_model)->emitDestroyingPackage(package); Executed by:
| 1654 | ||||||||||||||||||||||||
3257 | } executed 3302 times by 4 tests: end of block Executed by:
| 3302 | ||||||||||||||||||||||||
3258 | return flags; executed 3302 times by 4 tests: return flags; Executed by:
| 3302 | ||||||||||||||||||||||||
3259 | } | - | ||||||||||||||||||||||||
3260 | - | |||||||||||||||||||||||||
3261 | QString QQmlPartsModel::stringValue(int index, const QString &role) | - | ||||||||||||||||||||||||
3262 | { | - | ||||||||||||||||||||||||
3263 | return QQmlDelegateModelPrivate::get(m_model)->stringValue(m_compositorGroup, index, role); executed 404 times by 1 test: return QQmlDelegateModelPrivate::get(m_model)->stringValue(m_compositorGroup, index, role); Executed by:
| 404 | ||||||||||||||||||||||||
3264 | } | - | ||||||||||||||||||||||||
3265 | - | |||||||||||||||||||||||||
3266 | void QQmlPartsModel::setWatchedRoles(const QList<QByteArray> &roles) | - | ||||||||||||||||||||||||
3267 | { | - | ||||||||||||||||||||||||
3268 | QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(m_model); | - | ||||||||||||||||||||||||
3269 | model->m_adaptorModel.replaceWatchedRoles(m_watchedRoles, roles); | - | ||||||||||||||||||||||||
3270 | m_watchedRoles = roles; | - | ||||||||||||||||||||||||
3271 | } executed 348 times by 3 tests: end of block Executed by:
| 348 | ||||||||||||||||||||||||
3272 | - | |||||||||||||||||||||||||
3273 | QQmlIncubator::Status QQmlPartsModel::incubationStatus(int index) | - | ||||||||||||||||||||||||
3274 | { | - | ||||||||||||||||||||||||
3275 | QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(m_model); | - | ||||||||||||||||||||||||
3276 | Compositor::iterator it = model->m_compositor.find(model->m_compositorGroup, index); | - | ||||||||||||||||||||||||
3277 | if (!it->inCache())
| 0-2 | ||||||||||||||||||||||||
3278 | return QQmlIncubator::Null; never executed: return QQmlIncubator::Null; | 0 | ||||||||||||||||||||||||
3279 | - | |||||||||||||||||||||||||
3280 | if (auto incubationTask = model->m_cache.at(it.cacheIndex)->incubationTask)
| 0-2 | ||||||||||||||||||||||||
3281 | return incubationTask->status(); executed 2 times by 1 test: return incubationTask->status(); Executed by:
| 2 | ||||||||||||||||||||||||
3282 | - | |||||||||||||||||||||||||
3283 | return QQmlIncubator::Ready; never executed: return QQmlIncubator::Ready; | 0 | ||||||||||||||||||||||||
3284 | } | - | ||||||||||||||||||||||||
3285 | - | |||||||||||||||||||||||||
3286 | int QQmlPartsModel::indexOf(QObject *item, QObject *) const | - | ||||||||||||||||||||||||
3287 | { | - | ||||||||||||||||||||||||
3288 | QHash<QObject *, QQuickPackage *>::const_iterator it = m_packaged.find(item); | - | ||||||||||||||||||||||||
3289 | if (it != m_packaged.end()) {
| 272-1372 | ||||||||||||||||||||||||
3290 | if (QQmlDelegateModelItem *cacheItem = QQmlDelegateModelItem::dataForObject(*it))
| 0-272 | ||||||||||||||||||||||||
3291 | return cacheItem->groupIndex(m_compositorGroup); never executed: return cacheItem->groupIndex(m_compositorGroup); | 0 | ||||||||||||||||||||||||
3292 | } executed 272 times by 1 test: end of block Executed by:
| 272 | ||||||||||||||||||||||||
3293 | return -1; executed 1644 times by 4 tests: return -1; Executed by:
| 1644 | ||||||||||||||||||||||||
3294 | } | - | ||||||||||||||||||||||||
3295 | - | |||||||||||||||||||||||||
3296 | void QQmlPartsModel::createdPackage(int index, QQuickPackage *package) | - | ||||||||||||||||||||||||
3297 | { | - | ||||||||||||||||||||||||
3298 | emit createdItem(index, package->part(m_part)); | - | ||||||||||||||||||||||||
3299 | } executed 5226 times by 6 tests: end of block Executed by:
| 5226 | ||||||||||||||||||||||||
3300 | - | |||||||||||||||||||||||||
3301 | void QQmlPartsModel::initPackage(int index, QQuickPackage *package) | - | ||||||||||||||||||||||||
3302 | { | - | ||||||||||||||||||||||||
3303 | if (m_modelUpdatePending)
| 2-5224 | ||||||||||||||||||||||||
3304 | m_pendingPackageInitializations << index; executed 2 times by 1 test: m_pendingPackageInitializations << index; Executed by:
| 2 | ||||||||||||||||||||||||
3305 | else | - | ||||||||||||||||||||||||
3306 | emit initItem(index, package->part(m_part)); executed 5224 times by 6 tests: initItem(index, package->part(m_part)); Executed by:
| 5224 | ||||||||||||||||||||||||
3307 | } | - | ||||||||||||||||||||||||
3308 | - | |||||||||||||||||||||||||
3309 | void QQmlPartsModel::destroyingPackage(QQuickPackage *package) | - | ||||||||||||||||||||||||
3310 | { | - | ||||||||||||||||||||||||
3311 | QObject *item = package->part(m_part); | - | ||||||||||||||||||||||||
3312 | Q_ASSERT(!m_packaged.contains(item)); | - | ||||||||||||||||||||||||
3313 | emit destroyingItem(item); | - | ||||||||||||||||||||||||
3314 | } executed 1698 times by 3 tests: end of block Executed by:
| 1698 | ||||||||||||||||||||||||
3315 | - | |||||||||||||||||||||||||
3316 | void QQmlPartsModel::emitModelUpdated(const QQmlChangeSet &changeSet, bool reset) | - | ||||||||||||||||||||||||
3317 | { | - | ||||||||||||||||||||||||
3318 | m_modelUpdatePending = false; | - | ||||||||||||||||||||||||
3319 | emit modelUpdated(changeSet, reset); | - | ||||||||||||||||||||||||
3320 | if (changeSet.difference() != 0)
| 410-1060 | ||||||||||||||||||||||||
3321 | emit countChanged(); executed 1060 times by 6 tests: countChanged(); Executed by:
| 1060 | ||||||||||||||||||||||||
3322 | - | |||||||||||||||||||||||||
3323 | QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(m_model); | - | ||||||||||||||||||||||||
3324 | QVector<int> pendingPackageInitializations; | - | ||||||||||||||||||||||||
3325 | qSwap(pendingPackageInitializations, m_pendingPackageInitializations); | - | ||||||||||||||||||||||||
3326 | for (int index : pendingPackageInitializations) { | - | ||||||||||||||||||||||||
3327 | if (!model->m_delegate || index < 0 || index >= model->m_compositor.count(m_compositorGroup))
| 0-2 | ||||||||||||||||||||||||
3328 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
3329 | QObject *object = model->object(m_compositorGroup, index, QQmlIncubator::Asynchronous); | - | ||||||||||||||||||||||||
3330 | if (QQuickPackage *package = qmlobject_cast<QQuickPackage *>(object))
| 0-2 | ||||||||||||||||||||||||
3331 | emit initItem(index, package->part(m_part)); executed 2 times by 1 test: initItem(index, package->part(m_part)); Executed by:
| 2 | ||||||||||||||||||||||||
3332 | model->release(object); | - | ||||||||||||||||||||||||
3333 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
3334 | } executed 1470 times by 6 tests: end of block Executed by:
| 1470 | ||||||||||||||||||||||||
3335 | - | |||||||||||||||||||||||||
3336 | //============================================================================ | - | ||||||||||||||||||||||||
3337 | - | |||||||||||||||||||||||||
3338 | struct QQmlDelegateModelGroupChange : QV4::Object | - | ||||||||||||||||||||||||
3339 | { | - | ||||||||||||||||||||||||
3340 | V4_OBJECT2(QQmlDelegateModelGroupChange, QV4::Object) executed 166 times by 1 test: end of block Executed by:
never executed: end of block executed 664 times by 1 test: return &static_vtbl; Executed by:
executed 696 times by 1 test: return static_cast<QV4::Heap::QQmlDelegateModelGroupChange *>(m()); Executed by:
executed 530 times by 1 test: return dptr; Executed by:
| 0-696 | ||||||||||||||||||||||||
3341 | - | |||||||||||||||||||||||||
3342 | static QV4::Heap::QQmlDelegateModelGroupChange *create(QV4::ExecutionEngine *e) { | - | ||||||||||||||||||||||||
3343 | return e->memoryManager->allocate<QQmlDelegateModelGroupChange>(); executed 166 times by 1 test: return e->memoryManager->allocate<QQmlDelegateModelGroupChange>(); Executed by:
| 166 | ||||||||||||||||||||||||
3344 | } | - | ||||||||||||||||||||||||
3345 | - | |||||||||||||||||||||||||
3346 | static QV4::ReturnedValue method_get_index(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) { | - | ||||||||||||||||||||||||
3347 | QV4::Scope scope(b); | - | ||||||||||||||||||||||||
3348 | QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, thisObject->as<QQmlDelegateModelGroupChange>()); | - | ||||||||||||||||||||||||
3349 | if (!that)
| 0-50 | ||||||||||||||||||||||||
3350 | THROW_TYPE_ERROR(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
3351 | return QV4::Encode(that->d()->change.index); executed 50 times by 1 test: return QV4::Encode(that->d()->change.index); Executed by:
| 50 | ||||||||||||||||||||||||
3352 | } | - | ||||||||||||||||||||||||
3353 | static QV4::ReturnedValue method_get_count(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) { | - | ||||||||||||||||||||||||
3354 | QV4::Scope scope(b); | - | ||||||||||||||||||||||||
3355 | QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, thisObject->as<QQmlDelegateModelGroupChange>()); | - | ||||||||||||||||||||||||
3356 | if (!that)
| 0-50 | ||||||||||||||||||||||||
3357 | THROW_TYPE_ERROR(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
3358 | return QV4::Encode(that->d()->change.count); executed 50 times by 1 test: return QV4::Encode(that->d()->change.count); Executed by:
| 50 | ||||||||||||||||||||||||
3359 | } | - | ||||||||||||||||||||||||
3360 | static QV4::ReturnedValue method_get_moveId(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) { | - | ||||||||||||||||||||||||
3361 | QV4::Scope scope(b); | - | ||||||||||||||||||||||||
3362 | QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, thisObject->as<QQmlDelegateModelGroupChange>()); | - | ||||||||||||||||||||||||
3363 | if (!that)
| 0-66 | ||||||||||||||||||||||||
3364 | THROW_TYPE_ERROR(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
3365 | if (that->d()->change.moveId < 0)
| 32-34 | ||||||||||||||||||||||||
3366 | RETURN_UNDEFINED(); executed 34 times by 1 test: return QV4::Encode::undefined(); Executed by:
| 34 | ||||||||||||||||||||||||
3367 | return QV4::Encode(that->d()->change.moveId); executed 32 times by 1 test: return QV4::Encode(that->d()->change.moveId); Executed by:
| 32 | ||||||||||||||||||||||||
3368 | } | - | ||||||||||||||||||||||||
3369 | }; | - | ||||||||||||||||||||||||
3370 | - | |||||||||||||||||||||||||
3371 | DEFINE_OBJECT_VTABLE(QQmlDelegateModelGroupChange); | - | ||||||||||||||||||||||||
3372 | - | |||||||||||||||||||||||||
3373 | struct QQmlDelegateModelGroupChangeArray : public QV4::Object | - | ||||||||||||||||||||||||
3374 | { | - | ||||||||||||||||||||||||
3375 | V4_OBJECT2(QQmlDelegateModelGroupChangeArray, QV4::Object) executed 536 times by 1 test: end of block Executed by:
never executed: end of block executed 1028 times by 2 tests: return &static_vtbl; Executed by:
executed 1030 times by 2 tests: return static_cast<QV4::Heap::QQmlDelegateModelGroupChangeArray *>(m()); Executed by:
executed 866 times by 2 tests: return dptr; Executed by:
| 0-1030 | ||||||||||||||||||||||||
3376 | V4_NEEDS_DESTROY executed 164 times by 2 tests: end of block Executed by:
| 164 | ||||||||||||||||||||||||
3377 | public: | - | ||||||||||||||||||||||||
3378 | static QV4::Heap::QQmlDelegateModelGroupChangeArray *create(QV4::ExecutionEngine *engine, const QVector<QQmlChangeSet::Change> &changes) | - | ||||||||||||||||||||||||
3379 | { | - | ||||||||||||||||||||||||
3380 | return engine->memoryManager->allocate<QQmlDelegateModelGroupChangeArray>(changes); executed 164 times by 2 tests: return engine->memoryManager->allocate<QQmlDelegateModelGroupChangeArray>(changes); Executed by:
| 164 | ||||||||||||||||||||||||
3381 | } | - | ||||||||||||||||||||||||
3382 | - | |||||||||||||||||||||||||
3383 | quint32 count() const { return d()->changes->count(); } executed 536 times by 1 test: return d()->changes->count(); Executed by:
| 536 | ||||||||||||||||||||||||
3384 | const QQmlChangeSet::Change &at(int index) const { return d()->changes->at(index); } executed 166 times by 1 test: return d()->changes->at(index); Executed by:
| 166 | ||||||||||||||||||||||||
3385 | - | |||||||||||||||||||||||||
3386 | static QV4::ReturnedValue virtualGet(const QV4::Managed *m, QV4::PropertyKey id, const QV4::Value *receiver, bool *hasProperty) | - | ||||||||||||||||||||||||
3387 | { | - | ||||||||||||||||||||||||
3388 | if (id.isArrayIndex()) {
| 166-370 | ||||||||||||||||||||||||
3389 | uint index = id.asArrayIndex(); | - | ||||||||||||||||||||||||
3390 | Q_ASSERT(m->as<QQmlDelegateModelGroupChangeArray>()); | - | ||||||||||||||||||||||||
3391 | QV4::ExecutionEngine *v4 = static_cast<const QQmlDelegateModelGroupChangeArray *>(m)->engine(); | - | ||||||||||||||||||||||||
3392 | QV4::Scope scope(v4); | - | ||||||||||||||||||||||||
3393 | QV4::Scoped<QQmlDelegateModelGroupChangeArray> array(scope, static_cast<const QQmlDelegateModelGroupChangeArray *>(m)); | - | ||||||||||||||||||||||||
3394 | - | |||||||||||||||||||||||||
3395 | if (index >= array->count()) {
| 0-166 | ||||||||||||||||||||||||
3396 | if (hasProperty)
| 0 | ||||||||||||||||||||||||
3397 | *hasProperty = false; never executed: *hasProperty = false; | 0 | ||||||||||||||||||||||||
3398 | return QV4::Primitive::undefinedValue().asReturnedValue(); never executed: return QV4::Primitive::undefinedValue().asReturnedValue(); | 0 | ||||||||||||||||||||||||
3399 | } | - | ||||||||||||||||||||||||
3400 | - | |||||||||||||||||||||||||
3401 | const QQmlChangeSet::Change &change = array->at(index); | - | ||||||||||||||||||||||||
3402 | - | |||||||||||||||||||||||||
3403 | QV4::ScopedObject changeProto(scope, engineData(v4)->changeProto.value()); | - | ||||||||||||||||||||||||
3404 | QV4::Scoped<QQmlDelegateModelGroupChange> object(scope, QQmlDelegateModelGroupChange::create(v4)); | - | ||||||||||||||||||||||||
3405 | object->setPrototypeOf(changeProto); | - | ||||||||||||||||||||||||
3406 | object->d()->change = change; | - | ||||||||||||||||||||||||
3407 | - | |||||||||||||||||||||||||
3408 | if (hasProperty)
| 0-166 | ||||||||||||||||||||||||
3409 | *hasProperty = true; never executed: *hasProperty = true; | 0 | ||||||||||||||||||||||||
3410 | return object.asReturnedValue(); executed 166 times by 1 test: return object.asReturnedValue(); Executed by:
| 166 | ||||||||||||||||||||||||
3411 | } | - | ||||||||||||||||||||||||
3412 | - | |||||||||||||||||||||||||
3413 | Q_ASSERT(m->as<QQmlDelegateModelGroupChangeArray>()); | - | ||||||||||||||||||||||||
3414 | const QQmlDelegateModelGroupChangeArray *array = static_cast<const QQmlDelegateModelGroupChangeArray *>(m); | - | ||||||||||||||||||||||||
3415 | - | |||||||||||||||||||||||||
3416 | if (id == array->engine()->id_length()->propertyKey()) {
| 0-370 | ||||||||||||||||||||||||
3417 | if (hasProperty)
| 0-370 | ||||||||||||||||||||||||
3418 | *hasProperty = true; never executed: *hasProperty = true; | 0 | ||||||||||||||||||||||||
3419 | return QV4::Encode(array->count()); executed 370 times by 1 test: return QV4::Encode(array->count()); Executed by:
| 370 | ||||||||||||||||||||||||
3420 | } | - | ||||||||||||||||||||||||
3421 | - | |||||||||||||||||||||||||
3422 | return Object::virtualGet(m, id, receiver, hasProperty); never executed: return Object::virtualGet(m, id, receiver, hasProperty); | 0 | ||||||||||||||||||||||||
3423 | } | - | ||||||||||||||||||||||||
3424 | }; | - | ||||||||||||||||||||||||
3425 | - | |||||||||||||||||||||||||
3426 | void QV4::Heap::QQmlDelegateModelGroupChangeArray::init(const QVector<QQmlChangeSet::Change> &changes) | - | ||||||||||||||||||||||||
3427 | { | - | ||||||||||||||||||||||||
3428 | Object::init(); | - | ||||||||||||||||||||||||
3429 | this->changes = new QVector<QQmlChangeSet::Change>(changes); | - | ||||||||||||||||||||||||
3430 | QV4::Scope scope(internalClass->engine); | - | ||||||||||||||||||||||||
3431 | QV4::ScopedObject o(scope, this); | - | ||||||||||||||||||||||||
3432 | o->setArrayType(QV4::Heap::ArrayData::Custom); | - | ||||||||||||||||||||||||
3433 | } executed 164 times by 2 tests: end of block Executed by:
| 164 | ||||||||||||||||||||||||
3434 | - | |||||||||||||||||||||||||
3435 | DEFINE_OBJECT_VTABLE(QQmlDelegateModelGroupChangeArray); | - | ||||||||||||||||||||||||
3436 | - | |||||||||||||||||||||||||
3437 | QQmlDelegateModelEngineData::QQmlDelegateModelEngineData(QV4::ExecutionEngine *v4) | - | ||||||||||||||||||||||||
3438 | { | - | ||||||||||||||||||||||||
3439 | QV4::Scope scope(v4); | - | ||||||||||||||||||||||||
3440 | - | |||||||||||||||||||||||||
3441 | QV4::ScopedObject proto(scope, v4->newObject()); | - | ||||||||||||||||||||||||
3442 | proto->defineAccessorProperty(QStringLiteral("index"), QQmlDelegateModelGroupChange::method_get_index, nullptr); executed 4 times by 2 tests: return qstring_literal_temp; Executed by:
| 4 | ||||||||||||||||||||||||
3443 | proto->defineAccessorProperty(QStringLiteral("count"), QQmlDelegateModelGroupChange::method_get_count, nullptr); executed 4 times by 2 tests: return qstring_literal_temp; Executed by:
| 4 | ||||||||||||||||||||||||
3444 | proto->defineAccessorProperty(QStringLiteral("moveId"), QQmlDelegateModelGroupChange::method_get_moveId, nullptr); executed 4 times by 2 tests: return qstring_literal_temp; Executed by:
| 4 | ||||||||||||||||||||||||
3445 | changeProto.set(v4, proto); | - | ||||||||||||||||||||||||
3446 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||||||||
3447 | - | |||||||||||||||||||||||||
3448 | QQmlDelegateModelEngineData::~QQmlDelegateModelEngineData() | - | ||||||||||||||||||||||||
3449 | { | - | ||||||||||||||||||||||||
3450 | } | - | ||||||||||||||||||||||||
3451 | - | |||||||||||||||||||||||||
3452 | QV4::ReturnedValue QQmlDelegateModelEngineData::array(QV4::ExecutionEngine *v4, | - | ||||||||||||||||||||||||
3453 | const QVector<QQmlChangeSet::Change> &changes) | - | ||||||||||||||||||||||||
3454 | { | - | ||||||||||||||||||||||||
3455 | QV4::Scope scope(v4); | - | ||||||||||||||||||||||||
3456 | QV4::ScopedObject o(scope, QQmlDelegateModelGroupChangeArray::create(v4, changes)); | - | ||||||||||||||||||||||||
3457 | return o.asReturnedValue(); executed 164 times by 2 tests: return o.asReturnedValue(); Executed by:
| 164 | ||||||||||||||||||||||||
3458 | } | - | ||||||||||||||||||||||||
3459 | - | |||||||||||||||||||||||||
3460 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
3461 | - | |||||||||||||||||||||||||
3462 | #include "moc_qqmldelegatemodel_p.cpp" | - | ||||||||||||||||||||||||
Source code | Switch to Preprocessed file |