| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/types/qqmllistmodelworkeragent.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 "qqmllistmodelworkeragent_p.h" | - | ||||||
| 41 | #include "qqmllistmodel_p_p.h" | - | ||||||
| 42 | #include <private/qqmldata_p.h> | - | ||||||
| 43 | #include <private/qqmlengine_p.h> | - | ||||||
| 44 | #include <qqmlinfo.h> | - | ||||||
| 45 | - | |||||||
| 46 | #include <QtCore/qcoreevent.h> | - | ||||||
| 47 | #include <QtCore/qcoreapplication.h> | - | ||||||
| 48 | #include <QtCore/qdebug.h> | - | ||||||
| 49 | - | |||||||
| 50 | - | |||||||
| 51 | QT_BEGIN_NAMESPACE | - | ||||||
| 52 | - | |||||||
| 53 | QQmlListModelWorkerAgent::Sync::~Sync() | - | ||||||
| 54 | { | - | ||||||
| 55 | } | - | ||||||
| 56 | - | |||||||
| 57 | QQmlListModelWorkerAgent::QQmlListModelWorkerAgent(QQmlListModel *model) | - | ||||||
| 58 | : m_ref(1), m_orig(model), m_copy(new QQmlListModel(model, this)) | - | ||||||
| 59 | { | - | ||||||
| 60 | } executed 904 times by 2 tests: end of blockExecuted by:
| 904 | ||||||
| 61 | - | |||||||
| 62 | QQmlListModelWorkerAgent::~QQmlListModelWorkerAgent() | - | ||||||
| 63 | { | - | ||||||
| 64 | mutex.lock(); | - | ||||||
| 65 | syncDone.wakeAll(); | - | ||||||
| 66 | mutex.unlock(); | - | ||||||
| 67 | } executed 902 times by 1 test: end of blockExecuted by:
| 902 | ||||||
| 68 | - | |||||||
| 69 | void QQmlListModelWorkerAgent::setEngine(QV4::ExecutionEngine *eng) | - | ||||||
| 70 | { | - | ||||||
| 71 | m_copy->m_engine = eng; | - | ||||||
| 72 | } executed 928 times by 2 tests: end of blockExecuted by:
| 928 | ||||||
| 73 | - | |||||||
| 74 | void QQmlListModelWorkerAgent::addref() | - | ||||||
| 75 | { | - | ||||||
| 76 | m_ref.ref(); | - | ||||||
| 77 | } executed 2814 times by 2 tests: end of blockExecuted by:
| 2814 | ||||||
| 78 | - | |||||||
| 79 | void QQmlListModelWorkerAgent::release() | - | ||||||
| 80 | { | - | ||||||
| 81 | bool del = !m_ref.deref(); | - | ||||||
| 82 | - | |||||||
| 83 | if (del)
| 904-2814 | ||||||
| 84 | deleteLater(); executed 904 times by 2 tests: deleteLater();Executed by:
| 904 | ||||||
| 85 | } executed 3718 times by 2 tests: end of blockExecuted by:
| 3718 | ||||||
| 86 | - | |||||||
| 87 | void QQmlListModelWorkerAgent::modelDestroyed() | - | ||||||
| 88 | { | - | ||||||
| 89 | m_orig = nullptr; | - | ||||||
| 90 | } executed 934 times by 2 tests: end of blockExecuted by:
| 934 | ||||||
| 91 | - | |||||||
| 92 | int QQmlListModelWorkerAgent::count() const | - | ||||||
| 93 | { | - | ||||||
| 94 | return m_copy->count(); executed 164 times by 1 test: return m_copy->count();Executed by:
| 164 | ||||||
| 95 | } | - | ||||||
| 96 | - | |||||||
| 97 | void QQmlListModelWorkerAgent::clear() | - | ||||||
| 98 | { | - | ||||||
| 99 | m_copy->clear(); | - | ||||||
| 100 | } executed 28 times by 1 test: end of blockExecuted by:
| 28 | ||||||
| 101 | - | |||||||
| 102 | void QQmlListModelWorkerAgent::remove(QQmlV4Function *args) | - | ||||||
| 103 | { | - | ||||||
| 104 | m_copy->remove(args); | - | ||||||
| 105 | } executed 172 times by 1 test: end of blockExecuted by:
| 172 | ||||||
| 106 | - | |||||||
| 107 | void QQmlListModelWorkerAgent::append(QQmlV4Function *args) | - | ||||||
| 108 | { | - | ||||||
| 109 | m_copy->append(args); | - | ||||||
| 110 | } executed 1006 times by 2 tests: end of blockExecuted by:
| 1006 | ||||||
| 111 | - | |||||||
| 112 | void QQmlListModelWorkerAgent::insert(QQmlV4Function *args) | - | ||||||
| 113 | { | - | ||||||
| 114 | m_copy->insert(args); | - | ||||||
| 115 | } executed 100 times by 1 test: end of blockExecuted by:
| 100 | ||||||
| 116 | - | |||||||
| 117 | QQmlV4Handle QQmlListModelWorkerAgent::get(int index) const | - | ||||||
| 118 | { | - | ||||||
| 119 | return m_copy->get(index); executed 258 times by 1 test: return m_copy->get(index);Executed by:
| 258 | ||||||
| 120 | } | - | ||||||
| 121 | - | |||||||
| 122 | void QQmlListModelWorkerAgent::set(int index, const QQmlV4Handle &value) | - | ||||||
| 123 | { | - | ||||||
| 124 | m_copy->set(index, value); | - | ||||||
| 125 | } executed 160 times by 1 test: end of blockExecuted by:
| 160 | ||||||
| 126 | - | |||||||
| 127 | void QQmlListModelWorkerAgent::setProperty(int index, const QString& property, const QVariant& value) | - | ||||||
| 128 | { | - | ||||||
| 129 | m_copy->setProperty(index, property, value); | - | ||||||
| 130 | } executed 72 times by 1 test: end of blockExecuted by:
| 72 | ||||||
| 131 | - | |||||||
| 132 | void QQmlListModelWorkerAgent::move(int from, int to, int count) | - | ||||||
| 133 | { | - | ||||||
| 134 | m_copy->move(from, to, count); | - | ||||||
| 135 | } executed 104 times by 1 test: end of blockExecuted by:
| 104 | ||||||
| 136 | - | |||||||
| 137 | void QQmlListModelWorkerAgent::sync() | - | ||||||
| 138 | { | - | ||||||
| 139 | Sync *s = new Sync(m_copy); | - | ||||||
| 140 | - | |||||||
| 141 | mutex.lock(); | - | ||||||
| 142 | QCoreApplication::postEvent(this, s); | - | ||||||
| 143 | syncDone.wait(&mutex); | - | ||||||
| 144 | mutex.unlock(); | - | ||||||
| 145 | } executed 908 times by 2 tests: end of blockExecuted by:
| 908 | ||||||
| 146 | - | |||||||
| 147 | bool QQmlListModelWorkerAgent::event(QEvent *e) | - | ||||||
| 148 | { | - | ||||||
| 149 | if (e->type() == QEvent::User) {
| 908-1806 | ||||||
| 150 | bool cc = false; | - | ||||||
| 151 | QMutexLocker locker(&mutex); | - | ||||||
| 152 | if (m_orig) {
| 6-902 | ||||||
| 153 | Sync *s = static_cast<Sync *>(e); | - | ||||||
| 154 | - | |||||||
| 155 | cc = (m_orig->count() != s->list->count()); | - | ||||||
| 156 | - | |||||||
| 157 | Q_ASSERT(m_orig->m_dynamicRoles == s->list->m_dynamicRoles); | - | ||||||
| 158 | if (m_orig->m_dynamicRoles)
| 434-468 | ||||||
| 159 | QQmlListModel::sync(s->list, m_orig); executed 468 times by 1 test: QQmlListModel::sync(s->list, m_orig);Executed by:
| 468 | ||||||
| 160 | else | - | ||||||
| 161 | ListModel::sync(s->list->m_listModel, m_orig->m_listModel); executed 434 times by 1 test: ListModel::sync(s->list->m_listModel, m_orig->m_listModel);Executed by:
| 434 | ||||||
| 162 | } | - | ||||||
| 163 | - | |||||||
| 164 | syncDone.wakeAll(); | - | ||||||
| 165 | locker.unlock(); | - | ||||||
| 166 | - | |||||||
| 167 | if (cc)
| 248-660 | ||||||
| 168 | emit m_orig->countChanged(); executed 660 times by 1 test: m_orig->countChanged();Executed by:
| 660 | ||||||
| 169 | return true; executed 908 times by 2 tests: return true;Executed by:
| 908 | ||||||
| 170 | } | - | ||||||
| 171 | - | |||||||
| 172 | return QObject::event(e); executed 1806 times by 2 tests: return QObject::event(e);Executed by:
| 1806 | ||||||
| 173 | } | - | ||||||
| 174 | - | |||||||
| 175 | QT_END_NAMESPACE | - | ||||||
| 176 | - | |||||||
| 177 | #include "moc_qqmllistmodelworkeragent_p.cpp" | - | ||||||
| Source code | Switch to Preprocessed file |