OpenCoverage

qqmllist.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/qml/qqmllist.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtQml module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qqmllist.h"-
41#include "qqmllist_p.h"-
42#include "qqmlengine_p.h"-
43#include "qqmlproperty_p.h"-
44-
45QT_BEGIN_NAMESPACE-
46-
47QQmlListReferencePrivate::QQmlListReferencePrivate()-
48: propertyType(-1), refCount(1)-
49{-
50}
executed 208 times by 16 tests: end of block
Executed by:
  • tst_examples
  • tst_multipointtoucharea_interop
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickdesignersupport
  • tst_qquickitem2
  • tst_qquickmultipointtoucharea
  • tst_qquickpath
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickshape
  • tst_qquickstates
  • tst_qquickvisualdatamodel
208
51-
52QQmlListReference QQmlListReferencePrivate::init(const QQmlListProperty<QObject> &prop, int propType, QQmlEngine *engine)-
53{-
54 QQmlListReference rv;-
55-
56 if (!prop.object) return rv;
never executed: return rv;
!prop.objectDescription
TRUEnever evaluated
FALSEevaluated 56 times by 9 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickitem2
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
0-56
57-
58 QQmlEnginePrivate *p = engine?QQmlEnginePrivate::get(engine):nullptr;
engineDescription
TRUEevaluated 52 times by 8 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • tst_qqmllistreference
  • tst_qquickitem2
4-52
59-
60 int listType = p?p->listType(propType):QQmlMetaType::listType(propType);
pDescription
TRUEevaluated 52 times by 8 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • tst_qqmllistreference
  • tst_qquickitem2
4-52
61 if (listType == -1) return rv;
never executed: return rv;
listType == -1Description
TRUEnever evaluated
FALSEevaluated 56 times by 9 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickitem2
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
0-56
62-
63 rv.d = new QQmlListReferencePrivate;-
64 rv.d->object = prop.object;-
65 rv.d->elementType = QQmlPropertyPrivate::rawMetaObjectForType(p, listType);-
66 rv.d->property = prop;-
67 rv.d->propertyType = propType;-
68-
69 return rv;
executed 56 times by 9 tests: return rv;
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickitem2
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
56
70}-
71-
72void QQmlListReferencePrivate::addref()-
73{-
74 Q_ASSERT(refCount > 0);-
75 ++refCount;-
76}
executed 78 times by 9 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickitem2
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
78
77-
78void QQmlListReferencePrivate::release()-
79{-
80 Q_ASSERT(refCount > 0);-
81 --refCount;-
82 if (!refCount)
!refCountDescription
TRUEevaluated 208 times by 16 tests
Evaluated by:
  • tst_examples
  • tst_multipointtoucharea_interop
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickdesignersupport
  • tst_qquickitem2
  • tst_qquickmultipointtoucharea
  • tst_qquickpath
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickshape
  • tst_qquickstates
  • tst_qquickvisualdatamodel
FALSEevaluated 78 times by 9 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickitem2
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
78-208
83 delete this;
executed 208 times by 16 tests: delete this;
Executed by:
  • tst_examples
  • tst_multipointtoucharea_interop
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickdesignersupport
  • tst_qquickitem2
  • tst_qquickmultipointtoucharea
  • tst_qquickpath
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickshape
  • tst_qquickstates
  • tst_qquickvisualdatamodel
208
84}
executed 286 times by 16 tests: end of block
Executed by:
  • tst_examples
  • tst_multipointtoucharea_interop
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickdesignersupport
  • tst_qquickitem2
  • tst_qquickmultipointtoucharea
  • tst_qquickpath
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickshape
  • tst_qquickstates
  • tst_qquickvisualdatamodel
