Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | QGraphicsAnchor::QGraphicsAnchor(QGraphicsAnchorLayout *parentLayout) | - |
5 | : QObject(*(new QGraphicsAnchorPrivate)) | - |
6 | { | - |
7 | QGraphicsAnchorPrivate * const d = d_func(); | - |
8 | qt_noop(); | - |
9 | d->layoutPrivate = parentLayout->d_func(); | - |
10 | } | 0 |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | QGraphicsAnchor::~QGraphicsAnchor() | - |
16 | { | - |
17 | } | - |
18 | void QGraphicsAnchor::setSizePolicy(QSizePolicy::Policy policy) | - |
19 | { | - |
20 | QGraphicsAnchorPrivate * const d = d_func(); | - |
21 | d->setSizePolicy(policy); | - |
22 | } | 0 |
23 | | - |
24 | QSizePolicy::Policy QGraphicsAnchor::sizePolicy() const | - |
25 | { | - |
26 | const QGraphicsAnchorPrivate * const d = d_func(); | - |
27 | return d->sizePolicy; never executed: return d->sizePolicy; | 0 |
28 | } | - |
29 | void QGraphicsAnchor::setSpacing(qreal spacing) | - |
30 | { | - |
31 | QGraphicsAnchorPrivate * const d = d_func(); | - |
32 | d->setSpacing(spacing); | - |
33 | } | 0 |
34 | | - |
35 | qreal QGraphicsAnchor::spacing() const | - |
36 | { | - |
37 | const QGraphicsAnchorPrivate * const d = d_func(); | - |
38 | return d->spacing(); never executed: return d->spacing(); | 0 |
39 | } | - |
40 | | - |
41 | void QGraphicsAnchor::unsetSpacing() | - |
42 | { | - |
43 | QGraphicsAnchorPrivate * const d = d_func(); | - |
44 | d->unsetSpacing(); | - |
45 | } | 0 |
46 | | - |
47 | | - |
48 | | - |
49 | | - |
50 | | - |
51 | QGraphicsAnchorLayout::QGraphicsAnchorLayout(QGraphicsLayoutItem *parent) | - |
52 | : QGraphicsLayout(*new QGraphicsAnchorLayoutPrivate(), parent) | - |
53 | { | - |
54 | QGraphicsAnchorLayoutPrivate * const d = d_func(); | - |
55 | d->createLayoutEdges(); | - |
56 | } | 0 |
57 | | - |
58 | | - |
59 | | - |
60 | | - |
61 | QGraphicsAnchorLayout::~QGraphicsAnchorLayout() | - |
62 | { | - |
63 | QGraphicsAnchorLayoutPrivate * const d = d_func(); | - |
64 | | - |
65 | for (int i = count() - 1; i >= 0; --i) { | 0 |
66 | QGraphicsLayoutItem *item = d->items.at(i); | - |
67 | removeAt(i); | - |
68 | if (item) { | 0 |
69 | if (item->ownedByLayout()) never evaluated: item->ownedByLayout() | 0 |
70 | delete item; never executed: delete item; | 0 |
71 | } | 0 |
72 | } | 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 | } | 0 |
83 | QGraphicsAnchor * | - |
84 | QGraphicsAnchorLayout::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 | | - |
97 | QGraphicsAnchor * | - |
98 | QGraphicsAnchorLayout::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 | } | - |
104 | void 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 | } | 0 |
122 | } | 0 |
123 | void 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) | 0 |
132 | addAnchor(firstItem, Qt::AnchorRight, secondItem, Qt::AnchorRight); never executed: addAnchor(firstItem, Qt::AnchorRight, secondItem, Qt::AnchorRight); | 0 |
133 | } | 0 |
134 | if (orientations & Qt::Vertical && ok) { never evaluated: orientations & Qt::Vertical | 0 |
135 | addAnchor(secondItem, Qt::AnchorTop, firstItem, Qt::AnchorTop); | - |
136 | addAnchor(firstItem, Qt::AnchorBottom, secondItem, Qt::AnchorBottom); | - |
137 | } | 0 |
138 | } | 0 |
139 | | - |
140 | | - |
141 | | - |
142 | | - |
143 | | - |
144 | | - |
145 | void QGraphicsAnchorLayout::setHorizontalSpacing(qreal spacing) | - |
146 | { | - |
147 | QGraphicsAnchorLayoutPrivate * const d = d_func(); | - |
148 | | - |
149 | d->spacings[0] = spacing; | - |
150 | invalidate(); | - |
151 | } | 0 |
152 | | - |
153 | | - |
154 | | - |
155 | | - |
156 | | - |
157 | | - |
158 | void QGraphicsAnchorLayout::setVerticalSpacing(qreal spacing) | - |
159 | { | - |
160 | QGraphicsAnchorLayoutPrivate * const d = d_func(); | - |
161 | | - |
162 | d->spacings[1] = spacing; | - |
163 | invalidate(); | - |
164 | } | 0 |
165 | void QGraphicsAnchorLayout::setSpacing(qreal spacing) | - |
166 | { | - |
167 | QGraphicsAnchorLayoutPrivate * const d = d_func(); | - |
168 | | - |
169 | d->spacings[0] = d->spacings[1] = spacing; | - |
170 | invalidate(); | - |
171 | } | 0 |
172 | | - |
173 | | - |
174 | | - |
175 | | - |
176 | | - |
177 | | - |
178 | qreal 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 | | - |
189 | qreal 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 | | - |
198 | void 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 | } | 0 |
207 | void QGraphicsAnchorLayout::removeAt(int index) | - |
208 | { | - |
209 | QGraphicsAnchorLayoutPrivate * const d = d_func(); | - |
210 | QGraphicsLayoutItem *item = d->items.value(index); | - |
211 | | - |
212 | if (!item) | 0 |
213 | 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 | } | 0 |
224 | | - |
225 | | - |
226 | | - |
227 | | - |
228 | int 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 | | - |
237 | QGraphicsLayoutItem *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 | | - |
246 | void QGraphicsAnchorLayout::invalidate() | - |
247 | { | - |
248 | QGraphicsAnchorLayoutPrivate * const d = d_func(); | - |
249 | QGraphicsLayout::invalidate(); | - |
250 | d->calculateGraphCacheDirty = true; | - |
251 | d->styleInfoDirty = true; | - |
252 | } | 0 |
253 | | - |
254 | | - |
255 | | - |
256 | | - |
257 | QSizeF 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 | | - |
| | |