Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/util/qgridlayoutengine.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||||||||
2 | ** | - | ||||||||||||||||||||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||||||||||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||||||||
5 | ** | - | ||||||||||||||||||||||||
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||||||||||||||||||||
7 | ** | - | ||||||||||||||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||
14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||
15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||||||||||||||
16 | ** | - | ||||||||||||||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||
19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||||||||||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||||||||
25 | ** | - | ||||||||||||||||||||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||||||||
29 | ** | - | ||||||||||||||||||||||||
30 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||
31 | ** | - | ||||||||||||||||||||||||
32 | ****************************************************************************/ | - | ||||||||||||||||||||||||
33 | - | |||||||||||||||||||||||||
34 | #include "qglobal.h" | - | ||||||||||||||||||||||||
35 | - | |||||||||||||||||||||||||
36 | #include "qgridlayoutengine_p.h" | - | ||||||||||||||||||||||||
37 | #include "qvarlengtharray.h" | - | ||||||||||||||||||||||||
38 | - | |||||||||||||||||||||||||
39 | #include <QtDebug> | - | ||||||||||||||||||||||||
40 | #include <QtCore/qmath.h> | - | ||||||||||||||||||||||||
41 | - | |||||||||||||||||||||||||
42 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
43 | - | |||||||||||||||||||||||||
44 | template <typename T> | - | ||||||||||||||||||||||||
45 | static void insertOrRemoveItems(QVector<T> &items, int index, int delta) | - | ||||||||||||||||||||||||
46 | { | - | ||||||||||||||||||||||||
47 | int count = items.count(); | - | ||||||||||||||||||||||||
48 | if (index < count) {
| 0 | ||||||||||||||||||||||||
49 | if (delta > 0) {
| 0 | ||||||||||||||||||||||||
50 | items.insert(index, delta, T()); | - | ||||||||||||||||||||||||
51 | } else if (delta < 0) { never executed: end of block
| 0 | ||||||||||||||||||||||||
52 | items.remove(index, qMin(-delta, count - index)); | - | ||||||||||||||||||||||||
53 | } never executed: end of block | 0 | ||||||||||||||||||||||||
54 | } never executed: end of block | 0 | ||||||||||||||||||||||||
55 | } never executed: end of block | 0 | ||||||||||||||||||||||||
56 | - | |||||||||||||||||||||||||
57 | static qreal growthFactorBelowPreferredSize(qreal desired, qreal sumAvailable, qreal sumDesired) | - | ||||||||||||||||||||||||
58 | { | - | ||||||||||||||||||||||||
59 | Q_ASSERT(sumDesired != 0.0); | - | ||||||||||||||||||||||||
60 | return desired * qPow(sumAvailable / sumDesired, desired / sumDesired); never executed: return desired * qPow(sumAvailable / sumDesired, desired / sumDesired); | 0 | ||||||||||||||||||||||||
61 | } | - | ||||||||||||||||||||||||
62 | - | |||||||||||||||||||||||||
63 | static qreal fixedDescent(qreal descent, qreal ascent, qreal targetSize) | - | ||||||||||||||||||||||||
64 | { | - | ||||||||||||||||||||||||
65 | if (descent < 0.0)
| 0 | ||||||||||||||||||||||||
66 | return -1.0; never executed: return -1.0; | 0 | ||||||||||||||||||||||||
67 | - | |||||||||||||||||||||||||
68 | Q_ASSERT(descent >= 0.0); | - | ||||||||||||||||||||||||
69 | Q_ASSERT(ascent >= 0.0); | - | ||||||||||||||||||||||||
70 | Q_ASSERT(targetSize >= ascent + descent); | - | ||||||||||||||||||||||||
71 | - | |||||||||||||||||||||||||
72 | qreal extra = targetSize - (ascent + descent); | - | ||||||||||||||||||||||||
73 | return descent + (extra / 2.0); never executed: return descent + (extra / 2.0); | 0 | ||||||||||||||||||||||||
74 | } | - | ||||||||||||||||||||||||
75 | - | |||||||||||||||||||||||||
76 | static qreal compare(const QGridLayoutBox &box1, const QGridLayoutBox &box2, int which) | - | ||||||||||||||||||||||||
77 | { | - | ||||||||||||||||||||||||
78 | qreal size1 = box1.q_sizes(which); | - | ||||||||||||||||||||||||
79 | qreal size2 = box2.q_sizes(which); | - | ||||||||||||||||||||||||
80 | - | |||||||||||||||||||||||||
81 | if (which == MaximumSize) {
| 0 | ||||||||||||||||||||||||
82 | return size2 - size1; never executed: return size2 - size1; | 0 | ||||||||||||||||||||||||
83 | } else { | - | ||||||||||||||||||||||||
84 | return size1 - size2; never executed: return size1 - size2; | 0 | ||||||||||||||||||||||||
85 | } | - | ||||||||||||||||||||||||
86 | } | - | ||||||||||||||||||||||||
87 | - | |||||||||||||||||||||||||
88 | void QGridLayoutBox::add(const QGridLayoutBox &other, int stretch, qreal spacing) | - | ||||||||||||||||||||||||
89 | { | - | ||||||||||||||||||||||||
90 | Q_ASSERT(q_minimumDescent < 0.0); | - | ||||||||||||||||||||||||
91 | - | |||||||||||||||||||||||||
92 | q_minimumSize += other.q_minimumSize + spacing; | - | ||||||||||||||||||||||||
93 | q_preferredSize += other.q_preferredSize + spacing; | - | ||||||||||||||||||||||||
94 | q_maximumSize += ((stretch == 0) ? other.q_preferredSize : other.q_maximumSize) + spacing;
| 0 | ||||||||||||||||||||||||
95 | } never executed: end of block | 0 | ||||||||||||||||||||||||
96 | - | |||||||||||||||||||||||||
97 | void QGridLayoutBox::combine(const QGridLayoutBox &other) | - | ||||||||||||||||||||||||
98 | { | - | ||||||||||||||||||||||||
99 | q_minimumDescent = qMax(q_minimumDescent, other.q_minimumDescent); | - | ||||||||||||||||||||||||
100 | q_minimumAscent = qMax(q_minimumAscent, other.q_minimumAscent); | - | ||||||||||||||||||||||||
101 | - | |||||||||||||||||||||||||
102 | q_minimumSize = qMax(q_minimumAscent + q_minimumDescent, | - | ||||||||||||||||||||||||
103 | qMax(q_minimumSize, other.q_minimumSize)); | - | ||||||||||||||||||||||||
104 | qreal maxMax; | - | ||||||||||||||||||||||||
105 | if (q_maximumSize == FLT_MAX && other.q_maximumSize != FLT_MAX)
| 0 | ||||||||||||||||||||||||
106 | maxMax = other.q_maximumSize; never executed: maxMax = other.q_maximumSize; | 0 | ||||||||||||||||||||||||
107 | else if (other.q_maximumSize == FLT_MAX && q_maximumSize != FLT_MAX)
| 0 | ||||||||||||||||||||||||
108 | maxMax = q_maximumSize; never executed: maxMax = q_maximumSize; | 0 | ||||||||||||||||||||||||
109 | else | - | ||||||||||||||||||||||||
110 | maxMax = qMax(q_maximumSize, other.q_maximumSize); never executed: maxMax = qMax(q_maximumSize, other.q_maximumSize); | 0 | ||||||||||||||||||||||||
111 | - | |||||||||||||||||||||||||
112 | q_maximumSize = qMax(q_minimumSize, maxMax); | - | ||||||||||||||||||||||||
113 | q_preferredSize = qBound(q_minimumSize, qMax(q_preferredSize, other.q_preferredSize), | - | ||||||||||||||||||||||||
114 | q_maximumSize); | - | ||||||||||||||||||||||||
115 | } never executed: end of block | 0 | ||||||||||||||||||||||||
116 | - | |||||||||||||||||||||||||
117 | void QGridLayoutBox::normalize() | - | ||||||||||||||||||||||||
118 | { | - | ||||||||||||||||||||||||
119 | q_maximumSize = qMax(qreal(0.0), q_maximumSize); | - | ||||||||||||||||||||||||
120 | q_minimumSize = qBound(qreal(0.0), q_minimumSize, q_maximumSize); | - | ||||||||||||||||||||||||
121 | q_preferredSize = qBound(q_minimumSize, q_preferredSize, q_maximumSize); | - | ||||||||||||||||||||||||
122 | q_minimumDescent = qMin(q_minimumDescent, q_minimumSize); | - | ||||||||||||||||||||||||
123 | - | |||||||||||||||||||||||||
124 | Q_ASSERT((q_minimumDescent < 0.0) == (q_minimumAscent < 0.0)); | - | ||||||||||||||||||||||||
125 | } never executed: end of block | 0 | ||||||||||||||||||||||||
126 | - | |||||||||||||||||||||||||
127 | #ifdef QGRIDLAYOUTENGINE_DEBUG | - | ||||||||||||||||||||||||
128 | void QGridLayoutBox::dump(int indent) const | - | ||||||||||||||||||||||||
129 | { | - | ||||||||||||||||||||||||
130 | qDebug("%*sBox (%g <= %g <= %g [%g/%g])", indent, "", q_minimumSize, q_preferredSize, | - | ||||||||||||||||||||||||
131 | q_maximumSize, q_minimumAscent, q_minimumDescent); | - | ||||||||||||||||||||||||
132 | } | - | ||||||||||||||||||||||||
133 | #endif | - | ||||||||||||||||||||||||
134 | - | |||||||||||||||||||||||||
135 | bool operator==(const QGridLayoutBox &box1, const QGridLayoutBox &box2) | - | ||||||||||||||||||||||||
136 | { | - | ||||||||||||||||||||||||
137 | for (int i = 0; i < NSizes; ++i) {
| 0 | ||||||||||||||||||||||||
138 | if (box1.q_sizes(i) != box2.q_sizes(i))
| 0 | ||||||||||||||||||||||||
139 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
140 | } never executed: end of block | 0 | ||||||||||||||||||||||||
141 | return box1.q_minimumDescent == box2.q_minimumDescent never executed: return box1.q_minimumDescent == box2.q_minimumDescent && box1.q_minimumAscent == box2.q_minimumAscent;
| 0 | ||||||||||||||||||||||||
142 | && box1.q_minimumAscent == box2.q_minimumAscent; never executed: return box1.q_minimumDescent == box2.q_minimumDescent && box1.q_minimumAscent == box2.q_minimumAscent;
| 0 | ||||||||||||||||||||||||
143 | } | - | ||||||||||||||||||||||||
144 | - | |||||||||||||||||||||||||
145 | void QGridLayoutRowData::reset(int count) | - | ||||||||||||||||||||||||
146 | { | - | ||||||||||||||||||||||||
147 | ignore.fill(false, count); | - | ||||||||||||||||||||||||
148 | boxes.fill(QGridLayoutBox(), count); | - | ||||||||||||||||||||||||
149 | multiCellMap.clear(); | - | ||||||||||||||||||||||||
150 | stretches.fill(0, count); | - | ||||||||||||||||||||||||
151 | spacings.fill(0.0, count); | - | ||||||||||||||||||||||||
152 | hasIgnoreFlag = false; | - | ||||||||||||||||||||||||
153 | } never executed: end of block | 0 | ||||||||||||||||||||||||
154 | - | |||||||||||||||||||||||||
155 | void QGridLayoutRowData::distributeMultiCells(const QGridLayoutRowInfo &rowInfo, bool snapToPixelGrid) | - | ||||||||||||||||||||||||
156 | { | - | ||||||||||||||||||||||||
157 | MultiCellMap::const_iterator i = multiCellMap.constBegin(); | - | ||||||||||||||||||||||||
158 | for (; i != multiCellMap.constEnd(); ++i) {
| 0 | ||||||||||||||||||||||||
159 | int start = i.key().first; | - | ||||||||||||||||||||||||
160 | int span = i.key().second; | - | ||||||||||||||||||||||||
161 | int end = start + span; | - | ||||||||||||||||||||||||
162 | const QGridLayoutBox &box = i.value().q_box; | - | ||||||||||||||||||||||||
163 | int stretch = i.value().q_stretch; | - | ||||||||||||||||||||||||
164 | - | |||||||||||||||||||||||||
165 | QGridLayoutBox totalBox = this->totalBox(start, end); | - | ||||||||||||||||||||||||
166 | QVarLengthArray<QGridLayoutBox> extras(span); | - | ||||||||||||||||||||||||
167 | QVarLengthArray<qreal> dummy(span); | - | ||||||||||||||||||||||||
168 | QVarLengthArray<qreal> newSizes(span); | - | ||||||||||||||||||||||||
169 | - | |||||||||||||||||||||||||
170 | for (int j = 0; j < NSizes; ++j) {
| 0 | ||||||||||||||||||||||||
171 | qreal extra = compare(box, totalBox, j); | - | ||||||||||||||||||||||||
172 | if (extra > 0.0) {
| 0 | ||||||||||||||||||||||||
173 | calculateGeometries(start, end, box.q_sizes(j), dummy.data(), newSizes.data(), | - | ||||||||||||||||||||||||
174 | 0, totalBox, rowInfo, snapToPixelGrid); | - | ||||||||||||||||||||||||
175 | - | |||||||||||||||||||||||||
176 | for (int k = 0; k < span; ++k)
| 0 | ||||||||||||||||||||||||
177 | extras[k].q_sizes(j) = newSizes[k]; never executed: extras[k].q_sizes(j) = newSizes[k]; | 0 | ||||||||||||||||||||||||
178 | } never executed: end of block | 0 | ||||||||||||||||||||||||
179 | } never executed: end of block | 0 | ||||||||||||||||||||||||
180 | - | |||||||||||||||||||||||||
181 | for (int k = 0; k < span; ++k) {
| 0 | ||||||||||||||||||||||||
182 | boxes[start + k].combine(extras[k]); | - | ||||||||||||||||||||||||
183 | if (stretch != 0)
| 0 | ||||||||||||||||||||||||
184 | stretches[start + k] = qMax(stretches[start + k], stretch); never executed: stretches[start + k] = qMax(stretches[start + k], stretch); | 0 | ||||||||||||||||||||||||
185 | } never executed: end of block | 0 | ||||||||||||||||||||||||
186 | } never executed: end of block | 0 | ||||||||||||||||||||||||
187 | multiCellMap.clear(); | - | ||||||||||||||||||||||||
188 | } never executed: end of block | 0 | ||||||||||||||||||||||||
189 | namespace { | - | ||||||||||||||||||||||||
190 | - | |||||||||||||||||||||||||
191 | // does not return int | - | ||||||||||||||||||||||||
192 | static inline qreal qround(qreal f) | - | ||||||||||||||||||||||||
193 | { | - | ||||||||||||||||||||||||
194 | return std::floor(f + qreal(0.5)); never executed: return std::floor(f + qreal(0.5)); | 0 | ||||||||||||||||||||||||
195 | } | - | ||||||||||||||||||||||||
196 | - | |||||||||||||||||||||||||
197 | } | - | ||||||||||||||||||||||||
198 | void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSize, qreal *positions, | - | ||||||||||||||||||||||||
199 | qreal *sizes, qreal *descents, | - | ||||||||||||||||||||||||
200 | const QGridLayoutBox &totalBox, | - | ||||||||||||||||||||||||
201 | const QGridLayoutRowInfo &rowInfo, bool snapToPixelGrid) | - | ||||||||||||||||||||||||
202 | { | - | ||||||||||||||||||||||||
203 | Q_ASSERT(end > start); | - | ||||||||||||||||||||||||
204 | - | |||||||||||||||||||||||||
205 | targetSize = qMax(totalBox.q_minimumSize, targetSize); | - | ||||||||||||||||||||||||
206 | - | |||||||||||||||||||||||||
207 | int n = end - start; | - | ||||||||||||||||||||||||
208 | QVarLengthArray<qreal> newSizes(n); | - | ||||||||||||||||||||||||
209 | QVarLengthArray<qreal> factors(n); | - | ||||||||||||||||||||||||
210 | qreal sumFactors = 0.0; | - | ||||||||||||||||||||||||
211 | int sumStretches = 0; | - | ||||||||||||||||||||||||
212 | qreal sumAvailable; | - | ||||||||||||||||||||||||
213 | - | |||||||||||||||||||||||||
214 | for (int i = 0; i < n; ++i) {
| 0 | ||||||||||||||||||||||||
215 | if (stretches[start + i] > 0)
| 0 | ||||||||||||||||||||||||
216 | sumStretches += stretches[start + i]; never executed: sumStretches += stretches[start + i]; | 0 | ||||||||||||||||||||||||
217 | } never executed: end of block | 0 | ||||||||||||||||||||||||
218 | - | |||||||||||||||||||||||||
219 | if (targetSize < totalBox.q_preferredSize) {
| 0 | ||||||||||||||||||||||||
220 | stealBox(start, end, MinimumSize, positions, sizes); | - | ||||||||||||||||||||||||
221 | - | |||||||||||||||||||||||||
222 | sumAvailable = targetSize - totalBox.q_minimumSize; | - | ||||||||||||||||||||||||
223 | if (sumAvailable > 0.0) {
| 0 | ||||||||||||||||||||||||
224 | qreal sumDesired = totalBox.q_preferredSize - totalBox.q_minimumSize; | - | ||||||||||||||||||||||||
225 | - | |||||||||||||||||||||||||
226 | for (int i = 0; i < n; ++i) {
| 0 | ||||||||||||||||||||||||
227 | if (ignore.testBit(start + i)) {
| 0 | ||||||||||||||||||||||||
228 | factors[i] = 0.0; | - | ||||||||||||||||||||||||
229 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
230 | } | - | ||||||||||||||||||||||||
231 | - | |||||||||||||||||||||||||
232 | const QGridLayoutBox &box = boxes.at(start + i); | - | ||||||||||||||||||||||||
233 | qreal desired = box.q_preferredSize - box.q_minimumSize; | - | ||||||||||||||||||||||||
234 | factors[i] = growthFactorBelowPreferredSize(desired, sumAvailable, sumDesired); | - | ||||||||||||||||||||||||
235 | sumFactors += factors[i]; | - | ||||||||||||||||||||||||
236 | } never executed: end of block | 0 | ||||||||||||||||||||||||
237 | - | |||||||||||||||||||||||||
238 | for (int i = 0; i < n; ++i) {
| 0 | ||||||||||||||||||||||||
239 | Q_ASSERT(sumFactors > 0.0); | - | ||||||||||||||||||||||||
240 | qreal delta = sumAvailable * factors[i] / sumFactors; | - | ||||||||||||||||||||||||
241 | newSizes[i] = sizes[i] + delta; | - | ||||||||||||||||||||||||
242 | } never executed: end of block | 0 | ||||||||||||||||||||||||
243 | } never executed: end of block | 0 | ||||||||||||||||||||||||
244 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
245 | bool isLargerThanMaximum = (targetSize > totalBox.q_maximumSize); | - | ||||||||||||||||||||||||
246 | if (isLargerThanMaximum) {
| 0 | ||||||||||||||||||||||||
247 | stealBox(start, end, MaximumSize, positions, sizes); | - | ||||||||||||||||||||||||
248 | sumAvailable = targetSize - totalBox.q_maximumSize; | - | ||||||||||||||||||||||||
249 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
250 | stealBox(start, end, PreferredSize, positions, sizes); | - | ||||||||||||||||||||||||
251 | sumAvailable = targetSize - totalBox.q_preferredSize; | - | ||||||||||||||||||||||||
252 | } never executed: end of block | 0 | ||||||||||||||||||||||||
253 | - | |||||||||||||||||||||||||
254 | if (sumAvailable > 0.0) {
| 0 | ||||||||||||||||||||||||
255 | qreal sumCurrentAvailable = sumAvailable; | - | ||||||||||||||||||||||||
256 | bool somethingHasAMaximumSize = false; | - | ||||||||||||||||||||||||
257 | - | |||||||||||||||||||||||||
258 | qreal sumSizes = 0.0; | - | ||||||||||||||||||||||||
259 | for (int i = 0; i < n; ++i)
| 0 | ||||||||||||||||||||||||
260 | sumSizes += sizes[i]; never executed: sumSizes += sizes[i]; | 0 | ||||||||||||||||||||||||
261 | - | |||||||||||||||||||||||||
262 | for (int i = 0; i < n; ++i) {
| 0 | ||||||||||||||||||||||||
263 | if (ignore.testBit(start + i)) {
| 0 | ||||||||||||||||||||||||
264 | newSizes[i] = 0.0; | - | ||||||||||||||||||||||||
265 | factors[i] = 0.0; | - | ||||||||||||||||||||||||
266 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
267 | } | - | ||||||||||||||||||||||||
268 | - | |||||||||||||||||||||||||
269 | const QGridLayoutBox &box = boxes.at(start + i); | - | ||||||||||||||||||||||||
270 | qreal boxSize; | - | ||||||||||||||||||||||||
271 | - | |||||||||||||||||||||||||
272 | qreal desired; | - | ||||||||||||||||||||||||
273 | if (isLargerThanMaximum) {
| 0 | ||||||||||||||||||||||||
274 | boxSize = box.q_maximumSize; | - | ||||||||||||||||||||||||
275 | desired = rowInfo.boxes.value(start + i).q_maximumSize - boxSize; | - | ||||||||||||||||||||||||
276 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
277 | boxSize = box.q_preferredSize; | - | ||||||||||||||||||||||||
278 | desired = box.q_maximumSize - boxSize; | - | ||||||||||||||||||||||||
279 | } never executed: end of block | 0 | ||||||||||||||||||||||||
280 | if (desired == 0.0) {
| 0 | ||||||||||||||||||||||||
281 | newSizes[i] = sizes[i]; | - | ||||||||||||||||||||||||
282 | factors[i] = 0.0; | - | ||||||||||||||||||||||||
283 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
284 | Q_ASSERT(desired > 0.0); | - | ||||||||||||||||||||||||
285 | - | |||||||||||||||||||||||||
286 | int stretch = stretches[start + i]; | - | ||||||||||||||||||||||||
287 | if (sumStretches == 0) {
| 0 | ||||||||||||||||||||||||
288 | if (hasIgnoreFlag || sizes[i] == 0.0) {
| 0 | ||||||||||||||||||||||||
289 | factors[i] = (stretch < 0) ? 1.0 : 0.0;
| 0 | ||||||||||||||||||||||||
290 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
291 | factors[i] = (stretch < 0) ? sizes[i] : 0.0;
| 0 | ||||||||||||||||||||||||
292 | } never executed: end of block | 0 | ||||||||||||||||||||||||
293 | } else if (stretch == sumStretches) {
| 0 | ||||||||||||||||||||||||
294 | factors[i] = 1.0; | - | ||||||||||||||||||||||||
295 | } else if (stretch <= 0) { never executed: end of block
| 0 | ||||||||||||||||||||||||
296 | factors[i] = 0.0; | - | ||||||||||||||||||||||||
297 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
298 | qreal ultimateSize; | - | ||||||||||||||||||||||||
299 | qreal ultimateSumSizes; | - | ||||||||||||||||||||||||
300 | qreal x = ((stretch * sumSizes) | - | ||||||||||||||||||||||||
301 | - (sumStretches * boxSize)) | - | ||||||||||||||||||||||||
302 | / (sumStretches - stretch); | - | ||||||||||||||||||||||||
303 | if (x >= 0.0) {
| 0 | ||||||||||||||||||||||||
304 | ultimateSize = boxSize + x; | - | ||||||||||||||||||||||||
305 | ultimateSumSizes = sumSizes + x; | - | ||||||||||||||||||||||||
306 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
307 | ultimateSize = boxSize; | - | ||||||||||||||||||||||||
308 | ultimateSumSizes = (sumStretches * boxSize) | - | ||||||||||||||||||||||||
309 | / stretch; | - | ||||||||||||||||||||||||
310 | } never executed: end of block | 0 | ||||||||||||||||||||||||
311 | - | |||||||||||||||||||||||||
312 | /* | - | ||||||||||||||||||||||||
313 | We multiply these by 1.5 to give some space for a smooth transition | - | ||||||||||||||||||||||||
314 | (at the expense of the stretch factors, which are not fully respected | - | ||||||||||||||||||||||||
315 | during the transition). | - | ||||||||||||||||||||||||
316 | */ | - | ||||||||||||||||||||||||
317 | ultimateSize = ultimateSize * 3 / 2; | - | ||||||||||||||||||||||||
318 | ultimateSumSizes = ultimateSumSizes * 3 / 2; | - | ||||||||||||||||||||||||
319 | - | |||||||||||||||||||||||||
320 | qreal beta = ultimateSumSizes - sumSizes; | - | ||||||||||||||||||||||||
321 | if (!beta) {
| 0 | ||||||||||||||||||||||||
322 | factors[i] = 1; | - | ||||||||||||||||||||||||
323 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
324 | qreal alpha = qMin(sumCurrentAvailable, beta); | - | ||||||||||||||||||||||||
325 | qreal ultimateFactor = (stretch * ultimateSumSizes / sumStretches) | - | ||||||||||||||||||||||||
326 | - (boxSize); | - | ||||||||||||||||||||||||
327 | qreal transitionalFactor = sumCurrentAvailable * (ultimateSize - boxSize) / beta; | - | ||||||||||||||||||||||||
328 | - | |||||||||||||||||||||||||
329 | factors[i] = ((alpha * ultimateFactor) | - | ||||||||||||||||||||||||
330 | + ((beta - alpha) * transitionalFactor)) / beta; | - | ||||||||||||||||||||||||
331 | } never executed: end of block | 0 | ||||||||||||||||||||||||
332 | - | |||||||||||||||||||||||||
333 | } | - | ||||||||||||||||||||||||
334 | sumFactors += factors[i]; | - | ||||||||||||||||||||||||
335 | if (desired < sumCurrentAvailable)
| 0 | ||||||||||||||||||||||||
336 | somethingHasAMaximumSize = true; never executed: somethingHasAMaximumSize = true; | 0 | ||||||||||||||||||||||||
337 | - | |||||||||||||||||||||||||
338 | newSizes[i] = -1.0; | - | ||||||||||||||||||||||||
339 | } never executed: end of block | 0 | ||||||||||||||||||||||||
340 | } | - | ||||||||||||||||||||||||
341 | - | |||||||||||||||||||||||||
342 | bool keepGoing = somethingHasAMaximumSize; | - | ||||||||||||||||||||||||
343 | while (keepGoing) {
| 0 | ||||||||||||||||||||||||
344 | //sumCurrentAvailable is so large that something *might* reach its maximum size | - | ||||||||||||||||||||||||
345 | keepGoing = false; | - | ||||||||||||||||||||||||
346 | - | |||||||||||||||||||||||||
347 | for (int i = 0; i < n; ++i) {
| 0 | ||||||||||||||||||||||||
348 | if (newSizes[i] >= 0.0)
| 0 | ||||||||||||||||||||||||
349 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
350 | - | |||||||||||||||||||||||||
351 | const QVector<QGridLayoutBox> &rBoxes = isLargerThanMaximum ? rowInfo.boxes : boxes;
| 0 | ||||||||||||||||||||||||
352 | const QGridLayoutBox &box = rBoxes.value(start + i); | - | ||||||||||||||||||||||||
353 | qreal maxBoxSize = box.q_maximumSize; | - | ||||||||||||||||||||||||
354 | - | |||||||||||||||||||||||||
355 | if (snapToPixelGrid)
| 0 | ||||||||||||||||||||||||
356 | maxBoxSize = qMax(box.q_minimumSize, std::floor(maxBoxSize)); never executed: maxBoxSize = qMax(box.q_minimumSize, std::floor(maxBoxSize)); | 0 | ||||||||||||||||||||||||
357 | - | |||||||||||||||||||||||||
358 | qreal avail = sumCurrentAvailable * factors[i] / sumFactors; | - | ||||||||||||||||||||||||
359 | if (sizes[i] + avail >= maxBoxSize) {
| 0 | ||||||||||||||||||||||||
360 | newSizes[i] = maxBoxSize; | - | ||||||||||||||||||||||||
361 | sumCurrentAvailable -= maxBoxSize - sizes[i]; | - | ||||||||||||||||||||||||
362 | sumFactors -= factors[i]; | - | ||||||||||||||||||||||||
363 | keepGoing = (sumCurrentAvailable > 0.0); | - | ||||||||||||||||||||||||
364 | if (!keepGoing)
| 0 | ||||||||||||||||||||||||
365 | break; never executed: break; | 0 | ||||||||||||||||||||||||
366 | } never executed: end of block | 0 | ||||||||||||||||||||||||
367 | } never executed: end of block | 0 | ||||||||||||||||||||||||
368 | } never executed: end of block | 0 | ||||||||||||||||||||||||
369 | for (int i = 0; i < n; ++i) {
| 0 | ||||||||||||||||||||||||
370 | if (newSizes[i] < 0.0) {
| 0 | ||||||||||||||||||||||||
371 | qreal delta = (sumFactors == 0.0) ? 0.0
| 0 | ||||||||||||||||||||||||
372 | : sumCurrentAvailable * factors[i] / sumFactors; | - | ||||||||||||||||||||||||
373 | newSizes[i] = sizes[i] + delta; | - | ||||||||||||||||||||||||
374 | } never executed: end of block | 0 | ||||||||||||||||||||||||
375 | } never executed: end of block | 0 | ||||||||||||||||||||||||
376 | } never executed: end of block | 0 | ||||||||||||||||||||||||
377 | } never executed: end of block | 0 | ||||||||||||||||||||||||
378 | - | |||||||||||||||||||||||||
379 | if (sumAvailable > 0) {
| 0 | ||||||||||||||||||||||||
380 | qreal offset = 0; | - | ||||||||||||||||||||||||
381 | for (int i = 0; i < n; ++i) {
| 0 | ||||||||||||||||||||||||
382 | qreal delta = newSizes[i] - sizes[i]; | - | ||||||||||||||||||||||||
383 | positions[i] += offset; | - | ||||||||||||||||||||||||
384 | sizes[i] += delta; | - | ||||||||||||||||||||||||
385 | offset += delta; | - | ||||||||||||||||||||||||
386 | } never executed: end of block | 0 | ||||||||||||||||||||||||
387 | - | |||||||||||||||||||||||||
388 | #if 0 // some "pixel allocation" | - | ||||||||||||||||||||||||
389 | int surplus = targetSize - (positions[n - 1] + sizes[n - 1]); | - | ||||||||||||||||||||||||
390 | Q_ASSERT(surplus >= 0 && surplus <= n); | - | ||||||||||||||||||||||||
391 | - | |||||||||||||||||||||||||
392 | int prevSurplus = -1; | - | ||||||||||||||||||||||||
393 | while (surplus > 0 && surplus != prevSurplus) { | - | ||||||||||||||||||||||||
394 | prevSurplus = surplus; | - | ||||||||||||||||||||||||
395 | - | |||||||||||||||||||||||||
396 | int offset = 0; | - | ||||||||||||||||||||||||
397 | for (int i = 0; i < n; ++i) { | - | ||||||||||||||||||||||||
398 | const QGridLayoutBox &box = boxes.at(start + i); | - | ||||||||||||||||||||||||
399 | int delta = (!ignore.testBit(start + i) && surplus > 0 | - | ||||||||||||||||||||||||
400 | && factors[i] > 0 && sizes[i] < box.q_maximumSize) | - | ||||||||||||||||||||||||
401 | ? 1 : 0; | - | ||||||||||||||||||||||||
402 | - | |||||||||||||||||||||||||
403 | positions[i] += offset; | - | ||||||||||||||||||||||||
404 | sizes[i] += delta; | - | ||||||||||||||||||||||||
405 | offset += delta; | - | ||||||||||||||||||||||||
406 | surplus -= delta; | - | ||||||||||||||||||||||||
407 | } | - | ||||||||||||||||||||||||
408 | } | - | ||||||||||||||||||||||||
409 | Q_ASSERT(surplus == 0); | - | ||||||||||||||||||||||||
410 | #endif | - | ||||||||||||||||||||||||
411 | } never executed: end of block | 0 | ||||||||||||||||||||||||
412 | if (snapToPixelGrid) {
| 0 | ||||||||||||||||||||||||
413 | for (int i = 0; i < n; ++i)
| 0 | ||||||||||||||||||||||||
414 | positions[i] = qround(positions[i]); never executed: positions[i] = qround(positions[i]); | 0 | ||||||||||||||||||||||||
415 | } never executed: end of block | 0 | ||||||||||||||||||||||||
416 | - | |||||||||||||||||||||||||
417 | if (descents) {
| 0 | ||||||||||||||||||||||||
418 | for (int i = 0; i < n; ++i) {
| 0 | ||||||||||||||||||||||||
419 | if (ignore.testBit(start + i))
| 0 | ||||||||||||||||||||||||
420 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
421 | const QGridLayoutBox &box = boxes.at(start + i); | - | ||||||||||||||||||||||||
422 | descents[i] = fixedDescent(box.q_minimumDescent, box.q_minimumAscent, sizes[i]); | - | ||||||||||||||||||||||||
423 | } never executed: end of block | 0 | ||||||||||||||||||||||||
424 | } never executed: end of block | 0 | ||||||||||||||||||||||||
425 | } never executed: end of block | 0 | ||||||||||||||||||||||||
426 | - | |||||||||||||||||||||||||
427 | QGridLayoutBox QGridLayoutRowData::totalBox(int start, int end) const | - | ||||||||||||||||||||||||
428 | { | - | ||||||||||||||||||||||||
429 | QGridLayoutBox result; | - | ||||||||||||||||||||||||
430 | if (start < end) {
| 0 | ||||||||||||||||||||||||
431 | result.q_maximumSize = 0.0; | - | ||||||||||||||||||||||||
432 | qreal nextSpacing = 0.0; | - | ||||||||||||||||||||||||
433 | for (int i = start; i < end; ++i) {
| 0 | ||||||||||||||||||||||||
434 | if (ignore.testBit(i))
| 0 | ||||||||||||||||||||||||
435 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
436 | result.add(boxes.at(i), stretches.at(i), nextSpacing); | - | ||||||||||||||||||||||||
437 | nextSpacing = spacings.at(i); | - | ||||||||||||||||||||||||
438 | } never executed: end of block | 0 | ||||||||||||||||||||||||
439 | } never executed: end of block | 0 | ||||||||||||||||||||||||
440 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
441 | } | - | ||||||||||||||||||||||||
442 | - | |||||||||||||||||||||||||
443 | void QGridLayoutRowData::stealBox(int start, int end, int which, qreal *positions, qreal *sizes) | - | ||||||||||||||||||||||||
444 | { | - | ||||||||||||||||||||||||
445 | qreal offset = 0.0; | - | ||||||||||||||||||||||||
446 | qreal nextSpacing = 0.0; | - | ||||||||||||||||||||||||
447 | - | |||||||||||||||||||||||||
448 | for (int i = start; i < end; ++i) {
| 0 | ||||||||||||||||||||||||
449 | qreal avail = 0.0; | - | ||||||||||||||||||||||||
450 | - | |||||||||||||||||||||||||
451 | if (!ignore.testBit(i)) {
| 0 | ||||||||||||||||||||||||
452 | const QGridLayoutBox &box = boxes.at(i); | - | ||||||||||||||||||||||||
453 | avail = box.q_sizes(which); | - | ||||||||||||||||||||||||
454 | offset += nextSpacing; | - | ||||||||||||||||||||||||
455 | nextSpacing = spacings.at(i); | - | ||||||||||||||||||||||||
456 | } never executed: end of block | 0 | ||||||||||||||||||||||||
457 | - | |||||||||||||||||||||||||
458 | *positions++ = offset; | - | ||||||||||||||||||||||||
459 | *sizes++ = avail; | - | ||||||||||||||||||||||||
460 | offset += avail; | - | ||||||||||||||||||||||||
461 | } never executed: end of block | 0 | ||||||||||||||||||||||||
462 | } never executed: end of block | 0 | ||||||||||||||||||||||||
463 | - | |||||||||||||||||||||||||
464 | #ifdef QGRIDLAYOUTENGINE_DEBUG | - | ||||||||||||||||||||||||
465 | void QGridLayoutRowData::dump(int indent) const | - | ||||||||||||||||||||||||
466 | { | - | ||||||||||||||||||||||||
467 | qDebug("%*sData", indent, ""); | - | ||||||||||||||||||||||||
468 | - | |||||||||||||||||||||||||
469 | for (int i = 0; i < ignore.count(); ++i) { | - | ||||||||||||||||||||||||
470 | qDebug("%*s Row %d (stretch %d, spacing %g)", indent, "", i, stretches.at(i), | - | ||||||||||||||||||||||||
471 | spacings.at(i)); | - | ||||||||||||||||||||||||
472 | if (ignore.testBit(i)) | - | ||||||||||||||||||||||||
473 | qDebug("%*s Ignored", indent, ""); | - | ||||||||||||||||||||||||
474 | boxes.at(i).dump(indent + 2); | - | ||||||||||||||||||||||||
475 | } | - | ||||||||||||||||||||||||
476 | - | |||||||||||||||||||||||||
477 | MultiCellMap::const_iterator it = multiCellMap.constBegin(); | - | ||||||||||||||||||||||||
478 | while (it != multiCellMap.constEnd()) { | - | ||||||||||||||||||||||||
479 | qDebug("%*s Multi-cell entry <%d, %d> (stretch %d)", indent, "", it.key().first, | - | ||||||||||||||||||||||||
480 | it.key().second, it.value().q_stretch); | - | ||||||||||||||||||||||||
481 | it.value().q_box.dump(indent + 2); | - | ||||||||||||||||||||||||
482 | } | - | ||||||||||||||||||||||||
483 | } | - | ||||||||||||||||||||||||
484 | #endif | - | ||||||||||||||||||||||||
485 | - | |||||||||||||||||||||||||
486 | QGridLayoutItem::QGridLayoutItem(int row, int column, int rowSpan, int columnSpan, | - | ||||||||||||||||||||||||
487 | Qt::Alignment alignment) | - | ||||||||||||||||||||||||
488 | : q_alignment(alignment) | - | ||||||||||||||||||||||||
489 | { | - | ||||||||||||||||||||||||
490 | q_firstRows[Hor] = column; | - | ||||||||||||||||||||||||
491 | q_firstRows[Ver] = row; | - | ||||||||||||||||||||||||
492 | q_rowSpans[Hor] = columnSpan; | - | ||||||||||||||||||||||||
493 | q_rowSpans[Ver] = rowSpan; | - | ||||||||||||||||||||||||
494 | q_stretches[Hor] = -1; | - | ||||||||||||||||||||||||
495 | q_stretches[Ver] = -1; | - | ||||||||||||||||||||||||
496 | } never executed: end of block | 0 | ||||||||||||||||||||||||
497 | - | |||||||||||||||||||||||||
498 | int QGridLayoutItem::firstRow(Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
499 | { | - | ||||||||||||||||||||||||
500 | return q_firstRows[orientation == Qt::Vertical]; never executed: return q_firstRows[orientation == Qt::Vertical]; | 0 | ||||||||||||||||||||||||
501 | } | - | ||||||||||||||||||||||||
502 | - | |||||||||||||||||||||||||
503 | int QGridLayoutItem::firstColumn(Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
504 | { | - | ||||||||||||||||||||||||
505 | return q_firstRows[orientation == Qt::Horizontal]; never executed: return q_firstRows[orientation == Qt::Horizontal]; | 0 | ||||||||||||||||||||||||
506 | } | - | ||||||||||||||||||||||||
507 | - | |||||||||||||||||||||||||
508 | int QGridLayoutItem::lastRow(Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
509 | { | - | ||||||||||||||||||||||||
510 | return firstRow(orientation) + rowSpan(orientation) - 1; never executed: return firstRow(orientation) + rowSpan(orientation) - 1; | 0 | ||||||||||||||||||||||||
511 | } | - | ||||||||||||||||||||||||
512 | - | |||||||||||||||||||||||||
513 | int QGridLayoutItem::lastColumn(Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
514 | { | - | ||||||||||||||||||||||||
515 | return firstColumn(orientation) + columnSpan(orientation) - 1; never executed: return firstColumn(orientation) + columnSpan(orientation) - 1; | 0 | ||||||||||||||||||||||||
516 | } | - | ||||||||||||||||||||||||
517 | - | |||||||||||||||||||||||||
518 | int QGridLayoutItem::rowSpan(Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
519 | { | - | ||||||||||||||||||||||||
520 | return q_rowSpans[orientation == Qt::Vertical]; never executed: return q_rowSpans[orientation == Qt::Vertical]; | 0 | ||||||||||||||||||||||||
521 | } | - | ||||||||||||||||||||||||
522 | - | |||||||||||||||||||||||||
523 | int QGridLayoutItem::columnSpan(Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
524 | { | - | ||||||||||||||||||||||||
525 | return q_rowSpans[orientation == Qt::Horizontal]; never executed: return q_rowSpans[orientation == Qt::Horizontal]; | 0 | ||||||||||||||||||||||||
526 | } | - | ||||||||||||||||||||||||
527 | - | |||||||||||||||||||||||||
528 | void QGridLayoutItem::setFirstRow(int row, Qt::Orientation orientation) | - | ||||||||||||||||||||||||
529 | { | - | ||||||||||||||||||||||||
530 | q_firstRows[orientation == Qt::Vertical] = row; | - | ||||||||||||||||||||||||
531 | } never executed: end of block | 0 | ||||||||||||||||||||||||
532 | - | |||||||||||||||||||||||||
533 | void QGridLayoutItem::setRowSpan(int rowSpan, Qt::Orientation orientation) | - | ||||||||||||||||||||||||
534 | { | - | ||||||||||||||||||||||||
535 | q_rowSpans[orientation == Qt::Vertical] = rowSpan; | - | ||||||||||||||||||||||||
536 | } never executed: end of block | 0 | ||||||||||||||||||||||||
537 | - | |||||||||||||||||||||||||
538 | int QGridLayoutItem::stretchFactor(Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
539 | { | - | ||||||||||||||||||||||||
540 | int stretch = q_stretches[orientation == Qt::Vertical]; | - | ||||||||||||||||||||||||
541 | if (stretch >= 0)
| 0 | ||||||||||||||||||||||||
542 | return stretch; never executed: return stretch; | 0 | ||||||||||||||||||||||||
543 | - | |||||||||||||||||||||||||
544 | QLayoutPolicy::Policy policy = sizePolicy(orientation); | - | ||||||||||||||||||||||||
545 | - | |||||||||||||||||||||||||
546 | if (policy & QLayoutPolicy::ExpandFlag) {
| 0 | ||||||||||||||||||||||||
547 | return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||
548 | } else if (policy & QLayoutPolicy::GrowFlag) {
| 0 | ||||||||||||||||||||||||
549 | return -1; // because we max it up never executed: return -1; | 0 | ||||||||||||||||||||||||
550 | } else { | - | ||||||||||||||||||||||||
551 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
552 | } | - | ||||||||||||||||||||||||
553 | } | - | ||||||||||||||||||||||||
554 | - | |||||||||||||||||||||||||
555 | void QGridLayoutItem::setStretchFactor(int stretch, Qt::Orientation orientation) | - | ||||||||||||||||||||||||
556 | { | - | ||||||||||||||||||||||||
557 | Q_ASSERT(stretch >= 0); // ### deal with too big stretches | - | ||||||||||||||||||||||||
558 | q_stretches[orientation == Qt::Vertical] = stretch; | - | ||||||||||||||||||||||||
559 | } never executed: end of block | 0 | ||||||||||||||||||||||||
560 | - | |||||||||||||||||||||||||
561 | QLayoutPolicy::ControlTypes QGridLayoutItem::controlTypes(LayoutSide /*side*/) const | - | ||||||||||||||||||||||||
562 | { | - | ||||||||||||||||||||||||
563 | return QLayoutPolicy::DefaultType; never executed: return QLayoutPolicy::DefaultType; | 0 | ||||||||||||||||||||||||
564 | } | - | ||||||||||||||||||||||||
565 | - | |||||||||||||||||||||||||
566 | QGridLayoutBox QGridLayoutItem::box(Qt::Orientation orientation, qreal constraint) const | - | ||||||||||||||||||||||||
567 | { | - | ||||||||||||||||||||||||
568 | QGridLayoutBox result; | - | ||||||||||||||||||||||||
569 | QLayoutPolicy::Policy policy = sizePolicy(orientation); | - | ||||||||||||||||||||||||
570 | - | |||||||||||||||||||||||||
571 | if (orientation == Qt::Horizontal) {
| 0 | ||||||||||||||||||||||||
572 | QSizeF constraintSize(-1.0, constraint); | - | ||||||||||||||||||||||||
573 | - | |||||||||||||||||||||||||
574 | result.q_preferredSize = sizeHint(Qt::PreferredSize, constraintSize).width(); | - | ||||||||||||||||||||||||
575 | - | |||||||||||||||||||||||||
576 | if (policy & QLayoutPolicy::ShrinkFlag) {
| 0 | ||||||||||||||||||||||||
577 | result.q_minimumSize = sizeHint(Qt::MinimumSize, constraintSize).width(); | - | ||||||||||||||||||||||||
578 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
579 | result.q_minimumSize = result.q_preferredSize; | - | ||||||||||||||||||||||||
580 | } never executed: end of block | 0 | ||||||||||||||||||||||||
581 | - | |||||||||||||||||||||||||
582 | if (policy & (QLayoutPolicy::GrowFlag | QLayoutPolicy::ExpandFlag)) {
| 0 | ||||||||||||||||||||||||
583 | result.q_maximumSize = sizeHint(Qt::MaximumSize, constraintSize).width(); | - | ||||||||||||||||||||||||
584 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
585 | result.q_maximumSize = result.q_preferredSize; | - | ||||||||||||||||||||||||
586 | } never executed: end of block | 0 | ||||||||||||||||||||||||
587 | } else { | - | ||||||||||||||||||||||||
588 | QSizeF constraintSize(constraint, -1.0); | - | ||||||||||||||||||||||||
589 | - | |||||||||||||||||||||||||
590 | result.q_preferredSize = sizeHint(Qt::PreferredSize, constraintSize).height(); | - | ||||||||||||||||||||||||
591 | - | |||||||||||||||||||||||||
592 | if (policy & QLayoutPolicy::ShrinkFlag) {
| 0 | ||||||||||||||||||||||||
593 | result.q_minimumSize = sizeHint(Qt::MinimumSize, constraintSize).height(); | - | ||||||||||||||||||||||||
594 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
595 | result.q_minimumSize = result.q_preferredSize; | - | ||||||||||||||||||||||||
596 | } never executed: end of block | 0 | ||||||||||||||||||||||||
597 | - | |||||||||||||||||||||||||
598 | if (policy & (QLayoutPolicy::GrowFlag | QLayoutPolicy::ExpandFlag)) {
| 0 | ||||||||||||||||||||||||
599 | result.q_maximumSize = sizeHint(Qt::MaximumSize, constraintSize).height(); | - | ||||||||||||||||||||||||
600 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
601 | result.q_maximumSize = result.q_preferredSize; | - | ||||||||||||||||||||||||
602 | } never executed: end of block | 0 | ||||||||||||||||||||||||
603 | - | |||||||||||||||||||||||||
604 | if (alignment() & Qt::AlignBaseline) {
| 0 | ||||||||||||||||||||||||
605 | result.q_minimumDescent = sizeHint(Qt::MinimumDescent, constraintSize).height(); | - | ||||||||||||||||||||||||
606 | if (result.q_minimumDescent != -1.0) {
| 0 | ||||||||||||||||||||||||
607 | const qreal minSizeHint = sizeHint(Qt::MinimumSize, constraintSize).height(); | - | ||||||||||||||||||||||||
608 | result.q_minimumDescent -= (minSizeHint - result.q_minimumSize); | - | ||||||||||||||||||||||||
609 | result.q_minimumAscent = result.q_minimumSize - result.q_minimumDescent; | - | ||||||||||||||||||||||||
610 | } never executed: end of block | 0 | ||||||||||||||||||||||||
611 | } never executed: end of block | 0 | ||||||||||||||||||||||||
612 | } never executed: end of block | 0 | ||||||||||||||||||||||||
613 | if (policy & QLayoutPolicy::IgnoreFlag)
| 0 | ||||||||||||||||||||||||
614 | result.q_preferredSize = result.q_minimumSize; never executed: result.q_preferredSize = result.q_minimumSize; | 0 | ||||||||||||||||||||||||
615 | - | |||||||||||||||||||||||||
616 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
617 | } | - | ||||||||||||||||||||||||
618 | - | |||||||||||||||||||||||||
619 | QRectF QGridLayoutItem::geometryWithin(qreal x, qreal y, qreal width, qreal height, | - | ||||||||||||||||||||||||
620 | qreal rowDescent, Qt::Alignment align) const | - | ||||||||||||||||||||||||
621 | { | - | ||||||||||||||||||||||||
622 | const qreal cellWidth = width; | - | ||||||||||||||||||||||||
623 | const qreal cellHeight = height; | - | ||||||||||||||||||||||||
624 | - | |||||||||||||||||||||||||
625 | QSizeF size = effectiveMaxSize(QSizeF(-1,-1)); | - | ||||||||||||||||||||||||
626 | if (hasDynamicConstraint()) {
| 0 | ||||||||||||||||||||||||
627 | if (dynamicConstraintOrientation() == Qt::Vertical) {
| 0 | ||||||||||||||||||||||||
628 | if (size.width() > cellWidth)
| 0 | ||||||||||||||||||||||||
629 | size = effectiveMaxSize(QSizeF(cellWidth, -1)); never executed: size = effectiveMaxSize(QSizeF(cellWidth, -1)); | 0 | ||||||||||||||||||||||||
630 | } else if (size.height() > cellHeight) { never executed: end of block
| 0 | ||||||||||||||||||||||||
631 | size = effectiveMaxSize(QSizeF(-1, cellHeight)); | - | ||||||||||||||||||||||||
632 | } never executed: end of block | 0 | ||||||||||||||||||||||||
633 | } never executed: end of block | 0 | ||||||||||||||||||||||||
634 | size = size.boundedTo(QSizeF(cellWidth, cellHeight)); | - | ||||||||||||||||||||||||
635 | width = size.width(); | - | ||||||||||||||||||||||||
636 | height = size.height(); | - | ||||||||||||||||||||||||
637 | - | |||||||||||||||||||||||||
638 | switch (align & Qt::AlignHorizontal_Mask) { | - | ||||||||||||||||||||||||
639 | case Qt::AlignHCenter: never executed: case Qt::AlignHCenter: | 0 | ||||||||||||||||||||||||
640 | x += (cellWidth - width)/2; | - | ||||||||||||||||||||||||
641 | break; never executed: break; | 0 | ||||||||||||||||||||||||
642 | case Qt::AlignRight: never executed: case Qt::AlignRight: | 0 | ||||||||||||||||||||||||
643 | x += cellWidth - width; | - | ||||||||||||||||||||||||
644 | break; never executed: break; | 0 | ||||||||||||||||||||||||
645 | default: never executed: default: | 0 | ||||||||||||||||||||||||
646 | break; never executed: break; | 0 | ||||||||||||||||||||||||
647 | } | - | ||||||||||||||||||||||||
648 | - | |||||||||||||||||||||||||
649 | switch (align & Qt::AlignVertical_Mask) { | - | ||||||||||||||||||||||||
650 | case Qt::AlignVCenter: never executed: case Qt::AlignVCenter: | 0 | ||||||||||||||||||||||||
651 | y += (cellHeight - height)/2; | - | ||||||||||||||||||||||||
652 | break; never executed: break; | 0 | ||||||||||||||||||||||||
653 | case Qt::AlignBottom: never executed: case Qt::AlignBottom: | 0 | ||||||||||||||||||||||||
654 | y += cellHeight - height; | - | ||||||||||||||||||||||||
655 | break; never executed: break; | 0 | ||||||||||||||||||||||||
656 | case Qt::AlignBaseline: { never executed: case Qt::AlignBaseline: | 0 | ||||||||||||||||||||||||
657 | width = qMin(effectiveMaxSize(QSizeF(-1,-1)).width(), width); | - | ||||||||||||||||||||||||
658 | QGridLayoutBox vBox = box(Qt::Vertical); | - | ||||||||||||||||||||||||
659 | const qreal descent = vBox.q_minimumDescent; | - | ||||||||||||||||||||||||
660 | const qreal ascent = vBox.q_minimumSize - descent; | - | ||||||||||||||||||||||||
661 | y += (cellHeight - rowDescent - ascent); | - | ||||||||||||||||||||||||
662 | height = ascent + descent; | - | ||||||||||||||||||||||||
663 | break; } never executed: break; | 0 | ||||||||||||||||||||||||
664 | default: never executed: default: | 0 | ||||||||||||||||||||||||
665 | break; never executed: break; | 0 | ||||||||||||||||||||||||
666 | } | - | ||||||||||||||||||||||||
667 | return QRectF(x, y, width, height); never executed: return QRectF(x, y, width, height); | 0 | ||||||||||||||||||||||||
668 | } | - | ||||||||||||||||||||||||
669 | - | |||||||||||||||||||||||||
670 | void QGridLayoutItem::transpose() | - | ||||||||||||||||||||||||
671 | { | - | ||||||||||||||||||||||||
672 | qSwap(q_firstRows[Hor], q_firstRows[Ver]); | - | ||||||||||||||||||||||||
673 | qSwap(q_rowSpans[Hor], q_rowSpans[Ver]); | - | ||||||||||||||||||||||||
674 | qSwap(q_stretches[Hor], q_stretches[Ver]); | - | ||||||||||||||||||||||||
675 | } never executed: end of block | 0 | ||||||||||||||||||||||||
676 | - | |||||||||||||||||||||||||
677 | void QGridLayoutItem::insertOrRemoveRows(int row, int delta, Qt::Orientation orientation) | - | ||||||||||||||||||||||||
678 | { | - | ||||||||||||||||||||||||
679 | int oldFirstRow = firstRow(orientation); | - | ||||||||||||||||||||||||
680 | if (oldFirstRow >= row) {
| 0 | ||||||||||||||||||||||||
681 | setFirstRow(oldFirstRow + delta, orientation); | - | ||||||||||||||||||||||||
682 | } else if (lastRow(orientation) >= row) { never executed: end of block
| 0 | ||||||||||||||||||||||||
683 | setRowSpan(rowSpan(orientation) + delta, orientation); | - | ||||||||||||||||||||||||
684 | } never executed: end of block | 0 | ||||||||||||||||||||||||
685 | } never executed: end of block | 0 | ||||||||||||||||||||||||
686 | /*! | - | ||||||||||||||||||||||||
687 | \internal | - | ||||||||||||||||||||||||
688 | returns the effective maximumSize, will take the sizepolicy into | - | ||||||||||||||||||||||||
689 | consideration. (i.e. if sizepolicy does not have QLayoutPolicy::Grow, then | - | ||||||||||||||||||||||||
690 | maxSizeHint will be the preferredSize) | - | ||||||||||||||||||||||||
691 | Note that effectiveSizeHint does not take sizePolicy into consideration, | - | ||||||||||||||||||||||||
692 | (since it only evaluates the hints, as the name implies) | - | ||||||||||||||||||||||||
693 | */ | - | ||||||||||||||||||||||||
694 | QSizeF QGridLayoutItem::effectiveMaxSize(const QSizeF &constraint) const | - | ||||||||||||||||||||||||
695 | { | - | ||||||||||||||||||||||||
696 | QSizeF size = constraint; | - | ||||||||||||||||||||||||
697 | bool vGrow = (sizePolicy(Qt::Vertical) & QLayoutPolicy::GrowFlag) == QLayoutPolicy::GrowFlag; | - | ||||||||||||||||||||||||
698 | bool hGrow = (sizePolicy(Qt::Horizontal) & QLayoutPolicy::GrowFlag) == QLayoutPolicy::GrowFlag; | - | ||||||||||||||||||||||||
699 | if (!vGrow || !hGrow) {
| 0 | ||||||||||||||||||||||||
700 | QSizeF pref = sizeHint(Qt::PreferredSize, constraint); | - | ||||||||||||||||||||||||
701 | if (!vGrow)
| 0 | ||||||||||||||||||||||||
702 | size.setHeight(pref.height()); never executed: size.setHeight(pref.height()); | 0 | ||||||||||||||||||||||||
703 | if (!hGrow)
| 0 | ||||||||||||||||||||||||
704 | size.setWidth(pref.width()); never executed: size.setWidth(pref.width()); | 0 | ||||||||||||||||||||||||
705 | } never executed: end of block | 0 | ||||||||||||||||||||||||
706 | - | |||||||||||||||||||||||||
707 | if (!size.isValid()) {
| 0 | ||||||||||||||||||||||||
708 | QSizeF maxSize = sizeHint(Qt::MaximumSize, size); | - | ||||||||||||||||||||||||
709 | if (size.width() == -1)
| 0 | ||||||||||||||||||||||||
710 | size.setWidth(maxSize.width()); never executed: size.setWidth(maxSize.width()); | 0 | ||||||||||||||||||||||||
711 | if (size.height() == -1)
| 0 | ||||||||||||||||||||||||
712 | size.setHeight(maxSize.height()); never executed: size.setHeight(maxSize.height()); | 0 | ||||||||||||||||||||||||
713 | } never executed: end of block | 0 | ||||||||||||||||||||||||
714 | return size; never executed: return size; | 0 | ||||||||||||||||||||||||
715 | } | - | ||||||||||||||||||||||||
716 | - | |||||||||||||||||||||||||
717 | #ifdef QGRIDLAYOUTENGINE_DEBUG | - | ||||||||||||||||||||||||
718 | void QGridLayoutItem::dump(int indent) const | - | ||||||||||||||||||||||||
719 | { | - | ||||||||||||||||||||||||
720 | qDebug("%*s (%d, %d) %d x %d", indent, "", firstRow(), firstColumn(), //### | - | ||||||||||||||||||||||||
721 | rowSpan(), columnSpan()); | - | ||||||||||||||||||||||||
722 | - | |||||||||||||||||||||||||
723 | if (q_stretches[Hor] >= 0) | - | ||||||||||||||||||||||||
724 | qDebug("%*s Horizontal stretch: %d", indent, "", q_stretches[Hor]); | - | ||||||||||||||||||||||||
725 | if (q_stretches[Ver] >= 0) | - | ||||||||||||||||||||||||
726 | qDebug("%*s Vertical stretch: %d", indent, "", q_stretches[Ver]); | - | ||||||||||||||||||||||||
727 | if (q_alignment != 0) | - | ||||||||||||||||||||||||
728 | qDebug("%*s Alignment: %x", indent, "", uint(q_alignment)); | - | ||||||||||||||||||||||||
729 | qDebug("%*s Horizontal size policy: %x Vertical size policy: %x", | - | ||||||||||||||||||||||||
730 | indent, "", sizePolicy(Qt::Horizontal), sizePolicy(Qt::Vertical)); | - | ||||||||||||||||||||||||
731 | } | - | ||||||||||||||||||||||||
732 | #endif | - | ||||||||||||||||||||||||
733 | - | |||||||||||||||||||||||||
734 | void QGridLayoutRowInfo::insertOrRemoveRows(int row, int delta) | - | ||||||||||||||||||||||||
735 | { | - | ||||||||||||||||||||||||
736 | count += delta; | - | ||||||||||||||||||||||||
737 | - | |||||||||||||||||||||||||
738 | insertOrRemoveItems(stretches, row, delta); | - | ||||||||||||||||||||||||
739 | insertOrRemoveItems(spacings, row, delta); | - | ||||||||||||||||||||||||
740 | insertOrRemoveItems(alignments, row, delta); | - | ||||||||||||||||||||||||
741 | insertOrRemoveItems(boxes, row, delta); | - | ||||||||||||||||||||||||
742 | } never executed: end of block | 0 | ||||||||||||||||||||||||
743 | - | |||||||||||||||||||||||||
744 | #ifdef QGRIDLAYOUTENGINE_DEBUG | - | ||||||||||||||||||||||||
745 | void QGridLayoutRowInfo::dump(int indent) const | - | ||||||||||||||||||||||||
746 | { | - | ||||||||||||||||||||||||
747 | qDebug("%*sInfo (count: %d)", indent, "", count); | - | ||||||||||||||||||||||||
748 | for (int i = 0; i < count; ++i) { | - | ||||||||||||||||||||||||
749 | QString message; | - | ||||||||||||||||||||||||
750 | - | |||||||||||||||||||||||||
751 | if (stretches.value(i).value() >= 0) | - | ||||||||||||||||||||||||
752 | message += QString::fromLatin1(" stretch %1").arg(stretches.value(i).value()); | - | ||||||||||||||||||||||||
753 | if (spacings.value(i).value() >= 0.0) | - | ||||||||||||||||||||||||
754 | message += QString::fromLatin1(" spacing %1").arg(spacings.value(i).value()); | - | ||||||||||||||||||||||||
755 | if (alignments.value(i) != 0) | - | ||||||||||||||||||||||||
756 | message += QString::fromLatin1(" alignment %1").arg(int(alignments.value(i)), 16); | - | ||||||||||||||||||||||||
757 | - | |||||||||||||||||||||||||
758 | if (!message.isEmpty() || boxes.value(i) != QGridLayoutBox()) { | - | ||||||||||||||||||||||||
759 | qDebug("%*s Row %d:%s", indent, "", i, qPrintable(message)); | - | ||||||||||||||||||||||||
760 | if (boxes.value(i) != QGridLayoutBox()) | - | ||||||||||||||||||||||||
761 | boxes.value(i).dump(indent + 1); | - | ||||||||||||||||||||||||
762 | } | - | ||||||||||||||||||||||||
763 | } | - | ||||||||||||||||||||||||
764 | } | - | ||||||||||||||||||||||||
765 | #endif | - | ||||||||||||||||||||||||
766 | - | |||||||||||||||||||||||||
767 | QGridLayoutEngine::QGridLayoutEngine(Qt::Alignment defaultAlignment, bool snapToPixelGrid) | - | ||||||||||||||||||||||||
768 | { | - | ||||||||||||||||||||||||
769 | m_visualDirection = Qt::LeftToRight; | - | ||||||||||||||||||||||||
770 | m_defaultAlignment = defaultAlignment; | - | ||||||||||||||||||||||||
771 | m_snapToPixelGrid = snapToPixelGrid; | - | ||||||||||||||||||||||||
772 | invalidate(); | - | ||||||||||||||||||||||||
773 | } never executed: end of block | 0 | ||||||||||||||||||||||||
774 | - | |||||||||||||||||||||||||
775 | int QGridLayoutEngine::rowCount(Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
776 | { | - | ||||||||||||||||||||||||
777 | return q_infos[orientation == Qt::Vertical].count; never executed: return q_infos[orientation == Qt::Vertical].count; | 0 | ||||||||||||||||||||||||
778 | } | - | ||||||||||||||||||||||||
779 | - | |||||||||||||||||||||||||
780 | int QGridLayoutEngine::columnCount(Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
781 | { | - | ||||||||||||||||||||||||
782 | return q_infos[orientation == Qt::Horizontal].count; never executed: return q_infos[orientation == Qt::Horizontal].count; | 0 | ||||||||||||||||||||||||
783 | } | - | ||||||||||||||||||||||||
784 | - | |||||||||||||||||||||||||
785 | int QGridLayoutEngine::itemCount() const | - | ||||||||||||||||||||||||
786 | { | - | ||||||||||||||||||||||||
787 | return q_items.count(); never executed: return q_items.count(); | 0 | ||||||||||||||||||||||||
788 | } | - | ||||||||||||||||||||||||
789 | - | |||||||||||||||||||||||||
790 | QGridLayoutItem *QGridLayoutEngine::itemAt(int index) const | - | ||||||||||||||||||||||||
791 | { | - | ||||||||||||||||||||||||
792 | Q_ASSERT(index >= 0 && index < itemCount()); | - | ||||||||||||||||||||||||
793 | return q_items.at(index); never executed: return q_items.at(index); | 0 | ||||||||||||||||||||||||
794 | } | - | ||||||||||||||||||||||||
795 | - | |||||||||||||||||||||||||
796 | int QGridLayoutEngine::effectiveFirstRow(Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
797 | { | - | ||||||||||||||||||||||||
798 | ensureEffectiveFirstAndLastRows(); | - | ||||||||||||||||||||||||
799 | return q_cachedEffectiveFirstRows[orientation == Qt::Vertical]; never executed: return q_cachedEffectiveFirstRows[orientation == Qt::Vertical]; | 0 | ||||||||||||||||||||||||
800 | } | - | ||||||||||||||||||||||||
801 | - | |||||||||||||||||||||||||
802 | int QGridLayoutEngine::effectiveLastRow(Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
803 | { | - | ||||||||||||||||||||||||
804 | ensureEffectiveFirstAndLastRows(); | - | ||||||||||||||||||||||||
805 | return q_cachedEffectiveLastRows[orientation == Qt::Vertical]; never executed: return q_cachedEffectiveLastRows[orientation == Qt::Vertical]; | 0 | ||||||||||||||||||||||||
806 | } | - | ||||||||||||||||||||||||
807 | - | |||||||||||||||||||||||||
808 | void QGridLayoutEngine::setSpacing(qreal spacing, Qt::Orientations orientations) | - | ||||||||||||||||||||||||
809 | { | - | ||||||||||||||||||||||||
810 | if (orientations & Qt::Horizontal)
| 0 | ||||||||||||||||||||||||
811 | q_defaultSpacings[Hor].setUserValue(spacing); never executed: q_defaultSpacings[Hor].setUserValue(spacing); | 0 | ||||||||||||||||||||||||
812 | if (orientations & Qt::Vertical)
| 0 | ||||||||||||||||||||||||
813 | q_defaultSpacings[Ver].setUserValue(spacing); never executed: q_defaultSpacings[Ver].setUserValue(spacing); | 0 | ||||||||||||||||||||||||
814 | - | |||||||||||||||||||||||||
815 | invalidate(); | - | ||||||||||||||||||||||||
816 | } never executed: end of block | 0 | ||||||||||||||||||||||||
817 | - | |||||||||||||||||||||||||
818 | qreal QGridLayoutEngine::spacing(Qt::Orientation orientation, const QAbstractLayoutStyleInfo *styleInfo) const | - | ||||||||||||||||||||||||
819 | { | - | ||||||||||||||||||||||||
820 | if (!q_defaultSpacings[orientation == Qt::Vertical].isUser()) {
| 0 | ||||||||||||||||||||||||
821 | qreal defaultSpacing = styleInfo->spacing(orientation); | - | ||||||||||||||||||||||||
822 | q_defaultSpacings[orientation == Qt::Vertical].setCachedValue(defaultSpacing); | - | ||||||||||||||||||||||||
823 | } never executed: end of block | 0 | ||||||||||||||||||||||||
824 | return q_defaultSpacings[orientation == Qt::Vertical].value(); never executed: return q_defaultSpacings[orientation == Qt::Vertical].value(); | 0 | ||||||||||||||||||||||||
825 | } | - | ||||||||||||||||||||||||
826 | - | |||||||||||||||||||||||||
827 | void QGridLayoutEngine::setRowSpacing(int row, qreal spacing, Qt::Orientation orientation) | - | ||||||||||||||||||||||||
828 | { | - | ||||||||||||||||||||||||
829 | Q_ASSERT(row >= 0); | - | ||||||||||||||||||||||||
830 | - | |||||||||||||||||||||||||
831 | QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical]; | - | ||||||||||||||||||||||||
832 | if (row >= rowInfo.spacings.count())
| 0 | ||||||||||||||||||||||||
833 | rowInfo.spacings.resize(row + 1); never executed: rowInfo.spacings.resize(row + 1); | 0 | ||||||||||||||||||||||||
834 | if (spacing >= 0)
| 0 | ||||||||||||||||||||||||
835 | rowInfo.spacings[row].setUserValue(spacing); never executed: rowInfo.spacings[row].setUserValue(spacing); | 0 | ||||||||||||||||||||||||
836 | else | - | ||||||||||||||||||||||||
837 | rowInfo.spacings[row] = QLayoutParameter<qreal>(); never executed: rowInfo.spacings[row] = QLayoutParameter<qreal>(); | 0 | ||||||||||||||||||||||||
838 | invalidate(); | - | ||||||||||||||||||||||||
839 | } never executed: end of block | 0 | ||||||||||||||||||||||||
840 | - | |||||||||||||||||||||||||
841 | qreal QGridLayoutEngine::rowSpacing(int row, Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
842 | { | - | ||||||||||||||||||||||||
843 | QLayoutParameter<qreal> spacing = q_infos[orientation == Qt::Vertical].spacings.value(row); | - | ||||||||||||||||||||||||
844 | if (!spacing.isDefault())
| 0 | ||||||||||||||||||||||||
845 | return spacing.value(); never executed: return spacing.value(); | 0 | ||||||||||||||||||||||||
846 | return q_defaultSpacings[orientation == Qt::Vertical].value(); never executed: return q_defaultSpacings[orientation == Qt::Vertical].value(); | 0 | ||||||||||||||||||||||||
847 | } | - | ||||||||||||||||||||||||
848 | - | |||||||||||||||||||||||||
849 | void QGridLayoutEngine::setRowStretchFactor(int row, int stretch, Qt::Orientation orientation) | - | ||||||||||||||||||||||||
850 | { | - | ||||||||||||||||||||||||
851 | Q_ASSERT(row >= 0); | - | ||||||||||||||||||||||||
852 | Q_ASSERT(stretch >= 0); | - | ||||||||||||||||||||||||
853 | - | |||||||||||||||||||||||||
854 | maybeExpandGrid(row, -1, orientation); | - | ||||||||||||||||||||||||
855 | - | |||||||||||||||||||||||||
856 | QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical]; | - | ||||||||||||||||||||||||
857 | if (row >= rowInfo.stretches.count())
| 0 | ||||||||||||||||||||||||
858 | rowInfo.stretches.resize(row + 1); never executed: rowInfo.stretches.resize(row + 1); | 0 | ||||||||||||||||||||||||
859 | rowInfo.stretches[row].setUserValue(stretch); | - | ||||||||||||||||||||||||
860 | } never executed: end of block | 0 | ||||||||||||||||||||||||
861 | - | |||||||||||||||||||||||||
862 | int QGridLayoutEngine::rowStretchFactor(int row, Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
863 | { | - | ||||||||||||||||||||||||
864 | QStretchParameter stretch = q_infos[orientation == Qt::Vertical].stretches.value(row); | - | ||||||||||||||||||||||||
865 | if (!stretch.isDefault())
| 0 | ||||||||||||||||||||||||
866 | return stretch.value(); never executed: return stretch.value(); | 0 | ||||||||||||||||||||||||
867 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
868 | } | - | ||||||||||||||||||||||||
869 | - | |||||||||||||||||||||||||
870 | void QGridLayoutEngine::setRowSizeHint(Qt::SizeHint which, int row, qreal size, | - | ||||||||||||||||||||||||
871 | Qt::Orientation orientation) | - | ||||||||||||||||||||||||
872 | { | - | ||||||||||||||||||||||||
873 | Q_ASSERT(row >= 0); | - | ||||||||||||||||||||||||
874 | Q_ASSERT(size >= 0.0); | - | ||||||||||||||||||||||||
875 | - | |||||||||||||||||||||||||
876 | maybeExpandGrid(row, -1, orientation); | - | ||||||||||||||||||||||||
877 | - | |||||||||||||||||||||||||
878 | QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical]; | - | ||||||||||||||||||||||||
879 | if (row >= rowInfo.boxes.count())
| 0 | ||||||||||||||||||||||||
880 | rowInfo.boxes.resize(row + 1); never executed: rowInfo.boxes.resize(row + 1); | 0 | ||||||||||||||||||||||||
881 | rowInfo.boxes[row].q_sizes(which) = size; | - | ||||||||||||||||||||||||
882 | } never executed: end of block | 0 | ||||||||||||||||||||||||
883 | - | |||||||||||||||||||||||||
884 | qreal QGridLayoutEngine::rowSizeHint(Qt::SizeHint which, int row, Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
885 | { | - | ||||||||||||||||||||||||
886 | return q_infos[orientation == Qt::Vertical].boxes.value(row).q_sizes(which); never executed: return q_infos[orientation == Qt::Vertical].boxes.value(row).q_sizes(which); | 0 | ||||||||||||||||||||||||
887 | } | - | ||||||||||||||||||||||||
888 | - | |||||||||||||||||||||||||
889 | void QGridLayoutEngine::setRowAlignment(int row, Qt::Alignment alignment, | - | ||||||||||||||||||||||||
890 | Qt::Orientation orientation) | - | ||||||||||||||||||||||||
891 | { | - | ||||||||||||||||||||||||
892 | Q_ASSERT(row >= 0); | - | ||||||||||||||||||||||||
893 | - | |||||||||||||||||||||||||
894 | maybeExpandGrid(row, -1, orientation); | - | ||||||||||||||||||||||||
895 | - | |||||||||||||||||||||||||
896 | QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical]; | - | ||||||||||||||||||||||||
897 | if (row >= rowInfo.alignments.count())
| 0 | ||||||||||||||||||||||||
898 | rowInfo.alignments.resize(row + 1); never executed: rowInfo.alignments.resize(row + 1); | 0 | ||||||||||||||||||||||||
899 | rowInfo.alignments[row] = alignment; | - | ||||||||||||||||||||||||
900 | } never executed: end of block | 0 | ||||||||||||||||||||||||
901 | - | |||||||||||||||||||||||||
902 | Qt::Alignment QGridLayoutEngine::rowAlignment(int row, Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
903 | { | - | ||||||||||||||||||||||||
904 | Q_ASSERT(row >= 0); | - | ||||||||||||||||||||||||
905 | return q_infos[orientation == Qt::Vertical].alignments.value(row); never executed: return q_infos[orientation == Qt::Vertical].alignments.value(row); | 0 | ||||||||||||||||||||||||
906 | } | - | ||||||||||||||||||||||||
907 | - | |||||||||||||||||||||||||
908 | Qt::Alignment QGridLayoutEngine::effectiveAlignment(const QGridLayoutItem *layoutItem) const | - | ||||||||||||||||||||||||
909 | { | - | ||||||||||||||||||||||||
910 | Qt::Alignment align = layoutItem->alignment(); | - | ||||||||||||||||||||||||
911 | if (!(align & Qt::AlignVertical_Mask)) {
| 0 | ||||||||||||||||||||||||
912 | // no vertical alignment, respect the row alignment | - | ||||||||||||||||||||||||
913 | int y = layoutItem->firstRow(); | - | ||||||||||||||||||||||||
914 | align |= (rowAlignment(y, Qt::Vertical) & Qt::AlignVertical_Mask); | - | ||||||||||||||||||||||||
915 | if (!(align & Qt::AlignVertical_Mask))
| 0 | ||||||||||||||||||||||||
916 | align |= (m_defaultAlignment & Qt::AlignVertical_Mask); never executed: align |= (m_defaultAlignment & Qt::AlignVertical_Mask); | 0 | ||||||||||||||||||||||||
917 | } never executed: end of block | 0 | ||||||||||||||||||||||||
918 | if (!(align & Qt::AlignHorizontal_Mask)) {
| 0 | ||||||||||||||||||||||||
919 | // no horizontal alignment, respect the column alignment | - | ||||||||||||||||||||||||
920 | int x = layoutItem->firstColumn(); | - | ||||||||||||||||||||||||
921 | align |= (rowAlignment(x, Qt::Horizontal) & Qt::AlignHorizontal_Mask); | - | ||||||||||||||||||||||||
922 | } never executed: end of block | 0 | ||||||||||||||||||||||||
923 | - | |||||||||||||||||||||||||
924 | return align; never executed: return align; | 0 | ||||||||||||||||||||||||
925 | } | - | ||||||||||||||||||||||||
926 | - | |||||||||||||||||||||||||
927 | /*! | - | ||||||||||||||||||||||||
928 | \internal | - | ||||||||||||||||||||||||
929 | The \a index is only used by QGraphicsLinearLayout to ensure that itemAt() reflects the order | - | ||||||||||||||||||||||||
930 | of visual arrangement. Strictly speaking it does not have to, but most people expect it to. | - | ||||||||||||||||||||||||
931 | (And if it didn't we would have to add itemArrangedAt(int index) or something..) | - | ||||||||||||||||||||||||
932 | */ | - | ||||||||||||||||||||||||
933 | void QGridLayoutEngine::insertItem(QGridLayoutItem *item, int index) | - | ||||||||||||||||||||||||
934 | { | - | ||||||||||||||||||||||||
935 | maybeExpandGrid(item->lastRow(), item->lastColumn()); | - | ||||||||||||||||||||||||
936 | - | |||||||||||||||||||||||||
937 | if (index == -1)
| 0 | ||||||||||||||||||||||||
938 | q_items.append(item); never executed: q_items.append(item); | 0 | ||||||||||||||||||||||||
939 | else | - | ||||||||||||||||||||||||
940 | q_items.insert(index, item); never executed: q_items.insert(index, item); | 0 | ||||||||||||||||||||||||
941 | - | |||||||||||||||||||||||||
942 | for (int i = item->firstRow(); i <= item->lastRow(); ++i) {
| 0 | ||||||||||||||||||||||||
943 | for (int j = item->firstColumn(); j <= item->lastColumn(); ++j) {
| 0 | ||||||||||||||||||||||||
944 | if (itemAt(i, j))
| 0 | ||||||||||||||||||||||||
945 | qWarning("QGridLayoutEngine::addItem: Cell (%d, %d) already taken", i, j); never executed: QMessageLogger(__FILE__, 945, __PRETTY_FUNCTION__).warning("QGridLayoutEngine::addItem: Cell (%d, %d) already taken", i, j); | 0 | ||||||||||||||||||||||||
946 | setItemAt(i, j, item); | - | ||||||||||||||||||||||||
947 | } never executed: end of block | 0 | ||||||||||||||||||||||||
948 | } never executed: end of block | 0 | ||||||||||||||||||||||||
949 | } never executed: end of block | 0 | ||||||||||||||||||||||||
950 | - | |||||||||||||||||||||||||
951 | void QGridLayoutEngine::addItem(QGridLayoutItem *item) | - | ||||||||||||||||||||||||
952 | { | - | ||||||||||||||||||||||||
953 | insertItem(item, -1); | - | ||||||||||||||||||||||||
954 | } never executed: end of block | 0 | ||||||||||||||||||||||||
955 | - | |||||||||||||||||||||||||
956 | void QGridLayoutEngine::removeItem(QGridLayoutItem *item) | - | ||||||||||||||||||||||||
957 | { | - | ||||||||||||||||||||||||
958 | Q_ASSERT(q_items.contains(item)); | - | ||||||||||||||||||||||||
959 | - | |||||||||||||||||||||||||
960 | invalidate(); | - | ||||||||||||||||||||||||
961 | - | |||||||||||||||||||||||||
962 | for (int i = item->firstRow(); i <= item->lastRow(); ++i) {
| 0 | ||||||||||||||||||||||||
963 | for (int j = item->firstColumn(); j <= item->lastColumn(); ++j) {
| 0 | ||||||||||||||||||||||||
964 | if (itemAt(i, j) == item)
| 0 | ||||||||||||||||||||||||
965 | setItemAt(i, j, 0); never executed: setItemAt(i, j, 0); | 0 | ||||||||||||||||||||||||
966 | } never executed: end of block | 0 | ||||||||||||||||||||||||
967 | } never executed: end of block | 0 | ||||||||||||||||||||||||
968 | - | |||||||||||||||||||||||||
969 | q_items.removeAll(item); | - | ||||||||||||||||||||||||
970 | } never executed: end of block | 0 | ||||||||||||||||||||||||
971 | - | |||||||||||||||||||||||||
972 | - | |||||||||||||||||||||||||
973 | QGridLayoutItem *QGridLayoutEngine::itemAt(int row, int column, Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
974 | { | - | ||||||||||||||||||||||||
975 | if (orientation == Qt::Horizontal)
| 0 | ||||||||||||||||||||||||
976 | qSwap(row, column); never executed: qSwap(row, column); | 0 | ||||||||||||||||||||||||
977 | if (uint(row) >= uint(rowCount()) || uint(column) >= uint(columnCount()))
| 0 | ||||||||||||||||||||||||
978 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
979 | return q_grid.at((row * internalGridColumnCount()) + column); never executed: return q_grid.at((row * internalGridColumnCount()) + column); | 0 | ||||||||||||||||||||||||
980 | } | - | ||||||||||||||||||||||||
981 | - | |||||||||||||||||||||||||
982 | void QGridLayoutEngine::invalidate() | - | ||||||||||||||||||||||||
983 | { | - | ||||||||||||||||||||||||
984 | q_cachedEffectiveFirstRows[Hor] = -1; | - | ||||||||||||||||||||||||
985 | q_cachedEffectiveFirstRows[Ver] = -1; | - | ||||||||||||||||||||||||
986 | q_cachedEffectiveLastRows[Hor] = -1; | - | ||||||||||||||||||||||||
987 | q_cachedEffectiveLastRows[Ver] = -1; | - | ||||||||||||||||||||||||
988 | - | |||||||||||||||||||||||||
989 | q_totalBoxCachedConstraints[Hor] = NotCached; | - | ||||||||||||||||||||||||
990 | q_totalBoxCachedConstraints[Ver] = NotCached; | - | ||||||||||||||||||||||||
991 | - | |||||||||||||||||||||||||
992 | q_cachedSize = QSizeF(); | - | ||||||||||||||||||||||||
993 | q_cachedConstraintOrientation = UnknownConstraint; | - | ||||||||||||||||||||||||
994 | } never executed: end of block | 0 | ||||||||||||||||||||||||
995 | - | |||||||||||||||||||||||||
996 | static void visualRect(QRectF *geom, Qt::LayoutDirection dir, const QRectF &contentsRect) | - | ||||||||||||||||||||||||
997 | { | - | ||||||||||||||||||||||||
998 | if (dir == Qt::RightToLeft)
| 0 | ||||||||||||||||||||||||
999 | geom->moveRight(contentsRect.right() - (geom->left() - contentsRect.left())); never executed: geom->moveRight(contentsRect.right() - (geom->left() - contentsRect.left())); | 0 | ||||||||||||||||||||||||
1000 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1001 | - | |||||||||||||||||||||||||
1002 | void QGridLayoutEngine::setGeometries(const QRectF &contentsGeometry, const QAbstractLayoutStyleInfo *styleInfo) | - | ||||||||||||||||||||||||
1003 | { | - | ||||||||||||||||||||||||
1004 | if (rowCount() < 1 || columnCount() < 1)
| 0 | ||||||||||||||||||||||||
1005 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1006 | - | |||||||||||||||||||||||||
1007 | ensureGeometries(contentsGeometry.size(), styleInfo); | - | ||||||||||||||||||||||||
1008 | - | |||||||||||||||||||||||||
1009 | for (int i = q_items.count() - 1; i >= 0; --i) {
| 0 | ||||||||||||||||||||||||
1010 | QGridLayoutItem *item = q_items.at(i); | - | ||||||||||||||||||||||||
1011 | - | |||||||||||||||||||||||||
1012 | qreal x = q_xx[item->firstColumn()]; | - | ||||||||||||||||||||||||
1013 | qreal y = q_yy[item->firstRow()]; | - | ||||||||||||||||||||||||
1014 | qreal width = q_widths[item->lastColumn()]; | - | ||||||||||||||||||||||||
1015 | qreal height = q_heights[item->lastRow()]; | - | ||||||||||||||||||||||||
1016 | - | |||||||||||||||||||||||||
1017 | if (item->columnSpan() != 1)
| 0 | ||||||||||||||||||||||||
1018 | width += q_xx[item->lastColumn()] - x; never executed: width += q_xx[item->lastColumn()] - x; | 0 | ||||||||||||||||||||||||
1019 | if (item->rowSpan() != 1)
| 0 | ||||||||||||||||||||||||
1020 | height += q_yy[item->lastRow()] - y; never executed: height += q_yy[item->lastRow()] - y; | 0 | ||||||||||||||||||||||||
1021 | - | |||||||||||||||||||||||||
1022 | const Qt::Alignment align = effectiveAlignment(item); | - | ||||||||||||||||||||||||
1023 | QRectF geom = item->geometryWithin(contentsGeometry.x() + x, contentsGeometry.y() + y, | - | ||||||||||||||||||||||||
1024 | width, height, q_descents[item->lastRow()], align); | - | ||||||||||||||||||||||||
1025 | if (m_snapToPixelGrid) {
| 0 | ||||||||||||||||||||||||
1026 | // x and y should already be rounded, but the call to geometryWithin() above might | - | ||||||||||||||||||||||||
1027 | // result in a geom with x,y at half-pixels (due to centering within the cell) | - | ||||||||||||||||||||||||
1028 | geom.setX(qround(geom.x())); | - | ||||||||||||||||||||||||
1029 | // Do not snap baseline aligned items, since that might cause the baselines to not be aligned. | - | ||||||||||||||||||||||||
1030 | if (align != Qt::AlignBaseline)
| 0 | ||||||||||||||||||||||||
1031 | geom.setY(qround(geom.y())); never executed: geom.setY(qround(geom.y())); | 0 | ||||||||||||||||||||||||
1032 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1033 | visualRect(&geom, visualDirection(), contentsGeometry); | - | ||||||||||||||||||||||||
1034 | item->setGeometry(geom); | - | ||||||||||||||||||||||||
1035 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1036 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1037 | - | |||||||||||||||||||||||||
1038 | // ### candidate for deletion | - | ||||||||||||||||||||||||
1039 | QRectF QGridLayoutEngine::cellRect(const QRectF &contentsGeometry, int row, int column, int rowSpan, | - | ||||||||||||||||||||||||
1040 | int columnSpan, const QAbstractLayoutStyleInfo *styleInfo) const | - | ||||||||||||||||||||||||
1041 | { | - | ||||||||||||||||||||||||
1042 | if (uint(row) >= uint(rowCount()) || uint(column) >= uint(columnCount())
| 0 | ||||||||||||||||||||||||
1043 | || rowSpan < 1 || columnSpan < 1)
| 0 | ||||||||||||||||||||||||
1044 | return QRectF(); never executed: return QRectF(); | 0 | ||||||||||||||||||||||||
1045 | - | |||||||||||||||||||||||||
1046 | ensureGeometries(contentsGeometry.size(), styleInfo); | - | ||||||||||||||||||||||||
1047 | - | |||||||||||||||||||||||||
1048 | int lastColumn = qMax(column + columnSpan, columnCount()) - 1; | - | ||||||||||||||||||||||||
1049 | int lastRow = qMax(row + rowSpan, rowCount()) - 1; | - | ||||||||||||||||||||||||
1050 | - | |||||||||||||||||||||||||
1051 | qreal x = q_xx[column]; | - | ||||||||||||||||||||||||
1052 | qreal y = q_yy[row]; | - | ||||||||||||||||||||||||
1053 | qreal width = q_widths[lastColumn]; | - | ||||||||||||||||||||||||
1054 | qreal height = q_heights[lastRow]; | - | ||||||||||||||||||||||||
1055 | - | |||||||||||||||||||||||||
1056 | if (columnSpan != 1)
| 0 | ||||||||||||||||||||||||
1057 | width += q_xx[lastColumn] - x; never executed: width += q_xx[lastColumn] - x; | 0 | ||||||||||||||||||||||||
1058 | if (rowSpan != 1)
| 0 | ||||||||||||||||||||||||
1059 | height += q_yy[lastRow] - y; never executed: height += q_yy[lastRow] - y; | 0 | ||||||||||||||||||||||||
1060 | - | |||||||||||||||||||||||||
1061 | return QRectF(contentsGeometry.x() + x, contentsGeometry.y() + y, width, height); never executed: return QRectF(contentsGeometry.x() + x, contentsGeometry.y() + y, width, height); | 0 | ||||||||||||||||||||||||
1062 | } | - | ||||||||||||||||||||||||
1063 | - | |||||||||||||||||||||||||
1064 | QSizeF QGridLayoutEngine::sizeHint(Qt::SizeHint which, const QSizeF &constraint, | - | ||||||||||||||||||||||||
1065 | const QAbstractLayoutStyleInfo *styleInfo) const | - | ||||||||||||||||||||||||
1066 | { | - | ||||||||||||||||||||||||
1067 | - | |||||||||||||||||||||||||
1068 | - | |||||||||||||||||||||||||
1069 | if (hasDynamicConstraint() && rowCount() > 0 && columnCount() > 0) {
| 0 | ||||||||||||||||||||||||
1070 | QGridLayoutBox sizehint_totalBoxes[NOrientations]; | - | ||||||||||||||||||||||||
1071 | bool sizeHintCalculated = false; | - | ||||||||||||||||||||||||
1072 | if (constraintOrientation() == Qt::Vertical) {
| 0 | ||||||||||||||||||||||||
1073 | //We have items whose height depends on their width | - | ||||||||||||||||||||||||
1074 | if (constraint.width() >= 0) {
| 0 | ||||||||||||||||||||||||
1075 | ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], NULL, NULL, Qt::Horizontal, styleInfo); | - | ||||||||||||||||||||||||
1076 | QVector<qreal> sizehint_xx; | - | ||||||||||||||||||||||||
1077 | QVector<qreal> sizehint_widths; | - | ||||||||||||||||||||||||
1078 | - | |||||||||||||||||||||||||
1079 | sizehint_xx.resize(columnCount()); | - | ||||||||||||||||||||||||
1080 | sizehint_widths.resize(columnCount()); | - | ||||||||||||||||||||||||
1081 | qreal width = constraint.width(); | - | ||||||||||||||||||||||||
1082 | //Calculate column widths and positions, and put results in q_xx.data() and q_widths.data() so that we can use this information as | - | ||||||||||||||||||||||||
1083 | //constraints to find the row heights | - | ||||||||||||||||||||||||
1084 | q_columnData.calculateGeometries(0, columnCount(), width, sizehint_xx.data(), sizehint_widths.data(), | - | ||||||||||||||||||||||||
1085 | 0, sizehint_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); | - | ||||||||||||||||||||||||
1086 | ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], sizehint_xx.data(), sizehint_widths.data(), Qt::Vertical, styleInfo); | - | ||||||||||||||||||||||||
1087 | sizeHintCalculated = true; | - | ||||||||||||||||||||||||
1088 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1089 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
1090 | if (constraint.height() >= 0) {
| 0 | ||||||||||||||||||||||||
1091 | //We have items whose width depends on their height | - | ||||||||||||||||||||||||
1092 | ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], NULL, NULL, Qt::Vertical, styleInfo); | - | ||||||||||||||||||||||||
1093 | QVector<qreal> sizehint_yy; | - | ||||||||||||||||||||||||
1094 | QVector<qreal> sizehint_heights; | - | ||||||||||||||||||||||||
1095 | - | |||||||||||||||||||||||||
1096 | sizehint_yy.resize(rowCount()); | - | ||||||||||||||||||||||||
1097 | sizehint_heights.resize(rowCount()); | - | ||||||||||||||||||||||||
1098 | qreal height = constraint.height(); | - | ||||||||||||||||||||||||
1099 | //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() so that we can use this information as | - | ||||||||||||||||||||||||
1100 | //constraints to find the column widths | - | ||||||||||||||||||||||||
1101 | q_rowData.calculateGeometries(0, rowCount(), height, sizehint_yy.data(), sizehint_heights.data(), | - | ||||||||||||||||||||||||
1102 | 0, sizehint_totalBoxes[Ver], q_infos[Ver], m_snapToPixelGrid); | - | ||||||||||||||||||||||||
1103 | ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], sizehint_yy.data(), sizehint_heights.data(), Qt::Horizontal, styleInfo); | - | ||||||||||||||||||||||||
1104 | sizeHintCalculated = true; | - | ||||||||||||||||||||||||
1105 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1106 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1107 | if (sizeHintCalculated)
| 0 | ||||||||||||||||||||||||
1108 | return QSizeF(sizehint_totalBoxes[Hor].q_sizes(which), sizehint_totalBoxes[Ver].q_sizes(which)); never executed: return QSizeF(sizehint_totalBoxes[Hor].q_sizes(which), sizehint_totalBoxes[Ver].q_sizes(which)); | 0 | ||||||||||||||||||||||||
1109 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1110 | - | |||||||||||||||||||||||||
1111 | //No items with height for width, so it doesn't matter which order we do these in | - | ||||||||||||||||||||||||
1112 | ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], NULL, NULL, Qt::Horizontal, styleInfo); | - | ||||||||||||||||||||||||
1113 | ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], NULL, NULL, Qt::Vertical, styleInfo); | - | ||||||||||||||||||||||||
1114 | return QSizeF(q_totalBoxes[Hor].q_sizes(which), q_totalBoxes[Ver].q_sizes(which)); never executed: return QSizeF(q_totalBoxes[Hor].q_sizes(which), q_totalBoxes[Ver].q_sizes(which)); | 0 | ||||||||||||||||||||||||
1115 | } | - | ||||||||||||||||||||||||
1116 | - | |||||||||||||||||||||||||
1117 | QLayoutPolicy::ControlTypes QGridLayoutEngine::controlTypes(LayoutSide side) const | - | ||||||||||||||||||||||||
1118 | { | - | ||||||||||||||||||||||||
1119 | Qt::Orientation orientation = (side == Top || side == Bottom) ? Qt::Vertical : Qt::Horizontal;
| 0 | ||||||||||||||||||||||||
1120 | int row = (side == Top || side == Left) ? effectiveFirstRow(orientation)
| 0 | ||||||||||||||||||||||||
1121 | : effectiveLastRow(orientation); | - | ||||||||||||||||||||||||
1122 | QLayoutPolicy::ControlTypes result = 0; | - | ||||||||||||||||||||||||
1123 | - | |||||||||||||||||||||||||
1124 | for (int column = columnCount(orientation) - 1; column >= 0; --column) {
| 0 | ||||||||||||||||||||||||
1125 | if (QGridLayoutItem *item = itemAt(row, column, orientation))
| 0 | ||||||||||||||||||||||||
1126 | result |= item->controlTypes(side); never executed: result |= item->controlTypes(side); | 0 | ||||||||||||||||||||||||
1127 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1128 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
1129 | } | - | ||||||||||||||||||||||||
1130 | - | |||||||||||||||||||||||||
1131 | void QGridLayoutEngine::transpose() | - | ||||||||||||||||||||||||
1132 | { | - | ||||||||||||||||||||||||
1133 | invalidate(); | - | ||||||||||||||||||||||||
1134 | - | |||||||||||||||||||||||||
1135 | for (int i = q_items.count() - 1; i >= 0; --i)
| 0 | ||||||||||||||||||||||||
1136 | q_items.at(i)->transpose(); never executed: q_items.at(i)->transpose(); | 0 | ||||||||||||||||||||||||
1137 | - | |||||||||||||||||||||||||
1138 | qSwap(q_defaultSpacings[Hor], q_defaultSpacings[Ver]); | - | ||||||||||||||||||||||||
1139 | qSwap(q_infos[Hor], q_infos[Ver]); | - | ||||||||||||||||||||||||
1140 | - | |||||||||||||||||||||||||
1141 | regenerateGrid(); | - | ||||||||||||||||||||||||
1142 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1143 | - | |||||||||||||||||||||||||
1144 | void QGridLayoutEngine::setVisualDirection(Qt::LayoutDirection direction) | - | ||||||||||||||||||||||||
1145 | { | - | ||||||||||||||||||||||||
1146 | m_visualDirection = direction; | - | ||||||||||||||||||||||||
1147 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1148 | - | |||||||||||||||||||||||||
1149 | Qt::LayoutDirection QGridLayoutEngine::visualDirection() const | - | ||||||||||||||||||||||||
1150 | { | - | ||||||||||||||||||||||||
1151 | return m_visualDirection; never executed: return m_visualDirection; | 0 | ||||||||||||||||||||||||
1152 | } | - | ||||||||||||||||||||||||
1153 | - | |||||||||||||||||||||||||
1154 | #ifdef QGRIDLAYOUTENGINE_DEBUG | - | ||||||||||||||||||||||||
1155 | void QGridLayoutEngine::dump(int indent) const | - | ||||||||||||||||||||||||
1156 | { | - | ||||||||||||||||||||||||
1157 | qDebug("%*sEngine", indent, ""); | - | ||||||||||||||||||||||||
1158 | - | |||||||||||||||||||||||||
1159 | qDebug("%*s Items (%d)", indent, "", q_items.count()); | - | ||||||||||||||||||||||||
1160 | int i; | - | ||||||||||||||||||||||||
1161 | for (i = 0; i < q_items.count(); ++i) | - | ||||||||||||||||||||||||
1162 | q_items.at(i)->dump(indent + 2); | - | ||||||||||||||||||||||||
1163 | - | |||||||||||||||||||||||||
1164 | qDebug("%*s Grid (%d x %d)", indent, "", internalGridRowCount(), | - | ||||||||||||||||||||||||
1165 | internalGridColumnCount()); | - | ||||||||||||||||||||||||
1166 | for (int row = 0; row < internalGridRowCount(); ++row) { | - | ||||||||||||||||||||||||
1167 | QString message = QLatin1String("[ "); | - | ||||||||||||||||||||||||
1168 | for (int column = 0; column < internalGridColumnCount(); ++column) { | - | ||||||||||||||||||||||||
1169 | message += QString::number(q_items.indexOf(itemAt(row, column))).rightJustified(3); | - | ||||||||||||||||||||||||
1170 | message += QLatin1Char(' '); | - | ||||||||||||||||||||||||
1171 | } | - | ||||||||||||||||||||||||
1172 | message += QLatin1Char(']'); | - | ||||||||||||||||||||||||
1173 | qDebug("%*s %s", indent, "", qPrintable(message)); | - | ||||||||||||||||||||||||
1174 | } | - | ||||||||||||||||||||||||
1175 | - | |||||||||||||||||||||||||
1176 | if (q_defaultSpacings[Hor].value() >= 0.0 || q_defaultSpacings[Ver].value() >= 0.0) | - | ||||||||||||||||||||||||
1177 | qDebug("%*s Default spacings: %g %g", indent, "", q_defaultSpacings[Hor].value(), | - | ||||||||||||||||||||||||
1178 | q_defaultSpacings[Ver].value()); | - | ||||||||||||||||||||||||
1179 | - | |||||||||||||||||||||||||
1180 | qDebug("%*s Column and row info", indent, ""); | - | ||||||||||||||||||||||||
1181 | q_infos[Hor].dump(indent + 2); | - | ||||||||||||||||||||||||
1182 | q_infos[Ver].dump(indent + 2); | - | ||||||||||||||||||||||||
1183 | - | |||||||||||||||||||||||||
1184 | qDebug("%*s Column and row data", indent, ""); | - | ||||||||||||||||||||||||
1185 | q_columnData.dump(indent + 2); | - | ||||||||||||||||||||||||
1186 | q_rowData.dump(indent + 2); | - | ||||||||||||||||||||||||
1187 | - | |||||||||||||||||||||||||
1188 | qDebug("%*s Geometries output", indent, ""); | - | ||||||||||||||||||||||||
1189 | QVector<qreal> *cellPos = &q_yy; | - | ||||||||||||||||||||||||
1190 | for (int pass = 0; pass < 2; ++pass) { | - | ||||||||||||||||||||||||
1191 | QString message; | - | ||||||||||||||||||||||||
1192 | for (i = 0; i < cellPos->count(); ++i) { | - | ||||||||||||||||||||||||
1193 | message += QLatin1String((message.isEmpty() ? "[" : ", ")); | - | ||||||||||||||||||||||||
1194 | message += QString::number(cellPos->at(i)); | - | ||||||||||||||||||||||||
1195 | } | - | ||||||||||||||||||||||||
1196 | message += QLatin1Char(']'); | - | ||||||||||||||||||||||||
1197 | qDebug("%*s %s %s", indent, "", (pass == 0 ? "rows:" : "columns:"), qPrintable(message)); | - | ||||||||||||||||||||||||
1198 | cellPos = &q_xx; | - | ||||||||||||||||||||||||
1199 | } | - | ||||||||||||||||||||||||
1200 | } | - | ||||||||||||||||||||||||
1201 | #endif | - | ||||||||||||||||||||||||
1202 | - | |||||||||||||||||||||||||
1203 | void QGridLayoutEngine::maybeExpandGrid(int row, int column, Qt::Orientation orientation) | - | ||||||||||||||||||||||||
1204 | { | - | ||||||||||||||||||||||||
1205 | invalidate(); // ### move out of here? | - | ||||||||||||||||||||||||
1206 | - | |||||||||||||||||||||||||
1207 | if (orientation == Qt::Horizontal)
| 0 | ||||||||||||||||||||||||
1208 | qSwap(row, column); never executed: qSwap(row, column); | 0 | ||||||||||||||||||||||||
1209 | - | |||||||||||||||||||||||||
1210 | if (row < rowCount() && column < columnCount())
| 0 | ||||||||||||||||||||||||
1211 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1212 | - | |||||||||||||||||||||||||
1213 | int oldGridRowCount = internalGridRowCount(); | - | ||||||||||||||||||||||||
1214 | int oldGridColumnCount = internalGridColumnCount(); | - | ||||||||||||||||||||||||
1215 | - | |||||||||||||||||||||||||
1216 | q_infos[Ver].count = qMax(row + 1, rowCount()); | - | ||||||||||||||||||||||||
1217 | q_infos[Hor].count = qMax(column + 1, columnCount()); | - | ||||||||||||||||||||||||
1218 | - | |||||||||||||||||||||||||
1219 | int newGridRowCount = internalGridRowCount(); | - | ||||||||||||||||||||||||
1220 | int newGridColumnCount = internalGridColumnCount(); | - | ||||||||||||||||||||||||
1221 | - | |||||||||||||||||||||||||
1222 | int newGridSize = newGridRowCount * newGridColumnCount; | - | ||||||||||||||||||||||||
1223 | if (newGridSize != q_grid.count()) {
| 0 | ||||||||||||||||||||||||
1224 | q_grid.resize(newGridSize); | - | ||||||||||||||||||||||||
1225 | - | |||||||||||||||||||||||||
1226 | if (newGridColumnCount != oldGridColumnCount) {
| 0 | ||||||||||||||||||||||||
1227 | for (int i = oldGridRowCount - 1; i >= 1; --i) {
| 0 | ||||||||||||||||||||||||
1228 | for (int j = oldGridColumnCount - 1; j >= 0; --j) {
| 0 | ||||||||||||||||||||||||
1229 | int oldIndex = (i * oldGridColumnCount) + j; | - | ||||||||||||||||||||||||
1230 | int newIndex = (i * newGridColumnCount) + j; | - | ||||||||||||||||||||||||
1231 | - | |||||||||||||||||||||||||
1232 | Q_ASSERT(newIndex > oldIndex); | - | ||||||||||||||||||||||||
1233 | q_grid[newIndex] = q_grid[oldIndex]; | - | ||||||||||||||||||||||||
1234 | q_grid[oldIndex] = 0; | - | ||||||||||||||||||||||||
1235 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1236 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1237 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1238 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1239 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1240 | - | |||||||||||||||||||||||||
1241 | void QGridLayoutEngine::regenerateGrid() | - | ||||||||||||||||||||||||
1242 | { | - | ||||||||||||||||||||||||
1243 | q_grid.fill(0); | - | ||||||||||||||||||||||||
1244 | - | |||||||||||||||||||||||||
1245 | for (int i = q_items.count() - 1; i >= 0; --i) {
| 0 | ||||||||||||||||||||||||
1246 | QGridLayoutItem *item = q_items.at(i); | - | ||||||||||||||||||||||||
1247 | - | |||||||||||||||||||||||||
1248 | for (int j = item->firstRow(); j <= item->lastRow(); ++j) {
| 0 | ||||||||||||||||||||||||
1249 | for (int k = item->firstColumn(); k <= item->lastColumn(); ++k) {
| 0 | ||||||||||||||||||||||||
1250 | setItemAt(j, k, item); | - | ||||||||||||||||||||||||
1251 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1252 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1253 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1254 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1255 | - | |||||||||||||||||||||||||
1256 | void QGridLayoutEngine::setItemAt(int row, int column, QGridLayoutItem *item) | - | ||||||||||||||||||||||||
1257 | { | - | ||||||||||||||||||||||||
1258 | Q_ASSERT(row >= 0 && row < rowCount()); | - | ||||||||||||||||||||||||
1259 | Q_ASSERT(column >= 0 && column < columnCount()); | - | ||||||||||||||||||||||||
1260 | q_grid[(row * internalGridColumnCount()) + column] = item; | - | ||||||||||||||||||||||||
1261 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1262 | - | |||||||||||||||||||||||||
1263 | void QGridLayoutEngine::insertOrRemoveRows(int row, int delta, Qt::Orientation orientation) | - | ||||||||||||||||||||||||
1264 | { | - | ||||||||||||||||||||||||
1265 | int oldRowCount = rowCount(orientation); | - | ||||||||||||||||||||||||
1266 | Q_ASSERT(uint(row) <= uint(oldRowCount)); | - | ||||||||||||||||||||||||
1267 | - | |||||||||||||||||||||||||
1268 | invalidate(); | - | ||||||||||||||||||||||||
1269 | - | |||||||||||||||||||||||||
1270 | // appending rows (or columns) is easy | - | ||||||||||||||||||||||||
1271 | if (row == oldRowCount && delta > 0) {
| 0 | ||||||||||||||||||||||||
1272 | maybeExpandGrid(oldRowCount + delta - 1, -1, orientation); | - | ||||||||||||||||||||||||
1273 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1274 | } | - | ||||||||||||||||||||||||
1275 | - | |||||||||||||||||||||||||
1276 | q_infos[orientation == Qt::Vertical].insertOrRemoveRows(row, delta); | - | ||||||||||||||||||||||||
1277 | - | |||||||||||||||||||||||||
1278 | for (int i = q_items.count() - 1; i >= 0; --i)
| 0 | ||||||||||||||||||||||||
1279 | q_items.at(i)->insertOrRemoveRows(row, delta, orientation); never executed: q_items.at(i)->insertOrRemoveRows(row, delta, orientation); | 0 | ||||||||||||||||||||||||
1280 | - | |||||||||||||||||||||||||
1281 | q_grid.resize(internalGridRowCount() * internalGridColumnCount()); | - | ||||||||||||||||||||||||
1282 | regenerateGrid(); | - | ||||||||||||||||||||||||
1283 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1284 | - | |||||||||||||||||||||||||
1285 | void QGridLayoutEngine::fillRowData(QGridLayoutRowData *rowData, | - | ||||||||||||||||||||||||
1286 | const qreal *colPositions, const qreal *colSizes, | - | ||||||||||||||||||||||||
1287 | Qt::Orientation orientation, | - | ||||||||||||||||||||||||
1288 | const QAbstractLayoutStyleInfo *styleInfo) const | - | ||||||||||||||||||||||||
1289 | { | - | ||||||||||||||||||||||||
1290 | const int ButtonMask = QLayoutPolicy::ButtonBox | QLayoutPolicy::PushButton; | - | ||||||||||||||||||||||||
1291 | const QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical]; | - | ||||||||||||||||||||||||
1292 | const QGridLayoutRowInfo &columnInfo = q_infos[orientation == Qt::Horizontal]; | - | ||||||||||||||||||||||||
1293 | LayoutSide top = (orientation == Qt::Vertical) ? Top : Left;
| 0 | ||||||||||||||||||||||||
1294 | LayoutSide bottom = (orientation == Qt::Vertical) ? Bottom : Right;
| 0 | ||||||||||||||||||||||||
1295 | - | |||||||||||||||||||||||||
1296 | const QLayoutParameter<qreal> &defaultSpacing = q_defaultSpacings[orientation == Qt::Vertical]; | - | ||||||||||||||||||||||||
1297 | qreal innerSpacing = styleInfo->spacing(orientation); | - | ||||||||||||||||||||||||
1298 | if (innerSpacing >= 0.0)
| 0 | ||||||||||||||||||||||||
1299 | defaultSpacing.setCachedValue(innerSpacing); never executed: defaultSpacing.setCachedValue(innerSpacing); | 0 | ||||||||||||||||||||||||
1300 | - | |||||||||||||||||||||||||
1301 | for (int row = 0; row < rowInfo.count; ++row) {
| 0 | ||||||||||||||||||||||||
1302 | bool rowIsEmpty = true; | - | ||||||||||||||||||||||||
1303 | bool rowIsIdenticalToPrevious = (row > 0); | - | ||||||||||||||||||||||||
1304 | - | |||||||||||||||||||||||||
1305 | for (int column = 0; column < columnInfo.count; ++column) {
| 0 | ||||||||||||||||||||||||
1306 | QGridLayoutItem *item = itemAt(row, column, orientation); | - | ||||||||||||||||||||||||
1307 | - | |||||||||||||||||||||||||
1308 | if (rowIsIdenticalToPrevious && item != itemAt(row - 1, column, orientation))
| 0 | ||||||||||||||||||||||||
1309 | rowIsIdenticalToPrevious = false; never executed: rowIsIdenticalToPrevious = false; | 0 | ||||||||||||||||||||||||
1310 | - | |||||||||||||||||||||||||
1311 | if (item && !item->isIgnored())
| 0 | ||||||||||||||||||||||||
1312 | rowIsEmpty = false; never executed: rowIsEmpty = false; | 0 | ||||||||||||||||||||||||
1313 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1314 | - | |||||||||||||||||||||||||
1315 | if ((rowIsEmpty || rowIsIdenticalToPrevious)
| 0 | ||||||||||||||||||||||||
1316 | && rowInfo.spacings.value(row).isDefault()
| 0 | ||||||||||||||||||||||||
1317 | && rowInfo.stretches.value(row).isDefault()
| 0 | ||||||||||||||||||||||||
1318 | && rowInfo.boxes.value(row) == QGridLayoutBox())
| 0 | ||||||||||||||||||||||||
1319 | rowData->ignore.setBit(row, true); never executed: rowData->ignore.setBit(row, true); | 0 | ||||||||||||||||||||||||
1320 | - | |||||||||||||||||||||||||
1321 | if (rowInfo.spacings.value(row).isUser()) {
| 0 | ||||||||||||||||||||||||
1322 | rowData->spacings[row] = rowInfo.spacings.at(row).value(); | - | ||||||||||||||||||||||||
1323 | } else if (!defaultSpacing.isDefault()) { never executed: end of block
| 0 | ||||||||||||||||||||||||
1324 | rowData->spacings[row] = defaultSpacing.value(); | - | ||||||||||||||||||||||||
1325 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1326 | - | |||||||||||||||||||||||||
1327 | rowData->stretches[row] = rowInfo.stretches.value(row).value(); | - | ||||||||||||||||||||||||
1328 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1329 | - | |||||||||||||||||||||||||
1330 | struct RowAdHocData { | - | ||||||||||||||||||||||||
1331 | int q_row; | - | ||||||||||||||||||||||||
1332 | unsigned int q_hasButtons : 8; | - | ||||||||||||||||||||||||
1333 | unsigned int q_hasNonButtons : 8; | - | ||||||||||||||||||||||||
1334 | - | |||||||||||||||||||||||||
1335 | inline RowAdHocData() : q_row(-1), q_hasButtons(false), q_hasNonButtons(false) {} never executed: end of block | 0 | ||||||||||||||||||||||||
1336 | inline void init(int row) { | - | ||||||||||||||||||||||||
1337 | this->q_row = row; | - | ||||||||||||||||||||||||
1338 | q_hasButtons = false; | - | ||||||||||||||||||||||||
1339 | q_hasNonButtons = false; | - | ||||||||||||||||||||||||
1340 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1341 | inline bool hasOnlyButtons() const { return q_hasButtons && !q_hasNonButtons; } never executed: return q_hasButtons && !q_hasNonButtons;
| 0 | ||||||||||||||||||||||||
1342 | inline bool hasOnlyNonButtons() const { return q_hasNonButtons && !q_hasButtons; } never executed: return q_hasNonButtons && !q_hasButtons;
| 0 | ||||||||||||||||||||||||
1343 | }; | - | ||||||||||||||||||||||||
1344 | RowAdHocData lastRowAdHocData; | - | ||||||||||||||||||||||||
1345 | RowAdHocData nextToLastRowAdHocData; | - | ||||||||||||||||||||||||
1346 | RowAdHocData nextToNextToLastRowAdHocData; | - | ||||||||||||||||||||||||
1347 | - | |||||||||||||||||||||||||
1348 | rowData->hasIgnoreFlag = false; | - | ||||||||||||||||||||||||
1349 | for (int row = 0; row < rowInfo.count; ++row) {
| 0 | ||||||||||||||||||||||||
1350 | if (rowData->ignore.testBit(row))
| 0 | ||||||||||||||||||||||||
1351 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
1352 | - | |||||||||||||||||||||||||
1353 | QGridLayoutBox &rowBox = rowData->boxes[row]; | - | ||||||||||||||||||||||||
1354 | if (styleInfo->isWindow()) {
| 0 | ||||||||||||||||||||||||
1355 | nextToNextToLastRowAdHocData = nextToLastRowAdHocData; | - | ||||||||||||||||||||||||
1356 | nextToLastRowAdHocData = lastRowAdHocData; | - | ||||||||||||||||||||||||
1357 | lastRowAdHocData.init(row); | - | ||||||||||||||||||||||||
1358 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1359 | - | |||||||||||||||||||||||||
1360 | bool userRowStretch = rowInfo.stretches.value(row).isUser(); | - | ||||||||||||||||||||||||
1361 | int &rowStretch = rowData->stretches[row]; | - | ||||||||||||||||||||||||
1362 | - | |||||||||||||||||||||||||
1363 | bool hasIgnoreFlag = true; | - | ||||||||||||||||||||||||
1364 | for (int column = 0; column < columnInfo.count; ++column) {
| 0 | ||||||||||||||||||||||||
1365 | QGridLayoutItem *item = itemAt(row, column, orientation); | - | ||||||||||||||||||||||||
1366 | if (item) {
| 0 | ||||||||||||||||||||||||
1367 | int itemRow = item->firstRow(orientation); | - | ||||||||||||||||||||||||
1368 | int itemColumn = item->firstColumn(orientation); | - | ||||||||||||||||||||||||
1369 | - | |||||||||||||||||||||||||
1370 | if (itemRow == row && itemColumn == column) {
| 0 | ||||||||||||||||||||||||
1371 | int itemStretch = item->stretchFactor(orientation); | - | ||||||||||||||||||||||||
1372 | if (!(item->sizePolicy(orientation) & QLayoutPolicy::IgnoreFlag))
| 0 | ||||||||||||||||||||||||
1373 | hasIgnoreFlag = false; never executed: hasIgnoreFlag = false; | 0 | ||||||||||||||||||||||||
1374 | int itemRowSpan = item->rowSpan(orientation); | - | ||||||||||||||||||||||||
1375 | - | |||||||||||||||||||||||||
1376 | int effectiveRowSpan = 1; | - | ||||||||||||||||||||||||
1377 | for (int i = 1; i < itemRowSpan; ++i) {
| 0 | ||||||||||||||||||||||||
1378 | if (!rowData->ignore.testBit(i + itemRow))
| 0 | ||||||||||||||||||||||||
1379 | ++effectiveRowSpan; never executed: ++effectiveRowSpan; | 0 | ||||||||||||||||||||||||
1380 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1381 | - | |||||||||||||||||||||||||
1382 | QGridLayoutBox *box; | - | ||||||||||||||||||||||||
1383 | if (effectiveRowSpan == 1) {
| 0 | ||||||||||||||||||||||||
1384 | box = &rowBox; | - | ||||||||||||||||||||||||
1385 | if (!userRowStretch && itemStretch != 0)
| 0 | ||||||||||||||||||||||||
1386 | rowStretch = qMax(rowStretch, itemStretch); never executed: rowStretch = qMax(rowStretch, itemStretch); | 0 | ||||||||||||||||||||||||
1387 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
1388 | QGridLayoutMultiCellData &multiCell = | - | ||||||||||||||||||||||||
1389 | rowData->multiCellMap[qMakePair(row, itemRowSpan)]; | - | ||||||||||||||||||||||||
1390 | box = &multiCell.q_box; | - | ||||||||||||||||||||||||
1391 | multiCell.q_stretch = itemStretch; | - | ||||||||||||||||||||||||
1392 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1393 | // Items with constraints need to be passed the constraint | - | ||||||||||||||||||||||||
1394 | if (colSizes && colPositions && item->hasDynamicConstraint() && orientation == item->dynamicConstraintOrientation()) {
| 0 | ||||||||||||||||||||||||
1395 | /* Get the width of the item by summing up the widths of the columns that it spans. | - | ||||||||||||||||||||||||
1396 | * We need to have already calculated the widths of the columns by calling | - | ||||||||||||||||||||||||
1397 | * q_columns->calculateGeometries() before hand and passing the value in the colSizes | - | ||||||||||||||||||||||||
1398 | * and colPositions parameters. | - | ||||||||||||||||||||||||
1399 | * The variable name is still colSizes even when it actually has the row sizes | - | ||||||||||||||||||||||||
1400 | */ | - | ||||||||||||||||||||||||
1401 | qreal length = colSizes[item->lastColumn(orientation)]; | - | ||||||||||||||||||||||||
1402 | if (item->columnSpan(orientation) != 1)
| 0 | ||||||||||||||||||||||||
1403 | length += colPositions[item->lastColumn(orientation)] - colPositions[item->firstColumn(orientation)]; never executed: length += colPositions[item->lastColumn(orientation)] - colPositions[item->firstColumn(orientation)]; | 0 | ||||||||||||||||||||||||
1404 | box->combine(item->box(orientation, length)); | - | ||||||||||||||||||||||||
1405 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
1406 | box->combine(item->box(orientation)); | - | ||||||||||||||||||||||||
1407 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1408 | - | |||||||||||||||||||||||||
1409 | if (effectiveRowSpan == 1) {
| 0 | ||||||||||||||||||||||||
1410 | QLayoutPolicy::ControlTypes controls = item->controlTypes(top); | - | ||||||||||||||||||||||||
1411 | if (controls & ButtonMask)
| 0 | ||||||||||||||||||||||||
1412 | lastRowAdHocData.q_hasButtons = true; never executed: lastRowAdHocData.q_hasButtons = true; | 0 | ||||||||||||||||||||||||
1413 | if (controls & ~ButtonMask)
| 0 | ||||||||||||||||||||||||
1414 | lastRowAdHocData.q_hasNonButtons = true; never executed: lastRowAdHocData.q_hasNonButtons = true; | 0 | ||||||||||||||||||||||||
1415 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1416 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1417 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1418 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1419 | if (row < rowInfo.boxes.count()) {
| 0 | ||||||||||||||||||||||||
1420 | QGridLayoutBox rowBoxInfo = rowInfo.boxes.at(row); | - | ||||||||||||||||||||||||
1421 | rowBoxInfo.normalize(); | - | ||||||||||||||||||||||||
1422 | rowBox.q_minimumSize = qMax(rowBox.q_minimumSize, rowBoxInfo.q_minimumSize); | - | ||||||||||||||||||||||||
1423 | rowBox.q_maximumSize = qMax(rowBox.q_minimumSize, | - | ||||||||||||||||||||||||
1424 | (rowBoxInfo.q_maximumSize != FLT_MAX ? | - | ||||||||||||||||||||||||
1425 | rowBoxInfo.q_maximumSize : rowBox.q_maximumSize)); | - | ||||||||||||||||||||||||
1426 | rowBox.q_preferredSize = qBound(rowBox.q_minimumSize, | - | ||||||||||||||||||||||||
1427 | qMax(rowBox.q_preferredSize, rowBoxInfo.q_preferredSize), | - | ||||||||||||||||||||||||
1428 | rowBox.q_maximumSize); | - | ||||||||||||||||||||||||
1429 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1430 | if (hasIgnoreFlag)
| 0 | ||||||||||||||||||||||||
1431 | rowData->hasIgnoreFlag = true; never executed: rowData->hasIgnoreFlag = true; | 0 | ||||||||||||||||||||||||
1432 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1433 | - | |||||||||||||||||||||||||
1434 | /* | - | ||||||||||||||||||||||||
1435 | Heuristic: Detect button boxes that don't use QLayoutPolicy::ButtonBox. | - | ||||||||||||||||||||||||
1436 | This is somewhat ad hoc but it usually does the trick. | - | ||||||||||||||||||||||||
1437 | */ | - | ||||||||||||||||||||||||
1438 | bool lastRowIsButtonBox = (lastRowAdHocData.hasOnlyButtons()
| 0 | ||||||||||||||||||||||||
1439 | && nextToLastRowAdHocData.hasOnlyNonButtons());
| 0 | ||||||||||||||||||||||||
1440 | bool lastTwoRowsIsButtonBox = (lastRowAdHocData.hasOnlyButtons()
| 0 | ||||||||||||||||||||||||
1441 | && nextToLastRowAdHocData.hasOnlyButtons()
| 0 | ||||||||||||||||||||||||
1442 | && nextToNextToLastRowAdHocData.hasOnlyNonButtons()
| 0 | ||||||||||||||||||||||||
1443 | && orientation == Qt::Vertical);
| 0 | ||||||||||||||||||||||||
1444 | - | |||||||||||||||||||||||||
1445 | if (defaultSpacing.isDefault()) {
| 0 | ||||||||||||||||||||||||
1446 | int prevRow = -1; | - | ||||||||||||||||||||||||
1447 | for (int row = 0; row < rowInfo.count; ++row) {
| 0 | ||||||||||||||||||||||||
1448 | if (rowData->ignore.testBit(row))
| 0 | ||||||||||||||||||||||||
1449 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
1450 | - | |||||||||||||||||||||||||
1451 | if (prevRow != -1 && !rowInfo.spacings.value(prevRow).isUser()) {
| 0 | ||||||||||||||||||||||||
1452 | qreal &rowSpacing = rowData->spacings[prevRow]; | - | ||||||||||||||||||||||||
1453 | for (int column = 0; column < columnInfo.count; ++column) {
| 0 | ||||||||||||||||||||||||
1454 | QGridLayoutItem *item1 = itemAt(prevRow, column, orientation); | - | ||||||||||||||||||||||||
1455 | QGridLayoutItem *item2 = itemAt(row, column, orientation); | - | ||||||||||||||||||||||||
1456 | - | |||||||||||||||||||||||||
1457 | if (item1 && item2 && item1 != item2) {
| 0 | ||||||||||||||||||||||||
1458 | QLayoutPolicy::ControlTypes controls1 = item1->controlTypes(bottom); | - | ||||||||||||||||||||||||
1459 | QLayoutPolicy::ControlTypes controls2 = item2->controlTypes(top); | - | ||||||||||||||||||||||||
1460 | - | |||||||||||||||||||||||||
1461 | if (controls2 & QLayoutPolicy::PushButton) {
| 0 | ||||||||||||||||||||||||
1462 | if ((row == nextToLastRowAdHocData.q_row && lastTwoRowsIsButtonBox)
| 0 | ||||||||||||||||||||||||
1463 | || (row == lastRowAdHocData.q_row && lastRowIsButtonBox)) {
| 0 | ||||||||||||||||||||||||
1464 | controls2 &= ~QLayoutPolicy::PushButton; | - | ||||||||||||||||||||||||
1465 | controls2 |= QLayoutPolicy::ButtonBox; | - | ||||||||||||||||||||||||
1466 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1467 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1468 | - | |||||||||||||||||||||||||
1469 | qreal spacing = styleInfo->combinedLayoutSpacing(controls1, controls2, | - | ||||||||||||||||||||||||
1470 | orientation); | - | ||||||||||||||||||||||||
1471 | if (orientation == Qt::Horizontal) {
| 0 | ||||||||||||||||||||||||
1472 | qreal width1 = rowData->boxes.at(prevRow).q_minimumSize; | - | ||||||||||||||||||||||||
1473 | qreal width2 = rowData->boxes.at(row).q_minimumSize; | - | ||||||||||||||||||||||||
1474 | QRectF rect1 = item1->geometryWithin(0.0, 0.0, width1, FLT_MAX, -1.0, effectiveAlignment(item1)); | - | ||||||||||||||||||||||||
1475 | QRectF rect2 = item2->geometryWithin(0.0, 0.0, width2, FLT_MAX, -1.0, effectiveAlignment(item2)); | - | ||||||||||||||||||||||||
1476 | spacing -= (width1 - (rect1.x() + rect1.width())) + rect2.x(); | - | ||||||||||||||||||||||||
1477 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
1478 | const QGridLayoutBox &box1 = rowData->boxes.at(prevRow); | - | ||||||||||||||||||||||||
1479 | const QGridLayoutBox &box2 = rowData->boxes.at(row); | - | ||||||||||||||||||||||||
1480 | qreal height1 = box1.q_minimumSize; | - | ||||||||||||||||||||||||
1481 | qreal height2 = box2.q_minimumSize; | - | ||||||||||||||||||||||||
1482 | qreal rowDescent1 = fixedDescent(box1.q_minimumDescent, | - | ||||||||||||||||||||||||
1483 | box1.q_minimumAscent, height1); | - | ||||||||||||||||||||||||
1484 | qreal rowDescent2 = fixedDescent(box2.q_minimumDescent, | - | ||||||||||||||||||||||||
1485 | box2.q_minimumAscent, height2); | - | ||||||||||||||||||||||||
1486 | QRectF rect1 = item1->geometryWithin(0.0, 0.0, FLT_MAX, height1, | - | ||||||||||||||||||||||||
1487 | rowDescent1, effectiveAlignment(item1)); | - | ||||||||||||||||||||||||
1488 | QRectF rect2 = item2->geometryWithin(0.0, 0.0, FLT_MAX, height2, | - | ||||||||||||||||||||||||
1489 | rowDescent2, effectiveAlignment(item2)); | - | ||||||||||||||||||||||||
1490 | spacing -= (height1 - (rect1.y() + rect1.height())) + rect2.y(); | - | ||||||||||||||||||||||||
1491 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1492 | rowSpacing = qMax(spacing, rowSpacing); | - | ||||||||||||||||||||||||
1493 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1494 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1495 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1496 | prevRow = row; | - | ||||||||||||||||||||||||
1497 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1498 | } else if (lastRowIsButtonBox || lastTwoRowsIsButtonBox) { never executed: end of block
| 0 | ||||||||||||||||||||||||
1499 | /* | - | ||||||||||||||||||||||||
1500 | Even for styles that define a uniform spacing, we cheat a | - | ||||||||||||||||||||||||
1501 | bit and use the window margin as the spacing. This | - | ||||||||||||||||||||||||
1502 | significantly improves the look of dialogs. | - | ||||||||||||||||||||||||
1503 | */ | - | ||||||||||||||||||||||||
1504 | int prevRow = lastRowIsButtonBox ? nextToLastRowAdHocData.q_row
| 0 | ||||||||||||||||||||||||
1505 | : nextToNextToLastRowAdHocData.q_row; | - | ||||||||||||||||||||||||
1506 | if (!defaultSpacing.isUser() && !rowInfo.spacings.value(prevRow).isUser()) {
| 0 | ||||||||||||||||||||||||
1507 | qreal windowMargin = styleInfo->windowMargin(orientation); | - | ||||||||||||||||||||||||
1508 | qreal &rowSpacing = rowData->spacings[prevRow]; | - | ||||||||||||||||||||||||
1509 | rowSpacing = qMax(windowMargin, rowSpacing); | - | ||||||||||||||||||||||||
1510 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1511 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1512 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1513 | - | |||||||||||||||||||||||||
1514 | void QGridLayoutEngine::ensureEffectiveFirstAndLastRows() const | - | ||||||||||||||||||||||||
1515 | { | - | ||||||||||||||||||||||||
1516 | if (q_cachedEffectiveFirstRows[Hor] == -1 && !q_items.isEmpty()) {
| 0 | ||||||||||||||||||||||||
1517 | int rowCount = this->rowCount(); | - | ||||||||||||||||||||||||
1518 | int columnCount = this->columnCount(); | - | ||||||||||||||||||||||||
1519 | - | |||||||||||||||||||||||||
1520 | q_cachedEffectiveFirstRows[Ver] = rowCount; | - | ||||||||||||||||||||||||
1521 | q_cachedEffectiveFirstRows[Hor] = columnCount; | - | ||||||||||||||||||||||||
1522 | q_cachedEffectiveLastRows[Ver] = -1; | - | ||||||||||||||||||||||||
1523 | q_cachedEffectiveLastRows[Hor] = -1; | - | ||||||||||||||||||||||||
1524 | - | |||||||||||||||||||||||||
1525 | for (int i = q_items.count() - 1; i >= 0; --i) {
| 0 | ||||||||||||||||||||||||
1526 | const QGridLayoutItem *item = q_items.at(i); | - | ||||||||||||||||||||||||
1527 | - | |||||||||||||||||||||||||
1528 | for (int j = 0; j < NOrientations; ++j) {
| 0 | ||||||||||||||||||||||||
1529 | Qt::Orientation orientation = (j == Hor) ? Qt::Horizontal : Qt::Vertical;
| 0 | ||||||||||||||||||||||||
1530 | if (item->firstRow(orientation) < q_cachedEffectiveFirstRows[j])
| 0 | ||||||||||||||||||||||||
1531 | q_cachedEffectiveFirstRows[j] = item->firstRow(orientation); never executed: q_cachedEffectiveFirstRows[j] = item->firstRow(orientation); | 0 | ||||||||||||||||||||||||
1532 | if (item->lastRow(orientation) > q_cachedEffectiveLastRows[j])
| 0 | ||||||||||||||||||||||||
1533 | q_cachedEffectiveLastRows[j] = item->lastRow(orientation); never executed: q_cachedEffectiveLastRows[j] = item->lastRow(orientation); | 0 | ||||||||||||||||||||||||
1534 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1535 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1536 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1537 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1538 | - | |||||||||||||||||||||||||
1539 | void QGridLayoutEngine::ensureColumnAndRowData(QGridLayoutRowData *rowData, QGridLayoutBox *totalBox, | - | ||||||||||||||||||||||||
1540 | const qreal *colPositions, const qreal *colSizes, | - | ||||||||||||||||||||||||
1541 | Qt::Orientation orientation, | - | ||||||||||||||||||||||||
1542 | const QAbstractLayoutStyleInfo *styleInfo) const | - | ||||||||||||||||||||||||
1543 | { | - | ||||||||||||||||||||||||
1544 | const int o = (orientation == Qt::Vertical ? Ver : Hor);
| 0 | ||||||||||||||||||||||||
1545 | const int cc = columnCount(orientation); | - | ||||||||||||||||||||||||
1546 | - | |||||||||||||||||||||||||
1547 | const qreal constraint = (colPositions && colSizes && hasDynamicConstraint()) ? (colPositions[cc - 1] + colSizes[cc - 1]) : qreal(CachedWithNoConstraint);
| 0 | ||||||||||||||||||||||||
1548 | qreal &cachedConstraint = q_totalBoxCachedConstraints[o]; | - | ||||||||||||||||||||||||
1549 | if (cachedConstraint == constraint) {
| 0 | ||||||||||||||||||||||||
1550 | if (totalBox != &q_totalBoxes[o])
| 0 | ||||||||||||||||||||||||
1551 | *totalBox = q_totalBoxes[o]; never executed: *totalBox = q_totalBoxes[o]; | 0 | ||||||||||||||||||||||||
1552 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1553 | } | - | ||||||||||||||||||||||||
1554 | rowData->reset(rowCount(orientation)); | - | ||||||||||||||||||||||||
1555 | fillRowData(rowData, colPositions, colSizes, orientation, styleInfo); | - | ||||||||||||||||||||||||
1556 | const QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical]; | - | ||||||||||||||||||||||||
1557 | rowData->distributeMultiCells(rowInfo, m_snapToPixelGrid); | - | ||||||||||||||||||||||||
1558 | *totalBox = rowData->totalBox(0, rowCount(orientation)); | - | ||||||||||||||||||||||||
1559 | - | |||||||||||||||||||||||||
1560 | if (totalBox != &q_totalBoxes[o])
| 0 | ||||||||||||||||||||||||
1561 | q_totalBoxes[o] = *totalBox; never executed: q_totalBoxes[o] = *totalBox; | 0 | ||||||||||||||||||||||||
1562 | - | |||||||||||||||||||||||||
1563 | cachedConstraint = constraint; | - | ||||||||||||||||||||||||
1564 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1565 | - | |||||||||||||||||||||||||
1566 | /** | - | ||||||||||||||||||||||||
1567 | returns false if the layout has contradicting constraints (i.e. some items with a horizontal | - | ||||||||||||||||||||||||
1568 | constraint and other items with a vertical constraint) | - | ||||||||||||||||||||||||
1569 | */ | - | ||||||||||||||||||||||||
1570 | bool QGridLayoutEngine::ensureDynamicConstraint() const | - | ||||||||||||||||||||||||
1571 | { | - | ||||||||||||||||||||||||
1572 | if (q_cachedConstraintOrientation == UnknownConstraint) {
| 0 | ||||||||||||||||||||||||
1573 | for (int i = q_items.count() - 1; i >= 0; --i) {
| 0 | ||||||||||||||||||||||||
1574 | QGridLayoutItem *item = q_items.at(i); | - | ||||||||||||||||||||||||
1575 | if (item->hasDynamicConstraint()) {
| 0 | ||||||||||||||||||||||||
1576 | Qt::Orientation itemConstraintOrientation = item->dynamicConstraintOrientation(); | - | ||||||||||||||||||||||||
1577 | if (q_cachedConstraintOrientation == UnknownConstraint) {
| 0 | ||||||||||||||||||||||||
1578 | q_cachedConstraintOrientation = itemConstraintOrientation; | - | ||||||||||||||||||||||||
1579 | } else if (q_cachedConstraintOrientation != itemConstraintOrientation) { never executed: end of block
| 0 | ||||||||||||||||||||||||
1580 | q_cachedConstraintOrientation = UnfeasibleConstraint; | - | ||||||||||||||||||||||||
1581 | qWarning("QGridLayoutEngine: Unfeasible, cannot mix horizontal and" | - | ||||||||||||||||||||||||
1582 | " vertical constraint in the same layout"); | - | ||||||||||||||||||||||||
1583 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
1584 | } | - | ||||||||||||||||||||||||
1585 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1586 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1587 | if (q_cachedConstraintOrientation == UnknownConstraint)
| 0 | ||||||||||||||||||||||||
1588 | q_cachedConstraintOrientation = NoConstraint; never executed: q_cachedConstraintOrientation = NoConstraint; | 0 | ||||||||||||||||||||||||
1589 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1590 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
1591 | } | - | ||||||||||||||||||||||||
1592 | - | |||||||||||||||||||||||||
1593 | bool QGridLayoutEngine::hasDynamicConstraint() const | - | ||||||||||||||||||||||||
1594 | { | - | ||||||||||||||||||||||||
1595 | if (!ensureDynamicConstraint())
| 0 | ||||||||||||||||||||||||
1596 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
1597 | return q_cachedConstraintOrientation != NoConstraint; never executed: return q_cachedConstraintOrientation != NoConstraint; | 0 | ||||||||||||||||||||||||
1598 | } | - | ||||||||||||||||||||||||
1599 | - | |||||||||||||||||||||||||
1600 | /* | - | ||||||||||||||||||||||||
1601 | * return value is only valid if hasConstraint() returns \c true | - | ||||||||||||||||||||||||
1602 | */ | - | ||||||||||||||||||||||||
1603 | Qt::Orientation QGridLayoutEngine::constraintOrientation() const | - | ||||||||||||||||||||||||
1604 | { | - | ||||||||||||||||||||||||
1605 | (void)ensureDynamicConstraint(); | - | ||||||||||||||||||||||||
1606 | return (Qt::Orientation)q_cachedConstraintOrientation; never executed: return (Qt::Orientation)q_cachedConstraintOrientation; | 0 | ||||||||||||||||||||||||
1607 | } | - | ||||||||||||||||||||||||
1608 | - | |||||||||||||||||||||||||
1609 | void QGridLayoutEngine::ensureGeometries(const QSizeF &size, | - | ||||||||||||||||||||||||
1610 | const QAbstractLayoutStyleInfo *styleInfo) const | - | ||||||||||||||||||||||||
1611 | { | - | ||||||||||||||||||||||||
1612 | if (q_cachedSize == size)
| 0 | ||||||||||||||||||||||||
1613 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1614 | - | |||||||||||||||||||||||||
1615 | q_cachedSize = size; | - | ||||||||||||||||||||||||
1616 | - | |||||||||||||||||||||||||
1617 | q_xx.resize(columnCount()); | - | ||||||||||||||||||||||||
1618 | q_widths.resize(columnCount()); | - | ||||||||||||||||||||||||
1619 | q_yy.resize(rowCount()); | - | ||||||||||||||||||||||||
1620 | q_heights.resize(rowCount()); | - | ||||||||||||||||||||||||
1621 | q_descents.resize(rowCount()); | - | ||||||||||||||||||||||||
1622 | - | |||||||||||||||||||||||||
1623 | if (constraintOrientation() != Qt::Horizontal) {
| 0 | ||||||||||||||||||||||||
1624 | //We might have items whose height depends on their width (HFW) | - | ||||||||||||||||||||||||
1625 | ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], NULL, NULL, Qt::Horizontal, styleInfo); | - | ||||||||||||||||||||||||
1626 | //Calculate column widths and positions, and put results in q_xx.data() and q_widths.data() so that we can use this information as | - | ||||||||||||||||||||||||
1627 | //constraints to find the row heights | - | ||||||||||||||||||||||||
1628 | q_columnData.calculateGeometries(0, columnCount(), size.width(), q_xx.data(), q_widths.data(), | - | ||||||||||||||||||||||||
1629 | 0, q_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); | - | ||||||||||||||||||||||||
1630 | ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], q_xx.data(), q_widths.data(), Qt::Vertical, styleInfo); | - | ||||||||||||||||||||||||
1631 | //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() | - | ||||||||||||||||||||||||
1632 | q_rowData.calculateGeometries(0, rowCount(), size.height(), q_yy.data(), q_heights.data(), | - | ||||||||||||||||||||||||
1633 | q_descents.data(), q_totalBoxes[Ver], q_infos[Ver], m_snapToPixelGrid); | - | ||||||||||||||||||||||||
1634 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
1635 | //We have items whose width depends on their height (WFH) | - | ||||||||||||||||||||||||
1636 | ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], NULL, NULL, Qt::Vertical, styleInfo); | - | ||||||||||||||||||||||||
1637 | //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() so that we can use this information as | - | ||||||||||||||||||||||||
1638 | //constraints to find the column widths | - | ||||||||||||||||||||||||
1639 | q_rowData.calculateGeometries(0, rowCount(), size.height(), q_yy.data(), q_heights.data(), | - | ||||||||||||||||||||||||
1640 | q_descents.data(), q_totalBoxes[Ver], q_infos[Ver], m_snapToPixelGrid); | - | ||||||||||||||||||||||||
1641 | ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], q_yy.data(), q_heights.data(), Qt::Horizontal, styleInfo); | - | ||||||||||||||||||||||||
1642 | //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() | - | ||||||||||||||||||||||||
1643 | q_columnData.calculateGeometries(0, columnCount(), size.width(), q_xx.data(), q_widths.data(), | - | ||||||||||||||||||||||||
1644 | 0, q_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); | - | ||||||||||||||||||||||||
1645 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1646 | } | - | ||||||||||||||||||||||||
1647 | - | |||||||||||||||||||||||||
1648 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
Source code | Switch to Preprocessed file |