OpenCoverage

qgraphicsanchorlayout_p.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13-
14-
15-
16-
17const qreal g_offset = (sizeof(qreal) == sizeof(double)) ? ((1<<24)-1) : ((1<<24)-1) / 32;-
18-
19QGraphicsAnchorPrivate::QGraphicsAnchorPrivate(int version)-
20 : QObjectPrivate(version), layoutPrivate(0), data(0),-
21 sizePolicy(QSizePolicy::Fixed), preferredSize(0),-
22 hasSize(true)-
23{-
24}
never executed: end of block
0
25-
26QGraphicsAnchorPrivate::~QGraphicsAnchorPrivate()-
27{-
28 if (data
dataDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
29-
30-
31 data->graphicsAnchor = 0;-
32-
33 layoutPrivate->removeAnchor(data->from, data->to);-
34 }
never executed: end of block
0
35}
never executed: end of block
0
36-
37void QGraphicsAnchorPrivate::setSizePolicy(QSizePolicy::Policy policy)-
38{-
39 if (sizePolicy != policy
sizePolicy != policyDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
40 sizePolicy = policy;-
41 layoutPrivate->q_func()->invalidate();-
42 }
never executed: end of block
0
43}
never executed: end of block
0
44-
45void QGraphicsAnchorPrivate::setSpacing(qreal value)-
46{-
47 if (!data
!dataDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
48 QMessageLogger(__FILE__, 93, __PRETTY_FUNCTION__).warning("QGraphicsAnchor::setSpacing: The anchor does not exist.");-
49 return;
never executed: return;
0
50 }-
51-
52 if (hasSize
hasSizeDescription
TRUEnever evaluated
FALSEnever evaluated
&& (
(preferredSize == value)Description
TRUEnever evaluated
FALSEnever evaluated
preferredSize == value)
(preferredSize == value)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
53 return;
never executed: return;
0
54-
55-
56 hasSize = true;-
57 preferredSize = value;-
58-
59 layoutPrivate->q_func()->invalidate();-
60}
never executed: end of block
0
61-
62void QGraphicsAnchorPrivate::unsetSpacing()-
63{-
64 if (!data
!dataDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
65 QMessageLogger(__FILE__, 110, __PRETTY_FUNCTION__).warning("QGraphicsAnchor::setSpacing: The anchor does not exist.");-
66 return;
never executed: return;
0
67 }-
68-
69-
70 hasSize = false;-
71-
72 layoutPrivate->q_func()->invalidate();-
73}
never executed: end of block
0
74-
75qreal QGraphicsAnchorPrivate::spacing() const-
76{-
77 if (!data
!dataDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
78 QMessageLogger(__FILE__, 123, __PRETTY_FUNCTION__).warning("QGraphicsAnchor::setSpacing: The anchor does not exist.");-
79 return
never executed: return 0;
0;
never executed: return 0;
0
80 }-
81-
82 return
never executed: return preferredSize;
preferredSize;
never executed: return preferredSize;
0
83}-
84-
85-
86static void applySizePolicy(QSizePolicy::Policy policy,-
87 qreal minSizeHint, qreal prefSizeHint, qreal maxSizeHint,-
88 qreal *minSize, qreal *prefSize,-
89 qreal *maxSize)-
90{-
91 if (policy & QSizePolicy::ShrinkFlag
policy & QSize...cy::ShrinkFlagDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
92 *
never executed: *minSize = minSizeHint;
minSize = minSizeHint;
never executed: *minSize = minSizeHint;
0
93 else-
94 *
never executed: *minSize = prefSizeHint;
minSize = prefSizeHint;
never executed: *minSize = prefSizeHint;
0
95-
96 if (policy & QSizePolicy::GrowFlag
policy & QSizePolicy::GrowFlagDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
97 *
never executed: *maxSize = maxSizeHint;
maxSize = maxSizeHint;
never executed: *maxSize = maxSizeHint;
0
98 else-
99 *
never executed: *maxSize = prefSizeHint;
maxSize = prefSizeHint;
never executed: *maxSize = prefSizeHint;
0
100-
101-
102 if (policy & QSizePolicy::IgnoreFlag
policy & QSize...cy::IgnoreFlagDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
103 *
never executed: *prefSize = *minSize;
prefSize = *minSize;
never executed: *prefSize = *minSize;
0
104 else-
105 *
never executed: *prefSize = prefSizeHint;
prefSize = prefSizeHint;
never executed: *prefSize = prefSizeHint;
0
106}-
107-
108AnchorData::~AnchorData()-
109{-
110 if (graphicsAnchor
graphicsAnchorDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
111-
112-
113 graphicsAnchor->d_func()->data = 0;-
114-
115 delete graphicsAnchor;-
116 }
never executed: end of block
0
117}
never executed: end of block
0
118-
119-
120void AnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo)-
121{-
122 QSizePolicy::Policy policy;-
123 qreal minSizeHint;-
124 qreal prefSizeHint;-
125 qreal maxSizeHint;-
126-
127 if (item
itemDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
128-
129 if (isLayoutAnchor
isLayoutAnchorDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
130 minSize = 0;-
131 prefSize = 0;-
132 maxSize = ((1<<24)-1);-
133 if (isCenterAnchor
isCenterAnchorDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
134 maxSize /= 2;
never executed: maxSize /= 2;
0
135-
136 minPrefSize = prefSize;-
137 maxPrefSize = maxSize;-
138 return;
never executed: return;
0
139 } else {-
140 if (orientation == QGraphicsAnchorLayoutPrivate::Horizontal
orientation ==...te::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
141 policy = item->sizePolicy().horizontalPolicy();-
142 minSizeHint = item->effectiveSizeHint(Qt::MinimumSize).width();-
143 prefSizeHint = item->effectiveSizeHint(Qt::PreferredSize).width();-
144 maxSizeHint = item->effectiveSizeHint(Qt::MaximumSize).width();-
145 }
never executed: end of block
else {
0
146 policy = item->sizePolicy().verticalPolicy();-
147 minSizeHint = item->effectiveSizeHint(Qt::MinimumSize).height();-
148 prefSizeHint = item->effectiveSizeHint(Qt::PreferredSize).height();-
149 maxSizeHint = item->effectiveSizeHint(Qt::MaximumSize).height();-
150 }
never executed: end of block
0
151-
152 if (isCenterAnchor
isCenterAnchorDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
153 minSizeHint /= 2;-
154 prefSizeHint /= 2;-
155 maxSizeHint /= 2;-
156 }
never executed: end of block
0
157 }
never executed: end of block
0
158 } else {-
159-
160 ((!(graphicsAnchor)) ? qt_assert("graphicsAnchor",__FILE__,218) : qt_noop());-
161 QGraphicsAnchorPrivate *anchorPrivate = graphicsAnchor->d_func();-
162-
163-
164 policy = anchorPrivate->sizePolicy;-
165 minSizeHint = 0;-
166 maxSizeHint = ((1<<24)-1);-
167-
168-
169 if (anchorPrivate->hasSize
anchorPrivate->hasSizeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
170-
171 prefSizeHint = anchorPrivate->preferredSize;-
172 }
never executed: end of block
else {
0
173-
174 const Qt::Orientation orient = Qt::Orientation(QGraphicsAnchorLayoutPrivate::edgeOrientation(from->m_edge) + 1);-
175 qreal s = styleInfo->defaultSpacing(orient);-
176 if (s < 0
s < 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
177 QSizePolicy::ControlType controlTypeFrom = from->m_item->sizePolicy().controlType();-
178 QSizePolicy::ControlType controlTypeTo = to->m_item->sizePolicy().controlType();-
179 s = styleInfo->perItemSpacing(controlTypeFrom, controlTypeTo, orient);-
180-
181-
182-
183-
184 if (s < 0
s < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
185 s = 0;
never executed: s = 0;
0
186 }
never executed: end of block
0
187 prefSizeHint = s;-
188 }
never executed: end of block
0
189 }-
190-
191-
192 applySizePolicy(policy, minSizeHint, prefSizeHint, maxSizeHint,-
193 &minSize, &prefSize, &maxSize);-
194-
195 minPrefSize = prefSize;-
196 maxPrefSize = maxSize;-
197 sizeAtMinimum = prefSize;-
198 sizeAtPreferred = prefSize;-
199 sizeAtMaximum = prefSize;-
200}
never executed: end of block
0
201-
202void ParallelAnchorData::updateChildrenSizes()-
203{-
204 firstEdge->sizeAtMinimum = sizeAtMinimum;-
205 firstEdge->sizeAtPreferred = sizeAtPreferred;-
206 firstEdge->sizeAtMaximum = sizeAtMaximum;-
207-
208 if (secondForward()
secondForward()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
209 secondEdge->sizeAtMinimum = sizeAtMinimum;-
210 secondEdge->sizeAtPreferred = sizeAtPreferred;-
211 secondEdge->sizeAtMaximum = sizeAtMaximum;-
212 }
never executed: end of block
else {
0
213 secondEdge->sizeAtMinimum = -sizeAtMinimum;-
214 secondEdge->sizeAtPreferred = -sizeAtPreferred;-
215 secondEdge->sizeAtMaximum = -sizeAtMaximum;-
216 }
never executed: end of block
0
217-
218 firstEdge->updateChildrenSizes();-
219 secondEdge->updateChildrenSizes();-
220}
never executed: end of block
0
221bool ParallelAnchorData::calculateSizeHints()-
222{-
223-
224-
225-
226 qreal secondMin;-
227 qreal secondMinPref;-
228 qreal secondPref;-
229 qreal secondMaxPref;-
230 qreal secondMax;-
231-
232 if (secondForward()
secondForward()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
233 secondMin = secondEdge->minSize;-
234 secondMinPref = secondEdge->minPrefSize;-
235 secondPref = secondEdge->prefSize;-
236 secondMaxPref = secondEdge->maxPrefSize;-
237 secondMax = secondEdge->maxSize;-
238 }
never executed: end of block
else {
0
239 secondMin = -secondEdge->maxSize;-
240 secondMinPref = -secondEdge->maxPrefSize;-
241 secondPref = -secondEdge->prefSize;-
242 secondMaxPref = -secondEdge->minPrefSize;-
243 secondMax = -secondEdge->minSize;-
244 }
never executed: end of block
0
245-
246 minSize = qMax(firstEdge->minSize, secondMin);-
247 maxSize = qMin(firstEdge->maxSize, secondMax);-
248-
249-
250-
251-
252 if (minSize > maxSize
minSize > maxSizeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
253 return
never executed: return false;
false;
never executed: return false;
0
254 }-
255 if (firstEdge->isLayoutAnchor
firstEdge->isLayoutAnchorDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
256 prefSize = qBound(minSize, secondPref, maxSize);-
257 minPrefSize = qBound(minSize, secondMinPref, maxSize);-
258 maxPrefSize = qBound(minSize, secondMaxPref, maxSize);-
259 }
never executed: end of block
else if (secondEdge->isLayoutAnchor
secondEdge->isLayoutAnchorDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
260 prefSize = qBound(minSize, firstEdge->prefSize, maxSize);-
261 minPrefSize = qBound(minSize, firstEdge->minPrefSize, maxSize);-
262 maxPrefSize = qBound(minSize, firstEdge->maxPrefSize, maxSize);-
263 }
never executed: end of block
else {
0
264-
265 const qreal lowerBoundary =-
266 qBound(minSize, qMax(firstEdge->minPrefSize, secondMinPref), maxSize);-
267 const qreal upperBoundary =-
268 qBound(minSize, qMin(firstEdge->maxPrefSize, secondMaxPref), maxSize);-
269 const qreal prefMean =-
270 qBound(minSize, (firstEdge->prefSize + secondPref) / 2, maxSize);-
271-
272 if (lowerBoundary < upperBoundary
lowerBoundary < upperBoundaryDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
273-
274-
275-
276-
277 prefSize = qBound(lowerBoundary, prefMean, upperBoundary);-
278 minPrefSize = lowerBoundary;-
279 maxPrefSize = upperBoundary;-
280 }
never executed: end of block
else {
0
281-
282-
283-
284-
285-
286-
287 prefSize = qBound(upperBoundary, prefMean, lowerBoundary);-
288 minPrefSize = upperBoundary;-
289 maxPrefSize = lowerBoundary;-
290 }
never executed: end of block
0
291 }-
292-
293-
294 sizeAtMinimum = prefSize;-
295 sizeAtPreferred = prefSize;-
296 sizeAtMaximum = prefSize;-
297-
298 return
never executed: return true;
true;
never executed: return true;
0
299}-
300static QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> getFactor(qreal value, qreal min,-
301 qreal minPref, qreal pref,-
302 qreal maxPref, qreal max)-
303{-
304 QGraphicsAnchorLayoutPrivate::Interval interval;-
305 qreal lower;-
306 qreal upper;-
307-
308 if (value < minPref
value < minPrefDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
309 interval = QGraphicsAnchorLayoutPrivate::MinimumToMinPreferred;-
310 lower = min;-
311 upper = minPref;-
312 }
never executed: end of block
else if (value < pref
value < prefDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
313 interval = QGraphicsAnchorLayoutPrivate::MinPreferredToPreferred;-
314 lower = minPref;-
315 upper = pref;-
316 }
never executed: end of block
else if (value < maxPref
value < maxPrefDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
317 interval = QGraphicsAnchorLayoutPrivate::PreferredToMaxPreferred;-
318 lower = pref;-
319 upper = maxPref;-
320 }
never executed: end of block
else {
0
321 interval = QGraphicsAnchorLayoutPrivate::MaxPreferredToMaximum;-
322 lower = maxPref;-
323 upper = max;-
324 }
never executed: end of block
0
325-
326 qreal progress;-
327 if (upper == lower
upper == lowerDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
328 progress = 0;-
329 }
never executed: end of block
else {
0
330 progress = (value - lower) / (upper - lower);-
331 }
never executed: end of block
0
332-
333 return
never executed: return qMakePair(interval, progress);
qMakePair(interval, progress);
never executed: return qMakePair(interval, progress);
0
334}-
335-
336static qreal interpolate(const QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> &factor,-
337 qreal min, qreal minPref, qreal pref, qreal maxPref, qreal max)-
338{-
339 qreal lower = 0;-
340 qreal upper = 0;-
341-
342 switch (factor.first) {-
343 case
never executed: case QGraphicsAnchorLayoutPrivate::MinimumToMinPreferred:
QGraphicsAnchorLayoutPrivate::MinimumToMinPreferred:
never executed: case QGraphicsAnchorLayoutPrivate::MinimumToMinPreferred:
0
344 lower = min;-
345 upper = minPref;-
346 break;
never executed: break;
0
347 case
never executed: case QGraphicsAnchorLayoutPrivate::MinPreferredToPreferred:
QGraphicsAnchorLayoutPrivate::MinPreferredToPreferred:
never executed: case QGraphicsAnchorLayoutPrivate::MinPreferredToPreferred:
0
348 lower = minPref;-
349 upper = pref;-
350 break;
never executed: break;
0
351 case
never executed: case QGraphicsAnchorLayoutPrivate::PreferredToMaxPreferred:
QGraphicsAnchorLayoutPrivate::PreferredToMaxPreferred:
never executed: case QGraphicsAnchorLayoutPrivate::PreferredToMaxPreferred:
0
352 lower = pref;-
353 upper = maxPref;-
354 break;
never executed: break;
0
355 case
never executed: case QGraphicsAnchorLayoutPrivate::MaxPreferredToMaximum:
QGraphicsAnchorLayoutPrivate::MaxPreferredToMaximum:
never executed: case QGraphicsAnchorLayoutPrivate::MaxPreferredToMaximum:
0
356 lower = maxPref;-
357 upper = max;-
358 break;
never executed: break;
0
359 }-
360-
361 return
never executed: return lower + factor.second * (upper - lower);
lower + factor.second * (upper - lower);
never executed: return lower + factor.second * (upper - lower);
0
362}-
363-
364void SequentialAnchorData::updateChildrenSizes()-
365{-
366-
367-
368-
369 const QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> minFactor =-
370 getFactor(sizeAtMinimum, minSize, minPrefSize, prefSize, maxPrefSize, maxSize);-
371 const QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> prefFactor =-
372 getFactor(sizeAtPreferred, minSize, minPrefSize, prefSize, maxPrefSize, maxSize);-
373 const QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> maxFactor =-
374 getFactor(sizeAtMaximum, minSize, minPrefSize, prefSize, maxPrefSize, maxSize);-
375-
376-
377-
378-
379 AnchorVertex *prev = from;-
380-
381 for (int i = 0; i < m_edges.count()
i < m_edges.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
382 AnchorData *e = m_edges.at(i);-
383-
384 const bool edgeIsForward = (e->from == prev);-
385 if (edgeIsForward
edgeIsForwardDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
386 e->sizeAtMinimum = interpolate(minFactor, e->minSize, e->minPrefSize,-
387 e->prefSize, e->maxPrefSize, e->maxSize);-
388 e->sizeAtPreferred = interpolate(prefFactor, e->minSize, e->minPrefSize,-
389 e->prefSize, e->maxPrefSize, e->maxSize);-
390 e->sizeAtMaximum = interpolate(maxFactor, e->minSize, e->minPrefSize,-
391 e->prefSize, e->maxPrefSize, e->maxSize);-
392 prev = e->to;-
393 }
never executed: end of block
else {
0
394 ((!(prev == e->to)) ? qt_assert("prev == e->to",__FILE__,509) : qt_noop());-
395 e->sizeAtMinimum = interpolate(minFactor, e->maxSize, e->maxPrefSize,-
396 e->prefSize, e->minPrefSize, e->minSize);-
397 e->sizeAtPreferred = interpolate(prefFactor, e->maxSize, e->maxPrefSize,-
398 e->prefSize, e->minPrefSize, e->minSize);-
399 e->sizeAtMaximum = interpolate(maxFactor, e->maxSize, e->maxPrefSize,-
400 e->prefSize, e->minPrefSize, e->minSize);-
401 prev = e->from;-
402 }
never executed: end of block
0
403-
404 e->updateChildrenSizes();-
405 }
never executed: end of block
0
406}
never executed: end of block
0
407-
408void SequentialAnchorData::calculateSizeHints()-
409{-
410 minSize = 0;-
411 prefSize = 0;-
412 maxSize = 0;-
413 minPrefSize = 0;-
414 maxPrefSize = 0;-
415-
416 AnchorVertex *prev = from;-
417-
418 for (int i = 0; i < m_edges.count()
i < m_edges.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
419 AnchorData *edge = m_edges.at(i);-
420-
421 const bool edgeIsForward = (edge->from == prev);-
422 if (edgeIsForward
edgeIsForwardDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
423 minSize += edge->minSize;-
424 prefSize += edge->prefSize;-
425 maxSize += edge->maxSize;-
426 minPrefSize += edge->minPrefSize;-
427 maxPrefSize += edge->maxPrefSize;-
428 prev = edge->to;-
429 }
never executed: end of block
else {
0
430 ((!(prev == edge->to)) ? qt_assert("prev == edge->to",__FILE__,545) : qt_noop());-
431 minSize -= edge->maxSize;-
432 prefSize -= edge->prefSize;-
433 maxSize -= edge->minSize;-
434 minPrefSize -= edge->maxPrefSize;-
435 maxPrefSize -= edge->minPrefSize;-
436 prev = edge->from;-
437 }
never executed: end of block
0
438 }-
439-
440-
441 sizeAtMinimum = prefSize;-
442 sizeAtPreferred = prefSize;-
443 sizeAtMaximum = prefSize;-
444}
never executed: end of block
0
445-
446-
447void AnchorData::dump(int indent) {-
448 if (type == Parallel
type == ParallelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
449 QMessageLogger(__FILE__, 564, __PRETTY_FUNCTION__).debug("%*s type: parallel:", indent, "");-
450 ParallelAnchorData *p = static_cast<ParallelAnchorData *>(this);-
451 p->firstEdge->dump(indent+2);-
452 p->secondEdge->dump(indent+2);-
453 }
never executed: end of block
else if (type == Sequential
type == SequentialDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
454 SequentialAnchorData *s = static_cast<SequentialAnchorData *>(this);-
455 int kids = s->m_edges.count();-
456 QMessageLogger(__FILE__, 571, __PRETTY_FUNCTION__).debug("%*s type: sequential(%d):", indent, "", kids);-
457 for (int i = 0; i < kids
i < kidsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
458 s->m_edges.at(i)->dump(indent+2);-
459 }
never executed: end of block
0
460 }
never executed: end of block
else {
0
461 QMessageLogger(__FILE__, 576, __PRETTY_FUNCTION__).debug("%*s type: Normal:", indent, "");-
462 }
never executed: end of block
0
463}-
464-
465-
466-
467QSimplexConstraint *GraphPath::constraint(const GraphPath &path) const-
468{-
469-
470 QSet<AnchorData *> cPositives;-
471 QSet<AnchorData *> cNegatives;-
472 QSet<AnchorData *> intersection;-
473-
474 cPositives = positives + path.negatives;-
475 cNegatives = negatives + path.positives;-
476-
477 intersection = cPositives & cNegatives;-
478-
479 cPositives -= intersection;-
480 cNegatives -= intersection;-
481-
482-
483 QSimplexConstraint *c = new QSimplexConstraint;-
484 QSet<AnchorData *>::iterator i;-
485 for (i = cPositives.begin(); i != cPositives.end()
i != cPositives.end()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
486 c->variables.insert(*i, 1.0);
never executed: c->variables.insert(*i, 1.0);
0
487-
488 for (i = cNegatives.begin(); i != cNegatives.end()
i != cNegatives.end()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
489 c->variables.insert(*i, -1.0);
never executed: c->variables.insert(*i, -1.0);
0
490-
491 return
never executed: return c;
c;
never executed: return c;
0
492}-
493-
494-
495QString GraphPath::toString() const-
496{-
497 QString string(QLatin1String("Path: "));-
498 for (AnchorData *edge : positives)-
499 string += QString::fromLatin1(" (+++) %1").arg(edge->toString());
never executed: string += QString::fromLatin1(" (+++) %1").arg(edge->toString());
0
500-
501 for (AnchorData *edge : negatives)-
502 string += QString::fromLatin1(" (---) %1").arg(edge->toString());
never executed: string += QString::fromLatin1(" (---) %1").arg(edge->toString());
0
503-
504 return
never executed: return string;
string;
never executed: return string;
0
505}-
506-
507-
508QGraphicsAnchorLayoutPrivate::QGraphicsAnchorLayoutPrivate()-
509 : calculateGraphCacheDirty(true), styleInfoDirty(true)-
510{-
511 for (int i = 0; i < NOrientations
i < NOrientationsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
512 for (int j = 0; j < 3
j < 3Description
TRUEnever evaluated
FALSEnever evaluated
; ++j) {
0
513 sizeHints[i][j] = -1;-
514 }
never executed: end of block
0
515 interpolationProgress[i] = -1;-
516-
517 spacings[i] = -1;-
518 graphHasConflicts[i] = false;-
519-
520 layoutFirstVertex[i] = 0;-
521 layoutCentralVertex[i] = 0;-
522 layoutLastVertex[i] = 0;-
523 }
never executed: end of block
0
524}
never executed: end of block
0
525-
526Qt::AnchorPoint QGraphicsAnchorLayoutPrivate::oppositeEdge(Qt::AnchorPoint edge)-
527{-
528 switch (edge) {-
529 case
never executed: case Qt::AnchorLeft:
Qt::AnchorLeft:
never executed: case Qt::AnchorLeft:
0
530 edge = Qt::AnchorRight;-
531 break;
never executed: break;
0
532 case
never executed: case Qt::AnchorRight:
Qt::AnchorRight:
never executed: case Qt::AnchorRight:
0
533 edge = Qt::AnchorLeft;-
534 break;
never executed: break;
0
535 case
never executed: case Qt::AnchorTop:
Qt::AnchorTop:
never executed: case Qt::AnchorTop:
0
536 edge = Qt::AnchorBottom;-
537 break;
never executed: break;
0
538 case
never executed: case Qt::AnchorBottom:
Qt::AnchorBottom:
never executed: case Qt::AnchorBottom:
0
539 edge = Qt::AnchorTop;-
540 break;
never executed: break;
0
541 default
never executed: default:
:
never executed: default:
0
542 break;
never executed: break;
0
543 }-
544 return
never executed: return edge;
edge;
never executed: return edge;
0
545}-
546AnchorData *QGraphicsAnchorLayoutPrivate::addAnchorMaybeParallel(AnchorData *newAnchor, bool *feasible)-
547{-
548 Orientation orientation = Orientation(newAnchor->orientation);-
549 Graph<AnchorVertex, AnchorData> &g = graph[orientation];-
550 *feasible = true;-
551-
552-
553-
554 if (AnchorData *oldAnchor = g.takeEdge(newAnchor->from, newAnchor->to)
AnchorData *ol...newAnchor->to)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
555 ParallelAnchorData *parallel = new ParallelAnchorData(oldAnchor, newAnchor);-
556-
557-
558-
559-
560-
561-
562 QList<QSimplexConstraint *> &constraints = itemCenterConstraints[orientation];-
563-
564 AnchorData *children[2] = { oldAnchor, newAnchor };-
565 QList<QSimplexConstraint *> *childrenConstraints[2] = { &parallel->m_firstConstraints,-
566 &parallel->m_secondConstraints };-
567-
568 for (int i = 0; i < 2
i < 2Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
569 AnchorData *child = children[i];-
570 QList<QSimplexConstraint *> *childConstraints = childrenConstraints[i];-
571-
572-
573-
574-
575-
576-
577 const bool needsReverse = i == 1
i == 1Description
TRUEnever evaluated
FALSEnever evaluated
&& !parallel->secondForward()
!parallel->secondForward()Description
TRUEnever evaluated
FALSEnever evaluated
;
0
578-
579 if (!child->isCenterAnchor
!child->isCenterAnchorDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
580 continue;
never executed: continue;
0
581-
582 parallel->isCenterAnchor = true;-
583-
584 for (int j = 0; j < constraints.count()
j < constraints.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++j) {
0
585 QSimplexConstraint *c = constraints[j];-
586 if (c->variables.contains(child)
c->variables.contains(child)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
587 childConstraints->append(c);-
588 qreal v = c->variables.take(child);-
589 if (needsReverse
needsReverseDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
590 v *= -1;
never executed: v *= -1;
0
591 c->variables.insert(parallel, v);-
592 }
never executed: end of block
0
593 }
never executed: end of block
0
594 }
never executed: end of block
0
595-
596-
597-
598 *feasible = parallel->calculateSizeHints();-
599 newAnchor = parallel;-
600 }
never executed: end of block
0
601-
602 g.createEdge(newAnchor->from, newAnchor->to, newAnchor);-
603 return
never executed: return newAnchor;
newAnchor;
never executed: return newAnchor;
0
604}-
605static AnchorData *createSequence(Graph<AnchorVertex, AnchorData> *graph,-
606 AnchorVertex *before,-
607 const QVector<AnchorVertex*> &vertices,-
608 AnchorVertex *after)-
609{-
610 AnchorVertex *prev = before;-
611 QVector<AnchorData *> edges;-
612 edges.reserve(vertices.count() + 1);-
613-
614 const int numVertices = vertices.count();-
615 edges.reserve(numVertices + 1);-
616-
617 for (int i = 0; i < numVertices
i < numVerticesDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
618 AnchorVertex *next = vertices.at(i);-
619 AnchorData *ad = graph->takeEdge(prev, next);-
620 ((!(ad)) ? qt_assert("ad",__FILE__,770) : qt_noop());-
621 edges.append(ad);-
622 prev = next;-
623 }
never executed: end of block
0
624-
625-
626 AnchorData *ad = graph->takeEdge(vertices.last(), after);-
627 ((!(ad)) ? qt_assert("ad",__FILE__,777) : qt_noop());-
628 edges.append(ad);-
629-
630-
631 SequentialAnchorData *sequence = new SequentialAnchorData(vertices, edges);-
632 sequence->from = before;-
633 sequence->to = after;-
634-
635 sequence->calculateSizeHints();-
636-
637 return
never executed: return sequence;
sequence;
never executed: return sequence;
0
638}-
639bool QGraphicsAnchorLayoutPrivate::simplifyGraph(Orientation orientation)-
640{-
641 if (items.isEmpty()
items.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
642 return
never executed: return true;
true;
never executed: return true;
0
643 if (!simplifyVertices(orientation)
!simplifyVertices(orientation)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
644 restoreVertices(orientation);-
645 return
never executed: return false;
false;
never executed: return false;
0
646 }-
647-
648-
649 bool dirty;-
650 bool feasible = true;-
651 do {-
652 dirty = simplifyGraphIteration(orientation, &feasible);-
653 }
never executed: end of block
while (dirty
dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
&& feasible
feasibleDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
654-
655-
656 if (!feasible
!feasibleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
657 restoreSimplifiedGraph(orientation);-
658 restoreVertices(orientation);-
659 return
never executed: return false;
false;
never executed: return false;
0
660 }-
661-
662-
663-
664-
665-
666-
667 return
never executed: return true;
true;
never executed: return true;
0
668}-
669-
670static AnchorVertex *replaceVertex_helper(AnchorData *data, AnchorVertex *oldV, AnchorVertex *newV)-
671{-
672 AnchorVertex *other;-
673 if (data->from == oldV
data->from == oldVDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
674 data->from = newV;-
675 other = data->to;-
676 }
never executed: end of block
else {
0
677 data->to = newV;-
678 other = data->from;-
679 }
never executed: end of block
0
680 return
never executed: return other;
other;
never executed: return other;
0
681}-
682-
683bool QGraphicsAnchorLayoutPrivate::replaceVertex(Orientation orientation, AnchorVertex *oldV,-
684 AnchorVertex *newV, const QList<AnchorData *> &edges)-
685{-
686 Graph<AnchorVertex, AnchorData> &g = graph[orientation];-
687 bool feasible = true;-
688-
689 for (int i = 0; i < edges.count()
i < edges.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
690 AnchorData *ad = edges[i];-
691 AnchorVertex *otherV = replaceVertex_helper(ad, oldV, newV);-
692-
693-
694 ad->name = QString::fromLatin1("%1 --to--> %2").arg(ad->from->toString()).arg(ad->to->toString());-
695-
696-
697 bool newFeasible;-
698 AnchorData *newAnchor = addAnchorMaybeParallel(ad, &newFeasible);-
699 feasible &= newFeasible;-
700-
701 if (newAnchor != ad
newAnchor != adDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
702-
703-
704-
705 anchorsFromSimplifiedVertices[orientation].append(newAnchor);-
706 }
never executed: end of block
0
707-
708 g.takeEdge(oldV, otherV);-
709 }
never executed: end of block
0
710-
711 return
never executed: return feasible;
feasible;
never executed: return feasible;
0
712}-
713-
714-
715-
716-
717bool QGraphicsAnchorLayoutPrivate::simplifyVertices(Orientation orientation)-
718{-
719 QGraphicsAnchorLayout * const q = q_func();-
720 Graph<AnchorVertex, AnchorData> &g = graph[orientation];-
721-
722-
723 QStack<AnchorVertex *> stack;-
724 stack.push(layoutFirstVertex[orientation]);-
725 QSet<AnchorVertex *> visited;-
726-
727 while (!stack.isEmpty()
!stack.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
728 AnchorVertex *v = stack.pop();-
729 visited.insert(v);-
730-
731-
732-
733-
734 QList<AnchorVertex *> adjacents = g.adjacentVertices(v);-
735 int index = 0;-
736-
737 while (index < adjacents.count()
index < adjacents.count()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
738 AnchorVertex *next = adjacents.at(index);-
739 index++;-
740-
741 AnchorData *data = g.edgeData(v, next);-
742 const bool bothLayoutVertices = v->m_item == q
v->m_item == qDescription
TRUEnever evaluated
FALSEnever evaluated
&& next->m_item == q
next->m_item == qDescription
TRUEnever evaluated
FALSEnever evaluated
;
0
743 const bool zeroSized = !data->minSize
!data->minSizeDescription
TRUEnever evaluated
FALSEnever evaluated
&& !data->maxSize
!data->maxSizeDescription
TRUEnever evaluated
FALSEnever evaluated
;
0
744-
745 if (!bothLayoutVertices
!bothLayoutVerticesDescription
TRUEnever evaluated
FALSEnever evaluated
&& zeroSized
zeroSizedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
746-
747-
748-
749 AnchorVertexPair *newV = new AnchorVertexPair(v, next, data);-
750 simplifiedVertices[orientation].append(newV);-
751-
752-
753-
754 const QList<AnchorVertex *> &vAdjacents = g.adjacentVertices(v);-
755 const QList<AnchorVertex *> &nextAdjacents = g.adjacentVertices(next);-
756-
757 for (int i = 0; i < vAdjacents.count()
i < vAdjacents.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
758 AnchorVertex *adjacent = vAdjacents.at(i);-
759 if (adjacent != next
adjacent != nextDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
760 AnchorData *ad = g.edgeData(v, adjacent);-
761 newV->m_firstAnchors.append(ad);-
762 }
never executed: end of block
0
763 }
never executed: end of block
0
764-
765 for (int i = 0; i < nextAdjacents.count()
i < nextAdjacents.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
766 AnchorVertex *adjacent = nextAdjacents.at(i);-
767 if (adjacent != v
adjacent != vDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
768 AnchorData *ad = g.edgeData(next, adjacent);-
769 newV->m_secondAnchors.append(ad);-
770-
771-
772-
773 if (!adjacents.contains(adjacent)
!adjacents.contains(adjacent)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
774 adjacents.append(adjacent);
never executed: adjacents.append(adjacent);
0
775 }
never executed: end of block
0
776 }
never executed: end of block
0
777-
778-
779-
780 bool feasible = replaceVertex(orientation, v, newV, newV->m_firstAnchors);-
781 feasible &= replaceVertex(orientation, next, newV, newV->m_secondAnchors);-
782-
783-
784 AnchorVertex *layoutVertex = 0;-
785 if (v->m_item == q
v->m_item == qDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
786 layoutVertex = v;
never executed: layoutVertex = v;
0
787 else if (next->m_item == q
next->m_item == qDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
788 layoutVertex = next;
never executed: layoutVertex = next;
0
789-
790 if (layoutVertex
layoutVertexDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
791-
792 newV->m_item = q;-
793 changeLayoutVertex(orientation, layoutVertex, newV);-
794 }
never executed: end of block
0
795-
796 g.takeEdge(v, next);-
797-
798-
799 if (!feasible
!feasibleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
800 return
never executed: return false;
false;
never executed: return false;
0
801-
802 v = newV;-
803 visited.insert(newV);-
804-
805 }
never executed: end of block
else if (!visited.contains(next)
!visited.contains(next)Description
TRUEnever evaluated
FALSEnever evaluated
&& !stack.contains(next)
!stack.contains(next)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
806-
807-
808 stack.push(next);-
809 }
never executed: end of block
0
810 }
never executed: end of block
0
811 }
never executed: end of block
0
812-
813 return
never executed: return true;
true;
never executed: return true;
0
814}-
815bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutPrivate::Orientation orientation,-
816 bool *feasible)-
817{-
818 QGraphicsAnchorLayout * const q = q_func();-
819 Graph<AnchorVertex, AnchorData> &g = graph[orientation];-
820-
821 QSet<AnchorVertex *> visited;-
822 QStack<QPair<AnchorVertex *, AnchorVertex *> > stack;-
823 stack.push(qMakePair(static_cast<AnchorVertex *>(0), layoutFirstVertex[orientation]));-
824 QVector<AnchorVertex*> candidates;-
825-
826-
827-
828 while (!stack.isEmpty()
!stack.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
829 QPair<AnchorVertex *, AnchorVertex *> pair = stack.pop();-
830 AnchorVertex *beforeSequence = pair.first;-
831 AnchorVertex *v = pair.second;-
832 const QList<AnchorVertex *> &adjacents = g.adjacentVertices(v);-
833 const bool isLayoutVertex = v->m_item == q;-
834 AnchorVertex *afterSequence = v;-
835 bool endOfSequence = false;-
836-
837-
838-
839-
840-
841-
842 endOfSequence = isLayoutVertex
isLayoutVertexDescription
TRUEnever evaluated
FALSEnever evaluated
|| adjacents.count() != 2
adjacents.count() != 2Description
TRUEnever evaluated
FALSEnever evaluated
;
0
843-
844 if (!endOfSequence
!endOfSequenceDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
845 AnchorVertex *after;-
846 if (candidates.isEmpty()
candidates.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
847 after = (beforeSequence == adjacents.last()
beforeSequence...jacents.last()Description
TRUEnever evaluated
FALSEnever evaluated
? adjacents.first() : adjacents.last());
never executed: after = (beforeSequence == adjacents.last() ? adjacents.first() : adjacents.last());
0
848 else-
849 after = (candidates.constLast() == adjacents.last()
candidates.con...jacents.last()Description
TRUEnever evaluated
FALSEnever evaluated
? adjacents.first() : adjacents.last());
never executed: after = (candidates.constLast() == adjacents.last() ? adjacents.first() : adjacents.last());
0
850-
851-
852-
853 ((!(!candidates.contains(after))) ? qt_assert("!candidates.contains(after)",__FILE__,1089) : qt_noop());-
854-
855 const AnchorData *data = g.edgeData(v, after);-
856 ((!(data)) ? qt_assert("data",__FILE__,1092) : qt_noop());-
857 const bool cycleFound = visited.contains(after);-
858-
859-
860 endOfSequence = cycleFound
cycleFoundDescription
TRUEnever evaluated
FALSEnever evaluated
|| data->isCenterAnchor
data->isCenterAnchorDescription
TRUEnever evaluated
FALSEnever evaluated
;
0
861-
862 if (!endOfSequence
!endOfSequenceDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
863-
864-
865 candidates.append(v);-
866 }
never executed: end of block
else if (cycleFound
cycleFoundDescription
TRUEnever evaluated
FALSEnever evaluated
&& (
(beforeSequence != after)Description
TRUEnever evaluated
FALSEnever evaluated
beforeSequence != after)
(beforeSequence != after)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
867 afterSequence = after;-
868 candidates.append(v);-
869 }
never executed: end of block
0
870 }
never executed: end of block
0
871-
872-
873-
874-
875 for (int i = 0; i < adjacents.count()
i < adjacents.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
876 AnchorVertex *next = adjacents.at(i);-
877 if (visited.contains(next)
visited.contains(next)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
878 continue;
never executed: continue;
0
879-
880-
881-
882-
883-
884 if (endOfSequence
endOfSequenceDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
885 stack.push(qMakePair(v, next));
never executed: stack.push(qMakePair(v, next));
0
886 else-
887 stack.push(qMakePair(beforeSequence, next));
never executed: stack.push(qMakePair(beforeSequence, next));
0
888 }-
889-
890 visited.insert(v);-
891-
892 if (!endOfSequence
!endOfSequenceDescription
TRUEnever evaluated
FALSEnever evaluated
|| candidates.isEmpty()
candidates.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
893 continue;
never executed: continue;
0
894-
895-
896-
897-
898-
899-
900-
901 const AnchorData *firstAnchor = g.edgeData(beforeSequence, candidates.constFirst());-
902 if (firstAnchor->isCenterAnchor
firstAnchor->isCenterAnchorDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
903 beforeSequence = candidates.constFirst();-
904 candidates.remove(0);-
905-
906-
907 if (candidates.isEmpty()
candidates.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
908 continue;
never executed: continue;
0
909 }
never executed: end of block
0
910-
911 const AnchorData *lastAnchor = g.edgeData(candidates.constLast(), afterSequence);-
912 if (lastAnchor->isCenterAnchor
lastAnchor->isCenterAnchorDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
913 afterSequence = candidates.constLast();-
914 candidates.remove(candidates.count() - 1);-
915-
916 if (candidates.isEmpty()
candidates.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
917 continue;
never executed: continue;
0
918 }
never executed: end of block
0
919-
920-
921-
922-
923-
924 AnchorData *sequence = createSequence(&g, beforeSequence, candidates, afterSequence);-
925-
926-
927-
928 bool newFeasible;-
929 AnchorData *newAnchor = addAnchorMaybeParallel(sequence, &newFeasible);-
930-
931 if (!newFeasible
!newFeasibleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
932 *feasible = false;-
933 return
never executed: return false;
false;
never executed: return false;
0
934 }-
935-
936-
937-
938-
939-
940 if (newAnchor != sequence
newAnchor != sequenceDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
941 return
never executed: return true;
true;
never executed: return true;
0
942-
943-
944-
945 candidates.clear();-
946 }
never executed: end of block
0
947-
948 return
never executed: return false;
false;
never executed: return false;
0
949}-
950-
951void QGraphicsAnchorLayoutPrivate::restoreSimplifiedAnchor(AnchorData *edge)-
952{-
953-
954-
955-
956-
957-
958-
959-
960 Graph<AnchorVertex, AnchorData> &g = graph[edge->orientation];-
961-
962 if (edge->type == AnchorData::Normal
edge->type == ...orData::NormalDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
963 g.createEdge(edge->from, edge->to, edge);-
964-
965 }
never executed: end of block
else if (edge->type == AnchorData::Sequential
edge->type == ...ta::SequentialDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
966 SequentialAnchorData *sequence = static_cast<SequentialAnchorData *>(edge);-
967-
968 for (int i = 0; i < sequence->m_edges.count()
i < sequence->m_edges.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
969 AnchorData *data = sequence->m_edges.at(i);-
970 restoreSimplifiedAnchor(data);-
971 }
never executed: end of block
0
972-
973 delete sequence;-
974-
975 }
never executed: end of block
else if (edge->type == AnchorData::Parallel
edge->type == ...Data::ParallelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
976-
977-
978-
979-
980 if (anchorsFromSimplifiedVertices[edge->orientation].contains(edge)
anchorsFromSim...contains(edge)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
981 return;
never executed: return;
0
982-
983 ParallelAnchorData* parallel = static_cast<ParallelAnchorData*>(edge);-
984 restoreSimplifiedConstraints(parallel);-
985-
986-
987-
988-
989 ((!(parallel->firstEdge->type == AnchorData::Sequential || parallel->secondEdge->type == AnchorData::Sequential)) ? qt_assert("parallel->firstEdge->type == AnchorData::Sequential || parallel->secondEdge->type == AnchorData::Sequential",-
990 __FILE__-
991 ,-
992 1226-
993 ) : qt_noop())-
994 ;-
995 restoreSimplifiedAnchor(parallel->firstEdge);-
996 restoreSimplifiedAnchor(parallel->secondEdge);-
997-
998 delete parallel;-
999 }
never executed: end of block
0
1000}
never executed: end of block
0
1001-
1002void QGraphicsAnchorLayoutPrivate::restoreSimplifiedConstraints(ParallelAnchorData *parallel)-
1003{-
1004 if (!parallel->isCenterAnchor
!parallel->isCenterAnchorDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1005 return;
never executed: return;
0
1006-
1007 for (int i = 0; i < parallel->m_firstConstraints.count()
i < parallel->...raints.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1008 QSimplexConstraint *c = parallel->m_firstConstraints.at(i);-
1009 qreal v = c->variables[parallel];-
1010 c->variables.remove(parallel);-
1011 c->variables.insert(parallel->firstEdge, v);-
1012 }
never executed: end of block
0
1013-
1014-
1015-
1016 const bool needsReverse = !parallel->secondForward();-
1017-
1018 for (int i = 0; i < parallel->m_secondConstraints.count()
i < parallel->...raints.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1019 QSimplexConstraint *c = parallel->m_secondConstraints.at(i);-
1020 qreal v = c->variables[parallel];-
1021 if (needsReverse
needsReverseDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1022 v *= -1;
never executed: v *= -1;
0
1023 c->variables.remove(parallel);-
1024 c->variables.insert(parallel->secondEdge, v);-
1025 }
never executed: end of block
0
1026}
never executed: end of block
0
1027-
1028void QGraphicsAnchorLayoutPrivate::restoreSimplifiedGraph(Orientation orientation)-
1029{-
1030-
1031-
1032-
1033-
1034-
1035-
1036 Graph<AnchorVertex, AnchorData> &g = graph[orientation];-
1037 QVector<QPair<AnchorVertex*, AnchorVertex*> > connections = g.connections();-
1038 for (int i = 0; i < connections.count()
i < connections.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1039 AnchorVertex *v1 = connections.at(i).first;-
1040 AnchorVertex *v2 = connections.at(i).second;-
1041 AnchorData *edge = g.edgeData(v1, v2);-
1042-
1043-
1044-
1045 if (edge->type == AnchorData::Sequential
edge->type == ...ta::SequentialDescription
TRUEnever evaluated
FALSEnever evaluated
0
1046 || (edge->type == AnchorData::Parallel
edge->type == ...Data::ParallelDescription
TRUEnever evaluated
FALSEnever evaluated
&&
0
1047 !anchorsFromSimplifiedVertices[orientation].contains(edge)
!anchorsFromSi...contains(edge)Description
TRUEnever evaluated
FALSEnever evaluated
)) {
0
1048-
1049 g.takeEdge(v1, v2);-
1050 restoreSimplifiedAnchor(edge);-
1051 }
never executed: end of block
0
1052 }
never executed: end of block
0
1053-
1054 restoreVertices(orientation);-
1055}
never executed: end of block
0
1056-
1057void QGraphicsAnchorLayoutPrivate::restoreVertices(Orientation orientation)-
1058{-
1059 QGraphicsAnchorLayout * const q = q_func();-
1060-
1061 Graph<AnchorVertex, AnchorData> &g = graph[orientation];-
1062 QList<AnchorVertexPair *> &toRestore = simplifiedVertices[orientation];-
1063 QList<AnchorData *> &parallelAnchors = anchorsFromSimplifiedVertices[orientation];-
1064-
1065 for (int i = parallelAnchors.count() - 1; i >= 0
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
; --i) {
0
1066 ParallelAnchorData *parallel = static_cast<ParallelAnchorData *>(parallelAnchors.at(i));-
1067 restoreSimplifiedConstraints(parallel);-
1068 }
never executed: end of block
0
1069-
1070-
1071-
1072 for (int i = toRestore.count() - 1; i >= 0
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
; --i) {
0
1073 AnchorVertexPair *pair = toRestore.at(i);-
1074 QList<AnchorVertex *> adjacents = g.adjacentVertices(pair);-
1075-
1076-
1077-
1078 AnchorVertex *first = pair->m_first;-
1079 AnchorVertex *second = pair->m_second;-
1080 g.createEdge(first, second, pair->m_removedAnchor);-
1081-
1082-
1083 for (int j = 0; j < pair->m_firstAnchors.count()
j < pair->m_fi...nchors.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++j) {
0
1084 AnchorData *ad = pair->m_firstAnchors.at(j);-
1085 ((!(ad->from == pair || ad->to == pair)) ? qt_assert("ad->from == pair || ad->to == pair",__FILE__,1326) : qt_noop());-
1086-
1087 replaceVertex_helper(ad, pair, first);-
1088 g.createEdge(ad->from, ad->to, ad);-
1089 }
never executed: end of block
0
1090-
1091-
1092 for (int j = 0; j < pair->m_secondAnchors.count()
j < pair->m_se...nchors.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++j) {
0
1093 AnchorData *ad = pair->m_secondAnchors.at(j);-
1094 ((!(ad->from == pair || ad->to == pair)) ? qt_assert("ad->from == pair || ad->to == pair",__FILE__,1335) : qt_noop());-
1095-
1096 replaceVertex_helper(ad, pair, second);-
1097 g.createEdge(ad->from, ad->to, ad);-
1098 }
never executed: end of block
0
1099-
1100 for (int j = 0; j < adjacents.count()
j < adjacents.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++j) {
0
1101 g.takeEdge(pair, adjacents.at(j));-
1102 }
never executed: end of block
0
1103-
1104-
1105-
1106 if (pair->m_item == q
pair->m_item == qDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1107 AnchorVertex *layoutVertex = first->m_item == q
first->m_item == qDescription
TRUEnever evaluated
FALSEnever evaluated
? first : second;
0
1108 ((!(layoutVertex->m_item == q)) ? qt_assert("layoutVertex->m_item == q",__FILE__,1349) : qt_noop());-
1109 changeLayoutVertex(orientation, pair, layoutVertex);-
1110 }
never executed: end of block
0
1111-
1112 delete pair;-
1113 }
never executed: end of block
0
1114 qDeleteAll(parallelAnchors);-
1115 parallelAnchors.clear();-
1116 toRestore.clear();-
1117}
never executed: end of block
0
1118-
1119QGraphicsAnchorLayoutPrivate::Orientation-
1120QGraphicsAnchorLayoutPrivate::edgeOrientation(Qt::AnchorPoint edge)-
1121{-
1122 return
never executed: return edge > Qt::AnchorRight ? Vertical : Horizontal;
edge > Qt::AnchorRight ? Vertical : Horizontal;
never executed: return edge > Qt::AnchorRight ? Vertical : Horizontal;
0
1123}-
1124void QGraphicsAnchorLayoutPrivate::createLayoutEdges()-
1125{-
1126 QGraphicsAnchorLayout * const q = q_func();-
1127 QGraphicsLayoutItem *layout = q;-
1128-
1129-
1130 AnchorData *data = new AnchorData;-
1131 addAnchor_helper(layout, Qt::AnchorLeft, layout,-
1132 Qt::AnchorRight, data);-
1133 data->maxSize = ((1<<24)-1);-
1134-
1135-
1136 layoutFirstVertex[Horizontal] = internalVertex(layout, Qt::AnchorLeft);-
1137 layoutCentralVertex[Horizontal] = 0;-
1138 layoutLastVertex[Horizontal] = internalVertex(layout, Qt::AnchorRight);-
1139-
1140-
1141 data = new AnchorData;-
1142 addAnchor_helper(layout, Qt::AnchorTop, layout,-
1143 Qt::AnchorBottom, data);-
1144 data->maxSize = ((1<<24)-1);-
1145-
1146-
1147 layoutFirstVertex[Vertical] = internalVertex(layout, Qt::AnchorTop);-
1148 layoutCentralVertex[Vertical] = 0;-
1149 layoutLastVertex[Vertical] = internalVertex(layout, Qt::AnchorBottom);-
1150}
never executed: end of block
0
1151-
1152void QGraphicsAnchorLayoutPrivate::deleteLayoutEdges()-
1153{-
1154 QGraphicsAnchorLayout * const q = q_func();-
1155-
1156 ((!(!internalVertex(q, Qt::AnchorHorizontalCenter))) ? qt_assert("!internalVertex(q, Qt::AnchorHorizontalCenter)",__FILE__,1407) : qt_noop());-
1157 ((!(!internalVertex(q, Qt::AnchorVerticalCenter))) ? qt_assert("!internalVertex(q, Qt::AnchorVerticalCenter)",__FILE__,1408) : qt_noop());-
1158-
1159 removeAnchor_helper(internalVertex(q, Qt::AnchorLeft),-
1160 internalVertex(q, Qt::AnchorRight));-
1161 removeAnchor_helper(internalVertex(q, Qt::AnchorTop),-
1162 internalVertex(q, Qt::AnchorBottom));-
1163}
never executed: end of block
0
1164-
1165void QGraphicsAnchorLayoutPrivate::createItemEdges(QGraphicsLayoutItem *item)-
1166{-
1167 items.append(item);-
1168-
1169-
1170-
1171 AnchorData *data = new AnchorData;-
1172 addAnchor_helper(item, Qt::AnchorLeft, item, Qt::AnchorRight, data);-
1173 data->refreshSizeHints();-
1174-
1175 data = new AnchorData;-
1176 addAnchor_helper(item, Qt::AnchorTop, item, Qt::AnchorBottom, data);-
1177 data->refreshSizeHints();-
1178}
never executed: end of block
0
1179void QGraphicsAnchorLayoutPrivate::createCenterAnchors(-
1180 QGraphicsLayoutItem *item, Qt::AnchorPoint centerEdge)-
1181{-
1182 QGraphicsAnchorLayout * const q = q_func();-
1183-
1184 Orientation orientation;-
1185 switch (centerEdge) {-
1186 case
never executed: case Qt::AnchorHorizontalCenter:
Qt::AnchorHorizontalCenter:
never executed: case Qt::AnchorHorizontalCenter:
0
1187 orientation = Horizontal;-
1188 break;
never executed: break;
0
1189 case
never executed: case Qt::AnchorVerticalCenter:
Qt::AnchorVerticalCenter:
never executed: case Qt::AnchorVerticalCenter:
0
1190 orientation = Vertical;-
1191 break;
never executed: break;
0
1192 default
never executed: default:
:
never executed: default:
0
1193-
1194 return;
never executed: return;
0
1195 }-
1196-
1197-
1198 if (internalVertex(item, centerEdge)
internalVertex...m, centerEdge)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1199 return;
never executed: return;
0
1200-
1201-
1202 Qt::AnchorPoint firstEdge;-
1203 Qt::AnchorPoint lastEdge;-
1204-
1205 if (orientation == Horizontal
orientation == HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1206 firstEdge = Qt::AnchorLeft;-
1207 lastEdge = Qt::AnchorRight;-
1208 }
never executed: end of block
else {
0
1209 firstEdge = Qt::AnchorTop;-
1210 lastEdge = Qt::AnchorBottom;-
1211 }
never executed: end of block
0
1212-
1213 AnchorVertex *first = internalVertex(item, firstEdge);-
1214 AnchorVertex *last = internalVertex(item, lastEdge);-
1215 ((!(first && last)) ? qt_assert("first && last",__FILE__,1478) : qt_noop());-
1216-
1217-
1218 QSimplexConstraint *c = new QSimplexConstraint;-
1219-
1220 AnchorData *data = new AnchorData;-
1221 c->variables.insert(data, 1.0);-
1222 addAnchor_helper(item, firstEdge, item, centerEdge, data);-
1223 data->isCenterAnchor = true;-
1224 data->dependency = AnchorData::Master;-
1225 data->refreshSizeHints();-
1226-
1227 data = new AnchorData;-
1228 c->variables.insert(data, -1.0);-
1229 addAnchor_helper(item, centerEdge, item, lastEdge, data);-
1230 data->isCenterAnchor = true;-
1231 data->dependency = AnchorData::Slave;-
1232 data->refreshSizeHints();-
1233-
1234 itemCenterConstraints[orientation].append(c);-
1235-
1236-
1237 removeAnchor_helper(first, last);-
1238-
1239 if (item == q
item == qDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1240 layoutCentralVertex[orientation] = internalVertex(q, centerEdge);-
1241 }
never executed: end of block
0
1242}
never executed: end of block
0
1243-
1244void QGraphicsAnchorLayoutPrivate::removeCenterAnchors(-
1245 QGraphicsLayoutItem *item, Qt::AnchorPoint centerEdge,-
1246 bool substitute)-
1247{-
1248 QGraphicsAnchorLayout * const q = q_func();-
1249-
1250 Orientation orientation;-
1251 switch (centerEdge) {-
1252 case
never executed: case Qt::AnchorHorizontalCenter:
Qt::AnchorHorizontalCenter:
never executed: case Qt::AnchorHorizontalCenter:
0
1253 orientation = Horizontal;-
1254 break;
never executed: break;
0
1255 case
never executed: case Qt::AnchorVerticalCenter:
Qt::AnchorVerticalCenter:
never executed: case Qt::AnchorVerticalCenter:
0
1256 orientation = Vertical;-
1257 break;
never executed: break;
0
1258 default
never executed: default:
:
never executed: default:
0
1259-
1260 return;
never executed: return;
0
1261 }-
1262-
1263-
1264 Qt::AnchorPoint firstEdge;-
1265 Qt::AnchorPoint lastEdge;-
1266-
1267 if (orientation == Horizontal
orientation == HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1268 firstEdge = Qt::AnchorLeft;-
1269 lastEdge = Qt::AnchorRight;-
1270 }
never executed: end of block
else {
0
1271 firstEdge = Qt::AnchorTop;-
1272 lastEdge = Qt::AnchorBottom;-
1273 }
never executed: end of block
0
1274-
1275 AnchorVertex *center = internalVertex(item, centerEdge);-
1276 if (!center
!centerDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1277 return;
never executed: return;
0
1278 AnchorVertex *first = internalVertex(item, firstEdge);-
1279-
1280 ((!(first)) ? qt_assert("first",__FILE__,1543) : qt_noop());-
1281 ((!(center)) ? qt_assert("center",__FILE__,1544) : qt_noop());-
1282-
1283 Graph<AnchorVertex, AnchorData> &g = graph[orientation];-
1284-
1285-
1286 AnchorData *oldData = g.edgeData(first, center);-
1287-
1288 for (int i = itemCenterConstraints[orientation].count() - 1; i >= 0
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
; --i) {
0
1289 if (itemCenterConstraints[orientation].at(i)->variables.contains(oldData)
itemCenterCons...tains(oldData)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1290 delete itemCenterConstraints[orientation].takeAt(i);-
1291 break;
never executed: break;
0
1292 }-
1293 }
never executed: end of block
0
1294-
1295 if (substitute
substituteDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1296-
1297 AnchorData *data = new AnchorData;-
1298 addAnchor_helper(item, firstEdge, item, lastEdge, data);-
1299 data->refreshSizeHints();-
1300-
1301-
1302 removeAnchor_helper(first, center);-
1303 removeAnchor_helper(center, internalVertex(item, lastEdge));-
1304-
1305 }
never executed: end of block
else {
0
1306-
1307-
1308 QList<AnchorVertex*> adjacents = g.adjacentVertices(center);-
1309 for (int i = 0; i < adjacents.count()
i < adjacents.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1310 AnchorVertex *v = adjacents.at(i);-
1311 if (v->m_item != item
v->m_item != itemDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1312 removeAnchor_helper(center, internalVertex(v->m_item, v->m_edge));-
1313 }
never executed: end of block
0
1314 }
never executed: end of block
0
1315-
1316-
1317-
1318 removeAnchor_helper(first, internalVertex(item, lastEdge));-
1319 }
never executed: end of block
0
1320-
1321 if (item == q
item == qDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1322 layoutCentralVertex[orientation] = 0;-
1323 }
never executed: end of block
0
1324}
never executed: end of block
0
1325-
1326-
1327void QGraphicsAnchorLayoutPrivate::removeCenterConstraints(QGraphicsLayoutItem *item,-
1328 Orientation orientation)-
1329{-
1330-
1331-
1332-
1333-
1334-
1335 AnchorVertex *first = internalVertex(item, orientation == Horizontal ?-
1336 Qt::AnchorLeft :-
1337 Qt::AnchorTop);-
1338 AnchorVertex *center = internalVertex(item, orientation == Horizontal ?-
1339 Qt::AnchorHorizontalCenter :-
1340 Qt::AnchorVerticalCenter);-
1341-
1342-
1343 if (!center
!centerDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1344 return;
never executed: return;
0
1345-
1346 ((!(first)) ? qt_assert("first",__FILE__,1609) : qt_noop());-
1347 AnchorData *internalAnchor = graph[orientation].edgeData(first, center);-
1348-
1349-
1350 for (int i = 0; i < itemCenterConstraints[orientation].size()
i < itemCenter...tation].size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1351 if (itemCenterConstraints[orientation].at(i)->variables.contains(internalAnchor)
itemCenterCons...nternalAnchor)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1352 delete itemCenterConstraints[orientation].takeAt(i);-
1353 break;
never executed: break;
0
1354 }-
1355 }
never executed: end of block
0
1356}
never executed: end of block
0
1357QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::addAnchor(QGraphicsLayoutItem *firstItem,-
1358 Qt::AnchorPoint firstEdge,-
1359 QGraphicsLayoutItem *secondItem,-
1360 Qt::AnchorPoint secondEdge,-
1361 qreal *spacing)-
1362{-
1363 QGraphicsAnchorLayout * const q = q_func();-
1364 if ((
(firstItem == 0)Description
TRUEnever evaluated
FALSEnever evaluated
firstItem == 0)
(firstItem == 0)Description
TRUEnever evaluated
FALSEnever evaluated
|| (
(secondItem == 0)Description
TRUEnever evaluated
FALSEnever evaluated
secondItem == 0)
(secondItem == 0)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1365 QMessageLogger(__FILE__, 1641, __PRETTY_FUNCTION__).warning("QGraphicsAnchorLayout::addAnchor(): "-
1366 "Cannot anchor NULL items");-
1367 return
never executed: return 0;
0;
never executed: return 0;
0
1368 }-
1369-
1370 if (firstItem == secondItem
firstItem == secondItemDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1371 QMessageLogger(__FILE__, 1647, __PRETTY_FUNCTION__).warning("QGraphicsAnchorLayout::addAnchor(): "-
1372 "Cannot anchor the item to itself");-
1373 return
never executed: return 0;
0;
never executed: return 0;
0
1374 }-
1375-
1376 if (edgeOrientation(secondEdge) != edgeOrientation(firstEdge)
edgeOrientatio...ion(firstEdge)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1377 QMessageLogger(__FILE__, 1653, __PRETTY_FUNCTION__).warning("QGraphicsAnchorLayout::addAnchor(): "-
1378 "Cannot anchor edges of different orientations");-
1379 return
never executed: return 0;
0;
never executed: return 0;
0
1380 }-
1381-
1382 const QGraphicsLayoutItem *parentWidget = q->parentLayoutItem();-
1383 if (firstItem == parentWidget
firstItem == parentWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
|| secondItem == parentWidget
secondItem == parentWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1384 QMessageLogger(__FILE__, 1660, __PRETTY_FUNCTION__).warning("QGraphicsAnchorLayout::addAnchor(): "-
1385 "You cannot add the parent of the layout to the layout.");-
1386 return
never executed: return 0;
0;
never executed: return 0;
0
1387 }-
1388 if (firstItem != q
firstItem != qDescription
TRUEnever evaluated
FALSEnever evaluated
&& !items.contains(firstItem)
!items.contains(firstItem)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1389 createItemEdges(firstItem);-
1390 addChildLayoutItem(firstItem);-
1391 }
never executed: end of block
0
1392 if (secondItem != q
secondItem != qDescription
TRUEnever evaluated
FALSEnever evaluated
&& !items.contains(secondItem)
!items.contains(secondItem)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1393 createItemEdges(secondItem);-
1394 addChildLayoutItem(secondItem);-
1395 }
never executed: end of block
0
1396-
1397-
1398 createCenterAnchors(firstItem, firstEdge);-
1399 createCenterAnchors(secondItem, secondEdge);-
1400-
1401-
1402 correctEdgeDirection(firstItem, firstEdge, secondItem, secondEdge);-
1403-
1404 AnchorData *data = new AnchorData;-
1405 QGraphicsAnchor *graphicsAnchor = acquireGraphicsAnchor(data);-
1406-
1407 addAnchor_helper(firstItem, firstEdge, secondItem, secondEdge, data);-
1408-
1409 if (spacing
spacingDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1410 graphicsAnchor->setSpacing(*spacing);-
1411 }
never executed: end of block
else {
0
1412 if (firstItem == q
firstItem == qDescription
TRUEnever evaluated
FALSEnever evaluated
0
1413 || secondItem == q
secondItem == qDescription
TRUEnever evaluated
FALSEnever evaluated
0
1414 || pickEdge(firstEdge, Horizontal) == Qt::AnchorHorizontalCenter
pickEdge(first...rizontalCenterDescription
TRUEnever evaluated
FALSEnever evaluated
0
1415 || oppositeEdge(firstEdge) != secondEdge
oppositeEdge(f... != secondEdgeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1416 graphicsAnchor->setSpacing(0);-
1417 }
never executed: end of block
else {
0
1418 graphicsAnchor->unsetSpacing();-
1419 }
never executed: end of block
0
1420 }-
1421-
1422 return
never executed: return graphicsAnchor;
graphicsAnchor;
never executed: return graphicsAnchor;
0
1423}-
1424void QGraphicsAnchorLayoutPrivate::addAnchor_helper(QGraphicsLayoutItem *firstItem,-
1425 Qt::AnchorPoint firstEdge,-
1426 QGraphicsLayoutItem *secondItem,-
1427 Qt::AnchorPoint secondEdge,-
1428 AnchorData *data)-
1429{-
1430 QGraphicsAnchorLayout * const q = q_func();-
1431-
1432 const Orientation orientation = edgeOrientation(firstEdge);-
1433-
1434-
1435 AnchorVertex *v1 = addInternalVertex(firstItem, firstEdge);-
1436 AnchorVertex *v2 = addInternalVertex(secondItem, secondEdge);-
1437-
1438-
1439 if (graph[orientation].edgeData(v1, v2)
graph[orientat...geData(v1, v2)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1440 removeAnchor_helper(v1, v2);-
1441 }
never executed: end of block
0
1442-
1443-
1444 if (firstItem == secondItem
firstItem == secondItemDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1445 data->item = firstItem;
never executed: data->item = firstItem;
0
1446-
1447 data->orientation = orientation;-
1448-
1449-
1450-
1451-
1452 data->from = v1;-
1453 data->to = v2;-
1454-
1455 data->name = QString::fromLatin1("%1 --to--> %2").arg(v1->toString()).arg(v2->toString());-
1456-
1457-
1458-
1459 data->isLayoutAnchor = (data->item == q);-
1460-
1461 graph[orientation].createEdge(v1, v2, data);-
1462}
never executed: end of block
0
1463-
1464QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::getAnchor(QGraphicsLayoutItem *firstItem,-
1465 Qt::AnchorPoint firstEdge,-
1466 QGraphicsLayoutItem *secondItem,-
1467 Qt::AnchorPoint secondEdge)-
1468{-
1469-
1470 if (firstItem == secondItem
firstItem == secondItemDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1471 return
never executed: return 0;
0;
never executed: return 0;
0
1472-
1473 const Orientation orientation = edgeOrientation(firstEdge);-
1474 AnchorVertex *v1 = internalVertex(firstItem, firstEdge);-
1475 AnchorVertex *v2 = internalVertex(secondItem, secondEdge);-
1476-
1477 QGraphicsAnchor *graphicsAnchor = 0;-
1478-
1479 AnchorData *data = graph[orientation].edgeData(v1, v2);-
1480 if (data
dataDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1481-
1482-
1483-
1484-
1485-
1486-
1487 ((!(data->graphicsAnchor)) ? qt_assert("data->graphicsAnchor",__FILE__,1790) : qt_noop());-
1488 graphicsAnchor = data->graphicsAnchor;-
1489 }
never executed: end of block
0
1490 return
never executed: return graphicsAnchor;
graphicsAnchor;
never executed: return graphicsAnchor;
0
1491}-
1492-
1493-
1494-
1495-
1496-
1497-
1498-
1499void QGraphicsAnchorLayoutPrivate::removeAnchor(AnchorVertex *firstVertex,-
1500 AnchorVertex *secondVertex)-
1501{-
1502 QGraphicsAnchorLayout * const q = q_func();-
1503-
1504-
1505 QGraphicsLayoutItem *firstItem = firstVertex->m_item;-
1506 QGraphicsLayoutItem *secondItem = secondVertex->m_item;-
1507-
1508-
1509 removeAnchor_helper(firstVertex, secondVertex);-
1510-
1511-
1512 firstVertex = secondVertex = 0;-
1513-
1514-
1515 bool keepFirstItem = false;-
1516 bool keepSecondItem = false;-
1517-
1518 QPair<AnchorVertex *, int> v;-
1519 int refcount = -1;-
1520-
1521 if (firstItem != q
firstItem != qDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1522 for (int i = Qt::AnchorLeft; i <= Qt::AnchorBottom
i <= Qt::AnchorBottomDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1523 v = m_vertexList.value(qMakePair(firstItem, static_cast<Qt::AnchorPoint>(i)));-
1524 if (v.first
v.firstDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1525 if (i == Qt::AnchorHorizontalCenter
i == Qt::Ancho...rizontalCenterDescription
TRUEnever evaluated
FALSEnever evaluated
|| i == Qt::AnchorVerticalCenter
i == Qt::AnchorVerticalCenterDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1526 refcount = 2;
never executed: refcount = 2;
0
1527 else-
1528 refcount = 1;
never executed: refcount = 1;
0
1529-
1530 if (v.second > refcount
v.second > refcountDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1531 keepFirstItem = true;-
1532 break;
never executed: break;
0
1533 }-
1534 }
never executed: end of block
0
1535 }
never executed: end of block
0
1536 }
never executed: end of block
else
0
1537 keepFirstItem = true;
never executed: keepFirstItem = true;
0
1538-
1539 if (secondItem != q
secondItem != qDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1540 for (int i = Qt::AnchorLeft; i <= Qt::AnchorBottom
i <= Qt::AnchorBottomDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1541 v = m_vertexList.value(qMakePair(secondItem, static_cast<Qt::AnchorPoint>(i)));-
1542 if (v.first
v.firstDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1543 if (i == Qt::AnchorHorizontalCenter
i == Qt::Ancho...rizontalCenterDescription
TRUEnever evaluated
FALSEnever evaluated
|| i == Qt::AnchorVerticalCenter
i == Qt::AnchorVerticalCenterDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1544 refcount = 2;
never executed: refcount = 2;
0
1545 else-
1546 refcount = 1;
never executed: refcount = 1;
0
1547-
1548 if (v.second > refcount
v.second > refcountDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1549 keepSecondItem = true;-
1550 break;
never executed: break;
0
1551 }-
1552 }
never executed: end of block
0
1553 }
never executed: end of block
0
1554 }
never executed: end of block
else
0
1555 keepSecondItem = true;
never executed: keepSecondItem = true;
0
1556-
1557 if (!keepFirstItem
!keepFirstItemDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1558 q->removeAt(items.indexOf(firstItem));
never executed: q->removeAt(items.indexOf(firstItem));
0
1559-
1560 if (!keepSecondItem
!keepSecondItemDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1561 q->removeAt(items.indexOf(secondItem));
never executed: q->removeAt(items.indexOf(secondItem));
0
1562-
1563-
1564 q->invalidate();-
1565}
never executed: end of block
0
1566-
1567-
1568-
1569-
1570-
1571-
1572-
1573void QGraphicsAnchorLayoutPrivate::removeAnchor_helper(AnchorVertex *v1, AnchorVertex *v2)-
1574{-
1575 ((!(v1 && v2)) ? qt_assert("v1 && v2",__FILE__,1878) : qt_noop());-
1576-
1577-
1578 const Orientation o = edgeOrientation(v1->m_edge);-
1579 graph[o].removeEdge(v1, v2);-
1580-
1581-
1582 removeInternalVertex(v1->m_item, v1->m_edge);-
1583 removeInternalVertex(v2->m_item, v2->m_edge);-
1584}
never executed: end of block
0
1585-
1586AnchorVertex *QGraphicsAnchorLayoutPrivate::addInternalVertex(QGraphicsLayoutItem *item,-
1587 Qt::AnchorPoint edge)-
1588{-
1589 QPair<QGraphicsLayoutItem *, Qt::AnchorPoint> pair(item, edge);-
1590 QPair<AnchorVertex *, int> v = m_vertexList.value(pair);-
1591-
1592 if (!v.first
!v.firstDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1593 ((!(v.second == 0)) ? qt_assert("v.second == 0",__FILE__,1896) : qt_noop());-
1594 v.first = new AnchorVertex(item, edge);-
1595 }
never executed: end of block
0
1596 v.second++;-
1597 m_vertexList.insert(pair, v);-
1598 return
never executed: return v.first;
v.first;
never executed: return v.first;
0
1599}-
1600-
1601-
1602-
1603-
1604-
1605-
1606-
1607void QGraphicsAnchorLayoutPrivate::removeInternalVertex(QGraphicsLayoutItem *item,-
1608 Qt::AnchorPoint edge)-
1609{-
1610 QPair<QGraphicsLayoutItem *, Qt::AnchorPoint> pair(item, edge);-
1611 QPair<AnchorVertex *, int> v = m_vertexList.value(pair);-
1612-
1613 if (!v.first
!v.firstDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1614 QMessageLogger(__FILE__, 1917, __PRETTY_FUNCTION__).warning("This item with this edge is not in the graph");-
1615 return;
never executed: return;
0
1616 }-
1617-
1618 v.second--;-
1619 if (v.second == 0
v.second == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1620-
1621 m_vertexList.remove(pair);-
1622 delete v.first;-
1623 }
never executed: end of block
else {
0
1624-
1625 m_vertexList.insert(pair, v);-
1626-
1627 if ((
(v.second == 2)Description
TRUEnever evaluated
FALSEnever evaluated
v.second == 2)
(v.second == 2)Description
TRUEnever evaluated
FALSEnever evaluated
&&
0
1628 ((
(edge == Qt::A...izontalCenter)Description
TRUEnever evaluated
FALSEnever evaluated
edge == Qt::AnchorHorizontalCenter)
(edge == Qt::A...izontalCenter)Description
TRUEnever evaluated
FALSEnever evaluated
||
0
1629 (
(edge == Qt::A...erticalCenter)Description
TRUEnever evaluated
FALSEnever evaluated
edge == Qt::AnchorVerticalCenter)
(edge == Qt::A...erticalCenter)Description
TRUEnever evaluated
FALSEnever evaluated
)) {
0
1630 removeCenterAnchors(item, edge, true);-
1631 }
never executed: end of block
0
1632 }
never executed: end of block
0
1633}-
1634-
1635void QGraphicsAnchorLayoutPrivate::removeVertex(QGraphicsLayoutItem *item, Qt::AnchorPoint edge)-
1636{-
1637 if (AnchorVertex *v = internalVertex(item, edge)
AnchorVertex *...ex(item, edge)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1638 Graph<AnchorVertex, AnchorData> &g = graph[edgeOrientation(edge)];-
1639 const QList<AnchorVertex *> allVertices = graph[edgeOrientation(edge)].adjacentVertices(v);-
1640 for (auto *v2 : allVertices) {-
1641 g.removeEdge(v, v2);-
1642 removeInternalVertex(item, edge);-
1643 removeInternalVertex(v2->m_item, v2->m_edge);-
1644 }
never executed: end of block
0
1645 }
never executed: end of block
0
1646}
never executed: end of block
0
1647-
1648void QGraphicsAnchorLayoutPrivate::removeAnchors(QGraphicsLayoutItem *item)-
1649{-
1650-
1651 removeCenterAnchors(item, Qt::AnchorHorizontalCenter, false);-
1652 removeVertex(item, Qt::AnchorLeft);-
1653 removeVertex(item, Qt::AnchorRight);-
1654-
1655 removeCenterAnchors(item, Qt::AnchorVerticalCenter, false);-
1656 removeVertex(item, Qt::AnchorTop);-
1657 removeVertex(item, Qt::AnchorBottom);-
1658}
never executed: end of block
0
1659void QGraphicsAnchorLayoutPrivate::correctEdgeDirection(QGraphicsLayoutItem *&firstItem,-
1660 Qt::AnchorPoint &firstEdge,-
1661 QGraphicsLayoutItem *&secondItem,-
1662 Qt::AnchorPoint &secondEdge)-
1663{-
1664 QGraphicsAnchorLayout * const q = q_func();-
1665-
1666 if ((
(firstItem != q)Description
TRUEnever evaluated
FALSEnever evaluated
firstItem != q)
(firstItem != q)Description
TRUEnever evaluated
FALSEnever evaluated
&& (
(secondItem != q)Description
TRUEnever evaluated
FALSEnever evaluated
secondItem != q)
(secondItem != q)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1667-
1668-
1669 if (firstEdge < secondEdge
firstEdge < secondEdgeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1670 qSwap(firstItem, secondItem);-
1671 qSwap(firstEdge, secondEdge);-
1672 }
never executed: end of block
0
1673 }
never executed: end of block
else if (firstItem == q
firstItem == qDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1674-
1675-
1676 if ((
(firstEdge == Qt::AnchorRight)Description
TRUEnever evaluated
FALSEnever evaluated
firstEdge == Qt::AnchorRight)
(firstEdge == Qt::AnchorRight)Description
TRUEnever evaluated
FALSEnever evaluated
|| (
(firstEdge == ...:AnchorBottom)Description
TRUEnever evaluated
FALSEnever evaluated
firstEdge == Qt::AnchorBottom)
(firstEdge == ...:AnchorBottom)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1677 qSwap(firstItem, secondItem);-
1678 qSwap(firstEdge, secondEdge);-
1679 }
never executed: end of block
0
1680 }
never executed: end of block
else if ((
(secondEdge !=...::AnchorRight)Description
TRUEnever evaluated
FALSEnever evaluated
secondEdge != Qt::AnchorRight)
(secondEdge !=...::AnchorRight)Description
TRUEnever evaluated
FALSEnever evaluated
&& (
(secondEdge !=...:AnchorBottom)Description
TRUEnever evaluated
FALSEnever evaluated
secondEdge != Qt::AnchorBottom)
(secondEdge !=...:AnchorBottom)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1681-
1682-
1683 qSwap(firstItem, secondItem);-
1684 qSwap(firstEdge, secondEdge);-
1685 }
never executed: end of block
0
1686}
never executed: end of block
0
1687-
1688QLayoutStyleInfo &QGraphicsAnchorLayoutPrivate::styleInfo() const-
1689{-
1690 if (styleInfoDirty
styleInfoDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1691 const QGraphicsAnchorLayout * const q = q_func();-
1692-
1693 QWidget *wid = 0;-
1694-
1695 QGraphicsLayoutItem *parent = q->parentLayoutItem();-
1696 while (parent
parentDescription
TRUEnever evaluated
FALSEnever evaluated
&& parent->isLayout()
parent->isLayout()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1697 parent = parent->parentLayoutItem();-
1698 }
never executed: end of block
0
1699 QGraphicsWidget *w = 0;-
1700 if (parent
parentDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1701 QGraphicsItem *parentItem = parent->graphicsItem();-
1702 if (parentItem
parentItemDescription
TRUEnever evaluated
FALSEnever evaluated
&& parentItem->isWidget()
parentItem->isWidget()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1703 w = static_cast<QGraphicsWidget*>(parentItem);
never executed: w = static_cast<QGraphicsWidget*>(parentItem);
0
1704 }
never executed: end of block
0
1705-
1706 QStyle *style = w
wDescription
TRUEnever evaluated
FALSEnever evaluated
? w->style() : QApplication::style();
0
1707 cachedStyleInfo = QLayoutStyleInfo(style, wid);-
1708 cachedStyleInfo.setDefaultSpacing(Qt::Horizontal, spacings[0]);-
1709 cachedStyleInfo.setDefaultSpacing(Qt::Vertical, spacings[1]);-
1710-
1711 styleInfoDirty = false;-
1712 }
never executed: end of block
0
1713 return
never executed: return cachedStyleInfo;
cachedStyleInfo;
never executed: return cachedStyleInfo;
0
1714}-
1715void QGraphicsAnchorLayoutPrivate::calculateGraphs()-
1716{-
1717 if (!calculateGraphCacheDirty
!calculateGraphCacheDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1718 return;
never executed: return;
0
1719 calculateGraphs(Horizontal);-
1720 calculateGraphs(Vertical);-
1721 calculateGraphCacheDirty = false;-
1722}
never executed: end of block
0
1723-
1724-
1725-
1726QList<AnchorData *> getVariables(const QList<QSimplexConstraint *> &constraints)-
1727{-
1728 QSet<AnchorData *> variableSet;-
1729 for (int i = 0; i < constraints.count()
i < constraints.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1730 const QSimplexConstraint *c = constraints.at(i);-
1731 for (auto it = c->variables.cbegin(), end = c->variables.cend(); it != end
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++it)
0
1732 variableSet.insert(static_cast<AnchorData *>(it.key()));
never executed: variableSet.insert(static_cast<AnchorData *>(it.key()));
0
1733 }
never executed: end of block
0
1734 return
never executed: return variableSet.toList();
variableSet.toList();
never executed: return variableSet.toList();
0
1735}-
1736void QGraphicsAnchorLayoutPrivate::calculateGraphs(-
1737 QGraphicsAnchorLayoutPrivate::Orientation orientation)-
1738{-
1739-
1740 lastCalculationUsedSimplex[orientation] = false;-
1741-
1742-
1743 static bool simplificationEnabled = qEnvironmentVariableIsEmpty("QT_ANCHORLAYOUT_NO_SIMPLIFICATION");-
1744-
1745-
1746 refreshAllSizeHints(orientation);-
1747-
1748-
1749 if (simplificationEnabled
simplificationEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
&& !simplifyGraph(orientation)
!simplifyGraph(orientation)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1750 QMessageLogger(__FILE__, 2110, __PRETTY_FUNCTION__).warning("QGraphicsAnchorLayout: anchor setup is not feasible.");-
1751 graphHasConflicts[orientation] = true;-
1752 return;
never executed: return;
0
1753 }-
1754-
1755-
1756 findPaths(orientation);-
1757-
1758-
1759-
1760 constraintsFromPaths(orientation);-
1761 const auto parts = getGraphParts(orientation);-
1762-
1763-
1764-
1765-
1766 const QList<AnchorData *> trunkVariables = getVariables(parts.trunkConstraints);-
1767-
1768-
1769-
1770 AnchorVertex *v = layoutLastVertex[orientation];-
1771 GraphPath trunkPath = graphPaths[orientation].value(v);-
1772-
1773 bool feasible = calculateTrunk(orientation, trunkPath, parts.trunkConstraints, trunkVariables);-
1774-
1775-
1776-
1777-
1778-
1779 if (feasible
feasibleDescription
TRUEnever evaluated
FALSEnever evaluated
&& !parts.nonTrunkConstraints.isEmpty()
!parts.nonTrun...ints.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1780 const QList<AnchorData *> partVariables = getVariables(parts.nonTrunkConstraints);-
1781 ((!(!partVariables.isEmpty())) ? qt_assert("!partVariables.isEmpty()",__FILE__,2152) : qt_noop());-
1782 feasible = calculateNonTrunk(parts.nonTrunkConstraints, partVariables);-
1783 }
never executed: end of block
0
1784-
1785-
1786-
1787 updateAnchorSizes(orientation);-
1788-
1789 graphHasConflicts[orientation] = !feasible;-
1790-
1791-
1792-
1793 qDeleteAll(constraints[orientation]);-
1794 constraints[orientation].clear();-
1795 graphPaths[orientation].clear();-
1796-
1797 if (simplificationEnabled
simplificationEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1798 restoreSimplifiedGraph(orientation);
never executed: restoreSimplifiedGraph(orientation);
0
1799}
never executed: end of block
0
1800static void shiftConstraints(const QList<QSimplexConstraint *> &constraints, qreal amount)-
1801{-
1802 for (int i = 0; i < constraints.count()
i < constraints.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1803 QSimplexConstraint *c = constraints.at(i);-
1804 const qreal multiplier = std::accumulate(c->variables.cbegin(), c->variables.cend(), qreal(0));-
1805 c->constant += multiplier * amount;-
1806 }
never executed: end of block
0
1807}
never executed: end of block
0
1808-
1809-
1810-
1811-
1812-
1813-
1814-
1815bool QGraphicsAnchorLayoutPrivate::calculateTrunk(Orientation orientation, const GraphPath &path,-
1816 const QList<QSimplexConstraint *> &constraints,-
1817 const QList<AnchorData *> &variables)-
1818{-
1819 bool feasible = true;-
1820 bool needsSimplex = !constraints.isEmpty();-
1821-
1822-
1823-
1824-
1825-
1826-
1827 if (needsSimplex
needsSimplexDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1828-
1829 QList<QSimplexConstraint *> sizeHintConstraints = constraintsFromSizeHints(variables);-
1830 QList<QSimplexConstraint *> allConstraints = constraints + sizeHintConstraints;-
1831-
1832 shiftConstraints(allConstraints, g_offset);-
1833-
1834-
1835 qreal min, max;-
1836 feasible = solveMinMax(allConstraints, path, &min, &max);-
1837-
1838 if (feasible
feasibleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1839 solvePreferred(constraints, variables);-
1840-
1841-
1842-
1843 qreal pref(0.0);-
1844 for (const AnchorData *ad : path.positives)-
1845 pref += ad->sizeAtPreferred;
never executed: pref += ad->sizeAtPreferred;
0
1846 for (const AnchorData *ad : path.negatives)-
1847 pref -= ad->sizeAtPreferred;
never executed: pref -= ad->sizeAtPreferred;
0
1848-
1849 sizeHints[orientation][Qt::MinimumSize] = min;-
1850 sizeHints[orientation][Qt::PreferredSize] = pref;-
1851 sizeHints[orientation][Qt::MaximumSize] = max;-
1852 }
never executed: end of block
0
1853-
1854 qDeleteAll(sizeHintConstraints);-
1855 shiftConstraints(constraints, -g_offset);-
1856-
1857 }
never executed: end of block
else {
0
1858-
1859-
1860 ((!(path.positives.count() == 1)) ? qt_assert("path.positives.count() == 1",__FILE__,2239) : qt_noop());-
1861 ((!(path.negatives.count() == 0)) ? qt_assert("path.negatives.count() == 0",__FILE__,2240) : qt_noop());-
1862-
1863 AnchorData *ad = *path.positives.cbegin();-
1864 ad->sizeAtMinimum = ad->minSize;-
1865 ad->sizeAtPreferred = ad->prefSize;-
1866 ad->sizeAtMaximum = ad->maxSize;-
1867-
1868 sizeHints[orientation][Qt::MinimumSize] = ad->sizeAtMinimum;-
1869 sizeHints[orientation][Qt::PreferredSize] = ad->sizeAtPreferred;-
1870 sizeHints[orientation][Qt::MaximumSize] = ad->sizeAtMaximum;-
1871 }
never executed: end of block
0
1872-
1873-
1874 lastCalculationUsedSimplex[orientation] = needsSimplex;-
1875-
1876-
1877 return
never executed: return feasible;
feasible;
never executed: return feasible;
0
1878}-
1879-
1880-
1881-
1882-
1883bool QGraphicsAnchorLayoutPrivate::calculateNonTrunk(const QList<QSimplexConstraint *> &constraints,-
1884 const QList<AnchorData *> &variables)-
1885{-
1886 shiftConstraints(constraints, g_offset);-
1887 bool feasible = solvePreferred(constraints, variables);-
1888-
1889 if (feasible
feasibleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1890-
1891-
1892 for (int j = 0; j < variables.count()
j < variables.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++j) {
0
1893 AnchorData *ad = variables.at(j);-
1894 ((!(ad)) ? qt_assert("ad",__FILE__,2273) : qt_noop());-
1895 ad->sizeAtMinimum = ad->sizeAtPreferred;-
1896 ad->sizeAtMaximum = ad->sizeAtPreferred;-
1897 }
never executed: end of block
0
1898 }
never executed: end of block
0
1899-
1900 shiftConstraints(constraints, -g_offset);-
1901 return
never executed: return feasible;
feasible;
never executed: return feasible;
0
1902}-
1903-
1904-
1905-
1906-
1907-
1908-
1909-
1910void QGraphicsAnchorLayoutPrivate::refreshAllSizeHints(Orientation orientation)-
1911{-
1912 Graph<AnchorVertex, AnchorData> &g = graph[orientation];-
1913 QVector<QPair<AnchorVertex *, AnchorVertex *> > vertices = g.connections();-
1914-
1915 QLayoutStyleInfo styleInf = styleInfo();-
1916 for (int i = 0; i < vertices.count()
i < vertices.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1917 AnchorData *data = g.edgeData(vertices.at(i).first, vertices.at(i).second);-
1918 data->refreshSizeHints(&styleInf);-
1919 }
never executed: end of block
0
1920}
never executed: end of block
0
1921void QGraphicsAnchorLayoutPrivate::findPaths(Orientation orientation)-
1922{-
1923 QQueue<QPair<AnchorVertex *, AnchorVertex *> > queue;-
1924-
1925 QSet<AnchorData *> visited;-
1926-
1927 AnchorVertex *root = layoutFirstVertex[orientation];-
1928-
1929 graphPaths[orientation].insert(root, GraphPath());-
1930-
1931 const auto adjacentVertices = graph[orientation].adjacentVertices(root);-
1932 for (AnchorVertex *v : adjacentVertices)-
1933 queue.enqueue(qMakePair(root, v));
never executed: queue.enqueue(qMakePair(root, v));
0
1934-
1935 while(!queue.isEmpty()
!queue.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1936 QPair<AnchorVertex *, AnchorVertex *> pair = queue.dequeue();-
1937 AnchorData *edge = graph[orientation].edgeData(pair.first, pair.second);-
1938-
1939 if (visited.contains(edge)
visited.contains(edge)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1940 continue;
never executed: continue;
0
1941-
1942 visited.insert(edge);-
1943 GraphPath current = graphPaths[orientation].value(pair.first);-
1944-
1945 if (edge->from == pair.first
edge->from == pair.firstDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1946 current.positives.insert(edge);
never executed: current.positives.insert(edge);
0
1947 else-
1948 current.negatives.insert(edge);
never executed: current.negatives.insert(edge);
0
1949-
1950 graphPaths[orientation].insert(pair.second, current);-
1951-
1952 const auto adjacentVertices = graph[orientation].adjacentVertices(pair.second);-
1953 for (AnchorVertex *v : adjacentVertices)-
1954 queue.enqueue(qMakePair(pair.second, v));
never executed: queue.enqueue(qMakePair(pair.second, v));
0
1955 }
never executed: end of block
0
1956-
1957-
1958-
1959-
1960 identifyFloatItems(visited, orientation);-
1961}
never executed: end of block
0
1962void QGraphicsAnchorLayoutPrivate::constraintsFromPaths(Orientation orientation)-
1963{-
1964 const auto vertices = graphPaths[orientation].uniqueKeys();-
1965 for (AnchorVertex *vertex : vertices) {-
1966 int valueCount = graphPaths[orientation].count(vertex);-
1967 if (valueCount == 1
valueCount == 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1968 continue;
never executed: continue;
0
1969-
1970 QList<GraphPath> pathsToVertex = graphPaths[orientation].values(vertex);-
1971 for (int i = 1; i < valueCount
i < valueCountDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1972 constraints[orientation] +=-
1973 pathsToVertex[0].constraint(pathsToVertex.at(i));-
1974 }
never executed: end of block
0
1975 }
never executed: end of block
0
1976}
never executed: end of block
0
1977-
1978-
1979-
1980-
1981void QGraphicsAnchorLayoutPrivate::updateAnchorSizes(Orientation orientation)-
1982{-
1983 Graph<AnchorVertex, AnchorData> &g = graph[orientation];-
1984 const QVector<QPair<AnchorVertex *, AnchorVertex *> > &vertices = g.connections();-
1985-
1986 for (int i = 0; i < vertices.count()
i < vertices.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1987 AnchorData *ad = g.edgeData(vertices.at(i).first, vertices.at(i).second);-
1988 ad->updateChildrenSizes();-
1989 }
never executed: end of block
0
1990}
never executed: end of block
0
1991-
1992-
1993-
1994-
1995-
1996-
1997-
1998QList<QSimplexConstraint *> QGraphicsAnchorLayoutPrivate::constraintsFromSizeHints(-
1999 const QList<AnchorData *> &anchors)-
2000{-
2001 if (anchors.isEmpty()
anchors.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2002 return
never executed: return QList<QSimplexConstraint *>();
QList<QSimplexConstraint *>();
never executed: return QList<QSimplexConstraint *>();
0
2003-
2004-
2005-
2006 Orientation orient = Orientation(anchors.first()->orientation);-
2007 AnchorData *layoutEdge = 0;-
2008 if (layoutCentralVertex[orient]
layoutCentralVertex[orient]Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2009 layoutEdge = graph[orient].edgeData(layoutFirstVertex[orient], layoutCentralVertex[orient]);-
2010 }
never executed: end of block
else {
0
2011 layoutEdge = graph[orient].edgeData(layoutFirstVertex[orient], layoutLastVertex[orient]);-
2012 }
never executed: end of block
0
2013-
2014-
2015-
2016-
2017-
2018 const qreal expectedMax = layoutCentralVertex[orient]
layoutCentralVertex[orient]Description
TRUEnever evaluated
FALSEnever evaluated
? ((1<<24)-1) / 2 : ((1<<24)-1);
0
2019 qreal actualMax;-
2020 if (layoutEdge->from == layoutFirstVertex[orient]
layoutEdge->fr...Vertex[orient]Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2021 actualMax = layoutEdge->maxSize;-
2022 }
never executed: end of block
else {
0
2023 actualMax = -layoutEdge->minSize;-
2024 }
never executed: end of block
0
2025 if (actualMax != expectedMax
actualMax != expectedMaxDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2026 layoutEdge = 0;-
2027 }
never executed: end of block
0
2028-
2029-
2030 QList<QSimplexConstraint *> anchorConstraints;-
2031 bool unboundedProblem = true;-
2032 for (int i = 0; i < anchors.size()
i < anchors.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
2033 AnchorData *ad = anchors.at(i);-
2034-
2035-
2036-
2037-
2038 if (ad->dependency == AnchorData::Slave
ad->dependency...horData::SlaveDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2039 continue;
never executed: continue;
0
2040-
2041-
2042-
2043-
2044 qreal boundedMin = qBound(-g_offset, ad->minSize, g_offset);-
2045 qreal boundedMax = qBound(-g_offset, ad->maxSize, g_offset);-
2046-
2047 if ((
(boundedMin == boundedMax)Description
TRUEnever evaluated
FALSEnever evaluated
boundedMin == boundedMax)
(boundedMin == boundedMax)Description
TRUEnever evaluated
FALSEnever evaluated
|| qFuzzyCompare(boundedMin, boundedMax)
qFuzzyCompare(...n, boundedMax)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2048 QSimplexConstraint *c = new QSimplexConstraint;-
2049 c->variables.insert(ad, 1.0);-
2050 c->constant = boundedMin;-
2051 c->ratio = QSimplexConstraint::Equal;-
2052 anchorConstraints += c;-
2053 unboundedProblem = false;-
2054 }
never executed: end of block
else {
0
2055 QSimplexConstraint *c = new QSimplexConstraint;-
2056 c->variables.insert(ad, 1.0);-
2057 c->constant = boundedMin;-
2058 c->ratio = QSimplexConstraint::MoreOrEqual;-
2059 anchorConstraints += c;-
2060-
2061-
2062-
2063-
2064 if (ad == layoutEdge
ad == layoutEdgeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2065 continue;
never executed: continue;
0
2066-
2067 c = new QSimplexConstraint;-
2068 c->variables.insert(ad, 1.0);-
2069 c->constant = boundedMax;-
2070 c->ratio = QSimplexConstraint::LessOrEqual;-
2071 anchorConstraints += c;-
2072 unboundedProblem = false;-
2073 }
never executed: end of block
0
2074 }-
2075-
2076-
2077 if (unboundedProblem
unboundedProblemDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2078 QSimplexConstraint *c = new QSimplexConstraint;-
2079 c->variables.insert(layoutEdge, 1.0);-
2080-
2081 c->constant = g_offset;-
2082 c->ratio = QSimplexConstraint::LessOrEqual;-
2083 anchorConstraints += c;-
2084 }
never executed: end of block
0
2085-
2086 return
never executed: return anchorConstraints;
anchorConstraints;
never executed: return anchorConstraints;
0
2087}-
2088-
2089-
2090-
2091-
2092QGraphicsAnchorLayoutPrivate::GraphParts-
2093QGraphicsAnchorLayoutPrivate::getGraphParts(Orientation orientation)-
2094{-
2095 GraphParts result;-
2096-
2097 ((!(layoutFirstVertex[orientation] && layoutLastVertex[orientation])) ? qt_assert("layoutFirstVertex[orientation] && layoutLastVertex[orientation]",__FILE__,2498) : qt_noop());-
2098-
2099 AnchorData *edgeL1 = 0;-
2100 AnchorData *edgeL2 = 0;-
2101-
2102-
2103-
2104 if (layoutCentralVertex[orientation]
layoutCentralV...x[orientation]Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2105 edgeL1 = graph[orientation].edgeData(layoutFirstVertex[orientation], layoutCentralVertex[orientation]);-
2106 edgeL2 = graph[orientation].edgeData(layoutCentralVertex[orientation], layoutLastVertex[orientation]);-
2107 }
never executed: end of block
else {
0
2108 edgeL1 = graph[orientation].edgeData(layoutFirstVertex[orientation], layoutLastVertex[orientation]);-
2109 }
never executed: end of block
0
2110-