qgraphicslinearlayout.cpp

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

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9