qgraphicsanchorlayout.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/graphicsview/qgraphicsanchorlayout.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4QGraphicsAnchor::QGraphicsAnchor(QGraphicsAnchorLayout *parentLayout)-
5 : QObject(*(new QGraphicsAnchorPrivate))-
6{-
7 QGraphicsAnchorPrivate * const d = d_func();-
8 ((!(parentLayout)) ? qt_assert("parentLayout",__FILE__,145) : qt_noop());-
9 d->layoutPrivate = parentLayout->d_func();-
10}
never executed: end of block
0
11-
12-
13-
14-
15QGraphicsAnchor::~QGraphicsAnchor()-
16{-
17}-
18void QGraphicsAnchor::setSizePolicy(QSizePolicy::Policy policy)-
19{-
20 QGraphicsAnchorPrivate * const d = d_func();-
21 d->setSizePolicy(policy);-
22}
never executed: end of block
0
23-
24QSizePolicy::Policy QGraphicsAnchor::sizePolicy() const-
25{-
26 const QGraphicsAnchorPrivate * const d = d_func();-
27 return
never executed: return d->sizePolicy;
d->sizePolicy;
never executed: return d->sizePolicy;
0
28}-
29void QGraphicsAnchor::setSpacing(qreal spacing)-
30{-
31 QGraphicsAnchorPrivate * const d = d_func();-
32 d->setSpacing(spacing);-
33}
never executed: end of block
0
34-
35qreal QGraphicsAnchor::spacing() const-
36{-
37 const QGraphicsAnchorPrivate * const d = d_func();-
38 return
never executed: return d->spacing();
d->spacing();
never executed: return d->spacing();
0
39}-
40-
41void QGraphicsAnchor::unsetSpacing()-
42{-
43 QGraphicsAnchorPrivate * const d = d_func();-
44 d->unsetSpacing();-
45}
never executed: end of block
0
46-
47-
48-
49-
50-
51QGraphicsAnchorLayout::QGraphicsAnchorLayout(QGraphicsLayoutItem *parent)-
52 : QGraphicsLayout(*new QGraphicsAnchorLayoutPrivate(), parent)-
53{-
54 QGraphicsAnchorLayoutPrivate * const d = d_func();-
55 d->createLayoutEdges();-
56}
never executed: end of block
0
57-
58-
59-
60-
61QGraphicsAnchorLayout::~QGraphicsAnchorLayout()-
62{-
63 QGraphicsAnchorLayoutPrivate * const d = d_func();-
64-
65 for (int i = count() - 1; i >= 0
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
; --i) {
0
66 QGraphicsLayoutItem *item = d->items.at(i);-
67 removeAt(i);-
68 if (item
itemDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
69 if (item->ownedByLayout()
item->ownedByLayout()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
70 delete item;
never executed: delete item;
0
71 }
never executed: end of block
0
72 }
never executed: end of block
0
73-
74 d->removeCenterConstraints(this, QGraphicsAnchorLayoutPrivate::Horizontal);-
75 d->removeCenterConstraints(this, QGraphicsAnchorLayoutPrivate::Vertical);-
76 d->deleteLayoutEdges();-
77-
78 ((!(d->itemCenterConstraints[0].isEmpty())) ? qt_assert("d->itemCenterConstraints[0].isEmpty()",__FILE__,241) : qt_noop());-
79 ((!(d->itemCenterConstraints[1].isEmpty())) ? qt_assert("d->itemCenterConstraints[1].isEmpty()",__FILE__,242) : qt_noop());-
80 ((!(d->items.isEmpty())) ? qt_assert("d->items.isEmpty()",__FILE__,243) : qt_noop());-
81 ((!(d->m_vertexList.isEmpty())) ? qt_assert("d->m_vertexList.isEmpty()",__FILE__,244) : qt_noop());-
82}
never executed: end of block
0
83QGraphicsAnchor *-
84QGraphicsAnchorLayout::addAnchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,-
85 QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge)-
86{-
87 QGraphicsAnchorLayoutPrivate * const d = d_func();-
88 QGraphicsAnchor *a = d->addAnchor(firstItem, firstEdge, secondItem, secondEdge);-
89 invalidate();-
90 return
never executed: return a;
a;
never executed: return a;
0
91}-
92-
93-
94-
95-
96-
97QGraphicsAnchor *-
98QGraphicsAnchorLayout::anchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,-
99 QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge)-
100{-
101 QGraphicsAnchorLayoutPrivate * const d = d_func();-
102 return
never executed: return d->getAnchor(firstItem, firstEdge, secondItem, secondEdge);
d->getAnchor(firstItem, firstEdge, secondItem, secondEdge);
never executed: return d->getAnchor(firstItem, firstEdge, secondItem, secondEdge);
0
103}-
104void QGraphicsAnchorLayout::addCornerAnchors(QGraphicsLayoutItem *firstItem,-
105 Qt::Corner firstCorner,-
106 QGraphicsLayoutItem *secondItem,-
107 Qt::Corner secondCorner)-
108{-
109 QGraphicsAnchorLayoutPrivate * const d = d_func();-
110-
111-
112 Qt::AnchorPoint firstEdge = (firstCorner & 1
firstCorner & 1Description
TRUEnever evaluated
FALSEnever evaluated
? Qt::AnchorRight: Qt::AnchorLeft);
0
113 Qt::AnchorPoint secondEdge = (secondCorner & 1
secondCorner & 1Description
TRUEnever evaluated
FALSEnever evaluated
? Qt::AnchorRight: Qt::AnchorLeft);
0
114 if (d->addAnchor(firstItem, firstEdge, secondItem, secondEdge)
d->addAnchor(f...m, secondEdge)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
115-
116 firstEdge = (firstCorner & 2
firstCorner & 2Description
TRUEnever evaluated
FALSEnever evaluated
? Qt::AnchorBottom: Qt::AnchorTop);
0
117 secondEdge = (secondCorner & 2
secondCorner & 2Description
TRUEnever evaluated
FALSEnever evaluated
? Qt::AnchorBottom: Qt::AnchorTop);
0
118 d->addAnchor(firstItem, firstEdge, secondItem, secondEdge);-
119-
120 invalidate();-
121 }
never executed: end of block
0
122}
never executed: end of block
0
123void QGraphicsAnchorLayout::addAnchors(QGraphicsLayoutItem *firstItem,-
124 QGraphicsLayoutItem *secondItem,-
125 Qt::Orientations orientations)-
126{-
127 bool ok = true;-
128 if (orientations & Qt::Horizontal
orientations & Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
129-
130 ok = addAnchor(secondItem, Qt::AnchorLeft, firstItem, Qt::AnchorLeft) != 0;-
131 if (ok
okDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
132 addAnchor(firstItem, Qt::AnchorRight, secondItem, Qt::AnchorRight);
never executed: addAnchor(firstItem, Qt::AnchorRight, secondItem, Qt::AnchorRight);
0
133 }
never executed: end of block
0
134 if (orientations & Qt::Vertical
orientations & Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
&& ok
okDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
135 addAnchor(secondItem, Qt::AnchorTop, firstItem, Qt::AnchorTop);-
136 addAnchor(firstItem, Qt::AnchorBottom, secondItem, Qt::AnchorBottom);-
137 }
never executed: end of block
0
138}
never executed: end of block
0
139-
140-
141-
142-
143-
144-
145void QGraphicsAnchorLayout::setHorizontalSpacing(qreal spacing)-
146{-
147 QGraphicsAnchorLayoutPrivate * const d = d_func();-
148-
149 d->spacings[0] = spacing;-
150 invalidate();-
151}
never executed: end of block
0
152-
153-
154-
155-
156-
157-
158void QGraphicsAnchorLayout::setVerticalSpacing(qreal spacing)-
159{-
160 QGraphicsAnchorLayoutPrivate * const d = d_func();-
161-
162 d->spacings[1] = spacing;-
163 invalidate();-
164}
never executed: end of block
0
165void QGraphicsAnchorLayout::setSpacing(qreal spacing)-
166{-
167 QGraphicsAnchorLayoutPrivate * const d = d_func();-
168-
169 d->spacings[0] = d->spacings[1] = spacing;-
170 invalidate();-
171}
never executed: end of block
0
172-
173-
174-
175-
176-
177-
178qreal QGraphicsAnchorLayout::horizontalSpacing() const-
179{-
180 const QGraphicsAnchorLayoutPrivate * const d = d_func();-
181 return
never executed: return d->styleInfo().defaultSpacing(Qt::Horizontal);
d->styleInfo().defaultSpacing(Qt::Horizontal);
never executed: return d->styleInfo().defaultSpacing(Qt::Horizontal);
0
182}-
183-
184-
185-
186-
187-
188-
189qreal QGraphicsAnchorLayout::verticalSpacing() const-
190{-
191 const QGraphicsAnchorLayoutPrivate * const d = d_func();-
192 return
never executed: return d->styleInfo().defaultSpacing(Qt::Vertical);
d->styleInfo().defaultSpacing(Qt::Vertical);
never executed: return d->styleInfo().defaultSpacing(Qt::Vertical);
0
193}-
194-
195-
196-
197-
198void QGraphicsAnchorLayout::setGeometry(const QRectF &geom)-
199{-
200 QGraphicsAnchorLayoutPrivate * const d = d_func();-
201-
202 QGraphicsLayout::setGeometry(geom);-
203 d->calculateVertexPositions(QGraphicsAnchorLayoutPrivate::Horizontal);-
204 d->calculateVertexPositions(QGraphicsAnchorLayoutPrivate::Vertical);-
205 d->setItemsGeometries(geom);-
206}
never executed: end of block
0
207void QGraphicsAnchorLayout::removeAt(int index)-
208{-
209 QGraphicsAnchorLayoutPrivate * const d = d_func();-
210 QGraphicsLayoutItem *item = d->items.value(index);-
211-
212 if (!item
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
213 return;
never executed: return;
0
214-
215-
216 d->removeCenterConstraints(item, QGraphicsAnchorLayoutPrivate::Horizontal);-
217 d->removeCenterConstraints(item, QGraphicsAnchorLayoutPrivate::Vertical);-
218 d->removeAnchors(item);-
219 d->items.remove(index);-
220-
221 item->setParentLayoutItem(0);-
222 invalidate();-
223}
never executed: end of block
0
224-
225-
226-
227-
228int QGraphicsAnchorLayout::count() const-
229{-
230 const QGraphicsAnchorLayoutPrivate * const d = d_func();-
231 return
never executed: return d->items.size();
d->items.size();
never executed: return d->items.size();
0
232}-
233-
234-
235-
236-
237QGraphicsLayoutItem *QGraphicsAnchorLayout::itemAt(int index) const-
238{-
239 const QGraphicsAnchorLayoutPrivate * const d = d_func();-
240 return
never executed: return d->items.value(index);
d->items.value(index);
never executed: return d->items.value(index);
0
241}-
242-
243-
244-
245-
246void QGraphicsAnchorLayout::invalidate()-
247{-
248 QGraphicsAnchorLayoutPrivate * const d = d_func();-
249 QGraphicsLayout::invalidate();-
250 d->calculateGraphCacheDirty = true;-
251 d->styleInfoDirty = true;-
252}
never executed: end of block
0
253-
254-
255-
256-
257QSizeF QGraphicsAnchorLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const-
258{-
259 (void)constraint;;-
260 const QGraphicsAnchorLayoutPrivate * const d = d_func();-
261 const_cast<QGraphicsAnchorLayoutPrivate *>(d)->calculateGraphs();-
262-
263-
264 QSizeF engineSizeHint(-
265 d->sizeHints[QGraphicsAnchorLayoutPrivate::Horizontal][which],-
266 d->sizeHints[QGraphicsAnchorLayoutPrivate::Vertical][which]);-
267-
268 qreal left, top, right, bottom;-
269 getContentsMargins(&left, &top, &right, &bottom);-
270-
271 return
never executed: return engineSizeHint + QSizeF(left + right, top + bottom);
engineSizeHint + QSizeF(left + right, top + bottom);
never executed: return engineSizeHint + QSizeF(left + right, top + bottom);
0
272}-
273-
274-
275-
Switch to Source codePreprocessed file

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