286
85-
86/*!-
87\class QQmlListReference-
88\since 5.0-
89\inmodule QtQml-
90\brief The QQmlListReference class allows the manipulation of QQmlListProperty properties.-
91-
92QQmlListReference allows C++ programs to read from, and assign values to a QML list property in a-
93simple and type-safe way. A QQmlListReference can be created by passing an object and property-
94name or through a QQmlProperty instance. These two are equivalent:-
95-
96\code-
97QQmlListReference ref1(object, "children");-
98-
99QQmlProperty ref2(object, "children");-
100QQmlListReference ref2 = qvariant_cast<QQmlListReference>(ref2.read());-
101\endcode-
102-
103Not all QML list properties support all operations. A set of methods, canAppend(), canAt(), canClear() and-
104canCount() allow programs to query whether an operation is supported on a given property.-
105-
106QML list properties are type-safe. Only QObject's that derive from the correct base class can be assigned to-
107the list. The listElementType() method can be used to query the QMetaObject of the QObject type supported.-
108Attempting to add objects of the incorrect type to a list property will fail.-
109-
110Like with normal lists, when accessing a list element by index, it is the callers responsibility to ensure-
111that it does not request an out of range element using the count() method before calling at().-
112-
113The \l {Qt Quick 1} version of this class is named QDeclarativeListReference.-
114*/-
115-
116/*!-
117Constructs an invalid instance.-
118*/-
119QQmlListReference::QQmlListReference()-
120: d(nullptr)-
121{-
122}
executed 86 times by 9 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickitem2
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
86
123-
124/*!-
125Constructs a QQmlListReference for \a object's \a property. If \a property is not a list-
126property, an invalid QQmlListReference is created. If \a object is destroyed after-
127the reference is constructed, it will automatically become invalid. That is, it is safe to hold-
128QQmlListReference instances even after \a object is deleted.-
129-
130Passing \a engine is required to access some QML created list properties. If in doubt, and an engine-
131is available, pass it.-
132*/-
133QQmlListReference::QQmlListReference(QObject *object, const char *property, QQmlEngine *engine)-
134: d(nullptr)-
135{-
136 if (!object || !property) return;
never executed: return;
!objectDescription
TRUEnever evaluated
FALSEevaluated 182 times by 9 tests
Evaluated by:
  • tst_multipointtoucharea_interop
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickdesignersupport
  • tst_qquickmultipointtoucharea
  • tst_qquickpath
  • tst_qquickpathview
  • tst_qquickshape
  • tst_qquickstates
!propertyDescription
TRUEnever evaluated
FALSEevaluated 182 times by 9 tests
Evaluated by:
  • tst_multipointtoucharea_interop
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickdesignersupport
  • tst_qquickmultipointtoucharea
  • tst_qquickpath
  • tst_qquickpathview
  • tst_qquickshape
  • tst_qquickstates
0-182
137-
138 QQmlPropertyData local;-
139 QQmlPropertyData *data =-
140 QQmlPropertyCache::property(engine, object, QLatin1String(property), nullptr, local);-
141-
142 if (!data || !data->isQList()) return;
executed 30 times by 1 test: return;
Executed by:
  • tst_qqmllistreference
!dataDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_qqmllistreference
FALSEevaluated 154 times by 9 tests
Evaluated by:
  • tst_multipointtoucharea_interop
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickdesignersupport
  • tst_qquickmultipointtoucharea
  • tst_qquickpath
  • tst_qquickpathview
  • tst_qquickshape
  • tst_qquickstates
!data->isQList()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistreference
FALSEevaluated 152 times by 9 tests
Evaluated by:
  • tst_multipointtoucharea_interop
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickdesignersupport
  • tst_qquickmultipointtoucharea
  • tst_qquickpath
  • tst_qquickpathview
  • tst_qquickshape
  • tst_qquickstates
2-154
143-
144 QQmlEnginePrivate *p = engine?QQmlEnginePrivate::get(engine):nullptr;
engineDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qqmlproperty
FALSEevaluated 146 times by 9 tests
Evaluated by:
  • tst_multipointtoucharea_interop
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickdesignersupport
  • tst_qquickmultipointtoucharea
  • tst_qquickpath
  • tst_qquickpathview
  • tst_qquickshape
  • tst_qquickstates
6-146
145-
146 int listType = p?p->listType(data->propType()):QQmlMetaType::listType(data->propType());
pDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qqmlproperty
FALSEevaluated 146 times by 9 tests
Evaluated by:
  • tst_multipointtoucharea_interop
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickdesignersupport
  • tst_qquickmultipointtoucharea
  • tst_qquickpath
  • tst_qquickpathview
  • tst_qquickshape
  • tst_qquickstates
6-146
147 if (listType == -1) return;
never executed: return;
listType == -1Description
TRUEnever evaluated
FALSEevaluated 152 times by 9 tests
Evaluated by:
  • tst_multipointtoucharea_interop
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickdesignersupport
  • tst_qquickmultipointtoucharea
  • tst_qquickpath
  • tst_qquickpathview
  • tst_qquickshape
  • tst_qquickstates
0-152
148-
149 d = new QQmlListReferencePrivate;-
150 d->object = object;-
151 d->elementType = p ? p->rawMetaObjectForType(listType) : QQmlMetaType::qmlType(listType).baseMetaObject();
pDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qqmlproperty
FALSEevaluated 146 times by 9 tests
Evaluated by:
  • tst_multipointtoucharea_interop
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickdesignersupport
  • tst_qquickmultipointtoucharea
  • tst_qquickpath
  • tst_qquickpathview
  • tst_qquickshape
  • tst_qquickstates
6-146
152 d->propertyType = data->propType();-
153-
154 void *args[] = { &d->property, nullptr };-
155 QMetaObject::metacall(object, QMetaObject::ReadProperty, data->coreIndex(), args);-
156}
executed 152 times by 9 tests: end of block
Executed by:
  • tst_multipointtoucharea_interop
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickdesignersupport
  • tst_qquickmultipointtoucharea
  • tst_qquickpath
  • tst_qquickpathview
  • tst_qquickshape
  • tst_qquickstates
152
157-
158/*! \internal */-
159QQmlListReference::QQmlListReference(const QQmlListReference &o)-
160: d(o.d)-
161{-
162 if (d) d->addref();
executed 76 times by 9 tests: d->addref();
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickitem2
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
dDescription
TRUEevaluated 76 times by 9 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickitem2
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
FALSEnever evaluated
0-76
163}
executed 76 times by 9 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickitem2
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
76
164-
165/*! \internal */-
166QQmlListReference &QQmlListReference::operator=(const QQmlListReference &o)-
167{-
168 if (o.d) o.d->addref();
executed 2 times by 1 test: o.d->addref();
Executed by:
  • tst_qqmllistreference
o.dDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistreference
FALSEnever evaluated
0-2
169 if (d) d->release();
never executed: d->release();
dDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistreference
0-2
170 d = o.d;-
171 return *this;
executed 2 times by 1 test: return *this;
Executed by:
  • tst_qqmllistreference
2
172}-
173-
174/*! \internal */-
175QQmlListReference::~QQmlListReference()-
176{-
177 if (d) d->release();
executed 286 times by 16 tests: d->release();
Executed by:
  • tst_examples
  • tst_multipointtoucharea_interop
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickdesignersupport
  • tst_qquickitem2
  • tst_qquickmultipointtoucharea
  • tst_qquickpath
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickshape
  • tst_qquickstates
  • tst_qquickvisualdatamodel
dDescription
TRUEevaluated 286 times by 16 tests
Evaluated by:
  • tst_examples
  • tst_multipointtoucharea_interop
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickdesignersupport
  • tst_qquickitem2
  • tst_qquickmultipointtoucharea
  • tst_qquickpath
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickshape
  • tst_qquickstates
  • tst_qquickvisualdatamodel
FALSEevaluated 58 times by 1 test
Evaluated by:
  • tst_qqmllistreference
58-286
178}
executed 344 times by 16 tests: end of block
Executed by:
  • tst_examples
  • tst_multipointtoucharea_interop
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickdesignersupport
  • tst_qquickitem2
  • tst_qquickmultipointtoucharea
  • tst_qquickpath
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickshape
  • tst_qquickstates
  • tst_qquickvisualdatamodel
