Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/types/qqmlobjectmodel.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||
7 | QHash<QObject*, QQmlObjectModelAttached*> QQmlObjectModelAttached::attachedProperties; | - | ||||||||||||||||||||||||
8 | - | |||||||||||||||||||||||||
9 | - | |||||||||||||||||||||||||
10 | class QQmlObjectModelPrivate : public QObjectPrivate | - | ||||||||||||||||||||||||
11 | { | - | ||||||||||||||||||||||||
12 | inline QQmlObjectModel* q_func() { return static_cast<QQmlObjectModel *>(q_ptr); } inline const QQmlObjectModel* q_func() const { return static_cast<const QQmlObjectModel *>(q_ptr); } friend class QQmlObjectModel; | - | ||||||||||||||||||||||||
13 | public: | - | ||||||||||||||||||||||||
14 | class Item { | - | ||||||||||||||||||||||||
15 | public: | - | ||||||||||||||||||||||||
16 | Item(QObject *i) : item(i), ref(0) {} executed 154 times by 6 tests: end of block Executed by:
| 154 | ||||||||||||||||||||||||
17 | - | |||||||||||||||||||||||||
18 | void addRef() { ++ref; } executed 384 times by 5 tests: end of block Executed by:
| 384 | ||||||||||||||||||||||||
19 | bool deref() { return executed 258 times by 5 tests: --ref == 0;return --ref == 0; Executed by:
executed 258 times by 5 tests: }return --ref == 0; Executed by:
| 258 | ||||||||||||||||||||||||
20 | - | |||||||||||||||||||||||||
21 | QObject *item; | - | ||||||||||||||||||||||||
22 | int ref; | - | ||||||||||||||||||||||||
23 | }; | - | ||||||||||||||||||||||||
24 | - | |||||||||||||||||||||||||
25 | QQmlObjectModelPrivate() : QObjectPrivate(), moveId(0) {} executed 52 times by 7 tests: end of block Executed by:
| 52 | ||||||||||||||||||||||||
26 | - | |||||||||||||||||||||||||
27 | static void children_append(QQmlListProperty<QObject> *prop, QObject *item) { | - | ||||||||||||||||||||||||
28 | int index = static_cast<QQmlObjectModelPrivate *>(prop->data)->children.count(); | - | ||||||||||||||||||||||||
29 | static_cast<QQmlObjectModelPrivate *>(prop->data)->insert(index, item); | - | ||||||||||||||||||||||||
30 | } executed 138 times by 5 tests: end of block Executed by:
| 138 | ||||||||||||||||||||||||
31 | - | |||||||||||||||||||||||||
32 | static int children_count(QQmlListProperty<QObject> *prop) { | - | ||||||||||||||||||||||||
33 | return executed 26 times by 1 test: static_cast<QQmlObjectModelPrivate *>(prop->data)->children.count();return static_cast<QQmlObjectModelPrivate *>(prop->data)->children.count(); Executed by:
executed 26 times by 1 test: return static_cast<QQmlObjectModelPrivate *>(prop->data)->children.count(); Executed by:
| 26 | ||||||||||||||||||||||||
34 | } | - | ||||||||||||||||||||||||
35 | - | |||||||||||||||||||||||||
36 | static QObject *children_at(QQmlListProperty<QObject> *prop, int index) { | - | ||||||||||||||||||||||||
37 | return executed 6 times by 1 test: static_cast<QQmlObjectModelPrivate *>(prop->data)->children.at(index).item;return static_cast<QQmlObjectModelPrivate *>(prop->data)->children.at(index).item; Executed by:
executed 6 times by 1 test: return static_cast<QQmlObjectModelPrivate *>(prop->data)->children.at(index).item; Executed by:
| 6 | ||||||||||||||||||||||||
38 | } | - | ||||||||||||||||||||||||
39 | - | |||||||||||||||||||||||||
40 | static void children_clear(QQmlListProperty<QObject> *prop) { | - | ||||||||||||||||||||||||
41 | static_cast<QQmlObjectModelPrivate *>(prop->data)->clear(); | - | ||||||||||||||||||||||||
42 | } never executed: end of block | 0 | ||||||||||||||||||||||||
43 | - | |||||||||||||||||||||||||
44 | void insert(int index, QObject *item) { | - | ||||||||||||||||||||||||
45 | QQmlObjectModel * const q = q_func(); | - | ||||||||||||||||||||||||
46 | children.insert(index, Item(item)); | - | ||||||||||||||||||||||||
47 | for (int i = index; i < children.count()
| 154-174 | ||||||||||||||||||||||||
48 | QQmlObjectModelAttached *attached = QQmlObjectModelAttached::properties(children.at(i).item); | - | ||||||||||||||||||||||||
49 | attached->setIndex(i); | - | ||||||||||||||||||||||||
50 | } executed 174 times by 6 tests: end of block Executed by:
| 174 | ||||||||||||||||||||||||
51 | QQmlChangeSet changeSet; | - | ||||||||||||||||||||||||
52 | changeSet.insert(index, 1); | - | ||||||||||||||||||||||||
53 | q->modelUpdated(changeSet, false); | - | ||||||||||||||||||||||||
54 | q->countChanged(); | - | ||||||||||||||||||||||||
55 | q->childrenChanged(); | - | ||||||||||||||||||||||||
56 | } executed 154 times by 6 tests: end of block Executed by:
| 154 | ||||||||||||||||||||||||
57 | - | |||||||||||||||||||||||||
58 | void move(int from, int to, int n) { | - | ||||||||||||||||||||||||
59 | QQmlObjectModel * const q = q_func(); | - | ||||||||||||||||||||||||
60 | if (from > to
| 2-8 | ||||||||||||||||||||||||
61 | - | |||||||||||||||||||||||||
62 | int tfrom = from; | - | ||||||||||||||||||||||||
63 | int tto = to; | - | ||||||||||||||||||||||||
64 | from = tto; | - | ||||||||||||||||||||||||
65 | to = tto+n; | - | ||||||||||||||||||||||||
66 | n = tfrom-tto; | - | ||||||||||||||||||||||||
67 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
68 | - | |||||||||||||||||||||||||
69 | QPODVector<QQmlObjectModelPrivate::Item, 4> store; | - | ||||||||||||||||||||||||
70 | for (int i = 0; i < to - from
| 10 | ||||||||||||||||||||||||
71 | store.append(children[from + n + i]); executed 10 times by 4 tests: store.append(children[from + n + i]); Executed by:
| 10 | ||||||||||||||||||||||||
72 | for (int i = 0; i < n
| 10-18 | ||||||||||||||||||||||||
73 | store.append(children[from + i]); executed 18 times by 4 tests: store.append(children[from + i]); Executed by:
| 18 | ||||||||||||||||||||||||
74 | - | |||||||||||||||||||||||||
75 | for (int i = 0; i < store.count()
| 10-28 | ||||||||||||||||||||||||
76 | children[from + i] = store[i]; | - | ||||||||||||||||||||||||
77 | QQmlObjectModelAttached *attached = QQmlObjectModelAttached::properties(children.at(from + i).item); | - | ||||||||||||||||||||||||
78 | attached->setIndex(from + i); | - | ||||||||||||||||||||||||
79 | } executed 28 times by 4 tests: end of block Executed by:
| 28 | ||||||||||||||||||||||||
80 | - | |||||||||||||||||||||||||
81 | QQmlChangeSet changeSet; | - | ||||||||||||||||||||||||
82 | changeSet.move(from, to, n, ++moveId); | - | ||||||||||||||||||||||||
83 | q->modelUpdated(changeSet, false); | - | ||||||||||||||||||||||||
84 | q->childrenChanged(); | - | ||||||||||||||||||||||||
85 | } executed 10 times by 4 tests: end of block Executed by:
| 10 | ||||||||||||||||||||||||
86 | - | |||||||||||||||||||||||||
87 | void remove(int index, int n) { | - | ||||||||||||||||||||||||
88 | QQmlObjectModel * const q = q_func(); | - | ||||||||||||||||||||||||
89 | for (int i = index; i < index + n
| 14-28 | ||||||||||||||||||||||||
90 | QQmlObjectModelAttached *attached = QQmlObjectModelAttached::properties(children.at(i).item); | - | ||||||||||||||||||||||||
91 | attached->setIndex(-1); | - | ||||||||||||||||||||||||
92 | } executed 28 times by 3 tests: end of block Executed by:
| 28 | ||||||||||||||||||||||||
93 | children.erase(children.begin() + index, children.begin() + index + n); | - | ||||||||||||||||||||||||
94 | for (int i = index; i < children.count()
| 10-14 | ||||||||||||||||||||||||
95 | QQmlObjectModelAttached *attached = QQmlObjectModelAttached::properties(children.at(i).item); | - | ||||||||||||||||||||||||
96 | attached->setIndex(i); | - | ||||||||||||||||||||||||
97 | } executed 10 times by 3 tests: end of block Executed by:
| 10 | ||||||||||||||||||||||||
98 | QQmlChangeSet changeSet; | - | ||||||||||||||||||||||||
99 | changeSet.remove(index, n); | - | ||||||||||||||||||||||||
100 | q->modelUpdated(changeSet, false); | - | ||||||||||||||||||||||||
101 | q->countChanged(); | - | ||||||||||||||||||||||||
102 | q->childrenChanged(); | - | ||||||||||||||||||||||||
103 | } executed 14 times by 3 tests: end of block Executed by:
| 14 | ||||||||||||||||||||||||
104 | - | |||||||||||||||||||||||||
105 | void clear() { | - | ||||||||||||||||||||||||
106 | QQmlObjectModel * const q = q_func(); | - | ||||||||||||||||||||||||
107 | for (const Item &child : qAsConst(children)) | - | ||||||||||||||||||||||||
108 | q->destroyingItem(child.item); executed 16 times by 3 tests: q->destroyingItem(child.item); Executed by:
| 16 | ||||||||||||||||||||||||
109 | remove(0, children.count()); | - | ||||||||||||||||||||||||
110 | } executed 6 times by 3 tests: end of block Executed by:
| 6 | ||||||||||||||||||||||||
111 | - | |||||||||||||||||||||||||
112 | int indexOf(QObject *item) const { | - | ||||||||||||||||||||||||
113 | for (int i = 0; i < children.count()
| 34-3518 | ||||||||||||||||||||||||
114 | if (children.at(i).item == item
| 1754-1764 | ||||||||||||||||||||||||
115 | return executed 1754 times by 5 tests: i;return i; Executed by:
executed 1754 times by 5 tests: return i; Executed by:
| 1754 | ||||||||||||||||||||||||
116 | return executed 34 times by 2 tests: -1;return -1; Executed by:
executed 34 times by 2 tests: return -1; Executed by:
| 34 | ||||||||||||||||||||||||
117 | } | - | ||||||||||||||||||||||||
118 | - | |||||||||||||||||||||||||
119 | uint moveId; | - | ||||||||||||||||||||||||
120 | QList<Item> children; | - | ||||||||||||||||||||||||
121 | }; | - | ||||||||||||||||||||||||
122 | QQmlObjectModel::QQmlObjectModel(QObject *parent) | - | ||||||||||||||||||||||||
123 | : QQmlInstanceModel(*(new QQmlObjectModelPrivate), parent) | - | ||||||||||||||||||||||||
124 | { | - | ||||||||||||||||||||||||
125 | } executed 52 times by 7 tests: end of block Executed by:
| 52 | ||||||||||||||||||||||||
126 | QQmlListProperty<QObject> QQmlObjectModel::children() | - | ||||||||||||||||||||||||
127 | { | - | ||||||||||||||||||||||||
128 | QQmlObjectModelPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
129 | return executed 50 times by 5 tests: QQmlListProperty<QObject>(this,return QQmlListProperty<QObject>(this, d, d->children_append, d->children_count, d->children_at, d->children_clear); Executed by:
executed 50 times by 5 tests: return QQmlListProperty<QObject>(this, d, d->children_append, d->children_count, d->children_at, d->children_clear); Executed by:
| 50 | ||||||||||||||||||||||||
130 | d, executed 50 times by 5 tests: return QQmlListProperty<QObject>(this, d, d->children_append, d->children_count, d->children_at, d->children_clear); Executed by:
| 50 | ||||||||||||||||||||||||
131 | d->children_append, executed 50 times by 5 tests: return QQmlListProperty<QObject>(this, d, d->children_append, d->children_count, d->children_at, d->children_clear); Executed by:
| 50 | ||||||||||||||||||||||||
132 | d->children_count, executed 50 times by 5 tests: return QQmlListProperty<QObject>(this, d, d->children_append, d->children_count, d->children_at, d->children_clear); Executed by:
| 50 | ||||||||||||||||||||||||
133 | d->children_at, executed 50 times by 5 tests: return QQmlListProperty<QObject>(this, d, d->children_append, d->children_count, d->children_at, d->children_clear); Executed by:
| 50 | ||||||||||||||||||||||||
134 | d->children_clear); executed 50 times by 5 tests: return QQmlListProperty<QObject>(this, d, d->children_append, d->children_count, d->children_at, d->children_clear); Executed by:
| 50 | ||||||||||||||||||||||||
135 | } | - | ||||||||||||||||||||||||
136 | - | |||||||||||||||||||||||||
137 | - | |||||||||||||||||||||||||
138 | - | |||||||||||||||||||||||||
139 | - | |||||||||||||||||||||||||
140 | - | |||||||||||||||||||||||||
141 | - | |||||||||||||||||||||||||
142 | int QQmlObjectModel::count() const | - | ||||||||||||||||||||||||
143 | { | - | ||||||||||||||||||||||||
144 | const QQmlObjectModelPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
145 | return executed 4276 times by 6 tests: d->children.count();return d->children.count(); Executed by:
executed 4276 times by 6 tests: return d->children.count(); Executed by:
| 4276 | ||||||||||||||||||||||||
146 | } | - | ||||||||||||||||||||||||
147 | - | |||||||||||||||||||||||||
148 | bool QQmlObjectModel::isValid() const | - | ||||||||||||||||||||||||
149 | { | - | ||||||||||||||||||||||||
150 | return executed 1588 times by 5 tests: true;return true; Executed by:
executed 1588 times by 5 tests: return true; Executed by:
| 1588 | ||||||||||||||||||||||||
151 | } | - | ||||||||||||||||||||||||
152 | - | |||||||||||||||||||||||||
153 | QObject *QQmlObjectModel::object(int index, QQmlIncubator::IncubationMode) | - | ||||||||||||||||||||||||
154 | { | - | ||||||||||||||||||||||||
155 | QQmlObjectModelPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
156 | QQmlObjectModelPrivate::Item &item = d->children[index]; | - | ||||||||||||||||||||||||
157 | item.addRef(); | - | ||||||||||||||||||||||||
158 | if (item.ref == 1
| 156-228 | ||||||||||||||||||||||||
159 | initItem(index, item.item); | - | ||||||||||||||||||||||||
160 | createdItem(index, item.item); | - | ||||||||||||||||||||||||
161 | } executed 228 times by 5 tests: end of block Executed by:
| 228 | ||||||||||||||||||||||||
162 | return executed 384 times by 5 tests: item.item;return item.item; Executed by:
executed 384 times by 5 tests: return item.item; Executed by:
| 384 | ||||||||||||||||||||||||
163 | } | - | ||||||||||||||||||||||||
164 | - | |||||||||||||||||||||||||
165 | QQmlInstanceModel::ReleaseFlags QQmlObjectModel::release(QObject *item) | - | ||||||||||||||||||||||||
166 | { | - | ||||||||||||||||||||||||
167 | QQmlObjectModelPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
168 | int idx = d->indexOf(item); | - | ||||||||||||||||||||||||
169 | if (idx >= 0
| 22-258 | ||||||||||||||||||||||||
170 | if (!d->children[idx].deref()
| 128-130 | ||||||||||||||||||||||||
171 | return executed 128 times by 5 tests: QQmlInstanceModel::Referenced;return QQmlInstanceModel::Referenced; Executed by:
executed 128 times by 5 tests: return QQmlInstanceModel::Referenced; Executed by:
| 128 | ||||||||||||||||||||||||
172 | } executed 130 times by 5 tests: end of block Executed by:
| 130 | ||||||||||||||||||||||||
173 | return executed 152 times by 5 tests: nullptr;return nullptr; Executed by:
executed 152 times by 5 tests: return nullptr; Executed by:
| 152 | ||||||||||||||||||||||||
174 | } | - | ||||||||||||||||||||||||
175 | - | |||||||||||||||||||||||||
176 | QString QQmlObjectModel::stringValue(int index, const QString &name) | - | ||||||||||||||||||||||||
177 | { | - | ||||||||||||||||||||||||
178 | QQmlObjectModelPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
179 | if (index < 0
| 0 | ||||||||||||||||||||||||
180 | return never executed: QString();return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||
181 | return never executed: QQmlEngine::contextForObject(d->children.at(index).item)->contextProperty(name).toString();return QQmlEngine::contextForObject(d->children.at(index).item)->contextProperty(name).toString(); never executed: return QQmlEngine::contextForObject(d->children.at(index).item)->contextProperty(name).toString(); | 0 | ||||||||||||||||||||||||
182 | } | - | ||||||||||||||||||||||||
183 | - | |||||||||||||||||||||||||
184 | QQmlIncubator::Status QQmlObjectModel::incubationStatus(int) | - | ||||||||||||||||||||||||
185 | { | - | ||||||||||||||||||||||||
186 | return never executed: QQmlIncubator::Ready;return QQmlIncubator::Ready; never executed: return QQmlIncubator::Ready; | 0 | ||||||||||||||||||||||||
187 | } | - | ||||||||||||||||||||||||
188 | - | |||||||||||||||||||||||||
189 | int QQmlObjectModel::indexOf(QObject *item, QObject *) const | - | ||||||||||||||||||||||||
190 | { | - | ||||||||||||||||||||||||
191 | const QQmlObjectModelPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
192 | return executed 1508 times by 4 tests: d->indexOf(item);return d->indexOf(item); Executed by:
executed 1508 times by 4 tests: return d->indexOf(item); Executed by:
| 1508 | ||||||||||||||||||||||||
193 | } | - | ||||||||||||||||||||||||
194 | - | |||||||||||||||||||||||||
195 | QQmlObjectModelAttached *QQmlObjectModel::qmlAttachedProperties(QObject *obj) | - | ||||||||||||||||||||||||
196 | { | - | ||||||||||||||||||||||||
197 | return executed 52 times by 3 tests: QQmlObjectModelAttached::properties(obj);return QQmlObjectModelAttached::properties(obj); Executed by:
executed 52 times by 3 tests: return QQmlObjectModelAttached::properties(obj); Executed by:
| 52 | ||||||||||||||||||||||||
198 | } | - | ||||||||||||||||||||||||
199 | QObject *QQmlObjectModel::get(int index) const | - | ||||||||||||||||||||||||
200 | { | - | ||||||||||||||||||||||||
201 | const QQmlObjectModelPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
202 | if (index < 0
| 0-114 | ||||||||||||||||||||||||
203 | return never executed: nullptr;return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
204 | return executed 114 times by 3 tests: d->children.at(index).item;return d->children.at(index).item; Executed by:
executed 114 times by 3 tests: return d->children.at(index).item; Executed by:
| 114 | ||||||||||||||||||||||||
205 | } | - | ||||||||||||||||||||||||
206 | void QQmlObjectModel::append(QObject *object) | - | ||||||||||||||||||||||||
207 | { | - | ||||||||||||||||||||||||
208 | QQmlObjectModelPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
209 | d->insert(count(), object); | - | ||||||||||||||||||||||||
210 | } executed 8 times by 3 tests: end of block Executed by:
| 8 | ||||||||||||||||||||||||
211 | void QQmlObjectModel::insert(int index, QObject *object) | - | ||||||||||||||||||||||||
212 | { | - | ||||||||||||||||||||||||
213 | QQmlObjectModelPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
214 | if (index < 0
| 0-8 | ||||||||||||||||||||||||
215 | qmlWarning(this) << tr("insert: index %1 out of range").arg(index); | - | ||||||||||||||||||||||||
216 | return; never executed: return; | 0 | ||||||||||||||||||||||||
217 | } | - | ||||||||||||||||||||||||
218 | d->insert(index, object); | - | ||||||||||||||||||||||||
219 | } executed 8 times by 3 tests: end of block Executed by:
| 8 | ||||||||||||||||||||||||
220 | void QQmlObjectModel::move(int from, int to, int n) | - | ||||||||||||||||||||||||
221 | { | - | ||||||||||||||||||||||||
222 | QQmlObjectModelPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
223 | if (n <= 0
| 0-10 | ||||||||||||||||||||||||
224 | return; never executed: return; | 0 | ||||||||||||||||||||||||
225 | if (from < 0
| 0-10 | ||||||||||||||||||||||||
226 | qmlWarning(this) << tr("move: out of range"); | - | ||||||||||||||||||||||||
227 | return; never executed: return; | 0 | ||||||||||||||||||||||||
228 | } | - | ||||||||||||||||||||||||
229 | d->move(from, to, n); | - | ||||||||||||||||||||||||
230 | } executed 10 times by 4 tests: end of block Executed by:
| 10 | ||||||||||||||||||||||||
231 | void QQmlObjectModel::remove(int index, int n) | - | ||||||||||||||||||||||||
232 | { | - | ||||||||||||||||||||||||
233 | QQmlObjectModelPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
234 | if (index < 0
| 0-8 | ||||||||||||||||||||||||
235 | qmlWarning(this) << tr("remove: indices [%1 - %2] out of range [0 - %3]").arg(index).arg(index+n).arg(count()); | - | ||||||||||||||||||||||||
236 | return; never executed: return; | 0 | ||||||||||||||||||||||||
237 | } | - | ||||||||||||||||||||||||
238 | d->remove(index, n); | - | ||||||||||||||||||||||||
239 | } executed 8 times by 3 tests: end of block Executed by:
| 8 | ||||||||||||||||||||||||
240 | void QQmlObjectModel::clear() | - | ||||||||||||||||||||||||
241 | { | - | ||||||||||||||||||||||||
242 | QQmlObjectModelPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
243 | d->clear(); | - | ||||||||||||||||||||||||
244 | } executed 6 times by 3 tests: end of block Executed by:
| 6 | ||||||||||||||||||||||||
245 | - | |||||||||||||||||||||||||
246 | - | |||||||||||||||||||||||||
247 | - | |||||||||||||||||||||||||
Switch to Source code | Preprocessed file |