Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/types/qqmlbind.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | - | |||||||||||||||||||
5 | - | |||||||||||||||||||
6 | - | |||||||||||||||||||
7 | - | |||||||||||||||||||
8 | class QQmlBindPrivate : public QObjectPrivate | - | ||||||||||||||||||
9 | { | - | ||||||||||||||||||
10 | public: | - | ||||||||||||||||||
11 | QQmlBindPrivate() : obj(nullptr), componentComplete(true), delayed(false), pendingEval(false) {} executed 36 times by 4 tests: end of block Executed by:
| 36 | ||||||||||||||||||
12 | ~QQmlBindPrivate() { } | - | ||||||||||||||||||
13 | - | |||||||||||||||||||
14 | QQmlNullableValue<bool> when; | - | ||||||||||||||||||
15 | QPointer<QObject> obj; | - | ||||||||||||||||||
16 | QString propName; | - | ||||||||||||||||||
17 | QQmlNullableValue<QVariant> value; | - | ||||||||||||||||||
18 | QQmlProperty prop; | - | ||||||||||||||||||
19 | QQmlAbstractBinding::Ptr prevBind; | - | ||||||||||||||||||
20 | bool componentComplete:1; | - | ||||||||||||||||||
21 | bool delayed:1; | - | ||||||||||||||||||
22 | bool pendingEval:1; | - | ||||||||||||||||||
23 | - | |||||||||||||||||||
24 | void validate(QObject *binding) const; | - | ||||||||||||||||||
25 | }; | - | ||||||||||||||||||
26 | - | |||||||||||||||||||
27 | void QQmlBindPrivate::validate(QObject *binding) const | - | ||||||||||||||||||
28 | { | - | ||||||||||||||||||
29 | if (!obj
| 4-30 | ||||||||||||||||||
30 | return; executed 20 times by 2 tests: return; Executed by:
| 20 | ||||||||||||||||||
31 | - | |||||||||||||||||||
32 | if (!prop.isValid()
| 2-18 | ||||||||||||||||||
33 | qmlWarning(binding) << "Property '" << propName << "' does not exist on " << QQmlMetaType::prettyTypeName(obj) << "."; | - | ||||||||||||||||||
34 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||
35 | } | - | ||||||||||||||||||
36 | - | |||||||||||||||||||
37 | if (!prop.isWritable()
| 2-16 | ||||||||||||||||||
38 | qmlWarning(binding) << "Property '" << propName << "' on " << QQmlMetaType::prettyTypeName(obj) << " is read-only."; | - | ||||||||||||||||||
39 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||
40 | } | - | ||||||||||||||||||
41 | } executed 16 times by 3 tests: end of block Executed by:
| 16 | ||||||||||||||||||
42 | QQmlBind::QQmlBind(QObject *parent) | - | ||||||||||||||||||
43 | : QObject(*(new QQmlBindPrivate), parent) | - | ||||||||||||||||||
44 | { | - | ||||||||||||||||||
45 | } executed 36 times by 4 tests: end of block Executed by:
| 36 | ||||||||||||||||||
46 | - | |||||||||||||||||||
47 | QQmlBind::~QQmlBind() | - | ||||||||||||||||||
48 | { | - | ||||||||||||||||||
49 | } | - | ||||||||||||||||||
50 | bool QQmlBind::when() const | - | ||||||||||||||||||
51 | { | - | ||||||||||||||||||
52 | const QQmlBindPrivate * const d = d_func(); | - | ||||||||||||||||||
53 | return executed 4 times by 1 test: d->when;return d->when; Executed by:
executed 4 times by 1 test: return d->when; Executed by:
| 4 | ||||||||||||||||||
54 | } | - | ||||||||||||||||||
55 | - | |||||||||||||||||||
56 | void QQmlBind::setWhen(bool v) | - | ||||||||||||||||||
57 | { | - | ||||||||||||||||||
58 | QQmlBindPrivate * const d = d_func(); | - | ||||||||||||||||||
59 | if (!d->when.isNull
| 14-32 | ||||||||||||||||||
60 | return; executed 14 times by 1 test: return; Executed by:
| 14 | ||||||||||||||||||
61 | - | |||||||||||||||||||
62 | d->when = v; | - | ||||||||||||||||||
63 | if (v
| 0-22 | ||||||||||||||||||
64 | d->validate(this); executed 12 times by 1 test: d->validate(this); Executed by:
| 12 | ||||||||||||||||||
65 | eval(); | - | ||||||||||||||||||
66 | } executed 34 times by 1 test: end of block Executed by:
| 34 | ||||||||||||||||||
67 | - | |||||||||||||||||||
68 | - | |||||||||||||||||||
69 | - | |||||||||||||||||||
70 | - | |||||||||||||||||||
71 | - | |||||||||||||||||||
72 | - | |||||||||||||||||||
73 | QObject *QQmlBind::object() | - | ||||||||||||||||||
74 | { | - | ||||||||||||||||||
75 | const QQmlBindPrivate * const d = d_func(); | - | ||||||||||||||||||
76 | return executed 4 times by 1 test: d->obj;return d->obj; Executed by:
executed 4 times by 1 test: return d->obj; Executed by:
| 4 | ||||||||||||||||||
77 | } | - | ||||||||||||||||||
78 | - | |||||||||||||||||||
79 | void QQmlBind::setObject(QObject *obj) | - | ||||||||||||||||||
80 | { | - | ||||||||||||||||||
81 | QQmlBindPrivate * const d = d_func(); | - | ||||||||||||||||||
82 | if (d->obj && d->when.isValid()
| 0 | ||||||||||||||||||
83 | - | |||||||||||||||||||
84 | - | |||||||||||||||||||
85 | d->when = false; | - | ||||||||||||||||||
86 | eval(); | - | ||||||||||||||||||
87 | d->when = true; | - | ||||||||||||||||||
88 | } never executed: end of block | 0 | ||||||||||||||||||
89 | d->obj = obj; | - | ||||||||||||||||||
90 | if (d->componentComplete
| 0-26 | ||||||||||||||||||
91 | d->prop = QQmlProperty(d->obj, d->propName); | - | ||||||||||||||||||
92 | d->validate(this); | - | ||||||||||||||||||
93 | } never executed: end of block | 0 | ||||||||||||||||||
94 | eval(); | - | ||||||||||||||||||
95 | } executed 26 times by 3 tests: end of block Executed by:
| 26 | ||||||||||||||||||
96 | QString QQmlBind::property() const | - | ||||||||||||||||||
97 | { | - | ||||||||||||||||||
98 | const QQmlBindPrivate * const d = d_func(); | - | ||||||||||||||||||
99 | return executed 2 times by 1 test: d->propName;return d->propName; Executed by:
executed 2 times by 1 test: return d->propName; Executed by:
| 2 | ||||||||||||||||||
100 | } | - | ||||||||||||||||||
101 | - | |||||||||||||||||||
102 | void QQmlBind::setProperty(const QString &p) | - | ||||||||||||||||||
103 | { | - | ||||||||||||||||||
104 | QQmlBindPrivate * const d = d_func(); | - | ||||||||||||||||||
105 | if (!d->propName.isEmpty()
| 0-26 | ||||||||||||||||||
106 | - | |||||||||||||||||||
107 | - | |||||||||||||||||||
108 | d->when = false; | - | ||||||||||||||||||
109 | eval(); | - | ||||||||||||||||||
110 | d->when = true; | - | ||||||||||||||||||
111 | } never executed: end of block | 0 | ||||||||||||||||||
112 | d->propName = p; | - | ||||||||||||||||||
113 | if (d->componentComplete
| 0-26 | ||||||||||||||||||
114 | d->prop = QQmlProperty(d->obj, d->propName); | - | ||||||||||||||||||
115 | d->validate(this); | - | ||||||||||||||||||
116 | } never executed: end of block | 0 | ||||||||||||||||||
117 | eval(); | - | ||||||||||||||||||
118 | } executed 26 times by 3 tests: end of block Executed by:
| 26 | ||||||||||||||||||
119 | - | |||||||||||||||||||
120 | - | |||||||||||||||||||
121 | - | |||||||||||||||||||
122 | - | |||||||||||||||||||
123 | - | |||||||||||||||||||
124 | - | |||||||||||||||||||
125 | - | |||||||||||||||||||
126 | QVariant QQmlBind::value() const | - | ||||||||||||||||||
127 | { | - | ||||||||||||||||||
128 | const QQmlBindPrivate * const d = d_func(); | - | ||||||||||||||||||
129 | return executed 2 times by 1 test: d->value.value;return d->value.value; Executed by:
executed 2 times by 1 test: return d->value.value; Executed by:
| 2 | ||||||||||||||||||
130 | } | - | ||||||||||||||||||
131 | - | |||||||||||||||||||
132 | void QQmlBind::setValue(const QVariant &v) | - | ||||||||||||||||||
133 | { | - | ||||||||||||||||||
134 | QQmlBindPrivate * const d = d_func(); | - | ||||||||||||||||||
135 | d->value = v; | - | ||||||||||||||||||
136 | prepareEval(); | - | ||||||||||||||||||
137 | } executed 72 times by 3 tests: end of block Executed by:
| 72 | ||||||||||||||||||
138 | bool QQmlBind::delayed() const | - | ||||||||||||||||||
139 | { | - | ||||||||||||||||||
140 | const QQmlBindPrivate * const d = d_func(); | - | ||||||||||||||||||
141 | return never executed: d->delayed;return d->delayed; never executed: return d->delayed; | 0 | ||||||||||||||||||
142 | } | - | ||||||||||||||||||
143 | - | |||||||||||||||||||
144 | void QQmlBind::setDelayed(bool delayed) | - | ||||||||||||||||||
145 | { | - | ||||||||||||||||||
146 | QQmlBindPrivate * const d = d_func(); | - | ||||||||||||||||||
147 | if (d->delayed == delayed
| 0-2 | ||||||||||||||||||
148 | return; never executed: return; | 0 | ||||||||||||||||||
149 | - | |||||||||||||||||||
150 | d->delayed = delayed; | - | ||||||||||||||||||
151 | - | |||||||||||||||||||
152 | if (!d->delayed
| 0-2 | ||||||||||||||||||
153 | eval(); never executed: eval(); | 0 | ||||||||||||||||||
154 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
155 | - | |||||||||||||||||||
156 | void QQmlBind::setTarget(const QQmlProperty &p) | - | ||||||||||||||||||
157 | { | - | ||||||||||||||||||
158 | QQmlBindPrivate * const d = d_func(); | - | ||||||||||||||||||
159 | d->prop = p; | - | ||||||||||||||||||
160 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
161 | - | |||||||||||||||||||
162 | void QQmlBind::classBegin() | - | ||||||||||||||||||
163 | { | - | ||||||||||||||||||
164 | QQmlBindPrivate * const d = d_func(); | - | ||||||||||||||||||
165 | d->componentComplete = false; | - | ||||||||||||||||||
166 | } executed 36 times by 4 tests: end of block Executed by:
| 36 | ||||||||||||||||||
167 | - | |||||||||||||||||||
168 | void QQmlBind::componentComplete() | - | ||||||||||||||||||
169 | { | - | ||||||||||||||||||
170 | QQmlBindPrivate * const d = d_func(); | - | ||||||||||||||||||
171 | d->componentComplete = true; | - | ||||||||||||||||||
172 | if (!d->prop.isValid()
| 8-28 | ||||||||||||||||||
173 | d->prop = QQmlProperty(d->obj, d->propName); | - | ||||||||||||||||||
174 | d->validate(this); | - | ||||||||||||||||||
175 | } executed 28 times by 4 tests: end of block Executed by:
| 28 | ||||||||||||||||||
176 | eval(); | - | ||||||||||||||||||
177 | } executed 36 times by 4 tests: end of block Executed by:
| 36 | ||||||||||||||||||
178 | - | |||||||||||||||||||
179 | void QQmlBind::prepareEval() | - | ||||||||||||||||||
180 | { | - | ||||||||||||||||||
181 | QQmlBindPrivate * const d = d_func(); | - | ||||||||||||||||||
182 | if (d->delayed
| 6-66 | ||||||||||||||||||
183 | if (!d->pendingEval
| 2-4 | ||||||||||||||||||
184 | QTimer::singleShot(0, this, &QQmlBind::eval); executed 4 times by 1 test: QTimer::singleShot(0, this, &QQmlBind::eval); Executed by:
| 4 | ||||||||||||||||||
185 | d->pendingEval = true; | - | ||||||||||||||||||
186 | } executed 6 times by 1 test: else {end of block Executed by:
| 6 | ||||||||||||||||||
187 | eval(); | - | ||||||||||||||||||
188 | } executed 66 times by 3 tests: end of block Executed by:
| 66 | ||||||||||||||||||
189 | } | - | ||||||||||||||||||
190 | - | |||||||||||||||||||
191 | void QQmlBind::eval() | - | ||||||||||||||||||
192 | { | - | ||||||||||||||||||
193 | QQmlBindPrivate * const d = d_func(); | - | ||||||||||||||||||
194 | d->pendingEval = false; | - | ||||||||||||||||||
195 | if (!d->prop.isValid()
| 6-98 | ||||||||||||||||||
196 | return; executed 106 times by 4 tests: return; Executed by:
| 106 | ||||||||||||||||||
197 | - | |||||||||||||||||||
198 | if (d->when.isValid()
| 20-66 | ||||||||||||||||||
199 | if (!d->when
| 26-40 | ||||||||||||||||||
200 | - | |||||||||||||||||||
201 | if (d->prevBind
| 6-34 | ||||||||||||||||||
202 | QQmlAbstractBinding::Ptr p = d->prevBind; | - | ||||||||||||||||||
203 | d->prevBind = nullptr; | - | ||||||||||||||||||
204 | QQmlPropertyPrivate::setBinding(p.data()); | - | ||||||||||||||||||
205 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||
206 | return; executed 40 times by 1 test: return; Executed by:
| 40 | ||||||||||||||||||
207 | } | - | ||||||||||||||||||
208 | - | |||||||||||||||||||
209 | - | |||||||||||||||||||
210 | if (!d->prevBind
| 12-14 | ||||||||||||||||||
211 | d->prevBind = QQmlPropertyPrivate::binding(d->prop); executed 12 times by 1 test: d->prevBind = QQmlPropertyPrivate::binding(d->prop); Executed by:
| 12 | ||||||||||||||||||
212 | QQmlPropertyPrivate::removeBinding(d->prop); | - | ||||||||||||||||||
213 | } executed 26 times by 1 test: end of block Executed by:
| 26 | ||||||||||||||||||
214 | - | |||||||||||||||||||
215 | d->prop.write(d->value.value); | - | ||||||||||||||||||
216 | } executed 46 times by 3 tests: end of block Executed by:
| 46 | ||||||||||||||||||
217 | - | |||||||||||||||||||
218 | - | |||||||||||||||||||
219 | - | |||||||||||||||||||
Switch to Source code | Preprocessed file |