344
179-
180/*!-
181Returns true if the instance refers to a valid list property, otherwise false.-
182*/-
183bool QQmlListReference::isValid() const-
184{-
185 return d && d->object;
executed 3194 times by 15 tests: return d && d->object;
Executed by:
  • tst_examples
  • tst_multipointtoucharea_interop
  • tst_qqmlecmascript
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickdesignersupport
  • tst_qquickitem2
  • tst_qquickmultipointtoucharea
  • tst_qquickpath
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickshape
  • tst_qquickstates
  • tst_qquickvisualdatamodel
3194
186}-
187-
188/*!-
189Returns the list property's object. Returns 0 if the reference is invalid.-
190*/-
191QObject *QQmlListReference::object() const-
192{-
193 if (isValid()) return d->object;
executed 26 times by 5 tests: return d->object;
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistreference
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
isValid()Description
TRUEevaluated 26 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistreference
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qqmllistreference
12-26
194 else return nullptr;
executed 12 times by 1 test: return nullptr;
Executed by:
  • tst_qqmllistreference
12
195}-
196-
197/*!-
198Returns the QMetaObject for the elements stored in the list property. Returns 0 if the reference-
199is invalid.-
200-
201The QMetaObject can be used ahead of time to determine whether a given instance can be added-
202to a list.-
203*/-
204const QMetaObject *QQmlListReference::listElementType() const-
205{-
206 if (isValid()) return d->elementType.metaObject();
executed 8 times by 1 test: return d->elementType.metaObject();
Executed by:
  • tst_qqmllistreference
isValid()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qqmllistreference
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qqmllistreference
8-12
207 else return nullptr;
executed 12 times by 1 test: return nullptr;
Executed by:
  • tst_qqmllistreference
12
208}-
209-
210/*!-
211Returns true if the list property can be appended to, otherwise false. Returns false if the-
212reference is invalid.-
213-
214\sa append()-
215*/-
216bool QQmlListReference::canAppend() const-
217{-
218 return (isValid() && d->property.append);
executed 30 times by 1 test: return (isValid() && d->property.append);
Executed by:
  • tst_qqmllistreference
30
219}-
220-
221/*!-
222Returns true if the list property can queried by index, otherwise false. Returns false if the-
223reference is invalid.-
224-
225\sa at()-
226*/-
227bool QQmlListReference::canAt() const-
228{-
229 return (isValid() && d->property.at);
executed 852 times by 13 tests: return (isValid() && d->property.at);
Executed by:
  • tst_examples
  • tst_multipointtoucharea_interop
  • tst_qqmlecmascript
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickdesignersupport
  • tst_qquickpath
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickshape
  • tst_qquickstates
  • tst_qquickvisualdatamodel
852
230}-
231-
232/*!-
233Returns true if the list property can be cleared, otherwise false. Returns false if the-
234reference is invalid.-
235-
236\sa clear()-
237*/-
238bool QQmlListReference::canClear() const-
239{-
240 return (isValid() && d->property.clear);
executed 32 times by 1 test: return (isValid() && d->property.clear);
Executed by:
  • tst_qqmllistreference
32
241}-
242-
243/*!-
244Returns true if the list property can be queried for its element count, otherwise false.-
245Returns false if the reference is invalid.-
246-
247\sa count()-
248*/-
249bool QQmlListReference::canCount() const-
250{-
251 return (isValid() && d->property.count);
executed 2160 times by 13 tests: return (isValid() && d->property.count);
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickdesignersupport
  • tst_qquickitem2
  • tst_qquickmultipointtoucharea
  • tst_qquickpath
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickshape
  • tst_qquickvisualdatamodel
2160
252}-
253-
254/*!-
255 Return true if at(), count(), append() and clear() are implemented, so you can manipulate-
256 the list.-
257-
258\sa isReadable(), at(), count(), append(), clear()-
259*/-
260bool QQmlListReference::isManipulable() const-
261{-
262 return (isValid()
executed 16 times by 1 test: return (isValid() && d->property.append && d->property.count && d->property.at && d->property.clear);
Executed by:
  • tst_qqmllistreference
16
263 && d->property.append
executed 16 times by 1 test: return (isValid() && d->property.append && d->property.count && d->property.at && d->property.clear);
Executed by:
  • tst_qqmllistreference
16
264 && d->property.count
executed 16 times by 1 test: return (isValid() && d->property.append && d->property.count && d->property.at && d->property.clear);
Executed by:
  • tst_qqmllistreference
16
265 && d->property.at
executed 16 times by 1 test: return (isValid() && d->property.append && d->property.count && d->property.at && d->property.clear);
Executed by:
  • tst_qqmllistreference
16
266 && d->property.clear);
executed 16 times by 1 test: return (isValid() && d->property.append && d->property.count && d->property.at && d->property.clear);
Executed by:
  • tst_qqmllistreference
16
267}-
268-
269-
270/*!-
271 Return true if at() and count() are implemented, so you can access the elements.-
272-
273\sa isManipulable(), at(), count()-
274*/-
275bool QQmlListReference::isReadable() const-
276{-
277 return (isValid() && d->property.count && d->property.at);
executed 16 times by 1 test: return (isValid() && d->property.count && d->property.at);
Executed by:
  • tst_qqmllistreference
16
278}-
279-
280/*!-
281Appends \a object to the list. Returns true if the operation succeeded, otherwise false.-
282-
283\sa canAppend()-
284*/-
285bool QQmlListReference::append(QObject *object) const-
286{-
287 if (!canAppend()) return false;
executed 14 times by 1 test: return false;
Executed by:
  • tst_qqmllistreference
!canAppend()Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qqmllistreference
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qqmllistreference
6-14
288-
289 if (object && !QQmlMetaObject::canConvert(object, d->elementType))
objectDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmllistreference
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistreference
!QQmlMetaObjec...->elementType)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistreference
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistreference
2-4
290 return false;
executed 2 times by 1 test: return false;
Executed by:
  • tst_qqmllistreference
