Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | class QGraphicsLinearLayoutPrivate : public QGraphicsLayoutPrivate | - |
11 | { | - |
12 | public: | - |
13 | QGraphicsLinearLayoutPrivate(Qt::Orientation orientation) : orientation(orientation) { } executed: } Execution Count:399 | 399 |
14 | | - |
15 | void removeGridItem(QGridLayoutItem *gridItem); | - |
16 | QLayoutStyleInfo styleInfo() const; | - |
17 | void fixIndex(int *index) const; | - |
18 | int gridRow(int index) const; | - |
19 | int gridColumn(int index) const; | - |
20 | | - |
21 | Qt::Orientation orientation; | - |
22 | QGridLayoutEngine engine; | - |
23 | }; | - |
24 | | - |
25 | void QGraphicsLinearLayoutPrivate::removeGridItem(QGridLayoutItem *gridItem) | - |
26 | { | - |
27 | int index = gridItem->firstRow(orientation); | - |
28 | engine.removeItem(gridItem); | - |
29 | engine.removeRows(index, 1, orientation); | - |
30 | } executed: } Execution Count:622 | 622 |
31 | | - |
32 | void QGraphicsLinearLayoutPrivate::fixIndex(int *index) const | - |
33 | { | - |
34 | int count = engine.rowCount(orientation); | - |
35 | if (uint(*index) > uint(count)) evaluated: uint(*index) > uint(count) yes Evaluation Count:628 | yes Evaluation Count:41 |
| 41-628 |
36 | *index = count; executed: *index = count; Execution Count:628 | 628 |
37 | } executed: } Execution Count:669 | 669 |
38 | | - |
39 | int QGraphicsLinearLayoutPrivate::gridRow(int index) const | - |
40 | { | - |
41 | if (orientation == Qt::Horizontal) evaluated: orientation == Qt::Horizontal yes Evaluation Count:531 | yes Evaluation Count:106 |
| 106-531 |
42 | return 0; executed: return 0; Execution Count:531 | 531 |
43 | return int(qMin(uint(index), uint(engine.rowCount()))); executed: return int(qMin(uint(index), uint(engine.rowCount()))); Execution Count:106 | 106 |
44 | } | - |
45 | | - |
46 | int QGraphicsLinearLayoutPrivate::gridColumn(int index) const | - |
47 | { | - |
48 | if (orientation == Qt::Vertical) evaluated: orientation == Qt::Vertical yes Evaluation Count:106 | yes Evaluation Count:531 |
| 106-531 |
49 | return 0; executed: return 0; Execution Count:106 | 106 |
50 | return int(qMin(uint(index), uint(engine.columnCount()))); executed: return int(qMin(uint(index), uint(engine.columnCount()))); Execution Count:531 | 531 |
51 | } | - |
52 | | - |
53 | static QWidget *globalStyleInfoWidget() { static QGlobalStatic<QWidget > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QWidget *x = new QWidget; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QWidget > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); } partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x) no Evaluation Count:0 | yes Evaluation Count:2 |
evaluated: !thisGlobalStatic.pointer.load() yes Evaluation Count:2 | yes Evaluation Count:1276 |
partially evaluated: !thisGlobalStatic.destroyed yes Evaluation Count:2 | no Evaluation Count:0 |
never executed: delete x; executed: return thisGlobalStatic.pointer.load(); Execution Count:1278 | 0-1278 |
54 | | - |
55 | QLayoutStyleInfo QGraphicsLinearLayoutPrivate::styleInfo() const | - |
56 | { | - |
57 | QGraphicsItem *item = parentItem(); | - |
58 | QStyle *style = (item && item->isWidget()) ? static_cast<QGraphicsWidget*>(item)->style() : QApplication::style(); evaluated: item yes Evaluation Count:928 | yes Evaluation Count:350 |
partially evaluated: item->isWidget() yes Evaluation Count:928 | no Evaluation Count:0 |
| 0-928 |
59 | return QLayoutStyleInfo(style, globalStyleInfoWidget()); executed: return QLayoutStyleInfo(style, globalStyleInfoWidget()); Execution Count:1278 | 1278 |
60 | } | - |
61 | | - |
62 | | - |
63 | | - |
64 | | - |
65 | | - |
66 | | - |
67 | QGraphicsLinearLayout::QGraphicsLinearLayout(Qt::Orientation orientation, QGraphicsLayoutItem *parent) | - |
68 | : QGraphicsLayout(*new QGraphicsLinearLayoutPrivate(orientation), parent) | - |
69 | { | - |
70 | } executed: } Execution Count:373 | 373 |
71 | | - |
72 | | - |
73 | | - |
74 | | - |
75 | | - |
76 | QGraphicsLinearLayout::QGraphicsLinearLayout(QGraphicsLayoutItem *parent) | - |
77 | : QGraphicsLayout(*new QGraphicsLinearLayoutPrivate(Qt::Horizontal), parent) | - |
78 | { | - |
79 | } executed: } Execution Count:26 | 26 |
80 | | - |
81 | | - |
82 | | - |
83 | | - |
84 | QGraphicsLinearLayout::~QGraphicsLinearLayout() | - |
85 | { | - |
86 | for (int i = count() - 1; i >= 0; --i) { evaluated: i >= 0 yes Evaluation Count:595 | yes Evaluation Count:392 |
| 392-595 |
87 | QGraphicsLayoutItem *item = itemAt(i); | - |
88 | | - |
89 | | - |
90 | | - |
91 | removeAt(i); | - |
92 | if (item) { partially evaluated: item yes Evaluation Count:595 | no Evaluation Count:0 |
| 0-595 |
93 | item->setParentLayoutItem(0); | - |
94 | if (item->ownedByLayout()) evaluated: item->ownedByLayout() yes Evaluation Count:209 | yes Evaluation Count:386 |
| 209-386 |
95 | delete item; executed: delete item; Execution Count:209 | 209 |
96 | } executed: } Execution Count:595 | 595 |
97 | } executed: } Execution Count:595 | 595 |
98 | } executed: } Execution Count:392 | 392 |
99 | | - |
100 | | - |
101 | | - |
102 | | - |
103 | | - |
104 | | - |
105 | | - |
106 | void QGraphicsLinearLayout::setOrientation(Qt::Orientation orientation) | - |
107 | { | - |
108 | QGraphicsLinearLayoutPrivate * const d = d_func(); | - |
109 | if (orientation != d->orientation) { evaluated: orientation != d->orientation yes Evaluation Count:8 | yes Evaluation Count:1 |
| 1-8 |
110 | d->engine.transpose(); | - |
111 | d->orientation = orientation; | - |
112 | invalidate(); | - |
113 | } executed: } Execution Count:8 | 8 |
114 | } executed: } Execution Count:9 | 9 |
115 | | - |
116 | | - |
117 | | - |
118 | | - |
119 | | - |
120 | Qt::Orientation QGraphicsLinearLayout::orientation() const | - |
121 | { | - |
122 | const QGraphicsLinearLayoutPrivate * const d = d_func(); | - |
123 | return d->orientation; executed: return d->orientation; Execution Count:6 | 6 |
124 | } | - |
125 | void QGraphicsLinearLayout::insertItem(int index, QGraphicsLayoutItem *item) | - |
126 | { | - |
127 | QGraphicsLinearLayoutPrivate * const d = d_func(); | - |
128 | if (!item) { evaluated: !item yes Evaluation Count:4 | yes Evaluation Count:638 |
| 4-638 |
129 | QMessageLogger("graphicsview/qgraphicslinearlayout.cpp", 272, __PRETTY_FUNCTION__).warning("QGraphicsLinearLayout::insertItem: cannot insert null item"); | - |
130 | return; executed: return; Execution Count:4 | 4 |
131 | } | - |
132 | if (item == this) { evaluated: item == this yes Evaluation Count:1 | yes Evaluation Count:637 |
| 1-637 |
133 | QMessageLogger("graphicsview/qgraphicslinearlayout.cpp", 276, __PRETTY_FUNCTION__).warning("QGraphicsLinearLayout::insertItem: cannot insert itself"); | - |
134 | return; executed: return; Execution Count:1 | 1 |
135 | } | - |
136 | d->addChildLayoutItem(item); | - |
137 | | - |
138 | qt_noop(); | - |
139 | d->fixIndex(&index); | - |
140 | d->engine.insertRow(index, d->orientation); | - |
141 | new QGridLayoutItem(&d->engine, item, d->gridRow(index), d->gridColumn(index), 1, 1, 0, index); | - |
142 | invalidate(); | - |
143 | } executed: } Execution Count:637 | 637 |
144 | | - |
145 | | - |
146 | | - |
147 | | - |
148 | | - |
149 | | - |
150 | | - |
151 | void QGraphicsLinearLayout::insertStretch(int index, int stretch) | - |
152 | { | - |
153 | QGraphicsLinearLayoutPrivate * const d = d_func(); | - |
154 | d->fixIndex(&index); | - |
155 | d->engine.insertRow(index, d->orientation); | - |
156 | d->engine.setRowStretchFactor(index, stretch, d->orientation); | - |
157 | invalidate(); | - |
158 | } executed: } Execution Count:32 | 32 |
159 | | - |
160 | | - |
161 | | - |
162 | | - |
163 | | - |
164 | | - |
165 | | - |
166 | void QGraphicsLinearLayout::removeItem(QGraphicsLayoutItem *item) | - |
167 | { | - |
168 | QGraphicsLinearLayoutPrivate * const d = d_func(); | - |
169 | if (QGridLayoutItem *gridItem = d->engine.findLayoutItem(item)) { evaluated: QGridLayoutItem *gridItem = d->engine.findLayoutItem(item) yes Evaluation Count:6 | yes Evaluation Count:2 |
| 2-6 |
170 | item->setParentLayoutItem(0); | - |
171 | d->removeGridItem(gridItem); | - |
172 | delete gridItem; | - |
173 | invalidate(); | - |
174 | } executed: } Execution Count:6 | 6 |
175 | } executed: } Execution Count:8 | 8 |
176 | | - |
177 | | - |
178 | | - |
179 | | - |
180 | | - |
181 | | - |
182 | | - |
183 | void QGraphicsLinearLayout::removeAt(int index) | - |
184 | { | - |
185 | QGraphicsLinearLayoutPrivate * const d = d_func(); | - |
186 | if (index < 0 || index >= d->engine.itemCount()) { partially evaluated: index < 0 no Evaluation Count:0 | yes Evaluation Count:616 |
partially evaluated: index >= d->engine.itemCount() no Evaluation Count:0 | yes Evaluation Count:616 |
| 0-616 |
187 | QMessageLogger("graphicsview/qgraphicslinearlayout.cpp", 330, __PRETTY_FUNCTION__).warning("QGraphicsLinearLayout::removeAt: invalid index %d", index); | - |
188 | return; | 0 |
189 | } | - |
190 | if (QGridLayoutItem *gridItem = d->engine.itemAt(index)) { partially evaluated: QGridLayoutItem *gridItem = d->engine.itemAt(index) yes Evaluation Count:616 | no Evaluation Count:0 |
| 0-616 |
191 | if (QGraphicsLayoutItem *layoutItem = gridItem->layoutItem()) partially evaluated: QGraphicsLayoutItem *layoutItem = gridItem->layoutItem() yes Evaluation Count:616 | no Evaluation Count:0 |
| 0-616 |
192 | layoutItem->setParentLayoutItem(0); executed: layoutItem->setParentLayoutItem(0); Execution Count:616 | 616 |
193 | d->removeGridItem(gridItem); | - |
194 | delete gridItem; | - |
195 | invalidate(); | - |
196 | } executed: } Execution Count:616 | 616 |
197 | } executed: } Execution Count:616 | 616 |
198 | | - |
199 | | - |
200 | | - |
201 | | - |
202 | | - |
203 | | - |
204 | | - |
205 | void QGraphicsLinearLayout::setSpacing(qreal spacing) | - |
206 | { | - |
207 | QGraphicsLinearLayoutPrivate * const d = d_func(); | - |
208 | if (spacing < 0) { partially evaluated: spacing < 0 no Evaluation Count:0 | yes Evaluation Count:45 |
| 0-45 |
209 | QMessageLogger("graphicsview/qgraphicslinearlayout.cpp", 352, __PRETTY_FUNCTION__).warning("QGraphicsLinearLayout::setSpacing: invalid spacing %g", spacing); | - |
210 | return; | 0 |
211 | } | - |
212 | d->engine.setSpacing(spacing, Qt::Horizontal | Qt::Vertical); | - |
213 | invalidate(); | - |
214 | } executed: } Execution Count:45 | 45 |
215 | | - |
216 | | - |
217 | | - |
218 | | - |
219 | | - |
220 | | - |
221 | | - |
222 | qreal QGraphicsLinearLayout::spacing() const | - |
223 | { | - |
224 | const QGraphicsLinearLayoutPrivate * const d = d_func(); | - |
225 | return d->engine.spacing(d->styleInfo(), d->orientation); executed: return d->engine.spacing(d->styleInfo(), d->orientation); Execution Count:15 | 15 |
226 | } | - |
227 | | - |
228 | | - |
229 | | - |
230 | | - |
231 | void QGraphicsLinearLayout::setItemSpacing(int index, qreal spacing) | - |
232 | { | - |
233 | QGraphicsLinearLayoutPrivate * const d = d_func(); | - |
234 | d->engine.setRowSpacing(index, spacing, d->orientation); | - |
235 | invalidate(); | - |
236 | } executed: } Execution Count:15 | 15 |
237 | | - |
238 | | - |
239 | | - |
240 | qreal QGraphicsLinearLayout::itemSpacing(int index) const | - |
241 | { | - |
242 | const QGraphicsLinearLayoutPrivate * const d = d_func(); | - |
243 | return d->engine.rowSpacing(index, d->orientation); executed: return d->engine.rowSpacing(index, d->orientation); Execution Count:3 | 3 |
244 | } | - |
245 | void QGraphicsLinearLayout::setStretchFactor(QGraphicsLayoutItem *item, int stretch) | - |
246 | { | - |
247 | QGraphicsLinearLayoutPrivate * const d = d_func(); | - |
248 | if (!item) { evaluated: !item yes Evaluation Count:2 | yes Evaluation Count:9 |
| 2-9 |
249 | QMessageLogger("graphicsview/qgraphicslinearlayout.cpp", 402, __PRETTY_FUNCTION__).warning("QGraphicsLinearLayout::setStretchFactor: cannot assign" | - |
250 | " a stretch factor to a null item"); | - |
251 | return; executed: return; Execution Count:2 | 2 |
252 | } | - |
253 | if (stretchFactor(item) == stretch) partially evaluated: stretchFactor(item) == stretch no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
254 | return; | 0 |
255 | d->engine.setStretchFactor(item, stretch, d->orientation); | - |
256 | invalidate(); | - |
257 | } executed: } Execution Count:9 | 9 |
258 | | - |
259 | | - |
260 | | - |
261 | | - |
262 | | - |
263 | | - |
264 | | - |
265 | int QGraphicsLinearLayout::stretchFactor(QGraphicsLayoutItem *item) const | - |
266 | { | - |
267 | const QGraphicsLinearLayoutPrivate * const d = d_func(); | - |
268 | if (!item) { evaluated: !item yes Evaluation Count:2 | yes Evaluation Count:91 |
| 2-91 |
269 | QMessageLogger("graphicsview/qgraphicslinearlayout.cpp", 422, __PRETTY_FUNCTION__).warning("QGraphicsLinearLayout::setStretchFactor: cannot return" | - |
270 | " a stretch factor for a null item"); | - |
271 | return 0; executed: return 0; Execution Count:2 | 2 |
272 | } | - |
273 | return d->engine.stretchFactor(item, d->orientation); executed: return d->engine.stretchFactor(item, d->orientation); Execution Count:91 | 91 |
274 | } | - |
275 | | - |
276 | | - |
277 | | - |
278 | | - |
279 | | - |
280 | | - |
281 | | - |
282 | void QGraphicsLinearLayout::setAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment) | - |
283 | { | - |
284 | QGraphicsLinearLayoutPrivate * const d = d_func(); | - |
285 | if (this->alignment(item) == alignment) evaluated: this->alignment(item) == alignment yes Evaluation Count:8 | yes Evaluation Count:67 |
| 8-67 |
286 | return; executed: return; Execution Count:8 | 8 |
287 | d->engine.setAlignment(item, alignment); | - |
288 | invalidate(); | - |
289 | } executed: } Execution Count:67 | 67 |
290 | Qt::Alignment QGraphicsLinearLayout::alignment(QGraphicsLayoutItem *item) const | - |
291 | { | - |
292 | const QGraphicsLinearLayoutPrivate * const d = d_func(); | - |
293 | return d->engine.alignment(item); executed: return d->engine.alignment(item); Execution Count:142 | 142 |
294 | } | - |
295 | int QGraphicsLinearLayout::count() const | - |
296 | { | - |
297 | const QGraphicsLinearLayoutPrivate * const d = d_func(); | - |
298 | return d->engine.itemCount(); executed: return d->engine.itemCount(); Execution Count:2050 | 2050 |
299 | } | - |
300 | | - |
301 | | - |
302 | | - |
303 | | - |
304 | | - |
305 | QGraphicsLayoutItem *QGraphicsLinearLayout::itemAt(int index) const | - |
306 | { | - |
307 | const QGraphicsLinearLayoutPrivate * const d = d_func(); | - |
308 | if (index < 0 || index >= d->engine.itemCount()) { partially evaluated: index < 0 no Evaluation Count:0 | yes Evaluation Count:2112 |
partially evaluated: index >= d->engine.itemCount() no Evaluation Count:0 | yes Evaluation Count:2112 |
| 0-2112 |
309 | QMessageLogger("graphicsview/qgraphicslinearlayout.cpp", 484, __PRETTY_FUNCTION__).warning("QGraphicsLinearLayout::itemAt: invalid index %d", index); | - |
310 | return 0; never executed: return 0; | 0 |
311 | } | - |
312 | QGraphicsLayoutItem *item = 0; | - |
313 | if (QGridLayoutItem *gridItem = d->engine.itemAt(index)) partially evaluated: QGridLayoutItem *gridItem = d->engine.itemAt(index) yes Evaluation Count:2112 | no Evaluation Count:0 |
| 0-2112 |
314 | item = gridItem->layoutItem(); executed: item = gridItem->layoutItem(); Execution Count:2112 | 2112 |
315 | return item; executed: return item; Execution Count:2112 | 2112 |
316 | } | - |
317 | | - |
318 | | - |
319 | | - |
320 | | - |
321 | void QGraphicsLinearLayout::setGeometry(const QRectF &rect) | - |
322 | { | - |
323 | QGraphicsLinearLayoutPrivate * const d = d_func(); | - |
324 | QGraphicsLayout::setGeometry(rect); | - |
325 | QRectF effectiveRect = geometry(); | - |
326 | qreal left, top, right, bottom; | - |
327 | getContentsMargins(&left, &top, &right, &bottom); | - |
328 | Qt::LayoutDirection visualDir = d->visualDirection(); | - |
329 | d->engine.setVisualDirection(visualDir); | - |
330 | if (visualDir == Qt::RightToLeft) evaluated: visualDir == Qt::RightToLeft yes Evaluation Count:1 | yes Evaluation Count:323 |
| 1-323 |
331 | qSwap(left, right); executed: qSwap(left, right); Execution Count:1 | 1 |
332 | effectiveRect.adjust(+left, +top, -right, -bottom); | - |
333 | | - |
334 | | - |
335 | | - |
336 | | - |
337 | | - |
338 | | - |
339 | | - |
340 | d->engine.setGeometries(d->styleInfo(), effectiveRect); | - |
341 | | - |
342 | | - |
343 | | - |
344 | | - |
345 | | - |
346 | | - |
347 | } executed: } Execution Count:324 | 324 |
348 | | - |
349 | | - |
350 | | - |
351 | | - |
352 | QSizeF QGraphicsLinearLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const | - |
353 | { | - |
354 | const QGraphicsLinearLayoutPrivate * const d = d_func(); | - |
355 | qreal left, top, right, bottom; | - |
356 | getContentsMargins(&left, &top, &right, &bottom); | - |
357 | const QSizeF extraMargins(left + right, top + bottom); | - |
358 | return d->engine.sizeHint(d->styleInfo(), which , constraint - extraMargins) + extraMargins; executed: return d->engine.sizeHint(d->styleInfo(), which , constraint - extraMargins) + extraMargins; Execution Count:939 | 939 |
359 | } | - |
360 | | - |
361 | | - |
362 | | - |
363 | | - |
364 | void QGraphicsLinearLayout::invalidate() | - |
365 | { | - |
366 | QGraphicsLinearLayoutPrivate * const d = d_func(); | - |
367 | d->engine.invalidate(); | - |
368 | QGraphicsLayout::invalidate(); | - |
369 | } executed: } Execution Count:1782 | 1782 |
370 | | - |
371 | | - |
372 | | - |
373 | | - |
374 | void QGraphicsLinearLayout::dump(int indent) const | - |
375 | { | - |
376 | (void)indent;; | - |
377 | | - |
378 | } | 0 |
379 | | - |
380 | | - |
381 | | - |
| | |