| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/util/qqmladaptormodel.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 "qqmladaptormodel_p.h" | - | ||||||||||||||||||
| 41 | - | |||||||||||||||||||
| 42 | #include <private/qqmldelegatemodel_p_p.h> | - | ||||||||||||||||||
| 43 | #include <private/qmetaobjectbuilder_p.h> | - | ||||||||||||||||||
| 44 | #include <private/qqmlproperty_p.h> | - | ||||||||||||||||||
| 45 | #include <private/qv8engine_p.h> | - | ||||||||||||||||||
| 46 | - | |||||||||||||||||||
| 47 | #include <private/qv4value_p.h> | - | ||||||||||||||||||
| 48 | #include <private/qv4functionobject_p.h> | - | ||||||||||||||||||
| 49 | - | |||||||||||||||||||
| 50 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
| 51 | - | |||||||||||||||||||
| 52 | class QQmlAdaptorModelEngineData : public QV8Engine::Deletable | - | ||||||||||||||||||
| 53 | { | - | ||||||||||||||||||
| 54 | public: | - | ||||||||||||||||||
| 55 | QQmlAdaptorModelEngineData(QV4::ExecutionEngine *v4); | - | ||||||||||||||||||
| 56 | ~QQmlAdaptorModelEngineData(); | - | ||||||||||||||||||
| 57 | - | |||||||||||||||||||
| 58 | QV4::ExecutionEngine *v4; | - | ||||||||||||||||||
| 59 | QV4::PersistentValue listItemProto; | - | ||||||||||||||||||
| 60 | }; | - | ||||||||||||||||||
| 61 | - | |||||||||||||||||||
| 62 | V4_DEFINE_EXTENSION(QQmlAdaptorModelEngineData, engineData) executed 4 times by 2 tests: extensionId = QV8Engine::registerExtension();Executed by:
executed 4 times by 2 tests: end of blockExecuted by:
executed 8 times by 2 tests: end of blockExecuted by:
executed 786 times by 2 tests: return rv;Executed by:
| 0-786 | ||||||||||||||||||
| 63 | - | |||||||||||||||||||
| 64 | static QV4::ReturnedValue get_index(const QV4::FunctionObject *f, const QV4::Value *thisObject, const QV4::Value *, int) | - | ||||||||||||||||||
| 65 | { | - | ||||||||||||||||||
| 66 | QV4::Scope scope(f); | - | ||||||||||||||||||
| 67 | QV4::Scoped<QQmlDelegateModelItemObject> o(scope, thisObject->as<QQmlDelegateModelItemObject>()); | - | ||||||||||||||||||
| 68 | if (!o)
| 0-2332 | ||||||||||||||||||
| 69 | RETURN_RESULT(scope.engine->throwTypeError(QStringLiteral("Not a valid VisualData object"))); never executed: return QV4::Encode(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 | ||||||||||||||||||
| 70 | - | |||||||||||||||||||
| 71 | RETURN_RESULT(QV4::Encode(o->d()->item->index)); executed 2332 times by 1 test: return QV4::Encode(QV4::Encode(o->d()->item->index));Executed by:
| 2332 | ||||||||||||||||||
| 72 | } | - | ||||||||||||||||||
| 73 | - | |||||||||||||||||||
| 74 | template <typename T, typename M> static void setModelDataType(QMetaObjectBuilder *builder, M *metaType) | - | ||||||||||||||||||
| 75 | { | - | ||||||||||||||||||
| 76 | builder->setFlags(QMetaObjectBuilder::DynamicMetaObject); | - | ||||||||||||||||||
| 77 | builder->setClassName(T::staticMetaObject.className()); | - | ||||||||||||||||||
| 78 | builder->setSuperClass(&T::staticMetaObject); | - | ||||||||||||||||||
| 79 | metaType->propertyOffset = T::staticMetaObject.propertyCount(); | - | ||||||||||||||||||
| 80 | metaType->signalOffset = T::staticMetaObject.methodCount(); | - | ||||||||||||||||||
| 81 | } executed 3970 times by 12 tests: end of blockExecuted by:
| 3970 | ||||||||||||||||||
| 82 | - | |||||||||||||||||||
| 83 | static void addProperty(QMetaObjectBuilder *builder, int propertyId, const QByteArray &propertyName, const QByteArray &propertyType) | - | ||||||||||||||||||
| 84 | { | - | ||||||||||||||||||
| 85 | builder->addSignal("__" + QByteArray::number(propertyId) + "()"); | - | ||||||||||||||||||
| 86 | QMetaPropertyBuilder property = builder->addProperty( | - | ||||||||||||||||||
| 87 | propertyName, propertyType, propertyId); | - | ||||||||||||||||||
| 88 | property.setWritable(true); | - | ||||||||||||||||||
| 89 | } executed 26940 times by 12 tests: end of blockExecuted by:
| 26940 | ||||||||||||||||||
| 90 | - | |||||||||||||||||||
| 91 | class VDMModelDelegateDataType; | - | ||||||||||||||||||
| 92 | - | |||||||||||||||||||
| 93 | class QQmlDMCachedModelData : public QQmlDelegateModelItem | - | ||||||||||||||||||
| 94 | { | - | ||||||||||||||||||
| 95 | public: | - | ||||||||||||||||||
| 96 | QQmlDMCachedModelData( | - | ||||||||||||||||||
| 97 | QQmlDelegateModelItemMetaType *metaType, | - | ||||||||||||||||||
| 98 | VDMModelDelegateDataType *dataType, | - | ||||||||||||||||||
| 99 | int index); | - | ||||||||||||||||||
| 100 | - | |||||||||||||||||||
| 101 | int metaCall(QMetaObject::Call call, int id, void **arguments); | - | ||||||||||||||||||
| 102 | - | |||||||||||||||||||
| 103 | virtual QVariant value(int role) const = 0; | - | ||||||||||||||||||
| 104 | virtual void setValue(int role, const QVariant &value) = 0; | - | ||||||||||||||||||
| 105 | - | |||||||||||||||||||
| 106 | void setValue(const QString &role, const QVariant &value) override; | - | ||||||||||||||||||
| 107 | bool resolveIndex(const QQmlAdaptorModel &model, int idx) override; | - | ||||||||||||||||||
| 108 | - | |||||||||||||||||||
| 109 | static QV4::ReturnedValue get_property(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); | - | ||||||||||||||||||
| 110 | static QV4::ReturnedValue set_property(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); | - | ||||||||||||||||||
| 111 | - | |||||||||||||||||||
| 112 | VDMModelDelegateDataType *type; | - | ||||||||||||||||||
| 113 | QVector<QVariant> cachedData; | - | ||||||||||||||||||
| 114 | }; | - | ||||||||||||||||||
| 115 | - | |||||||||||||||||||
| 116 | class VDMModelDelegateDataType | - | ||||||||||||||||||
| 117 | : public QQmlRefCount | - | ||||||||||||||||||
| 118 | , public QQmlAdaptorModel::Accessors | - | ||||||||||||||||||
| 119 | , public QAbstractDynamicMetaObject | - | ||||||||||||||||||
| 120 | { | - | ||||||||||||||||||
| 121 | public: | - | ||||||||||||||||||
| 122 | VDMModelDelegateDataType(QQmlAdaptorModel *model) | - | ||||||||||||||||||
| 123 | : model(model) | - | ||||||||||||||||||
| 124 | , metaObject(nullptr) | - | ||||||||||||||||||
| 125 | , propertyCache(nullptr) | - | ||||||||||||||||||
| 126 | , propertyOffset(0) | - | ||||||||||||||||||
| 127 | , signalOffset(0) | - | ||||||||||||||||||
| 128 | , hasModelData(false) | - | ||||||||||||||||||
| 129 | { | - | ||||||||||||||||||
| 130 | } executed 4156 times by 12 tests: end of blockExecuted by:
| 4156 | ||||||||||||||||||
| 131 | - | |||||||||||||||||||
| 132 | ~VDMModelDelegateDataType() | - | ||||||||||||||||||
| 133 | { | - | ||||||||||||||||||
| 134 | if (propertyCache)
| 210-3930 | ||||||||||||||||||
| 135 | propertyCache->release(); executed 3930 times by 11 tests: propertyCache->release();Executed by:
| 3930 | ||||||||||||||||||
| 136 | free(metaObject); | - | ||||||||||||||||||
| 137 | } executed 4140 times by 11 tests: end of blockExecuted by:
| 4140 | ||||||||||||||||||
| 138 | - | |||||||||||||||||||
| 139 | bool notify( | - | ||||||||||||||||||
| 140 | const QQmlAdaptorModel &, | - | ||||||||||||||||||
| 141 | const QList<QQmlDelegateModelItem *> &items, | - | ||||||||||||||||||
| 142 | int index, | - | ||||||||||||||||||
| 143 | int count, | - | ||||||||||||||||||
| 144 | const QVector<int> &roles) const override | - | ||||||||||||||||||
| 145 | { | - | ||||||||||||||||||
| 146 | bool changed = roles.isEmpty() && !watchedRoles.isEmpty();
| 32-450 | ||||||||||||||||||
| 147 | if (!changed && !watchedRoles.isEmpty() && watchedRoleIds.isEmpty()) {
| 6-418 | ||||||||||||||||||
| 148 | QList<int> roleIds; | - | ||||||||||||||||||
| 149 | for (const QByteArray &r : watchedRoles) { | - | ||||||||||||||||||
| 150 | QHash<QByteArray, int>::const_iterator it = roleNames.find(r); | - | ||||||||||||||||||
| 151 | if (it != roleNames.end())
| 4-8 | ||||||||||||||||||
| 152 | roleIds << it.value(); executed 8 times by 1 test: roleIds << it.value();Executed by:
| 8 | ||||||||||||||||||
| 153 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||||||||||||||
| 154 | const_cast<VDMModelDelegateDataType *>(this)->watchedRoleIds = roleIds; | - | ||||||||||||||||||
| 155 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||
| 156 | - | |||||||||||||||||||
| 157 | QVector<int> signalIndexes; | - | ||||||||||||||||||
| 158 | for (int i = 0; i < roles.count(); ++i) {
| 52-494 | ||||||||||||||||||
| 159 | const int role = roles.at(i); | - | ||||||||||||||||||
| 160 | if (!changed && watchedRoleIds.contains(role))
| 0-52 | ||||||||||||||||||
| 161 | changed = true; executed 8 times by 1 test: changed = true;Executed by:
| 8 | ||||||||||||||||||
| 162 | - | |||||||||||||||||||
| 163 | int propertyId = propertyRoles.indexOf(role); | - | ||||||||||||||||||
| 164 | if (propertyId != -1)
| 0-52 | ||||||||||||||||||
| 165 | signalIndexes.append(propertyId + signalOffset); executed 52 times by 4 tests: signalIndexes.append(propertyId + signalOffset);Executed by:
| 52 | ||||||||||||||||||
| 166 | } executed 52 times by 4 tests: end of blockExecuted by:
| 52 | ||||||||||||||||||
| 167 | if (roles.isEmpty()) {
| 44-450 | ||||||||||||||||||
| 168 | const int propertyRolesCount = propertyRoles.count(); | - | ||||||||||||||||||
| 169 | signalIndexes.reserve(propertyRolesCount); | - | ||||||||||||||||||
| 170 | for (int propertyId = 0; propertyId < propertyRolesCount; ++propertyId)
| 450-3134 | ||||||||||||||||||
| 171 | signalIndexes.append(propertyId + signalOffset); executed 3134 times by 4 tests: signalIndexes.append(propertyId + signalOffset);Executed by:
| 3134 | ||||||||||||||||||
| 172 | } executed 450 times by 4 tests: end of blockExecuted by:
| 450 | ||||||||||||||||||
| 173 | - | |||||||||||||||||||
| 174 | for (int i = 0, c = items.count(); i < c; ++i) {
| 494-4646 | ||||||||||||||||||
| 175 | QQmlDelegateModelItem *item = items.at(i); | - | ||||||||||||||||||
| 176 | const int idx = item->modelIndex(); | - | ||||||||||||||||||
| 177 | if (idx >= index && idx < index + count) {
| 1253-3393 | ||||||||||||||||||
| 178 | for (int i = 0; i < signalIndexes.count(); ++i)
| 1952-13502 | ||||||||||||||||||
| 179 | QMetaObject::activate(item, signalIndexes.at(i), nullptr); executed 13502 times by 5 tests: QMetaObject::activate(item, signalIndexes.at(i), nullptr);Executed by:
| 13502 | ||||||||||||||||||
| 180 | } executed 1952 times by 5 tests: end of blockExecuted by:
| 1952 | ||||||||||||||||||
| 181 | } executed 4646 times by 5 tests: end of blockExecuted by:
| 4646 | ||||||||||||||||||
| 182 | return changed; executed 494 times by 5 tests: return changed;Executed by:
| 494 | ||||||||||||||||||
| 183 | } | - | ||||||||||||||||||
| 184 | - | |||||||||||||||||||
| 185 | void replaceWatchedRoles( | - | ||||||||||||||||||
| 186 | QQmlAdaptorModel &, | - | ||||||||||||||||||
| 187 | const QList<QByteArray> &oldRoles, | - | ||||||||||||||||||
| 188 | const QList<QByteArray> &newRoles) const override | - | ||||||||||||||||||
| 189 | { | - | ||||||||||||||||||
| 190 | VDMModelDelegateDataType *dataType = const_cast<VDMModelDelegateDataType *>(this); | - | ||||||||||||||||||
| 191 | - | |||||||||||||||||||
| 192 | dataType->watchedRoleIds.clear(); | - | ||||||||||||||||||
| 193 | for (const QByteArray &oldRole : oldRoles) | - | ||||||||||||||||||
| 194 | dataType->watchedRoles.removeOne(oldRole); executed 24 times by 2 tests: dataType->watchedRoles.removeOne(oldRole);Executed by:
| 24 | ||||||||||||||||||
| 195 | dataType->watchedRoles += newRoles; | - | ||||||||||||||||||
| 196 | } executed 6002 times by 12 tests: end of blockExecuted by:
| 6002 | ||||||||||||||||||
| 197 | - | |||||||||||||||||||
| 198 | static QV4::ReturnedValue get_hasModelChildren(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) | - | ||||||||||||||||||
| 199 | { | - | ||||||||||||||||||
| 200 | QV4::Scope scope(b); | - | ||||||||||||||||||
| 201 | QV4::Scoped<QQmlDelegateModelItemObject> o(scope, thisObject->as<QQmlDelegateModelItemObject>()); | - | ||||||||||||||||||
| 202 | if (!o)
| 0-8 | ||||||||||||||||||
| 203 | RETURN_RESULT(scope.engine->throwTypeError(QStringLiteral("Not a valid VisualData object"))); never executed: return QV4::Encode(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 | ||||||||||||||||||
| 204 | - | |||||||||||||||||||
| 205 | const QQmlAdaptorModel *const model = static_cast<QQmlDMCachedModelData *>(o->d()->item)->type->model; | - | ||||||||||||||||||
| 206 | if (o->d()->item->index >= 0 && *model) {
| 0-8 | ||||||||||||||||||
| 207 | const QAbstractItemModel * const aim = model->aim(); | - | ||||||||||||||||||
| 208 | RETURN_RESULT(QV4::Encode(aim->hasChildren(aim->index(o->d()->item->index, 0, model->rootIndex)))); executed 8 times by 1 test: return QV4::Encode(QV4::Encode(aim->hasChildren(aim->index(o->d()->item->index, 0, model->rootIndex))));Executed by:
| 8 | ||||||||||||||||||
| 209 | } else { | - | ||||||||||||||||||
| 210 | RETURN_RESULT(QV4::Encode(false)); never executed: return QV4::Encode(QV4::Encode(false)); | 0 | ||||||||||||||||||
| 211 | } | - | ||||||||||||||||||
| 212 | } | - | ||||||||||||||||||
| 213 | - | |||||||||||||||||||
| 214 | - | |||||||||||||||||||
| 215 | void initializeConstructor(QQmlAdaptorModelEngineData *const data) | - | ||||||||||||||||||
| 216 | { | - | ||||||||||||||||||
| 217 | QV4::ExecutionEngine *v4 = data->v4; | - | ||||||||||||||||||
| 218 | QV4::Scope scope(v4); | - | ||||||||||||||||||
| 219 | QV4::ScopedObject proto(scope, v4->newObject()); | - | ||||||||||||||||||
| 220 | proto->defineAccessorProperty(QStringLiteral("index"), get_index, nullptr); executed 362 times by 2 tests: return qstring_literal_temp;Executed by:
| 362 | ||||||||||||||||||
| 221 | proto->defineAccessorProperty(QStringLiteral("hasModelChildren"), get_hasModelChildren, nullptr); executed 362 times by 2 tests: return qstring_literal_temp;Executed by:
| 362 | ||||||||||||||||||
| 222 | QV4::ScopedProperty p(scope); | - | ||||||||||||||||||
| 223 | - | |||||||||||||||||||
| 224 | typedef QHash<QByteArray, int>::const_iterator iterator; | - | ||||||||||||||||||
| 225 | for (iterator it = roleNames.constBegin(), end = roleNames.constEnd(); it != end; ++it) {
| 362-936 | ||||||||||||||||||
| 226 | const int propertyId = propertyRoles.indexOf(it.value()); | - | ||||||||||||||||||
| 227 | const QByteArray &propertyName = it.key(); | - | ||||||||||||||||||
| 228 | - | |||||||||||||||||||
| 229 | QV4::ScopedString name(scope, v4->newString(QString::fromUtf8(propertyName))); | - | ||||||||||||||||||
| 230 | QV4::ExecutionContext *global = v4->rootContext(); | - | ||||||||||||||||||
| 231 | QV4::ScopedFunctionObject g(scope, v4->memoryManager->allocate<QV4::IndexedBuiltinFunction>(global, propertyId, QQmlDMCachedModelData::get_property)); | - | ||||||||||||||||||
| 232 | QV4::ScopedFunctionObject s(scope, v4->memoryManager->allocate<QV4::IndexedBuiltinFunction>(global, propertyId, QQmlDMCachedModelData::set_property)); | - | ||||||||||||||||||
| 233 | p->setGetter(g); | - | ||||||||||||||||||
| 234 | p->setSetter(s); | - | ||||||||||||||||||
| 235 | proto->insertMember(name, p, QV4::Attr_Accessor|QV4::Attr_NotEnumerable|QV4::Attr_NotConfigurable); | - | ||||||||||||||||||
| 236 | } executed 936 times by 2 tests: end of blockExecuted by:
| 936 | ||||||||||||||||||
| 237 | prototype.set(v4, proto); | - | ||||||||||||||||||
| 238 | } executed 362 times by 2 tests: end of blockExecuted by:
| 362 | ||||||||||||||||||
| 239 | - | |||||||||||||||||||
| 240 | // QAbstractDynamicMetaObject | - | ||||||||||||||||||
| 241 | - | |||||||||||||||||||
| 242 | void objectDestroyed(QObject *) override | - | ||||||||||||||||||
| 243 | { | - | ||||||||||||||||||
| 244 | release(); | - | ||||||||||||||||||
| 245 | } executed 77952 times by 12 tests: end of blockExecuted by:
| 77952 | ||||||||||||||||||
| 246 | - | |||||||||||||||||||
| 247 | int metaCall(QObject *object, QMetaObject::Call call, int id, void **arguments) override | - | ||||||||||||||||||
| 248 | { | - | ||||||||||||||||||
| 249 | return static_cast<QQmlDMCachedModelData *>(object)->metaCall(call, id, arguments); executed 234595 times by 11 tests: return static_cast<QQmlDMCachedModelData *>(object)->metaCall(call, id, arguments);Executed by:
| 234595 | ||||||||||||||||||
| 250 | } | - | ||||||||||||||||||
| 251 | - | |||||||||||||||||||
| 252 | QV4::PersistentValue prototype; | - | ||||||||||||||||||
| 253 | QList<int> propertyRoles; | - | ||||||||||||||||||
| 254 | QList<int> watchedRoleIds; | - | ||||||||||||||||||
| 255 | QList<QByteArray> watchedRoles; | - | ||||||||||||||||||
| 256 | QHash<QByteArray, int> roleNames; | - | ||||||||||||||||||
| 257 | QQmlAdaptorModel *model; | - | ||||||||||||||||||
| 258 | QMetaObject *metaObject; | - | ||||||||||||||||||
| 259 | QQmlPropertyCache *propertyCache; | - | ||||||||||||||||||
| 260 | int propertyOffset; | - | ||||||||||||||||||
| 261 | int signalOffset; | - | ||||||||||||||||||
| 262 | bool hasModelData; | - | ||||||||||||||||||
| 263 | }; | - | ||||||||||||||||||
| 264 | - | |||||||||||||||||||
| 265 | QQmlDMCachedModelData::QQmlDMCachedModelData( | - | ||||||||||||||||||
| 266 | QQmlDelegateModelItemMetaType *metaType, VDMModelDelegateDataType *dataType, int index) | - | ||||||||||||||||||
| 267 | : QQmlDelegateModelItem(metaType, index) | - | ||||||||||||||||||
| 268 | , type(dataType) | - | ||||||||||||||||||
| 269 | { | - | ||||||||||||||||||
| 270 | if (index == -1)
| 360-77626 | ||||||||||||||||||
| 271 | cachedData.resize(type->hasModelData ? 1 : type->propertyRoles.count()); executed 360 times by 1 test: cachedData.resize(type->hasModelData ? 1 : type->propertyRoles.count());Executed by:
| 360 | ||||||||||||||||||
| 272 | - | |||||||||||||||||||
| 273 | QObjectPrivate::get(this)->metaObject = type; | - | ||||||||||||||||||
| 274 | - | |||||||||||||||||||
| 275 | type->addref(); | - | ||||||||||||||||||
| 276 | - | |||||||||||||||||||
| 277 | QQmlData *qmldata = QQmlData::get(this, true); | - | ||||||||||||||||||
| 278 | qmldata->propertyCache = dataType->propertyCache; | - | ||||||||||||||||||
| 279 | qmldata->propertyCache->addref(); | - | ||||||||||||||||||
| 280 | } executed 77986 times by 12 tests: end of blockExecuted by:
| 77986 | ||||||||||||||||||
| 281 | - | |||||||||||||||||||
| 282 | int QQmlDMCachedModelData::metaCall(QMetaObject::Call call, int id, void **arguments) | - | ||||||||||||||||||
| 283 | { | - | ||||||||||||||||||
| 284 | if (call == QMetaObject::ReadProperty && id >= type->propertyOffset) {
| 0-234549 | ||||||||||||||||||
| 285 | const int propertyIndex = id - type->propertyOffset; | - | ||||||||||||||||||
| 286 | if (index == -1) {
| 1400-233149 | ||||||||||||||||||
| 287 | if (!cachedData.isEmpty()) {
| 0-1400 | ||||||||||||||||||
| 288 | *static_cast<QVariant *>(arguments[0]) = cachedData.at( | - | ||||||||||||||||||
| 289 | type->hasModelData ? 0 : propertyIndex); | - | ||||||||||||||||||
| 290 | } executed 1400 times by 1 test: end of blockExecuted by:
| 1400 | ||||||||||||||||||
| 291 | } else if (*type->model) { executed 1400 times by 1 test: end of blockExecuted by:
| 0-233149 | ||||||||||||||||||
| 292 | *static_cast<QVariant *>(arguments[0]) = value(type->propertyRoles.at(propertyIndex)); | - | ||||||||||||||||||
| 293 | } executed 233149 times by 11 tests: end of blockExecuted by:
| 233149 | ||||||||||||||||||
| 294 | return -1; executed 234549 times by 11 tests: return -1;Executed by:
| 234549 | ||||||||||||||||||
| 295 | } else if (call == QMetaObject::WriteProperty && id >= type->propertyOffset) {
| 0-46 | ||||||||||||||||||
| 296 | const int propertyIndex = id - type->propertyOffset; | - | ||||||||||||||||||
| 297 | if (index == -1) {
| 6-40 | ||||||||||||||||||
| 298 | const QMetaObject *meta = metaObject(); | - | ||||||||||||||||||
| 299 | if (cachedData.count() > 1) {
| 8-32 | ||||||||||||||||||
| 300 | cachedData[propertyIndex] = *static_cast<QVariant *>(arguments[0]); | - | ||||||||||||||||||
| 301 | QMetaObject::activate(this, meta, propertyIndex, nullptr); | - | ||||||||||||||||||
| 302 | } else if (cachedData.count() == 1) { executed 8 times by 1 test: end of blockExecuted by:
| 0-32 | ||||||||||||||||||
| 303 | cachedData[0] = *static_cast<QVariant *>(arguments[0]); | - | ||||||||||||||||||
| 304 | QMetaObject::activate(this, meta, 0, nullptr); | - | ||||||||||||||||||
| 305 | QMetaObject::activate(this, meta, 1, nullptr); | - | ||||||||||||||||||
| 306 | } executed 32 times by 1 test: end of blockExecuted by:
| 32 | ||||||||||||||||||
| 307 | } else if (*type->model) { executed 40 times by 1 test: end of blockExecuted by:
| 0-40 | ||||||||||||||||||
| 308 | setValue(type->propertyRoles.at(propertyIndex), *static_cast<QVariant *>(arguments[0])); | - | ||||||||||||||||||
| 309 | } executed 6 times by 2 tests: end of blockExecuted by:
| 6 | ||||||||||||||||||
| 310 | return -1; executed 46 times by 2 tests: return -1;Executed by:
| 46 | ||||||||||||||||||
| 311 | } else { | - | ||||||||||||||||||
| 312 | return qt_metacall(call, id, arguments); never executed: return qt_metacall(call, id, arguments); | 0 | ||||||||||||||||||
| 313 | } | - | ||||||||||||||||||
| 314 | } | - | ||||||||||||||||||
| 315 | - | |||||||||||||||||||
| 316 | void QQmlDMCachedModelData::setValue(const QString &role, const QVariant &value) | - | ||||||||||||||||||
| 317 | { | - | ||||||||||||||||||
| 318 | QHash<QByteArray, int>::iterator it = type->roleNames.find(role.toUtf8()); | - | ||||||||||||||||||
| 319 | if (it != type->roleNames.end()) {
| 8-352 | ||||||||||||||||||
| 320 | for (int i = 0; i < type->propertyRoles.count(); ++i) {
| 0-440 | ||||||||||||||||||
| 321 | if (type->propertyRoles.at(i) == *it) {
| 88-352 | ||||||||||||||||||
| 322 | cachedData[i] = value; | - | ||||||||||||||||||
| 323 | return; executed 352 times by 1 test: return;Executed by:
| 352 | ||||||||||||||||||
| 324 | } | - | ||||||||||||||||||
| 325 | } executed 88 times by 1 test: end of blockExecuted by:
| 88 | ||||||||||||||||||
| 326 | } never executed: end of block | 0 | ||||||||||||||||||
| 327 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||
| 328 | - | |||||||||||||||||||
| 329 | bool QQmlDMCachedModelData::resolveIndex(const QQmlAdaptorModel &, int idx) | - | ||||||||||||||||||
| 330 | { | - | ||||||||||||||||||
| 331 | if (index == -1) {
| 0-120 | ||||||||||||||||||
| 332 | Q_ASSERT(idx >= 0); | - | ||||||||||||||||||
| 333 | cachedData.clear(); | - | ||||||||||||||||||
| 334 | setModelIndex(idx); | - | ||||||||||||||||||
| 335 | const QMetaObject *meta = metaObject(); | - | ||||||||||||||||||
| 336 | const int propertyCount = type->propertyRoles.count(); | - | ||||||||||||||||||
| 337 | for (int i = 0; i < propertyCount; ++i)
| 120-288 | ||||||||||||||||||
| 338 | QMetaObject::activate(this, meta, i, nullptr); executed 288 times by 1 test: QMetaObject::activate(this, meta, i, nullptr);Executed by:
| 288 | ||||||||||||||||||
| 339 | return true; executed 120 times by 1 test: return true;Executed by:
| 120 | ||||||||||||||||||
| 340 | } else { | - | ||||||||||||||||||
| 341 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 342 | } | - | ||||||||||||||||||
| 343 | } | - | ||||||||||||||||||
| 344 | - | |||||||||||||||||||
| 345 | QV4::ReturnedValue QQmlDMCachedModelData::get_property(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) | - | ||||||||||||||||||
| 346 | { | - | ||||||||||||||||||
| 347 | QV4::Scope scope(b); | - | ||||||||||||||||||
| 348 | QV4::Scoped<QQmlDelegateModelItemObject> o(scope, thisObject->as<QQmlDelegateModelItemObject>()); | - | ||||||||||||||||||
| 349 | if (!o)
| 0-2588 | ||||||||||||||||||
| 350 | 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 | ||||||||||||||||||
| 351 | - | |||||||||||||||||||
| 352 | uint propertyId = static_cast<const QV4::IndexedBuiltinFunction *>(b)->d()->index; | - | ||||||||||||||||||
| 353 | - | |||||||||||||||||||
| 354 | QQmlDMCachedModelData *modelData = static_cast<QQmlDMCachedModelData *>(o->d()->item); | - | ||||||||||||||||||
| 355 | if (o->d()->item->index == -1) {
| 236-2352 | ||||||||||||||||||
| 356 | if (!modelData->cachedData.isEmpty()) {
| 0-236 | ||||||||||||||||||
| 357 | return scope.engine->fromVariant( executed 236 times by 1 test: return scope.engine->fromVariant( modelData->cachedData.at(modelData->type->hasModelData ? 0 : propertyId));Executed by:
| 236 | ||||||||||||||||||
| 358 | modelData->cachedData.at(modelData->type->hasModelData ? 0 : propertyId)); executed 236 times by 1 test: return scope.engine->fromVariant( modelData->cachedData.at(modelData->type->hasModelData ? 0 : propertyId));Executed by:
| 236 | ||||||||||||||||||
| 359 | } | - | ||||||||||||||||||
| 360 | } else if (*modelData->type->model) { never executed: end of block
| 0-2352 | ||||||||||||||||||
| 361 | return scope.engine->fromVariant( executed 2352 times by 2 tests: return scope.engine->fromVariant( modelData->value(modelData->type->propertyRoles.at(propertyId)));Executed by:
| 2352 | ||||||||||||||||||
| 362 | modelData->value(modelData->type->propertyRoles.at(propertyId))); executed 2352 times by 2 tests: return scope.engine->fromVariant( modelData->value(modelData->type->propertyRoles.at(propertyId)));Executed by:
| 2352 | ||||||||||||||||||
| 363 | } | - | ||||||||||||||||||
| 364 | return QV4::Encode::undefined(); never executed: return QV4::Encode::undefined(); | 0 | ||||||||||||||||||
| 365 | } | - | ||||||||||||||||||
| 366 | - | |||||||||||||||||||
| 367 | QV4::ReturnedValue QQmlDMCachedModelData::set_property(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) | - | ||||||||||||||||||
| 368 | { | - | ||||||||||||||||||
| 369 | QV4::Scope scope(b); | - | ||||||||||||||||||
| 370 | QV4::Scoped<QQmlDelegateModelItemObject> o(scope, thisObject->as<QQmlDelegateModelItemObject>()); | - | ||||||||||||||||||
| 371 | if (!o)
| 0-32 | ||||||||||||||||||
| 372 | 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 | ||||||||||||||||||
| 373 | if (!argc)
| 0-32 | ||||||||||||||||||
| 374 | return scope.engine->throwTypeError(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||
| 375 | - | |||||||||||||||||||
| 376 | uint propertyId = static_cast<const QV4::IndexedBuiltinFunction *>(b)->d()->index; | - | ||||||||||||||||||
| 377 | - | |||||||||||||||||||
| 378 | if (o->d()->item->index == -1) {
| 12-20 | ||||||||||||||||||
| 379 | QQmlDMCachedModelData *modelData = static_cast<QQmlDMCachedModelData *>(o->d()->item); | - | ||||||||||||||||||
| 380 | if (!modelData->cachedData.isEmpty()) {
| 0-20 | ||||||||||||||||||
| 381 | if (modelData->cachedData.count() > 1) {
| 4-16 | ||||||||||||||||||
| 382 | modelData->cachedData[propertyId] = scope.engine->toVariant(argv[0], QVariant::Invalid); | - | ||||||||||||||||||
| 383 | QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), propertyId, nullptr); | - | ||||||||||||||||||
| 384 | } else if (modelData->cachedData.count() == 1) { executed 4 times by 1 test: end of blockExecuted by:
| 0-16 | ||||||||||||||||||
| 385 | modelData->cachedData[0] = scope.engine->toVariant(argv[0], QVariant::Invalid); | - | ||||||||||||||||||
| 386 | QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), 0, nullptr); | - | ||||||||||||||||||
| 387 | QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), 1, nullptr); | - | ||||||||||||||||||
| 388 | } executed 16 times by 1 test: end of blockExecuted by:
| 16 | ||||||||||||||||||
| 389 | } executed 20 times by 1 test: end of blockExecuted by:
| 20 | ||||||||||||||||||
| 390 | } executed 20 times by 1 test: end of blockExecuted by:
| 20 | ||||||||||||||||||
| 391 | return QV4::Encode::undefined(); executed 32 times by 1 test: return QV4::Encode::undefined();Executed by:
| 32 | ||||||||||||||||||
| 392 | } | - | ||||||||||||||||||
| 393 | - | |||||||||||||||||||
| 394 | //----------------------------------------------------------------- | - | ||||||||||||||||||
| 395 | // QAbstractItemModel | - | ||||||||||||||||||
| 396 | //----------------------------------------------------------------- | - | ||||||||||||||||||
| 397 | - | |||||||||||||||||||
| 398 | class QQmlDMAbstractItemModelData : public QQmlDMCachedModelData | - | ||||||||||||||||||
| 399 | { | - | ||||||||||||||||||
| 400 | Q_OBJECT | - | ||||||||||||||||||
| 401 | Q_PROPERTY(bool hasModelChildren READ hasModelChildren CONSTANT) | - | ||||||||||||||||||
| 402 | - | |||||||||||||||||||
| 403 | public: | - | ||||||||||||||||||
| 404 | QQmlDMAbstractItemModelData( | - | ||||||||||||||||||
| 405 | QQmlDelegateModelItemMetaType *metaType, | - | ||||||||||||||||||
| 406 | VDMModelDelegateDataType *dataType, | - | ||||||||||||||||||
| 407 | int index) | - | ||||||||||||||||||
| 408 | : QQmlDMCachedModelData(metaType, dataType, index) | - | ||||||||||||||||||
| 409 | { | - | ||||||||||||||||||
| 410 | } executed 77986 times by 12 tests: end of blockExecuted by:
| 77986 | ||||||||||||||||||
| 411 | - | |||||||||||||||||||
| 412 | bool hasModelChildren() const | - | ||||||||||||||||||
| 413 | { | - | ||||||||||||||||||
| 414 | if (index >= 0 && *type->model) {
| 0-34 | ||||||||||||||||||
| 415 | const QAbstractItemModel * const model = type->model->aim(); | - | ||||||||||||||||||
| 416 | return model->hasChildren(model->index(row, column, type->model->rootIndex)); executed 34 times by 1 test: return model->hasChildren(model->index(row, column, type->model->rootIndex));Executed by:
| 34 | ||||||||||||||||||
| 417 | } else { | - | ||||||||||||||||||
| 418 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 419 | } | - | ||||||||||||||||||
| 420 | } | - | ||||||||||||||||||
| 421 | - | |||||||||||||||||||
| 422 | QVariant value(int role) const override | - | ||||||||||||||||||
| 423 | { | - | ||||||||||||||||||
| 424 | return type->model->aim()->index(row, column, type->model->rootIndex).data(role); executed 235501 times by 11 tests: return type->model->aim()->index(row, column, type->model->rootIndex).data(role);Executed by:
| 235501 | ||||||||||||||||||
| 425 | } | - | ||||||||||||||||||
| 426 | - | |||||||||||||||||||
| 427 | void setValue(int role, const QVariant &value) override | - | ||||||||||||||||||
| 428 | { | - | ||||||||||||||||||
| 429 | type->model->aim()->setData( | - | ||||||||||||||||||
| 430 | type->model->aim()->index(row, column, type->model->rootIndex), value, role); | - | ||||||||||||||||||
| 431 | } executed 6 times by 2 tests: end of blockExecuted by:
| 6 | ||||||||||||||||||
| 432 | - | |||||||||||||||||||
| 433 | QV4::ReturnedValue get() override | - | ||||||||||||||||||
| 434 | { | - | ||||||||||||||||||
| 435 | if (type->prototype.isUndefined()) {
| 362-4394 | ||||||||||||||||||
| 436 | QQmlAdaptorModelEngineData * const data = engineData(v4); | - | ||||||||||||||||||
| 437 | type->initializeConstructor(data); | - | ||||||||||||||||||
| 438 | } executed 362 times by 2 tests: end of blockExecuted by:
| 362 | ||||||||||||||||||
| 439 | QV4::Scope scope(v4); | - | ||||||||||||||||||
| 440 | QV4::ScopedObject proto(scope, type->prototype.value()); | - | ||||||||||||||||||
| 441 | QV4::ScopedObject o(scope, proto->engine()->memoryManager->allocate<QQmlDelegateModelItemObject>(this)); | - | ||||||||||||||||||
| 442 | o->setPrototypeOf(proto); | - | ||||||||||||||||||
| 443 | ++scriptRef; | - | ||||||||||||||||||
| 444 | return o.asReturnedValue(); executed 4756 times by 2 tests: return o.asReturnedValue();Executed by:
| 4756 | ||||||||||||||||||
| 445 | } | - | ||||||||||||||||||
| 446 | }; | - | ||||||||||||||||||
| 447 | - | |||||||||||||||||||
| 448 | class VDMAbstractItemModelDataType : public VDMModelDelegateDataType | - | ||||||||||||||||||
| 449 | { | - | ||||||||||||||||||
| 450 | public: | - | ||||||||||||||||||
| 451 | VDMAbstractItemModelDataType(QQmlAdaptorModel *model) | - | ||||||||||||||||||
| 452 | : VDMModelDelegateDataType(model) | - | ||||||||||||||||||
| 453 | { | - | ||||||||||||||||||
| 454 | } executed 4156 times by 12 tests: end of blockExecuted by:
| 4156 | ||||||||||||||||||
| 455 | - | |||||||||||||||||||
| 456 | int rowCount(const QQmlAdaptorModel &model) const override | - | ||||||||||||||||||
| 457 | { | - | ||||||||||||||||||
| 458 | return model.aim()->rowCount(model.rootIndex); executed 259434 times by 12 tests: return model.aim()->rowCount(model.rootIndex);Executed by:
| 259434 | ||||||||||||||||||
| 459 | } | - | ||||||||||||||||||
| 460 | - | |||||||||||||||||||
| 461 | int columnCount(const QQmlAdaptorModel &model) const override | - | ||||||||||||||||||
| 462 | { | - | ||||||||||||||||||
| 463 | return model.aim()->columnCount(model.rootIndex); never executed: return model.aim()->columnCount(model.rootIndex); | 0 | ||||||||||||||||||
| 464 | } | - | ||||||||||||||||||
| 465 | - | |||||||||||||||||||
| 466 | void cleanup(QQmlAdaptorModel &model, QQmlDelegateModel *vdm) const override | - | ||||||||||||||||||
| 467 | { | - | ||||||||||||||||||
| 468 | QAbstractItemModel * const aim = model.aim(); | - | ||||||||||||||||||
| 469 | if (aim && vdm) {
| 0-4080 | ||||||||||||||||||
| 470 | QObject::disconnect(aim, SIGNAL(rowsInserted(QModelIndex,int,int)), | - | ||||||||||||||||||
| 471 | vdm, SLOT(_q_rowsInserted(QModelIndex,int,int))); | - | ||||||||||||||||||
| 472 | QObject::disconnect(aim, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), | - | ||||||||||||||||||
| 473 | vdm, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int))); | - | ||||||||||||||||||
| 474 | QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)), | - | ||||||||||||||||||
| 475 | vdm, SLOT(_q_rowsRemoved(QModelIndex,int,int))); | - | ||||||||||||||||||
| 476 | QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)), | - | ||||||||||||||||||
| 477 | vdm, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>))); | - | ||||||||||||||||||
| 478 | QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), | - | ||||||||||||||||||
| 479 | vdm, SLOT(_q_rowsMoved(QModelIndex,int,int,QModelIndex,int))); | - | ||||||||||||||||||
| 480 | QObject::disconnect(aim, SIGNAL(modelReset()), | - | ||||||||||||||||||
| 481 | vdm, SLOT(_q_modelReset())); | - | ||||||||||||||||||
| 482 | QObject::disconnect(aim, SIGNAL(layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)), | - | ||||||||||||||||||
| 483 | vdm, SLOT(_q_layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint))); | - | ||||||||||||||||||
| 484 | } executed 70 times by 6 tests: end of blockExecuted by:
| 70 | ||||||||||||||||||
| 485 | - | |||||||||||||||||||
| 486 | const_cast<VDMAbstractItemModelDataType *>(this)->release(); | - | ||||||||||||||||||
| 487 | } executed 4150 times by 11 tests: end of blockExecuted by:
| 4150 | ||||||||||||||||||
| 488 | - | |||||||||||||||||||
| 489 | QVariant value(const QQmlAdaptorModel &model, int index, const QString &role) const override | - | ||||||||||||||||||
| 490 | { | - | ||||||||||||||||||
| 491 | QHash<QByteArray, int>::const_iterator it = roleNames.find(role.toUtf8()); | - | ||||||||||||||||||
| 492 | if (it != roleNames.end()) {
| 8-7278 | ||||||||||||||||||
| 493 | return model.aim()->index(model.rowAt(index), model.columnAt(index), model.rootIndex).data(*it); executed 7278 times by 3 tests: return model.aim()->index(model.rowAt(index), model.columnAt(index), model.rootIndex).data(*it);Executed by:
| 7278 | ||||||||||||||||||
| 494 | } else if (role == QLatin1String("hasModelChildren")) {
| 0-8 | ||||||||||||||||||
| 495 | return QVariant(model.aim()->hasChildren(model.aim()->index(model.rowAt(index), model.columnAt(index), model.rootIndex))); executed 8 times by 1 test: return QVariant(model.aim()->hasChildren(model.aim()->index(model.rowAt(index), model.columnAt(index), model.rootIndex)));Executed by:
| 8 | ||||||||||||||||||
| 496 | } else { | - | ||||||||||||||||||
| 497 | return QVariant(); never executed: return QVariant(); | 0 | ||||||||||||||||||
| 498 | } | - | ||||||||||||||||||
| 499 | } | - | ||||||||||||||||||
| 500 | - | |||||||||||||||||||
| 501 | QVariant parentModelIndex(const QQmlAdaptorModel &model) const override | - | ||||||||||||||||||
| 502 | { | - | ||||||||||||||||||
| 503 | return model executed 2 times by 1 test: return model ? QVariant::fromValue(model.aim()->parent(model.rootIndex)) : QVariant();Executed by:
| 2 | ||||||||||||||||||
| 504 | ? QVariant::fromValue(model.aim()->parent(model.rootIndex)) executed 2 times by 1 test: return model ? QVariant::fromValue(model.aim()->parent(model.rootIndex)) : QVariant();Executed by:
| 2 | ||||||||||||||||||
| 505 | : QVariant(); executed 2 times by 1 test: return model ? QVariant::fromValue(model.aim()->parent(model.rootIndex)) : QVariant();Executed by:
| 2 | ||||||||||||||||||
| 506 | } | - | ||||||||||||||||||
| 507 | - | |||||||||||||||||||
| 508 | QVariant modelIndex(const QQmlAdaptorModel &model, int index) const override | - | ||||||||||||||||||
| 509 | { | - | ||||||||||||||||||
| 510 | return model executed 6 times by 2 tests: return model ? QVariant::fromValue(model.aim()->index(model.rowAt(index), model.columnAt(index), model.rootIndex)) : QVariant();Executed by:
| 6 | ||||||||||||||||||
| 511 | ? QVariant::fromValue(model.aim()->index(model.rowAt(index), model.columnAt(index), model.rootIndex)) executed 6 times by 2 tests: return model ? QVariant::fromValue(model.aim()->index(model.rowAt(index), model.columnAt(index), model.rootIndex)) : QVariant();Executed by:
| 6 | ||||||||||||||||||
| 512 | : QVariant(); executed 6 times by 2 tests: return model ? QVariant::fromValue(model.aim()->index(model.rowAt(index), model.columnAt(index), model.rootIndex)) : QVariant();Executed by:
| 6 | ||||||||||||||||||
| 513 | } | - | ||||||||||||||||||
| 514 | - | |||||||||||||||||||
| 515 | bool canFetchMore(const QQmlAdaptorModel &model) const override | - | ||||||||||||||||||
| 516 | { | - | ||||||||||||||||||
| 517 | return model && model.aim()->canFetchMore(model.rootIndex); executed 11513 times by 12 tests: return model && model.aim()->canFetchMore(model.rootIndex);Executed by:
| 11513 | ||||||||||||||||||
| 518 | } | - | ||||||||||||||||||
| 519 | - | |||||||||||||||||||
| 520 | void fetchMore(QQmlAdaptorModel &model) const override | - | ||||||||||||||||||
| 521 | { | - | ||||||||||||||||||
| 522 | if (model)
| 0-18 | ||||||||||||||||||
| 523 | model.aim()->fetchMore(model.rootIndex); executed 18 times by 1 test: model.aim()->fetchMore(model.rootIndex);Executed by:
| 18 | ||||||||||||||||||
| 524 | } executed 18 times by 1 test: end of blockExecuted by:
| 18 | ||||||||||||||||||
| 525 | - | |||||||||||||||||||
| 526 | QQmlDelegateModelItem *createItem( | - | ||||||||||||||||||
| 527 | QQmlAdaptorModel &model, | - | ||||||||||||||||||
| 528 | QQmlDelegateModelItemMetaType *metaType, | - | ||||||||||||||||||
| 529 | int index) const override | - | ||||||||||||||||||
| 530 | { | - | ||||||||||||||||||
| 531 | VDMAbstractItemModelDataType *dataType = const_cast<VDMAbstractItemModelDataType *>(this); | - | ||||||||||||||||||
| 532 | if (!metaObject)
| 3946-74040 | ||||||||||||||||||
| 533 | dataType->initializeMetaType(model); executed 3946 times by 12 tests: dataType->initializeMetaType(model);Executed by:
| 3946 | ||||||||||||||||||
| 534 | return new QQmlDMAbstractItemModelData(metaType, dataType, index); executed 77986 times by 12 tests: return new QQmlDMAbstractItemModelData(metaType, dataType, index);Executed by:
| 77986 | ||||||||||||||||||
| 535 | } | - | ||||||||||||||||||
| 536 | - | |||||||||||||||||||
| 537 | void initializeMetaType(QQmlAdaptorModel &model) | - | ||||||||||||||||||
| 538 | { | - | ||||||||||||||||||
| 539 | QMetaObjectBuilder builder; | - | ||||||||||||||||||
| 540 | setModelDataType<QQmlDMAbstractItemModelData>(&builder, this); | - | ||||||||||||||||||
| 541 | - | |||||||||||||||||||
| 542 | const QByteArray propertyType = QByteArrayLiteral("QVariant"); executed 3946 times by 12 tests: return ba;Executed by:
| 3946 | ||||||||||||||||||
| 543 | const QHash<int, QByteArray> names = model.aim()->roleNames(); | - | ||||||||||||||||||
| 544 | for (QHash<int, QByteArray>::const_iterator it = names.begin(), cend = names.end(); it != cend; ++it) {
| 3946-26316 | ||||||||||||||||||
| 545 | const int propertyId = propertyRoles.count(); | - | ||||||||||||||||||
| 546 | propertyRoles.append(it.key()); | - | ||||||||||||||||||
| 547 | roleNames.insert(it.value(), it.key()); | - | ||||||||||||||||||
| 548 | addProperty(&builder, propertyId, it.value(), propertyType); | - | ||||||||||||||||||
| 549 | } executed 26316 times by 12 tests: end of blockExecuted by:
| 26316 | ||||||||||||||||||
| 550 | if (propertyRoles.count() == 1) {
| 624-3322 | ||||||||||||||||||
| 551 | hasModelData = true; | - | ||||||||||||||||||
| 552 | const int role = names.begin().key(); | - | ||||||||||||||||||
| 553 | const QByteArray propertyName = QByteArrayLiteral("modelData"); executed 624 times by 10 tests: return ba;Executed by:
| 624 | ||||||||||||||||||
| 554 | - | |||||||||||||||||||
| 555 | propertyRoles.append(role); | - | ||||||||||||||||||
| 556 | roleNames.insert(propertyName, role); | - | ||||||||||||||||||
| 557 | addProperty(&builder, 1, propertyName, propertyType); | - | ||||||||||||||||||
| 558 | } executed 624 times by 10 tests: end of blockExecuted by:
| 624 | ||||||||||||||||||
| 559 | - | |||||||||||||||||||
| 560 | metaObject = builder.toMetaObject(); | - | ||||||||||||||||||
| 561 | *static_cast<QMetaObject *>(this) = *metaObject; | - | ||||||||||||||||||
| 562 | propertyCache = new QQmlPropertyCache(metaObject); | - | ||||||||||||||||||
| 563 | } executed 3946 times by 12 tests: end of blockExecuted by:
| 3946 | ||||||||||||||||||
| 564 | }; | - | ||||||||||||||||||
| 565 | - | |||||||||||||||||||
| 566 | //----------------------------------------------------------------- | - | ||||||||||||||||||
| 567 | // QQmlListAccessor | - | ||||||||||||||||||
| 568 | //----------------------------------------------------------------- | - | ||||||||||||||||||
| 569 | - | |||||||||||||||||||
| 570 | class QQmlDMListAccessorData : public QQmlDelegateModelItem | - | ||||||||||||||||||
| 571 | { | - | ||||||||||||||||||
| 572 | Q_OBJECT | - | ||||||||||||||||||
| 573 | Q_PROPERTY(QVariant modelData READ modelData WRITE setModelData NOTIFY modelDataChanged) | - | ||||||||||||||||||
| 574 | public: | - | ||||||||||||||||||
| 575 | QQmlDMListAccessorData(QQmlDelegateModelItemMetaType *metaType, int index, const QVariant &value) | - | ||||||||||||||||||
| 576 | : QQmlDelegateModelItem(metaType, index) | - | ||||||||||||||||||
| 577 | , cachedData(value) | - | ||||||||||||||||||
| 578 | { | - | ||||||||||||||||||
| 579 | } executed 9985 times by 22 tests: end of blockExecuted by:
| 9985 | ||||||||||||||||||
| 580 | - | |||||||||||||||||||
| 581 | QVariant modelData() const | - | ||||||||||||||||||
| 582 | { | - | ||||||||||||||||||
| 583 | return cachedData; executed 5750 times by 7 tests: return cachedData;Executed by:
| 5750 | ||||||||||||||||||
| 584 | } | - | ||||||||||||||||||
| 585 | - | |||||||||||||||||||
| 586 | void setModelData(const QVariant &data) | - | ||||||||||||||||||
| 587 | { | - | ||||||||||||||||||
| 588 | if (index == -1 && data != cachedData) {
| 0-12 | ||||||||||||||||||
| 589 | cachedData = data; | - | ||||||||||||||||||
| 590 | emit modelDataChanged(); | - | ||||||||||||||||||
| 591 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||||||||||||||
| 592 | } executed 16 times by 1 test: end of blockExecuted by:
| 16 | ||||||||||||||||||
| 593 | - | |||||||||||||||||||
| 594 | static QV4::ReturnedValue get_modelData(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) | - | ||||||||||||||||||
| 595 | { | - | ||||||||||||||||||
| 596 | QV4::ExecutionEngine *v4 = b->engine(); | - | ||||||||||||||||||
| 597 | const QQmlDelegateModelItemObject *o = thisObject->as<QQmlDelegateModelItemObject>(); | - | ||||||||||||||||||
| 598 | if (!o)
| 0-208 | ||||||||||||||||||
| 599 | return v4->throwTypeError(QStringLiteral("Not a valid VisualData object")); never executed: return v4->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 | ||||||||||||||||||
| 600 | - | |||||||||||||||||||
| 601 | return v4->fromVariant(static_cast<QQmlDMListAccessorData *>(o->d()->item)->cachedData); executed 208 times by 1 test: return v4->fromVariant(static_cast<QQmlDMListAccessorData *>(o->d()->item)->cachedData);Executed by:
| 208 | ||||||||||||||||||
| 602 | } | - | ||||||||||||||||||
| 603 | - | |||||||||||||||||||
| 604 | static QV4::ReturnedValue set_modelData(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) | - | ||||||||||||||||||
| 605 | { | - | ||||||||||||||||||
| 606 | QV4::ExecutionEngine *v4 = b->engine(); | - | ||||||||||||||||||
| 607 | const QQmlDelegateModelItemObject *o = thisObject->as<QQmlDelegateModelItemObject>(); | - | ||||||||||||||||||
| 608 | if (!o)
| 0-8 | ||||||||||||||||||
| 609 | return v4->throwTypeError(QStringLiteral("Not a valid VisualData object")); never executed: return v4->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 | ||||||||||||||||||
| 610 | if (!argc)
| 0-8 | ||||||||||||||||||
| 611 | return v4->throwTypeError(); never executed: return v4->throwTypeError(); | 0 | ||||||||||||||||||
| 612 | - | |||||||||||||||||||
| 613 | static_cast<QQmlDMListAccessorData *>(o->d()->item)->setModelData(v4->toVariant(argv[0], QVariant::Invalid)); | - | ||||||||||||||||||
| 614 | return QV4::Encode::undefined(); executed 8 times by 1 test: return QV4::Encode::undefined();Executed by:
| 8 | ||||||||||||||||||
| 615 | } | - | ||||||||||||||||||
| 616 | - | |||||||||||||||||||
| 617 | QV4::ReturnedValue get() override | - | ||||||||||||||||||
| 618 | { | - | ||||||||||||||||||
| 619 | QQmlAdaptorModelEngineData *data = engineData(v4); | - | ||||||||||||||||||
| 620 | QV4::Scope scope(v4); | - | ||||||||||||||||||
| 621 | QV4::ScopedObject o(scope, v4->memoryManager->allocate<QQmlDelegateModelItemObject>(this)); | - | ||||||||||||||||||
| 622 | QV4::ScopedObject p(scope, data->listItemProto.value()); | - | ||||||||||||||||||
| 623 | o->setPrototypeOf(p); | - | ||||||||||||||||||
| 624 | ++scriptRef; | - | ||||||||||||||||||
| 625 | return o.asReturnedValue(); executed 424 times by 1 test: return o.asReturnedValue();Executed by:
| 424 | ||||||||||||||||||
| 626 | } | - | ||||||||||||||||||
| 627 | - | |||||||||||||||||||
| 628 | void setValue(const QString &role, const QVariant &value) override | - | ||||||||||||||||||
| 629 | { | - | ||||||||||||||||||
| 630 | if (role == QLatin1String("modelData"))
| 0-44 | ||||||||||||||||||
| 631 | cachedData = value; executed 44 times by 1 test: cachedData = value;Executed by:
| 44 | ||||||||||||||||||
| 632 | } executed 44 times by 1 test: end of blockExecuted by:
| 44 | ||||||||||||||||||
| 633 | - | |||||||||||||||||||
| 634 | bool resolveIndex(const QQmlAdaptorModel &model, int idx) override | - | ||||||||||||||||||
| 635 | { | - | ||||||||||||||||||
| 636 | if (index == -1) {
| 0-12 | ||||||||||||||||||
| 637 | index = idx; | - | ||||||||||||||||||
| 638 | cachedData = model.list.at(idx); | - | ||||||||||||||||||
| 639 | emit modelIndexChanged(); | - | ||||||||||||||||||
| 640 | emit modelDataChanged(); | - | ||||||||||||||||||
| 641 | return true; executed 12 times by 1 test: return true;Executed by:
| 12 | ||||||||||||||||||
| 642 | } else { | - | ||||||||||||||||||
| 643 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 644 | } | - | ||||||||||||||||||
| 645 | } | - | ||||||||||||||||||
| 646 | - | |||||||||||||||||||
| 647 | - | |||||||||||||||||||
| 648 | Q_SIGNALS: | - | ||||||||||||||||||
| 649 | void modelDataChanged(); | - | ||||||||||||||||||
| 650 | - | |||||||||||||||||||
| 651 | private: | - | ||||||||||||||||||
| 652 | QVariant cachedData; | - | ||||||||||||||||||
| 653 | }; | - | ||||||||||||||||||
| 654 | - | |||||||||||||||||||
| 655 | - | |||||||||||||||||||
| 656 | class VDMListDelegateDataType : public QQmlAdaptorModel::Accessors | - | ||||||||||||||||||
| 657 | { | - | ||||||||||||||||||
| 658 | public: | - | ||||||||||||||||||
| 659 | inline VDMListDelegateDataType() {} | - | ||||||||||||||||||
| 660 | - | |||||||||||||||||||
| 661 | int rowCount(const QQmlAdaptorModel &model) const override | - | ||||||||||||||||||
| 662 | { | - | ||||||||||||||||||
| 663 | return model.list.count(); executed 20760 times by 22 tests: return model.list.count();Executed by:
| 20760 | ||||||||||||||||||
| 664 | } | - | ||||||||||||||||||
| 665 | - | |||||||||||||||||||
| 666 | int columnCount(const QQmlAdaptorModel &) const override | - | ||||||||||||||||||
| 667 | { | - | ||||||||||||||||||
| 668 | return 1; never executed: return 1; | 0 | ||||||||||||||||||
| 669 | } | - | ||||||||||||||||||
| 670 | - | |||||||||||||||||||
| 671 | QVariant value(const QQmlAdaptorModel &model, int index, const QString &role) const override | - | ||||||||||||||||||
| 672 | { | - | ||||||||||||||||||
| 673 | return role == QLatin1String("modelData") executed 102 times by 1 test: return role == QLatin1String("modelData") ? model.list.at(index) : QVariant();Executed by:
| 102 | ||||||||||||||||||
| 674 | ? model.list.at(index) executed 102 times by 1 test: return role == QLatin1String("modelData") ? model.list.at(index) : QVariant();Executed by:
| 102 | ||||||||||||||||||
| 675 | : QVariant(); executed 102 times by 1 test: return role == QLatin1String("modelData") ? model.list.at(index) : QVariant();Executed by:
| 102 | ||||||||||||||||||
| 676 | } | - | ||||||||||||||||||
| 677 | - | |||||||||||||||||||
| 678 | QQmlDelegateModelItem *createItem( | - | ||||||||||||||||||
| 679 | QQmlAdaptorModel &model, | - | ||||||||||||||||||
| 680 | QQmlDelegateModelItemMetaType *metaType, | - | ||||||||||||||||||
| 681 | int index) const override | - | ||||||||||||||||||
| 682 | { | - | ||||||||||||||||||
| 683 | return new QQmlDMListAccessorData( executed 9985 times by 22 tests: return new QQmlDMListAccessorData( metaType, index, index >= 0 && index < model.list.count() ? model.list.at(index) : QVariant());Executed by:
| 9985 | ||||||||||||||||||
| 684 | metaType, executed 9985 times by 22 tests: return new QQmlDMListAccessorData( metaType, index, index >= 0 && index < model.list.count() ? model.list.at(index) : QVariant());Executed by:
| 9985 | ||||||||||||||||||
| 685 | index, executed 9985 times by 22 tests: return new QQmlDMListAccessorData( metaType, index, index >= 0 && index < model.list.count() ? model.list.at(index) : QVariant());Executed by:
| 9985 | ||||||||||||||||||
| 686 | index >= 0 && index < model.list.count() ? model.list.at(index) : QVariant()); executed 9985 times by 22 tests: return new QQmlDMListAccessorData( metaType, index, index >= 0 && index < model.list.count() ? model.list.at(index) : QVariant());Executed by:
| 9985 | ||||||||||||||||||
| 687 | } | - | ||||||||||||||||||
| 688 | }; | - | ||||||||||||||||||
| 689 | - | |||||||||||||||||||
| 690 | //----------------------------------------------------------------- | - | ||||||||||||||||||
| 691 | // QObject | - | ||||||||||||||||||
| 692 | //----------------------------------------------------------------- | - | ||||||||||||||||||
| 693 | - | |||||||||||||||||||
| 694 | class VDMObjectDelegateDataType; | - | ||||||||||||||||||
| 695 | class QQmlDMObjectData : public QQmlDelegateModelItem, public QQmlAdaptorModelProxyInterface | - | ||||||||||||||||||
| 696 | { | - | ||||||||||||||||||
| 697 | Q_OBJECT | - | ||||||||||||||||||
| 698 | Q_PROPERTY(QObject *modelData READ modelData CONSTANT) | - | ||||||||||||||||||
| 699 | Q_INTERFACES(QQmlAdaptorModelProxyInterface) | - | ||||||||||||||||||
| 700 | public: | - | ||||||||||||||||||
| 701 | QQmlDMObjectData( | - | ||||||||||||||||||
| 702 | QQmlDelegateModelItemMetaType *metaType, | - | ||||||||||||||||||
| 703 | VDMObjectDelegateDataType *dataType, | - | ||||||||||||||||||
| 704 | int index, | - | ||||||||||||||||||
| 705 | QObject *object); | - | ||||||||||||||||||
| 706 | - | |||||||||||||||||||
| 707 | QObject *modelData() const { return object; } executed 454 times by 3 tests: return object;Executed by:
| 454 | ||||||||||||||||||
| 708 | QObject *proxiedObject() override { return object; } executed 472 times by 3 tests: return object;Executed by:
| 472 | ||||||||||||||||||
| 709 | - | |||||||||||||||||||
| 710 | QPointer<QObject> object; | - | ||||||||||||||||||
| 711 | }; | - | ||||||||||||||||||
| 712 | - | |||||||||||||||||||
| 713 | class VDMObjectDelegateDataType : public QQmlRefCount, public QQmlAdaptorModel::Accessors | - | ||||||||||||||||||
| 714 | { | - | ||||||||||||||||||
| 715 | public: | - | ||||||||||||||||||
| 716 | QMetaObject *metaObject; | - | ||||||||||||||||||
| 717 | int propertyOffset; | - | ||||||||||||||||||
| 718 | int signalOffset; | - | ||||||||||||||||||
| 719 | bool shared; | - | ||||||||||||||||||
| 720 | QMetaObjectBuilder builder; | - | ||||||||||||||||||
| 721 | - | |||||||||||||||||||
| 722 | VDMObjectDelegateDataType() | - | ||||||||||||||||||
| 723 | : metaObject(nullptr) | - | ||||||||||||||||||
| 724 | , propertyOffset(0) | - | ||||||||||||||||||
| 725 | , signalOffset(0) | - | ||||||||||||||||||
| 726 | , shared(true) | - | ||||||||||||||||||
| 727 | { | - | ||||||||||||||||||
| 728 | } executed 24 times by 3 tests: end of blockExecuted by:
| 24 | ||||||||||||||||||
| 729 | - | |||||||||||||||||||
| 730 | VDMObjectDelegateDataType(const VDMObjectDelegateDataType &type) | - | ||||||||||||||||||
| 731 | : QQmlRefCount() | - | ||||||||||||||||||
| 732 | , QQmlAdaptorModel::Accessors() | - | ||||||||||||||||||
| 733 | , metaObject(nullptr) | - | ||||||||||||||||||
| 734 | , propertyOffset(type.propertyOffset) | - | ||||||||||||||||||
| 735 | , signalOffset(type.signalOffset) | - | ||||||||||||||||||
| 736 | , shared(false) | - | ||||||||||||||||||
| 737 | , builder(type.metaObject, QMetaObjectBuilder::Properties | - | ||||||||||||||||||
| 738 | | QMetaObjectBuilder::Signals | - | ||||||||||||||||||
| 739 | | QMetaObjectBuilder::SuperClass | - | ||||||||||||||||||
| 740 | | QMetaObjectBuilder::ClassName) | - | ||||||||||||||||||
| 741 | { | - | ||||||||||||||||||
| 742 | builder.setFlags(QMetaObjectBuilder::DynamicMetaObject); | - | ||||||||||||||||||
| 743 | } executed 66 times by 1 test: end of blockExecuted by:
| 66 | ||||||||||||||||||
| 744 | - | |||||||||||||||||||
| 745 | ~VDMObjectDelegateDataType() | - | ||||||||||||||||||
| 746 | { | - | ||||||||||||||||||
| 747 | free(metaObject); | - | ||||||||||||||||||
| 748 | } executed 90 times by 3 tests: end of blockExecuted by:
| 90 | ||||||||||||||||||
| 749 | - | |||||||||||||||||||
| 750 | int rowCount(const QQmlAdaptorModel &model) const override | - | ||||||||||||||||||
| 751 | { | - | ||||||||||||||||||
| 752 | return model.list.count(); executed 968 times by 3 tests: return model.list.count();Executed by:
| 968 | ||||||||||||||||||
| 753 | } | - | ||||||||||||||||||
| 754 | - | |||||||||||||||||||
| 755 | int columnCount(const QQmlAdaptorModel &) const override | - | ||||||||||||||||||
| 756 | { | - | ||||||||||||||||||
| 757 | return 1; never executed: return 1; | 0 | ||||||||||||||||||
| 758 | } | - | ||||||||||||||||||
| 759 | - | |||||||||||||||||||
| 760 | QVariant value(const QQmlAdaptorModel &model, int index, const QString &role) const override | - | ||||||||||||||||||
| 761 | { | - | ||||||||||||||||||
| 762 | if (QObject *object = model.list.at(index).value<QObject *>())
| 0-24 | ||||||||||||||||||
| 763 | return object->property(role.toUtf8()); executed 24 times by 1 test: return object->property(role.toUtf8());Executed by:
| 24 | ||||||||||||||||||
| 764 | return QVariant(); never executed: return QVariant(); | 0 | ||||||||||||||||||
| 765 | } | - | ||||||||||||||||||
| 766 | - | |||||||||||||||||||
| 767 | QQmlDelegateModelItem *createItem( | - | ||||||||||||||||||
| 768 | QQmlAdaptorModel &model, | - | ||||||||||||||||||
| 769 | QQmlDelegateModelItemMetaType *metaType, | - | ||||||||||||||||||
| 770 | int index) const override | - | ||||||||||||||||||
| 771 | { | - | ||||||||||||||||||
| 772 | VDMObjectDelegateDataType *dataType = const_cast<VDMObjectDelegateDataType *>(this); | - | ||||||||||||||||||
| 773 | if (!metaObject)
| 24-460 | ||||||||||||||||||
| 774 | dataType->initializeMetaType(model); executed 24 times by 3 tests: dataType->initializeMetaType(model);Executed by:
| 24 | ||||||||||||||||||
| 775 | return index >= 0 && index < model.list.count() executed 484 times by 3 tests: return index >= 0 && index < model.list.count() ? new QQmlDMObjectData(metaType, dataType, index, qvariant_cast<QObject *>(model.list.at(index))) : nullptr;Executed by:
| 484 | ||||||||||||||||||
| 776 | ? new QQmlDMObjectData(metaType, dataType, index, qvariant_cast<QObject *>(model.list.at(index))) executed 484 times by 3 tests: return index >= 0 && index < model.list.count() ? new QQmlDMObjectData(metaType, dataType, index, qvariant_cast<QObject *>(model.list.at(index))) : nullptr;Executed by:
| 484 | ||||||||||||||||||
| 777 | : nullptr; executed 484 times by 3 tests: return index >= 0 && index < model.list.count() ? new QQmlDMObjectData(metaType, dataType, index, qvariant_cast<QObject *>(model.list.at(index))) : nullptr;Executed by:
| 484 | ||||||||||||||||||
| 778 | } | - | ||||||||||||||||||
| 779 | - | |||||||||||||||||||
| 780 | void initializeMetaType(QQmlAdaptorModel &) | - | ||||||||||||||||||
| 781 | { | - | ||||||||||||||||||
| 782 | setModelDataType<QQmlDMObjectData>(&builder, this); | - | ||||||||||||||||||
| 783 | - | |||||||||||||||||||
| 784 | metaObject = builder.toMetaObject(); | - | ||||||||||||||||||
| 785 | } executed 24 times by 3 tests: end of blockExecuted by:
| 24 | ||||||||||||||||||
| 786 | - | |||||||||||||||||||
| 787 | void cleanup(QQmlAdaptorModel &, QQmlDelegateModel *) const override | - | ||||||||||||||||||
| 788 | { | - | ||||||||||||||||||
| 789 | const_cast<VDMObjectDelegateDataType *>(this)->release(); | - | ||||||||||||||||||
| 790 | } executed 24 times by 3 tests: end of blockExecuted by:
| 24 | ||||||||||||||||||
| 791 | }; | - | ||||||||||||||||||
| 792 | - | |||||||||||||||||||
| 793 | class QQmlDMObjectDataMetaObject : public QAbstractDynamicMetaObject | - | ||||||||||||||||||
| 794 | { | - | ||||||||||||||||||
| 795 | public: | - | ||||||||||||||||||
| 796 | QQmlDMObjectDataMetaObject(QQmlDMObjectData *data, VDMObjectDelegateDataType *type) | - | ||||||||||||||||||
| 797 | : m_data(data) | - | ||||||||||||||||||
| 798 | , m_type(type) | - | ||||||||||||||||||
| 799 | { | - | ||||||||||||||||||
| 800 | QObjectPrivate *op = QObjectPrivate::get(m_data); | - | ||||||||||||||||||
| 801 | *static_cast<QMetaObject *>(this) = *type->metaObject; | - | ||||||||||||||||||
| 802 | op->metaObject = this; | - | ||||||||||||||||||
| 803 | m_type->addref(); | - | ||||||||||||||||||
| 804 | } executed 472 times by 3 tests: end of blockExecuted by:
| 472 | ||||||||||||||||||
| 805 | - | |||||||||||||||||||
| 806 | ~QQmlDMObjectDataMetaObject() | - | ||||||||||||||||||
| 807 | { | - | ||||||||||||||||||
| 808 | m_type->release(); | - | ||||||||||||||||||
| 809 | } executed 472 times by 3 tests: end of blockExecuted by:
| 472 | ||||||||||||||||||
| 810 | - | |||||||||||||||||||
| 811 | int metaCall(QObject *o, QMetaObject::Call call, int id, void **arguments) override | - | ||||||||||||||||||
| 812 | { | - | ||||||||||||||||||
| 813 | Q_ASSERT(o == m_data); | - | ||||||||||||||||||
| 814 | Q_UNUSED(o); | - | ||||||||||||||||||
| 815 | - | |||||||||||||||||||
| 816 | static const int objectPropertyOffset = QObject::staticMetaObject.propertyCount(); | - | ||||||||||||||||||
| 817 | if (id >= m_type->propertyOffset
| 118-1314 | ||||||||||||||||||
| 818 | && (call == QMetaObject::ReadProperty
| 2-116 | ||||||||||||||||||
| 819 | || call == QMetaObject::WriteProperty
| 0-2 | ||||||||||||||||||
| 820 | || call == QMetaObject::ResetProperty)) {
| 0-2 | ||||||||||||||||||
| 821 | if (m_data->object)
| 0-116 | ||||||||||||||||||
| 822 | QMetaObject::metacall(m_data->object, call, id - m_type->propertyOffset + objectPropertyOffset, arguments); executed 116 times by 1 test: QMetaObject::metacall(m_data->object, call, id - m_type->propertyOffset + objectPropertyOffset, arguments);Executed by:
| 116 | ||||||||||||||||||
| 823 | return -1; executed 116 times by 1 test: return -1;Executed by:
| 116 | ||||||||||||||||||
| 824 | } else if (id >= m_type->signalOffset && call == QMetaObject::InvokeMetaMethod) {
| 0-1314 | ||||||||||||||||||
| 825 | QMetaObject::activate(m_data, this, id - m_type->signalOffset, nullptr); | - | ||||||||||||||||||
| 826 | return -1; executed 2 times by 1 test: return -1;Executed by:
| 2 | ||||||||||||||||||
| 827 | } else { | - | ||||||||||||||||||
| 828 | return m_data->qt_metacall(call, id, arguments); executed 1314 times by 3 tests: return m_data->qt_metacall(call, id, arguments);Executed by:
| 1314 | ||||||||||||||||||
| 829 | } | - | ||||||||||||||||||
| 830 | } | - | ||||||||||||||||||
| 831 | - | |||||||||||||||||||
| 832 | int createProperty(const char *name, const char *) override | - | ||||||||||||||||||
| 833 | { | - | ||||||||||||||||||
| 834 | if (!m_data->object)
| 0-466 | ||||||||||||||||||
| 835 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
| 836 | const QMetaObject *metaObject = m_data->object->metaObject(); | - | ||||||||||||||||||
| 837 | static const int objectPropertyOffset = QObject::staticMetaObject.propertyCount(); | - | ||||||||||||||||||
| 838 | - | |||||||||||||||||||
| 839 | const int previousPropertyCount = propertyCount() - propertyOffset(); | - | ||||||||||||||||||
| 840 | int propertyIndex = metaObject->indexOfProperty(name); | - | ||||||||||||||||||
| 841 | if (propertyIndex == -1)
| 66-400 | ||||||||||||||||||
| 842 | return -1; executed 400 times by 1 test: return -1;Executed by:
| 400 | ||||||||||||||||||
| 843 | if (previousPropertyCount + objectPropertyOffset == metaObject->propertyCount())
| 0-66 | ||||||||||||||||||
| 844 | return propertyIndex + m_type->propertyOffset - objectPropertyOffset; never executed: return propertyIndex + m_type->propertyOffset - objectPropertyOffset; | 0 | ||||||||||||||||||
| 845 | - | |||||||||||||||||||
| 846 | if (m_type->shared) {
| 0-66 | ||||||||||||||||||
| 847 | VDMObjectDelegateDataType *type = m_type; | - | ||||||||||||||||||
| 848 | m_type = new VDMObjectDelegateDataType(*m_type); | - | ||||||||||||||||||
| 849 | type->release(); | - | ||||||||||||||||||
| 850 | } executed 66 times by 1 test: end of blockExecuted by:
| 66 | ||||||||||||||||||
| 851 | - | |||||||||||||||||||
| 852 | const int previousMethodCount = methodCount(); | - | ||||||||||||||||||
| 853 | int notifierId = previousMethodCount - methodOffset(); | - | ||||||||||||||||||
| 854 | for (int propertyId = previousPropertyCount; propertyId < metaObject->propertyCount() - objectPropertyOffset; ++propertyId) {
| 66-198 | ||||||||||||||||||
| 855 | QMetaProperty property = metaObject->property(propertyId + objectPropertyOffset); | - | ||||||||||||||||||
| 856 | QMetaPropertyBuilder propertyBuilder; | - | ||||||||||||||||||
| 857 | if (property.hasNotifySignal()) {
| 66-132 | ||||||||||||||||||
| 858 | m_type->builder.addSignal("__" + QByteArray::number(propertyId) + "()"); | - | ||||||||||||||||||
| 859 | propertyBuilder = m_type->builder.addProperty(property.name(), property.typeName(), notifierId); | - | ||||||||||||||||||
| 860 | ++notifierId; | - | ||||||||||||||||||
| 861 | } else { executed 132 times by 1 test: end of blockExecuted by:
| 132 | ||||||||||||||||||
| 862 | propertyBuilder = m_type->builder.addProperty(property.name(), property.typeName()); | - | ||||||||||||||||||
| 863 | } executed 66 times by 1 test: end of blockExecuted by:
| 66 | ||||||||||||||||||
| 864 | propertyBuilder.setWritable(property.isWritable()); | - | ||||||||||||||||||
| 865 | propertyBuilder.setResettable(property.isResettable()); | - | ||||||||||||||||||
| 866 | propertyBuilder.setConstant(property.isConstant()); | - | ||||||||||||||||||
| 867 | } executed 198 times by 1 test: end of blockExecuted by:
| 198 | ||||||||||||||||||
| 868 | - | |||||||||||||||||||
| 869 | if (m_type->metaObject)
| 0-66 | ||||||||||||||||||
| 870 | free(m_type->metaObject); never executed: free(m_type->metaObject); | 0 | ||||||||||||||||||
| 871 | m_type->metaObject = m_type->builder.toMetaObject(); | - | ||||||||||||||||||
| 872 | *static_cast<QMetaObject *>(this) = *m_type->metaObject; | - | ||||||||||||||||||
| 873 | - | |||||||||||||||||||
| 874 | notifierId = previousMethodCount; | - | ||||||||||||||||||
| 875 | for (int i = previousPropertyCount; i < metaObject->propertyCount() - objectPropertyOffset; ++i) {
| 66-198 | ||||||||||||||||||
| 876 | QMetaProperty property = metaObject->property(i + objectPropertyOffset); | - | ||||||||||||||||||
| 877 | if (property.hasNotifySignal()) {
| 66-132 | ||||||||||||||||||
| 878 | QQmlPropertyPrivate::connect( | - | ||||||||||||||||||
| 879 | m_data->object, property.notifySignalIndex(), m_data, notifierId); | - | ||||||||||||||||||
| 880 | ++notifierId; | - | ||||||||||||||||||
| 881 | } executed 132 times by 1 test: end of blockExecuted by:
| 132 | ||||||||||||||||||
| 882 | } executed 198 times by 1 test: end of blockExecuted by:
| 198 | ||||||||||||||||||
| 883 | return propertyIndex + m_type->propertyOffset - objectPropertyOffset; executed 66 times by 1 test: return propertyIndex + m_type->propertyOffset - objectPropertyOffset;Executed by:
| 66 | ||||||||||||||||||
| 884 | } | - | ||||||||||||||||||
| 885 | - | |||||||||||||||||||
| 886 | QQmlDMObjectData *m_data; | - | ||||||||||||||||||
| 887 | VDMObjectDelegateDataType *m_type; | - | ||||||||||||||||||
| 888 | }; | - | ||||||||||||||||||
| 889 | - | |||||||||||||||||||
| 890 | QQmlDMObjectData::QQmlDMObjectData( | - | ||||||||||||||||||
| 891 | QQmlDelegateModelItemMetaType *metaType, | - | ||||||||||||||||||
| 892 | VDMObjectDelegateDataType *dataType, | - | ||||||||||||||||||
| 893 | int index, | - | ||||||||||||||||||
| 894 | QObject *object) | - | ||||||||||||||||||
| 895 | : QQmlDelegateModelItem(metaType, index) | - | ||||||||||||||||||
| 896 | , object(object) | - | ||||||||||||||||||
| 897 | { | - | ||||||||||||||||||
| 898 | new QQmlDMObjectDataMetaObject(this, dataType); | - | ||||||||||||||||||
| 899 | } executed 472 times by 3 tests: end of blockExecuted by:
| 472 | ||||||||||||||||||
| 900 | - | |||||||||||||||||||
| 901 | //----------------------------------------------------------------- | - | ||||||||||||||||||
| 902 | // QQmlAdaptorModel | - | ||||||||||||||||||
| 903 | //----------------------------------------------------------------- | - | ||||||||||||||||||
| 904 | - | |||||||||||||||||||
| 905 | static const QQmlAdaptorModel::Accessors qt_vdm_null_accessors; | - | ||||||||||||||||||
| 906 | static const VDMListDelegateDataType qt_vdm_list_accessors; | - | ||||||||||||||||||
| 907 | - | |||||||||||||||||||
| 908 | QQmlAdaptorModel::Accessors::~Accessors() | - | ||||||||||||||||||
| 909 | { | - | ||||||||||||||||||
| 910 | } | - | ||||||||||||||||||
| 911 | - | |||||||||||||||||||
| 912 | QQmlAdaptorModel::QQmlAdaptorModel() | - | ||||||||||||||||||
| 913 | : accessors(&qt_vdm_null_accessors) | - | ||||||||||||||||||
| 914 | { | - | ||||||||||||||||||
| 915 | } executed 5622 times by 27 tests: end of blockExecuted by:
| 5622 | ||||||||||||||||||
| 916 | - | |||||||||||||||||||
| 917 | QQmlAdaptorModel::~QQmlAdaptorModel() | - | ||||||||||||||||||
| 918 | { | - | ||||||||||||||||||
| 919 | accessors->cleanup(*this); | - | ||||||||||||||||||
| 920 | } executed 5556 times by 25 tests: end of blockExecuted by:
| 5556 | ||||||||||||||||||
| 921 | - | |||||||||||||||||||
| 922 | void QQmlAdaptorModel::setModel(const QVariant &variant, QQmlDelegateModel *vdm, QQmlEngine *engine) | - | ||||||||||||||||||
| 923 | { | - | ||||||||||||||||||
| 924 | accessors->cleanup(*this, vdm); | - | ||||||||||||||||||
| 925 | - | |||||||||||||||||||
| 926 | list.setList(variant, engine); | - | ||||||||||||||||||
| 927 | - | |||||||||||||||||||
| 928 | if (QObject *object = qvariant_cast<QObject *>(list.list())) {
| 1324-4158 | ||||||||||||||||||
| 929 | setObject(object, vdm); | - | ||||||||||||||||||
| 930 | if (QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(object)) {
| 2-4156 | ||||||||||||||||||
| 931 | accessors = new VDMAbstractItemModelDataType(this); | - | ||||||||||||||||||
| 932 | - | |||||||||||||||||||
| 933 | qmlobject_connect(model, QAbstractItemModel, SIGNAL(rowsInserted(QModelIndex,int,int)), executed 24 times by 12 tests: end of blockExecuted by:
executed 24 times by 12 tests: methodIdx = QQmlDelegateModel::staticMetaObject.indexOfSlot(method+1);Executed by:
never executed: methodIdx = QQmlDelegateModel::staticMetaObject.indexOfSignal(method+1);
| 0-4132 | ||||||||||||||||||
| 934 | vdm, QQmlDelegateModel, SLOT(_q_rowsInserted(QModelIndex,int,int))); | - | ||||||||||||||||||
| 935 | qmlobject_connect(model, QAbstractItemModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), executed 24 times by 12 tests: end of blockExecuted by:
executed 24 times by 12 tests: methodIdx = QQmlDelegateModel::staticMetaObject.indexOfSlot(method+1);Executed by:
never executed: methodIdx = QQmlDelegateModel::staticMetaObject.indexOfSignal(method+1);
| 0-4132 | ||||||||||||||||||
| 936 | vdm, QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int))); | - | ||||||||||||||||||
| 937 | qmlobject_connect(model, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), executed 24 times by 12 tests: end of blockExecuted by:
executed 24 times by 12 tests: methodIdx = QQmlDelegateModel::staticMetaObject.indexOfSlot(method+1);Executed by:
never executed: methodIdx = QQmlDelegateModel::staticMetaObject.indexOfSignal(method+1);
| 0-4132 | ||||||||||||||||||
| 938 | vdm, QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int))); | - | ||||||||||||||||||
| 939 | qmlobject_connect(model, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)), executed 24 times by 12 tests: end of blockExecuted by:
executed 24 times by 12 tests: methodIdx = QQmlDelegateModel::staticMetaObject.indexOfSlot(method+1);Executed by:
never executed: methodIdx = QQmlDelegateModel::staticMetaObject.indexOfSignal(method+1);
| 0-4132 | ||||||||||||||||||
| 940 | vdm, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>))); | - | ||||||||||||||||||
| 941 | qmlobject_connect(model, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), executed 24 times by 12 tests: end of blockExecuted by:
executed 24 times by 12 tests: methodIdx = QQmlDelegateModel::staticMetaObject.indexOfSlot(method+1);Executed by:
never executed: methodIdx = QQmlDelegateModel::staticMetaObject.indexOfSignal(method+1);
| 0-4132 | ||||||||||||||||||
| 942 | vdm, QQmlDelegateModel, SLOT(_q_rowsMoved(QModelIndex,int,int,QModelIndex,int))); | - | ||||||||||||||||||
| 943 | qmlobject_connect(model, QAbstractItemModel, SIGNAL(modelReset()), executed 24 times by 12 tests: end of blockExecuted by:
executed 24 times by 12 tests: methodIdx = QQmlDelegateModel::staticMetaObject.indexOfSlot(method+1);Executed by:
never executed: methodIdx = QQmlDelegateModel::staticMetaObject.indexOfSignal(method+1);
| 0-4132 | ||||||||||||||||||
| 944 | vdm, QQmlDelegateModel, SLOT(_q_modelReset())); | - | ||||||||||||||||||
| 945 | qmlobject_connect(model, QAbstractItemModel, SIGNAL(layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)), executed 24 times by 12 tests: end of blockExecuted by:
executed 24 times by 12 tests: methodIdx = QQmlDelegateModel::staticMetaObject.indexOfSlot(method+1);Executed by:
never executed: methodIdx = QQmlDelegateModel::staticMetaObject.indexOfSignal(method+1);
| 0-4132 | ||||||||||||||||||
| 946 | vdm, QQmlDelegateModel, SLOT(_q_layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint))); | - | ||||||||||||||||||
| 947 | } else { executed 4156 times by 12 tests: end of blockExecuted by:
| 4156 | ||||||||||||||||||
| 948 | accessors = new VDMObjectDelegateDataType; | - | ||||||||||||||||||
| 949 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 950 | } else if (list.type() == QQmlListAccessor::ListProperty) {
| 22-1302 | ||||||||||||||||||
| 951 | setObject(static_cast<const QQmlListReference *>(variant.constData())->object(), vdm); | - | ||||||||||||||||||
| 952 | accessors = new VDMObjectDelegateDataType; | - | ||||||||||||||||||
| 953 | } else if (list.type() != QQmlListAccessor::Invalid executed 22 times by 3 tests: end of blockExecuted by:
| 22-754 | ||||||||||||||||||
| 954 | && list.type() != QQmlListAccessor::Instance) { // Null QObject
| 4-750 | ||||||||||||||||||
| 955 | setObject(nullptr, vdm); | - | ||||||||||||||||||
| 956 | accessors = &qt_vdm_list_accessors; | - | ||||||||||||||||||
| 957 | } else { executed 750 times by 22 tests: end of blockExecuted by:
| 750 | ||||||||||||||||||
| 958 | setObject(nullptr, vdm); | - | ||||||||||||||||||
| 959 | accessors = &qt_vdm_null_accessors; | - | ||||||||||||||||||
| 960 | } executed 552 times by 7 tests: end of blockExecuted by:
| 552 | ||||||||||||||||||
| 961 | } | - | ||||||||||||||||||
| 962 | - | |||||||||||||||||||
| 963 | void QQmlAdaptorModel::invalidateModel(QQmlDelegateModel *vdm) | - | ||||||||||||||||||
| 964 | { | - | ||||||||||||||||||
| 965 | accessors->cleanup(*this, vdm); | - | ||||||||||||||||||
| 966 | accessors = &qt_vdm_null_accessors; | - | ||||||||||||||||||
| 967 | // Don't clear the model object as we still need the guard to clear the list variant if the | - | ||||||||||||||||||
| 968 | // object is destroyed. | - | ||||||||||||||||||
| 969 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 970 | - | |||||||||||||||||||
| 971 | bool QQmlAdaptorModel::isValid() const | - | ||||||||||||||||||
| 972 | { | - | ||||||||||||||||||
| 973 | return accessors != &qt_vdm_null_accessors; executed 132 times by 4 tests: return accessors != &qt_vdm_null_accessors;Executed by:
| 132 | ||||||||||||||||||
| 974 | } | - | ||||||||||||||||||
| 975 | - | |||||||||||||||||||
| 976 | int QQmlAdaptorModel::count() const | - | ||||||||||||||||||
| 977 | { | - | ||||||||||||||||||
| 978 | return rowCount() * columnCount(); never executed: return rowCount() * columnCount(); | 0 | ||||||||||||||||||
| 979 | } | - | ||||||||||||||||||
| 980 | - | |||||||||||||||||||
| 981 | int QQmlAdaptorModel::rowCount() const | - | ||||||||||||||||||
| 982 | { | - | ||||||||||||||||||
| 983 | return qMax(0, accessors->rowCount(*this)); executed 282606 times by 27 tests: return qMax(0, accessors->rowCount(*this));Executed by:
| 282606 | ||||||||||||||||||
| 984 | } | - | ||||||||||||||||||
| 985 | - | |||||||||||||||||||
| 986 | int QQmlAdaptorModel::columnCount() const | - | ||||||||||||||||||
| 987 | { | - | ||||||||||||||||||
| 988 | return qMax(isValid() ? 1 : 0, accessors->columnCount(*this)); executed 102 times by 1 test: return qMax(isValid() ? 1 : 0, accessors->columnCount(*this));Executed by:
| 102 | ||||||||||||||||||
| 989 | } | - | ||||||||||||||||||
| 990 | - | |||||||||||||||||||
| 991 | int QQmlAdaptorModel::rowAt(int index) const | - | ||||||||||||||||||
| 992 | { | - | ||||||||||||||||||
| 993 | int count = rowCount(); | - | ||||||||||||||||||
| 994 | return count <= 0 ? -1 : index % count; executed 137920 times by 25 tests: return count <= 0 ? -1 : index % count;Executed by:
| 137920 | ||||||||||||||||||
| 995 | } | - | ||||||||||||||||||
| 996 | - | |||||||||||||||||||
| 997 | int QQmlAdaptorModel::columnAt(int index) const | - | ||||||||||||||||||
| 998 | { | - | ||||||||||||||||||
| 999 | int count = rowCount(); | - | ||||||||||||||||||
| 1000 | return count <= 0 ? -1 : index / count; executed 137920 times by 25 tests: return count <= 0 ? -1 : index / count;Executed by:
| 137920 | ||||||||||||||||||
| 1001 | } | - | ||||||||||||||||||
| 1002 | - | |||||||||||||||||||
| 1003 | int QQmlAdaptorModel::indexAt(int row, int column) const | - | ||||||||||||||||||
| 1004 | { | - | ||||||||||||||||||
| 1005 | return row + (column * rowCount()); executed 316 times by 5 tests: return row + (column * rowCount());Executed by:
| 316 | ||||||||||||||||||
| 1006 | } | - | ||||||||||||||||||
| 1007 | - | |||||||||||||||||||
| 1008 | void QQmlAdaptorModel::objectDestroyed(QObject *) | - | ||||||||||||||||||
| 1009 | { | - | ||||||||||||||||||
| 1010 | setModel(QVariant(), nullptr, nullptr); | - | ||||||||||||||||||
| 1011 | } executed 516 times by 6 tests: end of blockExecuted by:
| 516 | ||||||||||||||||||
| 1012 | - | |||||||||||||||||||
| 1013 | QQmlAdaptorModelEngineData::QQmlAdaptorModelEngineData(QV4::ExecutionEngine *v4) | - | ||||||||||||||||||
| 1014 | : v4(v4) | - | ||||||||||||||||||
| 1015 | { | - | ||||||||||||||||||
| 1016 | QV4::Scope scope(v4); | - | ||||||||||||||||||
| 1017 | QV4::ScopedObject proto(scope, v4->newObject()); | - | ||||||||||||||||||
| 1018 | proto->defineAccessorProperty(QStringLiteral("index"), get_index, nullptr); executed 8 times by 2 tests: return qstring_literal_temp;Executed by:
| 8 | ||||||||||||||||||
| 1019 | proto->defineAccessorProperty(QStringLiteral("modelData"), executed 8 times by 2 tests: return qstring_literal_temp;Executed by:
| 8 | ||||||||||||||||||
| 1020 | QQmlDMListAccessorData::get_modelData, QQmlDMListAccessorData::set_modelData); | - | ||||||||||||||||||
| 1021 | listItemProto.set(v4, proto); | - | ||||||||||||||||||
| 1022 | } executed 8 times by 2 tests: end of blockExecuted by:
| 8 | ||||||||||||||||||
| 1023 | - | |||||||||||||||||||
| 1024 | QQmlAdaptorModelEngineData::~QQmlAdaptorModelEngineData() | - | ||||||||||||||||||
| 1025 | { | - | ||||||||||||||||||
| 1026 | } | - | ||||||||||||||||||
| 1027 | - | |||||||||||||||||||
| 1028 | QT_END_NAMESPACE | - | ||||||||||||||||||
| 1029 | - | |||||||||||||||||||
| 1030 | #include <qqmladaptormodel.moc> | - | ||||||||||||||||||
| Source code | Switch to Preprocessed file |