2
291-
292 d->property.append(&d->property, object);-
293-
294 return true;
executed 4 times by 1 test: return true;
Executed by:
  • tst_qqmllistreference
4
295}-
296-
297/*!-
298Returns the list element at \a index, or 0 if the operation failed.-
299-
300\sa canAt()-
301*/-
302QObject *QQmlListReference::at(int index) const-
303{-
304 if (!canAt()) return nullptr;
executed 14 times by 1 test: return nullptr;
Executed by:
  • tst_qqmllistreference
!canAt()Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qqmllistreference
FALSEevaluated 762 times by 12 tests
Evaluated by:
  • tst_examples
  • tst_multipointtoucharea_interop
  • tst_qqmlecmascript
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickpath
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickshape
  • tst_qquickstates
  • tst_qquickvisualdatamodel
14-762
305-
306 return d->property.at(&d->property, index);
executed 762 times by 12 tests: return d->property.at(&d->property, index);
Executed by:
  • tst_examples
  • tst_multipointtoucharea_interop
  • tst_qqmlecmascript
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickpath
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickshape
  • tst_qquickstates
  • tst_qquickvisualdatamodel
762
307}-
308-
309/*!-
310Clears the list. Returns true if the operation succeeded, otherwise false.-
311-
312\sa canClear()-
313*/-
314bool QQmlListReference::clear() const-
315{-
316 if (!canClear()) return false;
executed 14 times by 1 test: return false;
Executed by:
  • tst_qqmllistreference
!canClear()Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qqmllistreference
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmllistreference
2-14
317-
318 d->property.clear(&d->property);-
319-
320 return true;
executed 2 times by 1 test: return true;
Executed by:
  • tst_qqmllistreference
2
321}-
322-
323/*!-
324Returns the number of objects in the list, or 0 if the operation failed.-
325*/-
326int QQmlListReference::count() const-
327{-
328 if (!canCount()) return 0;
executed 14 times by 1 test: return 0;
Executed by:
  • tst_qqmllistreference
!canCount()Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qqmllistreference
FALSEevaluated 2070 times by 13 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickdesignersupport
  • tst_qquickitem2
  • tst_qquickmultipointtoucharea
  • tst_qquickpath
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickshape
  • tst_qquickvisualdatamodel
14-2070
329-
330 return d->property.count(&d->property);
executed 2070 times by 13 tests: return d->property.count(&d->property);
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistreference
  • tst_qqmlproperty
  • tst_qquickanimations
  • tst_qquickdesignersupport
  • tst_qquickitem2
  • tst_qquickmultipointtoucharea
  • tst_qquickpath
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qquickshape
  • tst_qquickvisualdatamodel
2070
331}-
332-
333/*!-
334\class QQmlListProperty-
335\since 5.0-
336\inmodule QtQml-
337\brief The QQmlListProperty class allows applications to expose list-like-
338properties of QObject-derived classes to QML.-
339-
340QML has many list properties, where more than one object value can be assigned.-
341The use of a list property from QML looks like this:-
342-
343\code-
344FruitBasket {-
345 fruit: [-
346 Apple {},-
347 Orange{},-
348 Banana{}-
349 ]-
350}-
351\endcode-
352-
353The QQmlListProperty encapsulates a group of function pointers that represent the-
354set of actions QML can perform on the list - adding items, retrieving items and-
355clearing the list. In the future, additional operations may be supported. All-
356list properties must implement the append operation, but the rest are optional.-
357-
358To provide a list property, a C++ class must implement the operation callbacks,-
359and then return an appropriate QQmlListProperty value from the property getter.-
360List properties should have no setter. In the example above, the Q_PROPERTY()-
361declarative will look like this:-
362-
363\code-
364Q_PROPERTY(QQmlListProperty<Fruit> fruit READ fruit);-
365\endcode-
366-
367QML list properties are type-safe - in this case \c {Fruit} is a QObject type that-
368\c {Apple}, \c {Orange} and \c {Banana} all derive from.-
369-
370The \l {Qt Quick 1} version of this class is named QDeclarativeListProperty.-
371-
372\sa {Extending QML - Object and List Property Types Example}-
373-
374*/-
375-
376/*!-
377\fn template<typename T> QQmlListProperty<T>::QQmlListProperty()-
378\internal-
379*/-
380-
381/*!-
382\fn template<typename T> QQmlListProperty<T>::QQmlListProperty(QObject *object, QList<T *> &list)-
383-
384Convenience constructor for making a QQmlListProperty value from an existing-
385QList \a list. The \a list reference must remain valid for as long as \a object-
386exists. \a object must be provided.-
387-
388Generally this constructor should not be used in production code, as a-
389writable QList violates QML's memory management rules. However, this constructor-
390can be very useful while prototyping.-
391*/-
392-
393/*!-
394\fn template<typename T> QQmlListProperty<T>::QQmlListProperty(QObject *object, void *data,-
395 CountFunction count, AtFunction at)-
396-
397Construct a readonly QQmlListProperty from a set of operation functions-
398\a count and \a at. An opaque \a data handle may be passed which can be-
399accessed from within the operation functions. The list property-
400remains valid while \a object exists.-
401*/-
402-
403/*!-
404\fn template<typename T> QQmlListProperty<T>::QQmlListProperty(QObject *object, void *data, AppendFunction append,-
405 CountFunction count, AtFunction at,-
406 ClearFunction clear)-
407-
408Construct a QQmlListProperty from a set of operation functions \a append,-
409\a count, \a at, and \a clear. An opaque \a data handle may be passed which-
410can be accessed from within the operation functions. The list property-
411remains valid while \a object exists.-
412-
413Null pointers can be passed for any function. If any null pointers are passed in, the list-
414will be neither designable nor alterable by the debugger. It is recommended to provide valid-
415pointers for all functions.-
416*/-
417-
418/*!-
419\typedef QQmlListProperty::AppendFunction-
420-
421Synonym for \c {void (*)(QQmlListProperty<T> *property, T *value)}.-
422-
423Append the \a value to the list \a property.-
424*/-
425-
426/*!-
427\typedef QQmlListProperty::CountFunction-
428-
429Synonym for \c {int (*)(QQmlListProperty<T> *property)}.-
430-
431Return the number of elements in the list \a property.-
432*/-
433-
434/*!-
435\fn template<typename T> bool QQmlListProperty<T>::operator==(const QQmlListProperty &other) const-
436-
437Returns true if this QQmlListProperty is equal to \a other, otherwise false.-
438*/-
439-
440/*!-
441\typedef QQmlListProperty::AtFunction-
442-
443Synonym for \c {T *(*)(QQmlListProperty<T> *property, int index)}.-
444-
445Return the element at position \a index in the list \a property.-
446*/-
447-
448/*!-
449\typedef QQmlListProperty::ClearFunction-
450-
451Synonym for \c {void (*)(QQmlListProperty<T> *property)}.-
452-
453Clear the list \a property.-
454*/-
455-
456QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0