graphicsview/qgridlayoutengine.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9template <typename T> -
10static void insertOrRemoveItems(QVector<T> &items, int index, int delta) -
11{ -
12 int count = items.count(); -
13 if (index < count) {
evaluated: index < count
TRUEFALSE
yes
Evaluation Count:160
yes
Evaluation Count:5800
160-5800
14 if (delta > 0) {
evaluated: delta > 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:158
2-158
15 items.insert(index, delta, T()); -
16 } else if (delta < 0) {
executed: }
Execution Count:2
partially evaluated: delta < 0
TRUEFALSE
yes
Evaluation Count:158
no
Evaluation Count:0
0-158
17 items.remove(index, qMin(-delta, count - index)); -
18 }
executed: }
Execution Count:158
158
19 } -
20}
executed: }
Execution Count:5960
5960
21 -
22static qreal growthFactorBelowPreferredSize(qreal desired, qreal sumAvailable, qreal sumDesired) -
23{ -
24 qt_noop(); -
25 return desired * qPow(sumAvailable / sumDesired, desired / sumDesired);
executed: return desired * qPow(sumAvailable / sumDesired, desired / sumDesired);
Execution Count:115
115
26} -
27 -
28static qreal fixedDescent(qreal descent, qreal ascent, qreal targetSize) -
29{ -
30 if (descent < 0.0)
partially evaluated: descent < 0.0
TRUEFALSE
yes
Evaluation Count:562
no
Evaluation Count:0
0-562
31 return -1.0;
executed: return -1.0;
Execution Count:562
562
32 -
33 qt_noop(); -
34 qt_noop(); -
35 qt_noop(); -
36 -
37 qreal extra = targetSize - (ascent + descent); -
38 return descent + (extra / 2.0);
never executed: return descent + (extra / 2.0);
0
39} -
40 -
41static qreal compare(const QGridLayoutBox &box1, const QGridLayoutBox &box2, int which) -
42{ -
43 qreal size1 = box1.q_sizes(which); -
44 qreal size2 = box2.q_sizes(which); -
45 -
46 if (which == MaximumSize) {
evaluated: which == MaximumSize
TRUEFALSE
yes
Evaluation Count:157
yes
Evaluation Count:314
157-314
47 return size2 - size1;
executed: return size2 - size1;
Execution Count:157
157
48 } else { -
49 return size1 - size2;
executed: return size1 - size2;
Execution Count:314
314
50 } -
51} -
52 -
53void QGridLayoutBox::add(const QGridLayoutBox &other, int stretch, qreal spacing) -
54{ -
55 qt_noop(); -
56 -
57 q_minimumSize += other.q_minimumSize + spacing; -
58 q_preferredSize += other.q_preferredSize + spacing; -
59 q_maximumSize += ((stretch == 0) ? other.q_preferredSize : other.q_maximumSize) + spacing;
evaluated: (stretch == 0)
TRUEFALSE
yes
Evaluation Count:82
yes
Evaluation Count:6213
82-6213
60}
executed: }
Execution Count:6295
6295
61 -
62void QGridLayoutBox::combine(const QGridLayoutBox &other) -
63{ -
64 q_minimumDescent = qMax(q_minimumDescent, other.q_minimumDescent); -
65 q_minimumAscent = qMax(q_minimumAscent, other.q_minimumAscent); -
66 -
67 q_minimumSize = qMax(q_minimumAscent + q_minimumDescent, -
68 qMax(q_minimumSize, other.q_minimumSize)); -
69 qreal maxMax; -
70 if (q_maximumSize == 3.40282347e+38F && other.q_maximumSize != 3.40282347e+38F)
evaluated: q_maximumSize == 3.40282347e+38F
TRUEFALSE
yes
Evaluation Count:5959
yes
Evaluation Count:4583
partially evaluated: other.q_maximumSize != 3.40282347e+38F
TRUEFALSE
yes
Evaluation Count:5959
no
Evaluation Count:0
0-5959
71 maxMax = other.q_maximumSize;
executed: maxMax = other.q_maximumSize;
Execution Count:5959
5959
72 else if (other.q_maximumSize == 3.40282347e+38F && q_maximumSize != 3.40282347e+38F)
evaluated: other.q_maximumSize == 3.40282347e+38F
TRUEFALSE
yes
Evaluation Count:80
yes
Evaluation Count:4503
partially evaluated: q_maximumSize != 3.40282347e+38F
TRUEFALSE
yes
Evaluation Count:80
no
Evaluation Count:0
0-4503
73 maxMax = q_maximumSize;
executed: maxMax = q_maximumSize;
Execution Count:80
80
74 else -
75 maxMax = qMax(q_maximumSize, other.q_maximumSize);
executed: maxMax = qMax(q_maximumSize, other.q_maximumSize);
Execution Count:4503
4503
76 -
77 q_maximumSize = qMax(q_minimumSize, maxMax); -
78 q_preferredSize = qBound(q_minimumSize, qMax(q_preferredSize, other.q_preferredSize), -
79 q_maximumSize); -
80}
executed: }
Execution Count:10542
10542
81 -
82void QGridLayoutBox::normalize() -
83{ -
84 q_maximumSize = qMax(qreal(0.0), q_maximumSize); -
85 q_minimumSize = qBound(qreal(0.0), q_minimumSize, q_maximumSize); -
86 q_preferredSize = qBound(q_minimumSize, q_preferredSize, q_maximumSize); -
87 q_minimumDescent = qMin(q_minimumDescent, q_minimumSize); -
88 -
89 qt_noop(); -
90}
executed: }
Execution Count:403
403
91bool operator==(const QGridLayoutBox &box1, const QGridLayoutBox &box2) -
92{ -
93 for (int i = 0; i < NSizes; ++i) {
evaluated: i < NSizes
TRUEFALSE
yes
Evaluation Count:96
yes
Evaluation Count:32
32-96
94 if (box1.q_sizes(i) != box2.q_sizes(i))
partially evaluated: box1.q_sizes(i) != box2.q_sizes(i)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:96
0-96
95 return false;
never executed: return false;
0
96 }
executed: }
Execution Count:96
96
97 return box1.q_minimumDescent == box2.q_minimumDescent 32
98 && box1.q_minimumAscent == box2.q_minimumAscent;
executed: return box1.q_minimumDescent == box2.q_minimumDescent && box1.q_minimumAscent == box2.q_minimumAscent;
Execution Count:32
32
99} -
100 -
101void QGridLayoutRowData::reset(int count) -
102{ -
103 ignore.fill(false, count); -
104 boxes.fill(QGridLayoutBox(), count); -
105 multiCellMap.clear(); -
106 stretches.fill(0, count); -
107 spacings.fill(0.0, count); -
108 hasIgnoreFlag = false; -
109}
executed: }
Execution Count:3700
3700
110 -
111void QGridLayoutRowData::distributeMultiCells(const QGridLayoutRowInfo &rowInfo) -
112{ -
113 MultiCellMap::const_iterator i = multiCellMap.constBegin(); -
114 for (; i != multiCellMap.constEnd(); ++i) {
evaluated: i != multiCellMap.constEnd()
TRUEFALSE
yes
Evaluation Count:157
yes
Evaluation Count:3700
157-3700
115 int start = i.key().first; -
116 int span = i.key().second; -
117 int end = start + span; -
118 const QGridLayoutBox &box = i.value().q_box; -
119 int stretch = i.value().q_stretch; -
120 -
121 QGridLayoutBox totalBox = this->totalBox(start, end); -
122 QVarLengthArray<QGridLayoutBox> extras(span); -
123 QVarLengthArray<qreal> dummy(span); -
124 QVarLengthArray<qreal> newSizes(span); -
125 -
126 for (int j = 0; j < NSizes; ++j) {
evaluated: j < NSizes
TRUEFALSE
yes
Evaluation Count:471
yes
Evaluation Count:157
157-471
127 qreal extra = compare(box, totalBox, j); -
128 if (extra > 0.0) {
evaluated: extra > 0.0
TRUEFALSE
yes
Evaluation Count:341
yes
Evaluation Count:130
130-341
129 calculateGeometries(start, end, box.q_sizes(j), dummy.data(), newSizes.data(), -
130 0, totalBox, rowInfo); -
131 -
132 for (int k = 0; k < span; ++k)
evaluated: k < span
TRUEFALSE
yes
Evaluation Count:682
yes
Evaluation Count:341
341-682
133 extras[k].q_sizes(j) = newSizes[k];
executed: extras[k].q_sizes(j) = newSizes[k];
Execution Count:682
682
134 }
executed: }
Execution Count:341
341
135 }
executed: }
Execution Count:471
471
136 -
137 for (int k = 0; k < span; ++k) {
evaluated: k < span
TRUEFALSE
yes
Evaluation Count:314
yes
Evaluation Count:157
157-314
138 boxes[start + k].combine(extras[k]); -
139 if (stretch != 0)
evaluated: stretch != 0
TRUEFALSE
yes
Evaluation Count:218
yes
Evaluation Count:96
96-218
140 stretches[start + k] = qMax(stretches[start + k], stretch);
executed: stretches[start + k] = qMax(stretches[start + k], stretch);
Execution Count:218
218
141 }
executed: }
Execution Count:314
314
142 }
executed: }
Execution Count:157
157
143 multiCellMap.clear(); -
144}
executed: }
Execution Count:3700
3700
145 -
146void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSize, qreal *positions, -
147 qreal *sizes, qreal *descents, -
148 const QGridLayoutBox &totalBox, -
149 const QGridLayoutRowInfo &rowInfo) -
150{ -
151 qt_noop(); -
152 -
153 targetSize = qMax(totalBox.q_minimumSize, targetSize); -
154 -
155 int n = end - start; -
156 QVarLengthArray<qreal> newSizes(n); -
157 QVarLengthArray<qreal> factors(n); -
158 qreal sumFactors = 0.0; -
159 int sumStretches = 0; -
160 qreal sumAvailable; -
161 -
162 for (int i = 0; i < n; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:2079
yes
Evaluation Count:1101
1101-2079
163 if (stretches[start + i] > 0)
evaluated: stretches[start + i] > 0
TRUEFALSE
yes
Evaluation Count:155
yes
Evaluation Count:1924
155-1924
164 sumStretches += stretches[start + i];
executed: sumStretches += stretches[start + i];
Execution Count:155
155
165 }
executed: }
Execution Count:2079
2079
166 -
167 if (targetSize < totalBox.q_preferredSize) {
evaluated: targetSize < totalBox.q_preferredSize
TRUEFALSE
yes
Evaluation Count:228
yes
Evaluation Count:873
228-873
168 stealBox(start, end, MinimumSize, positions, sizes); -
169 -
170 sumAvailable = targetSize - totalBox.q_minimumSize; -
171 if (sumAvailable > 0.0) {
evaluated: sumAvailable > 0.0
TRUEFALSE
yes
Evaluation Count:54
yes
Evaluation Count:174
54-174
172 qreal sumDesired = totalBox.q_preferredSize - totalBox.q_minimumSize; -
173 -
174 for (int i = 0; i < n; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:118
yes
Evaluation Count:54
54-118
175 if (ignore.testBit(start + i)) {
evaluated: ignore.testBit(start + i)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:115
3-115
176 factors[i] = 0.0; -
177 continue;
executed: continue;
Execution Count:3
3
178 } -
179 -
180 const QGridLayoutBox &box = boxes.at(start + i); -
181 qreal desired = box.q_preferredSize - box.q_minimumSize; -
182 factors[i] = growthFactorBelowPreferredSize(desired, sumAvailable, sumDesired); -
183 sumFactors += factors[i]; -
184 }
executed: }
Execution Count:115
115
185 -
186 for (int i = 0; i < n; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:118
yes
Evaluation Count:54
54-118
187 qt_noop(); -
188 qreal delta = sumAvailable * factors[i] / sumFactors; -
189 newSizes[i] = sizes[i] + delta; -
190 }
executed: }
Execution Count:118
118
191 }
executed: }
Execution Count:54
54
192 } else {
executed: }
Execution Count:228
228
193 bool isLargerThanMaximum = (targetSize > totalBox.q_maximumSize); -
194 if (isLargerThanMaximum) {
evaluated: isLargerThanMaximum
TRUEFALSE
yes
Evaluation Count:82
yes
Evaluation Count:791
82-791
195 stealBox(start, end, MaximumSize, positions, sizes); -
196 sumAvailable = targetSize - totalBox.q_maximumSize; -
197 } else {
executed: }
Execution Count:82
82
198 stealBox(start, end, PreferredSize, positions, sizes); -
199 sumAvailable = targetSize - totalBox.q_preferredSize; -
200 }
executed: }
Execution Count:791
791
201 -
202 if (sumAvailable > 0.0) {
evaluated: sumAvailable > 0.0
TRUEFALSE
yes
Evaluation Count:446
yes
Evaluation Count:427
427-446
203 qreal sumCurrentAvailable = sumAvailable; -
204 bool somethingHasAMaximumSize = false; -
205 -
206 qreal sumSizes = 0.0; -
207 for (int i = 0; i < n; ++i)
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:887
yes
Evaluation Count:446
446-887
208 sumSizes += sizes[i];
executed: sumSizes += sizes[i];
Execution Count:887
887
209 -
210 for (int i = 0; i < n; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:887
yes
Evaluation Count:446
446-887
211 if (ignore.testBit(start + i)) {
partially evaluated: ignore.testBit(start + i)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:887
0-887
212 newSizes[i] = 0.0; -
213 factors[i] = 0.0; -
214 continue;
never executed: continue;
0
215 } -
216 -
217 const QGridLayoutBox &box = boxes.at(start + i); -
218 qreal boxSize; -
219 -
220 qreal desired; -
221 if (isLargerThanMaximum) {
evaluated: isLargerThanMaximum
TRUEFALSE
yes
Evaluation Count:153
yes
Evaluation Count:734
153-734
222 boxSize = box.q_maximumSize; -
223 desired = rowInfo.boxes.value(start + i).q_maximumSize - boxSize; -
224 } else {
executed: }
Execution Count:153
153
225 boxSize = box.q_preferredSize; -
226 desired = box.q_maximumSize - boxSize; -
227 }
executed: }
Execution Count:734
734
228 if (desired == 0.0) {
evaluated: desired == 0.0
TRUEFALSE
yes
Evaluation Count:162
yes
Evaluation Count:725
162-725
229 newSizes[i] = sizes[i]; -
230 factors[i] = 0.0; -
231 } else {
executed: }
Execution Count:162
162
232 qt_noop(); -
233 -
234 int stretch = stretches[start + i]; -
235 if (sumStretches == 0) {
evaluated: sumStretches == 0
TRUEFALSE
yes
Evaluation Count:680
yes
Evaluation Count:45
45-680
236 if (hasIgnoreFlag) {
evaluated: hasIgnoreFlag
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:663
17-663
237 factors[i] = (stretch < 0) ? 1.0 : 0.0;
evaluated: (stretch < 0)
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:3
3-14
238 } else {
executed: }
Execution Count:17
17
239 factors[i] = (stretch < 0) ? sizes[i] : 0.0;
partially evaluated: (stretch < 0)
TRUEFALSE
yes
Evaluation Count:663
no
Evaluation Count:0
0-663
240 }
executed: }
Execution Count:663
663
241 } else if (stretch == sumStretches) {
evaluated: stretch == sumStretches
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:33
12-33
242 factors[i] = 1.0; -
243 } else if (stretch <= 0) {
evaluated: stretch <= 0
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:24
executed: }
Execution Count:12
9-24
244 factors[i] = 0.0; -
245 } else {
executed: }
Execution Count:9
9
246 qreal ultimateSize; -
247 qreal ultimateSumSizes; -
248 qreal x = ((stretch * sumSizes) -
249 - (sumStretches * boxSize)) -
250 / (sumStretches - stretch); -
251 if (x >= 0.0) {
evaluated: x >= 0.0
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:10
10-14
252 ultimateSize = boxSize + x; -
253 ultimateSumSizes = sumSizes + x; -
254 } else {
executed: }
Execution Count:14
14
255 ultimateSize = boxSize; -
256 ultimateSumSizes = (sumStretches * boxSize) -
257 / stretch; -
258 }
executed: }
Execution Count:10
10
259 -
260 -
261 -
262 -
263 -
264 -
265 ultimateSize = ultimateSize * 3 / 2; -
266 ultimateSumSizes = ultimateSumSizes * 3 / 2; -
267 -
268 qreal beta = ultimateSumSizes - sumSizes; -
269 if (!beta) {
partially evaluated: !beta
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24
0-24
270 factors[i] = 1; -
271 } else {
never executed: }
0
272 qreal alpha = qMin(sumCurrentAvailable, beta); -
273 qreal ultimateFactor = (stretch * ultimateSumSizes / sumStretches) -
274 - (boxSize); -
275 qreal transitionalFactor = sumCurrentAvailable * (ultimateSize - boxSize) / beta; -
276 -
277 factors[i] = ((alpha * ultimateFactor) -
278 + ((beta - alpha) * transitionalFactor)) / beta; -
279 }
executed: }
Execution Count:24
24
280 -
281 } -
282 sumFactors += factors[i]; -
283 if (desired < sumCurrentAvailable)
evaluated: desired < sumCurrentAvailable
TRUEFALSE
yes
Evaluation Count:81
yes
Evaluation Count:644
81-644
284 somethingHasAMaximumSize = true;
executed: somethingHasAMaximumSize = true;
Execution Count:81
81
285 -
286 newSizes[i] = -1.0; -
287 }
executed: }
Execution Count:725
725
288 } -
289 -
290 bool keepGoing = somethingHasAMaximumSize; -
291 while (keepGoing) {
evaluated: keepGoing
TRUEFALSE
yes
Evaluation Count:54
yes
Evaluation Count:446
54-446
292 keepGoing = false; -
293 -
294 for (int i = 0; i < n; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:122
yes
Evaluation Count:31
31-122
295 if (newSizes[i] >= 0.0)
evaluated: newSizes[i] >= 0.0
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:110
12-110
296 continue;
executed: continue;
Execution Count:12
12
297 -
298 qreal maxBoxSize; -
299 if (isLargerThanMaximum)
partially evaluated: isLargerThanMaximum
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:110
0-110
300 maxBoxSize = rowInfo.boxes.value(start + i).q_maximumSize;
never executed: maxBoxSize = rowInfo.boxes.value(start + i).q_maximumSize;
0
301 else -
302 maxBoxSize = boxes.at(start + i).q_maximumSize;
executed: maxBoxSize = boxes.at(start + i).q_maximumSize;
Execution Count:110
110
303 -
304 qreal avail = sumCurrentAvailable * factors[i] / sumFactors; -
305 if (sizes[i] + avail >= maxBoxSize) {
evaluated: sizes[i] + avail >= maxBoxSize
TRUEFALSE
yes
Evaluation Count:56
yes
Evaluation Count:54
54-56
306 newSizes[i] = maxBoxSize; -
307 sumCurrentAvailable -= maxBoxSize - sizes[i]; -
308 sumFactors -= factors[i]; -
309 keepGoing = (sumCurrentAvailable > 0.0); -
310 if (!keepGoing)
evaluated: !keepGoing
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:33
23-33
311 break;
executed: break;
Execution Count:23
23
312 }
executed: }
Execution Count:33
33
313 }
executed: }
Execution Count:87
87
314 }
executed: }
Execution Count:54
54
315 -
316 for (int i = 0; i < n; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:887
yes
Evaluation Count:446
446-887
317 if (newSizes[i] < 0.0) {
evaluated: newSizes[i] < 0.0
TRUEFALSE
yes
Evaluation Count:669
yes
Evaluation Count:218
218-669
318 qreal delta = (sumFactors == 0.0) ? 0.0
partially evaluated: (sumFactors == 0.0)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:669
0-669
319 : sumCurrentAvailable * factors[i] / sumFactors; -
320 newSizes[i] = sizes[i] + delta; -
321 }
executed: }
Execution Count:669
669
322 }
executed: }
Execution Count:887
887
323 }
executed: }
Execution Count:446
446
324 }
executed: }
Execution Count:873
873
325 -
326 if (sumAvailable > 0) {
evaluated: sumAvailable > 0
TRUEFALSE
yes
Evaluation Count:500
yes
Evaluation Count:601
500-601
327 qreal offset = 0; -
328 for (int i = 0; i < n; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:1005
yes
Evaluation Count:500
500-1005
329 qreal delta = newSizes[i] - sizes[i]; -
330 positions[i] += offset; -
331 sizes[i] += delta; -
332 offset += delta; -
333 }
executed: }
Execution Count:1005
1005
334 }
executed: }
Execution Count:500
500
335 -
336 if (descents) {
evaluated: descents
TRUEFALSE
yes
Evaluation Count:365
yes
Evaluation Count:736
365-736
337 for (int i = 0; i < n; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:563
yes
Evaluation Count:365
365-563
338 if (ignore.testBit(start + i))
evaluated: ignore.testBit(start + i)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:562
1-562
339 continue;
executed: continue;
Execution Count:1
1
340 const QGridLayoutBox &box = boxes.at(start + i); -
341 descents[i] = fixedDescent(box.q_minimumDescent, box.q_minimumAscent, sizes[i]); -
342 }
executed: }
Execution Count:562
562
343 }
executed: }
Execution Count:365
365
344}
executed: }
Execution Count:1101
1101
345 -
346QGridLayoutBox QGridLayoutRowData::totalBox(int start, int end) const -
347{ -
348 QGridLayoutBox result; -
349 if (start < end) {
evaluated: start < end
TRUEFALSE
yes
Evaluation Count:3192
yes
Evaluation Count:665
665-3192
350 result.q_maximumSize = 0.0; -
351 qreal nextSpacing = 0.0; -
352 for (int i = start; i < end; ++i) {
evaluated: i < end
TRUEFALSE
yes
Evaluation Count:6295
yes
Evaluation Count:3192
3192-6295
353 result.add(boxes.at(i), stretches.at(i), nextSpacing); -
354 nextSpacing = spacings.at(i); -
355 }
executed: }
Execution Count:6295
6295
356 }
executed: }
Execution Count:3192
3192
357 return result;
executed: return result;
Execution Count:3857
3857
358} -
359 -
360void QGridLayoutRowData::stealBox(int start, int end, int which, qreal *positions, qreal *sizes) -
361{ -
362 qreal offset = 0.0; -
363 qreal nextSpacing = 0.0; -
364 -
365 for (int i = start; i < end; ++i) {
evaluated: i < end
TRUEFALSE
yes
Evaluation Count:2079
yes
Evaluation Count:1101
1101-2079
366 qreal avail = 0.0; -
367 -
368 if (!ignore.testBit(i)) {
evaluated: !ignore.testBit(i)
TRUEFALSE
yes
Evaluation Count:2068
yes
Evaluation Count:11
11-2068
369 const QGridLayoutBox &box = boxes.at(i); -
370 avail = box.q_sizes(which); -
371 offset += nextSpacing; -
372 nextSpacing = spacings.at(i); -
373 }
executed: }
Execution Count:2068
2068
374 -
375 *positions++ = offset; -
376 *sizes++ = avail; -
377 offset += avail; -
378 }
executed: }
Execution Count:2079
2079
379}
executed: }
Execution Count:1101
1101
380QGridLayoutItem::QGridLayoutItem(QGridLayoutEngine *engine, QGraphicsLayoutItem *layoutItem, -
381 int row, int column, int rowSpan, int columnSpan, -
382 Qt::Alignment alignment, int itemAtIndex) -
383 : q_engine(engine), q_layoutItem(layoutItem), q_alignment(alignment) -
384{ -
385 q_firstRows[Hor] = column; -
386 q_firstRows[Ver] = row; -
387 q_rowSpans[Hor] = columnSpan; -
388 q_rowSpans[Ver] = rowSpan; -
389 q_stretches[Hor] = -1; -
390 q_stretches[Ver] = -1; -
391 -
392 q_engine->insertItem(this, itemAtIndex); -
393}
executed: }
Execution Count:1342
1342
394 -
395int QGridLayoutItem::firstRow(Qt::Orientation orientation) const -
396{ -
397 return q_firstRows[orientation == Qt::Vertical];
executed: return q_firstRows[orientation == Qt::Vertical];
Execution Count:30938
30938
398} -
399 -
400int QGridLayoutItem::firstColumn(Qt::Orientation orientation) const -
401{ -
402 return q_firstRows[orientation == Qt::Horizontal];
executed: return q_firstRows[orientation == Qt::Horizontal];
Execution Count:10810
10810
403} -
404 -
405int QGridLayoutItem::lastRow(Qt::Orientation orientation) const -
406{ -
407 return firstRow(orientation) + rowSpan(orientation) - 1;
executed: return firstRow(orientation) + rowSpan(orientation) - 1;
Execution Count:10052
10052
408} -
409 -
410int QGridLayoutItem::lastColumn(Qt::Orientation orientation) const -
411{ -
412 return firstColumn(orientation) + columnSpan(orientation) - 1;
executed: return firstColumn(orientation) + columnSpan(orientation) - 1;
Execution Count:224
224
413} -
414 -
415int QGridLayoutItem::rowSpan(Qt::Orientation orientation) const -
416{ -
417 return q_rowSpans[orientation == Qt::Vertical];
executed: return q_rowSpans[orientation == Qt::Vertical];
Execution Count:20280
20280
418} -
419 -
420int QGridLayoutItem::columnSpan(Qt::Orientation orientation) const -
421{ -
422 return q_rowSpans[orientation == Qt::Horizontal];
executed: return q_rowSpans[orientation == Qt::Horizontal];
Execution Count:438
438
423} -
424 -
425void QGridLayoutItem::setFirstRow(int row, Qt::Orientation orientation) -
426{ -
427 q_firstRows[orientation == Qt::Vertical] = row; -
428}
executed: }
Execution Count:78
78
429 -
430void QGridLayoutItem::setRowSpan(int rowSpan, Qt::Orientation orientation) -
431{ -
432 q_rowSpans[orientation == Qt::Vertical] = rowSpan; -
433}
never executed: }
0
434 -
435int QGridLayoutItem::stretchFactor(Qt::Orientation orientation) const -
436{ -
437 int stretch = q_stretches[orientation == Qt::Vertical]; -
438 if (stretch >= 0)
evaluated: stretch >= 0
TRUEFALSE
yes
Evaluation Count:36
yes
Evaluation Count:10283
36-10283
439 return stretch;
executed: return stretch;
Execution Count:36
36
440 -
441 QSizePolicy::Policy policy = sizePolicy(orientation); -
442 -
443 if (policy & QSizePolicy::ExpandFlag) {
evaluated: policy & QSizePolicy::ExpandFlag
TRUEFALSE
yes
Evaluation Count:714
yes
Evaluation Count:9569
714-9569
444 return 1;
executed: return 1;
Execution Count:714
714
445 } else if (policy & QSizePolicy::GrowFlag) {
evaluated: policy & QSizePolicy::GrowFlag
TRUEFALSE
yes
Evaluation Count:9120
yes
Evaluation Count:449
449-9120
446 return -1;
executed: return -1;
Execution Count:9120
9120
447 } else { -
448 return 0;
executed: return 0;
Execution Count:449
449
449 } -
450} -
451 -
452void QGridLayoutItem::setStretchFactor(int stretch, Qt::Orientation orientation) -
453{ -
454 qt_noop(); -
455 q_stretches[orientation == Qt::Vertical] = stretch; -
456}
executed: }
Execution Count:9
9
457 -
458QSizePolicy::Policy QGridLayoutItem::sizePolicy(Qt::Orientation orientation) const -
459{ -
460 QSizePolicy sizePolicy(q_layoutItem->sizePolicy()); -
461 return (orientation == Qt::Horizontal) ? sizePolicy.horizontalPolicy() 34765
462 : sizePolicy.verticalPolicy();
executed: return (orientation == Qt::Horizontal) ? sizePolicy.horizontalPolicy() : sizePolicy.verticalPolicy();
Execution Count:34765
34765
463} -
464 -
465 -
466 -
467 -
468 -
469bool QGridLayoutItem::hasDynamicConstraint() const -
470{ -
471 return QGraphicsLayoutItemPrivate::get(q_layoutItem)->hasHeightForWidth() 3976
472 || QGraphicsLayoutItemPrivate::get(q_layoutItem)->hasWidthForHeight();
executed: return QGraphicsLayoutItemPrivate::get(q_layoutItem)->hasHeightForWidth() || QGraphicsLayoutItemPrivate::get(q_layoutItem)->hasWidthForHeight();
Execution Count:3976
3976
473} -
474 -
475Qt::Orientation QGridLayoutItem::dynamicConstraintOrientation() const -
476{ -
477 if (QGraphicsLayoutItemPrivate::get(q_layoutItem)->hasHeightForWidth())
evaluated: QGraphicsLayoutItemPrivate::get(q_layoutItem)->hasHeightForWidth()
TRUEFALSE
yes
Evaluation Count:588
yes
Evaluation Count:36
36-588
478 return Qt::Vertical;
executed: return Qt::Vertical;
Execution Count:588
588
479 else -
480 return Qt::Horizontal;
executed: return Qt::Horizontal;
Execution Count:36
36
481} -
482 -
483QSizePolicy::ControlTypes QGridLayoutItem::controlTypes(LayoutSide ) const -
484{ -
485 return q_layoutItem->sizePolicy().controlType();
executed: return q_layoutItem->sizePolicy().controlType();
Execution Count:10067
10067
486} -
487 -
488QSizeF QGridLayoutItem::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const -
489{ -
490 return q_layoutItem->effectiveSizeHint(which, constraint);
executed: return q_layoutItem->effectiveSizeHint(which, constraint);
Execution Count:39848
39848
491} -
492 -
493QGridLayoutBox QGridLayoutItem::box(Qt::Orientation orientation, qreal constraint) const -
494{ -
495 QGridLayoutBox result; -
496 QSizePolicy::Policy policy = sizePolicy(orientation); -
497 -
498 if (orientation == Qt::Horizontal) {
evaluated: orientation == Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:5114
yes
Evaluation Count:6366
5114-6366
499 QSizeF constraintSize(-1.0, constraint); -
500 -
501 result.q_preferredSize = sizeHint(Qt::PreferredSize, constraintSize).width(); -
502 -
503 if (policy & QSizePolicy::ShrinkFlag) {
evaluated: policy & QSizePolicy::ShrinkFlag
TRUEFALSE
yes
Evaluation Count:4996
yes
Evaluation Count:118
118-4996
504 result.q_minimumSize = sizeHint(Qt::MinimumSize, constraintSize).width(); -
505 } else {
executed: }
Execution Count:4996
4996
506 result.q_minimumSize = result.q_preferredSize; -
507 }
executed: }
Execution Count:118
118
508 -
509 if (policy & (QSizePolicy::GrowFlag | QSizePolicy::ExpandFlag)) {
evaluated: policy & (QSizePolicy::GrowFlag | QSizePolicy::ExpandFlag)
TRUEFALSE
yes
Evaluation Count:4996
yes
Evaluation Count:118
118-4996
510 result.q_maximumSize = sizeHint(Qt::MaximumSize, constraintSize).width(); -
511 } else {
executed: }
Execution Count:4996
4996
512 result.q_maximumSize = result.q_preferredSize; -
513 }
executed: }
Execution Count:118
118
514 } else { -
515 QSizeF constraintSize(constraint, -1.0); -
516 -
517 result.q_preferredSize = sizeHint(Qt::PreferredSize, constraintSize).height(); -
518 -
519 if (policy & QSizePolicy::ShrinkFlag) {
evaluated: policy & QSizePolicy::ShrinkFlag
TRUEFALSE
yes
Evaluation Count:6005
yes
Evaluation Count:361
361-6005
520 result.q_minimumSize = sizeHint(Qt::MinimumSize, constraintSize).height(); -
521 } else {
executed: }
Execution Count:6005
6005
522 result.q_minimumSize = result.q_preferredSize; -
523 }
executed: }
Execution Count:361
361
524 -
525 if (policy & (QSizePolicy::GrowFlag | QSizePolicy::ExpandFlag)) {
evaluated: policy & (QSizePolicy::GrowFlag | QSizePolicy::ExpandFlag)
TRUEFALSE
yes
Evaluation Count:6005
yes
Evaluation Count:361
361-6005
526 result.q_maximumSize = sizeHint(Qt::MaximumSize, constraintSize).height(); -
527 } else {
executed: }
Execution Count:6005
6005
528 result.q_maximumSize = result.q_preferredSize; -
529 }
executed: }
Execution Count:361
361
530 -
531 result.q_minimumDescent = sizeHint(Qt::MinimumDescent, constraintSize).height(); -
532 if (result.q_minimumDescent >= 0.0)
partially evaluated: result.q_minimumDescent >= 0.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6366
0-6366
533 result.q_minimumAscent = result.q_minimumSize - result.q_minimumDescent;
never executed: result.q_minimumAscent = result.q_minimumSize - result.q_minimumDescent;
0
534 }
executed: }
Execution Count:6366
6366
535 if (policy & QSizePolicy::IgnoreFlag)
evaluated: policy & QSizePolicy::IgnoreFlag
TRUEFALSE
yes
Evaluation Count:242
yes
Evaluation Count:11238
242-11238
536 result.q_preferredSize = result.q_minimumSize;
executed: result.q_preferredSize = result.q_minimumSize;
Execution Count:242
242
537 -
538 return result;
executed: return result;
Execution Count:11480
11480
539} -
540 -
541QRectF QGridLayoutItem::geometryWithin(qreal x, qreal y, qreal width, qreal height, -
542 qreal rowDescent) const -
543{ -
544 rowDescent = -1.0; -
545 -
546 QGridLayoutBox vBox = box(Qt::Vertical); -
547 if (vBox.q_minimumDescent < 0.0 || rowDescent < 0.0) {
partially evaluated: vBox.q_minimumDescent < 0.0
TRUEFALSE
yes
Evaluation Count:1252
no
Evaluation Count:0
never evaluated: rowDescent < 0.0
0-1252
548 qreal cellWidth = width; -
549 qreal cellHeight = height; -
550 -
551 -
552 QSizeF size = effectiveMaxSize(QSizeF(-1,-1)); -
553 if (hasDynamicConstraint()) {
evaluated: hasDynamicConstraint()
TRUEFALSE
yes
Evaluation Count:193
yes
Evaluation Count:1059
193-1059
554 if (dynamicConstraintOrientation() == Qt::Vertical) {
evaluated: dynamicConstraintOrientation() == Qt::Vertical
TRUEFALSE
yes
Evaluation Count:183
yes
Evaluation Count:10
10-183
555 if (size.width() > cellWidth)
evaluated: size.width() > cellWidth
TRUEFALSE
yes
Evaluation Count:125
yes
Evaluation Count:58
58-125
556 size = effectiveMaxSize(QSizeF(cellWidth, -1));
executed: size = effectiveMaxSize(QSizeF(cellWidth, -1));
Execution Count:125
125
557 } else if (size.height() > cellHeight) {
executed: }
Execution Count:183
partially evaluated: size.height() > cellHeight
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-183
558 size = effectiveMaxSize(QSizeF(-1, cellHeight)); -
559 }
executed: }
Execution Count:10
10
560 } -
561 size = size.boundedTo(QSizeF(cellWidth, cellHeight)); -
562 width = size.width(); -
563 height = size.height(); -
564 -
565 Qt::Alignment align = q_engine->effectiveAlignment(this); -
566 switch (align & Qt::AlignHorizontal_Mask) { -
567 case Qt::AlignHCenter: -
568 x += (cellWidth - width)/2; -
569 break;
executed: break;
Execution Count:63
63
570 case Qt::AlignRight: -
571 x += cellWidth - width; -
572 break;
executed: break;
Execution Count:46
46
573 default: -
574 break;
executed: break;
Execution Count:1143
1143
575 } -
576 switch (align & Qt::AlignVertical_Mask) { -
577 case Qt::AlignVCenter: -
578 y += (cellHeight - height)/2; -
579 break;
executed: break;
Execution Count:49
49
580 case Qt::AlignBottom: -
581 y += cellHeight - height; -
582 break;
executed: break;
Execution Count:37
37
583 default: -
584 break;
executed: break;
Execution Count:1166
1166
585 } -
586 return QRectF(x, y, width, height);
executed: return QRectF(x, y, width, height);
Execution Count:1252
1252
587 } else { -
588 qreal descent = vBox.q_minimumDescent; -
589 qreal ascent = vBox.q_minimumSize - descent; -
590 return QRectF(x, y + height - rowDescent - ascent, width, ascent + descent);
never executed: return QRectF(x, y + height - rowDescent - ascent, width, ascent + descent);
0
591 } -
592} -
593 -
594void QGridLayoutItem::setGeometry(const QRectF &rect) -
595{ -
596 q_layoutItem->setGeometry(rect); -
597}
executed: }
Execution Count:1252
1252
598 -
599void QGridLayoutItem::transpose() -
600{ -
601 qSwap(q_firstRows[Hor], q_firstRows[Ver]); -
602 qSwap(q_rowSpans[Hor], q_rowSpans[Ver]); -
603 qSwap(q_stretches[Hor], q_stretches[Ver]); -
604}
executed: }
Execution Count:9
9
605 -
606void QGridLayoutItem::insertOrRemoveRows(int row, int delta, Qt::Orientation orientation) -
607{ -
608 int oldFirstRow = firstRow(orientation); -
609 if (oldFirstRow >= row) {
evaluated: oldFirstRow >= row
TRUEFALSE
yes
Evaluation Count:78
yes
Evaluation Count:3158
78-3158
610 setFirstRow(oldFirstRow + delta, orientation); -
611 } else if (lastRow(orientation) >= row) {
executed: }
Execution Count:78
partially evaluated: lastRow(orientation) >= row
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3158
0-3158
612 setRowSpan(rowSpan(orientation) + delta, orientation); -
613 }
never executed: }
0
614} -
615QSizeF QGridLayoutItem::effectiveMaxSize(const QSizeF &constraint) const -
616{ -
617 QSizeF size = constraint; -
618 bool vGrow = (sizePolicy(Qt::Vertical) & QSizePolicy::GrowFlag) == QSizePolicy::GrowFlag; -
619 bool hGrow = (sizePolicy(Qt::Horizontal) & QSizePolicy::GrowFlag) == QSizePolicy::GrowFlag; -
620 if (!vGrow || !hGrow) {
evaluated: !vGrow
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:1357
evaluated: !hGrow
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:1337
20-1357
621 QSizeF pref = layoutItem()->effectiveSizeHint(Qt::PreferredSize, constraint); -
622 if (!vGrow)
evaluated: !vGrow
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:20
20-30
623 size.setHeight(pref.height());
executed: size.setHeight(pref.height());
Execution Count:30
30
624 if (!hGrow)
evaluated: !hGrow
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:8
8-42
625 size.setWidth(pref.width());
executed: size.setWidth(pref.width());
Execution Count:42
42
626 }
executed: }
Execution Count:50
50
627 -
628 if (!size.isValid()) {
evaluated: !size.isValid()
TRUEFALSE
yes
Evaluation Count:1365
yes
Evaluation Count:22
22-1365
629 QSizeF maxSize = layoutItem()->effectiveSizeHint(Qt::MaximumSize, size); -
630 if (size.width() == -1)
evaluated: size.width() == -1
TRUEFALSE
yes
Evaluation Count:1220
yes
Evaluation Count:145
145-1220
631 size.setWidth(maxSize.width());
executed: size.setWidth(maxSize.width());
Execution Count:1220
1220
632 if (size.height() == -1)
evaluated: size.height() == -1
TRUEFALSE
yes
Evaluation Count:1347
yes
Evaluation Count:18
18-1347
633 size.setHeight(maxSize.height());
executed: size.setHeight(maxSize.height());
Execution Count:1347
1347
634 }
executed: }
Execution Count:1365
1365
635 return size;
executed: return size;
Execution Count:1387
1387
636} -
637void QGridLayoutRowInfo::insertOrRemoveRows(int row, int delta) -
638{ -
639 count += delta; -
640 -
641 insertOrRemoveItems(stretches, row, delta); -
642 insertOrRemoveItems(spacings, row, delta); -
643 insertOrRemoveItems(alignments, row, delta); -
644 insertOrRemoveItems(boxes, row, delta); -
645}
executed: }
Execution Count:1490
1490
646QGridLayoutEngine::QGridLayoutEngine() -
647{ -
648 m_visualDirection = Qt::LeftToRight; -
649 invalidate(); -
650}
executed: }
Execution Count:664
664
651 -
652int QGridLayoutEngine::rowCount(Qt::Orientation orientation) const -
653{ -
654 return q_infos[orientation == Qt::Vertical].count;
executed: return q_infos[orientation == Qt::Vertical].count;
Execution Count:11209
11209
655} -
656 -
657int QGridLayoutEngine::columnCount(Qt::Orientation orientation) const -
658{ -
659 return q_infos[orientation == Qt::Horizontal].count;
never executed: return q_infos[orientation == Qt::Horizontal].count;
0
660} -
661 -
662int QGridLayoutEngine::itemCount() const -
663{ -
664 return q_items.count();
executed: return q_items.count();
Execution Count:7069
7069
665} -
666 -
667QGridLayoutItem *QGridLayoutEngine::itemAt(int index) const -
668{ -
669 qt_noop(); -
670 return q_items.at(index);
executed: return q_items.at(index);
Execution Count:4490
4490
671} -
672 -
673int QGridLayoutEngine::indexOf(QGraphicsLayoutItem *item) const -
674{ -
675 for (int i = 0; i < q_items.size(); ++i) {
evaluated: i < q_items.size()
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:2
2-19
676 if (item == q_items.at(i)->layoutItem())
evaluated: item == q_items.at(i)->layoutItem()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:17
2-17
677 return i;
executed: return i;
Execution Count:2
2
678 }
executed: }
Execution Count:17
17
679 return -1;
executed: return -1;
Execution Count:2
2
680} -
681 -
682int QGridLayoutEngine::effectiveFirstRow(Qt::Orientation orientation) const -
683{ -
684 ensureEffectiveFirstAndLastRows(); -
685 return q_cachedEffectiveFirstRows[orientation == Qt::Vertical];
never executed: return q_cachedEffectiveFirstRows[orientation == Qt::Vertical];
0
686} -
687 -
688int QGridLayoutEngine::effectiveLastRow(Qt::Orientation orientation) const -
689{ -
690 ensureEffectiveFirstAndLastRows(); -
691 return q_cachedEffectiveLastRows[orientation == Qt::Vertical];
executed: return q_cachedEffectiveLastRows[orientation == Qt::Vertical];
Execution Count:1438
1438
692} -
693 -
694void QGridLayoutEngine::setSpacing(qreal spacing, Qt::Orientations orientations) -
695{ -
696 qt_noop(); -
697 if (orientations & Qt::Horizontal)
evaluated: orientations & Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:183
yes
Evaluation Count:3
3-183
698 q_defaultSpacings[Hor].setUserValue(spacing);
executed: q_defaultSpacings[Hor].setUserValue(spacing);
Execution Count:183
183
699 if (orientations & Qt::Vertical)
evaluated: orientations & Qt::Vertical
TRUEFALSE
yes
Evaluation Count:183
yes
Evaluation Count:3
3-183
700 q_defaultSpacings[Ver].setUserValue(spacing);
executed: q_defaultSpacings[Ver].setUserValue(spacing);
Execution Count:183
183
701 -
702 invalidate(); -
703}
executed: }
Execution Count:186
186
704 -
705qreal QGridLayoutEngine::spacing(const QLayoutStyleInfo &styleInfo, Qt::Orientation orientation) const -
706{ -
707 if (q_defaultSpacings[orientation == Qt::Vertical].isDefault()) {
evaluated: q_defaultSpacings[orientation == Qt::Vertical].isDefault()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:22
8-22
708 QStyle *style = styleInfo.style(); -
709 QStyleOption option; -
710 option.initFrom(styleInfo.widget()); -
711 qreal defaultSpacing = (qreal)style->pixelMetric(orientation == Qt::Vertical ? QStyle::PM_LayoutVerticalSpacing -
712 : QStyle::PM_LayoutHorizontalSpacing, &option, styleInfo.widget()); -
713 q_defaultSpacings[orientation == Qt::Vertical].setCachedValue(defaultSpacing); -
714 }
executed: }
Execution Count:8
8
715 return q_defaultSpacings[orientation == Qt::Vertical].value();
executed: return q_defaultSpacings[orientation == Qt::Vertical].value();
Execution Count:30
30
716} -
717 -
718void QGridLayoutEngine::setRowSpacing(int row, qreal spacing, Qt::Orientation orientation) -
719{ -
720 qt_noop(); -
721 -
722 QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical]; -
723 if (row >= rowInfo.spacings.count())
evaluated: row >= rowInfo.spacings.count()
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:1
1-34
724 rowInfo.spacings.resize(row + 1);
executed: rowInfo.spacings.resize(row + 1);
Execution Count:34
34
725 if (spacing >= 0)
evaluated: spacing >= 0
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:1
1-34
726 rowInfo.spacings[row].setUserValue(spacing);
executed: rowInfo.spacings[row].setUserValue(spacing);
Execution Count:34
34
727 else -
728 rowInfo.spacings[row] = QLayoutParameter<qreal>();
executed: rowInfo.spacings[row] = QLayoutParameter<qreal>();
Execution Count:1
1
729 invalidate(); -
730}
executed: }
Execution Count:35
35
731 -
732qreal QGridLayoutEngine::rowSpacing(int row, Qt::Orientation orientation) const -
733{ -
734 QLayoutParameter<qreal> spacing = q_infos[orientation == Qt::Vertical].spacings.value(row); -
735 if (!spacing.isDefault())
evaluated: !spacing.isDefault()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:14
1-14
736 return spacing.value();
executed: return spacing.value();
Execution Count:1
1
737 return q_defaultSpacings[orientation == Qt::Vertical].value();
executed: return q_defaultSpacings[orientation == Qt::Vertical].value();
Execution Count:14
14
738} -
739 -
740void QGridLayoutEngine::setRowStretchFactor(int row, int stretch, Qt::Orientation orientation) -
741{ -
742 qt_noop(); -
743 qt_noop(); -
744 -
745 maybeExpandGrid(row, -1, orientation); -
746 -
747 QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical]; -
748 if (row >= rowInfo.stretches.count())
evaluated: row >= rowInfo.stretches.count()
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:2
2-42
749 rowInfo.stretches.resize(row + 1);
executed: rowInfo.stretches.resize(row + 1);
Execution Count:42
42
750 rowInfo.stretches[row].setUserValue(stretch); -
751}
executed: }
Execution Count:44
44
752 -
753int QGridLayoutEngine::rowStretchFactor(int row, Qt::Orientation orientation) const -
754{ -
755 QStretchParameter stretch = q_infos[orientation == Qt::Vertical].stretches.value(row); -
756 if (!stretch.isDefault())
partially evaluated: !stretch.isDefault()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
757 return stretch.value();
never executed: return stretch.value();
0
758 return 0;
executed: return 0;
Execution Count:2
2
759} -
760 -
761void QGridLayoutEngine::setStretchFactor(QGraphicsLayoutItem *layoutItem, int stretch, -
762 Qt::Orientation orientation) -
763{ -
764 qt_noop(); -
765 -
766 if (QGridLayoutItem *item = findLayoutItem(layoutItem))
partially evaluated: QGridLayoutItem *item = findLayoutItem(layoutItem)
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
767 item->setStretchFactor(stretch, orientation);
executed: item->setStretchFactor(stretch, orientation);
Execution Count:9
9
768}
executed: }
Execution Count:9
9
769 -
770int QGridLayoutEngine::stretchFactor(QGraphicsLayoutItem *layoutItem, Qt::Orientation orientation) const -
771{ -
772 if (QGridLayoutItem *item = findLayoutItem(layoutItem))
partially evaluated: QGridLayoutItem *item = findLayoutItem(layoutItem)
TRUEFALSE
yes
Evaluation Count:91
no
Evaluation Count:0
0-91
773 return item->stretchFactor(orientation);
executed: return item->stretchFactor(orientation);
Execution Count:91
91
774 return 0;
never executed: return 0;
0
775} -
776 -
777void QGridLayoutEngine::setRowSizeHint(Qt::SizeHint which, int row, qreal size, -
778 Qt::Orientation orientation) -
779{ -
780 qt_noop(); -
781 qt_noop(); -
782 -
783 maybeExpandGrid(row, -1, orientation); -
784 -
785 QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical]; -
786 if (row >= rowInfo.boxes.count())
evaluated: row >= rowInfo.boxes.count()
TRUEFALSE
yes
Evaluation Count:54
yes
Evaluation Count:14
14-54
787 rowInfo.boxes.resize(row + 1);
executed: rowInfo.boxes.resize(row + 1);
Execution Count:54
54
788 rowInfo.boxes[row].q_sizes(which) = size; -
789}
executed: }
Execution Count:68
68
790 -
791qreal QGridLayoutEngine::rowSizeHint(Qt::SizeHint which, int row, Qt::Orientation orientation) const -
792{ -
793 return q_infos[orientation == Qt::Vertical].boxes.value(row).q_sizes(which);
executed: return q_infos[orientation == Qt::Vertical].boxes.value(row).q_sizes(which);
Execution Count:66
66
794} -
795 -
796void QGridLayoutEngine::setRowAlignment(int row, Qt::Alignment alignment, -
797 Qt::Orientation orientation) -
798{ -
799 qt_noop(); -
800 -
801 maybeExpandGrid(row, -1, orientation); -
802 -
803 QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical]; -
804 if (row >= rowInfo.alignments.count())
partially evaluated: row >= rowInfo.alignments.count()
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
0-16
805 rowInfo.alignments.resize(row + 1);
executed: rowInfo.alignments.resize(row + 1);
Execution Count:16
16
806 rowInfo.alignments[row] = alignment; -
807}
executed: }
Execution Count:16
16
808 -
809Qt::Alignment QGridLayoutEngine::rowAlignment(int row, Qt::Orientation orientation) const -
810{ -
811 qt_noop(); -
812 return q_infos[orientation == Qt::Vertical].alignments.value(row);
executed: return q_infos[orientation == Qt::Vertical].alignments.value(row);
Execution Count:2302
2302
813} -
814 -
815void QGridLayoutEngine::setAlignment(QGraphicsLayoutItem *layoutItem, Qt::Alignment alignment) -
816{ -
817 if (QGridLayoutItem *item = findLayoutItem(layoutItem))
evaluated: QGridLayoutItem *item = findLayoutItem(layoutItem)
TRUEFALSE
yes
Evaluation Count:296
yes
Evaluation Count:3
3-296
818 item->setAlignment(alignment);
executed: item->setAlignment(alignment);
Execution Count:296
296
819 invalidate(); -
820}
executed: }
Execution Count:299
299
821 -
822Qt::Alignment QGridLayoutEngine::alignment(QGraphicsLayoutItem *layoutItem) const -
823{ -
824 if (QGridLayoutItem *item = findLayoutItem(layoutItem))
evaluated: QGridLayoutItem *item = findLayoutItem(layoutItem)
TRUEFALSE
yes
Evaluation Count:144
yes
Evaluation Count:5
5-144
825 return item->alignment();
executed: return item->alignment();
Execution Count:144
144
826 return 0;
executed: return 0;
Execution Count:5
5
827} -
828 -
829Qt::Alignment QGridLayoutEngine::effectiveAlignment(const QGridLayoutItem *layoutItem) const -
830{ -
831 Qt::Alignment align = layoutItem->alignment(); -
832 if (!(align & Qt::AlignVertical_Mask)) {
evaluated: !(align & Qt::AlignVertical_Mask)
TRUEFALSE
yes
Evaluation Count:1157
yes
Evaluation Count:95
95-1157
833 -
834 int y = layoutItem->firstRow(); -
835 align |= (rowAlignment(y, Qt::Vertical) & Qt::AlignVertical_Mask); -
836 }
executed: }
Execution Count:1157
1157
837 if (!(align & Qt::AlignHorizontal_Mask)) {
evaluated: !(align & Qt::AlignHorizontal_Mask)
TRUEFALSE
yes
Evaluation Count:1125
yes
Evaluation Count:127
127-1125
838 -
839 int x = layoutItem->firstColumn(); -
840 align |= (rowAlignment(x, Qt::Horizontal) & Qt::AlignHorizontal_Mask); -
841 }
executed: }
Execution Count:1125
1125
842 return align;
executed: return align;
Execution Count:1252
1252
843} -
844 -
845 -
846 -
847 -
848 -
849 -
850 -
851void QGridLayoutEngine::insertItem(QGridLayoutItem *item, int index) -
852{ -
853 maybeExpandGrid(item->lastRow(), item->lastColumn()); -
854 -
855 if (index == -1)
evaluated: index == -1
TRUEFALSE
yes
Evaluation Count:705
yes
Evaluation Count:637
637-705
856 q_items.append(item);
executed: q_items.append(item);
Execution Count:705
705
857 else -
858 q_items.insert(index, item);
executed: q_items.insert(index, item);
Execution Count:637
637
859 -
860 for (int i = item->firstRow(); i <= item->lastRow(); ++i) {
evaluated: i <= item->lastRow()
TRUEFALSE
yes
Evaluation Count:1389
yes
Evaluation Count:1342
1342-1389
861 for (int j = item->firstColumn(); j <= item->lastColumn(); ++j) {
evaluated: j <= item->lastColumn()
TRUEFALSE
yes
Evaluation Count:1399
yes
Evaluation Count:1389
1389-1399
862 if (itemAt(i, j))
partially evaluated: itemAt(i, j)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1399
0-1399
863 QMessageLogger("graphicsview/qgridlayoutengine.cpp", 1018, __PRETTY_FUNCTION__).warning("QGridLayoutEngine::addItem: Cell (%d, %d) already taken", i, j);
never executed: QMessageLogger("graphicsview/qgridlayoutengine.cpp", 1018, __PRETTY_FUNCTION__).warning("QGridLayoutEngine::addItem: Cell (%d, %d) already taken", i, j);
0
864 setItemAt(i, j, item); -
865 }
executed: }
Execution Count:1399
1399
866 }
executed: }
Execution Count:1389
1389
867}
executed: }
Execution Count:1342
1342
868 -
869void QGridLayoutEngine::addItem(QGridLayoutItem *item) -
870{ -
871 insertItem(item, -1); -
872}
never executed: }
0
873 -
874void QGridLayoutEngine::removeItem(QGridLayoutItem *item) -
875{ -
876 qt_noop(); -
877 -
878 invalidate(); -
879 -
880 for (int i = item->firstRow(); i <= item->lastRow(); ++i) {
evaluated: i <= item->lastRow()
TRUEFALSE
yes
Evaluation Count:1134
yes
Evaluation Count:1127
1127-1134
881 for (int j = item->firstColumn(); j <= item->lastColumn(); ++j) {
evaluated: j <= item->lastColumn()
TRUEFALSE
yes
Evaluation Count:1138
yes
Evaluation Count:1134
1134-1138
882 if (itemAt(i, j) == item)
partially evaluated: itemAt(i, j) == item
TRUEFALSE
yes
Evaluation Count:1138
no
Evaluation Count:0
0-1138
883 setItemAt(i, j, 0);
executed: setItemAt(i, j, 0);
Execution Count:1138
1138
884 }
executed: }
Execution Count:1138
1138
885 }
executed: }
Execution Count:1134
1134
886 -
887 q_items.removeAll(item); -
888}
executed: }
Execution Count:1127
1127
889 -
890QGridLayoutItem *QGridLayoutEngine::findLayoutItem(QGraphicsLayoutItem *layoutItem) const -
891{ -
892 for (int i = q_items.count() - 1; i >= 0; --i) {
evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:1266
yes
Evaluation Count:10
10-1266
893 QGridLayoutItem *item = q_items.at(i); -
894 if (item->layoutItem() == layoutItem)
evaluated: item->layoutItem() == layoutItem
TRUEFALSE
yes
Evaluation Count:546
yes
Evaluation Count:720
546-720
895 return item;
executed: return item;
Execution Count:546
546
896 }
executed: }
Execution Count:720
720
897 return 0;
executed: return 0;
Execution Count:10
10
898} -
899 -
900QGridLayoutItem *QGridLayoutEngine::itemAt(int row, int column, Qt::Orientation orientation) const -
901{ -
902 if (orientation == Qt::Horizontal)
evaluated: orientation == Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:12803
yes
Evaluation Count:14800
12803-14800
903 qSwap(row, column);
executed: qSwap(row, column);
Execution Count:12803
12803
904 if (uint(row) >= uint(rowCount()) || uint(column) >= uint(columnCount()))
partially evaluated: uint(row) >= uint(rowCount())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:27603
partially evaluated: uint(column) >= uint(columnCount())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:27603
0-27603
905 return 0;
never executed: return 0;
0
906 return q_grid.at((row * internalGridColumnCount()) + column);
executed: return q_grid.at((row * internalGridColumnCount()) + column);
Execution Count:27603
27603
907} -
908 -
909void QGridLayoutEngine::invalidate() -
910{ -
911 q_cachedEffectiveFirstRows[Hor] = -1; -
912 q_cachedEffectiveFirstRows[Ver] = -1; -
913 q_cachedEffectiveLastRows[Hor] = -1; -
914 q_cachedEffectiveLastRows[Ver] = -1; -
915 q_cachedDataForStyleInfo.invalidate(); -
916 q_cachedSize = QSizeF(); -
917 q_cachedConstraintOrientation = UnknownConstraint; -
918}
executed: }
Execution Count:10393
10393
919 -
920static void visualRect(QRectF *geom, Qt::LayoutDirection dir, const QRectF &contentsRect) -
921{ -
922 if (dir == Qt::RightToLeft)
evaluated: dir == Qt::RightToLeft
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:1242
10-1242
923 geom->moveRight(contentsRect.right() - (geom->left() - contentsRect.left()));
executed: geom->moveRight(contentsRect.right() - (geom->left() - contentsRect.left()));
Execution Count:10
10
924}
executed: }
Execution Count:1252
1252
925 -
926void QGridLayoutEngine::setGeometries(const QLayoutStyleInfo &styleInfo, -
927 const QRectF &contentsGeometry) -
928{ -
929 if (rowCount() < 1 || columnCount() < 1)
evaluated: rowCount() < 1
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:445
evaluated: columnCount() < 1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:443
2-445
930 return;
executed: return;
Execution Count:54
54
931 -
932 ensureGeometries(styleInfo, contentsGeometry.size()); -
933 -
934 for (int i = q_items.count() - 1; i >= 0; --i) {
evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:1252
yes
Evaluation Count:443
443-1252
935 QGridLayoutItem *item = q_items.at(i); -
936 -
937 qreal x = q_xx[item->firstColumn()]; -
938 qreal y = q_yy[item->firstRow()]; -
939 qreal width = q_widths[item->lastColumn()]; -
940 qreal height = q_heights[item->lastRow()]; -
941 -
942 if (item->columnSpan() != 1)
evaluated: item->columnSpan() != 1
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1248
4-1248
943 width += q_xx[item->lastColumn()] - x;
executed: width += q_xx[item->lastColumn()] - x;
Execution Count:4
4
944 if (item->rowSpan() != 1)
evaluated: item->rowSpan() != 1
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:1228
24-1228
945 height += q_yy[item->lastRow()] - y;
executed: height += q_yy[item->lastRow()] - y;
Execution Count:24
24
946 -
947 QRectF geom = item->geometryWithin(contentsGeometry.x() + x, contentsGeometry.y() + y, -
948 width, height, q_descents[item->lastRow()]); -
949 visualRect(&geom, visualDirection(), contentsGeometry); -
950 item->setGeometry(geom); -
951 }
executed: }
Execution Count:1252
1252
952}
executed: }
Execution Count:443
443
953 -
954 -
955QRectF QGridLayoutEngine::cellRect(const QLayoutStyleInfo &styleInfo, -
956 const QRectF &contentsGeometry, int row, int column, int rowSpan, -
957 int columnSpan) const -
958{ -
959 if (uint(row) >= uint(rowCount()) || uint(column) >= uint(columnCount())
never evaluated: uint(row) >= uint(rowCount())
never evaluated: uint(column) >= uint(columnCount())
0
960 || rowSpan < 1 || columnSpan < 1)
never evaluated: rowSpan < 1
never evaluated: columnSpan < 1
0
961 return QRectF();
never executed: return QRectF();
0
962 -
963 ensureGeometries(styleInfo, contentsGeometry.size()); -
964 -
965 int lastColumn = qMax(column + columnSpan, columnCount()) - 1; -
966 int lastRow = qMax(row + rowSpan, rowCount()) - 1; -
967 -
968 qreal x = q_xx[column]; -
969 qreal y = q_yy[row]; -
970 qreal width = q_widths[lastColumn]; -
971 qreal height = q_heights[lastRow]; -
972 -
973 if (columnSpan != 1)
never evaluated: columnSpan != 1
0
974 width += q_xx[lastColumn] - x;
never executed: width += q_xx[lastColumn] - x;
0
975 if (rowSpan != 1)
never evaluated: rowSpan != 1
0
976 height += q_yy[lastRow] - y;
never executed: height += q_yy[lastRow] - y;
0
977 -
978 return QRectF(contentsGeometry.x() + x, contentsGeometry.y() + y, width, height);
never executed: return QRectF(contentsGeometry.x() + x, contentsGeometry.y() + y, width, height);
0
979} -
980 -
981QSizeF QGridLayoutEngine::sizeHint(const QLayoutStyleInfo &styleInfo, Qt::SizeHint which, -
982 const QSizeF &constraint) const -
983{ -
984 QGridLayoutBox sizehint_totalBoxes[NOrientations]; -
985 -
986 bool sizeHintCalculated = false; -
987 -
988 if (hasDynamicConstraint() && rowCount() > 0 && columnCount() > 0) {
evaluated: hasDynamicConstraint()
TRUEFALSE
yes
Evaluation Count:190
yes
Evaluation Count:1331
partially evaluated: rowCount() > 0
TRUEFALSE
yes
Evaluation Count:190
no
Evaluation Count:0
partially evaluated: columnCount() > 0
TRUEFALSE
yes
Evaluation Count:190
no
Evaluation Count:0
0-1331
989 if (constraintOrientation() == Qt::Vertical) {
evaluated: constraintOrientation() == Qt::Vertical
TRUEFALSE
yes
Evaluation Count:163
yes
Evaluation Count:27
27-163
990 -
991 if (constraint.width() >= 0) {
evaluated: constraint.width() >= 0
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:145
18-145
992 if (q_cachedDataForStyleInfo != styleInfo)
partially evaluated: q_cachedDataForStyleInfo != styleInfo
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
0-18
993 ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], styleInfo, __null, __null, Qt::Horizontal);
executed: ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], styleInfo, __null, __null, Qt::Horizontal);
Execution Count:18
18
994 else -
995 sizehint_totalBoxes[Hor] = q_totalBoxes[Hor];
never executed: sizehint_totalBoxes[Hor] = q_totalBoxes[Hor];
0
996 QVector<qreal> sizehint_xx; -
997 QVector<qreal> sizehint_widths; -
998 -
999 sizehint_xx.resize(columnCount()); -
1000 sizehint_widths.resize(columnCount()); -
1001 qreal width = constraint.width(); -
1002 -
1003 -
1004 q_columnData.calculateGeometries(0, columnCount(), width, sizehint_xx.data(), sizehint_widths.data(), -
1005 0, sizehint_totalBoxes[Hor], q_infos[Hor]); -
1006 ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], styleInfo, sizehint_xx.data(), sizehint_widths.data(), Qt::Vertical); -
1007 sizeHintCalculated = true; -
1008 }
executed: }
Execution Count:18
18
1009 } else {
executed: }
Execution Count:163
163
1010 if (constraint.height() >= 0) {
evaluated: constraint.height() >= 0
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:15
12-15
1011 -
1012 ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], styleInfo, __null, __null, Qt::Vertical); -
1013 QVector<qreal> sizehint_yy; -
1014 QVector<qreal> sizehint_heights; -
1015 -
1016 sizehint_yy.resize(rowCount()); -
1017 sizehint_heights.resize(rowCount()); -
1018 qreal height = constraint.height(); -
1019 -
1020 -
1021 q_rowData.calculateGeometries(0, rowCount(), height, sizehint_yy.data(), sizehint_heights.data(), -
1022 0, sizehint_totalBoxes[Ver], q_infos[Ver]); -
1023 ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], styleInfo, sizehint_yy.data(), sizehint_heights.data(), Qt::Horizontal); -
1024 sizeHintCalculated = true; -
1025 }
executed: }
Execution Count:12
12
1026 }
executed: }
Execution Count:27
27
1027 } -
1028 -
1029 if (!sizeHintCalculated) {
evaluated: !sizeHintCalculated
TRUEFALSE
yes
Evaluation Count:1491
yes
Evaluation Count:30
30-1491
1030 -
1031 if (q_cachedDataForStyleInfo != styleInfo) {
evaluated: q_cachedDataForStyleInfo != styleInfo
TRUEFALSE
yes
Evaluation Count:1455
yes
Evaluation Count:36
36-1455
1032 ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], styleInfo, __null, __null, Qt::Horizontal); -
1033 ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], styleInfo, __null, __null, Qt::Vertical); -
1034 } else {
executed: }
Execution Count:1455
1455
1035 sizehint_totalBoxes[Hor] = q_totalBoxes[Hor]; -
1036 sizehint_totalBoxes[Ver] = q_totalBoxes[Ver]; -
1037 }
executed: }
Execution Count:36
36
1038 } -
1039 -
1040 switch (which) { -
1041 case Qt::MinimumSize: -
1042 return QSizeF(sizehint_totalBoxes[Hor].q_minimumSize, sizehint_totalBoxes[Ver].q_minimumSize);
executed: return QSizeF(sizehint_totalBoxes[Hor].q_minimumSize, sizehint_totalBoxes[Ver].q_minimumSize);
Execution Count:431
431
1043 case Qt::PreferredSize: -
1044 return QSizeF(sizehint_totalBoxes[Hor].q_preferredSize, sizehint_totalBoxes[Ver].q_preferredSize);
executed: return QSizeF(sizehint_totalBoxes[Hor].q_preferredSize, sizehint_totalBoxes[Ver].q_preferredSize);
Execution Count:673
673
1045 case Qt::MaximumSize: -
1046 return QSizeF(sizehint_totalBoxes[Hor].q_maximumSize, sizehint_totalBoxes[Ver].q_maximumSize);
executed: return QSizeF(sizehint_totalBoxes[Hor].q_maximumSize, sizehint_totalBoxes[Ver].q_maximumSize);
Execution Count:417
417
1047 case Qt::MinimumDescent: -
1048 return QSizeF(-1.0, sizehint_totalBoxes[Hor].q_minimumDescent);
never executed: return QSizeF(-1.0, sizehint_totalBoxes[Hor].q_minimumDescent);
0
1049 default: -
1050 break;
never executed: break;
0
1051 } -
1052 return QSizeF();
never executed: return QSizeF();
0
1053} -
1054 -
1055QSizePolicy::ControlTypes QGridLayoutEngine::controlTypes(LayoutSide side) const -
1056{ -
1057 Qt::Orientation orientation = (side == Top || side == Bottom) ? Qt::Vertical : Qt::Horizontal;
never evaluated: side == Top
never evaluated: side == Bottom
0
1058 int row = (side == Top || side == Left) ? effectiveFirstRow(orientation)
never evaluated: side == Top
never evaluated: side == Left
0
1059 : effectiveLastRow(orientation); -
1060 QSizePolicy::ControlTypes result = 0; -
1061 -
1062 for (int column = columnCount(orientation) - 1; column >= 0; --column) {
never evaluated: column >= 0
0
1063 if (QGridLayoutItem *item = itemAt(row, column, orientation))
never evaluated: QGridLayoutItem *item = itemAt(row, column, orientation)
0
1064 result |= item->controlTypes(side);
never executed: result |= item->controlTypes(side);
0
1065 }
never executed: }
0
1066 return result;
never executed: return result;
0
1067} -
1068 -
1069void QGridLayoutEngine::transpose() -
1070{ -
1071 invalidate(); -
1072 -
1073 for (int i = q_items.count() - 1; i >= 0; --i)
evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:8
8-9
1074 q_items.at(i)->transpose();
executed: q_items.at(i)->transpose();
Execution Count:9
9
1075 -
1076 qSwap(q_defaultSpacings[Hor], q_defaultSpacings[Ver]); -
1077 qSwap(q_infos[Hor], q_infos[Ver]); -
1078 -
1079 regenerateGrid(); -
1080}
executed: }
Execution Count:8
8
1081 -
1082void QGridLayoutEngine::setVisualDirection(Qt::LayoutDirection direction) -
1083{ -
1084 m_visualDirection = direction; -
1085}
executed: }
Execution Count:497
497
1086 -
1087Qt::LayoutDirection QGridLayoutEngine::visualDirection() const -
1088{ -
1089 return m_visualDirection;
executed: return m_visualDirection;
Execution Count:1252
1252
1090} -
1091void QGridLayoutEngine::maybeExpandGrid(int row, int column, Qt::Orientation orientation) -
1092{ -
1093 invalidate(); -
1094 -
1095 if (orientation == Qt::Horizontal)
evaluated: orientation == Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:613
yes
Evaluation Count:1497
613-1497
1096 qSwap(row, column);
executed: qSwap(row, column);
Execution Count:613
613
1097 -
1098 if (row < rowCount() && column < columnCount())
evaluated: row < rowCount()
TRUEFALSE
yes
Evaluation Count:1559
yes
Evaluation Count:551
evaluated: column < columnCount()
TRUEFALSE
yes
Evaluation Count:765
yes
Evaluation Count:794
551-1559
1099 return;
executed: return;
Execution Count:765
765
1100 -
1101 int oldGridRowCount = internalGridRowCount(); -
1102 int oldGridColumnCount = internalGridColumnCount(); -
1103 -
1104 q_infos[Ver].count = qMax(row + 1, rowCount()); -
1105 q_infos[Hor].count = qMax(column + 1, columnCount()); -
1106 -
1107 int newGridRowCount = internalGridRowCount(); -
1108 int newGridColumnCount = internalGridColumnCount(); -
1109 -
1110 int newGridSize = newGridRowCount * newGridColumnCount; -
1111 if (newGridSize != q_grid.count()) {
evaluated: newGridSize != q_grid.count()
TRUEFALSE
yes
Evaluation Count:773
yes
Evaluation Count:572
572-773
1112 q_grid.resize(newGridSize); -
1113 -
1114 if (newGridColumnCount != oldGridColumnCount) {
evaluated: newGridColumnCount != oldGridColumnCount
TRUEFALSE
yes
Evaluation Count:281
yes
Evaluation Count:492
281-492
1115 for (int i = oldGridRowCount - 1; i >= 1; --i) {
evaluated: i >= 1
TRUEFALSE
yes
Evaluation Count:168
yes
Evaluation Count:281
168-281
1116 for (int j = oldGridColumnCount - 1; j >= 0; --j) {
evaluated: j >= 0
TRUEFALSE
yes
Evaluation Count:168
yes
Evaluation Count:168
168
1117 int oldIndex = (i * oldGridColumnCount) + j; -
1118 int newIndex = (i * newGridColumnCount) + j; -
1119 -
1120 qt_noop(); -
1121 q_grid[newIndex] = q_grid[oldIndex]; -
1122 q_grid[oldIndex] = 0; -
1123 }
executed: }
Execution Count:168
168
1124 }
executed: }
Execution Count:168
168
1125 }
executed: }
Execution Count:281
281
1126 }
executed: }
Execution Count:773
773
1127}
executed: }
Execution Count:1345
1345
1128 -
1129void QGridLayoutEngine::regenerateGrid() -
1130{ -
1131 q_grid.fill(0); -
1132 -
1133 for (int i = q_items.count() - 1; i >= 0; --i) {
evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:3245
yes
Evaluation Count:1498
1498-3245
1134 QGridLayoutItem *item = q_items.at(i); -
1135 -
1136 for (int j = item->firstRow(); j <= item->lastRow(); ++j) {
evaluated: j <= item->lastRow()
TRUEFALSE
yes
Evaluation Count:3266
yes
Evaluation Count:3245
3245-3266
1137 for (int k = item->firstColumn(); k <= item->lastColumn(); ++k) {
evaluated: k <= item->lastColumn()
TRUEFALSE
yes
Evaluation Count:3278
yes
Evaluation Count:3266
3266-3278
1138 setItemAt(j, k, item); -
1139 }
executed: }
Execution Count:3278
3278
1140 }
executed: }
Execution Count:3266
3266
1141 }
executed: }
Execution Count:3245
3245
1142}
executed: }
Execution Count:1498
1498
1143 -
1144void QGridLayoutEngine::setItemAt(int row, int column, QGridLayoutItem *item) -
1145{ -
1146 qt_noop(); -
1147 qt_noop(); -
1148 q_grid[(row * internalGridColumnCount()) + column] = item; -
1149}
executed: }
Execution Count:5815
5815
1150 -
1151void QGridLayoutEngine::insertOrRemoveRows(int row, int delta, Qt::Orientation orientation) -
1152{ -
1153 int oldRowCount = rowCount(orientation); -
1154 qt_noop(); -
1155 -
1156 invalidate(); -
1157 -
1158 -
1159 if (row == oldRowCount && delta > 0) {
evaluated: row == oldRowCount
TRUEFALSE
yes
Evaluation Count:1021
yes
Evaluation Count:1109
evaluated: delta > 0
TRUEFALSE
yes
Evaluation Count:640
yes
Evaluation Count:381
381-1109
1160 maybeExpandGrid(oldRowCount + delta - 1, -1, orientation); -
1161 return;
executed: return;
Execution Count:640
640
1162 } -
1163 -
1164 q_infos[orientation == Qt::Vertical].insertOrRemoveRows(row, delta); -
1165 -
1166 for (int i = q_items.count() - 1; i >= 0; --i)
evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:3236
yes
Evaluation Count:1490
1490-3236
1167 q_items.at(i)->insertOrRemoveRows(row, delta, orientation);
executed: q_items.at(i)->insertOrRemoveRows(row, delta, orientation);
Execution Count:3236
3236
1168 -
1169 q_grid.resize(internalGridRowCount() * internalGridColumnCount()); -
1170 regenerateGrid(); -
1171}
executed: }
Execution Count:1490
1490
1172 -
1173void QGridLayoutEngine::fillRowData(QGridLayoutRowData *rowData, const QLayoutStyleInfo &styleInfo, -
1174 qreal *colPositions, qreal *colSizes, -
1175 Qt::Orientation orientation) const -
1176{ -
1177 const int ButtonMask = QSizePolicy::ButtonBox | QSizePolicy::PushButton; -
1178 const QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical]; -
1179 const QGridLayoutRowInfo &columnInfo = q_infos[orientation == Qt::Horizontal]; -
1180 LayoutSide top = (orientation == Qt::Vertical) ? Top : Left;
evaluated: (orientation == Qt::Vertical)
TRUEFALSE
yes
Evaluation Count:1850
yes
Evaluation Count:1850
1850
1181 LayoutSide bottom = (orientation == Qt::Vertical) ? Bottom : Right;
evaluated: (orientation == Qt::Vertical)
TRUEFALSE
yes
Evaluation Count:1850
yes
Evaluation Count:1850
1850
1182 -
1183 QStyle *style = styleInfo.style(); -
1184 QStyleOption option; -
1185 option.initFrom(styleInfo.widget()); -
1186 -
1187 const QLayoutParameter<qreal> &defaultSpacing = q_defaultSpacings[orientation == Qt::Vertical]; -
1188 qreal innerSpacing = 0.0; -
1189 if (style)
partially evaluated: style
TRUEFALSE
yes
Evaluation Count:3700
no
Evaluation Count:0
0-3700
1190 innerSpacing = (qreal)style->pixelMetric(orientation == Qt::Vertical ? QStyle::PM_LayoutVerticalSpacing 3700
1191 : QStyle::PM_LayoutHorizontalSpacing, 3700
1192 &option, styleInfo.widget());
executed: innerSpacing = (qreal)style->pixelMetric(orientation == Qt::Vertical ? QStyle::PM_LayoutVerticalSpacing : QStyle::PM_LayoutHorizontalSpacing, &option, styleInfo.widget());
Execution Count:3700
3700
1193 if (innerSpacing >= 0.0)
partially evaluated: innerSpacing >= 0.0
TRUEFALSE
yes
Evaluation Count:3700
no
Evaluation Count:0
0-3700
1194 defaultSpacing.setCachedValue(innerSpacing);
executed: defaultSpacing.setCachedValue(innerSpacing);
Execution Count:3700
3700
1195 -
1196 for (int row = 0; row < rowInfo.count; ++row) {
evaluated: row < rowInfo.count
TRUEFALSE
yes
Evaluation Count:5981
yes
Evaluation Count:3700
3700-5981
1197 bool rowIsEmpty = true; -
1198 bool rowIsIdenticalToPrevious = (row > 0); -
1199 -
1200 for (int column = 0; column < columnInfo.count; ++column) {
evaluated: column < columnInfo.count
TRUEFALSE
yes
Evaluation Count:10864
yes
Evaluation Count:5981
5981-10864
1201 QGridLayoutItem *item = itemAt(row, column, orientation); -
1202 -
1203 if (rowIsIdenticalToPrevious && item != itemAt(row - 1, column, orientation))
evaluated: rowIsIdenticalToPrevious
TRUEFALSE
yes
Evaluation Count:3108
yes
Evaluation Count:7756
evaluated: item != itemAt(row - 1, column, orientation)
TRUEFALSE
yes
Evaluation Count:2912
yes
Evaluation Count:196
196-7756
1204 rowIsIdenticalToPrevious = false;
executed: rowIsIdenticalToPrevious = false;
Execution Count:2912
2912
1205 -
1206 if (item)
evaluated: item
TRUEFALSE
yes
Evaluation Count:10628
yes
Evaluation Count:236
236-10628
1207 rowIsEmpty = false;
executed: rowIsEmpty = false;
Execution Count:10628
10628
1208 }
executed: }
Execution Count:10864
10864
1209 -
1210 if ((rowIsEmpty || rowIsIdenticalToPrevious)
evaluated: rowIsEmpty
TRUEFALSE
yes
Evaluation Count:153
yes
Evaluation Count:5828
evaluated: rowIsIdenticalToPrevious
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:5802
26-5828
1211 && rowInfo.spacings.value(row).isDefault()
evaluated: rowInfo.spacings.value(row).isDefault()
TRUEFALSE
yes
Evaluation Count:174
yes
Evaluation Count:5
5-174
1212 && rowInfo.stretches.value(row).isDefault()
evaluated: rowInfo.stretches.value(row).isDefault()
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:142
32-142
1213 && rowInfo.boxes.value(row) == QGridLayoutBox())
partially evaluated: rowInfo.boxes.value(row) == QGridLayoutBox()
TRUEFALSE
yes
Evaluation Count:32
no
Evaluation Count:0
0-32
1214 rowData->ignore.setBit(row, true);
executed: rowData->ignore.setBit(row, true);
Execution Count:32
32
1215 -
1216 if (rowInfo.spacings.value(row).isUser()) {
evaluated: rowInfo.spacings.value(row).isUser()
TRUEFALSE
yes
Evaluation Count:171
yes
Evaluation Count:5810
171-5810
1217 rowData->spacings[row] = rowInfo.spacings.at(row).value(); -
1218 } else if (!defaultSpacing.isDefault()) {
executed: }
Execution Count:171
partially evaluated: !defaultSpacing.isDefault()
TRUEFALSE
yes
Evaluation Count:5810
no
Evaluation Count:0
0-5810
1219 rowData->spacings[row] = defaultSpacing.value(); -
1220 }
executed: }
Execution Count:5810
5810
1221 -
1222 rowData->stretches[row] = rowInfo.stretches.value(row).value(); -
1223 }
executed: }
Execution Count:5981
5981
1224 -
1225 struct RowAdHocData { -
1226 int q_row; -
1227 unsigned int q_hasButtons : 8; -
1228 unsigned int q_hasNonButtons : 8; -
1229 -
1230 inline RowAdHocData() : q_row(-1), q_hasButtons(false), q_hasNonButtons(false) {}
executed: }
Execution Count:11100
11100
1231 inline void init(int row) { -
1232 this->q_row = row; -
1233 q_hasButtons = false; -
1234 q_hasNonButtons = false; -
1235 }
executed: }
Execution Count:5949
5949
1236 inline bool hasOnlyButtons() const { return q_hasButtons && !q_hasNonButtons; }
executed: return q_hasButtons && !q_hasNonButtons;
Execution Count:7400
7400
1237 inline bool hasOnlyNonButtons() const { return q_hasNonButtons && !q_hasButtons; }
never executed: return q_hasNonButtons && !q_hasButtons;
0
1238 }; -
1239 RowAdHocData lastRowAdHocData; -
1240 RowAdHocData nextToLastRowAdHocData; -
1241 RowAdHocData nextToNextToLastRowAdHocData; -
1242 -
1243 rowData->hasIgnoreFlag = false; -
1244 for (int row = 0; row < rowInfo.count; ++row) {
evaluated: row < rowInfo.count
TRUEFALSE
yes
Evaluation Count:5981
yes
Evaluation Count:3700
3700-5981
1245 if (rowData->ignore.testBit(row))
evaluated: rowData->ignore.testBit(row)
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:5949
32-5949
1246 continue;
executed: continue;
Execution Count:32
32
1247 -
1248 QGridLayoutBox &rowBox = rowData->boxes[row]; -
1249 if (option.state & QStyle::State_Window) {
partially evaluated: option.state & QStyle::State_Window
TRUEFALSE
yes
Evaluation Count:5949
no
Evaluation Count:0
0-5949
1250 nextToNextToLastRowAdHocData = nextToLastRowAdHocData; -
1251 nextToLastRowAdHocData = lastRowAdHocData; -
1252 lastRowAdHocData.init(row); -
1253 }
executed: }
Execution Count:5949
5949
1254 -
1255 bool userRowStretch = rowInfo.stretches.value(row).isUser(); -
1256 int &rowStretch = rowData->stretches[row]; -
1257 -
1258 bool hasIgnoreFlag = true; -
1259 for (int column = 0; column < columnInfo.count; ++column) {
evaluated: column < columnInfo.count
TRUEFALSE
yes
Evaluation Count:10812
yes
Evaluation Count:5949
5949-10812
1260 QGridLayoutItem *item = itemAt(row, column, orientation); -
1261 if (item) {
evaluated: item
TRUEFALSE
yes
Evaluation Count:10576
yes
Evaluation Count:236
236-10576
1262 int itemRow = item->firstRow(orientation); -
1263 int itemColumn = item->firstColumn(orientation); -
1264 -
1265 if (itemRow == row && itemColumn == column) {
evaluated: itemRow == row
TRUEFALSE
yes
Evaluation Count:10415
yes
Evaluation Count:161
evaluated: itemColumn == column
TRUEFALSE
yes
Evaluation Count:10228
yes
Evaluation Count:187
161-10415
1266 int itemStretch = item->stretchFactor(orientation); -
1267 if (!(item->sizePolicy(orientation) & QSizePolicy::IgnoreFlag))
evaluated: !(item->sizePolicy(orientation) & QSizePolicy::IgnoreFlag)
TRUEFALSE
yes
Evaluation Count:10016
yes
Evaluation Count:212
212-10016
1268 hasIgnoreFlag = false;
executed: hasIgnoreFlag = false;
Execution Count:10016
10016
1269 int itemRowSpan = item->rowSpan(orientation); -
1270 -
1271 int effectiveRowSpan = 1; -
1272 for (int i = 1; i < itemRowSpan; ++i) {
evaluated: i < itemRowSpan
TRUEFALSE
yes
Evaluation Count:187
yes
Evaluation Count:10228
187-10228
1273 if (!rowData->ignore.testBit(i))
evaluated: !rowData->ignore.testBit(i)
TRUEFALSE
yes
Evaluation Count:161
yes
Evaluation Count:26
26-161
1274 ++effectiveRowSpan;
executed: ++effectiveRowSpan;
Execution Count:161
161
1275 }
executed: }
Execution Count:187
187
1276 -
1277 QGridLayoutBox *box; -
1278 if (effectiveRowSpan == 1) {
evaluated: effectiveRowSpan == 1
TRUEFALSE
yes
Evaluation Count:10067
yes
Evaluation Count:161
161-10067
1279 box = &rowBox; -
1280 if (!userRowStretch && itemStretch != 0)
evaluated: !userRowStretch
TRUEFALSE
yes
Evaluation Count:9982
yes
Evaluation Count:85
evaluated: itemStretch != 0
TRUEFALSE
yes
Evaluation Count:9581
yes
Evaluation Count:401
85-9982
1281 rowStretch = qMax(rowStretch, itemStretch);
executed: rowStretch = qMax(rowStretch, itemStretch);
Execution Count:9581
9581
1282 } else {
executed: }
Execution Count:10067
10067
1283 QGridLayoutMultiCellData &multiCell = -
1284 rowData->multiCellMap[qMakePair(row, effectiveRowSpan)]; -
1285 box = &multiCell.q_box; -
1286 multiCell.q_stretch = itemStretch; -
1287 }
executed: }
Execution Count:161
161
1288 -
1289 if (colSizes && colPositions && item->hasDynamicConstraint() && orientation == item->dynamicConstraintOrientation()) {
evaluated: colSizes
TRUEFALSE
yes
Evaluation Count:1199
yes
Evaluation Count:9029
partially evaluated: colPositions
TRUEFALSE
yes
Evaluation Count:1199
no
Evaluation Count:0
evaluated: item->hasDynamicConstraint()
TRUEFALSE
yes
Evaluation Count:214
yes
Evaluation Count:985
partially evaluated: orientation == item->dynamicConstraintOrientation()
TRUEFALSE
yes
Evaluation Count:214
no
Evaluation Count:0
0-9029
1290 -
1291 -
1292 -
1293 -
1294 -
1295 -
1296 qreal length = colSizes[item->lastColumn(orientation)]; -
1297 if (item->columnSpan(orientation) != 1)
evaluated: item->columnSpan(orientation) != 1
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:204
10-204
1298 length += colPositions[item->lastColumn(orientation)] - colPositions[item->firstColumn(orientation)];
executed: length += colPositions[item->lastColumn(orientation)] - colPositions[item->firstColumn(orientation)];
Execution Count:10
10
1299 box->combine(item->box(orientation, length)); -
1300 } else {
executed: }
Execution Count:214
214
1301 box->combine(item->box(orientation)); -
1302 }
executed: }
Execution Count:10014
10014
1303 -
1304 if (effectiveRowSpan == 1) {
evaluated: effectiveRowSpan == 1
TRUEFALSE
yes
Evaluation Count:10067
yes
Evaluation Count:161
161-10067
1305 QSizePolicy::ControlTypes controls = item->controlTypes(top); -
1306 if (controls & ButtonMask)
partially evaluated: controls & ButtonMask
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10067
0-10067
1307 lastRowAdHocData.q_hasButtons = true;
never executed: lastRowAdHocData.q_hasButtons = true;
0
1308 if (controls & ~ButtonMask)
partially evaluated: controls & ~ButtonMask
TRUEFALSE
yes
Evaluation Count:10067
no
Evaluation Count:0
0-10067
1309 lastRowAdHocData.q_hasNonButtons = true;
executed: lastRowAdHocData.q_hasNonButtons = true;
Execution Count:10067
10067
1310 }
executed: }
Execution Count:10067
10067
1311 }
executed: }
Execution Count:10228
10228
1312 }
executed: }
Execution Count:10576
10576
1313 }
executed: }
Execution Count:10812
10812
1314 if (row < rowInfo.boxes.count()) {
evaluated: row < rowInfo.boxes.count()
TRUEFALSE
yes
Evaluation Count:403
yes
Evaluation Count:5546
403-5546
1315 QGridLayoutBox rowBoxInfo = rowInfo.boxes.at(row); -
1316 rowBoxInfo.normalize(); -
1317 rowBox.q_minimumSize = qMax(rowBox.q_minimumSize, rowBoxInfo.q_minimumSize); -
1318 rowBox.q_maximumSize = qMax(rowBox.q_minimumSize, -
1319 (rowBoxInfo.q_maximumSize != 3.40282347e+38F ? -
1320 rowBoxInfo.q_maximumSize : rowBox.q_maximumSize)); -
1321 rowBox.q_preferredSize = qBound(rowBox.q_minimumSize, -
1322 qMax(rowBox.q_preferredSize, rowBoxInfo.q_preferredSize), -
1323 rowBox.q_maximumSize); -
1324 }
executed: }
Execution Count:403
403
1325 if (hasIgnoreFlag)
evaluated: hasIgnoreFlag
TRUEFALSE
yes
Evaluation Count:208
yes
Evaluation Count:5741
208-5741
1326 rowData->hasIgnoreFlag = true;
executed: rowData->hasIgnoreFlag = true;
Execution Count:208
208
1327 }
executed: }
Execution Count:5949
5949
1328 -
1329 -
1330 -
1331 -
1332 -
1333 bool lastRowIsButtonBox = (lastRowAdHocData.hasOnlyButtons()
partially evaluated: lastRowAdHocData.hasOnlyButtons()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3700
0-3700
1334 && nextToLastRowAdHocData.hasOnlyNonButtons());
never evaluated: nextToLastRowAdHocData.hasOnlyNonButtons()
0
1335 bool lastTwoRowsIsButtonBox = (lastRowAdHocData.hasOnlyButtons()
partially evaluated: lastRowAdHocData.hasOnlyButtons()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3700
0-3700
1336 && nextToLastRowAdHocData.hasOnlyButtons()
never evaluated: nextToLastRowAdHocData.hasOnlyButtons()
0
1337 && nextToNextToLastRowAdHocData.hasOnlyNonButtons()
never evaluated: nextToNextToLastRowAdHocData.hasOnlyNonButtons()
0
1338 && orientation == Qt::Vertical);
never evaluated: orientation == Qt::Vertical
0
1339 -
1340 if (defaultSpacing.isDefault()) {
partially evaluated: defaultSpacing.isDefault()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3700
0-3700
1341 int prevRow = -1; -
1342 for (int row = 0; row < rowInfo.count; ++row) {
never evaluated: row < rowInfo.count
0
1343 if (rowData->ignore.testBit(row))
never evaluated: rowData->ignore.testBit(row)
0
1344 continue;
never executed: continue;
0
1345 -
1346 if (prevRow != -1 && !rowInfo.spacings.value(prevRow).isUser()) {
never evaluated: prevRow != -1
never evaluated: !rowInfo.spacings.value(prevRow).isUser()
0
1347 qreal &rowSpacing = rowData->spacings[prevRow]; -
1348 for (int column = 0; column < columnInfo.count; ++column) {
never evaluated: column < columnInfo.count
0
1349 QGridLayoutItem *item1 = itemAt(prevRow, column, orientation); -
1350 QGridLayoutItem *item2 = itemAt(row, column, orientation); -
1351 -
1352 if (item1 && item2 && item1 != item2) {
never evaluated: item1
never evaluated: item2
never evaluated: item1 != item2
0
1353 QSizePolicy::ControlTypes controls1 = item1->controlTypes(bottom); -
1354 QSizePolicy::ControlTypes controls2 = item2->controlTypes(top); -
1355 -
1356 if (controls2 & QSizePolicy::PushButton) {
never evaluated: controls2 & QSizePolicy::PushButton
0
1357 if ((row == nextToLastRowAdHocData.q_row && lastTwoRowsIsButtonBox)
never evaluated: row == nextToLastRowAdHocData.q_row
never evaluated: lastTwoRowsIsButtonBox
0
1358 || (row == lastRowAdHocData.q_row && lastRowIsButtonBox)) {
never evaluated: row == lastRowAdHocData.q_row
never evaluated: lastRowIsButtonBox
0
1359 controls2 &= ~QSizePolicy::PushButton; -
1360 controls2 |= QSizePolicy::ButtonBox; -
1361 }
never executed: }
0
1362 }
never executed: }
0
1363 -
1364 qreal spacing = style->combinedLayoutSpacing(controls1, controls2, -
1365 orientation, &option, -
1366 styleInfo.widget()); -
1367 if (orientation == Qt::Horizontal) {
never evaluated: orientation == Qt::Horizontal
0
1368 qreal width1 = rowData->boxes.at(prevRow).q_minimumSize; -
1369 qreal width2 = rowData->boxes.at(row).q_minimumSize; -
1370 QRectF rect1 = item1->geometryWithin(0.0, 0.0, width1, 3.40282347e+38F, -1.0); -
1371 QRectF rect2 = item2->geometryWithin(0.0, 0.0, width2, 3.40282347e+38F, -1.0); -
1372 spacing -= (width1 - (rect1.x() + rect1.width())) + rect2.x(); -
1373 } else {
never executed: }
0
1374 const QGridLayoutBox &box1 = rowData->boxes.at(prevRow); -
1375 const QGridLayoutBox &box2 = rowData->boxes.at(row); -
1376 qreal height1 = box1.q_minimumSize; -
1377 qreal height2 = box2.q_minimumSize; -
1378 qreal rowDescent1 = fixedDescent(box1.q_minimumDescent, -
1379 box1.q_minimumAscent, height1); -
1380 qreal rowDescent2 = fixedDescent(box2.q_minimumDescent, -
1381 box2.q_minimumAscent, height2); -
1382 QRectF rect1 = item1->geometryWithin(0.0, 0.0, 3.40282347e+38F, height1, -
1383 rowDescent1); -
1384 QRectF rect2 = item2->geometryWithin(0.0, 0.0, 3.40282347e+38F, height2, -
1385 rowDescent2); -
1386 spacing -= (height1 - (rect1.y() + rect1.height())) + rect2.y(); -
1387 }
never executed: }
0
1388 rowSpacing = qMax(spacing, rowSpacing); -
1389 }
never executed: }
0
1390 }
never executed: }
0
1391 }
never executed: }
0
1392 prevRow = row; -
1393 }
never executed: }
0
1394 } else if (lastRowIsButtonBox || lastTwoRowsIsButtonBox) {
never executed: }
partially evaluated: lastRowIsButtonBox
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3700
partially evaluated: lastTwoRowsIsButtonBox
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3700
0-3700
1395 -
1396 -
1397 -
1398 -
1399 -
1400 int prevRow = lastRowIsButtonBox ? nextToLastRowAdHocData.q_row
never evaluated: lastRowIsButtonBox
0
1401 : nextToNextToLastRowAdHocData.q_row; -
1402 if (!defaultSpacing.isUser() && !rowInfo.spacings.value(prevRow).isUser()) {
never evaluated: !defaultSpacing.isUser()
never evaluated: !rowInfo.spacings.value(prevRow).isUser()
0
1403 qreal windowMargin = style->pixelMetric(orientation == Qt::Vertical -
1404 ? QStyle::PM_LayoutBottomMargin -
1405 : QStyle::PM_LayoutRightMargin, -
1406 &option, styleInfo.widget()); -
1407 -
1408 qreal &rowSpacing = rowData->spacings[prevRow]; -
1409 rowSpacing = qMax(windowMargin, rowSpacing); -
1410 }
never executed: }
0
1411 }
never executed: }
0
1412} -
1413 -
1414void QGridLayoutEngine::ensureEffectiveFirstAndLastRows() const -
1415{ -
1416 if (q_cachedEffectiveFirstRows[Hor] == -1 && !q_items.isEmpty()) {
evaluated: q_cachedEffectiveFirstRows[Hor] == -1
TRUEFALSE
yes
Evaluation Count:930
yes
Evaluation Count:508
evaluated: !q_items.isEmpty()
TRUEFALSE
yes
Evaluation Count:711
yes
Evaluation Count:219
219-930
1417 int rowCount = this->rowCount(); -
1418 int columnCount = this->columnCount(); -
1419 -
1420 q_cachedEffectiveFirstRows[Ver] = rowCount; -
1421 q_cachedEffectiveFirstRows[Hor] = columnCount; -
1422 q_cachedEffectiveLastRows[Ver] = -1; -
1423 q_cachedEffectiveLastRows[Hor] = -1; -
1424 -
1425 for (int i = q_items.count() - 1; i >= 0; --i) {
evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:2098
yes
Evaluation Count:711
711-2098
1426 const QGridLayoutItem *item = q_items.at(i); -
1427 -
1428 for (int j = 0; j < NOrientations; ++j) {
evaluated: j < NOrientations
TRUEFALSE
yes
Evaluation Count:4196
yes
Evaluation Count:2098
2098-4196
1429 Qt::Orientation orientation = (j == Hor) ? Qt::Horizontal : Qt::Vertical;
evaluated: (j == Hor)
TRUEFALSE
yes
Evaluation Count:2098
yes
Evaluation Count:2098
2098
1430 if (item->firstRow(orientation) < q_cachedEffectiveFirstRows[j])
evaluated: item->firstRow(orientation) < q_cachedEffectiveFirstRows[j]
TRUEFALSE
yes
Evaluation Count:2256
yes
Evaluation Count:1940
1940-2256
1431 q_cachedEffectiveFirstRows[j] = item->firstRow(orientation);
executed: q_cachedEffectiveFirstRows[j] = item->firstRow(orientation);
Execution Count:2256
2256
1432 if (item->lastRow(orientation) > q_cachedEffectiveLastRows[j])
evaluated: item->lastRow(orientation) > q_cachedEffectiveLastRows[j]
TRUEFALSE
yes
Evaluation Count:1688
yes
Evaluation Count:2508
1688-2508
1433 q_cachedEffectiveLastRows[j] = item->lastRow(orientation);
executed: q_cachedEffectiveLastRows[j] = item->lastRow(orientation);
Execution Count:1688
1688
1434 }
executed: }
Execution Count:4196
4196
1435 }
executed: }
Execution Count:2098
2098
1436 }
executed: }
Execution Count:711
711
1437}
executed: }
Execution Count:1438
1438
1438 -
1439void QGridLayoutEngine::ensureColumnAndRowData(QGridLayoutRowData *rowData, QGridLayoutBox *totalBox, -
1440 const QLayoutStyleInfo &styleInfo, -
1441 qreal *colPositions, qreal *colSizes, -
1442 Qt::Orientation orientation) const -
1443{ -
1444 rowData->reset(rowCount(orientation)); -
1445 fillRowData(rowData, styleInfo, colPositions, colSizes, orientation); -
1446 const QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical]; -
1447 rowData->distributeMultiCells(rowInfo); -
1448 *totalBox = rowData->totalBox(0, rowCount(orientation)); -
1449 -
1450}
executed: }
Execution Count:3700
3700
1451 -
1452 -
1453 -
1454 -
1455 -
1456bool QGridLayoutEngine::ensureDynamicConstraint() const -
1457{ -
1458 if (q_cachedConstraintOrientation == UnknownConstraint) {
evaluated: q_cachedConstraintOrientation == UnknownConstraint
TRUEFALSE
yes
Evaluation Count:615
yes
Evaluation Count:1461
615-1461
1459 for (int i = q_items.count() - 1; i >= 0; --i) {
evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:1525
yes
Evaluation Count:615
615-1525
1460 QGridLayoutItem *item = q_items.at(i); -
1461 if (item->hasDynamicConstraint()) {
evaluated: item->hasDynamicConstraint()
TRUEFALSE
yes
Evaluation Count:217
yes
Evaluation Count:1308
217-1308
1462 Qt::Orientation itemConstraintOrientation = item->dynamicConstraintOrientation(); -
1463 if (q_cachedConstraintOrientation == UnknownConstraint) {
evaluated: q_cachedConstraintOrientation == UnknownConstraint
TRUEFALSE
yes
Evaluation Count:56
yes
Evaluation Count:161
56-161
1464 q_cachedConstraintOrientation = itemConstraintOrientation; -
1465 } else if (q_cachedConstraintOrientation != itemConstraintOrientation) {
executed: }
Execution Count:56
partially evaluated: q_cachedConstraintOrientation != itemConstraintOrientation
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:161
0-161
1466 q_cachedConstraintOrientation = UnfeasibleConstraint; -
1467 QMessageLogger("graphicsview/qgridlayoutengine.cpp", 1672, __PRETTY_FUNCTION__).warning("QGridLayoutEngine: Unfeasible, cannot mix horizontal and" -
1468 " vertical constraint in the same layout"); -
1469 return false;
never executed: return false;
0
1470 } -
1471 } -
1472 }
executed: }
Execution Count:1525
1525
1473 if (q_cachedConstraintOrientation == UnknownConstraint)
evaluated: q_cachedConstraintOrientation == UnknownConstraint
TRUEFALSE
yes
Evaluation Count:559
yes
Evaluation Count:56
56-559
1474 q_cachedConstraintOrientation = NoConstraint;
executed: q_cachedConstraintOrientation = NoConstraint;
Execution Count:559
559
1475 }
executed: }
Execution Count:615
615
1476 return true;
executed: return true;
Execution Count:2076
2076
1477} -
1478 -
1479bool QGridLayoutEngine::hasDynamicConstraint() const -
1480{ -
1481 if (!ensureDynamicConstraint())
partially evaluated: !ensureDynamicConstraint()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1521
0-1521
1482 return false;
never executed: return false;
0
1483 return q_cachedConstraintOrientation != NoConstraint;
executed: return q_cachedConstraintOrientation != NoConstraint;
Execution Count:1521
1521
1484} -
1485 -
1486 -
1487 -
1488 -
1489Qt::Orientation QGridLayoutEngine::constraintOrientation() const -
1490{ -
1491 (void)ensureDynamicConstraint(); -
1492 return (Qt::Orientation)q_cachedConstraintOrientation;
executed: return (Qt::Orientation)q_cachedConstraintOrientation;
Execution Count:555
555
1493} -
1494 -
1495void QGridLayoutEngine::ensureGeometries(const QLayoutStyleInfo &styleInfo, -
1496 const QSizeF &size) const -
1497{ -
1498 if (q_cachedDataForStyleInfo == styleInfo && q_cachedSize == size)
evaluated: q_cachedDataForStyleInfo == styleInfo
TRUEFALSE
yes
Evaluation Count:156
yes
Evaluation Count:287
evaluated: q_cachedSize == size
TRUEFALSE
yes
Evaluation Count:78
yes
Evaluation Count:78
78-287
1499 return;
executed: return;
Execution Count:78
78
1500 -
1501 q_cachedDataForStyleInfo = styleInfo; -
1502 q_cachedSize = size; -
1503 -
1504 q_xx.resize(columnCount()); -
1505 q_widths.resize(columnCount()); -
1506 q_yy.resize(rowCount()); -
1507 q_heights.resize(rowCount()); -
1508 q_descents.resize(rowCount()); -
1509 -
1510 if (constraintOrientation() != Qt::Horizontal) {
evaluated: constraintOrientation() != Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:356
yes
Evaluation Count:9
9-356
1511 -
1512 ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], styleInfo, __null, __null, Qt::Horizontal); -
1513 -
1514 -
1515 q_columnData.calculateGeometries(0, columnCount(), size.width(), q_xx.data(), q_widths.data(), -
1516 0, q_totalBoxes[Hor], q_infos[Hor] ); -
1517 ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], styleInfo, q_xx.data(), q_widths.data(), Qt::Vertical); -
1518 -
1519 q_rowData.calculateGeometries(0, rowCount(), size.height(), q_yy.data(), q_heights.data(), -
1520 q_descents.data(), q_totalBoxes[Ver], q_infos[Ver]); -
1521 } else {
executed: }
Execution Count:356
356
1522 -
1523 ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], styleInfo, __null, __null, Qt::Vertical); -
1524 -
1525 -
1526 q_rowData.calculateGeometries(0, rowCount(), size.height(), q_yy.data(), q_heights.data(), -
1527 q_descents.data(), q_totalBoxes[Ver], q_infos[Ver]); -
1528 ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], styleInfo, q_yy.data(), q_heights.data(), Qt::Horizontal); -
1529 -
1530 q_columnData.calculateGeometries(0, columnCount(), size.width(), q_xx.data(), q_widths.data(), -
1531 0, q_totalBoxes[Hor], q_infos[Hor]); -
1532 }
executed: }
Execution Count:9
9
1533} -
1534 -
1535 -
1536 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial