graphicsview/qgraphicsanchorlayout.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4QGraphicsAnchor::QGraphicsAnchor(QGraphicsAnchorLayout *parentLayout) -
5 : QObject(*(new QGraphicsAnchorPrivate)) -
6{ -
7 QGraphicsAnchorPrivate * const d = d_func(); -
8 qt_noop(); -
9 d->layoutPrivate = parentLayout->d_func(); -
10}
never executed: }
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: }
0
23 -
24QSizePolicy::Policy QGraphicsAnchor::sizePolicy() const -
25{ -
26 const QGraphicsAnchorPrivate * const d = d_func(); -
27 return 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: }
0
34 -
35qreal QGraphicsAnchor::spacing() const -
36{ -
37 const QGraphicsAnchorPrivate * const d = d_func(); -
38 return 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: }
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: }
0
57 -
58 -
59 -
60 -
61QGraphicsAnchorLayout::~QGraphicsAnchorLayout() -
62{ -
63 QGraphicsAnchorLayoutPrivate * const d = d_func(); -
64 -
65 for (int i = count() - 1; i >= 0; --i) {
never evaluated: i >= 0
0
66 QGraphicsLayoutItem *item = d->items.at(i); -
67 removeAt(i); -
68 if (item) {
never evaluated: item
0
69 if (item->ownedByLayout())
never evaluated: item->ownedByLayout()
0
70 delete item;
never executed: delete item;
0
71 }
never executed: }
0
72 }
never executed: }
0
73 -
74 d->removeCenterConstraints(this, QGraphicsAnchorLayoutPrivate::Horizontal); -
75 d->removeCenterConstraints(this, QGraphicsAnchorLayoutPrivate::Vertical); -
76 d->deleteLayoutEdges(); -
77 -
78 qt_noop(); -
79 qt_noop(); -
80 qt_noop(); -
81 qt_noop(); -
82}
never executed: }
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 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 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 ? Qt::AnchorRight: Qt::AnchorLeft);
never evaluated: firstCorner & 1
0
113 Qt::AnchorPoint secondEdge = (secondCorner & 1 ? Qt::AnchorRight: Qt::AnchorLeft);
never evaluated: secondCorner & 1
0
114 if (d->addAnchor(firstItem, firstEdge, secondItem, secondEdge)) {
never evaluated: d->addAnchor(firstItem, firstEdge, secondItem, secondEdge)
0
115 -
116 firstEdge = (firstCorner & 2 ? Qt::AnchorBottom: Qt::AnchorTop);
never evaluated: firstCorner & 2
0
117 secondEdge = (secondCorner & 2 ? Qt::AnchorBottom: Qt::AnchorTop);
never evaluated: secondCorner & 2
0
118 d->addAnchor(firstItem, firstEdge, secondItem, secondEdge); -
119 -
120 invalidate(); -
121 }
never executed: }
0
122}
never executed: }
0
123void QGraphicsAnchorLayout::addAnchors(QGraphicsLayoutItem *firstItem, -
124 QGraphicsLayoutItem *secondItem, -
125 Qt::Orientations orientations) -
126{ -
127 bool ok = true; -
128 if (orientations & Qt::Horizontal) {
never evaluated: orientations & Qt::Horizontal
0
129 -
130 ok = addAnchor(secondItem, Qt::AnchorLeft, firstItem, Qt::AnchorLeft) != 0; -
131 if (ok)
never evaluated: ok
0
132 addAnchor(firstItem, Qt::AnchorRight, secondItem, Qt::AnchorRight);
never executed: addAnchor(firstItem, Qt::AnchorRight, secondItem, Qt::AnchorRight);
0
133 }
never executed: }
0
134 if (orientations & Qt::Vertical && ok) {
never evaluated: orientations & Qt::Vertical
never evaluated: ok
0
135 addAnchor(secondItem, Qt::AnchorTop, firstItem, Qt::AnchorTop); -
136 addAnchor(firstItem, Qt::AnchorBottom, secondItem, Qt::AnchorBottom); -
137 }
never executed: }
0
138}
never executed: }
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: }
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: }
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: }
0
172 -
173 -
174 -
175 -
176 -
177 -
178qreal QGraphicsAnchorLayout::horizontalSpacing() const -
179{ -
180 const QGraphicsAnchorLayoutPrivate * const d = d_func(); -
181 return 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 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: }
0
207void QGraphicsAnchorLayout::removeAt(int index) -
208{ -
209 QGraphicsAnchorLayoutPrivate * const d = d_func(); -
210 QGraphicsLayoutItem *item = d->items.value(index); -
211 -
212 if (!item)
never evaluated: !item
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: }
0
224 -
225 -
226 -
227 -
228int QGraphicsAnchorLayout::count() const -
229{ -
230 const QGraphicsAnchorLayoutPrivate * const d = d_func(); -
231 return 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 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: }
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 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