Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||
7 | - | |||||||||||||||||||||||||
8 | - | |||||||||||||||||||||||||
9 | - | |||||||||||||||||||||||||
10 | - | |||||||||||||||||||||||||
11 | - | |||||||||||||||||||||||||
12 | - | |||||||||||||||||||||||||
13 | - | |||||||||||||||||||||||||
14 | - | |||||||||||||||||||||||||
15 | const qreal g_offset = (sizeof(qreal) == sizeof(double)) ? ((1<<24)-1) : ((1<<24)-1) / 32; | - | ||||||||||||||||||||||||
16 | - | |||||||||||||||||||||||||
17 | QGraphicsAnchorPrivate::QGraphicsAnchorPrivate(int version) | - | ||||||||||||||||||||||||
18 | : QObjectPrivate(version), layoutPrivate(0), data(0), | - | ||||||||||||||||||||||||
19 | sizePolicy(QSizePolicy::Fixed), preferredSize(0), | - | ||||||||||||||||||||||||
20 | hasSize(true) | - | ||||||||||||||||||||||||
21 | { | - | ||||||||||||||||||||||||
22 | } never executed: end of block | 0 | ||||||||||||||||||||||||
23 | - | |||||||||||||||||||||||||
24 | QGraphicsAnchorPrivate::~QGraphicsAnchorPrivate() | - | ||||||||||||||||||||||||
25 | { | - | ||||||||||||||||||||||||
26 | if (data
| 0 | ||||||||||||||||||||||||
27 | - | |||||||||||||||||||||||||
28 | - | |||||||||||||||||||||||||
29 | data->graphicsAnchor = 0; | - | ||||||||||||||||||||||||
30 | - | |||||||||||||||||||||||||
31 | layoutPrivate->removeAnchor(data->from, data->to); | - | ||||||||||||||||||||||||
32 | } never executed: end of block | 0 | ||||||||||||||||||||||||
33 | } never executed: end of block | 0 | ||||||||||||||||||||||||
34 | - | |||||||||||||||||||||||||
35 | void QGraphicsAnchorPrivate::setSizePolicy(QSizePolicy::Policy policy) | - | ||||||||||||||||||||||||
36 | { | - | ||||||||||||||||||||||||
37 | if (sizePolicy != policy
| 0 | ||||||||||||||||||||||||
38 | sizePolicy = policy; | - | ||||||||||||||||||||||||
39 | layoutPrivate->q_func()->invalidate(); | - | ||||||||||||||||||||||||
40 | } never executed: end of block | 0 | ||||||||||||||||||||||||
41 | } never executed: end of block | 0 | ||||||||||||||||||||||||
42 | - | |||||||||||||||||||||||||
43 | void QGraphicsAnchorPrivate::setSpacing(qreal value) | - | ||||||||||||||||||||||||
44 | { | - | ||||||||||||||||||||||||
45 | if (!data
| 0 | ||||||||||||||||||||||||
46 | QMessageLogger(__FILE__, 85, __PRETTY_FUNCTION__).warning("QGraphicsAnchor::setSpacing: The anchor does not exist."); | - | ||||||||||||||||||||||||
47 | return; never executed: return; | 0 | ||||||||||||||||||||||||
48 | } | - | ||||||||||||||||||||||||
49 | - | |||||||||||||||||||||||||
50 | if (hasSize
| 0 | ||||||||||||||||||||||||
51 | return; never executed: return; | 0 | ||||||||||||||||||||||||
52 | - | |||||||||||||||||||||||||
53 | - | |||||||||||||||||||||||||
54 | hasSize = true; | - | ||||||||||||||||||||||||
55 | preferredSize = value; | - | ||||||||||||||||||||||||
56 | - | |||||||||||||||||||||||||
57 | layoutPrivate->q_func()->invalidate(); | - | ||||||||||||||||||||||||
58 | } never executed: end of block | 0 | ||||||||||||||||||||||||
59 | - | |||||||||||||||||||||||||
60 | void QGraphicsAnchorPrivate::unsetSpacing() | - | ||||||||||||||||||||||||
61 | { | - | ||||||||||||||||||||||||
62 | if (!data
| 0 | ||||||||||||||||||||||||
63 | QMessageLogger(__FILE__, 102, __PRETTY_FUNCTION__).warning("QGraphicsAnchor::setSpacing: The anchor does not exist."); | - | ||||||||||||||||||||||||
64 | return; never executed: return; | 0 | ||||||||||||||||||||||||
65 | } | - | ||||||||||||||||||||||||
66 | - | |||||||||||||||||||||||||
67 | - | |||||||||||||||||||||||||
68 | hasSize = false; | - | ||||||||||||||||||||||||
69 | - | |||||||||||||||||||||||||
70 | layoutPrivate->q_func()->invalidate(); | - | ||||||||||||||||||||||||
71 | } never executed: end of block | 0 | ||||||||||||||||||||||||
72 | - | |||||||||||||||||||||||||
73 | qreal QGraphicsAnchorPrivate::spacing() const | - | ||||||||||||||||||||||||
74 | { | - | ||||||||||||||||||||||||
75 | if (!data
| 0 | ||||||||||||||||||||||||
76 | QMessageLogger(__FILE__, 115, __PRETTY_FUNCTION__).warning("QGraphicsAnchor::setSpacing: The anchor does not exist."); | - | ||||||||||||||||||||||||
77 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
78 | } | - | ||||||||||||||||||||||||
79 | - | |||||||||||||||||||||||||
80 | return never executed: preferredSize;return preferredSize; never executed: return preferredSize; | 0 | ||||||||||||||||||||||||
81 | } | - | ||||||||||||||||||||||||
82 | - | |||||||||||||||||||||||||
83 | - | |||||||||||||||||||||||||
84 | static void applySizePolicy(QSizePolicy::Policy policy, | - | ||||||||||||||||||||||||
85 | qreal minSizeHint, qreal prefSizeHint, qreal maxSizeHint, | - | ||||||||||||||||||||||||
86 | qreal *minSize, qreal *prefSize, | - | ||||||||||||||||||||||||
87 | qreal *maxSize) | - | ||||||||||||||||||||||||
88 | { | - | ||||||||||||||||||||||||
89 | if (policy & QSizePolicy::ShrinkFlag
| 0 | ||||||||||||||||||||||||
90 | * never executed: minSize = minSizeHint;*minSize = minSizeHint; never executed: *minSize = minSizeHint; | 0 | ||||||||||||||||||||||||
91 | else | - | ||||||||||||||||||||||||
92 | * never executed: minSize = prefSizeHint;*minSize = prefSizeHint; never executed: *minSize = prefSizeHint; | 0 | ||||||||||||||||||||||||
93 | - | |||||||||||||||||||||||||
94 | if (policy & QSizePolicy::GrowFlag
| 0 | ||||||||||||||||||||||||
95 | * never executed: maxSize = maxSizeHint;*maxSize = maxSizeHint; never executed: *maxSize = maxSizeHint; | 0 | ||||||||||||||||||||||||
96 | else | - | ||||||||||||||||||||||||
97 | * never executed: maxSize = prefSizeHint;*maxSize = prefSizeHint; never executed: *maxSize = prefSizeHint; | 0 | ||||||||||||||||||||||||
98 | - | |||||||||||||||||||||||||
99 | - | |||||||||||||||||||||||||
100 | if (policy & QSizePolicy::IgnoreFlag
| 0 | ||||||||||||||||||||||||
101 | * never executed: prefSize = *minSize;*prefSize = *minSize; never executed: *prefSize = *minSize; | 0 | ||||||||||||||||||||||||
102 | else | - | ||||||||||||||||||||||||
103 | * never executed: prefSize = prefSizeHint;*prefSize = prefSizeHint; never executed: *prefSize = prefSizeHint; | 0 | ||||||||||||||||||||||||
104 | } | - | ||||||||||||||||||||||||
105 | - | |||||||||||||||||||||||||
106 | AnchorData::~AnchorData() | - | ||||||||||||||||||||||||
107 | { | - | ||||||||||||||||||||||||
108 | if (graphicsAnchor
| 0 | ||||||||||||||||||||||||
109 | - | |||||||||||||||||||||||||
110 | - | |||||||||||||||||||||||||
111 | graphicsAnchor->d_func()->data = 0; | - | ||||||||||||||||||||||||
112 | - | |||||||||||||||||||||||||
113 | delete graphicsAnchor; | - | ||||||||||||||||||||||||
114 | } never executed: end of block | 0 | ||||||||||||||||||||||||
115 | } never executed: end of block | 0 | ||||||||||||||||||||||||
116 | - | |||||||||||||||||||||||||
117 | - | |||||||||||||||||||||||||
118 | void AnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo) | - | ||||||||||||||||||||||||
119 | { | - | ||||||||||||||||||||||||
120 | QSizePolicy::Policy policy; | - | ||||||||||||||||||||||||
121 | qreal minSizeHint; | - | ||||||||||||||||||||||||
122 | qreal prefSizeHint; | - | ||||||||||||||||||||||||
123 | qreal maxSizeHint; | - | ||||||||||||||||||||||||
124 | - | |||||||||||||||||||||||||
125 | if (item
| 0 | ||||||||||||||||||||||||
126 | - | |||||||||||||||||||||||||
127 | if (isLayoutAnchor
| 0 | ||||||||||||||||||||||||
128 | minSize = 0; | - | ||||||||||||||||||||||||
129 | prefSize = 0; | - | ||||||||||||||||||||||||
130 | maxSize = ((1<<24)-1); | - | ||||||||||||||||||||||||
131 | if (isCenterAnchor
| 0 | ||||||||||||||||||||||||
132 | maxSize /= 2; never executed: maxSize /= 2; | 0 | ||||||||||||||||||||||||
133 | - | |||||||||||||||||||||||||
134 | minPrefSize = prefSize; | - | ||||||||||||||||||||||||
135 | maxPrefSize = maxSize; | - | ||||||||||||||||||||||||
136 | return; never executed: return; | 0 | ||||||||||||||||||||||||
137 | } else { | - | ||||||||||||||||||||||||
138 | if (orientation == QGraphicsAnchorLayoutPrivate::Horizontal
| 0 | ||||||||||||||||||||||||
139 | policy = item->sizePolicy().horizontalPolicy(); | - | ||||||||||||||||||||||||
140 | minSizeHint = item->effectiveSizeHint(Qt::MinimumSize).width(); | - | ||||||||||||||||||||||||
141 | prefSizeHint = item->effectiveSizeHint(Qt::PreferredSize).width(); | - | ||||||||||||||||||||||||
142 | maxSizeHint = item->effectiveSizeHint(Qt::MaximumSize).width(); | - | ||||||||||||||||||||||||
143 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
144 | policy = item->sizePolicy().verticalPolicy(); | - | ||||||||||||||||||||||||
145 | minSizeHint = item->effectiveSizeHint(Qt::MinimumSize).height(); | - | ||||||||||||||||||||||||
146 | prefSizeHint = item->effectiveSizeHint(Qt::PreferredSize).height(); | - | ||||||||||||||||||||||||
147 | maxSizeHint = item->effectiveSizeHint(Qt::MaximumSize).height(); | - | ||||||||||||||||||||||||
148 | } never executed: end of block | 0 | ||||||||||||||||||||||||
149 | - | |||||||||||||||||||||||||
150 | if (isCenterAnchor
| 0 | ||||||||||||||||||||||||
151 | minSizeHint /= 2; | - | ||||||||||||||||||||||||
152 | prefSizeHint /= 2; | - | ||||||||||||||||||||||||
153 | maxSizeHint /= 2; | - | ||||||||||||||||||||||||
154 | } never executed: end of block | 0 | ||||||||||||||||||||||||
155 | } never executed: end of block | 0 | ||||||||||||||||||||||||
156 | } else { | - | ||||||||||||||||||||||||
157 | - | |||||||||||||||||||||||||
158 | ((!(graphicsAnchor)) ? qt_assert("graphicsAnchor",__FILE__,210) : qt_noop()); | - | ||||||||||||||||||||||||
159 | QGraphicsAnchorPrivate *anchorPrivate = graphicsAnchor->d_func(); | - | ||||||||||||||||||||||||
160 | - | |||||||||||||||||||||||||
161 | - | |||||||||||||||||||||||||
162 | policy = anchorPrivate->sizePolicy; | - | ||||||||||||||||||||||||
163 | minSizeHint = 0; | - | ||||||||||||||||||||||||
164 | maxSizeHint = ((1<<24)-1); | - | ||||||||||||||||||||||||
165 | - | |||||||||||||||||||||||||
166 | - | |||||||||||||||||||||||||
167 | if (anchorPrivate->hasSize
| 0 | ||||||||||||||||||||||||
168 | - | |||||||||||||||||||||||||
169 | prefSizeHint = anchorPrivate->preferredSize; | - | ||||||||||||||||||||||||
170 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
171 | - | |||||||||||||||||||||||||
172 | const Qt::Orientation orient = Qt::Orientation(QGraphicsAnchorLayoutPrivate::edgeOrientation(from->m_edge) + 1); | - | ||||||||||||||||||||||||
173 | qreal s = styleInfo->defaultSpacing(orient); | - | ||||||||||||||||||||||||
174 | if (s < 0
| 0 | ||||||||||||||||||||||||
175 | QSizePolicy::ControlType controlTypeFrom = from->m_item->sizePolicy().controlType(); | - | ||||||||||||||||||||||||
176 | QSizePolicy::ControlType controlTypeTo = to->m_item->sizePolicy().controlType(); | - | ||||||||||||||||||||||||
177 | s = styleInfo->perItemSpacing(controlTypeFrom, controlTypeTo, orient); | - | ||||||||||||||||||||||||
178 | - | |||||||||||||||||||||||||
179 | - | |||||||||||||||||||||||||
180 | - | |||||||||||||||||||||||||
181 | - | |||||||||||||||||||||||||
182 | if (s < 0
| 0 | ||||||||||||||||||||||||
183 | s = 0; never executed: s = 0; | 0 | ||||||||||||||||||||||||
184 | } never executed: end of block | 0 | ||||||||||||||||||||||||
185 | prefSizeHint = s; | - | ||||||||||||||||||||||||
186 | } never executed: end of block | 0 | ||||||||||||||||||||||||
187 | } | - | ||||||||||||||||||||||||
188 | - | |||||||||||||||||||||||||
189 | - | |||||||||||||||||||||||||
190 | applySizePolicy(policy, minSizeHint, prefSizeHint, maxSizeHint, | - | ||||||||||||||||||||||||
191 | &minSize, &prefSize, &maxSize); | - | ||||||||||||||||||||||||
192 | - | |||||||||||||||||||||||||
193 | minPrefSize = prefSize; | - | ||||||||||||||||||||||||
194 | maxPrefSize = maxSize; | - | ||||||||||||||||||||||||
195 | sizeAtMinimum = prefSize; | - | ||||||||||||||||||||||||
196 | sizeAtPreferred = prefSize; | - | ||||||||||||||||||||||||
197 | sizeAtMaximum = prefSize; | - | ||||||||||||||||||||||||
198 | } never executed: end of block | 0 | ||||||||||||||||||||||||
199 | - | |||||||||||||||||||||||||
200 | void ParallelAnchorData::updateChildrenSizes() | - | ||||||||||||||||||||||||
201 | { | - | ||||||||||||||||||||||||
202 | firstEdge->sizeAtMinimum = sizeAtMinimum; | - | ||||||||||||||||||||||||
203 | firstEdge->sizeAtPreferred = sizeAtPreferred; | - | ||||||||||||||||||||||||
204 | firstEdge->sizeAtMaximum = sizeAtMaximum; | - | ||||||||||||||||||||||||
205 | - | |||||||||||||||||||||||||
206 | if (secondForward()
| 0 | ||||||||||||||||||||||||
207 | secondEdge->sizeAtMinimum = sizeAtMinimum; | - | ||||||||||||||||||||||||
208 | secondEdge->sizeAtPreferred = sizeAtPreferred; | - | ||||||||||||||||||||||||
209 | secondEdge->sizeAtMaximum = sizeAtMaximum; | - | ||||||||||||||||||||||||
210 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
211 | secondEdge->sizeAtMinimum = -sizeAtMinimum; | - | ||||||||||||||||||||||||
212 | secondEdge->sizeAtPreferred = -sizeAtPreferred; | - | ||||||||||||||||||||||||
213 | secondEdge->sizeAtMaximum = -sizeAtMaximum; | - | ||||||||||||||||||||||||
214 | } never executed: end of block | 0 | ||||||||||||||||||||||||
215 | - | |||||||||||||||||||||||||
216 | firstEdge->updateChildrenSizes(); | - | ||||||||||||||||||||||||
217 | secondEdge->updateChildrenSizes(); | - | ||||||||||||||||||||||||
218 | } never executed: end of block | 0 | ||||||||||||||||||||||||
219 | bool ParallelAnchorData::calculateSizeHints() | - | ||||||||||||||||||||||||
220 | { | - | ||||||||||||||||||||||||
221 | - | |||||||||||||||||||||||||
222 | - | |||||||||||||||||||||||||
223 | - | |||||||||||||||||||||||||
224 | qreal secondMin; | - | ||||||||||||||||||||||||
225 | qreal secondMinPref; | - | ||||||||||||||||||||||||
226 | qreal secondPref; | - | ||||||||||||||||||||||||
227 | qreal secondMaxPref; | - | ||||||||||||||||||||||||
228 | qreal secondMax; | - | ||||||||||||||||||||||||
229 | - | |||||||||||||||||||||||||
230 | if (secondForward()
| 0 | ||||||||||||||||||||||||
231 | secondMin = secondEdge->minSize; | - | ||||||||||||||||||||||||
232 | secondMinPref = secondEdge->minPrefSize; | - | ||||||||||||||||||||||||
233 | secondPref = secondEdge->prefSize; | - | ||||||||||||||||||||||||
234 | secondMaxPref = secondEdge->maxPrefSize; | - | ||||||||||||||||||||||||
235 | secondMax = secondEdge->maxSize; | - | ||||||||||||||||||||||||
236 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
237 | secondMin = -secondEdge->maxSize; | - | ||||||||||||||||||||||||
238 | secondMinPref = -secondEdge->maxPrefSize; | - | ||||||||||||||||||||||||
239 | secondPref = -secondEdge->prefSize; | - | ||||||||||||||||||||||||
240 | secondMaxPref = -secondEdge->minPrefSize; | - | ||||||||||||||||||||||||
241 | secondMax = -secondEdge->minSize; | - | ||||||||||||||||||||||||
242 | } never executed: end of block | 0 | ||||||||||||||||||||||||
243 | - | |||||||||||||||||||||||||
244 | minSize = qMax(firstEdge->minSize, secondMin); | - | ||||||||||||||||||||||||
245 | maxSize = qMin(firstEdge->maxSize, secondMax); | - | ||||||||||||||||||||||||
246 | - | |||||||||||||||||||||||||
247 | - | |||||||||||||||||||||||||
248 | - | |||||||||||||||||||||||||
249 | - | |||||||||||||||||||||||||
250 | if (minSize > maxSize
| 0 | ||||||||||||||||||||||||
251 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
252 | } | - | ||||||||||||||||||||||||
253 | if (firstEdge->isLayoutAnchor
| 0 | ||||||||||||||||||||||||
254 | prefSize = qBound(minSize, secondPref, maxSize); | - | ||||||||||||||||||||||||
255 | minPrefSize = qBound(minSize, secondMinPref, maxSize); | - | ||||||||||||||||||||||||
256 | maxPrefSize = qBound(minSize, secondMaxPref, maxSize); | - | ||||||||||||||||||||||||
257 | } never executed: else if (secondEdge->isLayoutAnchorend of block
| 0 | ||||||||||||||||||||||||
258 | prefSize = qBound(minSize, firstEdge->prefSize, maxSize); | - | ||||||||||||||||||||||||
259 | minPrefSize = qBound(minSize, firstEdge->minPrefSize, maxSize); | - | ||||||||||||||||||||||||
260 | maxPrefSize = qBound(minSize, firstEdge->maxPrefSize, maxSize); | - | ||||||||||||||||||||||||
261 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
262 | - | |||||||||||||||||||||||||
263 | const qreal lowerBoundary = | - | ||||||||||||||||||||||||
264 | qBound(minSize, qMax(firstEdge->minPrefSize, secondMinPref), maxSize); | - | ||||||||||||||||||||||||
265 | const qreal upperBoundary = | - | ||||||||||||||||||||||||
266 | qBound(minSize, qMin(firstEdge->maxPrefSize, secondMaxPref), maxSize); | - | ||||||||||||||||||||||||
267 | const qreal prefMean = | - | ||||||||||||||||||||||||
268 | qBound(minSize, (firstEdge->prefSize + secondPref) / 2, maxSize); | - | ||||||||||||||||||||||||
269 | - | |||||||||||||||||||||||||
270 | if (lowerBoundary < upperBoundary
| 0 | ||||||||||||||||||||||||
271 | - | |||||||||||||||||||||||||
272 | - | |||||||||||||||||||||||||
273 | - | |||||||||||||||||||||||||
274 | - | |||||||||||||||||||||||||
275 | prefSize = qBound(lowerBoundary, prefMean, upperBoundary); | - | ||||||||||||||||||||||||
276 | minPrefSize = lowerBoundary; | - | ||||||||||||||||||||||||
277 | maxPrefSize = upperBoundary; | - | ||||||||||||||||||||||||
278 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
279 | - | |||||||||||||||||||||||||
280 | - | |||||||||||||||||||||||||
281 | - | |||||||||||||||||||||||||
282 | - | |||||||||||||||||||||||||
283 | - | |||||||||||||||||||||||||
284 | - | |||||||||||||||||||||||||
285 | prefSize = qBound(upperBoundary, prefMean, lowerBoundary); | - | ||||||||||||||||||||||||
286 | minPrefSize = upperBoundary; | - | ||||||||||||||||||||||||
287 | maxPrefSize = lowerBoundary; | - | ||||||||||||||||||||||||
288 | } never executed: end of block | 0 | ||||||||||||||||||||||||
289 | } | - | ||||||||||||||||||||||||
290 | - | |||||||||||||||||||||||||
291 | - | |||||||||||||||||||||||||
292 | sizeAtMinimum = prefSize; | - | ||||||||||||||||||||||||
293 | sizeAtPreferred = prefSize; | - | ||||||||||||||||||||||||
294 | sizeAtMaximum = prefSize; | - | ||||||||||||||||||||||||
295 | - | |||||||||||||||||||||||||
296 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
297 | } | - | ||||||||||||||||||||||||
298 | static QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> getFactor(qreal value, qreal min, | - | ||||||||||||||||||||||||
299 | qreal minPref, qreal pref, | - | ||||||||||||||||||||||||
300 | qreal maxPref, qreal max) | - | ||||||||||||||||||||||||
301 | { | - | ||||||||||||||||||||||||
302 | QGraphicsAnchorLayoutPrivate::Interval interval; | - | ||||||||||||||||||||||||
303 | qreal lower; | - | ||||||||||||||||||||||||
304 | qreal upper; | - | ||||||||||||||||||||||||
305 | - | |||||||||||||||||||||||||
306 | if (value < minPref
| 0 | ||||||||||||||||||||||||
307 | interval = QGraphicsAnchorLayoutPrivate::MinimumToMinPreferred; | - | ||||||||||||||||||||||||
308 | lower = min; | - | ||||||||||||||||||||||||
309 | upper = minPref; | - | ||||||||||||||||||||||||
310 | } never executed: else if (value < prefend of block
| 0 | ||||||||||||||||||||||||
311 | interval = QGraphicsAnchorLayoutPrivate::MinPreferredToPreferred; | - | ||||||||||||||||||||||||
312 | lower = minPref; | - | ||||||||||||||||||||||||
313 | upper = pref; | - | ||||||||||||||||||||||||
314 | } never executed: else if (value < maxPrefend of block
| 0 | ||||||||||||||||||||||||
315 | interval = QGraphicsAnchorLayoutPrivate::PreferredToMaxPreferred; | - | ||||||||||||||||||||||||
316 | lower = pref; | - | ||||||||||||||||||||||||
317 | upper = maxPref; | - | ||||||||||||||||||||||||
318 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
319 | interval = QGraphicsAnchorLayoutPrivate::MaxPreferredToMaximum; | - | ||||||||||||||||||||||||
320 | lower = maxPref; | - | ||||||||||||||||||||||||
321 | upper = max; | - | ||||||||||||||||||||||||
322 | } never executed: end of block | 0 | ||||||||||||||||||||||||
323 | - | |||||||||||||||||||||||||
324 | qreal progress; | - | ||||||||||||||||||||||||
325 | if (upper == lower
| 0 | ||||||||||||||||||||||||
326 | progress = 0; | - | ||||||||||||||||||||||||
327 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
328 | progress = (value - lower) / (upper - lower); | - | ||||||||||||||||||||||||
329 | } never executed: end of block | 0 | ||||||||||||||||||||||||
330 | - | |||||||||||||||||||||||||
331 | return never executed: qMakePair(interval, progress);return qMakePair(interval, progress); never executed: return qMakePair(interval, progress); | 0 | ||||||||||||||||||||||||
332 | } | - | ||||||||||||||||||||||||
333 | - | |||||||||||||||||||||||||
334 | static qreal interpolate(const QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> &factor, | - | ||||||||||||||||||||||||
335 | qreal min, qreal minPref, qreal pref, qreal maxPref, qreal max) | - | ||||||||||||||||||||||||
336 | { | - | ||||||||||||||||||||||||
337 | qreal lower = 0; | - | ||||||||||||||||||||||||
338 | qreal upper = 0; | - | ||||||||||||||||||||||||
339 | - | |||||||||||||||||||||||||
340 | switch (factor.first) { | - | ||||||||||||||||||||||||
341 | case never executed: QGraphicsAnchorLayoutPrivate::MinimumToMinPreferred:case QGraphicsAnchorLayoutPrivate::MinimumToMinPreferred: never executed: case QGraphicsAnchorLayoutPrivate::MinimumToMinPreferred: | 0 | ||||||||||||||||||||||||
342 | lower = min; | - | ||||||||||||||||||||||||
343 | upper = minPref; | - | ||||||||||||||||||||||||
344 | break; never executed: break; | 0 | ||||||||||||||||||||||||
345 | case never executed: QGraphicsAnchorLayoutPrivate::MinPreferredToPreferred:case QGraphicsAnchorLayoutPrivate::MinPreferredToPreferred: never executed: case QGraphicsAnchorLayoutPrivate::MinPreferredToPreferred: | 0 | ||||||||||||||||||||||||
346 | lower = minPref; | - | ||||||||||||||||||||||||
347 | upper = pref; | - | ||||||||||||||||||||||||
348 | break; never executed: break; | 0 | ||||||||||||||||||||||||
349 | case never executed: QGraphicsAnchorLayoutPrivate::PreferredToMaxPreferred:case QGraphicsAnchorLayoutPrivate::PreferredToMaxPreferred: never executed: case QGraphicsAnchorLayoutPrivate::PreferredToMaxPreferred: | 0 | ||||||||||||||||||||||||
350 | lower = pref; | - | ||||||||||||||||||||||||
351 | upper = maxPref; | - | ||||||||||||||||||||||||
352 | break; never executed: break; | 0 | ||||||||||||||||||||||||
353 | case never executed: QGraphicsAnchorLayoutPrivate::MaxPreferredToMaximum:case QGraphicsAnchorLayoutPrivate::MaxPreferredToMaximum: never executed: case QGraphicsAnchorLayoutPrivate::MaxPreferredToMaximum: | 0 | ||||||||||||||||||||||||
354 | lower = maxPref; | - | ||||||||||||||||||||||||
355 | upper = max; | - | ||||||||||||||||||||||||
356 | break; never executed: break; | 0 | ||||||||||||||||||||||||
357 | } | - | ||||||||||||||||||||||||
358 | - | |||||||||||||||||||||||||
359 | return never executed: lower + factor.second * (upper - lower);return lower + factor.second * (upper - lower); never executed: return lower + factor.second * (upper - lower); | 0 | ||||||||||||||||||||||||
360 | } | - | ||||||||||||||||||||||||
361 | - | |||||||||||||||||||||||||
362 | void SequentialAnchorData::updateChildrenSizes() | - | ||||||||||||||||||||||||
363 | { | - | ||||||||||||||||||||||||
364 | - | |||||||||||||||||||||||||
365 | - | |||||||||||||||||||||||||
366 | - | |||||||||||||||||||||||||
367 | const QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> minFactor = | - | ||||||||||||||||||||||||
368 | getFactor(sizeAtMinimum, minSize, minPrefSize, prefSize, maxPrefSize, maxSize); | - | ||||||||||||||||||||||||
369 | const QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> prefFactor = | - | ||||||||||||||||||||||||
370 | getFactor(sizeAtPreferred, minSize, minPrefSize, prefSize, maxPrefSize, maxSize); | - | ||||||||||||||||||||||||
371 | const QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> maxFactor = | - | ||||||||||||||||||||||||
372 | getFactor(sizeAtMaximum, minSize, minPrefSize, prefSize, maxPrefSize, maxSize); | - | ||||||||||||||||||||||||
373 | - | |||||||||||||||||||||||||
374 | - | |||||||||||||||||||||||||
375 | - | |||||||||||||||||||||||||
376 | - | |||||||||||||||||||||||||
377 | AnchorVertex *prev = from; | - | ||||||||||||||||||||||||
378 | - | |||||||||||||||||||||||||
379 | for (int i = 0; i < m_edges.count()
| 0 | ||||||||||||||||||||||||
380 | AnchorData *e = m_edges.at(i); | - | ||||||||||||||||||||||||
381 | - | |||||||||||||||||||||||||
382 | const bool edgeIsForward = (e->from == prev); | - | ||||||||||||||||||||||||
383 | if (edgeIsForward
| 0 | ||||||||||||||||||||||||
384 | e->sizeAtMinimum = interpolate(minFactor, e->minSize, e->minPrefSize, | - | ||||||||||||||||||||||||
385 | e->prefSize, e->maxPrefSize, e->maxSize); | - | ||||||||||||||||||||||||
386 | e->sizeAtPreferred = interpolate(prefFactor, e->minSize, e->minPrefSize, | - | ||||||||||||||||||||||||
387 | e->prefSize, e->maxPrefSize, e->maxSize); | - | ||||||||||||||||||||||||
388 | e->sizeAtMaximum = interpolate(maxFactor, e->minSize, e->minPrefSize, | - | ||||||||||||||||||||||||
389 | e->prefSize, e->maxPrefSize, e->maxSize); | - | ||||||||||||||||||||||||
390 | prev = e->to; | - | ||||||||||||||||||||||||
391 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
392 | ((!(prev == e->to)) ? qt_assert("prev == e->to",__FILE__,501) : qt_noop()); | - | ||||||||||||||||||||||||
393 | e->sizeAtMinimum = interpolate(minFactor, e->maxSize, e->maxPrefSize, | - | ||||||||||||||||||||||||
394 | e->prefSize, e->minPrefSize, e->minSize); | - | ||||||||||||||||||||||||
395 | e->sizeAtPreferred = interpolate(prefFactor, e->maxSize, e->maxPrefSize, | - | ||||||||||||||||||||||||
396 | e->prefSize, e->minPrefSize, e->minSize); | - | ||||||||||||||||||||||||
397 | e->sizeAtMaximum = interpolate(maxFactor, e->maxSize, e->maxPrefSize, | - | ||||||||||||||||||||||||
398 | e->prefSize, e->minPrefSize, e->minSize); | - | ||||||||||||||||||||||||
399 | prev = e->from; | - | ||||||||||||||||||||||||
400 | } never executed: end of block | 0 | ||||||||||||||||||||||||
401 | - | |||||||||||||||||||||||||
402 | e->updateChildrenSizes(); | - | ||||||||||||||||||||||||
403 | } never executed: end of block | 0 | ||||||||||||||||||||||||
404 | } never executed: end of block | 0 | ||||||||||||||||||||||||
405 | - | |||||||||||||||||||||||||
406 | void SequentialAnchorData::calculateSizeHints() | - | ||||||||||||||||||||||||
407 | { | - | ||||||||||||||||||||||||
408 | minSize = 0; | - | ||||||||||||||||||||||||
409 | prefSize = 0; | - | ||||||||||||||||||||||||
410 | maxSize = 0; | - | ||||||||||||||||||||||||
411 | minPrefSize = 0; | - | ||||||||||||||||||||||||
412 | maxPrefSize = 0; | - | ||||||||||||||||||||||||
413 | - | |||||||||||||||||||||||||
414 | AnchorVertex *prev = from; | - | ||||||||||||||||||||||||
415 | - | |||||||||||||||||||||||||
416 | for (int i = 0; i < m_edges.count()
| 0 | ||||||||||||||||||||||||
417 | AnchorData *edge = m_edges.at(i); | - | ||||||||||||||||||||||||
418 | - | |||||||||||||||||||||||||
419 | const bool edgeIsForward = (edge->from == prev); | - | ||||||||||||||||||||||||
420 | if (edgeIsForward
| 0 | ||||||||||||||||||||||||
421 | minSize += edge->minSize; | - | ||||||||||||||||||||||||
422 | prefSize += edge->prefSize; | - | ||||||||||||||||||||||||
423 | maxSize += edge->maxSize; | - | ||||||||||||||||||||||||
424 | minPrefSize += edge->minPrefSize; | - | ||||||||||||||||||||||||
425 | maxPrefSize += edge->maxPrefSize; | - | ||||||||||||||||||||||||
426 | prev = edge->to; | - | ||||||||||||||||||||||||
427 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
428 | ((!(prev == edge->to)) ? qt_assert("prev == edge->to",__FILE__,537) : qt_noop()); | - | ||||||||||||||||||||||||
429 | minSize -= edge->maxSize; | - | ||||||||||||||||||||||||
430 | prefSize -= edge->prefSize; | - | ||||||||||||||||||||||||
431 | maxSize -= edge->minSize; | - | ||||||||||||||||||||||||
432 | minPrefSize -= edge->maxPrefSize; | - | ||||||||||||||||||||||||
433 | maxPrefSize -= edge->minPrefSize; | - | ||||||||||||||||||||||||
434 | prev = edge->from; | - | ||||||||||||||||||||||||
435 | } never executed: end of block | 0 | ||||||||||||||||||||||||
436 | } | - | ||||||||||||||||||||||||
437 | - | |||||||||||||||||||||||||
438 | - | |||||||||||||||||||||||||
439 | sizeAtMinimum = prefSize; | - | ||||||||||||||||||||||||
440 | sizeAtPreferred = prefSize; | - | ||||||||||||||||||||||||
441 | sizeAtMaximum = prefSize; | - | ||||||||||||||||||||||||
442 | } never executed: end of block | 0 | ||||||||||||||||||||||||
443 | - | |||||||||||||||||||||||||
444 | - | |||||||||||||||||||||||||
445 | void AnchorData::dump(int indent) { | - | ||||||||||||||||||||||||
446 | if (type == Parallel
| 0 | ||||||||||||||||||||||||
447 | QMessageLogger(__FILE__, 556, __PRETTY_FUNCTION__).debug("%*s type: parallel:", indent, ""); | - | ||||||||||||||||||||||||
448 | ParallelAnchorData *p = static_cast<ParallelAnchorData *>(this); | - | ||||||||||||||||||||||||
449 | p->firstEdge->dump(indent+2); | - | ||||||||||||||||||||||||
450 | p->secondEdge->dump(indent+2); | - | ||||||||||||||||||||||||
451 | } never executed: else if (type == Sequentialend of block
| 0 | ||||||||||||||||||||||||
452 | SequentialAnchorData *s = static_cast<SequentialAnchorData *>(this); | - | ||||||||||||||||||||||||
453 | int kids = s->m_edges.count(); | - | ||||||||||||||||||||||||
454 | QMessageLogger(__FILE__, 563, __PRETTY_FUNCTION__).debug("%*s type: sequential(%d):", indent, "", kids); | - | ||||||||||||||||||||||||
455 | for (int i = 0; i < kids
| 0 | ||||||||||||||||||||||||
456 | s->m_edges.at(i)->dump(indent+2); | - | ||||||||||||||||||||||||
457 | } never executed: end of block | 0 | ||||||||||||||||||||||||
458 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
459 | QMessageLogger(__FILE__, 568, __PRETTY_FUNCTION__).debug("%*s type: Normal:", indent, ""); | - | ||||||||||||||||||||||||
460 | } never executed: end of block | 0 | ||||||||||||||||||||||||
461 | } | - | ||||||||||||||||||||||||
462 | - | |||||||||||||||||||||||||
463 | - | |||||||||||||||||||||||||
464 | - | |||||||||||||||||||||||||
465 | QSimplexConstraint *GraphPath::constraint(const GraphPath &path) const | - | ||||||||||||||||||||||||
466 | { | - | ||||||||||||||||||||||||
467 | - | |||||||||||||||||||||||||
468 | QSet<AnchorData *> cPositives; | - | ||||||||||||||||||||||||
469 | QSet<AnchorData *> cNegatives; | - | ||||||||||||||||||||||||
470 | QSet<AnchorData *> intersection; | - | ||||||||||||||||||||||||
471 | - | |||||||||||||||||||||||||
472 | cPositives = positives + path.negatives; | - | ||||||||||||||||||||||||
473 | cNegatives = negatives + path.positives; | - | ||||||||||||||||||||||||
474 | - | |||||||||||||||||||||||||
475 | intersection = cPositives & cNegatives; | - | ||||||||||||||||||||||||
476 | - | |||||||||||||||||||||||||
477 | cPositives -= intersection; | - | ||||||||||||||||||||||||
478 | cNegatives -= intersection; | - | ||||||||||||||||||||||||
479 | - | |||||||||||||||||||||||||
480 | - | |||||||||||||||||||||||||
481 | QSimplexConstraint *c = new QSimplexConstraint; | - | ||||||||||||||||||||||||
482 | QSet<AnchorData *>::iterator i; | - | ||||||||||||||||||||||||
483 | for (i = cPositives.begin(); i != cPositives.end()
| 0 | ||||||||||||||||||||||||
484 | c->variables.insert(*i, 1.0); never executed: c->variables.insert(*i, 1.0); | 0 | ||||||||||||||||||||||||
485 | - | |||||||||||||||||||||||||
486 | for (i = cNegatives.begin(); i != cNegatives.end()
| 0 | ||||||||||||||||||||||||
487 | c->variables.insert(*i, -1.0); never executed: c->variables.insert(*i, -1.0); | 0 | ||||||||||||||||||||||||
488 | - | |||||||||||||||||||||||||
489 | return never executed: c;return c; never executed: return c; | 0 | ||||||||||||||||||||||||
490 | } | - | ||||||||||||||||||||||||
491 | - | |||||||||||||||||||||||||
492 | - | |||||||||||||||||||||||||
493 | QString GraphPath::toString() const | - | ||||||||||||||||||||||||
494 | { | - | ||||||||||||||||||||||||
495 | QString string(QLatin1String("Path: ")); | - | ||||||||||||||||||||||||
496 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(positives)>::type> _container_((positives)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (AnchorData *edge = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||||||||||||||
497 | string += QString::fromLatin1(" (+++) %1").arg(edge->toString()); never executed: string += QString::fromLatin1(" (+++) %1").arg(edge->toString()); | 0 | ||||||||||||||||||||||||
498 | - | |||||||||||||||||||||||||
499 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(negatives)>::type> _container_((negatives)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (AnchorData *edge = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||||||||||||||
500 | string += QString::fromLatin1(" (---) %1").arg(edge->toString()); never executed: string += QString::fromLatin1(" (---) %1").arg(edge->toString()); | 0 | ||||||||||||||||||||||||
501 | - | |||||||||||||||||||||||||
502 | return never executed: string;return string; never executed: return string; | 0 | ||||||||||||||||||||||||
503 | } | - | ||||||||||||||||||||||||
504 | - | |||||||||||||||||||||||||
505 | - | |||||||||||||||||||||||||
506 | QGraphicsAnchorLayoutPrivate::QGraphicsAnchorLayoutPrivate() | - | ||||||||||||||||||||||||
507 | : calculateGraphCacheDirty(true), styleInfoDirty(true) | - | ||||||||||||||||||||||||
508 | { | - | ||||||||||||||||||||||||
509 | for (int i = 0; i < NOrientations
| 0 | ||||||||||||||||||||||||
510 | for (int j = 0; j < 3
| 0 | ||||||||||||||||||||||||
511 | sizeHints[i][j] = -1; | - | ||||||||||||||||||||||||
512 | } never executed: end of block | 0 | ||||||||||||||||||||||||
513 | interpolationProgress[i] = -1; | - | ||||||||||||||||||||||||
514 | - | |||||||||||||||||||||||||
515 | spacings[i] = -1; | - | ||||||||||||||||||||||||
516 | graphHasConflicts[i] = false; | - | ||||||||||||||||||||||||
517 | - | |||||||||||||||||||||||||
518 | layoutFirstVertex[i] = 0; | - | ||||||||||||||||||||||||
519 | layoutCentralVertex[i] = 0; | - | ||||||||||||||||||||||||
520 | layoutLastVertex[i] = 0; | - | ||||||||||||||||||||||||
521 | } never executed: end of block | 0 | ||||||||||||||||||||||||
522 | } never executed: end of block | 0 | ||||||||||||||||||||||||
523 | - | |||||||||||||||||||||||||
524 | Qt::AnchorPoint QGraphicsAnchorLayoutPrivate::oppositeEdge(Qt::AnchorPoint edge) | - | ||||||||||||||||||||||||
525 | { | - | ||||||||||||||||||||||||
526 | switch (edge) { | - | ||||||||||||||||||||||||
527 | case never executed: Qt::AnchorLeft:case Qt::AnchorLeft: never executed: case Qt::AnchorLeft: | 0 | ||||||||||||||||||||||||
528 | edge = Qt::AnchorRight; | - | ||||||||||||||||||||||||
529 | break; never executed: break; | 0 | ||||||||||||||||||||||||
530 | case never executed: Qt::AnchorRight:case Qt::AnchorRight: never executed: case Qt::AnchorRight: | 0 | ||||||||||||||||||||||||
531 | edge = Qt::AnchorLeft; | - | ||||||||||||||||||||||||
532 | break; never executed: break; | 0 | ||||||||||||||||||||||||
533 | case never executed: Qt::AnchorTop:case Qt::AnchorTop: never executed: case Qt::AnchorTop: | 0 | ||||||||||||||||||||||||
534 | edge = Qt::AnchorBottom; | - | ||||||||||||||||||||||||
535 | break; never executed: break; | 0 | ||||||||||||||||||||||||
536 | case never executed: Qt::AnchorBottom:case Qt::AnchorBottom: never executed: case Qt::AnchorBottom: | 0 | ||||||||||||||||||||||||
537 | edge = Qt::AnchorTop; | - | ||||||||||||||||||||||||
538 | break; never executed: break; | 0 | ||||||||||||||||||||||||
539 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||
540 | break; never executed: break; | 0 | ||||||||||||||||||||||||
541 | } | - | ||||||||||||||||||||||||
542 | return never executed: edge;return edge; never executed: return edge; | 0 | ||||||||||||||||||||||||
543 | } | - | ||||||||||||||||||||||||
544 | AnchorData *QGraphicsAnchorLayoutPrivate::addAnchorMaybeParallel(AnchorData *newAnchor, bool *feasible) | - | ||||||||||||||||||||||||
545 | { | - | ||||||||||||||||||||||||
546 | Orientation orientation = Orientation(newAnchor->orientation); | - | ||||||||||||||||||||||||
547 | Graph<AnchorVertex, AnchorData> &g = graph[orientation]; | - | ||||||||||||||||||||||||
548 | *feasible = true; | - | ||||||||||||||||||||||||
549 | - | |||||||||||||||||||||||||
550 | - | |||||||||||||||||||||||||
551 | - | |||||||||||||||||||||||||
552 | if (AnchorData *oldAnchor = g.takeEdge(newAnchor->from, newAnchor->to)
| 0 | ||||||||||||||||||||||||
553 | ParallelAnchorData *parallel = new ParallelAnchorData(oldAnchor, newAnchor); | - | ||||||||||||||||||||||||
554 | - | |||||||||||||||||||||||||
555 | - | |||||||||||||||||||||||||
556 | - | |||||||||||||||||||||||||
557 | - | |||||||||||||||||||||||||
558 | - | |||||||||||||||||||||||||
559 | - | |||||||||||||||||||||||||
560 | QList<QSimplexConstraint *> &constraints = itemCenterConstraints[orientation]; | - | ||||||||||||||||||||||||
561 | - | |||||||||||||||||||||||||
562 | AnchorData *children[2] = { oldAnchor, newAnchor }; | - | ||||||||||||||||||||||||
563 | QList<QSimplexConstraint *> *childrenConstraints[2] = { ¶llel->m_firstConstraints, | - | ||||||||||||||||||||||||
564 | ¶llel->m_secondConstraints }; | - | ||||||||||||||||||||||||
565 | - | |||||||||||||||||||||||||
566 | for (int i = 0; i < 2
| 0 | ||||||||||||||||||||||||
567 | AnchorData *child = children[i]; | - | ||||||||||||||||||||||||
568 | QList<QSimplexConstraint *> *childConstraints = childrenConstraints[i]; | - | ||||||||||||||||||||||||
569 | - | |||||||||||||||||||||||||
570 | - | |||||||||||||||||||||||||
571 | - | |||||||||||||||||||||||||
572 | - | |||||||||||||||||||||||||
573 | - | |||||||||||||||||||||||||
574 | - | |||||||||||||||||||||||||
575 | const bool needsReverse = i == 1
| 0 | ||||||||||||||||||||||||
576 | - | |||||||||||||||||||||||||
577 | if (!child->isCenterAnchor
| 0 | ||||||||||||||||||||||||
578 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
579 | - | |||||||||||||||||||||||||
580 | parallel->isCenterAnchor = true; | - | ||||||||||||||||||||||||
581 | - | |||||||||||||||||||||||||
582 | for (int j = 0; j < constraints.count()
| 0 | ||||||||||||||||||||||||
583 | QSimplexConstraint *c = constraints[j]; | - | ||||||||||||||||||||||||
584 | if (c->variables.contains(child)
| 0 | ||||||||||||||||||||||||
585 | childConstraints->append(c); | - | ||||||||||||||||||||||||
586 | qreal v = c->variables.take(child); | - | ||||||||||||||||||||||||
587 | if (needsReverse
| 0 | ||||||||||||||||||||||||
588 | v *= -1; never executed: v *= -1; | 0 | ||||||||||||||||||||||||
589 | c->variables.insert(parallel, v); | - | ||||||||||||||||||||||||
590 | } never executed: end of block | 0 | ||||||||||||||||||||||||
591 | } never executed: end of block | 0 | ||||||||||||||||||||||||
592 | } never executed: end of block | 0 | ||||||||||||||||||||||||
593 | - | |||||||||||||||||||||||||
594 | - | |||||||||||||||||||||||||
595 | - | |||||||||||||||||||||||||
596 | *feasible = parallel->calculateSizeHints(); | - | ||||||||||||||||||||||||
597 | newAnchor = parallel; | - | ||||||||||||||||||||||||
598 | } never executed: end of block | 0 | ||||||||||||||||||||||||
599 | - | |||||||||||||||||||||||||
600 | g.createEdge(newAnchor->from, newAnchor->to, newAnchor); | - | ||||||||||||||||||||||||
601 | return never executed: newAnchor;return newAnchor; never executed: return newAnchor; | 0 | ||||||||||||||||||||||||
602 | } | - | ||||||||||||||||||||||||
603 | static AnchorData *createSequence(Graph<AnchorVertex, AnchorData> *graph, | - | ||||||||||||||||||||||||
604 | AnchorVertex *before, | - | ||||||||||||||||||||||||
605 | const QVector<AnchorVertex*> &vertices, | - | ||||||||||||||||||||||||
606 | AnchorVertex *after) | - | ||||||||||||||||||||||||
607 | { | - | ||||||||||||||||||||||||
608 | AnchorVertex *prev = before; | - | ||||||||||||||||||||||||
609 | QVector<AnchorData *> edges; | - | ||||||||||||||||||||||||
610 | edges.reserve(vertices.count() + 1); | - | ||||||||||||||||||||||||
611 | - | |||||||||||||||||||||||||
612 | const int numVertices = vertices.count(); | - | ||||||||||||||||||||||||
613 | edges.reserve(numVertices + 1); | - | ||||||||||||||||||||||||
614 | - | |||||||||||||||||||||||||
615 | for (int i = 0; i < numVertices
| 0 | ||||||||||||||||||||||||
616 | AnchorVertex *next = vertices.at(i); | - | ||||||||||||||||||||||||
617 | AnchorData *ad = graph->takeEdge(prev, next); | - | ||||||||||||||||||||||||
618 | ((!(ad)) ? qt_assert("ad",__FILE__,762) : qt_noop()); | - | ||||||||||||||||||||||||
619 | edges.append(ad); | - | ||||||||||||||||||||||||
620 | prev = next; | - | ||||||||||||||||||||||||
621 | } never executed: end of block | 0 | ||||||||||||||||||||||||
622 | - | |||||||||||||||||||||||||
623 | - | |||||||||||||||||||||||||
624 | AnchorData *ad = graph->takeEdge(vertices.last(), after); | - | ||||||||||||||||||||||||
625 | ((!(ad)) ? qt_assert("ad",__FILE__,769) : qt_noop()); | - | ||||||||||||||||||||||||
626 | edges.append(ad); | - | ||||||||||||||||||||||||
627 | - | |||||||||||||||||||||||||
628 | - | |||||||||||||||||||||||||
629 | SequentialAnchorData *sequence = new SequentialAnchorData(vertices, edges); | - | ||||||||||||||||||||||||
630 | sequence->from = before; | - | ||||||||||||||||||||||||
631 | sequence->to = after; | - | ||||||||||||||||||||||||
632 | - | |||||||||||||||||||||||||
633 | sequence->calculateSizeHints(); | - | ||||||||||||||||||||||||
634 | - | |||||||||||||||||||||||||
635 | return never executed: sequence;return sequence; never executed: return sequence; | 0 | ||||||||||||||||||||||||
636 | } | - | ||||||||||||||||||||||||
637 | bool QGraphicsAnchorLayoutPrivate::simplifyGraph(Orientation orientation) | - | ||||||||||||||||||||||||
638 | { | - | ||||||||||||||||||||||||
639 | if (items.isEmpty()
| 0 | ||||||||||||||||||||||||
640 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
641 | if (!simplifyVertices(orientation)
| 0 | ||||||||||||||||||||||||
642 | restoreVertices(orientation); | - | ||||||||||||||||||||||||
643 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
644 | } | - | ||||||||||||||||||||||||
645 | - | |||||||||||||||||||||||||
646 | - | |||||||||||||||||||||||||
647 | bool dirty; | - | ||||||||||||||||||||||||
648 | bool feasible = true; | - | ||||||||||||||||||||||||
649 | do { | - | ||||||||||||||||||||||||
650 | dirty = simplifyGraphIteration(orientation, &feasible); | - | ||||||||||||||||||||||||
651 | } never executed: while (dirtyend of block
| 0 | ||||||||||||||||||||||||
652 | - | |||||||||||||||||||||||||
653 | - | |||||||||||||||||||||||||
654 | if (!feasible
| 0 | ||||||||||||||||||||||||
655 | restoreSimplifiedGraph(orientation); | - | ||||||||||||||||||||||||
656 | restoreVertices(orientation); | - | ||||||||||||||||||||||||
657 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
658 | } | - | ||||||||||||||||||||||||
659 | - | |||||||||||||||||||||||||
660 | - | |||||||||||||||||||||||||
661 | - | |||||||||||||||||||||||||
662 | - | |||||||||||||||||||||||||
663 | - | |||||||||||||||||||||||||
664 | - | |||||||||||||||||||||||||
665 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
666 | } | - | ||||||||||||||||||||||||
667 | - | |||||||||||||||||||||||||
668 | static AnchorVertex *replaceVertex_helper(AnchorData *data, AnchorVertex *oldV, AnchorVertex *newV) | - | ||||||||||||||||||||||||
669 | { | - | ||||||||||||||||||||||||
670 | AnchorVertex *other; | - | ||||||||||||||||||||||||
671 | if (data->from == oldV
| 0 | ||||||||||||||||||||||||
672 | data->from = newV; | - | ||||||||||||||||||||||||
673 | other = data->to; | - | ||||||||||||||||||||||||
674 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
675 | data->to = newV; | - | ||||||||||||||||||||||||
676 | other = data->from; | - | ||||||||||||||||||||||||
677 | } never executed: end of block | 0 | ||||||||||||||||||||||||
678 | return never executed: other;return other; never executed: return other; | 0 | ||||||||||||||||||||||||
679 | } | - | ||||||||||||||||||||||||
680 | - | |||||||||||||||||||||||||
681 | bool QGraphicsAnchorLayoutPrivate::replaceVertex(Orientation orientation, AnchorVertex *oldV, | - | ||||||||||||||||||||||||
682 | AnchorVertex *newV, const QList<AnchorData *> &edges) | - | ||||||||||||||||||||||||
683 | { | - | ||||||||||||||||||||||||
684 | Graph<AnchorVertex, AnchorData> &g = graph[orientation]; | - | ||||||||||||||||||||||||
685 | bool feasible = true; | - | ||||||||||||||||||||||||
686 | - | |||||||||||||||||||||||||
687 | for (int i = 0; i < edges.count()
| 0 | ||||||||||||||||||||||||
688 | AnchorData *ad = edges[i]; | - | ||||||||||||||||||||||||
689 | AnchorVertex *otherV = replaceVertex_helper(ad, oldV, newV); | - | ||||||||||||||||||||||||
690 | - | |||||||||||||||||||||||||
691 | - | |||||||||||||||||||||||||
692 | ad->name = QString::fromLatin1("%1 --to--> %2").arg(ad->from->toString()).arg(ad->to->toString()); | - | ||||||||||||||||||||||||
693 | - | |||||||||||||||||||||||||
694 | - | |||||||||||||||||||||||||
695 | bool newFeasible; | - | ||||||||||||||||||||||||
696 | AnchorData *newAnchor = addAnchorMaybeParallel(ad, &newFeasible); | - | ||||||||||||||||||||||||
697 | feasible &= newFeasible; | - | ||||||||||||||||||||||||
698 | - | |||||||||||||||||||||||||
699 | if (newAnchor != ad
| 0 | ||||||||||||||||||||||||
700 | - | |||||||||||||||||||||||||
701 | - | |||||||||||||||||||||||||
702 | - | |||||||||||||||||||||||||
703 | anchorsFromSimplifiedVertices[orientation].append(newAnchor); | - | ||||||||||||||||||||||||
704 | } never executed: end of block | 0 | ||||||||||||||||||||||||
705 | - | |||||||||||||||||||||||||
706 | g.takeEdge(oldV, otherV); | - | ||||||||||||||||||||||||
707 | } never executed: end of block | 0 | ||||||||||||||||||||||||
708 | - | |||||||||||||||||||||||||
709 | return never executed: feasible;return feasible; never executed: return feasible; | 0 | ||||||||||||||||||||||||
710 | } | - | ||||||||||||||||||||||||
711 | - | |||||||||||||||||||||||||
712 | - | |||||||||||||||||||||||||
713 | - | |||||||||||||||||||||||||
714 | - | |||||||||||||||||||||||||
715 | bool QGraphicsAnchorLayoutPrivate::simplifyVertices(Orientation orientation) | - | ||||||||||||||||||||||||
716 | { | - | ||||||||||||||||||||||||
717 | QGraphicsAnchorLayout * const q = q_func(); | - | ||||||||||||||||||||||||
718 | Graph<AnchorVertex, AnchorData> &g = graph[orientation]; | - | ||||||||||||||||||||||||
719 | - | |||||||||||||||||||||||||
720 | - | |||||||||||||||||||||||||
721 | QStack<AnchorVertex *> stack; | - | ||||||||||||||||||||||||
722 | stack.push(layoutFirstVertex[orientation]); | - | ||||||||||||||||||||||||
723 | QSet<AnchorVertex *> visited; | - | ||||||||||||||||||||||||
724 | - | |||||||||||||||||||||||||
725 | while (!stack.isEmpty()
| 0 | ||||||||||||||||||||||||
726 | AnchorVertex *v = stack.pop(); | - | ||||||||||||||||||||||||
727 | visited.insert(v); | - | ||||||||||||||||||||||||
728 | - | |||||||||||||||||||||||||
729 | - | |||||||||||||||||||||||||
730 | - | |||||||||||||||||||||||||
731 | - | |||||||||||||||||||||||||
732 | QList<AnchorVertex *> adjacents = g.adjacentVertices(v); | - | ||||||||||||||||||||||||
733 | int index = 0; | - | ||||||||||||||||||||||||
734 | - | |||||||||||||||||||||||||
735 | while (index < adjacents.count()
| 0 | ||||||||||||||||||||||||
736 | AnchorVertex *next = adjacents.at(index); | - | ||||||||||||||||||||||||
737 | index++; | - | ||||||||||||||||||||||||
738 | - | |||||||||||||||||||||||||
739 | AnchorData *data = g.edgeData(v, next); | - | ||||||||||||||||||||||||
740 | const bool bothLayoutVertices = v->m_item == q
| 0 | ||||||||||||||||||||||||
741 | const bool zeroSized = !data->minSize
| 0 | ||||||||||||||||||||||||
742 | - | |||||||||||||||||||||||||
743 | if (!bothLayoutVertices
| 0 | ||||||||||||||||||||||||
744 | - | |||||||||||||||||||||||||
745 | - | |||||||||||||||||||||||||
746 | - | |||||||||||||||||||||||||
747 | AnchorVertexPair *newV = new AnchorVertexPair(v, next, data); | - | ||||||||||||||||||||||||
748 | simplifiedVertices[orientation].append(newV); | - | ||||||||||||||||||||||||
749 | - | |||||||||||||||||||||||||
750 | - | |||||||||||||||||||||||||
751 | - | |||||||||||||||||||||||||
752 | const QList<AnchorVertex *> &vAdjacents = g.adjacentVertices(v); | - | ||||||||||||||||||||||||
753 | const QList<AnchorVertex *> &nextAdjacents = g.adjacentVertices(next); | - | ||||||||||||||||||||||||
754 | - | |||||||||||||||||||||||||
755 | for (int i = 0; i < vAdjacents.count()
| 0 | ||||||||||||||||||||||||
756 | AnchorVertex *adjacent = vAdjacents.at(i); | - | ||||||||||||||||||||||||
757 | if (adjacent != next
| 0 | ||||||||||||||||||||||||
758 | AnchorData *ad = g.edgeData(v, adjacent); | - | ||||||||||||||||||||||||
759 | newV->m_firstAnchors.append(ad); | - | ||||||||||||||||||||||||
760 | } never executed: end of block | 0 | ||||||||||||||||||||||||
761 | } never executed: end of block | 0 | ||||||||||||||||||||||||
762 | - | |||||||||||||||||||||||||
763 | for (int i = 0; i < nextAdjacents.count()
| 0 | ||||||||||||||||||||||||
764 | AnchorVertex *adjacent = nextAdjacents.at(i); | - | ||||||||||||||||||||||||
765 | if (adjacent != v
| 0 | ||||||||||||||||||||||||
766 | AnchorData *ad = g.edgeData(next, adjacent); | - | ||||||||||||||||||||||||
767 | newV->m_secondAnchors.append(ad); | - | ||||||||||||||||||||||||
768 | - | |||||||||||||||||||||||||
769 | - | |||||||||||||||||||||||||
770 | - | |||||||||||||||||||||||||
771 | if (!adjacents.contains(adjacent)
| 0 | ||||||||||||||||||||||||
772 | adjacents.append(adjacent); never executed: adjacents.append(adjacent); | 0 | ||||||||||||||||||||||||
773 | } never executed: end of block | 0 | ||||||||||||||||||||||||
774 | } never executed: end of block | 0 | ||||||||||||||||||||||||
775 | - | |||||||||||||||||||||||||
776 | - | |||||||||||||||||||||||||
777 | - | |||||||||||||||||||||||||
778 | bool feasible = replaceVertex(orientation, v, newV, newV->m_firstAnchors); | - | ||||||||||||||||||||||||
779 | feasible &= replaceVertex(orientation, next, newV, newV->m_secondAnchors); | - | ||||||||||||||||||||||||
780 | - | |||||||||||||||||||||||||
781 | - | |||||||||||||||||||||||||
782 | AnchorVertex *layoutVertex = 0; | - | ||||||||||||||||||||||||
783 | if (v->m_item == q
| 0 | ||||||||||||||||||||||||
784 | layoutVertex = v; never executed: layoutVertex = v; | 0 | ||||||||||||||||||||||||
785 | else if (next->m_item == q
| 0 | ||||||||||||||||||||||||
786 | layoutVertex = next; never executed: layoutVertex = next; | 0 | ||||||||||||||||||||||||
787 | - | |||||||||||||||||||||||||
788 | if (layoutVertex
| 0 | ||||||||||||||||||||||||
789 | - | |||||||||||||||||||||||||
790 | newV->m_item = q; | - | ||||||||||||||||||||||||
791 | changeLayoutVertex(orientation, layoutVertex, newV); | - | ||||||||||||||||||||||||
792 | } never executed: end of block | 0 | ||||||||||||||||||||||||
793 | - | |||||||||||||||||||||||||
794 | g.takeEdge(v, next); | - | ||||||||||||||||||||||||
795 | - | |||||||||||||||||||||||||
796 | - | |||||||||||||||||||||||||
797 | if (!feasible
| 0 | ||||||||||||||||||||||||
798 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
799 | - | |||||||||||||||||||||||||
800 | v = newV; | - | ||||||||||||||||||||||||
801 | visited.insert(newV); | - | ||||||||||||||||||||||||
802 | - | |||||||||||||||||||||||||
803 | } never executed: else if (!visited.contains(next)end of block
| 0 | ||||||||||||||||||||||||
804 | - | |||||||||||||||||||||||||
805 | - | |||||||||||||||||||||||||
806 | stack.push(next); | - | ||||||||||||||||||||||||
807 | } never executed: end of block | 0 | ||||||||||||||||||||||||
808 | } never executed: end of block | 0 | ||||||||||||||||||||||||
809 | } never executed: end of block | 0 | ||||||||||||||||||||||||
810 | - | |||||||||||||||||||||||||
811 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
812 | } | - | ||||||||||||||||||||||||
813 | bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutPrivate::Orientation orientation, | - | ||||||||||||||||||||||||
814 | bool *feasible) | - | ||||||||||||||||||||||||
815 | { | - | ||||||||||||||||||||||||
816 | QGraphicsAnchorLayout * const q = q_func(); | - | ||||||||||||||||||||||||
817 | Graph<AnchorVertex, AnchorData> &g = graph[orientation]; | - | ||||||||||||||||||||||||
818 | - | |||||||||||||||||||||||||
819 | QSet<AnchorVertex *> visited; | - | ||||||||||||||||||||||||
820 | QStack<QPair<AnchorVertex *, AnchorVertex *> > stack; | - | ||||||||||||||||||||||||
821 | stack.push(qMakePair(static_cast<AnchorVertex *>(0), layoutFirstVertex[orientation])); | - | ||||||||||||||||||||||||
822 | QVector<AnchorVertex*> candidates; | - | ||||||||||||||||||||||||
823 | - | |||||||||||||||||||||||||
824 | - | |||||||||||||||||||||||||
825 | - | |||||||||||||||||||||||||
826 | while (!stack.isEmpty()
| 0 | ||||||||||||||||||||||||
827 | QPair<AnchorVertex *, AnchorVertex *> pair = stack.pop(); | - | ||||||||||||||||||||||||
828 | AnchorVertex *beforeSequence = pair.first; | - | ||||||||||||||||||||||||
829 | AnchorVertex *v = pair.second; | - | ||||||||||||||||||||||||
830 | const QList<AnchorVertex *> &adjacents = g.adjacentVertices(v); | - | ||||||||||||||||||||||||
831 | const bool isLayoutVertex = v->m_item == q; | - | ||||||||||||||||||||||||
832 | AnchorVertex *afterSequence = v; | - | ||||||||||||||||||||||||
833 | bool endOfSequence = false; | - | ||||||||||||||||||||||||
834 | - | |||||||||||||||||||||||||
835 | - | |||||||||||||||||||||||||
836 | - | |||||||||||||||||||||||||
837 | - | |||||||||||||||||||||||||
838 | - | |||||||||||||||||||||||||
839 | - | |||||||||||||||||||||||||
840 | endOfSequence = isLayoutVertex
| 0 | ||||||||||||||||||||||||
841 | - | |||||||||||||||||||||||||
842 | if (!endOfSequence
| 0 | ||||||||||||||||||||||||
843 | AnchorVertex *after; | - | ||||||||||||||||||||||||
844 | if (candidates.isEmpty()
| 0 | ||||||||||||||||||||||||
845 | after = (beforeSequence == adjacents.last()
never executed: after = (beforeSequence == adjacents.last() ? adjacents.first() : adjacents.last()); | 0 | ||||||||||||||||||||||||
846 | else | - | ||||||||||||||||||||||||
847 | after = (candidates.last() == adjacents.last()
never executed: after = (candidates.last() == adjacents.last() ? adjacents.first() : adjacents.last()); | 0 | ||||||||||||||||||||||||
848 | - | |||||||||||||||||||||||||
849 | - | |||||||||||||||||||||||||
850 | - | |||||||||||||||||||||||||
851 | ((!(!candidates.contains(after))) ? qt_assert("!candidates.contains(after)",__FILE__,1081) : qt_noop()); | - | ||||||||||||||||||||||||
852 | - | |||||||||||||||||||||||||
853 | const AnchorData *data = g.edgeData(v, after); | - | ||||||||||||||||||||||||
854 | ((!(data)) ? qt_assert("data",__FILE__,1084) : qt_noop()); | - | ||||||||||||||||||||||||
855 | const bool cycleFound = visited.contains(after); | - | ||||||||||||||||||||||||
856 | - | |||||||||||||||||||||||||
857 | - | |||||||||||||||||||||||||
858 | endOfSequence = cycleFound
| 0 | ||||||||||||||||||||||||
859 | - | |||||||||||||||||||||||||
860 | if (!endOfSequence
| 0 | ||||||||||||||||||||||||
861 | - | |||||||||||||||||||||||||
862 | - | |||||||||||||||||||||||||
863 | candidates.append(v); | - | ||||||||||||||||||||||||
864 | } never executed: else if (cycleFoundend of block
| 0 | ||||||||||||||||||||||||
865 | afterSequence = after; | - | ||||||||||||||||||||||||
866 | candidates.append(v); | - | ||||||||||||||||||||||||
867 | } never executed: end of block | 0 | ||||||||||||||||||||||||
868 | } never executed: end of block | 0 | ||||||||||||||||||||||||
869 | - | |||||||||||||||||||||||||
870 | - | |||||||||||||||||||||||||
871 | - | |||||||||||||||||||||||||
872 | - | |||||||||||||||||||||||||
873 | for (int i = 0; i < adjacents.count()
| 0 | ||||||||||||||||||||||||
874 | AnchorVertex *next = adjacents.at(i); | - | ||||||||||||||||||||||||
875 | if (visited.contains(next)
| 0 | ||||||||||||||||||||||||
876 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
877 | - | |||||||||||||||||||||||||
878 | - | |||||||||||||||||||||||||
879 | - | |||||||||||||||||||||||||
880 | - | |||||||||||||||||||||||||
881 | - | |||||||||||||||||||||||||
882 | if (endOfSequence
| 0 | ||||||||||||||||||||||||
883 | stack.push(qMakePair(v, next)); never executed: stack.push(qMakePair(v, next)); | 0 | ||||||||||||||||||||||||
884 | else | - | ||||||||||||||||||||||||
885 | stack.push(qMakePair(beforeSequence, next)); never executed: stack.push(qMakePair(beforeSequence, next)); | 0 | ||||||||||||||||||||||||
886 | } | - | ||||||||||||||||||||||||
887 | - | |||||||||||||||||||||||||
888 | visited.insert(v); | - | ||||||||||||||||||||||||
889 | - | |||||||||||||||||||||||||
890 | if (!endOfSequence
| 0 | ||||||||||||||||||||||||
891 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
892 | - | |||||||||||||||||||||||||
893 | - | |||||||||||||||||||||||||
894 | - | |||||||||||||||||||||||||
895 | - | |||||||||||||||||||||||||
896 | - | |||||||||||||||||||||||||
897 | - | |||||||||||||||||||||||||
898 | - | |||||||||||||||||||||||||
899 | const AnchorData *firstAnchor = g.edgeData(beforeSequence, candidates.first()); | - | ||||||||||||||||||||||||
900 | if (firstAnchor->isCenterAnchor
| 0 | ||||||||||||||||||||||||
901 | beforeSequence = candidates.first(); | - | ||||||||||||||||||||||||
902 | candidates.remove(0); | - | ||||||||||||||||||||||||
903 | - | |||||||||||||||||||||||||
904 | - | |||||||||||||||||||||||||
905 | if (candidates.isEmpty()
| 0 | ||||||||||||||||||||||||
906 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
907 | } never executed: end of block | 0 | ||||||||||||||||||||||||
908 | - | |||||||||||||||||||||||||
909 | const AnchorData *lastAnchor = g.edgeData(candidates.last(), afterSequence); | - | ||||||||||||||||||||||||
910 | if (lastAnchor->isCenterAnchor
| 0 | ||||||||||||||||||||||||
911 | afterSequence = candidates.last(); | - | ||||||||||||||||||||||||
912 | candidates.remove(candidates.count() - 1); | - | ||||||||||||||||||||||||
913 | - | |||||||||||||||||||||||||
914 | if (candidates.isEmpty()
| 0 | ||||||||||||||||||||||||
915 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
916 | } never executed: end of block | 0 | ||||||||||||||||||||||||
917 | - | |||||||||||||||||||||||||
918 | - | |||||||||||||||||||||||||
919 | - | |||||||||||||||||||||||||
920 | - | |||||||||||||||||||||||||
921 | - | |||||||||||||||||||||||||
922 | AnchorData *sequence = createSequence(&g, beforeSequence, candidates, afterSequence); | - | ||||||||||||||||||||||||
923 | - | |||||||||||||||||||||||||
924 | - | |||||||||||||||||||||||||
925 | - | |||||||||||||||||||||||||
926 | bool newFeasible; | - | ||||||||||||||||||||||||
927 | AnchorData *newAnchor = addAnchorMaybeParallel(sequence, &newFeasible); | - | ||||||||||||||||||||||||
928 | - | |||||||||||||||||||||||||
929 | if (!newFeasible
| 0 | ||||||||||||||||||||||||
930 | *feasible = false; | - | ||||||||||||||||||||||||
931 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
932 | } | - | ||||||||||||||||||||||||
933 | - | |||||||||||||||||||||||||
934 | - | |||||||||||||||||||||||||
935 | - | |||||||||||||||||||||||||
936 | - | |||||||||||||||||||||||||
937 | - | |||||||||||||||||||||||||
938 | if (newAnchor != sequence
| 0 | ||||||||||||||||||||||||
939 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
940 | - | |||||||||||||||||||||||||
941 | - | |||||||||||||||||||||||||
942 | - | |||||||||||||||||||||||||
943 | candidates.clear(); | - | ||||||||||||||||||||||||
944 | } never executed: end of block | 0 | ||||||||||||||||||||||||
945 | - | |||||||||||||||||||||||||
946 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
947 | } | - | ||||||||||||||||||||||||
948 | - | |||||||||||||||||||||||||
949 | void QGraphicsAnchorLayoutPrivate::restoreSimplifiedAnchor(AnchorData *edge) | - | ||||||||||||||||||||||||
950 | { | - | ||||||||||||||||||||||||
951 | - | |||||||||||||||||||||||||
952 | - | |||||||||||||||||||||||||
953 | - | |||||||||||||||||||||||||
954 | - | |||||||||||||||||||||||||
955 | - | |||||||||||||||||||||||||
956 | - | |||||||||||||||||||||||||
957 | - | |||||||||||||||||||||||||
958 | Graph<AnchorVertex, AnchorData> &g = graph[edge->orientation]; | - | ||||||||||||||||||||||||
959 | - | |||||||||||||||||||||||||
960 | if (edge->type == AnchorData::Normal
| 0 | ||||||||||||||||||||||||
961 | g.createEdge(edge->from, edge->to, edge); | - | ||||||||||||||||||||||||
962 | - | |||||||||||||||||||||||||
963 | } never executed: else if (edge->type == AnchorData::Sequentialend of block
| 0 | ||||||||||||||||||||||||
964 | SequentialAnchorData *sequence = static_cast<SequentialAnchorData *>(edge); | - | ||||||||||||||||||||||||
965 | - | |||||||||||||||||||||||||
966 | for (int i = 0; i < sequence->m_edges.count()
| 0 | ||||||||||||||||||||||||
967 | AnchorData *data = sequence->m_edges.at(i); | - | ||||||||||||||||||||||||
968 | restoreSimplifiedAnchor(data); | - | ||||||||||||||||||||||||
969 | } never executed: end of block | 0 | ||||||||||||||||||||||||
970 | - | |||||||||||||||||||||||||
971 | delete sequence; | - | ||||||||||||||||||||||||
972 | - | |||||||||||||||||||||||||
973 | } never executed: else if (edge->type == AnchorData::Parallelend of block
| 0 | ||||||||||||||||||||||||
974 | - | |||||||||||||||||||||||||
975 | - | |||||||||||||||||||||||||
976 | - | |||||||||||||||||||||||||
977 | - | |||||||||||||||||||||||||
978 | if (anchorsFromSimplifiedVertices[edge->orientation].contains(edge)
| 0 | ||||||||||||||||||||||||
979 | return; never executed: return; | 0 | ||||||||||||||||||||||||
980 | - | |||||||||||||||||||||||||
981 | ParallelAnchorData* parallel = static_cast<ParallelAnchorData*>(edge); | - | ||||||||||||||||||||||||
982 | restoreSimplifiedConstraints(parallel); | - | ||||||||||||||||||||||||
983 | - | |||||||||||||||||||||||||
984 | - | |||||||||||||||||||||||||
985 | - | |||||||||||||||||||||||||
986 | - | |||||||||||||||||||||||||
987 | ((!(parallel->firstEdge->type == AnchorData::Sequential || parallel->secondEdge->type == AnchorData::Sequential)) ? qt_assert("parallel->firstEdge->type == AnchorData::Sequential || parallel->secondEdge->type == AnchorData::Sequential", | - | ||||||||||||||||||||||||
988 | __FILE__ | - | ||||||||||||||||||||||||
989 | , | - | ||||||||||||||||||||||||
990 | 1218 | - | ||||||||||||||||||||||||
991 | ) : qt_noop()) | - | ||||||||||||||||||||||||
992 | ; | - | ||||||||||||||||||||||||
993 | restoreSimplifiedAnchor(parallel->firstEdge); | - | ||||||||||||||||||||||||
994 | restoreSimplifiedAnchor(parallel->secondEdge); | - | ||||||||||||||||||||||||
995 | - | |||||||||||||||||||||||||
996 | delete parallel; | - | ||||||||||||||||||||||||
997 | } never executed: end of block | 0 | ||||||||||||||||||||||||
998 | } never executed: end of block | 0 | ||||||||||||||||||||||||
999 | - | |||||||||||||||||||||||||
1000 | void QGraphicsAnchorLayoutPrivate::restoreSimplifiedConstraints(ParallelAnchorData *parallel) | - | ||||||||||||||||||||||||
1001 | { | - | ||||||||||||||||||||||||
1002 | if (!parallel->isCenterAnchor
| 0 | ||||||||||||||||||||||||
1003 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1004 | - | |||||||||||||||||||||||||
1005 | for (int i = 0; i < parallel->m_firstConstraints.count()
| 0 | ||||||||||||||||||||||||
1006 | QSimplexConstraint *c = parallel->m_firstConstraints.at(i); | - | ||||||||||||||||||||||||
1007 | qreal v = c->variables[parallel]; | - | ||||||||||||||||||||||||
1008 | c->variables.remove(parallel); | - | ||||||||||||||||||||||||
1009 | c->variables.insert(parallel->firstEdge, v); | - | ||||||||||||||||||||||||
1010 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1011 | - | |||||||||||||||||||||||||
1012 | - | |||||||||||||||||||||||||
1013 | - | |||||||||||||||||||||||||
1014 | const bool needsReverse = !parallel->secondForward(); | - | ||||||||||||||||||||||||
1015 | - | |||||||||||||||||||||||||
1016 | for (int i = 0; i < parallel->m_secondConstraints.count()
| 0 | ||||||||||||||||||||||||
1017 | QSimplexConstraint *c = parallel->m_secondConstraints.at(i); | - | ||||||||||||||||||||||||
1018 | qreal v = c->variables[parallel]; | - | ||||||||||||||||||||||||
1019 | if (needsReverse
| 0 | ||||||||||||||||||||||||
1020 | v *= -1; never executed: v *= -1; | 0 | ||||||||||||||||||||||||
1021 | c->variables.remove(parallel); | - | ||||||||||||||||||||||||
1022 | c->variables.insert(parallel->secondEdge, v); | - | ||||||||||||||||||||||||
1023 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1024 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1025 | - | |||||||||||||||||||||||||
1026 | void QGraphicsAnchorLayoutPrivate::restoreSimplifiedGraph(Orientation orientation) | - | ||||||||||||||||||||||||
1027 | { | - | ||||||||||||||||||||||||
1028 | - | |||||||||||||||||||||||||
1029 | - | |||||||||||||||||||||||||
1030 | - | |||||||||||||||||||||||||
1031 | - | |||||||||||||||||||||||||
1032 | - | |||||||||||||||||||||||||
1033 | - | |||||||||||||||||||||||||
1034 | Graph<AnchorVertex, AnchorData> &g = graph[orientation]; | - | ||||||||||||||||||||||||
1035 | QList<QPair<AnchorVertex*, AnchorVertex*> > connections = g.connections(); | - | ||||||||||||||||||||||||
1036 | for (int i = 0; i < connections.count()
| 0 | ||||||||||||||||||||||||
1037 | AnchorVertex *v1 = connections.at(i).first; | - | ||||||||||||||||||||||||
1038 | AnchorVertex *v2 = connections.at(i).second; | - | ||||||||||||||||||||||||
1039 | AnchorData *edge = g.edgeData(v1, v2); | - | ||||||||||||||||||||||||
1040 | - | |||||||||||||||||||||||||
1041 | - | |||||||||||||||||||||||||
1042 | - | |||||||||||||||||||||||||
1043 | if (edge->type == AnchorData::Sequential
| 0 | ||||||||||||||||||||||||
1044 | || (edge->type == AnchorData::Parallel
| 0 | ||||||||||||||||||||||||
1045 | !anchorsFromSimplifiedVertices[orientation].contains(edge)
| 0 | ||||||||||||||||||||||||
1046 | - | |||||||||||||||||||||||||
1047 | g.takeEdge(v1, v2); | - | ||||||||||||||||||||||||
1048 | restoreSimplifiedAnchor(edge); | - | ||||||||||||||||||||||||
1049 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1050 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1051 | - | |||||||||||||||||||||||||
1052 | restoreVertices(orientation); | - | ||||||||||||||||||||||||
1053 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1054 | - | |||||||||||||||||||||||||
1055 | void QGraphicsAnchorLayoutPrivate::restoreVertices(Orientation orientation) | - | ||||||||||||||||||||||||
1056 | { | - | ||||||||||||||||||||||||
1057 | QGraphicsAnchorLayout * const q = q_func(); | - | ||||||||||||||||||||||||
1058 | - | |||||||||||||||||||||||||
1059 | Graph<AnchorVertex, AnchorData> &g = graph[orientation]; | - | ||||||||||||||||||||||||
1060 | QList<AnchorVertexPair *> &toRestore = simplifiedVertices[orientation]; | - | ||||||||||||||||||||||||
1061 | QList<AnchorData *> ¶llelAnchors = anchorsFromSimplifiedVertices[orientation]; | - | ||||||||||||||||||||||||
1062 | - | |||||||||||||||||||||||||
1063 | for (int i = parallelAnchors.count() - 1; i >= 0
| 0 | ||||||||||||||||||||||||
1064 | ParallelAnchorData *parallel = static_cast<ParallelAnchorData *>(parallelAnchors.at(i)); | - | ||||||||||||||||||||||||
1065 | restoreSimplifiedConstraints(parallel); | - | ||||||||||||||||||||||||
1066 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1067 | - | |||||||||||||||||||||||||
1068 | - | |||||||||||||||||||||||||
1069 | - | |||||||||||||||||||||||||
1070 | for (int i = toRestore.count() - 1; i >= 0
| 0 | ||||||||||||||||||||||||
1071 | AnchorVertexPair *pair = toRestore.at(i); | - | ||||||||||||||||||||||||
1072 | QList<AnchorVertex *> adjacents = g.adjacentVertices(pair); | - | ||||||||||||||||||||||||
1073 | - | |||||||||||||||||||||||||
1074 | - | |||||||||||||||||||||||||
1075 | - | |||||||||||||||||||||||||
1076 | AnchorVertex *first = pair->m_first; | - | ||||||||||||||||||||||||
1077 | AnchorVertex *second = pair->m_second; | - | ||||||||||||||||||||||||
1078 | g.createEdge(first, second, pair->m_removedAnchor); | - | ||||||||||||||||||||||||
1079 | - | |||||||||||||||||||||||||
1080 | - | |||||||||||||||||||||||||
1081 | for (int j = 0; j < pair->m_firstAnchors.count()
| 0 | ||||||||||||||||||||||||
1082 | AnchorData *ad = pair->m_firstAnchors.at(j); | - | ||||||||||||||||||||||||
1083 | ((!(ad->from == pair || ad->to == pair)) ? qt_assert("ad->from == pair || ad->to == pair",__FILE__,1318) : qt_noop()); | - | ||||||||||||||||||||||||
1084 | - | |||||||||||||||||||||||||
1085 | replaceVertex_helper(ad, pair, first); | - | ||||||||||||||||||||||||
1086 | g.createEdge(ad->from, ad->to, ad); | - | ||||||||||||||||||||||||
1087 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1088 | - | |||||||||||||||||||||||||
1089 | - | |||||||||||||||||||||||||
1090 | for (int j = 0; j < pair->m_secondAnchors.count()
| 0 | ||||||||||||||||||||||||
1091 | AnchorData *ad = pair->m_secondAnchors.at(j); | - | ||||||||||||||||||||||||
1092 | ((!(ad->from == pair || ad->to == pair)) ? qt_assert("ad->from == pair || ad->to == pair",__FILE__,1327) : qt_noop()); | - | ||||||||||||||||||||||||
1093 | - | |||||||||||||||||||||||||
1094 | replaceVertex_helper(ad, pair, second); | - | ||||||||||||||||||||||||
1095 | g.createEdge(ad->from, ad->to, ad); | - | ||||||||||||||||||||||||
1096 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1097 | - | |||||||||||||||||||||||||
1098 | for (int j = 0; j < adjacents.count()
| 0 | ||||||||||||||||||||||||
1099 | g.takeEdge(pair, adjacents.at(j)); | - | ||||||||||||||||||||||||
1100 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1101 | - | |||||||||||||||||||||||||
1102 | - | |||||||||||||||||||||||||
1103 | - | |||||||||||||||||||||||||
1104 | if (pair->m_item == q
| 0 | ||||||||||||||||||||||||
1105 | AnchorVertex *layoutVertex = first->m_item == q
| 0 | ||||||||||||||||||||||||
1106 | ((!(layoutVertex->m_item == q)) ? qt_assert("layoutVertex->m_item == q",__FILE__,1341) : qt_noop()); | - | ||||||||||||||||||||||||
1107 | changeLayoutVertex(orientation, pair, layoutVertex); | - | ||||||||||||||||||||||||
1108 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1109 | - | |||||||||||||||||||||||||
1110 | delete pair; | - | ||||||||||||||||||||||||
1111 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1112 | qDeleteAll(parallelAnchors); | - | ||||||||||||||||||||||||
1113 | parallelAnchors.clear(); | - | ||||||||||||||||||||||||
1114 | toRestore.clear(); | - | ||||||||||||||||||||||||
1115 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1116 | - | |||||||||||||||||||||||||
1117 | QGraphicsAnchorLayoutPrivate::Orientation | - | ||||||||||||||||||||||||
1118 | QGraphicsAnchorLayoutPrivate::edgeOrientation(Qt::AnchorPoint edge) | - | ||||||||||||||||||||||||
1119 | { | - | ||||||||||||||||||||||||
1120 | return never executed: edge > Qt::AnchorRightreturn edge > Qt::AnchorRight ? Vertical : Horizontal;
never executed: return edge > Qt::AnchorRight ? Vertical : Horizontal; | 0 | ||||||||||||||||||||||||
1121 | } | - | ||||||||||||||||||||||||
1122 | void QGraphicsAnchorLayoutPrivate::createLayoutEdges() | - | ||||||||||||||||||||||||
1123 | { | - | ||||||||||||||||||||||||
1124 | QGraphicsAnchorLayout * const q = q_func(); | - | ||||||||||||||||||||||||
1125 | QGraphicsLayoutItem *layout = q; | - | ||||||||||||||||||||||||
1126 | - | |||||||||||||||||||||||||
1127 | - | |||||||||||||||||||||||||
1128 | AnchorData *data = new AnchorData; | - | ||||||||||||||||||||||||
1129 | addAnchor_helper(layout, Qt::AnchorLeft, layout, | - | ||||||||||||||||||||||||
1130 | Qt::AnchorRight, data); | - | ||||||||||||||||||||||||
1131 | data->maxSize = ((1<<24)-1); | - | ||||||||||||||||||||||||
1132 | - | |||||||||||||||||||||||||
1133 | - | |||||||||||||||||||||||||
1134 | layoutFirstVertex[Horizontal] = internalVertex(layout, Qt::AnchorLeft); | - | ||||||||||||||||||||||||
1135 | layoutCentralVertex[Horizontal] = 0; | - | ||||||||||||||||||||||||
1136 | layoutLastVertex[Horizontal] = internalVertex(layout, Qt::AnchorRight); | - | ||||||||||||||||||||||||
1137 | - | |||||||||||||||||||||||||
1138 | - | |||||||||||||||||||||||||
1139 | data = new AnchorData; | - | ||||||||||||||||||||||||
1140 | addAnchor_helper(layout, Qt::AnchorTop, layout, | - | ||||||||||||||||||||||||
1141 | Qt::AnchorBottom, data); | - | ||||||||||||||||||||||||
1142 | data->maxSize = ((1<<24)-1); | - | ||||||||||||||||||||||||
1143 | - | |||||||||||||||||||||||||
1144 | - | |||||||||||||||||||||||||
1145 | layoutFirstVertex[Vertical] = internalVertex(layout, Qt::AnchorTop); | - | ||||||||||||||||||||||||
1146 | layoutCentralVertex[Vertical] = 0; | - | ||||||||||||||||||||||||
1147 | layoutLastVertex[Vertical] = internalVertex(layout, Qt::AnchorBottom); | - | ||||||||||||||||||||||||
1148 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1149 | - | |||||||||||||||||||||||||
1150 | void QGraphicsAnchorLayoutPrivate::deleteLayoutEdges() | - | ||||||||||||||||||||||||
1151 | { | - | ||||||||||||||||||||||||
1152 | QGraphicsAnchorLayout * const q = q_func(); | - | ||||||||||||||||||||||||
1153 | - | |||||||||||||||||||||||||
1154 | ((!(!internalVertex(q, Qt::AnchorHorizontalCenter))) ? qt_assert("!internalVertex(q, Qt::AnchorHorizontalCenter)",__FILE__,1399) : qt_noop()); | - | ||||||||||||||||||||||||
1155 | ((!(!internalVertex(q, Qt::AnchorVerticalCenter))) ? qt_assert("!internalVertex(q, Qt::AnchorVerticalCenter)",__FILE__,1400) : qt_noop()); | - | ||||||||||||||||||||||||
1156 | - | |||||||||||||||||||||||||
1157 | removeAnchor_helper(internalVertex(q, Qt::AnchorLeft), | - | ||||||||||||||||||||||||
1158 | internalVertex(q, Qt::AnchorRight)); | - | ||||||||||||||||||||||||
1159 | removeAnchor_helper(internalVertex(q, Qt::AnchorTop), | - | ||||||||||||||||||||||||
1160 | internalVertex(q, Qt::AnchorBottom)); | - | ||||||||||||||||||||||||
1161 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1162 | - | |||||||||||||||||||||||||
1163 | void QGraphicsAnchorLayoutPrivate::createItemEdges(QGraphicsLayoutItem *item) | - | ||||||||||||||||||||||||
1164 | { | - | ||||||||||||||||||||||||
1165 | items.append(item); | - | ||||||||||||||||||||||||
1166 | - | |||||||||||||||||||||||||
1167 | - | |||||||||||||||||||||||||
1168 | - | |||||||||||||||||||||||||
1169 | AnchorData *data = new AnchorData; | - | ||||||||||||||||||||||||
1170 | addAnchor_helper(item, Qt::AnchorLeft, item, Qt::AnchorRight, data); | - | ||||||||||||||||||||||||
1171 | data->refreshSizeHints(); | - | ||||||||||||||||||||||||
1172 | - | |||||||||||||||||||||||||
1173 | data = new AnchorData; | - | ||||||||||||||||||||||||
1174 | addAnchor_helper(item, Qt::AnchorTop, item, Qt::AnchorBottom, data); | - | ||||||||||||||||||||||||
1175 | data->refreshSizeHints(); | - | ||||||||||||||||||||||||
1176 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1177 | void QGraphicsAnchorLayoutPrivate::createCenterAnchors( | - | ||||||||||||||||||||||||
1178 | QGraphicsLayoutItem *item, Qt::AnchorPoint centerEdge) | - | ||||||||||||||||||||||||
1179 | { | - | ||||||||||||||||||||||||
1180 | QGraphicsAnchorLayout * const q = q_func(); | - | ||||||||||||||||||||||||
1181 | - | |||||||||||||||||||||||||
1182 | Orientation orientation; | - | ||||||||||||||||||||||||
1183 | switch (centerEdge) { | - | ||||||||||||||||||||||||
1184 | case never executed: Qt::AnchorHorizontalCenter:case Qt::AnchorHorizontalCenter: never executed: case Qt::AnchorHorizontalCenter: | 0 | ||||||||||||||||||||||||
1185 | orientation = Horizontal; | - | ||||||||||||||||||||||||
1186 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1187 | case never executed: Qt::AnchorVerticalCenter:case Qt::AnchorVerticalCenter: never executed: case Qt::AnchorVerticalCenter: | 0 | ||||||||||||||||||||||||
1188 | orientation = Vertical; | - | ||||||||||||||||||||||||
1189 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1190 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||
1191 | - | |||||||||||||||||||||||||
1192 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1193 | } | - | ||||||||||||||||||||||||
1194 | - | |||||||||||||||||||||||||
1195 | - | |||||||||||||||||||||||||
1196 | if (internalVertex(item, centerEdge)
| 0 | ||||||||||||||||||||||||
1197 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1198 | - | |||||||||||||||||||||||||
1199 | - | |||||||||||||||||||||||||
1200 | Qt::AnchorPoint firstEdge; | - | ||||||||||||||||||||||||
1201 | Qt::AnchorPoint lastEdge; | - | ||||||||||||||||||||||||
1202 | - | |||||||||||||||||||||||||
1203 | if (orientation == Horizontal
| 0 | ||||||||||||||||||||||||
1204 | firstEdge = Qt::AnchorLeft; | - | ||||||||||||||||||||||||
1205 | lastEdge = Qt::AnchorRight; | - | ||||||||||||||||||||||||
1206 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1207 | firstEdge = Qt::AnchorTop; | - | ||||||||||||||||||||||||
1208 | lastEdge = Qt::AnchorBottom; | - | ||||||||||||||||||||||||
1209 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1210 | - | |||||||||||||||||||||||||
1211 | AnchorVertex *first = internalVertex(item, firstEdge); | - | ||||||||||||||||||||||||
1212 | AnchorVertex *last = internalVertex(item, lastEdge); | - | ||||||||||||||||||||||||
1213 | ((!(first && last)) ? qt_assert("first && last",__FILE__,1470) : qt_noop()); | - | ||||||||||||||||||||||||
1214 | - | |||||||||||||||||||||||||
1215 | - | |||||||||||||||||||||||||
1216 | QSimplexConstraint *c = new QSimplexConstraint; | - | ||||||||||||||||||||||||
1217 | - | |||||||||||||||||||||||||
1218 | AnchorData *data = new AnchorData; | - | ||||||||||||||||||||||||
1219 | c->variables.insert(data, 1.0); | - | ||||||||||||||||||||||||
1220 | addAnchor_helper(item, firstEdge, item, centerEdge, data); | - | ||||||||||||||||||||||||
1221 | data->isCenterAnchor = true; | - | ||||||||||||||||||||||||
1222 | data->dependency = AnchorData::Master; | - | ||||||||||||||||||||||||
1223 | data->refreshSizeHints(); | - | ||||||||||||||||||||||||
1224 | - | |||||||||||||||||||||||||
1225 | data = new AnchorData; | - | ||||||||||||||||||||||||
1226 | c->variables.insert(data, -1.0); | - | ||||||||||||||||||||||||
1227 | addAnchor_helper(item, centerEdge, item, lastEdge, data); | - | ||||||||||||||||||||||||
1228 | data->isCenterAnchor = true; | - | ||||||||||||||||||||||||
1229 | data->dependency = AnchorData::Slave; | - | ||||||||||||||||||||||||
1230 | data->refreshSizeHints(); | - | ||||||||||||||||||||||||
1231 | - | |||||||||||||||||||||||||
1232 | itemCenterConstraints[orientation].append(c); | - | ||||||||||||||||||||||||
1233 | - | |||||||||||||||||||||||||
1234 | - | |||||||||||||||||||||||||
1235 | removeAnchor_helper(first, last); | - | ||||||||||||||||||||||||
1236 | - | |||||||||||||||||||||||||
1237 | if (item == q
| 0 | ||||||||||||||||||||||||
1238 | layoutCentralVertex[orientation] = internalVertex(q, centerEdge); | - | ||||||||||||||||||||||||
1239 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1240 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1241 | - | |||||||||||||||||||||||||
1242 | void QGraphicsAnchorLayoutPrivate::removeCenterAnchors( | - | ||||||||||||||||||||||||
1243 | QGraphicsLayoutItem *item, Qt::AnchorPoint centerEdge, | - | ||||||||||||||||||||||||
1244 | bool substitute) | - | ||||||||||||||||||||||||
1245 | { | - | ||||||||||||||||||||||||
1246 | QGraphicsAnchorLayout * const q = q_func(); | - | ||||||||||||||||||||||||
1247 | - | |||||||||||||||||||||||||
1248 | Orientation orientation; | - | ||||||||||||||||||||||||
1249 | switch (centerEdge) { | - | ||||||||||||||||||||||||
1250 | case never executed: Qt::AnchorHorizontalCenter:case Qt::AnchorHorizontalCenter: never executed: case Qt::AnchorHorizontalCenter: | 0 | ||||||||||||||||||||||||
1251 | orientation = Horizontal; | - | ||||||||||||||||||||||||
1252 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1253 | case never executed: Qt::AnchorVerticalCenter:case Qt::AnchorVerticalCenter: never executed: case Qt::AnchorVerticalCenter: | 0 | ||||||||||||||||||||||||
1254 | orientation = Vertical; | - | ||||||||||||||||||||||||
1255 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1256 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||
1257 | - | |||||||||||||||||||||||||
1258 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1259 | } | - | ||||||||||||||||||||||||
1260 | - | |||||||||||||||||||||||||
1261 | - | |||||||||||||||||||||||||
1262 | Qt::AnchorPoint firstEdge; | - | ||||||||||||||||||||||||
1263 | Qt::AnchorPoint lastEdge; | - | ||||||||||||||||||||||||
1264 | - | |||||||||||||||||||||||||
1265 | if (orientation == Horizontal
| 0 | ||||||||||||||||||||||||
1266 | firstEdge = Qt::AnchorLeft; | - | ||||||||||||||||||||||||
1267 | lastEdge = Qt::AnchorRight; | - | ||||||||||||||||||||||||
1268 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1269 | firstEdge = Qt::AnchorTop; | - | ||||||||||||||||||||||||
1270 | lastEdge = Qt::AnchorBottom; | - | ||||||||||||||||||||||||
1271 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1272 | - | |||||||||||||||||||||||||
1273 | AnchorVertex *center = internalVertex(item, centerEdge); | - | ||||||||||||||||||||||||
1274 | if (!center
| 0 | ||||||||||||||||||||||||
1275 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1276 | AnchorVertex *first = internalVertex(item, firstEdge); | - | ||||||||||||||||||||||||
1277 | - | |||||||||||||||||||||||||
1278 | ((!(first)) ? qt_assert("first",__FILE__,1535) : qt_noop()); | - | ||||||||||||||||||||||||
1279 | ((!(center)) ? qt_assert("center",__FILE__,1536) : qt_noop()); | - | ||||||||||||||||||||||||
1280 | - | |||||||||||||||||||||||||
1281 | Graph<AnchorVertex, AnchorData> &g = graph[orientation]; | - | ||||||||||||||||||||||||
1282 | - | |||||||||||||||||||||||||
1283 | - | |||||||||||||||||||||||||
1284 | AnchorData *oldData = g.edgeData(first, center); | - | ||||||||||||||||||||||||
1285 | - | |||||||||||||||||||||||||
1286 | for (int i = itemCenterConstraints[orientation].count() - 1; i >= 0
| 0 | ||||||||||||||||||||||||
1287 | if (itemCenterConstraints[orientation].at(i)->variables.contains(oldData)
| 0 | ||||||||||||||||||||||||
1288 | delete itemCenterConstraints[orientation].takeAt(i); | - | ||||||||||||||||||||||||
1289 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1290 | } | - | ||||||||||||||||||||||||
1291 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1292 | - | |||||||||||||||||||||||||
1293 | if (substitute
| 0 | ||||||||||||||||||||||||
1294 | - | |||||||||||||||||||||||||
1295 | AnchorData *data = new AnchorData; | - | ||||||||||||||||||||||||
1296 | addAnchor_helper(item, firstEdge, item, lastEdge, data); | - | ||||||||||||||||||||||||
1297 | data->refreshSizeHints(); | - | ||||||||||||||||||||||||
1298 | - | |||||||||||||||||||||||||
1299 | - | |||||||||||||||||||||||||
1300 | removeAnchor_helper(first, center); | - | ||||||||||||||||||||||||
1301 | removeAnchor_helper(center, internalVertex(item, lastEdge)); | - | ||||||||||||||||||||||||
1302 | - | |||||||||||||||||||||||||
1303 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1304 | - | |||||||||||||||||||||||||
1305 | - | |||||||||||||||||||||||||
1306 | QList<AnchorVertex*> adjacents = g.adjacentVertices(center); | - | ||||||||||||||||||||||||
1307 | for (int i = 0; i < adjacents.count()
| 0 | ||||||||||||||||||||||||
1308 | AnchorVertex *v = adjacents.at(i); | - | ||||||||||||||||||||||||
1309 | if (v->m_item != item
| 0 | ||||||||||||||||||||||||
1310 | removeAnchor_helper(center, internalVertex(v->m_item, v->m_edge)); | - | ||||||||||||||||||||||||
1311 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1312 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1313 | - | |||||||||||||||||||||||||
1314 | - | |||||||||||||||||||||||||
1315 | - | |||||||||||||||||||||||||
1316 | removeAnchor_helper(first, internalVertex(item, lastEdge)); | - | ||||||||||||||||||||||||
1317 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1318 | - | |||||||||||||||||||||||||
1319 | if (item == q
| 0 | ||||||||||||||||||||||||
1320 | layoutCentralVertex[orientation] = 0; | - | ||||||||||||||||||||||||
1321 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1322 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1323 | - | |||||||||||||||||||||||||
1324 | - | |||||||||||||||||||||||||
1325 | void QGraphicsAnchorLayoutPrivate::removeCenterConstraints(QGraphicsLayoutItem *item, | - | ||||||||||||||||||||||||
1326 | Orientation orientation) | - | ||||||||||||||||||||||||
1327 | { | - | ||||||||||||||||||||||||
1328 | - | |||||||||||||||||||||||||
1329 | - | |||||||||||||||||||||||||
1330 | - | |||||||||||||||||||||||||
1331 | - | |||||||||||||||||||||||||
1332 | - | |||||||||||||||||||||||||
1333 | AnchorVertex *first = internalVertex(item, orientation == Horizontal ? | - | ||||||||||||||||||||||||
1334 | Qt::AnchorLeft : | - | ||||||||||||||||||||||||
1335 | Qt::AnchorTop); | - | ||||||||||||||||||||||||
1336 | AnchorVertex *center = internalVertex(item, orientation == Horizontal ? | - | ||||||||||||||||||||||||
1337 | Qt::AnchorHorizontalCenter : | - | ||||||||||||||||||||||||
1338 | Qt::AnchorVerticalCenter); | - | ||||||||||||||||||||||||
1339 | - | |||||||||||||||||||||||||
1340 | - | |||||||||||||||||||||||||
1341 | if (!center
| 0 | ||||||||||||||||||||||||
1342 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1343 | - | |||||||||||||||||||||||||
1344 | ((!(first)) ? qt_assert("first",__FILE__,1601) : qt_noop()); | - | ||||||||||||||||||||||||
1345 | AnchorData *internalAnchor = graph[orientation].edgeData(first, center); | - | ||||||||||||||||||||||||
1346 | - | |||||||||||||||||||||||||
1347 | - | |||||||||||||||||||||||||
1348 | for (int i = 0; i < itemCenterConstraints[orientation].size()
| 0 | ||||||||||||||||||||||||
1349 | if (itemCenterConstraints[orientation].at(i)->variables.contains(internalAnchor)
| 0 | ||||||||||||||||||||||||
1350 | delete itemCenterConstraints[orientation].takeAt(i); | - | ||||||||||||||||||||||||
1351 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1352 | } | - | ||||||||||||||||||||||||
1353 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1354 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1355 | QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::addAnchor(QGraphicsLayoutItem *firstItem, | - | ||||||||||||||||||||||||
1356 | Qt::AnchorPoint firstEdge, | - | ||||||||||||||||||||||||
1357 | QGraphicsLayoutItem *secondItem, | - | ||||||||||||||||||||||||
1358 | Qt::AnchorPoint secondEdge, | - | ||||||||||||||||||||||||
1359 | qreal *spacing) | - | ||||||||||||||||||||||||
1360 | { | - | ||||||||||||||||||||||||
1361 | QGraphicsAnchorLayout * const q = q_func(); | - | ||||||||||||||||||||||||
1362 | if ((
| 0 | ||||||||||||||||||||||||
1363 | QMessageLogger(__FILE__, 1633, __PRETTY_FUNCTION__).warning("QGraphicsAnchorLayout::addAnchor(): " | - | ||||||||||||||||||||||||
1364 | "Cannot anchor NULL items"); | - | ||||||||||||||||||||||||
1365 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
1366 | } | - | ||||||||||||||||||||||||
1367 | - | |||||||||||||||||||||||||
1368 | if (firstItem == secondItem
| 0 | ||||||||||||||||||||||||
1369 | QMessageLogger(__FILE__, 1639, __PRETTY_FUNCTION__).warning("QGraphicsAnchorLayout::addAnchor(): " | - | ||||||||||||||||||||||||
1370 | "Cannot anchor the item to itself"); | - | ||||||||||||||||||||||||
1371 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
1372 | } | - | ||||||||||||||||||||||||
1373 | - | |||||||||||||||||||||||||
1374 | if (edgeOrientation(secondEdge) != edgeOrientation(firstEdge)
| 0 | ||||||||||||||||||||||||
1375 | QMessageLogger(__FILE__, 1645, __PRETTY_FUNCTION__).warning("QGraphicsAnchorLayout::addAnchor(): " | - | ||||||||||||||||||||||||
1376 | "Cannot anchor edges of different orientations"); | - | ||||||||||||||||||||||||
1377 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
1378 | } | - | ||||||||||||||||||||||||
1379 | - | |||||||||||||||||||||||||
1380 | const QGraphicsLayoutItem *parentWidget = q->parentLayoutItem(); | - | ||||||||||||||||||||||||
1381 | if (firstItem == parentWidget
| 0 | ||||||||||||||||||||||||
1382 | QMessageLogger(__FILE__, 1652, __PRETTY_FUNCTION__).warning("QGraphicsAnchorLayout::addAnchor(): " | - | ||||||||||||||||||||||||
1383 | "You cannot add the parent of the layout to the layout."); | - | ||||||||||||||||||||||||
1384 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
1385 | } | - | ||||||||||||||||||||||||
1386 | if (firstItem != q
| 0 | ||||||||||||||||||||||||
1387 | createItemEdges(firstItem); | - | ||||||||||||||||||||||||
1388 | addChildLayoutItem(firstItem); | - | ||||||||||||||||||||||||
1389 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1390 | if (secondItem != q
| 0 | ||||||||||||||||||||||||
1391 | createItemEdges(secondItem); | - | ||||||||||||||||||||||||
1392 | addChildLayoutItem(secondItem); | - | ||||||||||||||||||||||||
1393 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1394 | - | |||||||||||||||||||||||||
1395 | - | |||||||||||||||||||||||||
1396 | createCenterAnchors(firstItem, firstEdge); | - | ||||||||||||||||||||||||
1397 | createCenterAnchors(secondItem, secondEdge); | - | ||||||||||||||||||||||||
1398 | - | |||||||||||||||||||||||||
1399 | - | |||||||||||||||||||||||||
1400 | correctEdgeDirection(firstItem, firstEdge, secondItem, secondEdge); | - | ||||||||||||||||||||||||
1401 | - | |||||||||||||||||||||||||
1402 | AnchorData *data = new AnchorData; | - | ||||||||||||||||||||||||
1403 | QGraphicsAnchor *graphicsAnchor = acquireGraphicsAnchor(data); | - | ||||||||||||||||||||||||
1404 | - | |||||||||||||||||||||||||
1405 | addAnchor_helper(firstItem, firstEdge, secondItem, secondEdge, data); | - | ||||||||||||||||||||||||
1406 | - | |||||||||||||||||||||||||
1407 | if (spacing
| 0 | ||||||||||||||||||||||||
1408 | graphicsAnchor->setSpacing(*spacing); | - | ||||||||||||||||||||||||
1409 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1410 | if (firstItem == q
| 0 | ||||||||||||||||||||||||
1411 | || secondItem == q
| 0 | ||||||||||||||||||||||||
1412 | || pickEdge(firstEdge, Horizontal) == Qt::AnchorHorizontalCenter
| 0 | ||||||||||||||||||||||||
1413 | || oppositeEdge(firstEdge) != secondEdge
| 0 | ||||||||||||||||||||||||
1414 | graphicsAnchor->setSpacing(0); | - | ||||||||||||||||||||||||
1415 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1416 | graphicsAnchor->unsetSpacing(); | - | ||||||||||||||||||||||||
1417 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1418 | } | - | ||||||||||||||||||||||||
1419 | - | |||||||||||||||||||||||||
1420 | return never executed: graphicsAnchor;return graphicsAnchor; never executed: return graphicsAnchor; | 0 | ||||||||||||||||||||||||
1421 | } | - | ||||||||||||||||||||||||
1422 | void QGraphicsAnchorLayoutPrivate::addAnchor_helper(QGraphicsLayoutItem *firstItem, | - | ||||||||||||||||||||||||
1423 | Qt::AnchorPoint firstEdge, | - | ||||||||||||||||||||||||
1424 | QGraphicsLayoutItem *secondItem, | - | ||||||||||||||||||||||||
1425 | Qt::AnchorPoint secondEdge, | - | ||||||||||||||||||||||||
1426 | AnchorData *data) | - | ||||||||||||||||||||||||
1427 | { | - | ||||||||||||||||||||||||
1428 | QGraphicsAnchorLayout * const q = q_func(); | - | ||||||||||||||||||||||||
1429 | - | |||||||||||||||||||||||||
1430 | const Orientation orientation = edgeOrientation(firstEdge); | - | ||||||||||||||||||||||||
1431 | - | |||||||||||||||||||||||||
1432 | - | |||||||||||||||||||||||||
1433 | AnchorVertex *v1 = addInternalVertex(firstItem, firstEdge); | - | ||||||||||||||||||||||||
1434 | AnchorVertex *v2 = addInternalVertex(secondItem, secondEdge); | - | ||||||||||||||||||||||||
1435 | - | |||||||||||||||||||||||||
1436 | - | |||||||||||||||||||||||||
1437 | if (graph[orientation].edgeData(v1, v2)
| 0 | ||||||||||||||||||||||||
1438 | removeAnchor_helper(v1, v2); | - | ||||||||||||||||||||||||
1439 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1440 | - | |||||||||||||||||||||||||
1441 | - | |||||||||||||||||||||||||
1442 | if (firstItem == secondItem
| 0 | ||||||||||||||||||||||||
1443 | data->item = firstItem; never executed: data->item = firstItem; | 0 | ||||||||||||||||||||||||
1444 | - | |||||||||||||||||||||||||
1445 | data->orientation = orientation; | - | ||||||||||||||||||||||||
1446 | - | |||||||||||||||||||||||||
1447 | - | |||||||||||||||||||||||||
1448 | - | |||||||||||||||||||||||||
1449 | - | |||||||||||||||||||||||||
1450 | data->from = v1; | - | ||||||||||||||||||||||||
1451 | data->to = v2; | - | ||||||||||||||||||||||||
1452 | - | |||||||||||||||||||||||||
1453 | data->name = QString::fromLatin1("%1 --to--> %2").arg(v1->toString()).arg(v2->toString()); | - | ||||||||||||||||||||||||
1454 | - | |||||||||||||||||||||||||
1455 | - | |||||||||||||||||||||||||
1456 | - | |||||||||||||||||||||||||
1457 | data->isLayoutAnchor = (data->item == q); | - | ||||||||||||||||||||||||
1458 | - | |||||||||||||||||||||||||
1459 | graph[orientation].createEdge(v1, v2, data); | - | ||||||||||||||||||||||||
1460 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1461 | - | |||||||||||||||||||||||||
1462 | QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::getAnchor(QGraphicsLayoutItem *firstItem, | - | ||||||||||||||||||||||||
1463 | Qt::AnchorPoint firstEdge, | - | ||||||||||||||||||||||||
1464 | QGraphicsLayoutItem *secondItem, | - | ||||||||||||||||||||||||
1465 | Qt::AnchorPoint secondEdge) | - | ||||||||||||||||||||||||
1466 | { | - | ||||||||||||||||||||||||
1467 | - | |||||||||||||||||||||||||
1468 | if (firstItem == secondItem
| 0 | ||||||||||||||||||||||||
1469 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
1470 | - | |||||||||||||||||||||||||
1471 | const Orientation orientation = edgeOrientation(firstEdge); | - | ||||||||||||||||||||||||
1472 | AnchorVertex *v1 = internalVertex(firstItem, firstEdge); | - | ||||||||||||||||||||||||
1473 | AnchorVertex *v2 = internalVertex(secondItem, secondEdge); | - | ||||||||||||||||||||||||
1474 | - | |||||||||||||||||||||||||
1475 | QGraphicsAnchor *graphicsAnchor = 0; | - | ||||||||||||||||||||||||
1476 | - | |||||||||||||||||||||||||
1477 | AnchorData *data = graph[orientation].edgeData(v1, v2); | - | ||||||||||||||||||||||||
1478 | if (data
| 0 | ||||||||||||||||||||||||
1479 | - | |||||||||||||||||||||||||
1480 | - | |||||||||||||||||||||||||
1481 | - | |||||||||||||||||||||||||
1482 | - | |||||||||||||||||||||||||
1483 | - | |||||||||||||||||||||||||
1484 | - | |||||||||||||||||||||||||
1485 | ((!(data->graphicsAnchor)) ? qt_assert("data->graphicsAnchor",__FILE__,1782) : qt_noop()); | - | ||||||||||||||||||||||||
1486 | graphicsAnchor = data->graphicsAnchor; | - | ||||||||||||||||||||||||
1487 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1488 | return never executed: graphicsAnchor;return graphicsAnchor; never executed: return graphicsAnchor; | 0 | ||||||||||||||||||||||||
1489 | } | - | ||||||||||||||||||||||||
1490 | - | |||||||||||||||||||||||||
1491 | - | |||||||||||||||||||||||||
1492 | - | |||||||||||||||||||||||||
1493 | - | |||||||||||||||||||||||||
1494 | - | |||||||||||||||||||||||||
1495 | - | |||||||||||||||||||||||||
1496 | - | |||||||||||||||||||||||||
1497 | void QGraphicsAnchorLayoutPrivate::removeAnchor(AnchorVertex *firstVertex, | - | ||||||||||||||||||||||||
1498 | AnchorVertex *secondVertex) | - | ||||||||||||||||||||||||
1499 | { | - | ||||||||||||||||||||||||
1500 | QGraphicsAnchorLayout * const q = q_func(); | - | ||||||||||||||||||||||||
1501 | - | |||||||||||||||||||||||||
1502 | - | |||||||||||||||||||||||||
1503 | QGraphicsLayoutItem *firstItem = firstVertex->m_item; | - | ||||||||||||||||||||||||
1504 | QGraphicsLayoutItem *secondItem = secondVertex->m_item; | - | ||||||||||||||||||||||||
1505 | - | |||||||||||||||||||||||||
1506 | - | |||||||||||||||||||||||||
1507 | removeAnchor_helper(firstVertex, secondVertex); | - | ||||||||||||||||||||||||
1508 | - | |||||||||||||||||||||||||
1509 | - | |||||||||||||||||||||||||
1510 | firstVertex = secondVertex = 0; | - | ||||||||||||||||||||||||
1511 | - | |||||||||||||||||||||||||
1512 | - | |||||||||||||||||||||||||
1513 | bool keepFirstItem = false; | - | ||||||||||||||||||||||||
1514 | bool keepSecondItem = false; | - | ||||||||||||||||||||||||
1515 | - | |||||||||||||||||||||||||
1516 | QPair<AnchorVertex *, int> v; | - | ||||||||||||||||||||||||
1517 | int refcount = -1; | - | ||||||||||||||||||||||||
1518 | - | |||||||||||||||||||||||||
1519 | if (firstItem != q
| 0 | ||||||||||||||||||||||||
1520 | for (int i = Qt::AnchorLeft; i <= Qt::AnchorBottom
| 0 | ||||||||||||||||||||||||
1521 | v = m_vertexList.value(qMakePair(firstItem, static_cast<Qt::AnchorPoint>(i))); | - | ||||||||||||||||||||||||
1522 | if (v.first
| 0 | ||||||||||||||||||||||||
1523 | if (i == Qt::AnchorHorizontalCenter
| 0 | ||||||||||||||||||||||||
1524 | refcount = 2; never executed: refcount = 2; | 0 | ||||||||||||||||||||||||
1525 | else | - | ||||||||||||||||||||||||
1526 | refcount = 1; never executed: refcount = 1; | 0 | ||||||||||||||||||||||||
1527 | - | |||||||||||||||||||||||||
1528 | if (v.second > refcount
| 0 | ||||||||||||||||||||||||
1529 | keepFirstItem = true; | - | ||||||||||||||||||||||||
1530 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1531 | } | - | ||||||||||||||||||||||||
1532 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1533 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1534 | } never executed: elseend of block | 0 | ||||||||||||||||||||||||
1535 | keepFirstItem = true; never executed: keepFirstItem = true; | 0 | ||||||||||||||||||||||||
1536 | - | |||||||||||||||||||||||||
1537 | if (secondItem != q
| 0 | ||||||||||||||||||||||||
1538 | for (int i = Qt::AnchorLeft; i <= Qt::AnchorBottom
| 0 | ||||||||||||||||||||||||
1539 | v = m_vertexList.value(qMakePair(secondItem, static_cast<Qt::AnchorPoint>(i))); | - | ||||||||||||||||||||||||
1540 | if (v.first
| 0 | ||||||||||||||||||||||||
1541 | if (i == Qt::AnchorHorizontalCenter
| 0 | ||||||||||||||||||||||||
1542 | refcount = 2; never executed: refcount = 2; | 0 | ||||||||||||||||||||||||
1543 | else | - | ||||||||||||||||||||||||
1544 | refcount = 1; never executed: refcount = 1; | 0 | ||||||||||||||||||||||||
1545 | - | |||||||||||||||||||||||||
1546 | if (v.second > refcount
| 0 | ||||||||||||||||||||||||
1547 | keepSecondItem = true; | - | ||||||||||||||||||||||||
1548 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1549 | } | - | ||||||||||||||||||||||||
1550 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1551 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1552 | } never executed: elseend of block | 0 | ||||||||||||||||||||||||
1553 | keepSecondItem = true; never executed: keepSecondItem = true; | 0 | ||||||||||||||||||||||||
1554 | - | |||||||||||||||||||||||||
1555 | if (!keepFirstItem
| 0 | ||||||||||||||||||||||||
1556 | q->removeAt(items.indexOf(firstItem)); never executed: q->removeAt(items.indexOf(firstItem)); | 0 | ||||||||||||||||||||||||
1557 | - | |||||||||||||||||||||||||
1558 | if (!keepSecondItem
| 0 | ||||||||||||||||||||||||
1559 | q->removeAt(items.indexOf(secondItem)); never executed: q->removeAt(items.indexOf(secondItem)); | 0 | ||||||||||||||||||||||||
1560 | - | |||||||||||||||||||||||||
1561 | - | |||||||||||||||||||||||||
1562 | q->invalidate(); | - | ||||||||||||||||||||||||
1563 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1564 | - | |||||||||||||||||||||||||
1565 | - | |||||||||||||||||||||||||
1566 | - | |||||||||||||||||||||||||
1567 | - | |||||||||||||||||||||||||
1568 | - | |||||||||||||||||||||||||
1569 | - | |||||||||||||||||||||||||
1570 | - | |||||||||||||||||||||||||
1571 | void QGraphicsAnchorLayoutPrivate::removeAnchor_helper(AnchorVertex *v1, AnchorVertex *v2) | - | ||||||||||||||||||||||||
1572 | { | - | ||||||||||||||||||||||||
1573 | ((!(v1 && v2)) ? qt_assert("v1 && v2",__FILE__,1870) : qt_noop()); | - | ||||||||||||||||||||||||
1574 | - | |||||||||||||||||||||||||
1575 | - | |||||||||||||||||||||||||
1576 | const Orientation o = edgeOrientation(v1->m_edge); | - | ||||||||||||||||||||||||
1577 | graph[o].removeEdge(v1, v2); | - | ||||||||||||||||||||||||
1578 | - | |||||||||||||||||||||||||
1579 | - | |||||||||||||||||||||||||
1580 | removeInternalVertex(v1->m_item, v1->m_edge); | - | ||||||||||||||||||||||||
1581 | removeInternalVertex(v2->m_item, v2->m_edge); | - | ||||||||||||||||||||||||
1582 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1583 | - | |||||||||||||||||||||||||
1584 | AnchorVertex *QGraphicsAnchorLayoutPrivate::addInternalVertex(QGraphicsLayoutItem *item, | - | ||||||||||||||||||||||||
1585 | Qt::AnchorPoint edge) | - | ||||||||||||||||||||||||
1586 | { | - | ||||||||||||||||||||||||
1587 | QPair<QGraphicsLayoutItem *, Qt::AnchorPoint> pair(item, edge); | - | ||||||||||||||||||||||||
1588 | QPair<AnchorVertex *, int> v = m_vertexList.value(pair); | - | ||||||||||||||||||||||||
1589 | - | |||||||||||||||||||||||||
1590 | if (!v.first
| 0 | ||||||||||||||||||||||||
1591 | ((!(v.second == 0)) ? qt_assert("v.second == 0",__FILE__,1888) : qt_noop()); | - | ||||||||||||||||||||||||
1592 | v.first = new AnchorVertex(item, edge); | - | ||||||||||||||||||||||||
1593 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1594 | v.second++; | - | ||||||||||||||||||||||||
1595 | m_vertexList.insert(pair, v); | - | ||||||||||||||||||||||||
1596 | return never executed: v.first;return v.first; never executed: return v.first; | 0 | ||||||||||||||||||||||||
1597 | } | - | ||||||||||||||||||||||||
1598 | - | |||||||||||||||||||||||||
1599 | - | |||||||||||||||||||||||||
1600 | - | |||||||||||||||||||||||||
1601 | - | |||||||||||||||||||||||||
1602 | - | |||||||||||||||||||||||||
1603 | - | |||||||||||||||||||||||||
1604 | - | |||||||||||||||||||||||||
1605 | void QGraphicsAnchorLayoutPrivate::removeInternalVertex(QGraphicsLayoutItem *item, | - | ||||||||||||||||||||||||
1606 | Qt::AnchorPoint edge) | - | ||||||||||||||||||||||||
1607 | { | - | ||||||||||||||||||||||||
1608 | QPair<QGraphicsLayoutItem *, Qt::AnchorPoint> pair(item, edge); | - | ||||||||||||||||||||||||
1609 | QPair<AnchorVertex *, int> v = m_vertexList.value(pair); | - | ||||||||||||||||||||||||
1610 | - | |||||||||||||||||||||||||
1611 | if (!v.first
| 0 | ||||||||||||||||||||||||
1612 | QMessageLogger(__FILE__, 1909, __PRETTY_FUNCTION__).warning("This item with this edge is not in the graph"); | - | ||||||||||||||||||||||||
1613 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1614 | } | - | ||||||||||||||||||||||||
1615 | - | |||||||||||||||||||||||||
1616 | v.second--; | - | ||||||||||||||||||||||||
1617 | if (v.second == 0
| 0 | ||||||||||||||||||||||||
1618 | - | |||||||||||||||||||||||||
1619 | m_vertexList.remove(pair); | - | ||||||||||||||||||||||||
1620 | delete v.first; | - | ||||||||||||||||||||||||
1621 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1622 | - | |||||||||||||||||||||||||
1623 | m_vertexList.insert(pair, v); | - | ||||||||||||||||||||||||
1624 | - | |||||||||||||||||||||||||
1625 | if ((
| 0 | ||||||||||||||||||||||||
1626 | ((
| 0 | ||||||||||||||||||||||||
1627 | (
| 0 | ||||||||||||||||||||||||
1628 | removeCenterAnchors(item, edge, true); | - | ||||||||||||||||||||||||
1629 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1630 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1631 | } | - | ||||||||||||||||||||||||
1632 | - | |||||||||||||||||||||||||
1633 | void QGraphicsAnchorLayoutPrivate::removeVertex(QGraphicsLayoutItem *item, Qt::AnchorPoint edge) | - | ||||||||||||||||||||||||
1634 | { | - | ||||||||||||||||||||||||
1635 | if (AnchorVertex *v = internalVertex(item, edge)
| 0 | ||||||||||||||||||||||||
1636 | Graph<AnchorVertex, AnchorData> &g = graph[edgeOrientation(edge)]; | - | ||||||||||||||||||||||||
1637 | const QList<AnchorVertex *> allVertices = graph[edgeOrientation(edge)].adjacentVertices(v); | - | ||||||||||||||||||||||||
1638 | AnchorVertex *v2; | - | ||||||||||||||||||||||||
1639 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(allVertices)>::type> _container_((allVertices)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (v2 = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
1640 | g.removeEdge(v, v2); | - | ||||||||||||||||||||||||
1641 | removeInternalVertex(item, edge); | - | ||||||||||||||||||||||||
1642 | removeInternalVertex(v2->m_item, v2->m_edge); | - | ||||||||||||||||||||||||
1643 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1644 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1645 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1646 | - | |||||||||||||||||||||||||
1647 | void QGraphicsAnchorLayoutPrivate::removeAnchors(QGraphicsLayoutItem *item) | - | ||||||||||||||||||||||||
1648 | { | - | ||||||||||||||||||||||||
1649 | - | |||||||||||||||||||||||||
1650 | removeCenterAnchors(item, Qt::AnchorHorizontalCenter, false); | - | ||||||||||||||||||||||||
1651 | removeVertex(item, Qt::AnchorLeft); | - | ||||||||||||||||||||||||
1652 | removeVertex(item, Qt::AnchorRight); | - | ||||||||||||||||||||||||
1653 | - | |||||||||||||||||||||||||
1654 | removeCenterAnchors(item, Qt::AnchorVerticalCenter, false); | - | ||||||||||||||||||||||||
1655 | removeVertex(item, Qt::AnchorTop); | - | ||||||||||||||||||||||||
1656 | removeVertex(item, Qt::AnchorBottom); | - | ||||||||||||||||||||||||
1657 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1658 | void QGraphicsAnchorLayoutPrivate::correctEdgeDirection(QGraphicsLayoutItem *&firstItem, | - | ||||||||||||||||||||||||
1659 | Qt::AnchorPoint &firstEdge, | - | ||||||||||||||||||||||||
1660 | QGraphicsLayoutItem *&secondItem, | - | ||||||||||||||||||||||||
1661 | Qt::AnchorPoint &secondEdge) | - | ||||||||||||||||||||||||
1662 | { | - | ||||||||||||||||||||||||
1663 | QGraphicsAnchorLayout * const q = q_func(); | - | ||||||||||||||||||||||||
1664 | - | |||||||||||||||||||||||||
1665 | if ((
| 0 | ||||||||||||||||||||||||
1666 | - | |||||||||||||||||||||||||
1667 | - | |||||||||||||||||||||||||
1668 | if (firstEdge < secondEdge
| 0 | ||||||||||||||||||||||||
1669 | qSwap(firstItem, secondItem); | - | ||||||||||||||||||||||||
1670 | qSwap(firstEdge, secondEdge); | - | ||||||||||||||||||||||||
1671 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1672 | } never executed: else if (firstItem == qend of block
| 0 | ||||||||||||||||||||||||
1673 | - | |||||||||||||||||||||||||
1674 | - | |||||||||||||||||||||||||
1675 | if ((
| 0 | ||||||||||||||||||||||||
1676 | qSwap(firstItem, secondItem); | - | ||||||||||||||||||||||||
1677 | qSwap(firstEdge, secondEdge); | - | ||||||||||||||||||||||||
1678 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1679 | } never executed: else if ((end of block
| 0 | ||||||||||||||||||||||||
1680 | - | |||||||||||||||||||||||||
1681 | - | |||||||||||||||||||||||||
1682 | qSwap(firstItem, secondItem); | - | ||||||||||||||||||||||||
1683 | qSwap(firstEdge, secondEdge); | - | ||||||||||||||||||||||||
1684 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1685 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1686 | - | |||||||||||||||||||||||||
1687 | QLayoutStyleInfo &QGraphicsAnchorLayoutPrivate::styleInfo() const | - | ||||||||||||||||||||||||
1688 | { | - | ||||||||||||||||||||||||
1689 | if (styleInfoDirty
| 0 | ||||||||||||||||||||||||
1690 | const QGraphicsAnchorLayout * const q = q_func(); | - | ||||||||||||||||||||||||
1691 | - | |||||||||||||||||||||||||
1692 | QWidget *wid = 0; | - | ||||||||||||||||||||||||
1693 | - | |||||||||||||||||||||||||
1694 | QGraphicsLayoutItem *parent = q->parentLayoutItem(); | - | ||||||||||||||||||||||||
1695 | while (parent
| 0 | ||||||||||||||||||||||||
1696 | parent = parent->parentLayoutItem(); | - | ||||||||||||||||||||||||
1697 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1698 | QGraphicsWidget *w = 0; | - | ||||||||||||||||||||||||
1699 | if (parent
| 0 | ||||||||||||||||||||||||
1700 | QGraphicsItem *parentItem = parent->graphicsItem(); | - | ||||||||||||||||||||||||
1701 | if (parentItem
| 0 | ||||||||||||||||||||||||
1702 | w = static_cast<QGraphicsWidget*>(parentItem); never executed: w = static_cast<QGraphicsWidget*>(parentItem); | 0 | ||||||||||||||||||||||||
1703 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1704 | - | |||||||||||||||||||||||||
1705 | QStyle *style = w
| 0 | ||||||||||||||||||||||||
1706 | cachedStyleInfo = QLayoutStyleInfo(style, wid); | - | ||||||||||||||||||||||||
1707 | cachedStyleInfo.setDefaultSpacing(Qt::Horizontal, spacings[0]); | - | ||||||||||||||||||||||||
1708 | cachedStyleInfo.setDefaultSpacing(Qt::Vertical, spacings[1]); | - | ||||||||||||||||||||||||
1709 | - | |||||||||||||||||||||||||
1710 | styleInfoDirty = false; | - | ||||||||||||||||||||||||
1711 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1712 | return never executed: cachedStyleInfo;return cachedStyleInfo; never executed: return cachedStyleInfo; | 0 | ||||||||||||||||||||||||
1713 | } | - | ||||||||||||||||||||||||
1714 | void QGraphicsAnchorLayoutPrivate::calculateGraphs() | - | ||||||||||||||||||||||||
1715 | { | - | ||||||||||||||||||||||||
1716 | if (!calculateGraphCacheDirty
| 0 | ||||||||||||||||||||||||
1717 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1718 | calculateGraphs(Horizontal); | - | ||||||||||||||||||||||||
1719 | calculateGraphs(Vertical); | - | ||||||||||||||||||||||||
1720 | calculateGraphCacheDirty = false; | - | ||||||||||||||||||||||||
1721 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1722 | - | |||||||||||||||||||||||||
1723 | - | |||||||||||||||||||||||||
1724 | - | |||||||||||||||||||||||||
1725 | QList<AnchorData *> getVariables(const QList<QSimplexConstraint *> &constraints) | - | ||||||||||||||||||||||||
1726 | { | - | ||||||||||||||||||||||||
1727 | QSet<AnchorData *> variableSet; | - | ||||||||||||||||||||||||
1728 | for (int i = 0; i < constraints.count()
| 0 | ||||||||||||||||||||||||
1729 | const QSimplexConstraint *c = constraints.at(i); | - | ||||||||||||||||||||||||
1730 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(c->variables.keys())>::type> _container_((c->variables.keys())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QSimplexVariable *var = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
1731 | variableSet += static_cast<AnchorData *>(var); | - | ||||||||||||||||||||||||
1732 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1733 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1734 | return never executed: variableSet.toList();return variableSet.toList(); never executed: return variableSet.toList(); | 0 | ||||||||||||||||||||||||
1735 | } | - | ||||||||||||||||||||||||
1736 | void 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
| 0 | ||||||||||||||||||||||||
1750 | QMessageLogger(__FILE__, 2104, __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 | QList<QList<QSimplexConstraint *> > parts = getGraphParts(orientation); | - | ||||||||||||||||||||||||
1762 | - | |||||||||||||||||||||||||
1763 | - | |||||||||||||||||||||||||
1764 | - | |||||||||||||||||||||||||
1765 | - | |||||||||||||||||||||||||
1766 | QList<QSimplexConstraint *> trunkConstraints = parts.at(0); | - | ||||||||||||||||||||||||
1767 | QList<AnchorData *> trunkVariables = getVariables(trunkConstraints); | - | ||||||||||||||||||||||||
1768 | - | |||||||||||||||||||||||||
1769 | - | |||||||||||||||||||||||||
1770 | - | |||||||||||||||||||||||||
1771 | AnchorVertex *v = layoutLastVertex[orientation]; | - | ||||||||||||||||||||||||
1772 | GraphPath trunkPath = graphPaths[orientation].value(v); | - | ||||||||||||||||||||||||
1773 | - | |||||||||||||||||||||||||
1774 | bool feasible = calculateTrunk(orientation, trunkPath, trunkConstraints, trunkVariables); | - | ||||||||||||||||||||||||
1775 | - | |||||||||||||||||||||||||
1776 | - | |||||||||||||||||||||||||
1777 | - | |||||||||||||||||||||||||
1778 | - | |||||||||||||||||||||||||
1779 | - | |||||||||||||||||||||||||
1780 | - | |||||||||||||||||||||||||
1781 | for (int i = 1; i < parts.count()
| 0 | ||||||||||||||||||||||||
1782 | if (!feasible
| 0 | ||||||||||||||||||||||||
1783 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1784 | - | |||||||||||||||||||||||||
1785 | QList<QSimplexConstraint *> partConstraints = parts.at(i); | - | ||||||||||||||||||||||||
1786 | QList<AnchorData *> partVariables = getVariables(partConstraints); | - | ||||||||||||||||||||||||
1787 | ((!(!partVariables.isEmpty())) ? qt_assert("!partVariables.isEmpty()",__FILE__,2152) : qt_noop()); | - | ||||||||||||||||||||||||
1788 | feasible &= calculateNonTrunk(partConstraints, partVariables); | - | ||||||||||||||||||||||||
1789 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1790 | - | |||||||||||||||||||||||||
1791 | - | |||||||||||||||||||||||||
1792 | - | |||||||||||||||||||||||||
1793 | updateAnchorSizes(orientation); | - | ||||||||||||||||||||||||
1794 | - | |||||||||||||||||||||||||
1795 | graphHasConflicts[orientation] = !feasible; | - | ||||||||||||||||||||||||
1796 | - | |||||||||||||||||||||||||
1797 | - | |||||||||||||||||||||||||
1798 | - | |||||||||||||||||||||||||
1799 | qDeleteAll(constraints[orientation]); | - | ||||||||||||||||||||||||
1800 | constraints[orientation].clear(); | - | ||||||||||||||||||||||||
1801 | graphPaths[orientation].clear(); | - | ||||||||||||||||||||||||
1802 | - | |||||||||||||||||||||||||
1803 | if (simplificationEnabled
| 0 | ||||||||||||||||||||||||
1804 | restoreSimplifiedGraph(orientation); never executed: restoreSimplifiedGraph(orientation); | 0 | ||||||||||||||||||||||||
1805 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1806 | static void shiftConstraints(const QList<QSimplexConstraint *> &constraints, qreal amount) | - | ||||||||||||||||||||||||
1807 | { | - | ||||||||||||||||||||||||
1808 | for (int i = 0; i < constraints.count()
| 0 | ||||||||||||||||||||||||
1809 | QSimplexConstraint *c = constraints.at(i); | - | ||||||||||||||||||||||||
1810 | qreal multiplier = 0; | - | ||||||||||||||||||||||||
1811 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(c->variables)>::type> _container_((c->variables)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (qreal v = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
1812 | multiplier += v; | - | ||||||||||||||||||||||||
1813 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1814 | c->constant += multiplier * amount; | - | ||||||||||||||||||||||||
1815 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1816 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1817 | - | |||||||||||||||||||||||||
1818 | - | |||||||||||||||||||||||||
1819 | - | |||||||||||||||||||||||||
1820 | - | |||||||||||||||||||||||||
1821 | - | |||||||||||||||||||||||||
1822 | - | |||||||||||||||||||||||||
1823 | - | |||||||||||||||||||||||||
1824 | bool QGraphicsAnchorLayoutPrivate::calculateTrunk(Orientation orientation, const GraphPath &path, | - | ||||||||||||||||||||||||
1825 | const QList<QSimplexConstraint *> &constraints, | - | ||||||||||||||||||||||||
1826 | const QList<AnchorData *> &variables) | - | ||||||||||||||||||||||||
1827 | { | - | ||||||||||||||||||||||||
1828 | bool feasible = true; | - | ||||||||||||||||||||||||
1829 | bool needsSimplex = !constraints.isEmpty(); | - | ||||||||||||||||||||||||
1830 | - | |||||||||||||||||||||||||
1831 | - | |||||||||||||||||||||||||
1832 | - | |||||||||||||||||||||||||
1833 | - | |||||||||||||||||||||||||
1834 | - | |||||||||||||||||||||||||
1835 | - | |||||||||||||||||||||||||
1836 | if (needsSimplex
| 0 | ||||||||||||||||||||||||
1837 | - | |||||||||||||||||||||||||
1838 | QList<QSimplexConstraint *> sizeHintConstraints = constraintsFromSizeHints(variables); | - | ||||||||||||||||||||||||
1839 | QList<QSimplexConstraint *> allConstraints = constraints + sizeHintConstraints; | - | ||||||||||||||||||||||||
1840 | - | |||||||||||||||||||||||||
1841 | shiftConstraints(allConstraints, g_offset); | - | ||||||||||||||||||||||||
1842 | - | |||||||||||||||||||||||||
1843 | - | |||||||||||||||||||||||||
1844 | qreal min, max; | - | ||||||||||||||||||||||||
1845 | feasible = solveMinMax(allConstraints, path, &min, &max); | - | ||||||||||||||||||||||||
1846 | - | |||||||||||||||||||||||||
1847 | if (feasible
| 0 | ||||||||||||||||||||||||
1848 | solvePreferred(constraints, variables); | - | ||||||||||||||||||||||||
1849 | - | |||||||||||||||||||||||||
1850 | - | |||||||||||||||||||||||||
1851 | - | |||||||||||||||||||||||||
1852 | qreal pref(0.0); | - | ||||||||||||||||||||||||
1853 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(path.positives)>::type> _container_((path.positives)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const AnchorData *ad = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
1854 | pref += ad->sizeAtPreferred; | - | ||||||||||||||||||||||||
1855 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1856 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(path.negatives)>::type> _container_((path.negatives)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const AnchorData *ad = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
1857 | pref -= ad->sizeAtPreferred; | - | ||||||||||||||||||||||||
1858 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1859 | - | |||||||||||||||||||||||||
1860 | sizeHints[orientation][Qt::MinimumSize] = min; | - | ||||||||||||||||||||||||
1861 | sizeHints[orientation][Qt::PreferredSize] = pref; | - | ||||||||||||||||||||||||
1862 | sizeHints[orientation][Qt::MaximumSize] = max; | - | ||||||||||||||||||||||||
1863 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1864 | - | |||||||||||||||||||||||||
1865 | qDeleteAll(sizeHintConstraints); | - | ||||||||||||||||||||||||
1866 | shiftConstraints(constraints, -g_offset); | - | ||||||||||||||||||||||||
1867 | - | |||||||||||||||||||||||||
1868 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1869 | - | |||||||||||||||||||||||||
1870 | - | |||||||||||||||||||||||||
1871 | ((!(path.positives.count() == 1)) ? qt_assert("path.positives.count() == 1",__FILE__,2244) : qt_noop()); | - | ||||||||||||||||||||||||
1872 | ((!(path.negatives.count() == 0)) ? qt_assert("path.negatives.count() == 0",__FILE__,2245) : qt_noop()); | - | ||||||||||||||||||||||||
1873 | - | |||||||||||||||||||||||||
1874 | AnchorData *ad = path.positives.toList()[0]; | - | ||||||||||||||||||||||||
1875 | ad->sizeAtMinimum = ad->minSize; | - | ||||||||||||||||||||||||
1876 | ad->sizeAtPreferred = ad->prefSize; | - | ||||||||||||||||||||||||
1877 | ad->sizeAtMaximum = ad->maxSize; | - | ||||||||||||||||||||||||
1878 | - | |||||||||||||||||||||||||
1879 | sizeHints[orientation][Qt::MinimumSize] = ad->sizeAtMinimum; | - | ||||||||||||||||||||||||
1880 | sizeHints[orientation][Qt::PreferredSize] = ad->sizeAtPreferred; | - | ||||||||||||||||||||||||
1881 | sizeHints[orientation][Qt::MaximumSize] = ad->sizeAtMaximum; | - | ||||||||||||||||||||||||
1882 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1883 | - | |||||||||||||||||||||||||
1884 | - | |||||||||||||||||||||||||
1885 | lastCalculationUsedSimplex[orientation] = needsSimplex; | - | ||||||||||||||||||||||||
1886 | - | |||||||||||||||||||||||||
1887 | - | |||||||||||||||||||||||||
1888 | return never executed: feasible;return feasible; never executed: return feasible; | 0 | ||||||||||||||||||||||||
1889 | } | - | ||||||||||||||||||||||||
1890 | - | |||||||||||||||||||||||||
1891 | - | |||||||||||||||||||||||||
1892 | - | |||||||||||||||||||||||||
1893 | - | |||||||||||||||||||||||||
1894 | bool QGraphicsAnchorLayoutPrivate::calculateNonTrunk(const QList<QSimplexConstraint *> &constraints, | - | ||||||||||||||||||||||||
1895 | const QList<AnchorData *> &variables) | - | ||||||||||||||||||||||||
1896 | { | - | ||||||||||||||||||||||||
1897 | shiftConstraints(constraints, g_offset); | - | ||||||||||||||||||||||||
1898 | bool feasible = solvePreferred(constraints, variables); | - | ||||||||||||||||||||||||
1899 | - | |||||||||||||||||||||||||
1900 | if (feasible
| 0 | ||||||||||||||||||||||||
1901 | - | |||||||||||||||||||||||||
1902 | - | |||||||||||||||||||||||||
1903 | for (int j = 0; j < variables.count()
| 0 | ||||||||||||||||||||||||
1904 | AnchorData *ad = variables.at(j); | - | ||||||||||||||||||||||||
1905 | ((!(ad)) ? qt_assert("ad",__FILE__,2278) : qt_noop()); | - | ||||||||||||||||||||||||
1906 | ad->sizeAtMinimum = ad->sizeAtPreferred; | - | ||||||||||||||||||||||||
1907 | ad->sizeAtMaximum = ad->sizeAtPreferred; | - | ||||||||||||||||||||||||
1908 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1909 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1910 | - | |||||||||||||||||||||||||
1911 | shiftConstraints(constraints, -g_offset); | - | ||||||||||||||||||||||||
1912 | return never executed: feasible;return feasible; never executed: return feasible; | 0 | ||||||||||||||||||||||||
1913 | } | - | ||||||||||||||||||||||||
1914 | - | |||||||||||||||||||||||||
1915 | - | |||||||||||||||||||||||||
1916 | - | |||||||||||||||||||||||||
1917 | - | |||||||||||||||||||||||||
1918 | - | |||||||||||||||||||||||||
1919 | - | |||||||||||||||||||||||||
1920 | - | |||||||||||||||||||||||||
1921 | void QGraphicsAnchorLayoutPrivate::refreshAllSizeHints(Orientation orientation) | - | ||||||||||||||||||||||||
1922 | { | - | ||||||||||||||||||||||||
1923 | Graph<AnchorVertex, AnchorData> &g = graph[orientation]; | - | ||||||||||||||||||||||||
1924 | QList<QPair<AnchorVertex *, AnchorVertex *> > vertices = g.connections(); | - | ||||||||||||||||||||||||
1925 | - | |||||||||||||||||||||||||
1926 | QLayoutStyleInfo styleInf = styleInfo(); | - | ||||||||||||||||||||||||
1927 | for (int i = 0; i < vertices.count()
| 0 | ||||||||||||||||||||||||
1928 | AnchorData *data = g.edgeData(vertices.at(i).first, vertices.at(i).second); | - | ||||||||||||||||||||||||
1929 | data->refreshSizeHints(&styleInf); | - | ||||||||||||||||||||||||
1930 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1931 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1932 | void QGraphicsAnchorLayoutPrivate::findPaths(Orientation orientation) | - | ||||||||||||||||||||||||
1933 | { | - | ||||||||||||||||||||||||
1934 | QQueue<QPair<AnchorVertex *, AnchorVertex *> > queue; | - | ||||||||||||||||||||||||
1935 | - | |||||||||||||||||||||||||
1936 | QSet<AnchorData *> visited; | - | ||||||||||||||||||||||||
1937 | - | |||||||||||||||||||||||||
1938 | AnchorVertex *root = layoutFirstVertex[orientation]; | - | ||||||||||||||||||||||||
1939 | - | |||||||||||||||||||||||||
1940 | graphPaths[orientation].insert(root, GraphPath()); | - | ||||||||||||||||||||||||
1941 | - | |||||||||||||||||||||||||
1942 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(graph[orientation].adjacentVertices(root))>::type> _container_((graph[orientation].adjacentVertices(root))); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (AnchorVertex *v = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
1943 | queue.enqueue(qMakePair(root, v)); | - | ||||||||||||||||||||||||
1944 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1945 | - | |||||||||||||||||||||||||
1946 | while(!queue.isEmpty()
| 0 | ||||||||||||||||||||||||
1947 | QPair<AnchorVertex *, AnchorVertex *> pair = queue.dequeue(); | - | ||||||||||||||||||||||||
1948 | AnchorData *edge = graph[orientation].edgeData(pair.first, pair.second); | - | ||||||||||||||||||||||||
1949 | - | |||||||||||||||||||||||||
1950 | if (visited.contains(edge)
| 0 | ||||||||||||||||||||||||
1951 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
1952 | - | |||||||||||||||||||||||||
1953 | visited.insert(edge); | - | ||||||||||||||||||||||||
1954 | GraphPath current = graphPaths[orientation].value(pair.first); | - | ||||||||||||||||||||||||
1955 | - | |||||||||||||||||||||||||
1956 | if (edge->from == pair.first
| 0 | ||||||||||||||||||||||||
1957 | current.positives.insert(edge); never executed: current.positives.insert(edge); | 0 | ||||||||||||||||||||||||
1958 | else | - | ||||||||||||||||||||||||
1959 | current.negatives.insert(edge); never executed: current.negatives.insert(edge); | 0 | ||||||||||||||||||||||||
1960 | - | |||||||||||||||||||||||||
1961 | graphPaths[orientation].insert(pair.second, current); | - | ||||||||||||||||||||||||
1962 | - | |||||||||||||||||||||||||
1963 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(graph[orientation].adjacentVertices(pair.second))>::type> _container_((graph[orientation].adjacentVertices(pair.second))); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (AnchorVertex *v = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||||||||||||||
1964 | { | - | ||||||||||||||||||||||||
1965 | queue.enqueue(qMakePair(pair.second, v)); | - | ||||||||||||||||||||||||
1966 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1967 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1968 | - | |||||||||||||||||||||||||
1969 | - | |||||||||||||||||||||||||
1970 | - | |||||||||||||||||||||||||
1971 | - | |||||||||||||||||||||||||
1972 | identifyFloatItems(visited, orientation); | - | ||||||||||||||||||||||||
1973 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1974 | void QGraphicsAnchorLayoutPrivate::constraintsFromPaths(Orientation orientation) | - | ||||||||||||||||||||||||
1975 | { | - | ||||||||||||||||||||||||
1976 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(graphPaths[orientation].uniqueKeys())>::type> _container_((graphPaths[orientation].uniqueKeys())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (AnchorVertex *vertex = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||||||||||||||
1977 | { | - | ||||||||||||||||||||||||
1978 | int valueCount = graphPaths[orientation].count(vertex); | - | ||||||||||||||||||||||||
1979 | if (valueCount == 1
| 0 | ||||||||||||||||||||||||
1980 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
1981 | - | |||||||||||||||||||||||||
1982 | QList<GraphPath> pathsToVertex = graphPaths[orientation].values(vertex); | - | ||||||||||||||||||||||||
1983 | for (int i = 1; i < valueCount
| 0 | ||||||||||||||||||||||||
1984 | constraints[orientation] += | - | ||||||||||||||||||||||||
1985 | pathsToVertex[0].constraint(pathsToVertex.at(i)); | - | ||||||||||||||||||||||||
1986 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1987 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1988 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1989 | - | |||||||||||||||||||||||||
1990 | - | |||||||||||||||||||||||||
1991 | - | |||||||||||||||||||||||||
1992 | - | |||||||||||||||||||||||||
1993 | void QGraphicsAnchorLayoutPrivate::updateAnchorSizes(Orientation orientation) | - | ||||||||||||||||||||||||
1994 | { | - | ||||||||||||||||||||||||
1995 | Graph<AnchorVertex, AnchorData> &g = graph[orientation]; | - | ||||||||||||||||||||||||
1996 | const QList<QPair<AnchorVertex *, AnchorVertex *> > &vertices = g.connections(); | - | ||||||||||||||||||||||||
1997 | - | |||||||||||||||||||||||||
1998 | for (int i = 0; i < vertices.count()
| 0 | ||||||||||||||||||||||||
1999 | AnchorData *ad = g.edgeData(vertices.at(i).first, vertices.at(i).second); | - | ||||||||||||||||||||||||
2000 | ad->updateChildrenSizes(); | - | ||||||||||||||||||||||||
2001 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2002 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2003 | - | |||||||||||||||||||||||||
2004 | - | |||||||||||||||||||||||||
2005 | - | |||||||||||||||||||||||||
2006 | - | |||||||||||||||||||||||||
2007 | - | |||||||||||||||||||||||||
2008 | - | |||||||||||||||||||||||||
2009 | - | |||||||||||||||||||||||||
2010 | QList<QSimplexConstraint *> QGraphicsAnchorLayoutPrivate::constraintsFromSizeHints( | - | ||||||||||||||||||||||||
2011 | const QList<AnchorData *> &anchors) | - | ||||||||||||||||||||||||
2012 | { | - | ||||||||||||||||||||||||
2013 | if (anchors.isEmpty()
| 0 | ||||||||||||||||||||||||
2014 | return never executed: QList<QSimplexConstraint *>();return QList<QSimplexConstraint *>(); never executed: return QList<QSimplexConstraint *>(); | 0 | ||||||||||||||||||||||||
2015 | - | |||||||||||||||||||||||||
2016 | - | |||||||||||||||||||||||||
2017 | - | |||||||||||||||||||||||||
2018 | Orientation orient = Orientation(anchors.first()->orientation); | - | ||||||||||||||||||||||||
2019 | AnchorData *layoutEdge = 0; | - | ||||||||||||||||||||||||
2020 | if (layoutCentralVertex[orient]
| 0 | ||||||||||||||||||||||||
2021 | layoutEdge = graph[orient].edgeData(layoutFirstVertex[orient], layoutCentralVertex[orient]); | - | ||||||||||||||||||||||||
2022 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2023 | layoutEdge = graph[orient].edgeData(layoutFirstVertex[orient], layoutLastVertex[orient]); | - | ||||||||||||||||||||||||
2024 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2025 | - | |||||||||||||||||||||||||
2026 | - | |||||||||||||||||||||||||
2027 | - | |||||||||||||||||||||||||
2028 | - | |||||||||||||||||||||||||
2029 | - | |||||||||||||||||||||||||
2030 | const qreal expectedMax = layoutCentralVertex[orient]
| 0 | ||||||||||||||||||||||||
2031 | qreal actualMax; | - | ||||||||||||||||||||||||
2032 | if (layoutEdge->from == layoutFirstVertex[orient]
| 0 | ||||||||||||||||||||||||
2033 | actualMax = layoutEdge->maxSize; | - | ||||||||||||||||||||||||
2034 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2035 | actualMax = -layoutEdge->minSize; | - | ||||||||||||||||||||||||
2036 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2037 | if (actualMax != expectedMax
| 0 | ||||||||||||||||||||||||
2038 | layoutEdge = 0; | - | ||||||||||||||||||||||||
2039 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2040 | - | |||||||||||||||||||||||||
2041 | - | |||||||||||||||||||||||||
2042 | QList<QSimplexConstraint *> anchorConstraints; | - | ||||||||||||||||||||||||
2043 | bool unboundedProblem = true; | - | ||||||||||||||||||||||||
2044 | for (int i = 0; i < anchors.size()
| 0 | ||||||||||||||||||||||||
2045 | AnchorData *ad = anchors.at(i); | - | ||||||||||||||||||||||||
2046 | - | |||||||||||||||||||||||||
2047 | - | |||||||||||||||||||||||||
2048 | - | |||||||||||||||||||||||||
2049 | - | |||||||||||||||||||||||||
2050 | if (ad->dependency == AnchorData::Slave
| 0 | ||||||||||||||||||||||||
2051 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
2052 | - | |||||||||||||||||||||||||
2053 | - | |||||||||||||||||||||||||
2054 | - | |||||||||||||||||||||||||
2055 | - | |||||||||||||||||||||||||
2056 | qreal boundedMin = qBound(-g_offset, ad->minSize, g_offset); | - | ||||||||||||||||||||||||
2057 | qreal boundedMax = qBound(-g_offset, ad->maxSize, g_offset); | - | ||||||||||||||||||||||||
2058 | - | |||||||||||||||||||||||||
2059 | if ((
| 0 | ||||||||||||||||||||||||
2060 | QSimplexConstraint *c = new QSimplexConstraint; | - | ||||||||||||||||||||||||
2061 | c->variables.insert(ad, 1.0); | - | ||||||||||||||||||||||||
2062 | c->constant = boundedMin; | - | ||||||||||||||||||||||||
2063 | c->ratio = QSimplexConstraint::Equal; | - | ||||||||||||||||||||||||
2064 | anchorConstraints += c; | - | ||||||||||||||||||||||||
2065 | unboundedProblem = false; | - | ||||||||||||||||||||||||
2066 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2067 | QSimplexConstraint *c = new QSimplexConstraint; | - | ||||||||||||||||||||||||
2068 | c->variables.insert(ad, 1.0); | - | ||||||||||||||||||||||||
2069 | c->constant = boundedMin; | - | ||||||||||||||||||||||||
2070 | c->ratio = QSimplexConstraint::MoreOrEqual; | - | ||||||||||||||||||||||||
2071 | anchorConstraints += c; | - | ||||||||||||||||||||||||
2072 | - | |||||||||||||||||||||||||
2073 | - | |||||||||||||||||||||||||
2074 | - | |||||||||||||||||||||||||
2075 | - | |||||||||||||||||||||||||
2076 | if (ad == layoutEdge
| 0 | ||||||||||||||||||||||||
2077 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
2078 | - | |||||||||||||||||||||||||
2079 | c = new QSimplexConstraint; | - | ||||||||||||||||||||||||
2080 | c->variables.insert(ad, 1.0); | - | ||||||||||||||||||||||||
2081 | c->constant = boundedMax; | - | ||||||||||||||||||||||||
2082 | c->ratio = QSimplexConstraint::LessOrEqual; | - | ||||||||||||||||||||||||
2083 | anchorConstraints += c; | - | ||||||||||||||||||||||||
2084 | unboundedProblem = false; | - | ||||||||||||||||||||||||
2085 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2086 | } | - | ||||||||||||||||||||||||
2087 | - | |||||||||||||||||||||||||
2088 | - | |||||||||||||||||||||||||
2089 | if (unboundedProblem
| 0 | ||||||||||||||||||||||||
2090 | QSimplexConstraint *c = new QSimplexConstraint; | - | ||||||||||||||||||||||||
2091 | c->variables.insert(layoutEdge, 1.0); | - | ||||||||||||||||||||||||
2092 | - | |||||||||||||||||||||||||
2093 | c->constant = g_offset; | - | ||||||||||||||||||||||||
2094 | c->ratio = QSimplexConstraint::LessOrEqual; | - | ||||||||||||||||||||||||
2095 | anchorConstraints += c; | - | ||||||||||||||||||||||||
2096 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2097 | - | |||||||||||||||||||||||||
2098 | return never executed: anchorConstraints;return anchorConstraints; never executed: return anchorConstraints; | 0 | ||||||||||||||||||||||||
2099 | } | - | ||||||||||||||||||||||||
2100 | - | |||||||||||||||||||||||||
2101 | - | |||||||||||||||||||||||||
2102 | - | |||||||||||||||||||||||||
2103 | - | |||||||||||||||||||||||||
2104 | QList< QList<QSimplexConstraint *> > | - | ||||||||||||||||||||||||
2105 | QGraphicsAnchorLayoutPrivate::getGraphParts(Orientation orientation) | - | ||||||||||||||||||||||||
2106 | { | - | ||||||||||||||||||||||||
2107 | ((!(layoutFirstVertex[orientation] && layoutLastVertex[orientation])) ? qt_assert("layoutFirstVertex[orientation] && layoutLastVertex[orientation]",__FILE__,2502) : qt_noop()); | - | ||||||||||||||||||||||||
2108 | - | |||||||||||||||||||||||||
2109 | AnchorData *edgeL1 = 0; | - | ||||||||||||||||||||||||
2110 | AnchorData *edgeL2 = 0; | - | ||||||||||||||||||||||||
2111 | - | |||||||||||||||||||||||||
2112 | - | |||||||||||||||||||||||||
2113 | - | |||||||||||||||||||||||||
2114 | if (layoutCentralVertex[orientation]
| 0 | ||||||||||||||||||||||||
2115 | edgeL1 = graph[orientation].edgeData(layoutFirstVertex[orientation], layoutCentralVertex[orientation]); | - | ||||||||||||||||||||||||
2116 | edgeL2 = graph[orientation].edgeData(layoutCentralVertex[orientation], layoutLastVertex[orientation]); | - | ||||||||||||||||||||||||
2117 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2118 | edgeL1 = graph[orientation].edgeData(layoutFirstVertex[orientation], layoutLastVertex[orientation]); | - | ||||||||||||||||||||||||
2119 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2120 | - | |||||||||||||||||||||||||
2121 | QLinkedList<QSimplexConstraint *> remainingConstraints; | - | ||||||||||||||||||||||||
2122 | for (int i = 0; i < constraints[orientation].count()
| 0 | ||||||||||||||||||||||||
2123 | remainingConstraints += constraints[orientation].at(i); | - | ||||||||||||||||||||||||
2124 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2125 | for (int i = 0; i < itemCenterConstraints[orientation].count()
| 0 | ||||||||||||||||||||||||
2126 | remainingConstraints += itemCenterConstraints[orientation].at(i); | - | ||||||||||||||||||||||||
2127 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2128 | - | |||||||||||||||||||||||||
2129 | QList<QSimplexConstraint *> trunkConstraints; | - | ||||||||||||||||||||||||
2130 | QSet<QSimplexVariable *> trunkVariables; | - | ||||||||||||||||||||||||
2131 | - | |||||||||||||||||||||||||
2132 | trunkVariables += edgeL1; | - | ||||||||||||||||||||||||
2133 | if (edgeL2
| 0 | ||||||||||||||||||||||||
2134 | trunkVariables += edgeL2; never executed: trunkVariables += edgeL2; | 0 | ||||||||||||||||||||||||
2135 | - | |||||||||||||||||||||||||
2136 | bool dirty; | - | ||||||||||||||||||||||||
2137 | do { | - | ||||||||||||||||||||||||
2138 | dirty = false; | - | ||||||||||||||||||||||||
2139 | - | |||||||||||||||||||||||||
2140 | QLinkedList<QSimplexConstraint *>::iterator it = remainingConstraints.begin(); | - | ||||||||||||||||||||||||
2141 | while (it != remainingConstraints.end()
| 0 | ||||||||||||||||||||||||
2142 | QSimplexConstraint *c = *it; | - | ||||||||||||||||||||||||
2143 | bool match = false; | - | ||||||||||||||||||||||||
2144 | - | |||||||||||||||||||||||||
2145 | - | |||||||||||||||||||||||||
2146 | - | |||||||||||||||||||||||||
2147 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(trunkVariables)>::type> _container_((trunkVariables)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QSimplexVariable *ad = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
2148 | if (c->variables.contains(ad)
| 0 | ||||||||||||||||||||||||
2149 | match = true; | - | ||||||||||||||||||||||||
2150 | break; never executed: break; | 0 | ||||||||||||||||||||||||
2151 | } | - | ||||||||||||||||||||||||
2152 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2153 | - | |||||||||||||||||||||||||
2154 | - | |||||||||||||||||||||||||
2155 | - | |||||||||||||||||||||||||
2156 | if (match
| 0 | ||||||||||||||||||||||||
2157 | trunkConstraints += c; | - | ||||||||||||||||||||||||
2158 | trunkVariables += QSet<QSimplexVariable *>::fromList(c->variables.keys()); | - | ||||||||||||||||||||||||
2159 | it = remainingConstraints.erase(it); | - | ||||||||||||||||||||||||
2160 | dirty = true; | - | ||||||||||||||||||||||||
2161 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2162 | ++it; | - | ||||||||||||||||||||||||
2163 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2164 | } | - | ||||||||||||||||||||||||
2165 | } never executed: while (dirtyend of block
| 0 | ||||||||||||||||||||||||
2166 | - | |||||||||||||||||||||||||
2167 | QList< QList<QSimplexConstraint *> > result; | - | ||||||||||||||||||||||||
2168 | result += trunkConstraints; | - | ||||||||||||||||||||||||
2169 | - | |||||||||||||||||||||||||
2170 | if (!remainingConstraints.isEmpty()
| 0 | ||||||||||||||||||||||||
2171 | QList<QSimplexConstraint *> nonTrunkConstraints; | - | ||||||||||||||||||||||||
2172 | nonTrunkConstraints.reserve(remainingConstraints.size()); | - | ||||||||||||||||||||||||
2173 | QLinkedList<QSimplexConstraint *>::iterator it = remainingConstraints.begin(); | - | ||||||||||||||||||||||||
2174 | while (it != remainingConstraints.end()
| 0 | ||||||||||||||||||||||||
2175 | nonTrunkConstraints += *it; | - | ||||||||||||||||||||||||
2176 | ++it; | - | ||||||||||||||||||||||||
2177 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2178 | result += nonTrunkConstraints; | - | ||||||||||||||||||||||||
2179 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2180 | - | |||||||||||||||||||||||||
2181 | return never executed: result;return result; never executed: return result; | 0 | ||||||||||||||||||||||||
2182 | } | - | ||||||||||||||||||||||||
2183 | - | |||||||||||||||||||||||||
2184 | - | |||||||||||||||||||||||||
2185 | - | |||||||||||||||||||||||||
2186 | - | |||||||||||||||||||||||||
2187 | - | |||||||||||||||||||||||||
2188 | - | |||||||||||||||||||||||||
2189 | void QGraphicsAnchorLayoutPrivate::identifyFloatItems(const QSet<AnchorData *> &visited, Orientation orientation) | - | ||||||||||||||||||||||||
2190 | { | - | ||||||||||||||||||||||||
2191 | QSet<QGraphicsLayoutItem *> nonFloating; | - | ||||||||||||||||||||||||
2192 | - | |||||||||||||||||||||||||
2193 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(visited)>::type> _container_((visited)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const AnchorData *ad = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||||||||||||||
2194 | identifyNonFloatItems_helper(ad, &nonFloating); never executed: identifyNonFloatItems_helper(ad, &nonFloating); | 0 | ||||||||||||||||||||||||
2195 | - | |||||||||||||||||||||||||
2196 | QSet<QGraphicsLayoutItem *> allItems; | - | ||||||||||||||||||||||||
2197 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(items)>::type> _container_((items)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGraphicsLayoutItem *item = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||||||||||||||
2198 | allItems.insert(item); never executed: allItems.insert(item); | 0 | ||||||||||||||||||||||||
2199 | m_floatItems[orientation] = allItems - nonFloating; | - | ||||||||||||||||||||||||
2200 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2201 | void QGraphicsAnchorLayoutPrivate::identifyNonFloatItems_helper(const AnchorData *ad, QSet<QGraphicsLayoutItem *> *nonFloatingItemsIdentifiedSoFar) | - | ||||||||||||||||||||||||
2202 | { | - | ||||||||||||||||||||||||
2203 | QGraphicsAnchorLayout * const q = q_func(); | - | ||||||||||||||||||||||||
2204 | - | |||||||||||||||||||||||||
2205 | switch(ad->type) { | - | ||||||||||||||||||||||||
2206 | case never executed: AnchorData::Normal:case AnchorData::Normal: never executed: case AnchorData::Normal: | 0 | ||||||||||||||||||||||||
2207 | if (ad->item
| 0 | ||||||||||||||||||||||||
2208 | nonFloatingItemsIdentifiedSoFar->insert(ad->item); never executed: nonFloatingItemsIdentifiedSoFar->insert(ad->item); | 0 | ||||||||||||||||||||||||
2209 | break; never executed: break; | 0 | ||||||||||||||||||||||||
2210 | case never executed: AnchorData::Sequential:case AnchorData::Sequential: never executed: case AnchorData::Sequential: | 0 | ||||||||||||||||||||||||
2211 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(static_cast<const SequentialAnchorData *>(ad)->m_edges)>::type> _container_((static_cast<const SequentialAnchorData *>(ad)->m_edges)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const AnchorData *d = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||||||||||||||
2212 | identifyNonFloatItems_helper(d, nonFloatingItemsIdentifiedSoFar); never executed: identifyNonFloatItems_helper(d, nonFloatingItemsIdentifiedSoFar); | 0 | ||||||||||||||||||||||||
2213 | break; never executed: break; | 0 | ||||||||||||||||||||||||
2214 | case never executed: AnchorData::Parallel:case AnchorData::Parallel: never executed: case AnchorData::Parallel: | 0 | ||||||||||||||||||||||||
2215 | identifyNonFloatItems_helper(static_cast<const ParallelAnchorData *>(ad)->firstEdge, nonFloatingItemsIdentifiedSoFar); | - | ||||||||||||||||||||||||
2216 | identifyNonFloatItems_helper(static_cast<const ParallelAnchorData *>(ad)->secondEdge, nonFloatingItemsIdentifiedSoFar); | - | ||||||||||||||||||||||||
2217 | break; never executed: break; | 0 | ||||||||||||||||||||||||
2218 | } | - | ||||||||||||||||||||||||
2219 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2220 | - | |||||||||||||||||||||||||
2221 | - | |||||||||||||||||||||||||
2222 | - | |||||||||||||||||||||||||
2223 | - | |||||||||||||||||||||||||
2224 | - | |||||||||||||||||||||||||
2225 | - | |||||||||||||||||||||||||
2226 | - | |||||||||||||||||||||||||
2227 | void QGraphicsAnchorLayoutPrivate::setItemsGeometries(const QRectF &geom) | - | ||||||||||||||||||||||||
2228 | { | - | ||||||||||||||||||||||||
2229 | QGraphicsAnchorLayout * const q = q_func(); | - | ||||||||||||||||||||||||
2230 | AnchorVertex *firstH, *secondH, *firstV, *secondV; | - | ||||||||||||||||||||||||
2231 | - | |||||||||||||||||||||||||
2232 | qreal top; | - | ||||||||||||||||||||||||
2233 | qreal left; | - | ||||||||||||||||||||||||
2234 | qreal right; | - | ||||||||||||||||||||||||
2235 | - | |||||||||||||||||||||||||
2236 | q->getContentsMargins(&left, &top, &right, 0); | - | ||||||||||||||||||||||||
2237 | const Qt::LayoutDirection visualDir = visualDirection(); | - | ||||||||||||||||||||||||
2238 | if (visualDir == Qt::RightToLeft
| 0 | ||||||||||||||||||||||||
2239 | qSwap(left, right); never executed: qSwap(left, right); | 0 | ||||||||||||||||||||||||
2240 | - | |||||||||||||||||||||||||
2241 | left += geom.left(); | - | ||||||||||||||||||||||||
2242 | top += geom.top(); | - | ||||||||||||||||||||||||
2243 | right = geom.right() - right; | - | ||||||||||||||||||||||||
2244 | - | |||||||||||||||||||||||||
2245 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(items)>::type> _container_((items)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGraphicsLayoutItem *item = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
2246 | QRectF newGeom; | - | ||||||||||||||||||||||||
2247 | QSizeF itemPreferredSize = item->effectiveSizeHint(Qt::PreferredSize); | - | ||||||||||||||||||||||||
2248 | if (m_floatItems[Horizontal].contains(item)
| 0 | ||||||||||||||||||||||||
2249 | newGeom.setLeft(0); | - | ||||||||||||||||||||||||
2250 | newGeom.setRight(itemPreferredSize.width()); | - | ||||||||||||||||||||||||
2251 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2252 | firstH = internalVertex(item, Qt::AnchorLeft); | - | ||||||||||||||||||||||||
2253 | secondH = internalVertex(item, Qt::AnchorRight); | - | ||||||||||||||||||||||||
2254 | - | |||||||||||||||||||||||||
2255 | if (visualDir == Qt::LeftToRight
| 0 | ||||||||||||||||||||||||
2256 | newGeom.setLeft(left + firstH->distance); | - | ||||||||||||||||||||||||
2257 | newGeom.setRight(left + secondH->distance); | - | ||||||||||||||||||||||||
2258 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2259 | newGeom.setLeft(right - secondH->distance); | - | ||||||||||||||||||||||||
2260 | newGeom.setRight(right - firstH->distance); | - | ||||||||||||||||||||||||
2261 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2262 | } | - | ||||||||||||||||||||||||
2263 | - | |||||||||||||||||||||||||
2264 | if (m_floatItems[Vertical].contains(item)
| 0 | ||||||||||||||||||||||||
2265 | newGeom.setTop(0); | - | ||||||||||||||||||||||||
2266 | newGeom.setBottom(itemPreferredSize.height()); | - | ||||||||||||||||||||||||
2267 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2268 | firstV = internalVertex(item, Qt::AnchorTop); | - | ||||||||||||||||||||||||
2269 | secondV = internalVertex(item, Qt::AnchorBottom); | - | ||||||||||||||||||||||||
2270 | - | |||||||||||||||||||||||||
2271 | newGeom.setTop(top + firstV->distance); | - | ||||||||||||||||||||||||
2272 | newGeom.setBottom(top + secondV->distance); | - | ||||||||||||||||||||||||
2273 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2274 | - | |||||||||||||||||||||||||
2275 | item->setGeometry(newGeom); | - | ||||||||||||||||||||||||
2276 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2277 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2278 | - | |||||||||||||||||||||||||
2279 | - | |||||||||||||||||||||||||
2280 | - | |||||||||||||||||||||||||
2281 | - | |||||||||||||||||||||||||
2282 | - | |||||||||||||||||||||||||
2283 | - | |||||||||||||||||||||||||
2284 | - | |||||||||||||||||||||||||
2285 | void QGraphicsAnchorLayoutPrivate::calculateVertexPositions( | - | ||||||||||||||||||||||||
2286 | QGraphicsAnchorLayoutPrivate::Orientation orientation) | - | ||||||||||||||||||||||||
2287 | { | - | ||||||||||||||||||||||||
2288 | QQueue<QPair<AnchorVertex *, AnchorVertex *> > queue; | - | ||||||||||||||||||||||||
2289 | QSet<AnchorVertex *> visited; | - | ||||||||||||||||||||||||
2290 | - | |||||||||||||||||||||||||
2291 | - | |||||||||||||||||||||||||
2292 | AnchorVertex *root = layoutFirstVertex[orientation]; | - | ||||||||||||||||||||||||
2293 | - | |||||||||||||||||||||||||
2294 | root->distance = 0; | - | ||||||||||||||||||||||||
2295 | visited.insert(root); | - | ||||||||||||||||||||||||
2296 | - | |||||||||||||||||||||||||
2297 | - | |||||||||||||||||||||||||
2298 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(graph[orientation].adjacentVertices(root))>::type> _container_((graph[orientation].adjacentVertices(root))); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (AnchorVertex *v = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
2299 | queue.enqueue(qMakePair(root, v)); | - | ||||||||||||||||||||||||
2300 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2301 | - | |||||||||||||||||||||||||
2302 | - | |||||||||||||||||||||||||
2303 | setupEdgesInterpolation(orientation); | - | ||||||||||||||||||||||||
2304 | - | |||||||||||||||||||||||||
2305 | - | |||||||||||||||||||||||||
2306 | while (!queue.isEmpty()
| 0 | ||||||||||||||||||||||||
2307 | QPair<AnchorVertex *, AnchorVertex *> pair = queue.dequeue(); | - | ||||||||||||||||||||||||
2308 | AnchorData *edge = graph[orientation].edgeData(pair.first, pair.second); | - | ||||||||||||||||||||||||
2309 | - | |||||||||||||||||||||||||
2310 | if (visited.contains(pair.second)
| 0 | ||||||||||||||||||||||||
2311 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
2312 | - | |||||||||||||||||||||||||
2313 | visited.insert(pair.second); | - | ||||||||||||||||||||||||
2314 | interpolateEdge(pair.first, edge); | - | ||||||||||||||||||||||||
2315 | - | |||||||||||||||||||||||||
2316 | QList<AnchorVertex *> adjacents = graph[orientation].adjacentVertices(pair.second); | - | ||||||||||||||||||||||||
2317 | for (int i = 0; i < adjacents.count()
| 0 | ||||||||||||||||||||||||
2318 | if (!visited.contains(adjacents.at(i))
| 0 | ||||||||||||||||||||||||
2319 | queue.enqueue(qMakePair(pair.second, adjacents.at(i))); never executed: queue.enqueue(qMakePair(pair.second, adjacents.at(i))); | 0 | ||||||||||||||||||||||||
2320 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2321 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2322 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2323 | void QGraphicsAnchorLayoutPrivate::setupEdgesInterpolation( | - | ||||||||||||||||||||||||
2324 | Orientation orientation) | - | ||||||||||||||||||||||||
2325 | { | - | ||||||||||||||||||||||||
2326 | QGraphicsAnchorLayout * const q = q_func(); | - | ||||||||||||||||||||||||
2327 | - | |||||||||||||||||||||||||
2328 | qreal current; | - | ||||||||||||||||||||||||
2329 | current = (
| 0 | ||||||||||||||||||||||||
2330 | - | |||||||||||||||||||||||||
2331 | QPair<Interval, qreal> result; | - | ||||||||||||||||||||||||
2332 | result = getFactor(current, | - | ||||||||||||||||||||||||
2333 | sizeHints[orientation][Qt::MinimumSize], | - | ||||||||||||||||||||||||
2334 | sizeHints[orientation][Qt::PreferredSize], | - | ||||||||||||||||||||||||
2335 | sizeHints[orientation][Qt::PreferredSize], | - | ||||||||||||||||||||||||
2336 | sizeHints[orientation][Qt::PreferredSize], | - | ||||||||||||||||||||||||
2337 | sizeHints[orientation][Qt::MaximumSize]); | - | ||||||||||||||||||||||||
2338 | - | |||||||||||||||||||||||||
2339 | interpolationInterval[orientation] = result.first; | - | ||||||||||||||||||||||||
2340 | interpolationProgress[orientation] = result.second; | - | ||||||||||||||||||||||||
2341 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2342 | void QGraphicsAnchorLayoutPrivate::interpolateEdge(AnchorVertex *base, AnchorData *edge) | - | ||||||||||||||||||||||||
2343 | { | - | ||||||||||||||||||||||||
2344 | const Orientation orientation = Orientation(edge->orientation); | - | ||||||||||||||||||||||||
2345 | const QPair<Interval, qreal> factor(interpolationInterval[orientation], | - | ||||||||||||||||||||||||
2346 | interpolationProgress[orientation]); | - | ||||||||||||||||||||||||
2347 | - | |||||||||||||||||||||||||
2348 | qreal edgeDistance = interpolate(factor, edge->sizeAtMinimum, edge->sizeAtPreferred, | - | ||||||||||||||||||||||||
2349 | edge->sizeAtPreferred, edge->sizeAtPreferred, | - | ||||||||||||||||||||||||
2350 | edge->sizeAtMaximum); | - | ||||||||||||||||||||||||
2351 | - | |||||||||||||||||||||||||
2352 | ((!(edge->from == base || edge->to == base)) ? qt_assert("edge->from == base || edge->to == base",__FILE__,2788) : qt_noop()); | - | ||||||||||||||||||||||||
2353 | - | |||||||||||||||||||||||||
2354 | - | |||||||||||||||||||||||||
2355 | if (edge->from == base
| 0 | ||||||||||||||||||||||||
2356 | edge->to->distance = base->distance + edgeDistance; | - | ||||||||||||||||||||||||
2357 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2358 | edge->from->distance = base->distance - edgeDistance; | - | ||||||||||||||||||||||||
2359 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2360 | } | - | ||||||||||||||||||||||||
2361 | - | |||||||||||||||||||||||||
2362 | bool QGraphicsAnchorLayoutPrivate::solveMinMax(const QList<QSimplexConstraint *> &constraints, | - | ||||||||||||||||||||||||
2363 | GraphPath path, qreal *min, qreal *max) | - | ||||||||||||||||||||||||
2364 | { | - | ||||||||||||||||||||||||
2365 | QSimplex simplex; | - | ||||||||||||||||||||||||
2366 | bool feasible = simplex.setConstraints(constraints); | - | ||||||||||||||||||||||||
2367 | if (feasible
| 0 | ||||||||||||||||||||||||
2368 | - | |||||||||||||||||||||||||
2369 | QSimplexConstraint objective; | - | ||||||||||||||||||||||||
2370 | QSet<AnchorData *>::const_iterator iter; | - | ||||||||||||||||||||||||
2371 | for (iter = path.positives.constBegin(); iter != path.positives.constEnd()
| 0 | ||||||||||||||||||||||||
2372 | objective.variables.insert(*iter, 1.0); never executed: objective.variables.insert(*iter, 1.0); | 0 | ||||||||||||||||||||||||
2373 | - | |||||||||||||||||||||||||
2374 | for (iter = path.negatives.constBegin(); iter != path.negatives.constEnd()
| 0 | ||||||||||||||||||||||||
2375 | objective.variables.insert(*iter, -1.0); never executed: objective.variables.insert(*iter, -1.0); | 0 | ||||||||||||||||||||||||
2376 | - | |||||||||||||||||||||||||
2377 | const qreal objectiveOffset = (path.positives.count() - path.negatives.count()) * g_offset; | - | ||||||||||||||||||||||||
2378 | simplex.setObjective(&objective); | - | ||||||||||||||||||||||||
2379 | - | |||||||||||||||||||||||||
2380 | - | |||||||||||||||||||||||||
2381 | *min = simplex.solveMin() - objectiveOffset; | - | ||||||||||||||||||||||||
2382 | - | |||||||||||||||||||||||||
2383 | - | |||||||||||||||||||||||||
2384 | QList<AnchorData *> variables = getVariables(constraints); | - | ||||||||||||||||||||||||
2385 | for (int i = 0; i < variables.size()
| 0 | ||||||||||||||||||||||||
2386 | AnchorData *ad = static_cast<AnchorData *>(variables.at(i)); | - | ||||||||||||||||||||||||
2387 | ad->sizeAtMinimum = ad->result - g_offset; | - | ||||||||||||||||||||||||
2388 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2389 | - | |||||||||||||||||||||||||
2390 | - | |||||||||||||||||||||||||
2391 | *max = simplex.solveMax() - objectiveOffset; | - | ||||||||||||||||||||||||
2392 | - | |||||||||||||||||||||||||
2393 | - | |||||||||||||||||||||||||
2394 | for (int i = 0; i < variables.size()
| 0 | ||||||||||||||||||||||||
2395 | AnchorData *ad = static_cast<AnchorData *>(variables.at(i)); | - | ||||||||||||||||||||||||
2396 | ad->sizeAtMaximum = ad->result - g_offset; | - | ||||||||||||||||||||||||
2397 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2398 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2399 | return never executed: feasible;return feasible; never executed: return feasible; | 0 | ||||||||||||||||||||||||
2400 | } | - | ||||||||||||||||||||||||
2401 | - | |||||||||||||||||||||||||
2402 | enum slackType { Grower = -1, Shrinker = 1 }; | - | ||||||||||||||||||||||||
2403 | static QPair<QSimplexVariable *, QSimplexConstraint *> createSlack(QSimplexConstraint *sizeConstraint, | - | ||||||||||||||||||||||||
2404 | qreal interval, slackType type) | - | ||||||||||||||||||||||||
2405 | { | - | ||||||||||||||||||||||||
2406 | QSimplexVariable *slack = new QSimplexVariable; | - | ||||||||||||||||||||||||
2407 | sizeConstraint->variables.insert(slack, type); | - | ||||||||||||||||||||||||
2408 | - | |||||||||||||||||||||||||
2409 | QSimplexConstraint *limit = new QSimplexConstraint; | - | ||||||||||||||||||||||||
2410 | limit->variables.insert(slack, 1.0); | - | ||||||||||||||||||||||||
2411 | limit->ratio = QSimplexConstraint::LessOrEqual; | - | ||||||||||||||||||||||||
2412 | limit->constant = interval; | - | ||||||||||||||||||||||||
2413 | - | |||||||||||||||||||||||||
2414 | return never executed: qMakePair(slack, limit);return qMakePair(slack, limit); never executed: return qMakePair(slack, limit); | 0 | ||||||||||||||||||||||||
2415 | } | - | ||||||||||||||||||||||||
2416 | - | |||||||||||||||||||||||||
2417 | bool QGraphicsAnchorLayoutPrivate::solvePreferred(const QList<QSimplexConstraint *> &constraints, | - | ||||||||||||||||||||||||
2418 | const QList<AnchorData *> &variables) | - | ||||||||||||||||||||||||
2419 | { | - | ||||||||||||||||||||||||
2420 | QList<QSimplexConstraint *> preferredConstraints; | - | ||||||||||||||||||||||||
2421 | QList<QSimplexVariable *> preferredVariables; | - | ||||||||||||||||||||||||
2422 | QSimplexConstraint objective; | - | ||||||||||||||||||||||||
2423 | for (int i = 0; i < variables.size()
| 0 | ||||||||||||||||||||||||
2424 | AnchorData *ad = variables.at(i); | - | ||||||||||||||||||||||||
2425 | - | |||||||||||||||||||||||||
2426 | - | |||||||||||||||||||||||||
2427 | if (ad->isLayoutAnchor
| 0 | ||||||||||||||||||||||||
2428 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
2429 | - | |||||||||||||||||||||||||
2430 | - | |||||||||||||||||||||||||
2431 | - | |||||||||||||||||||||||||
2432 | QSimplexConstraint *sizeConstraint = new QSimplexConstraint; | - | ||||||||||||||||||||||||
2433 | preferredConstraints += sizeConstraint; | - | ||||||||||||||||||||||||
2434 | sizeConstraint->variables.insert(ad, 1.0); | - | ||||||||||||||||||||||||
2435 | sizeConstraint->constant = ad->prefSize + g_offset; | - | ||||||||||||||||||||||||
2436 | - | |||||||||||||||||||||||||
2437 | - | |||||||||||||||||||||||||
2438 | QPair<QSimplexVariable *, QSimplexConstraint *> slack; | - | ||||||||||||||||||||||||
2439 | const qreal softShrinkInterval = ad->prefSize - ad->minPrefSize; | - | ||||||||||||||||||||||||
2440 | if (softShrinkInterval
| 0 | ||||||||||||||||||||||||
2441 | slack = createSlack(sizeConstraint, softShrinkInterval, Shrinker); | - | ||||||||||||||||||||||||
2442 | preferredVariables += slack.first; | - | ||||||||||||||||||||||||
2443 | preferredConstraints += slack.second; | - | ||||||||||||||||||||||||
2444 | - | |||||||||||||||||||||||||
2445 | - | |||||||||||||||||||||||||
2446 | objective.variables.insert(slack.first, 1.0); | - | ||||||||||||||||||||||||
2447 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2448 | - | |||||||||||||||||||||||||
2449 | - | |||||||||||||||||||||||||
2450 | const qreal softGrowInterval = ad->maxPrefSize - ad->prefSize; | - | ||||||||||||||||||||||||
2451 | if (softGrowInterval
| 0 | ||||||||||||||||||||||||
2452 | slack = createSlack(sizeConstraint, softGrowInterval, Grower); | - | ||||||||||||||||||||||||
2453 | preferredVariables += slack.first; | - | ||||||||||||||||||||||||
2454 | preferredConstraints += slack.second; | - | ||||||||||||||||||||||||
2455 | - | |||||||||||||||||||||||||
2456 | - | |||||||||||||||||||||||||
2457 | objective.variables.insert(slack.first, 1.0); | - | ||||||||||||||||||||||||
2458 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2459 | - | |||||||||||||||||||||||||
2460 | - | |||||||||||||||||||||||||
2461 | const qreal hardShrinkInterval = ad->minPrefSize - ad->minSize; | - | ||||||||||||||||||||||||
2462 | if (hardShrinkInterval
| 0 | ||||||||||||||||||||||||
2463 | slack = createSlack(sizeConstraint, hardShrinkInterval, Shrinker); | - | ||||||||||||||||||||||||
2464 | preferredVariables += slack.first; | - | ||||||||||||||||||||||||
2465 | preferredConstraints += slack.second; | - | ||||||||||||||||||||||||
2466 | - | |||||||||||||||||||||||||
2467 | - | |||||||||||||||||||||||||
2468 | objective.variables.insert(slack.first, variables.size()); | - | ||||||||||||||||||||||||
2469 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2470 | - | |||||||||||||||||||||||||
2471 | - | |||||||||||||||||||||||||
2472 | const qreal hardGrowInterval = ad->maxSize - ad->maxPrefSize; | - | ||||||||||||||||||||||||
2473 | if (hardGrowInterval
| 0 | ||||||||||||||||||||||||
2474 | slack = createSlack(sizeConstraint, hardGrowInterval, Grower); | - | ||||||||||||||||||||||||
2475 | preferredVariables += slack.first; | - | ||||||||||||||||||||||||
2476 | preferredConstraints += slack.second; | - | ||||||||||||||||||||||||
2477 | - | |||||||||||||||||||||||||
2478 | - | |||||||||||||||||||||||||
2479 | objective.variables.insert(slack.first, variables.size()); | - | ||||||||||||||||||||||||
2480 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2481 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2482 | - | |||||||||||||||||||||||||
2483 | QSimplex *simplex = new QSimplex; | - | ||||||||||||||||||||||||
2484 | bool feasible = simplex->setConstraints(constraints + preferredConstraints); | - | ||||||||||||||||||||||||
2485 | if (feasible
| 0 | ||||||||||||||||||||||||
2486 | simplex->setObjective(&objective); | - | ||||||||||||||||||||||||
2487 | - | |||||||||||||||||||||||||
2488 | - | |||||||||||||||||||||||||
2489 | simplex->solveMin(); | - | ||||||||||||||||||||||||
2490 | - | |||||||||||||||||||||||||
2491 | - | |||||||||||||||||||||||||
2492 | for (int i = 0; i < variables.size()
| 0 | ||||||||||||||||||||||||
2493 | AnchorData *ad = variables.at(i); | - | ||||||||||||||||||||||||
2494 | ad->sizeAtPreferred = ad->result - g_offset; | - | ||||||||||||||||||||||||
2495 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2496 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2497 | - | |||||||||||||||||||||||||
2498 | - | |||||||||||||||||||||||||
2499 | - | |||||||||||||||||||||||||
2500 | delete simplex; | - | ||||||||||||||||||||||||
2501 | - | |||||||||||||||||||||||||
2502 | - | |||||||||||||||||||||||||
2503 | qDeleteAll(preferredConstraints); | - | ||||||||||||||||||||||||
2504 | qDeleteAll(preferredVariables); | - | ||||||||||||||||||||||||
2505 | - | |||||||||||||||||||||||||
2506 | return never executed: feasible;return feasible; never executed: return feasible; | 0 | ||||||||||||||||||||||||
2507 | } | - | ||||||||||||||||||||||||
2508 | bool QGraphicsAnchorLayoutPrivate::hasConflicts() const | - | ||||||||||||||||||||||||
2509 | { | - | ||||||||||||||||||||||||
2510 | QGraphicsAnchorLayoutPrivate *that = const_cast<QGraphicsAnchorLayoutPrivate*>(this); | - | ||||||||||||||||||||||||
2511 | that->calculateGraphs(); | - | ||||||||||||||||||||||||
2512 | - | |||||||||||||||||||||||||
2513 | bool floatConflict = !m_floatItems[0].isEmpty()
| 0 | ||||||||||||||||||||||||
2514 | - | |||||||||||||||||||||||||
2515 | return never executed: graphHasConflicts[0]return graphHasConflicts[0] || graphHasConflicts[1] || floatConflict;
never executed: return graphHasConflicts[0] || graphHasConflicts[1] || floatConflict; | 0 | ||||||||||||||||||||||||
2516 | } | - | ||||||||||||||||||||||||
2517 | - | |||||||||||||||||||||||||
2518 | - | |||||||||||||||||||||||||
2519 | void QGraphicsAnchorLayoutPrivate::dumpGraph(const QString &name) | - | ||||||||||||||||||||||||
2520 | { | - | ||||||||||||||||||||||||
2521 | QFile file(QString::fromLatin1("anchorlayout.%1.dot").arg(name)); | - | ||||||||||||||||||||||||
2522 | if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)
| 0 | ||||||||||||||||||||||||
2523 | QMessageLogger(__FILE__, 2986, __PRETTY_FUNCTION__).warning("Could not write to %s", file.fileName().toLocal8Bit().constData()); never executed: QMessageLogger(__FILE__, 2986, __PRETTY_FUNCTION__).warning("Could not write to %s", file.fileName().toLocal8Bit().constData()); | 0 | ||||||||||||||||||||||||
2524 | - | |||||||||||||||||||||||||
2525 | QString str = QString::fromLatin1("digraph anchorlayout {\nnode [shape=\"rect\"]\n%1}"); | - | ||||||||||||||||||||||||
2526 | QString dotContents = graph[0].serializeToDot(); | - | ||||||||||||||||||||||||
2527 | dotContents += graph[1].serializeToDot(); | - | ||||||||||||||||||||||||
2528 | file.write(str.arg(dotContents).toLocal8Bit()); | - | ||||||||||||||||||||||||
2529 | - | |||||||||||||||||||||||||
2530 | file.close(); | - | ||||||||||||||||||||||||
2531 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2532 | - | |||||||||||||||||||||||||
2533 | - | |||||||||||||||||||||||||
2534 | - | |||||||||||||||||||||||||
Switch to Source code | Preprocessed file |