| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/util/qgridlayoutengine.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | template <typename T> | - | ||||||||||||||||||||||||
| 7 | static void insertOrRemoveItems(QVector<T> &items, int index, int delta) | - | ||||||||||||||||||||||||
| 8 | { | - | ||||||||||||||||||||||||
| 9 | int count = items.count(); | - | ||||||||||||||||||||||||
| 10 | if (index < count
| 0 | ||||||||||||||||||||||||
| 11 | if (delta > 0
| 0 | ||||||||||||||||||||||||
| 12 | items.insert(index, delta, T()); | - | ||||||||||||||||||||||||
| 13 | } never executed: else if (delta < 0end of block
| 0 | ||||||||||||||||||||||||
| 14 | items.remove(index, qMin(-delta, count - index)); | - | ||||||||||||||||||||||||
| 15 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 16 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 17 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 18 | - | |||||||||||||||||||||||||
| 19 | static qreal growthFactorBelowPreferredSize(qreal desired, qreal sumAvailable, qreal sumDesired) | - | ||||||||||||||||||||||||
| 20 | { | - | ||||||||||||||||||||||||
| 21 | ((!(sumDesired != 0.0)) ? qt_assert("sumDesired != 0.0",__FILE__,59) : qt_noop()); | - | ||||||||||||||||||||||||
| 22 | return never executed: desired * qPow(sumAvailable / sumDesired, desired / sumDesired);return desired * qPow(sumAvailable / sumDesired, desired / sumDesired);never executed: return desired * qPow(sumAvailable / sumDesired, desired / sumDesired); | 0 | ||||||||||||||||||||||||
| 23 | } | - | ||||||||||||||||||||||||
| 24 | - | |||||||||||||||||||||||||
| 25 | static qreal fixedDescent(qreal descent, qreal ascent, qreal targetSize) | - | ||||||||||||||||||||||||
| 26 | { | - | ||||||||||||||||||||||||
| 27 | if (descent < 0.0
| 0 | ||||||||||||||||||||||||
| 28 | return never executed: -1.0;return -1.0;never executed: return -1.0; | 0 | ||||||||||||||||||||||||
| 29 | - | |||||||||||||||||||||||||
| 30 | ((!(descent >= 0.0)) ? qt_assert("descent >= 0.0",__FILE__,68) : qt_noop()); | - | ||||||||||||||||||||||||
| 31 | ((!(ascent >= 0.0)) ? qt_assert("ascent >= 0.0",__FILE__,69) : qt_noop()); | - | ||||||||||||||||||||||||
| 32 | ((!(targetSize >= ascent + descent)) ? qt_assert("targetSize >= ascent + descent",__FILE__,70) : qt_noop()); | - | ||||||||||||||||||||||||
| 33 | - | |||||||||||||||||||||||||
| 34 | qreal extra = targetSize - (ascent + descent); | - | ||||||||||||||||||||||||
| 35 | return never executed: descent + (extra / 2.0);return descent + (extra / 2.0);never executed: return descent + (extra / 2.0); | 0 | ||||||||||||||||||||||||
| 36 | } | - | ||||||||||||||||||||||||
| 37 | - | |||||||||||||||||||||||||
| 38 | static qreal compare(const QGridLayoutBox &box1, const QGridLayoutBox &box2, int which) | - | ||||||||||||||||||||||||
| 39 | { | - | ||||||||||||||||||||||||
| 40 | qreal size1 = box1.q_sizes(which); | - | ||||||||||||||||||||||||
| 41 | qreal size2 = box2.q_sizes(which); | - | ||||||||||||||||||||||||
| 42 | - | |||||||||||||||||||||||||
| 43 | if (which == MaximumSize
| 0 | ||||||||||||||||||||||||
| 44 | return never executed: size2 - size1;return size2 - size1;never executed: return size2 - size1; | 0 | ||||||||||||||||||||||||
| 45 | } else { | - | ||||||||||||||||||||||||
| 46 | return never executed: size1 - size2;return size1 - size2;never executed: return size1 - size2; | 0 | ||||||||||||||||||||||||
| 47 | } | - | ||||||||||||||||||||||||
| 48 | } | - | ||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||
| 50 | void QGridLayoutBox::add(const QGridLayoutBox &other, int stretch, qreal spacing) | - | ||||||||||||||||||||||||
| 51 | { | - | ||||||||||||||||||||||||
| 52 | ((!(q_minimumDescent < 0.0)) ? qt_assert("q_minimumDescent < 0.0",__FILE__,90) : qt_noop()); | - | ||||||||||||||||||||||||
| 53 | - | |||||||||||||||||||||||||
| 54 | q_minimumSize += other.q_minimumSize + spacing; | - | ||||||||||||||||||||||||
| 55 | q_preferredSize += other.q_preferredSize + spacing; | - | ||||||||||||||||||||||||
| 56 | q_maximumSize += ((
| 0 | ||||||||||||||||||||||||
| 57 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 58 | - | |||||||||||||||||||||||||
| 59 | void QGridLayoutBox::combine(const QGridLayoutBox &other) | - | ||||||||||||||||||||||||
| 60 | { | - | ||||||||||||||||||||||||
| 61 | q_minimumDescent = qMax(q_minimumDescent, other.q_minimumDescent); | - | ||||||||||||||||||||||||
| 62 | q_minimumAscent = qMax(q_minimumAscent, other.q_minimumAscent); | - | ||||||||||||||||||||||||
| 63 | - | |||||||||||||||||||||||||
| 64 | q_minimumSize = qMax(q_minimumAscent + q_minimumDescent, | - | ||||||||||||||||||||||||
| 65 | qMax(q_minimumSize, other.q_minimumSize)); | - | ||||||||||||||||||||||||
| 66 | qreal maxMax; | - | ||||||||||||||||||||||||
| 67 | if (q_maximumSize == 3.40282346638528859812e+38F
| 0 | ||||||||||||||||||||||||
| 68 | maxMax = other.q_maximumSize; never executed: maxMax = other.q_maximumSize; | 0 | ||||||||||||||||||||||||
| 69 | else if (other.q_maximumSize == 3.40282346638528859812e+38F
| 0 | ||||||||||||||||||||||||
| 70 | maxMax = q_maximumSize; never executed: maxMax = q_maximumSize; | 0 | ||||||||||||||||||||||||
| 71 | else | - | ||||||||||||||||||||||||
| 72 | maxMax = qMax(q_maximumSize, other.q_maximumSize); never executed: maxMax = qMax(q_maximumSize, other.q_maximumSize); | 0 | ||||||||||||||||||||||||
| 73 | - | |||||||||||||||||||||||||
| 74 | q_maximumSize = qMax(q_minimumSize, maxMax); | - | ||||||||||||||||||||||||
| 75 | q_preferredSize = qBound(q_minimumSize, qMax(q_preferredSize, other.q_preferredSize), | - | ||||||||||||||||||||||||
| 76 | q_maximumSize); | - | ||||||||||||||||||||||||
| 77 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 78 | - | |||||||||||||||||||||||||
| 79 | void QGridLayoutBox::normalize() | - | ||||||||||||||||||||||||
| 80 | { | - | ||||||||||||||||||||||||
| 81 | q_maximumSize = qMax(qreal(0.0), q_maximumSize); | - | ||||||||||||||||||||||||
| 82 | q_minimumSize = qBound(qreal(0.0), q_minimumSize, q_maximumSize); | - | ||||||||||||||||||||||||
| 83 | q_preferredSize = qBound(q_minimumSize, q_preferredSize, q_maximumSize); | - | ||||||||||||||||||||||||
| 84 | q_minimumDescent = qMin(q_minimumDescent, q_minimumSize); | - | ||||||||||||||||||||||||
| 85 | - | |||||||||||||||||||||||||
| 86 | ((!((q_minimumDescent < 0.0) == (q_minimumAscent < 0.0))) ? qt_assert("(q_minimumDescent < 0.0) == (q_minimumAscent < 0.0)",__FILE__,124) : qt_noop()); | - | ||||||||||||||||||||||||
| 87 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 88 | bool operator==(const QGridLayoutBox &box1, const QGridLayoutBox &box2) | - | ||||||||||||||||||||||||
| 89 | { | - | ||||||||||||||||||||||||
| 90 | for (int i = 0; i < NSizes
| 0 | ||||||||||||||||||||||||
| 91 | if (box1.q_sizes(i) != box2.q_sizes(i)
| 0 | ||||||||||||||||||||||||
| 92 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 93 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 94 | return never executed: box1.q_minimumDescent == box2.q_minimumDescentreturn box1.q_minimumDescent == box2.q_minimumDescent && box1.q_minimumAscent == box2.q_minimumAscent;
never executed: return box1.q_minimumDescent == box2.q_minimumDescent && box1.q_minimumAscent == box2.q_minimumAscent; | 0 | ||||||||||||||||||||||||
| 95 | && box1.q_minimumAscent == box2.q_minimumAscent
never executed: return box1.q_minimumDescent == box2.q_minimumDescent && box1.q_minimumAscent == box2.q_minimumAscent; | 0 | ||||||||||||||||||||||||
| 96 | } | - | ||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||
| 98 | void QGridLayoutRowData::reset(int count) | - | ||||||||||||||||||||||||
| 99 | { | - | ||||||||||||||||||||||||
| 100 | ignore.fill(false, count); | - | ||||||||||||||||||||||||
| 101 | boxes.fill(QGridLayoutBox(), count); | - | ||||||||||||||||||||||||
| 102 | multiCellMap.clear(); | - | ||||||||||||||||||||||||
| 103 | stretches.fill(0, count); | - | ||||||||||||||||||||||||
| 104 | spacings.fill(0.0, count); | - | ||||||||||||||||||||||||
| 105 | hasIgnoreFlag = false; | - | ||||||||||||||||||||||||
| 106 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 107 | - | |||||||||||||||||||||||||
| 108 | void QGridLayoutRowData::distributeMultiCells(const QGridLayoutRowInfo &rowInfo, bool snapToPixelGrid) | - | ||||||||||||||||||||||||
| 109 | { | - | ||||||||||||||||||||||||
| 110 | MultiCellMap::const_iterator i = multiCellMap.constBegin(); | - | ||||||||||||||||||||||||
| 111 | for (; i != multiCellMap.constEnd()
| 0 | ||||||||||||||||||||||||
| 112 | int start = i.key().first; | - | ||||||||||||||||||||||||
| 113 | int span = i.key().second; | - | ||||||||||||||||||||||||
| 114 | int end = start + span; | - | ||||||||||||||||||||||||
| 115 | const QGridLayoutBox &box = i.value().q_box; | - | ||||||||||||||||||||||||
| 116 | int stretch = i.value().q_stretch; | - | ||||||||||||||||||||||||
| 117 | - | |||||||||||||||||||||||||
| 118 | QGridLayoutBox totalBox = this->totalBox(start, end); | - | ||||||||||||||||||||||||
| 119 | QVarLengthArray<QGridLayoutBox> extras(span); | - | ||||||||||||||||||||||||
| 120 | QVarLengthArray<qreal> dummy(span); | - | ||||||||||||||||||||||||
| 121 | QVarLengthArray<qreal> newSizes(span); | - | ||||||||||||||||||||||||
| 122 | - | |||||||||||||||||||||||||
| 123 | for (int j = 0; j < NSizes
| 0 | ||||||||||||||||||||||||
| 124 | qreal extra = compare(box, totalBox, j); | - | ||||||||||||||||||||||||
| 125 | if (extra > 0.0
| 0 | ||||||||||||||||||||||||
| 126 | calculateGeometries(start, end, box.q_sizes(j), dummy.data(), newSizes.data(), | - | ||||||||||||||||||||||||
| 127 | 0, totalBox, rowInfo, snapToPixelGrid); | - | ||||||||||||||||||||||||
| 128 | - | |||||||||||||||||||||||||
| 129 | for (int k = 0; k < span
| 0 | ||||||||||||||||||||||||
| 130 | extras[k].q_sizes(j) = newSizes[k]; never executed: extras[k].q_sizes(j) = newSizes[k]; | 0 | ||||||||||||||||||||||||
| 131 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 132 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||
| 134 | for (int k = 0; k < span
| 0 | ||||||||||||||||||||||||
| 135 | boxes[start + k].combine(extras[k]); | - | ||||||||||||||||||||||||
| 136 | if (stretch != 0
| 0 | ||||||||||||||||||||||||
| 137 | stretches[start + k] = qMax(stretches[start + k], stretch); never executed: stretches[start + k] = qMax(stretches[start + k], stretch); | 0 | ||||||||||||||||||||||||
| 138 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 139 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 140 | multiCellMap.clear(); | - | ||||||||||||||||||||||||
| 141 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 142 | namespace { | - | ||||||||||||||||||||||||
| 143 | - | |||||||||||||||||||||||||
| 144 | - | |||||||||||||||||||||||||
| 145 | static inline qreal qround(qreal f) | - | ||||||||||||||||||||||||
| 146 | { | - | ||||||||||||||||||||||||
| 147 | return never executed: std::floor(f + qreal(0.5));return std::floor(f + qreal(0.5));never executed: return std::floor(f + qreal(0.5)); | 0 | ||||||||||||||||||||||||
| 148 | } | - | ||||||||||||||||||||||||
| 149 | - | |||||||||||||||||||||||||
| 150 | } | - | ||||||||||||||||||||||||
| 151 | void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSize, qreal *positions, | - | ||||||||||||||||||||||||
| 152 | qreal *sizes, qreal *descents, | - | ||||||||||||||||||||||||
| 153 | const QGridLayoutBox &totalBox, | - | ||||||||||||||||||||||||
| 154 | const QGridLayoutRowInfo &rowInfo, bool snapToPixelGrid) | - | ||||||||||||||||||||||||
| 155 | { | - | ||||||||||||||||||||||||
| 156 | ((!(end > start)) ? qt_assert("end > start",__FILE__,203) : qt_noop()); | - | ||||||||||||||||||||||||
| 157 | - | |||||||||||||||||||||||||
| 158 | targetSize = qMax(totalBox.q_minimumSize, targetSize); | - | ||||||||||||||||||||||||
| 159 | - | |||||||||||||||||||||||||
| 160 | int n = end - start; | - | ||||||||||||||||||||||||
| 161 | QVarLengthArray<qreal> newSizes(n); | - | ||||||||||||||||||||||||
| 162 | QVarLengthArray<qreal> factors(n); | - | ||||||||||||||||||||||||
| 163 | qreal sumFactors = 0.0; | - | ||||||||||||||||||||||||
| 164 | int sumStretches = 0; | - | ||||||||||||||||||||||||
| 165 | qreal sumAvailable; | - | ||||||||||||||||||||||||
| 166 | - | |||||||||||||||||||||||||
| 167 | for (int i = 0; i < n
| 0 | ||||||||||||||||||||||||
| 168 | if (stretches[start + i] > 0
| 0 | ||||||||||||||||||||||||
| 169 | sumStretches += stretches[start + i]; never executed: sumStretches += stretches[start + i]; | 0 | ||||||||||||||||||||||||
| 170 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 171 | - | |||||||||||||||||||||||||
| 172 | if (targetSize < totalBox.q_preferredSize
| 0 | ||||||||||||||||||||||||
| 173 | stealBox(start, end, MinimumSize, positions, sizes); | - | ||||||||||||||||||||||||
| 174 | - | |||||||||||||||||||||||||
| 175 | sumAvailable = targetSize - totalBox.q_minimumSize; | - | ||||||||||||||||||||||||
| 176 | if (sumAvailable > 0.0
| 0 | ||||||||||||||||||||||||
| 177 | qreal sumDesired = totalBox.q_preferredSize - totalBox.q_minimumSize; | - | ||||||||||||||||||||||||
| 178 | - | |||||||||||||||||||||||||
| 179 | for (int i = 0; i < n
| 0 | ||||||||||||||||||||||||
| 180 | if (ignore.testBit(start + i)
| 0 | ||||||||||||||||||||||||
| 181 | factors[i] = 0.0; | - | ||||||||||||||||||||||||
| 182 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 183 | } | - | ||||||||||||||||||||||||
| 184 | - | |||||||||||||||||||||||||
| 185 | const QGridLayoutBox &box = boxes.at(start + i); | - | ||||||||||||||||||||||||
| 186 | qreal desired = box.q_preferredSize - box.q_minimumSize; | - | ||||||||||||||||||||||||
| 187 | factors[i] = growthFactorBelowPreferredSize(desired, sumAvailable, sumDesired); | - | ||||||||||||||||||||||||
| 188 | sumFactors += factors[i]; | - | ||||||||||||||||||||||||
| 189 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 190 | - | |||||||||||||||||||||||||
| 191 | for (int i = 0; i < n
| 0 | ||||||||||||||||||||||||
| 192 | ((!(sumFactors > 0.0)) ? qt_assert("sumFactors > 0.0",__FILE__,239) : qt_noop()); | - | ||||||||||||||||||||||||
| 193 | qreal delta = sumAvailable * factors[i] / sumFactors; | - | ||||||||||||||||||||||||
| 194 | newSizes[i] = sizes[i] + delta; | - | ||||||||||||||||||||||||
| 195 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 196 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 197 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 198 | bool isLargerThanMaximum = (targetSize > totalBox.q_maximumSize); | - | ||||||||||||||||||||||||
| 199 | if (isLargerThanMaximum
| 0 | ||||||||||||||||||||||||
| 200 | stealBox(start, end, MaximumSize, positions, sizes); | - | ||||||||||||||||||||||||
| 201 | sumAvailable = targetSize - totalBox.q_maximumSize; | - | ||||||||||||||||||||||||
| 202 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 203 | stealBox(start, end, PreferredSize, positions, sizes); | - | ||||||||||||||||||||||||
| 204 | sumAvailable = targetSize - totalBox.q_preferredSize; | - | ||||||||||||||||||||||||
| 205 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 206 | - | |||||||||||||||||||||||||
| 207 | if (sumAvailable > 0.0
| 0 | ||||||||||||||||||||||||
| 208 | qreal sumCurrentAvailable = sumAvailable; | - | ||||||||||||||||||||||||
| 209 | bool somethingHasAMaximumSize = false; | - | ||||||||||||||||||||||||
| 210 | - | |||||||||||||||||||||||||
| 211 | qreal sumSizes = 0.0; | - | ||||||||||||||||||||||||
| 212 | for (int i = 0; i < n
| 0 | ||||||||||||||||||||||||
| 213 | sumSizes += sizes[i]; never executed: sumSizes += sizes[i]; | 0 | ||||||||||||||||||||||||
| 214 | - | |||||||||||||||||||||||||
| 215 | for (int i = 0; i < n
| 0 | ||||||||||||||||||||||||
| 216 | if (ignore.testBit(start + i)
| 0 | ||||||||||||||||||||||||
| 217 | newSizes[i] = 0.0; | - | ||||||||||||||||||||||||
| 218 | factors[i] = 0.0; | - | ||||||||||||||||||||||||
| 219 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 220 | } | - | ||||||||||||||||||||||||
| 221 | - | |||||||||||||||||||||||||
| 222 | const QGridLayoutBox &box = boxes.at(start + i); | - | ||||||||||||||||||||||||
| 223 | qreal boxSize; | - | ||||||||||||||||||||||||
| 224 | - | |||||||||||||||||||||||||
| 225 | qreal desired; | - | ||||||||||||||||||||||||
| 226 | if (isLargerThanMaximum
| 0 | ||||||||||||||||||||||||
| 227 | boxSize = box.q_maximumSize; | - | ||||||||||||||||||||||||
| 228 | desired = rowInfo.boxes.value(start + i).q_maximumSize - boxSize; | - | ||||||||||||||||||||||||
| 229 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 230 | boxSize = box.q_preferredSize; | - | ||||||||||||||||||||||||
| 231 | desired = box.q_maximumSize - boxSize; | - | ||||||||||||||||||||||||
| 232 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 233 | if (desired == 0.0
| 0 | ||||||||||||||||||||||||
| 234 | newSizes[i] = sizes[i]; | - | ||||||||||||||||||||||||
| 235 | factors[i] = 0.0; | - | ||||||||||||||||||||||||
| 236 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 237 | ((!(desired > 0.0)) ? qt_assert("desired > 0.0",__FILE__,284) : qt_noop()); | - | ||||||||||||||||||||||||
| 238 | - | |||||||||||||||||||||||||
| 239 | int stretch = stretches[start + i]; | - | ||||||||||||||||||||||||
| 240 | if (sumStretches == 0
| 0 | ||||||||||||||||||||||||
| 241 | if (hasIgnoreFlag
| 0 | ||||||||||||||||||||||||
| 242 | factors[i] = (
| 0 | ||||||||||||||||||||||||
| 243 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 244 | factors[i] = (
| 0 | ||||||||||||||||||||||||
| 245 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 246 | } else if (stretch == sumStretches
| 0 | ||||||||||||||||||||||||
| 247 | factors[i] = 1.0; | - | ||||||||||||||||||||||||
| 248 | } never executed: else if (stretch <= 0end of block
| 0 | ||||||||||||||||||||||||
| 249 | factors[i] = 0.0; | - | ||||||||||||||||||||||||
| 250 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 251 | qreal ultimateSize; | - | ||||||||||||||||||||||||
| 252 | qreal ultimateSumSizes; | - | ||||||||||||||||||||||||
| 253 | qreal x = ((stretch * sumSizes) | - | ||||||||||||||||||||||||
| 254 | - (sumStretches * boxSize)) | - | ||||||||||||||||||||||||
| 255 | / (sumStretches - stretch); | - | ||||||||||||||||||||||||
| 256 | if (x >= 0.0
| 0 | ||||||||||||||||||||||||
| 257 | ultimateSize = boxSize + x; | - | ||||||||||||||||||||||||
| 258 | ultimateSumSizes = sumSizes + x; | - | ||||||||||||||||||||||||
| 259 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 260 | ultimateSize = boxSize; | - | ||||||||||||||||||||||||
| 261 | ultimateSumSizes = (sumStretches * boxSize) | - | ||||||||||||||||||||||||
| 262 | / stretch; | - | ||||||||||||||||||||||||
| 263 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 264 | - | |||||||||||||||||||||||||
| 265 | - | |||||||||||||||||||||||||
| 266 | - | |||||||||||||||||||||||||
| 267 | - | |||||||||||||||||||||||||
| 268 | - | |||||||||||||||||||||||||
| 269 | - | |||||||||||||||||||||||||
| 270 | ultimateSize = ultimateSize * 3 / 2; | - | ||||||||||||||||||||||||
| 271 | ultimateSumSizes = ultimateSumSizes * 3 / 2; | - | ||||||||||||||||||||||||
| 272 | - | |||||||||||||||||||||||||
| 273 | qreal beta = ultimateSumSizes - sumSizes; | - | ||||||||||||||||||||||||
| 274 | if (!beta
| 0 | ||||||||||||||||||||||||
| 275 | factors[i] = 1; | - | ||||||||||||||||||||||||
| 276 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 277 | qreal alpha = qMin(sumCurrentAvailable, beta); | - | ||||||||||||||||||||||||
| 278 | qreal ultimateFactor = (stretch * ultimateSumSizes / sumStretches) | - | ||||||||||||||||||||||||
| 279 | - (boxSize); | - | ||||||||||||||||||||||||
| 280 | qreal transitionalFactor = sumCurrentAvailable * (ultimateSize - boxSize) / beta; | - | ||||||||||||||||||||||||
| 281 | - | |||||||||||||||||||||||||
| 282 | factors[i] = ((alpha * ultimateFactor) | - | ||||||||||||||||||||||||
| 283 | + ((beta - alpha) * transitionalFactor)) / beta; | - | ||||||||||||||||||||||||
| 284 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 285 | - | |||||||||||||||||||||||||
| 286 | } | - | ||||||||||||||||||||||||
| 287 | sumFactors += factors[i]; | - | ||||||||||||||||||||||||
| 288 | if (desired < sumCurrentAvailable
| 0 | ||||||||||||||||||||||||
| 289 | somethingHasAMaximumSize = true; never executed: somethingHasAMaximumSize = true; | 0 | ||||||||||||||||||||||||
| 290 | - | |||||||||||||||||||||||||
| 291 | newSizes[i] = -1.0; | - | ||||||||||||||||||||||||
| 292 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 293 | } | - | ||||||||||||||||||||||||
| 294 | - | |||||||||||||||||||||||||
| 295 | bool keepGoing = somethingHasAMaximumSize; | - | ||||||||||||||||||||||||
| 296 | while (keepGoing
| 0 | ||||||||||||||||||||||||
| 297 | - | |||||||||||||||||||||||||
| 298 | keepGoing = false; | - | ||||||||||||||||||||||||
| 299 | - | |||||||||||||||||||||||||
| 300 | for (int i = 0; i < n
| 0 | ||||||||||||||||||||||||
| 301 | if (newSizes[i] >= 0.0
| 0 | ||||||||||||||||||||||||
| 302 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 303 | - | |||||||||||||||||||||||||
| 304 | const QVector<QGridLayoutBox> &rBoxes = isLargerThanMaximum
| 0 | ||||||||||||||||||||||||
| 305 | const QGridLayoutBox &box = rBoxes.value(start + i); | - | ||||||||||||||||||||||||
| 306 | qreal maxBoxSize = box.q_maximumSize; | - | ||||||||||||||||||||||||
| 307 | - | |||||||||||||||||||||||||
| 308 | if (snapToPixelGrid
| 0 | ||||||||||||||||||||||||
| 309 | maxBoxSize = qMax(box.q_minimumSize, std::floor(maxBoxSize)); never executed: maxBoxSize = qMax(box.q_minimumSize, std::floor(maxBoxSize)); | 0 | ||||||||||||||||||||||||
| 310 | - | |||||||||||||||||||||||||
| 311 | qreal avail = sumCurrentAvailable * factors[i] / sumFactors; | - | ||||||||||||||||||||||||
| 312 | if (sizes[i] + avail >= maxBoxSize
| 0 | ||||||||||||||||||||||||
| 313 | newSizes[i] = maxBoxSize; | - | ||||||||||||||||||||||||
| 314 | sumCurrentAvailable -= maxBoxSize - sizes[i]; | - | ||||||||||||||||||||||||
| 315 | sumFactors -= factors[i]; | - | ||||||||||||||||||||||||
| 316 | keepGoing = (sumCurrentAvailable > 0.0); | - | ||||||||||||||||||||||||
| 317 | if (!keepGoing
| 0 | ||||||||||||||||||||||||
| 318 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 319 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 320 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 321 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 322 | for (int i = 0; i < n
| 0 | ||||||||||||||||||||||||
| 323 | if (newSizes[i] < 0.0
| 0 | ||||||||||||||||||||||||
| 324 | qreal delta = (
| 0 | ||||||||||||||||||||||||
| 325 | : sumCurrentAvailable * factors[i] / sumFactors; | - | ||||||||||||||||||||||||
| 326 | newSizes[i] = sizes[i] + delta; | - | ||||||||||||||||||||||||
| 327 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 328 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 329 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 330 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 331 | - | |||||||||||||||||||||||||
| 332 | if (sumAvailable > 0
| 0 | ||||||||||||||||||||||||
| 333 | qreal offset = 0; | - | ||||||||||||||||||||||||
| 334 | for (int i = 0; i < n
| 0 | ||||||||||||||||||||||||
| 335 | qreal delta = newSizes[i] - sizes[i]; | - | ||||||||||||||||||||||||
| 336 | positions[i] += offset; | - | ||||||||||||||||||||||||
| 337 | sizes[i] += delta; | - | ||||||||||||||||||||||||
| 338 | offset += delta; | - | ||||||||||||||||||||||||
| 339 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 340 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 341 | if (snapToPixelGrid
| 0 | ||||||||||||||||||||||||
| 342 | for (int i = 0; i < n
| 0 | ||||||||||||||||||||||||
| 343 | positions[i] = qround(positions[i]); never executed: positions[i] = qround(positions[i]); | 0 | ||||||||||||||||||||||||
| 344 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 345 | - | |||||||||||||||||||||||||
| 346 | if (descents
| 0 | ||||||||||||||||||||||||
| 347 | for (int i = 0; i < n
| 0 | ||||||||||||||||||||||||
| 348 | if (ignore.testBit(start + i)
| 0 | ||||||||||||||||||||||||
| 349 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 350 | const QGridLayoutBox &box = boxes.at(start + i); | - | ||||||||||||||||||||||||
| 351 | descents[i] = fixedDescent(box.q_minimumDescent, box.q_minimumAscent, sizes[i]); | - | ||||||||||||||||||||||||
| 352 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 353 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 354 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 355 | - | |||||||||||||||||||||||||
| 356 | QGridLayoutBox QGridLayoutRowData::totalBox(int start, int end) const | - | ||||||||||||||||||||||||
| 357 | { | - | ||||||||||||||||||||||||
| 358 | QGridLayoutBox result; | - | ||||||||||||||||||||||||
| 359 | if (start < end
| 0 | ||||||||||||||||||||||||
| 360 | result.q_maximumSize = 0.0; | - | ||||||||||||||||||||||||
| 361 | qreal nextSpacing = 0.0; | - | ||||||||||||||||||||||||
| 362 | for (int i = start; i < end
| 0 | ||||||||||||||||||||||||
| 363 | if (ignore.testBit(i)
| 0 | ||||||||||||||||||||||||
| 364 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 365 | result.add(boxes.at(i), stretches.at(i), nextSpacing); | - | ||||||||||||||||||||||||
| 366 | nextSpacing = spacings.at(i); | - | ||||||||||||||||||||||||
| 367 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 368 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 369 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||||||||
| 370 | } | - | ||||||||||||||||||||||||
| 371 | - | |||||||||||||||||||||||||
| 372 | void QGridLayoutRowData::stealBox(int start, int end, int which, qreal *positions, qreal *sizes) | - | ||||||||||||||||||||||||
| 373 | { | - | ||||||||||||||||||||||||
| 374 | qreal offset = 0.0; | - | ||||||||||||||||||||||||
| 375 | qreal nextSpacing = 0.0; | - | ||||||||||||||||||||||||
| 376 | - | |||||||||||||||||||||||||
| 377 | for (int i = start; i < end
| 0 | ||||||||||||||||||||||||
| 378 | qreal avail = 0.0; | - | ||||||||||||||||||||||||
| 379 | - | |||||||||||||||||||||||||
| 380 | if (!ignore.testBit(i)
| 0 | ||||||||||||||||||||||||
| 381 | const QGridLayoutBox &box = boxes.at(i); | - | ||||||||||||||||||||||||
| 382 | avail = box.q_sizes(which); | - | ||||||||||||||||||||||||
| 383 | offset += nextSpacing; | - | ||||||||||||||||||||||||
| 384 | nextSpacing = spacings.at(i); | - | ||||||||||||||||||||||||
| 385 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 386 | - | |||||||||||||||||||||||||
| 387 | *positions++ = offset; | - | ||||||||||||||||||||||||
| 388 | *sizes++ = avail; | - | ||||||||||||||||||||||||
| 389 | offset += avail; | - | ||||||||||||||||||||||||
| 390 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 391 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 392 | QGridLayoutItem::QGridLayoutItem(int row, int column, int rowSpan, int columnSpan, | - | ||||||||||||||||||||||||
| 393 | Qt::Alignment alignment) | - | ||||||||||||||||||||||||
| 394 | : q_alignment(alignment) | - | ||||||||||||||||||||||||
| 395 | { | - | ||||||||||||||||||||||||
| 396 | q_firstRows[Hor] = column; | - | ||||||||||||||||||||||||
| 397 | q_firstRows[Ver] = row; | - | ||||||||||||||||||||||||
| 398 | q_rowSpans[Hor] = columnSpan; | - | ||||||||||||||||||||||||
| 399 | q_rowSpans[Ver] = rowSpan; | - | ||||||||||||||||||||||||
| 400 | q_stretches[Hor] = -1; | - | ||||||||||||||||||||||||
| 401 | q_stretches[Ver] = -1; | - | ||||||||||||||||||||||||
| 402 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 403 | - | |||||||||||||||||||||||||
| 404 | int QGridLayoutItem::firstRow(Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
| 405 | { | - | ||||||||||||||||||||||||
| 406 | return never executed: q_firstRows[orientation == Qt::Vertical];return q_firstRows[orientation == Qt::Vertical];never executed: return q_firstRows[orientation == Qt::Vertical]; | 0 | ||||||||||||||||||||||||
| 407 | } | - | ||||||||||||||||||||||||
| 408 | - | |||||||||||||||||||||||||
| 409 | int QGridLayoutItem::firstColumn(Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
| 410 | { | - | ||||||||||||||||||||||||
| 411 | return never executed: q_firstRows[orientation == Qt::Horizontal];return q_firstRows[orientation == Qt::Horizontal];never executed: return q_firstRows[orientation == Qt::Horizontal]; | 0 | ||||||||||||||||||||||||
| 412 | } | - | ||||||||||||||||||||||||
| 413 | - | |||||||||||||||||||||||||
| 414 | int QGridLayoutItem::lastRow(Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
| 415 | { | - | ||||||||||||||||||||||||
| 416 | return never executed: firstRow(orientation) + rowSpan(orientation) - 1;return firstRow(orientation) + rowSpan(orientation) - 1;never executed: return firstRow(orientation) + rowSpan(orientation) - 1; | 0 | ||||||||||||||||||||||||
| 417 | } | - | ||||||||||||||||||||||||
| 418 | - | |||||||||||||||||||||||||
| 419 | int QGridLayoutItem::lastColumn(Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
| 420 | { | - | ||||||||||||||||||||||||
| 421 | return never executed: firstColumn(orientation) + columnSpan(orientation) - 1;return firstColumn(orientation) + columnSpan(orientation) - 1;never executed: return firstColumn(orientation) + columnSpan(orientation) - 1; | 0 | ||||||||||||||||||||||||
| 422 | } | - | ||||||||||||||||||||||||
| 423 | - | |||||||||||||||||||||||||
| 424 | int QGridLayoutItem::rowSpan(Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
| 425 | { | - | ||||||||||||||||||||||||
| 426 | return never executed: q_rowSpans[orientation == Qt::Vertical];return q_rowSpans[orientation == Qt::Vertical];never executed: return q_rowSpans[orientation == Qt::Vertical]; | 0 | ||||||||||||||||||||||||
| 427 | } | - | ||||||||||||||||||||||||
| 428 | - | |||||||||||||||||||||||||
| 429 | int QGridLayoutItem::columnSpan(Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
| 430 | { | - | ||||||||||||||||||||||||
| 431 | return never executed: q_rowSpans[orientation == Qt::Horizontal];return q_rowSpans[orientation == Qt::Horizontal];never executed: return q_rowSpans[orientation == Qt::Horizontal]; | 0 | ||||||||||||||||||||||||
| 432 | } | - | ||||||||||||||||||||||||
| 433 | - | |||||||||||||||||||||||||
| 434 | void QGridLayoutItem::setFirstRow(int row, Qt::Orientation orientation) | - | ||||||||||||||||||||||||
| 435 | { | - | ||||||||||||||||||||||||
| 436 | q_firstRows[orientation == Qt::Vertical] = row; | - | ||||||||||||||||||||||||
| 437 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 438 | - | |||||||||||||||||||||||||
| 439 | void QGridLayoutItem::setRowSpan(int rowSpan, Qt::Orientation orientation) | - | ||||||||||||||||||||||||
| 440 | { | - | ||||||||||||||||||||||||
| 441 | q_rowSpans[orientation == Qt::Vertical] = rowSpan; | - | ||||||||||||||||||||||||
| 442 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 443 | - | |||||||||||||||||||||||||
| 444 | int QGridLayoutItem::stretchFactor(Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
| 445 | { | - | ||||||||||||||||||||||||
| 446 | int stretch = q_stretches[orientation == Qt::Vertical]; | - | ||||||||||||||||||||||||
| 447 | if (stretch >= 0
| 0 | ||||||||||||||||||||||||
| 448 | return never executed: stretch;return stretch;never executed: return stretch; | 0 | ||||||||||||||||||||||||
| 449 | - | |||||||||||||||||||||||||
| 450 | QLayoutPolicy::Policy policy = sizePolicy(orientation); | - | ||||||||||||||||||||||||
| 451 | - | |||||||||||||||||||||||||
| 452 | if (policy & QLayoutPolicy::ExpandFlag
| 0 | ||||||||||||||||||||||||
| 453 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 454 | } else if (policy & QLayoutPolicy::GrowFlag
| 0 | ||||||||||||||||||||||||
| 455 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 456 | } else { | - | ||||||||||||||||||||||||
| 457 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 458 | } | - | ||||||||||||||||||||||||
| 459 | } | - | ||||||||||||||||||||||||
| 460 | - | |||||||||||||||||||||||||
| 461 | void QGridLayoutItem::setStretchFactor(int stretch, Qt::Orientation orientation) | - | ||||||||||||||||||||||||
| 462 | { | - | ||||||||||||||||||||||||
| 463 | ((!(stretch >= 0)) ? qt_assert("stretch >= 0",__FILE__,557) : qt_noop()); | - | ||||||||||||||||||||||||
| 464 | q_stretches[orientation == Qt::Vertical] = stretch; | - | ||||||||||||||||||||||||
| 465 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 466 | - | |||||||||||||||||||||||||
| 467 | QLayoutPolicy::ControlTypes QGridLayoutItem::controlTypes(LayoutSide ) const | - | ||||||||||||||||||||||||
| 468 | { | - | ||||||||||||||||||||||||
| 469 | return never executed: QLayoutPolicy::DefaultType;return QLayoutPolicy::DefaultType;never executed: return QLayoutPolicy::DefaultType; | 0 | ||||||||||||||||||||||||
| 470 | } | - | ||||||||||||||||||||||||
| 471 | - | |||||||||||||||||||||||||
| 472 | QGridLayoutBox QGridLayoutItem::box(Qt::Orientation orientation, qreal constraint) const | - | ||||||||||||||||||||||||
| 473 | { | - | ||||||||||||||||||||||||
| 474 | QGridLayoutBox result; | - | ||||||||||||||||||||||||
| 475 | QLayoutPolicy::Policy policy = sizePolicy(orientation); | - | ||||||||||||||||||||||||
| 476 | - | |||||||||||||||||||||||||
| 477 | if (orientation == Qt::Horizontal
| 0 | ||||||||||||||||||||||||
| 478 | QSizeF constraintSize(-1.0, constraint); | - | ||||||||||||||||||||||||
| 479 | - | |||||||||||||||||||||||||
| 480 | result.q_preferredSize = sizeHint(Qt::PreferredSize, constraintSize).width(); | - | ||||||||||||||||||||||||
| 481 | - | |||||||||||||||||||||||||
| 482 | if (policy & QLayoutPolicy::ShrinkFlag
| 0 | ||||||||||||||||||||||||
| 483 | result.q_minimumSize = sizeHint(Qt::MinimumSize, constraintSize).width(); | - | ||||||||||||||||||||||||
| 484 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 485 | result.q_minimumSize = result.q_preferredSize; | - | ||||||||||||||||||||||||
| 486 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 487 | - | |||||||||||||||||||||||||
| 488 | if (policy & (QLayoutPolicy::GrowFlag | QLayoutPolicy::ExpandFlag)
| 0 | ||||||||||||||||||||||||
| 489 | result.q_maximumSize = sizeHint(Qt::MaximumSize, constraintSize).width(); | - | ||||||||||||||||||||||||
| 490 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 491 | result.q_maximumSize = result.q_preferredSize; | - | ||||||||||||||||||||||||
| 492 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 493 | } else { | - | ||||||||||||||||||||||||
| 494 | QSizeF constraintSize(constraint, -1.0); | - | ||||||||||||||||||||||||
| 495 | - | |||||||||||||||||||||||||
| 496 | result.q_preferredSize = sizeHint(Qt::PreferredSize, constraintSize).height(); | - | ||||||||||||||||||||||||
| 497 | - | |||||||||||||||||||||||||
| 498 | if (policy & QLayoutPolicy::ShrinkFlag
| 0 | ||||||||||||||||||||||||
| 499 | result.q_minimumSize = sizeHint(Qt::MinimumSize, constraintSize).height(); | - | ||||||||||||||||||||||||
| 500 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 501 | result.q_minimumSize = result.q_preferredSize; | - | ||||||||||||||||||||||||
| 502 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 503 | - | |||||||||||||||||||||||||
| 504 | if (policy & (QLayoutPolicy::GrowFlag | QLayoutPolicy::ExpandFlag)
| 0 | ||||||||||||||||||||||||
| 505 | result.q_maximumSize = sizeHint(Qt::MaximumSize, constraintSize).height(); | - | ||||||||||||||||||||||||
| 506 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 507 | result.q_maximumSize = result.q_preferredSize; | - | ||||||||||||||||||||||||
| 508 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 509 | - | |||||||||||||||||||||||||
| 510 | if (alignment() & Qt::AlignBaseline
| 0 | ||||||||||||||||||||||||
| 511 | result.q_minimumDescent = sizeHint(Qt::MinimumDescent, constraintSize).height(); | - | ||||||||||||||||||||||||
| 512 | if (result.q_minimumDescent != -1.0
| 0 | ||||||||||||||||||||||||
| 513 | const qreal minSizeHint = sizeHint(Qt::MinimumSize, constraintSize).height(); | - | ||||||||||||||||||||||||
| 514 | result.q_minimumDescent -= (minSizeHint - result.q_minimumSize); | - | ||||||||||||||||||||||||
| 515 | result.q_minimumAscent = result.q_minimumSize - result.q_minimumDescent; | - | ||||||||||||||||||||||||
| 516 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 517 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 518 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 519 | if (policy & QLayoutPolicy::IgnoreFlag
| 0 | ||||||||||||||||||||||||
| 520 | result.q_preferredSize = result.q_minimumSize; never executed: result.q_preferredSize = result.q_minimumSize; | 0 | ||||||||||||||||||||||||
| 521 | - | |||||||||||||||||||||||||
| 522 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||||||||
| 523 | } | - | ||||||||||||||||||||||||
| 524 | - | |||||||||||||||||||||||||
| 525 | QRectF QGridLayoutItem::geometryWithin(qreal x, qreal y, qreal width, qreal height, | - | ||||||||||||||||||||||||
| 526 | qreal rowDescent, Qt::Alignment align) const | - | ||||||||||||||||||||||||
| 527 | { | - | ||||||||||||||||||||||||
| 528 | const qreal cellWidth = width; | - | ||||||||||||||||||||||||
| 529 | const qreal cellHeight = height; | - | ||||||||||||||||||||||||
| 530 | - | |||||||||||||||||||||||||
| 531 | QSizeF size = effectiveMaxSize(QSizeF(-1,-1)); | - | ||||||||||||||||||||||||
| 532 | if (hasDynamicConstraint()
| 0 | ||||||||||||||||||||||||
| 533 | if (dynamicConstraintOrientation() == Qt::Vertical
| 0 | ||||||||||||||||||||||||
| 534 | if (size.width() > cellWidth
| 0 | ||||||||||||||||||||||||
| 535 | size = effectiveMaxSize(QSizeF(cellWidth, -1)); never executed: size = effectiveMaxSize(QSizeF(cellWidth, -1)); | 0 | ||||||||||||||||||||||||
| 536 | } never executed: else if (size.height() > cellHeightend of block
| 0 | ||||||||||||||||||||||||
| 537 | size = effectiveMaxSize(QSizeF(-1, cellHeight)); | - | ||||||||||||||||||||||||
| 538 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 539 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 540 | size = size.boundedTo(QSizeF(cellWidth, cellHeight)); | - | ||||||||||||||||||||||||
| 541 | width = size.width(); | - | ||||||||||||||||||||||||
| 542 | height = size.height(); | - | ||||||||||||||||||||||||
| 543 | - | |||||||||||||||||||||||||
| 544 | switch (align & Qt::AlignHorizontal_Mask) { | - | ||||||||||||||||||||||||
| 545 | case never executed: Qt::AlignHCenter:case Qt::AlignHCenter:never executed: case Qt::AlignHCenter: | 0 | ||||||||||||||||||||||||
| 546 | x += (cellWidth - width)/2; | - | ||||||||||||||||||||||||
| 547 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 548 | case never executed: Qt::AlignRight:case Qt::AlignRight:never executed: case Qt::AlignRight: | 0 | ||||||||||||||||||||||||
| 549 | x += cellWidth - width; | - | ||||||||||||||||||||||||
| 550 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 551 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 552 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 553 | } | - | ||||||||||||||||||||||||
| 554 | - | |||||||||||||||||||||||||
| 555 | switch (align & Qt::AlignVertical_Mask) { | - | ||||||||||||||||||||||||
| 556 | case never executed: Qt::AlignVCenter:case Qt::AlignVCenter:never executed: case Qt::AlignVCenter: | 0 | ||||||||||||||||||||||||
| 557 | y += (cellHeight - height)/2; | - | ||||||||||||||||||||||||
| 558 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 559 | case never executed: Qt::AlignBottom:case Qt::AlignBottom:never executed: case Qt::AlignBottom: | 0 | ||||||||||||||||||||||||
| 560 | y += cellHeight - height; | - | ||||||||||||||||||||||||
| 561 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 562 | case never executed: Qt::AlignBaseline:case Qt::AlignBaseline:never executed: {case Qt::AlignBaseline: | 0 | ||||||||||||||||||||||||
| 563 | width = qMin(effectiveMaxSize(QSizeF(-1,-1)).width(), width); | - | ||||||||||||||||||||||||
| 564 | QGridLayoutBox vBox = box(Qt::Vertical); | - | ||||||||||||||||||||||||
| 565 | const qreal descent = vBox.q_minimumDescent; | - | ||||||||||||||||||||||||
| 566 | const qreal ascent = vBox.q_minimumSize - descent; | - | ||||||||||||||||||||||||
| 567 | y += (cellHeight - rowDescent - ascent); | - | ||||||||||||||||||||||||
| 568 | height = ascent + descent; | - | ||||||||||||||||||||||||
| 569 | break; never executed: }break; | 0 | ||||||||||||||||||||||||
| 570 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 571 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 572 | } | - | ||||||||||||||||||||||||
| 573 | return never executed: QRectF(x, y, width, height);return QRectF(x, y, width, height);never executed: return QRectF(x, y, width, height); | 0 | ||||||||||||||||||||||||
| 574 | } | - | ||||||||||||||||||||||||
| 575 | - | |||||||||||||||||||||||||
| 576 | void QGridLayoutItem::transpose() | - | ||||||||||||||||||||||||
| 577 | { | - | ||||||||||||||||||||||||
| 578 | qSwap(q_firstRows[Hor], q_firstRows[Ver]); | - | ||||||||||||||||||||||||
| 579 | qSwap(q_rowSpans[Hor], q_rowSpans[Ver]); | - | ||||||||||||||||||||||||
| 580 | qSwap(q_stretches[Hor], q_stretches[Ver]); | - | ||||||||||||||||||||||||
| 581 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 582 | - | |||||||||||||||||||||||||
| 583 | void QGridLayoutItem::insertOrRemoveRows(int row, int delta, Qt::Orientation orientation) | - | ||||||||||||||||||||||||
| 584 | { | - | ||||||||||||||||||||||||
| 585 | int oldFirstRow = firstRow(orientation); | - | ||||||||||||||||||||||||
| 586 | if (oldFirstRow >= row
| 0 | ||||||||||||||||||||||||
| 587 | setFirstRow(oldFirstRow + delta, orientation); | - | ||||||||||||||||||||||||
| 588 | } never executed: else if (lastRow(orientation) >= rowend of block
| 0 | ||||||||||||||||||||||||
| 589 | setRowSpan(rowSpan(orientation) + delta, orientation); | - | ||||||||||||||||||||||||
| 590 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 591 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 592 | QSizeF QGridLayoutItem::effectiveMaxSize(const QSizeF &constraint) const | - | ||||||||||||||||||||||||
| 593 | { | - | ||||||||||||||||||||||||
| 594 | QSizeF size = constraint; | - | ||||||||||||||||||||||||
| 595 | bool vGrow = (sizePolicy(Qt::Vertical) & QLayoutPolicy::GrowFlag) == QLayoutPolicy::GrowFlag; | - | ||||||||||||||||||||||||
| 596 | bool hGrow = (sizePolicy(Qt::Horizontal) & QLayoutPolicy::GrowFlag) == QLayoutPolicy::GrowFlag; | - | ||||||||||||||||||||||||
| 597 | if (!vGrow
| 0 | ||||||||||||||||||||||||
| 598 | QSizeF pref = sizeHint(Qt::PreferredSize, constraint); | - | ||||||||||||||||||||||||
| 599 | if (!vGrow
| 0 | ||||||||||||||||||||||||
| 600 | size.setHeight(pref.height()); never executed: size.setHeight(pref.height()); | 0 | ||||||||||||||||||||||||
| 601 | if (!hGrow
| 0 | ||||||||||||||||||||||||
| 602 | size.setWidth(pref.width()); never executed: size.setWidth(pref.width()); | 0 | ||||||||||||||||||||||||
| 603 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 604 | - | |||||||||||||||||||||||||
| 605 | if (!size.isValid()
| 0 | ||||||||||||||||||||||||
| 606 | QSizeF maxSize = sizeHint(Qt::MaximumSize, size); | - | ||||||||||||||||||||||||
| 607 | if (size.width() == -1
| 0 | ||||||||||||||||||||||||
| 608 | size.setWidth(maxSize.width()); never executed: size.setWidth(maxSize.width()); | 0 | ||||||||||||||||||||||||
| 609 | if (size.height() == -1
| 0 | ||||||||||||||||||||||||
| 610 | size.setHeight(maxSize.height()); never executed: size.setHeight(maxSize.height()); | 0 | ||||||||||||||||||||||||
| 611 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 612 | return never executed: size;return size;never executed: return size; | 0 | ||||||||||||||||||||||||
| 613 | } | - | ||||||||||||||||||||||||
| 614 | void QGridLayoutRowInfo::insertOrRemoveRows(int row, int delta) | - | ||||||||||||||||||||||||
| 615 | { | - | ||||||||||||||||||||||||
| 616 | count += delta; | - | ||||||||||||||||||||||||
| 617 | - | |||||||||||||||||||||||||
| 618 | insertOrRemoveItems(stretches, row, delta); | - | ||||||||||||||||||||||||
| 619 | insertOrRemoveItems(spacings, row, delta); | - | ||||||||||||||||||||||||
| 620 | insertOrRemoveItems(alignments, row, delta); | - | ||||||||||||||||||||||||
| 621 | insertOrRemoveItems(boxes, row, delta); | - | ||||||||||||||||||||||||
| 622 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 623 | QGridLayoutEngine::QGridLayoutEngine(Qt::Alignment defaultAlignment, bool snapToPixelGrid) | - | ||||||||||||||||||||||||
| 624 | { | - | ||||||||||||||||||||||||
| 625 | m_visualDirection = Qt::LeftToRight; | - | ||||||||||||||||||||||||
| 626 | m_defaultAlignment = defaultAlignment; | - | ||||||||||||||||||||||||
| 627 | m_snapToPixelGrid = snapToPixelGrid; | - | ||||||||||||||||||||||||
| 628 | invalidate(); | - | ||||||||||||||||||||||||
| 629 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 630 | - | |||||||||||||||||||||||||
| 631 | int QGridLayoutEngine::rowCount(Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
| 632 | { | - | ||||||||||||||||||||||||
| 633 | return never executed: q_infos[orientation == Qt::Vertical].count;return q_infos[orientation == Qt::Vertical].count;never executed: return q_infos[orientation == Qt::Vertical].count; | 0 | ||||||||||||||||||||||||
| 634 | } | - | ||||||||||||||||||||||||
| 635 | - | |||||||||||||||||||||||||
| 636 | int QGridLayoutEngine::columnCount(Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
| 637 | { | - | ||||||||||||||||||||||||
| 638 | return never executed: q_infos[orientation == Qt::Horizontal].count;return q_infos[orientation == Qt::Horizontal].count;never executed: return q_infos[orientation == Qt::Horizontal].count; | 0 | ||||||||||||||||||||||||
| 639 | } | - | ||||||||||||||||||||||||
| 640 | - | |||||||||||||||||||||||||
| 641 | int QGridLayoutEngine::itemCount() const | - | ||||||||||||||||||||||||
| 642 | { | - | ||||||||||||||||||||||||
| 643 | return never executed: q_items.count();return q_items.count();never executed: return q_items.count(); | 0 | ||||||||||||||||||||||||
| 644 | } | - | ||||||||||||||||||||||||
| 645 | - | |||||||||||||||||||||||||
| 646 | QGridLayoutItem *QGridLayoutEngine::itemAt(int index) const | - | ||||||||||||||||||||||||
| 647 | { | - | ||||||||||||||||||||||||
| 648 | ((!(index >= 0 && index < itemCount())) ? qt_assert("index >= 0 && index < itemCount()",__FILE__,792) : qt_noop()); | - | ||||||||||||||||||||||||
| 649 | return never executed: q_items.at(index);return q_items.at(index);never executed: return q_items.at(index); | 0 | ||||||||||||||||||||||||
| 650 | } | - | ||||||||||||||||||||||||
| 651 | - | |||||||||||||||||||||||||
| 652 | int QGridLayoutEngine::effectiveFirstRow(Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
| 653 | { | - | ||||||||||||||||||||||||
| 654 | ensureEffectiveFirstAndLastRows(); | - | ||||||||||||||||||||||||
| 655 | return never executed: q_cachedEffectiveFirstRows[orientation == Qt::Vertical];return q_cachedEffectiveFirstRows[orientation == Qt::Vertical];never executed: return q_cachedEffectiveFirstRows[orientation == Qt::Vertical]; | 0 | ||||||||||||||||||||||||
| 656 | } | - | ||||||||||||||||||||||||
| 657 | - | |||||||||||||||||||||||||
| 658 | int QGridLayoutEngine::effectiveLastRow(Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
| 659 | { | - | ||||||||||||||||||||||||
| 660 | ensureEffectiveFirstAndLastRows(); | - | ||||||||||||||||||||||||
| 661 | return never executed: q_cachedEffectiveLastRows[orientation == Qt::Vertical];return q_cachedEffectiveLastRows[orientation == Qt::Vertical];never executed: return q_cachedEffectiveLastRows[orientation == Qt::Vertical]; | 0 | ||||||||||||||||||||||||
| 662 | } | - | ||||||||||||||||||||||||
| 663 | - | |||||||||||||||||||||||||
| 664 | void QGridLayoutEngine::setSpacing(qreal spacing, Qt::Orientations orientations) | - | ||||||||||||||||||||||||
| 665 | { | - | ||||||||||||||||||||||||
| 666 | if (orientations & Qt::Horizontal
| 0 | ||||||||||||||||||||||||
| 667 | q_defaultSpacings[Hor].setUserValue(spacing); never executed: q_defaultSpacings[Hor].setUserValue(spacing); | 0 | ||||||||||||||||||||||||
| 668 | if (orientations & Qt::Vertical
| 0 | ||||||||||||||||||||||||
| 669 | q_defaultSpacings[Ver].setUserValue(spacing); never executed: q_defaultSpacings[Ver].setUserValue(spacing); | 0 | ||||||||||||||||||||||||
| 670 | - | |||||||||||||||||||||||||
| 671 | invalidate(); | - | ||||||||||||||||||||||||
| 672 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 673 | - | |||||||||||||||||||||||||
| 674 | qreal QGridLayoutEngine::spacing(Qt::Orientation orientation, const QAbstractLayoutStyleInfo *styleInfo) const | - | ||||||||||||||||||||||||
| 675 | { | - | ||||||||||||||||||||||||
| 676 | if (!q_defaultSpacings[orientation == Qt::Vertical].isUser()
| 0 | ||||||||||||||||||||||||
| 677 | qreal defaultSpacing = styleInfo->spacing(orientation); | - | ||||||||||||||||||||||||
| 678 | q_defaultSpacings[orientation == Qt::Vertical].setCachedValue(defaultSpacing); | - | ||||||||||||||||||||||||
| 679 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 680 | return never executed: q_defaultSpacings[orientation == Qt::Vertical].value();return q_defaultSpacings[orientation == Qt::Vertical].value();never executed: return q_defaultSpacings[orientation == Qt::Vertical].value(); | 0 | ||||||||||||||||||||||||
| 681 | } | - | ||||||||||||||||||||||||
| 682 | - | |||||||||||||||||||||||||
| 683 | void QGridLayoutEngine::setRowSpacing(int row, qreal spacing, Qt::Orientation orientation) | - | ||||||||||||||||||||||||
| 684 | { | - | ||||||||||||||||||||||||
| 685 | ((!(row >= 0)) ? qt_assert("row >= 0",__FILE__,829) : qt_noop()); | - | ||||||||||||||||||||||||
| 686 | - | |||||||||||||||||||||||||
| 687 | QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical]; | - | ||||||||||||||||||||||||
| 688 | if (row >= rowInfo.spacings.count()
| 0 | ||||||||||||||||||||||||
| 689 | rowInfo.spacings.resize(row + 1); never executed: rowInfo.spacings.resize(row + 1); | 0 | ||||||||||||||||||||||||
| 690 | if (spacing >= 0
| 0 | ||||||||||||||||||||||||
| 691 | rowInfo.spacings[row].setUserValue(spacing); never executed: rowInfo.spacings[row].setUserValue(spacing); | 0 | ||||||||||||||||||||||||
| 692 | else | - | ||||||||||||||||||||||||
| 693 | rowInfo.spacings[row] = QLayoutParameter<qreal>(); never executed: rowInfo.spacings[row] = QLayoutParameter<qreal>(); | 0 | ||||||||||||||||||||||||
| 694 | invalidate(); | - | ||||||||||||||||||||||||
| 695 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 696 | - | |||||||||||||||||||||||||
| 697 | qreal QGridLayoutEngine::rowSpacing(int row, Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
| 698 | { | - | ||||||||||||||||||||||||
| 699 | QLayoutParameter<qreal> spacing = q_infos[orientation == Qt::Vertical].spacings.value(row); | - | ||||||||||||||||||||||||
| 700 | if (!spacing.isDefault()
| 0 | ||||||||||||||||||||||||
| 701 | return never executed: spacing.value();return spacing.value();never executed: return spacing.value(); | 0 | ||||||||||||||||||||||||
| 702 | return never executed: q_defaultSpacings[orientation == Qt::Vertical].value();return q_defaultSpacings[orientation == Qt::Vertical].value();never executed: return q_defaultSpacings[orientation == Qt::Vertical].value(); | 0 | ||||||||||||||||||||||||
| 703 | } | - | ||||||||||||||||||||||||
| 704 | - | |||||||||||||||||||||||||
| 705 | void QGridLayoutEngine::setRowStretchFactor(int row, int stretch, Qt::Orientation orientation) | - | ||||||||||||||||||||||||
| 706 | { | - | ||||||||||||||||||||||||
| 707 | ((!(row >= 0)) ? qt_assert("row >= 0",__FILE__,851) : qt_noop()); | - | ||||||||||||||||||||||||
| 708 | ((!(stretch >= 0)) ? qt_assert("stretch >= 0",__FILE__,852) : qt_noop()); | - | ||||||||||||||||||||||||
| 709 | - | |||||||||||||||||||||||||
| 710 | maybeExpandGrid(row, -1, orientation); | - | ||||||||||||||||||||||||
| 711 | - | |||||||||||||||||||||||||
| 712 | QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical]; | - | ||||||||||||||||||||||||
| 713 | if (row >= rowInfo.stretches.count()
| 0 | ||||||||||||||||||||||||
| 714 | rowInfo.stretches.resize(row + 1); never executed: rowInfo.stretches.resize(row + 1); | 0 | ||||||||||||||||||||||||
| 715 | rowInfo.stretches[row].setUserValue(stretch); | - | ||||||||||||||||||||||||
| 716 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 717 | - | |||||||||||||||||||||||||
| 718 | int QGridLayoutEngine::rowStretchFactor(int row, Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
| 719 | { | - | ||||||||||||||||||||||||
| 720 | QStretchParameter stretch = q_infos[orientation == Qt::Vertical].stretches.value(row); | - | ||||||||||||||||||||||||
| 721 | if (!stretch.isDefault()
| 0 | ||||||||||||||||||||||||
| 722 | return never executed: stretch.value();return stretch.value();never executed: return stretch.value(); | 0 | ||||||||||||||||||||||||
| 723 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 724 | } | - | ||||||||||||||||||||||||
| 725 | - | |||||||||||||||||||||||||
| 726 | void QGridLayoutEngine::setRowSizeHint(Qt::SizeHint which, int row, qreal size, | - | ||||||||||||||||||||||||
| 727 | Qt::Orientation orientation) | - | ||||||||||||||||||||||||
| 728 | { | - | ||||||||||||||||||||||||
| 729 | ((!(row >= 0)) ? qt_assert("row >= 0",__FILE__,873) : qt_noop()); | - | ||||||||||||||||||||||||
| 730 | ((!(size >= 0.0)) ? qt_assert("size >= 0.0",__FILE__,874) : qt_noop()); | - | ||||||||||||||||||||||||
| 731 | - | |||||||||||||||||||||||||
| 732 | maybeExpandGrid(row, -1, orientation); | - | ||||||||||||||||||||||||
| 733 | - | |||||||||||||||||||||||||
| 734 | QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical]; | - | ||||||||||||||||||||||||
| 735 | if (row >= rowInfo.boxes.count()
| 0 | ||||||||||||||||||||||||
| 736 | rowInfo.boxes.resize(row + 1); never executed: rowInfo.boxes.resize(row + 1); | 0 | ||||||||||||||||||||||||
| 737 | rowInfo.boxes[row].q_sizes(which) = size; | - | ||||||||||||||||||||||||
| 738 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 739 | - | |||||||||||||||||||||||||
| 740 | qreal QGridLayoutEngine::rowSizeHint(Qt::SizeHint which, int row, Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
| 741 | { | - | ||||||||||||||||||||||||
| 742 | return never executed: q_infos[orientation == Qt::Vertical].boxes.value(row).q_sizes(which);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 | ||||||||||||||||||||||||
| 743 | } | - | ||||||||||||||||||||||||
| 744 | - | |||||||||||||||||||||||||
| 745 | void QGridLayoutEngine::setRowAlignment(int row, Qt::Alignment alignment, | - | ||||||||||||||||||||||||
| 746 | Qt::Orientation orientation) | - | ||||||||||||||||||||||||
| 747 | { | - | ||||||||||||||||||||||||
| 748 | ((!(row >= 0)) ? qt_assert("row >= 0",__FILE__,892) : qt_noop()); | - | ||||||||||||||||||||||||
| 749 | - | |||||||||||||||||||||||||
| 750 | maybeExpandGrid(row, -1, orientation); | - | ||||||||||||||||||||||||
| 751 | - | |||||||||||||||||||||||||
| 752 | QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical]; | - | ||||||||||||||||||||||||
| 753 | if (row >= rowInfo.alignments.count()
| 0 | ||||||||||||||||||||||||
| 754 | rowInfo.alignments.resize(row + 1); never executed: rowInfo.alignments.resize(row + 1); | 0 | ||||||||||||||||||||||||
| 755 | rowInfo.alignments[row] = alignment; | - | ||||||||||||||||||||||||
| 756 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 757 | - | |||||||||||||||||||||||||
| 758 | Qt::Alignment QGridLayoutEngine::rowAlignment(int row, Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
| 759 | { | - | ||||||||||||||||||||||||
| 760 | ((!(row >= 0)) ? qt_assert("row >= 0",__FILE__,904) : qt_noop()); | - | ||||||||||||||||||||||||
| 761 | return never executed: q_infos[orientation == Qt::Vertical].alignments.value(row);return q_infos[orientation == Qt::Vertical].alignments.value(row);never executed: return q_infos[orientation == Qt::Vertical].alignments.value(row); | 0 | ||||||||||||||||||||||||
| 762 | } | - | ||||||||||||||||||||||||
| 763 | - | |||||||||||||||||||||||||
| 764 | Qt::Alignment QGridLayoutEngine::effectiveAlignment(const QGridLayoutItem *layoutItem) const | - | ||||||||||||||||||||||||
| 765 | { | - | ||||||||||||||||||||||||
| 766 | Qt::Alignment align = layoutItem->alignment(); | - | ||||||||||||||||||||||||
| 767 | if (!(align & Qt::AlignVertical_Mask)
| 0 | ||||||||||||||||||||||||
| 768 | - | |||||||||||||||||||||||||
| 769 | int y = layoutItem->firstRow(); | - | ||||||||||||||||||||||||
| 770 | align |= (rowAlignment(y, Qt::Vertical) & Qt::AlignVertical_Mask); | - | ||||||||||||||||||||||||
| 771 | if (!(align & Qt::AlignVertical_Mask)
| 0 | ||||||||||||||||||||||||
| 772 | align |= (m_defaultAlignment & Qt::AlignVertical_Mask); never executed: align |= (m_defaultAlignment & Qt::AlignVertical_Mask); | 0 | ||||||||||||||||||||||||
| 773 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 774 | if (!(align & Qt::AlignHorizontal_Mask)
| 0 | ||||||||||||||||||||||||
| 775 | - | |||||||||||||||||||||||||
| 776 | int x = layoutItem->firstColumn(); | - | ||||||||||||||||||||||||
| 777 | align |= (rowAlignment(x, Qt::Horizontal) & Qt::AlignHorizontal_Mask); | - | ||||||||||||||||||||||||
| 778 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 779 | - | |||||||||||||||||||||||||
| 780 | return never executed: align;return align;never executed: return align; | 0 | ||||||||||||||||||||||||
| 781 | } | - | ||||||||||||||||||||||||
| 782 | - | |||||||||||||||||||||||||
| 783 | - | |||||||||||||||||||||||||
| 784 | - | |||||||||||||||||||||||||
| 785 | - | |||||||||||||||||||||||||
| 786 | - | |||||||||||||||||||||||||
| 787 | - | |||||||||||||||||||||||||
| 788 | - | |||||||||||||||||||||||||
| 789 | void QGridLayoutEngine::insertItem(QGridLayoutItem *item, int index) | - | ||||||||||||||||||||||||
| 790 | { | - | ||||||||||||||||||||||||
| 791 | maybeExpandGrid(item->lastRow(), item->lastColumn()); | - | ||||||||||||||||||||||||
| 792 | - | |||||||||||||||||||||||||
| 793 | if (index == -1
| 0 | ||||||||||||||||||||||||
| 794 | q_items.append(item); never executed: q_items.append(item); | 0 | ||||||||||||||||||||||||
| 795 | else | - | ||||||||||||||||||||||||
| 796 | q_items.insert(index, item); never executed: q_items.insert(index, item); | 0 | ||||||||||||||||||||||||
| 797 | - | |||||||||||||||||||||||||
| 798 | for (int i = item->firstRow(); i <= item->lastRow()
| 0 | ||||||||||||||||||||||||
| 799 | for (int j = item->firstColumn(); j <= item->lastColumn()
| 0 | ||||||||||||||||||||||||
| 800 | if (itemAt(i, j)
| 0 | ||||||||||||||||||||||||
| 801 | QMessageLogger(__FILE__, 945, __PRETTY_FUNCTION__).warning("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 | ||||||||||||||||||||||||
| 802 | setItemAt(i, j, item); | - | ||||||||||||||||||||||||
| 803 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 804 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 805 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 806 | - | |||||||||||||||||||||||||
| 807 | void QGridLayoutEngine::addItem(QGridLayoutItem *item) | - | ||||||||||||||||||||||||
| 808 | { | - | ||||||||||||||||||||||||
| 809 | insertItem(item, -1); | - | ||||||||||||||||||||||||
| 810 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 811 | - | |||||||||||||||||||||||||
| 812 | void QGridLayoutEngine::removeItem(QGridLayoutItem *item) | - | ||||||||||||||||||||||||
| 813 | { | - | ||||||||||||||||||||||||
| 814 | ((!(q_items.contains(item))) ? qt_assert("q_items.contains(item)",__FILE__,958) : qt_noop()); | - | ||||||||||||||||||||||||
| 815 | - | |||||||||||||||||||||||||
| 816 | invalidate(); | - | ||||||||||||||||||||||||
| 817 | - | |||||||||||||||||||||||||
| 818 | for (int i = item->firstRow(); i <= item->lastRow()
| 0 | ||||||||||||||||||||||||
| 819 | for (int j = item->firstColumn(); j <= item->lastColumn()
| 0 | ||||||||||||||||||||||||
| 820 | if (itemAt(i, j) == item
| 0 | ||||||||||||||||||||||||
| 821 | setItemAt(i, j, 0); never executed: setItemAt(i, j, 0); | 0 | ||||||||||||||||||||||||
| 822 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 823 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 824 | - | |||||||||||||||||||||||||
| 825 | q_items.removeAll(item); | - | ||||||||||||||||||||||||
| 826 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 827 | - | |||||||||||||||||||||||||
| 828 | - | |||||||||||||||||||||||||
| 829 | QGridLayoutItem *QGridLayoutEngine::itemAt(int row, int column, Qt::Orientation orientation) const | - | ||||||||||||||||||||||||
| 830 | { | - | ||||||||||||||||||||||||
| 831 | if (orientation == Qt::Horizontal
| 0 | ||||||||||||||||||||||||
| 832 | qSwap(row, column); never executed: qSwap(row, column); | 0 | ||||||||||||||||||||||||
| 833 | if (uint(row) >= uint(rowCount())
| 0 | ||||||||||||||||||||||||
| 834 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 835 | return never executed: q_grid.at((row * internalGridColumnCount()) + column);return q_grid.at((row * internalGridColumnCount()) + column);never executed: return q_grid.at((row * internalGridColumnCount()) + column); | 0 | ||||||||||||||||||||||||
| 836 | } | - | ||||||||||||||||||||||||
| 837 | - | |||||||||||||||||||||||||
| 838 | void QGridLayoutEngine::invalidate() | - | ||||||||||||||||||||||||
| 839 | { | - | ||||||||||||||||||||||||
| 840 | q_cachedEffectiveFirstRows[Hor] = -1; | - | ||||||||||||||||||||||||
| 841 | q_cachedEffectiveFirstRows[Ver] = -1; | - | ||||||||||||||||||||||||
| 842 | q_cachedEffectiveLastRows[Hor] = -1; | - | ||||||||||||||||||||||||
| 843 | q_cachedEffectiveLastRows[Ver] = -1; | - | ||||||||||||||||||||||||
| 844 | - | |||||||||||||||||||||||||
| 845 | q_totalBoxCachedConstraints[Hor] = NotCached; | - | ||||||||||||||||||||||||
| 846 | q_totalBoxCachedConstraints[Ver] = NotCached; | - | ||||||||||||||||||||||||
| 847 | - | |||||||||||||||||||||||||
| 848 | q_cachedSize = QSizeF(); | - | ||||||||||||||||||||||||
| 849 | q_cachedConstraintOrientation = UnknownConstraint; | - | ||||||||||||||||||||||||
| 850 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 851 | - | |||||||||||||||||||||||||
| 852 | static void visualRect(QRectF *geom, Qt::LayoutDirection dir, const QRectF &contentsRect) | - | ||||||||||||||||||||||||
| 853 | { | - | ||||||||||||||||||||||||
| 854 | if (dir == Qt::RightToLeft
| 0 | ||||||||||||||||||||||||
| 855 | geom->moveRight(contentsRect.right() - (geom->left() - contentsRect.left())); never executed: geom->moveRight(contentsRect.right() - (geom->left() - contentsRect.left())); | 0 | ||||||||||||||||||||||||
| 856 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 857 | - | |||||||||||||||||||||||||
| 858 | void QGridLayoutEngine::setGeometries(const QRectF &contentsGeometry, const QAbstractLayoutStyleInfo *styleInfo) | - | ||||||||||||||||||||||||
| 859 | { | - | ||||||||||||||||||||||||
| 860 | if (rowCount() < 1
| 0 | ||||||||||||||||||||||||
| 861 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 862 | - | |||||||||||||||||||||||||
| 863 | ensureGeometries(contentsGeometry.size(), styleInfo); | - | ||||||||||||||||||||||||
| 864 | - | |||||||||||||||||||||||||
| 865 | for (int i = q_items.count() - 1; i >= 0
| 0 | ||||||||||||||||||||||||
| 866 | QGridLayoutItem *item = q_items.at(i); | - | ||||||||||||||||||||||||
| 867 | - | |||||||||||||||||||||||||
| 868 | qreal x = q_xx[item->firstColumn()]; | - | ||||||||||||||||||||||||
| 869 | qreal y = q_yy[item->firstRow()]; | - | ||||||||||||||||||||||||
| 870 | qreal width = q_widths[item->lastColumn()]; | - | ||||||||||||||||||||||||
| 871 | qreal height = q_heights[item->lastRow()]; | - | ||||||||||||||||||||||||
| 872 | - | |||||||||||||||||||||||||
| 873 | if (item->columnSpan() != 1
| 0 | ||||||||||||||||||||||||
| 874 | width += q_xx[item->lastColumn()] - x; never executed: width += q_xx[item->lastColumn()] - x; | 0 | ||||||||||||||||||||||||
| 875 | if (item->rowSpan() != 1
| 0 | ||||||||||||||||||||||||
| 876 | height += q_yy[item->lastRow()] - y; never executed: height += q_yy[item->lastRow()] - y; | 0 | ||||||||||||||||||||||||
| 877 | - | |||||||||||||||||||||||||
| 878 | const Qt::Alignment align = effectiveAlignment(item); | - | ||||||||||||||||||||||||
| 879 | QRectF geom = item->geometryWithin(contentsGeometry.x() + x, contentsGeometry.y() + y, | - | ||||||||||||||||||||||||
| 880 | width, height, q_descents[item->lastRow()], align); | - | ||||||||||||||||||||||||
| 881 | if (m_snapToPixelGrid
| 0 | ||||||||||||||||||||||||
| 882 | - | |||||||||||||||||||||||||
| 883 | - | |||||||||||||||||||||||||
| 884 | geom.setX(qround(geom.x())); | - | ||||||||||||||||||||||||
| 885 | - | |||||||||||||||||||||||||
| 886 | if (align != Qt::AlignBaseline
| 0 | ||||||||||||||||||||||||
| 887 | geom.setY(qround(geom.y())); never executed: geom.setY(qround(geom.y())); | 0 | ||||||||||||||||||||||||
| 888 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 889 | visualRect(&geom, visualDirection(), contentsGeometry); | - | ||||||||||||||||||||||||
| 890 | item->setGeometry(geom); | - | ||||||||||||||||||||||||
| 891 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 892 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 893 | - | |||||||||||||||||||||||||
| 894 | - | |||||||||||||||||||||||||
| 895 | QRectF QGridLayoutEngine::cellRect(const QRectF &contentsGeometry, int row, int column, int rowSpan, | - | ||||||||||||||||||||||||
| 896 | int columnSpan, const QAbstractLayoutStyleInfo *styleInfo) const | - | ||||||||||||||||||||||||
| 897 | { | - | ||||||||||||||||||||||||
| 898 | if (uint(row) >= uint(rowCount())
| 0 | ||||||||||||||||||||||||
| 899 | || rowSpan < 1
| 0 | ||||||||||||||||||||||||
| 900 | return never executed: QRectF();return QRectF();never executed: return QRectF(); | 0 | ||||||||||||||||||||||||
| 901 | - | |||||||||||||||||||||||||
| 902 | ensureGeometries(contentsGeometry.size(), styleInfo); | - | ||||||||||||||||||||||||
| 903 | - | |||||||||||||||||||||||||
| 904 | int lastColumn = qMax(column + columnSpan, columnCount()) - 1; | - | ||||||||||||||||||||||||
| 905 | int lastRow = qMax(row + rowSpan, rowCount()) - 1; | - | ||||||||||||||||||||||||
| 906 | - | |||||||||||||||||||||||||
| 907 | qreal x = q_xx[column]; | - | ||||||||||||||||||||||||
| 908 | qreal y = q_yy[row]; | - | ||||||||||||||||||||||||
| 909 | qreal width = q_widths[lastColumn]; | - | ||||||||||||||||||||||||
| 910 | qreal height = q_heights[lastRow]; | - | ||||||||||||||||||||||||
| 911 | - | |||||||||||||||||||||||||
| 912 | if (columnSpan != 1
| 0 | ||||||||||||||||||||||||
| 913 | width += q_xx[lastColumn] - x; never executed: width += q_xx[lastColumn] - x; | 0 | ||||||||||||||||||||||||
| 914 | if (rowSpan != 1
| 0 | ||||||||||||||||||||||||
| 915 | height += q_yy[lastRow] - y; never executed: height += q_yy[lastRow] - y; | 0 | ||||||||||||||||||||||||
| 916 | - | |||||||||||||||||||||||||
| 917 | return never executed: QRectF(contentsGeometry.x() + x, contentsGeometry.y() + y, width, height);return QRectF(contentsGeometry.x() + x, contentsGeometry.y() + y, width, height);never executed: return QRectF(contentsGeometry.x() + x, contentsGeometry.y() + y, width, height); | 0 | ||||||||||||||||||||||||
| 918 | } | - | ||||||||||||||||||||||||
| 919 | - | |||||||||||||||||||||||||
| 920 | QSizeF QGridLayoutEngine::sizeHint(Qt::SizeHint which, const QSizeF &constraint, | - | ||||||||||||||||||||||||
| 921 | const QAbstractLayoutStyleInfo *styleInfo) const | - | ||||||||||||||||||||||||
| 922 | { | - | ||||||||||||||||||||||||
| 923 | - | |||||||||||||||||||||||||
| 924 | - | |||||||||||||||||||||||||
| 925 | if (hasDynamicConstraint()
| 0 | ||||||||||||||||||||||||
| 926 | QGridLayoutBox sizehint_totalBoxes[NOrientations]; | - | ||||||||||||||||||||||||
| 927 | bool sizeHintCalculated = false; | - | ||||||||||||||||||||||||
| 928 | if (constraintOrientation() == Qt::Vertical
| 0 | ||||||||||||||||||||||||
| 929 | - | |||||||||||||||||||||||||
| 930 | if (constraint.width() >= 0
| 0 | ||||||||||||||||||||||||
| 931 | ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], __null, __null, Qt::Horizontal, styleInfo); | - | ||||||||||||||||||||||||
| 932 | QVector<qreal> sizehint_xx; | - | ||||||||||||||||||||||||
| 933 | QVector<qreal> sizehint_widths; | - | ||||||||||||||||||||||||
| 934 | - | |||||||||||||||||||||||||
| 935 | sizehint_xx.resize(columnCount()); | - | ||||||||||||||||||||||||
| 936 | sizehint_widths.resize(columnCount()); | - | ||||||||||||||||||||||||
| 937 | qreal width = constraint.width(); | - | ||||||||||||||||||||||||
| 938 | - | |||||||||||||||||||||||||
| 939 | - | |||||||||||||||||||||||||
| 940 | q_columnData.calculateGeometries(0, columnCount(), width, sizehint_xx.data(), sizehint_widths.data(), | - | ||||||||||||||||||||||||
| 941 | 0, sizehint_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); | - | ||||||||||||||||||||||||
| 942 | ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], sizehint_xx.data(), sizehint_widths.data(), Qt::Vertical, styleInfo); | - | ||||||||||||||||||||||||
| 943 | sizeHintCalculated = true; | - | ||||||||||||||||||||||||
| 944 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 945 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 946 | if (constraint.height() >= 0
| 0 | ||||||||||||||||||||||||
| 947 | - | |||||||||||||||||||||||||
| 948 | ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], __null, __null, Qt::Vertical, styleInfo); | - | ||||||||||||||||||||||||
| 949 | QVector<qreal> sizehint_yy; | - | ||||||||||||||||||||||||
| 950 | QVector<qreal> sizehint_heights; | - | ||||||||||||||||||||||||
| 951 | - | |||||||||||||||||||||||||
| 952 | sizehint_yy.resize(rowCount()); | - | ||||||||||||||||||||||||
| 953 | sizehint_heights.resize(rowCount()); | - | ||||||||||||||||||||||||
| 954 | qreal height = constraint.height(); | - | ||||||||||||||||||||||||
| 955 | - | |||||||||||||||||||||||||
| 956 | - | |||||||||||||||||||||||||
| 957 | q_rowData.calculateGeometries(0, rowCount(), height, sizehint_yy.data(), sizehint_heights.data(), | - | ||||||||||||||||||||||||
| 958 | 0, sizehint_totalBoxes[Ver], q_infos[Ver], m_snapToPixelGrid); | - | ||||||||||||||||||||||||
| 959 | ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], sizehint_yy.data(), sizehint_heights.data(), Qt::Horizontal, styleInfo); | - | ||||||||||||||||||||||||
| 960 | sizeHintCalculated = true; | - | ||||||||||||||||||||||||
| 961 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 962 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 963 | if (sizeHintCalculated
| 0 | ||||||||||||||||||||||||
| 964 | return never executed: QSizeF(sizehint_totalBoxes[Hor].q_sizes(which), sizehint_totalBoxes[Ver].q_sizes(which));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 | ||||||||||||||||||||||||
| 965 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 966 | - | |||||||||||||||||||||||||
| 967 | - | |||||||||||||||||||||||||
| 968 | ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], __null, __null, Qt::Horizontal, styleInfo); | - | ||||||||||||||||||||||||
| 969 | ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], __null, __null, Qt::Vertical, styleInfo); | - | ||||||||||||||||||||||||
| 970 | return never executed: QSizeF(q_totalBoxes[Hor].q_sizes(which), q_totalBoxes[Ver].q_sizes(which));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 | ||||||||||||||||||||||||
| 971 | } | - | ||||||||||||||||||||||||
| 972 | - | |||||||||||||||||||||||||
| 973 | QLayoutPolicy::ControlTypes QGridLayoutEngine::controlTypes(LayoutSide side) const | - | ||||||||||||||||||||||||
| 974 | { | - | ||||||||||||||||||||||||
| 975 | Qt::Orientation orientation = (side == Top
| 0 | ||||||||||||||||||||||||
| 976 | int row = (side == Top
| 0 | ||||||||||||||||||||||||
| 977 | : effectiveLastRow(orientation); | - | ||||||||||||||||||||||||
| 978 | QLayoutPolicy::ControlTypes result = 0; | - | ||||||||||||||||||||||||
| 979 | - | |||||||||||||||||||||||||
| 980 | for (int column = columnCount(orientation) - 1; column >= 0
| 0 | ||||||||||||||||||||||||
| 981 | if (QGridLayoutItem *item = itemAt(row, column, orientation)
| 0 | ||||||||||||||||||||||||
| 982 | result |= item->controlTypes(side); never executed: result |= item->controlTypes(side); | 0 | ||||||||||||||||||||||||
| 983 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 984 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||||||||
| 985 | } | - | ||||||||||||||||||||||||
| 986 | - | |||||||||||||||||||||||||
| 987 | void QGridLayoutEngine::transpose() | - | ||||||||||||||||||||||||
| 988 | { | - | ||||||||||||||||||||||||
| 989 | invalidate(); | - | ||||||||||||||||||||||||
| 990 | - | |||||||||||||||||||||||||
| 991 | for (int i = q_items.count() - 1; i >= 0
| 0 | ||||||||||||||||||||||||
| 992 | q_items.at(i)->transpose(); never executed: q_items.at(i)->transpose(); | 0 | ||||||||||||||||||||||||
| 993 | - | |||||||||||||||||||||||||
| 994 | qSwap(q_defaultSpacings[Hor], q_defaultSpacings[Ver]); | - | ||||||||||||||||||||||||
| 995 | qSwap(q_infos[Hor], q_infos[Ver]); | - | ||||||||||||||||||||||||
| 996 | - | |||||||||||||||||||||||||
| 997 | regenerateGrid(); | - | ||||||||||||||||||||||||
| 998 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 999 | - | |||||||||||||||||||||||||
| 1000 | void QGridLayoutEngine::setVisualDirection(Qt::LayoutDirection direction) | - | ||||||||||||||||||||||||
| 1001 | { | - | ||||||||||||||||||||||||
| 1002 | m_visualDirection = direction; | - | ||||||||||||||||||||||||
| 1003 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1004 | - | |||||||||||||||||||||||||
| 1005 | Qt::LayoutDirection QGridLayoutEngine::visualDirection() const | - | ||||||||||||||||||||||||
| 1006 | { | - | ||||||||||||||||||||||||
| 1007 | return never executed: m_visualDirection;return m_visualDirection;never executed: return m_visualDirection; | 0 | ||||||||||||||||||||||||
| 1008 | } | - | ||||||||||||||||||||||||
| 1009 | void QGridLayoutEngine::maybeExpandGrid(int row, int column, Qt::Orientation orientation) | - | ||||||||||||||||||||||||
| 1010 | { | - | ||||||||||||||||||||||||
| 1011 | invalidate(); | - | ||||||||||||||||||||||||
| 1012 | - | |||||||||||||||||||||||||
| 1013 | if (orientation == Qt::Horizontal
| 0 | ||||||||||||||||||||||||
| 1014 | qSwap(row, column); never executed: qSwap(row, column); | 0 | ||||||||||||||||||||||||
| 1015 | - | |||||||||||||||||||||||||
| 1016 | if (row < rowCount()
| 0 | ||||||||||||||||||||||||
| 1017 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1018 | - | |||||||||||||||||||||||||
| 1019 | int oldGridRowCount = internalGridRowCount(); | - | ||||||||||||||||||||||||
| 1020 | int oldGridColumnCount = internalGridColumnCount(); | - | ||||||||||||||||||||||||
| 1021 | - | |||||||||||||||||||||||||
| 1022 | q_infos[Ver].count = qMax(row + 1, rowCount()); | - | ||||||||||||||||||||||||
| 1023 | q_infos[Hor].count = qMax(column + 1, columnCount()); | - | ||||||||||||||||||||||||
| 1024 | - | |||||||||||||||||||||||||
| 1025 | int newGridRowCount = internalGridRowCount(); | - | ||||||||||||||||||||||||
| 1026 | int newGridColumnCount = internalGridColumnCount(); | - | ||||||||||||||||||||||||
| 1027 | - | |||||||||||||||||||||||||
| 1028 | int newGridSize = newGridRowCount * newGridColumnCount; | - | ||||||||||||||||||||||||
| 1029 | if (newGridSize != q_grid.count()
| 0 | ||||||||||||||||||||||||
| 1030 | q_grid.resize(newGridSize); | - | ||||||||||||||||||||||||
| 1031 | - | |||||||||||||||||||||||||
| 1032 | if (newGridColumnCount != oldGridColumnCount
| 0 | ||||||||||||||||||||||||
| 1033 | for (int i = oldGridRowCount - 1; i >= 1
| 0 | ||||||||||||||||||||||||
| 1034 | for (int j = oldGridColumnCount - 1; j >= 0
| 0 | ||||||||||||||||||||||||
| 1035 | int oldIndex = (i * oldGridColumnCount) + j; | - | ||||||||||||||||||||||||
| 1036 | int newIndex = (i * newGridColumnCount) + j; | - | ||||||||||||||||||||||||
| 1037 | - | |||||||||||||||||||||||||
| 1038 | ((!(newIndex > oldIndex)) ? qt_assert("newIndex > oldIndex",__FILE__,1232) : qt_noop()); | - | ||||||||||||||||||||||||
| 1039 | q_grid[newIndex] = q_grid[oldIndex]; | - | ||||||||||||||||||||||||
| 1040 | q_grid[oldIndex] = 0; | - | ||||||||||||||||||||||||
| 1041 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1042 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1043 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1044 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1045 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1046 | - | |||||||||||||||||||||||||
| 1047 | void QGridLayoutEngine::regenerateGrid() | - | ||||||||||||||||||||||||
| 1048 | { | - | ||||||||||||||||||||||||
| 1049 | q_grid.fill(0); | - | ||||||||||||||||||||||||
| 1050 | - | |||||||||||||||||||||||||
| 1051 | for (int i = q_items.count() - 1; i >= 0
| 0 | ||||||||||||||||||||||||
| 1052 | QGridLayoutItem *item = q_items.at(i); | - | ||||||||||||||||||||||||
| 1053 | - | |||||||||||||||||||||||||
| 1054 | for (int j = item->firstRow(); j <= item->lastRow()
| 0 | ||||||||||||||||||||||||
| 1055 | for (int k = item->firstColumn(); k <= item->lastColumn()
| 0 | ||||||||||||||||||||||||
| 1056 | setItemAt(j, k, item); | - | ||||||||||||||||||||||||
| 1057 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1058 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1059 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1060 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1061 | - | |||||||||||||||||||||||||
| 1062 | void QGridLayoutEngine::setItemAt(int row, int column, QGridLayoutItem *item) | - | ||||||||||||||||||||||||
| 1063 | { | - | ||||||||||||||||||||||||
| 1064 | ((!(row >= 0 && row < rowCount())) ? qt_assert("row >= 0 && row < rowCount()",__FILE__,1258) : qt_noop()); | - | ||||||||||||||||||||||||
| 1065 | ((!(column >= 0 && column < columnCount())) ? qt_assert("column >= 0 && column < columnCount()",__FILE__,1259) : qt_noop()); | - | ||||||||||||||||||||||||
| 1066 | q_grid[(row * internalGridColumnCount()) + column] = item; | - | ||||||||||||||||||||||||
| 1067 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1068 | - | |||||||||||||||||||||||||
| 1069 | void QGridLayoutEngine::insertOrRemoveRows(int row, int delta, Qt::Orientation orientation) | - | ||||||||||||||||||||||||
| 1070 | { | - | ||||||||||||||||||||||||
| 1071 | int oldRowCount = rowCount(orientation); | - | ||||||||||||||||||||||||
| 1072 | ((!(uint(row) <= uint(oldRowCount))) ? qt_assert("uint(row) <= uint(oldRowCount)",__FILE__,1266) : qt_noop()); | - | ||||||||||||||||||||||||
| 1073 | - | |||||||||||||||||||||||||
| 1074 | invalidate(); | - | ||||||||||||||||||||||||
| 1075 | - | |||||||||||||||||||||||||
| 1076 | - | |||||||||||||||||||||||||
| 1077 | if (row == oldRowCount
| 0 | ||||||||||||||||||||||||
| 1078 | maybeExpandGrid(oldRowCount + delta - 1, -1, orientation); | - | ||||||||||||||||||||||||
| 1079 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1080 | } | - | ||||||||||||||||||||||||
| 1081 | - | |||||||||||||||||||||||||
| 1082 | q_infos[orientation == Qt::Vertical].insertOrRemoveRows(row, delta); | - | ||||||||||||||||||||||||
| 1083 | - | |||||||||||||||||||||||||
| 1084 | for (int i = q_items.count() - 1; i >= 0
| 0 | ||||||||||||||||||||||||
| 1085 | q_items.at(i)->insertOrRemoveRows(row, delta, orientation); never executed: q_items.at(i)->insertOrRemoveRows(row, delta, orientation); | 0 | ||||||||||||||||||||||||
| 1086 | - | |||||||||||||||||||||||||
| 1087 | q_grid.resize(internalGridRowCount() * internalGridColumnCount()); | - | ||||||||||||||||||||||||
| 1088 | regenerateGrid(); | - | ||||||||||||||||||||||||
| 1089 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1090 | - | |||||||||||||||||||||||||
| 1091 | void QGridLayoutEngine::fillRowData(QGridLayoutRowData *rowData, | - | ||||||||||||||||||||||||
| 1092 | const qreal *colPositions, const qreal *colSizes, | - | ||||||||||||||||||||||||
| 1093 | Qt::Orientation orientation, | - | ||||||||||||||||||||||||
| 1094 | const QAbstractLayoutStyleInfo *styleInfo) const | - | ||||||||||||||||||||||||
| 1095 | { | - | ||||||||||||||||||||||||
| 1096 | const int ButtonMask = QLayoutPolicy::ButtonBox | QLayoutPolicy::PushButton; | - | ||||||||||||||||||||||||
| 1097 | const QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical]; | - | ||||||||||||||||||||||||
| 1098 | const QGridLayoutRowInfo &columnInfo = q_infos[orientation == Qt::Horizontal]; | - | ||||||||||||||||||||||||
| 1099 | LayoutSide top = (
| 0 | ||||||||||||||||||||||||
| 1100 | LayoutSide bottom = (
| 0 | ||||||||||||||||||||||||
| 1101 | - | |||||||||||||||||||||||||
| 1102 | const QLayoutParameter<qreal> &defaultSpacing = q_defaultSpacings[orientation == Qt::Vertical]; | - | ||||||||||||||||||||||||
| 1103 | qreal innerSpacing = styleInfo->spacing(orientation); | - | ||||||||||||||||||||||||
| 1104 | if (innerSpacing >= 0.0
| 0 | ||||||||||||||||||||||||
| 1105 | defaultSpacing.setCachedValue(innerSpacing); never executed: defaultSpacing.setCachedValue(innerSpacing); | 0 | ||||||||||||||||||||||||
| 1106 | - | |||||||||||||||||||||||||
| 1107 | for (int row = 0; row < rowInfo.count
| 0 | ||||||||||||||||||||||||
| 1108 | bool rowIsEmpty = true; | - | ||||||||||||||||||||||||
| 1109 | bool rowIsIdenticalToPrevious = (row > 0); | - | ||||||||||||||||||||||||
| 1110 | - | |||||||||||||||||||||||||
| 1111 | for (int column = 0; column < columnInfo.count
| 0 | ||||||||||||||||||||||||
| 1112 | QGridLayoutItem *item = itemAt(row, column, orientation); | - | ||||||||||||||||||||||||
| 1113 | - | |||||||||||||||||||||||||
| 1114 | if (rowIsIdenticalToPrevious
| 0 | ||||||||||||||||||||||||
| 1115 | rowIsIdenticalToPrevious = false; never executed: rowIsIdenticalToPrevious = false; | 0 | ||||||||||||||||||||||||
| 1116 | - | |||||||||||||||||||||||||
| 1117 | if (item
| 0 | ||||||||||||||||||||||||
| 1118 | rowIsEmpty = false; never executed: rowIsEmpty = false; | 0 | ||||||||||||||||||||||||
| 1119 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1120 | - | |||||||||||||||||||||||||
| 1121 | if ((rowIsEmpty
| 0 | ||||||||||||||||||||||||
| 1122 | && rowInfo.spacings.value(row).isDefault()
| 0 | ||||||||||||||||||||||||
| 1123 | && rowInfo.stretches.value(row).isDefault()
| 0 | ||||||||||||||||||||||||
| 1124 | && rowInfo.boxes.value(row) == QGridLayoutBox()
| 0 | ||||||||||||||||||||||||
| 1125 | rowData->ignore.setBit(row, true); never executed: rowData->ignore.setBit(row, true); | 0 | ||||||||||||||||||||||||
| 1126 | - | |||||||||||||||||||||||||
| 1127 | if (rowInfo.spacings.value(row).isUser()
| 0 | ||||||||||||||||||||||||
| 1128 | rowData->spacings[row] = rowInfo.spacings.at(row).value(); | - | ||||||||||||||||||||||||
| 1129 | } never executed: else if (!defaultSpacing.isDefault()end of block
| 0 | ||||||||||||||||||||||||
| 1130 | rowData->spacings[row] = defaultSpacing.value(); | - | ||||||||||||||||||||||||
| 1131 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1132 | - | |||||||||||||||||||||||||
| 1133 | rowData->stretches[row] = rowInfo.stretches.value(row).value(); | - | ||||||||||||||||||||||||
| 1134 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1135 | - | |||||||||||||||||||||||||
| 1136 | struct RowAdHocData { | - | ||||||||||||||||||||||||
| 1137 | int q_row; | - | ||||||||||||||||||||||||
| 1138 | unsigned int q_hasButtons : 8; | - | ||||||||||||||||||||||||
| 1139 | unsigned int q_hasNonButtons : 8; | - | ||||||||||||||||||||||||
| 1140 | - | |||||||||||||||||||||||||
| 1141 | inline RowAdHocData() : q_row(-1), q_hasButtons(false), q_hasNonButtons(false) {} never executed: end of block | 0 | ||||||||||||||||||||||||
| 1142 | inline void init(int row) { | - | ||||||||||||||||||||||||
| 1143 | this->q_row = row; | - | ||||||||||||||||||||||||
| 1144 | q_hasButtons = false; | - | ||||||||||||||||||||||||
| 1145 | q_hasNonButtons = false; | - | ||||||||||||||||||||||||
| 1146 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1147 | inline bool hasOnlyButtons() const { return never executed: q_hasButtonsreturn q_hasButtons && !q_hasNonButtons;
never executed: }return q_hasButtons && !q_hasNonButtons; | 0 | ||||||||||||||||||||||||
| 1148 | inline bool hasOnlyNonButtons() const { return never executed: q_hasNonButtonsreturn q_hasNonButtons && !q_hasButtons;
never executed: }return q_hasNonButtons && !q_hasButtons; | 0 | ||||||||||||||||||||||||
| 1149 | }; | - | ||||||||||||||||||||||||
| 1150 | RowAdHocData lastRowAdHocData; | - | ||||||||||||||||||||||||
| 1151 | RowAdHocData nextToLastRowAdHocData; | - | ||||||||||||||||||||||||
| 1152 | RowAdHocData nextToNextToLastRowAdHocData; | - | ||||||||||||||||||||||||
| 1153 | - | |||||||||||||||||||||||||
| 1154 | rowData->hasIgnoreFlag = false; | - | ||||||||||||||||||||||||
| 1155 | for (int row = 0; row < rowInfo.count
| 0 | ||||||||||||||||||||||||
| 1156 | if (rowData->ignore.testBit(row)
| 0 | ||||||||||||||||||||||||
| 1157 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1158 | - | |||||||||||||||||||||||||
| 1159 | QGridLayoutBox &rowBox = rowData->boxes[row]; | - | ||||||||||||||||||||||||
| 1160 | if (styleInfo->isWindow()
| 0 | ||||||||||||||||||||||||
| 1161 | nextToNextToLastRowAdHocData = nextToLastRowAdHocData; | - | ||||||||||||||||||||||||
| 1162 | nextToLastRowAdHocData = lastRowAdHocData; | - | ||||||||||||||||||||||||
| 1163 | lastRowAdHocData.init(row); | - | ||||||||||||||||||||||||
| 1164 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1165 | - | |||||||||||||||||||||||||
| 1166 | bool userRowStretch = rowInfo.stretches.value(row).isUser(); | - | ||||||||||||||||||||||||
| 1167 | int &rowStretch = rowData->stretches[row]; | - | ||||||||||||||||||||||||
| 1168 | - | |||||||||||||||||||||||||
| 1169 | bool hasIgnoreFlag = true; | - | ||||||||||||||||||||||||
| 1170 | for (int column = 0; column < columnInfo.count
| 0 | ||||||||||||||||||||||||
| 1171 | QGridLayoutItem *item = itemAt(row, column, orientation); | - | ||||||||||||||||||||||||
| 1172 | if (item
| 0 | ||||||||||||||||||||||||
| 1173 | int itemRow = item->firstRow(orientation); | - | ||||||||||||||||||||||||
| 1174 | int itemColumn = item->firstColumn(orientation); | - | ||||||||||||||||||||||||
| 1175 | - | |||||||||||||||||||||||||
| 1176 | if (itemRow == row
| 0 | ||||||||||||||||||||||||
| 1177 | int itemStretch = item->stretchFactor(orientation); | - | ||||||||||||||||||||||||
| 1178 | if (!(item->sizePolicy(orientation) & QLayoutPolicy::IgnoreFlag)
| 0 | ||||||||||||||||||||||||
| 1179 | hasIgnoreFlag = false; never executed: hasIgnoreFlag = false; | 0 | ||||||||||||||||||||||||
| 1180 | int itemRowSpan = item->rowSpan(orientation); | - | ||||||||||||||||||||||||
| 1181 | - | |||||||||||||||||||||||||
| 1182 | int effectiveRowSpan = 1; | - | ||||||||||||||||||||||||
| 1183 | for (int i = 1; i < itemRowSpan
| 0 | ||||||||||||||||||||||||
| 1184 | if (!rowData->ignore.testBit(i + itemRow)
| 0 | ||||||||||||||||||||||||
| 1185 | ++ never executed: effectiveRowSpan;++effectiveRowSpan;never executed: ++effectiveRowSpan; | 0 | ||||||||||||||||||||||||
| 1186 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1187 | - | |||||||||||||||||||||||||
| 1188 | QGridLayoutBox *box; | - | ||||||||||||||||||||||||
| 1189 | if (effectiveRowSpan == 1
| 0 | ||||||||||||||||||||||||
| 1190 | box = &rowBox; | - | ||||||||||||||||||||||||
| 1191 | if (!userRowStretch
| 0 | ||||||||||||||||||||||||
| 1192 | rowStretch = qMax(rowStretch, itemStretch); never executed: rowStretch = qMax(rowStretch, itemStretch); | 0 | ||||||||||||||||||||||||
| 1193 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1194 | QGridLayoutMultiCellData &multiCell = | - | ||||||||||||||||||||||||
| 1195 | rowData->multiCellMap[qMakePair(row, itemRowSpan)]; | - | ||||||||||||||||||||||||
| 1196 | box = &multiCell.q_box; | - | ||||||||||||||||||||||||
| 1197 | multiCell.q_stretch = itemStretch; | - | ||||||||||||||||||||||||
| 1198 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1199 | - | |||||||||||||||||||||||||
| 1200 | if (colSizes
| 0 | ||||||||||||||||||||||||
| 1201 | - | |||||||||||||||||||||||||
| 1202 | - | |||||||||||||||||||||||||
| 1203 | - | |||||||||||||||||||||||||
| 1204 | - | |||||||||||||||||||||||||
| 1205 | - | |||||||||||||||||||||||||
| 1206 | - | |||||||||||||||||||||||||
| 1207 | qreal length = colSizes[item->lastColumn(orientation)]; | - | ||||||||||||||||||||||||
| 1208 | if (item->columnSpan(orientation) != 1
| 0 | ||||||||||||||||||||||||
| 1209 | length += colPositions[item->lastColumn(orientation)] - colPositions[item->firstColumn(orientation)]; never executed: length += colPositions[item->lastColumn(orientation)] - colPositions[item->firstColumn(orientation)]; | 0 | ||||||||||||||||||||||||
| 1210 | box->combine(item->box(orientation, length)); | - | ||||||||||||||||||||||||
| 1211 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1212 | box->combine(item->box(orientation)); | - | ||||||||||||||||||||||||
| 1213 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1214 | - | |||||||||||||||||||||||||
| 1215 | if (effectiveRowSpan == 1
| 0 | ||||||||||||||||||||||||
| 1216 | QLayoutPolicy::ControlTypes controls = item->controlTypes(top); | - | ||||||||||||||||||||||||
| 1217 | if (controls & ButtonMask
| 0 | ||||||||||||||||||||||||
| 1218 | lastRowAdHocData.q_hasButtons = true; never executed: lastRowAdHocData.q_hasButtons = true; | 0 | ||||||||||||||||||||||||
| 1219 | if (controls & ~ButtonMask
| 0 | ||||||||||||||||||||||||
| 1220 | lastRowAdHocData.q_hasNonButtons = true; never executed: lastRowAdHocData.q_hasNonButtons = true; | 0 | ||||||||||||||||||||||||
| 1221 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1222 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1223 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1224 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1225 | if (row < rowInfo.boxes.count()
| 0 | ||||||||||||||||||||||||
| 1226 | QGridLayoutBox rowBoxInfo = rowInfo.boxes.at(row); | - | ||||||||||||||||||||||||
| 1227 | rowBoxInfo.normalize(); | - | ||||||||||||||||||||||||
| 1228 | rowBox.q_minimumSize = qMax(rowBox.q_minimumSize, rowBoxInfo.q_minimumSize); | - | ||||||||||||||||||||||||
| 1229 | rowBox.q_maximumSize = qMax(rowBox.q_minimumSize, | - | ||||||||||||||||||||||||
| 1230 | (rowBoxInfo.q_maximumSize != 3.40282346638528859812e+38F ? | - | ||||||||||||||||||||||||
| 1231 | rowBoxInfo.q_maximumSize : rowBox.q_maximumSize)); | - | ||||||||||||||||||||||||
| 1232 | rowBox.q_preferredSize = qBound(rowBox.q_minimumSize, | - | ||||||||||||||||||||||||
| 1233 | qMax(rowBox.q_preferredSize, rowBoxInfo.q_preferredSize), | - | ||||||||||||||||||||||||
| 1234 | rowBox.q_maximumSize); | - | ||||||||||||||||||||||||
| 1235 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1236 | if (hasIgnoreFlag
| 0 | ||||||||||||||||||||||||
| 1237 | rowData->hasIgnoreFlag = true; never executed: rowData->hasIgnoreFlag = true; | 0 | ||||||||||||||||||||||||
| 1238 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1239 | - | |||||||||||||||||||||||||
| 1240 | - | |||||||||||||||||||||||||
| 1241 | - | |||||||||||||||||||||||||
| 1242 | - | |||||||||||||||||||||||||
| 1243 | - | |||||||||||||||||||||||||
| 1244 | bool lastRowIsButtonBox = (lastRowAdHocData.hasOnlyButtons()
| 0 | ||||||||||||||||||||||||
| 1245 | && nextToLastRowAdHocData.hasOnlyNonButtons()
| 0 | ||||||||||||||||||||||||
| 1246 | bool lastTwoRowsIsButtonBox = (lastRowAdHocData.hasOnlyButtons()
| 0 | ||||||||||||||||||||||||
| 1247 | && nextToLastRowAdHocData.hasOnlyButtons()
| 0 | ||||||||||||||||||||||||
| 1248 | && nextToNextToLastRowAdHocData.hasOnlyNonButtons()
| 0 | ||||||||||||||||||||||||
| 1249 | && orientation == Qt::Vertical
| 0 | ||||||||||||||||||||||||
| 1250 | - | |||||||||||||||||||||||||
| 1251 | if (defaultSpacing.isDefault()
| 0 | ||||||||||||||||||||||||
| 1252 | int prevRow = -1; | - | ||||||||||||||||||||||||
| 1253 | for (int row = 0; row < rowInfo.count
| 0 | ||||||||||||||||||||||||
| 1254 | if (rowData->ignore.testBit(row)
| 0 | ||||||||||||||||||||||||
| 1255 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1256 | - | |||||||||||||||||||||||||
| 1257 | if (prevRow != -1
| 0 | ||||||||||||||||||||||||
| 1258 | qreal &rowSpacing = rowData->spacings[prevRow]; | - | ||||||||||||||||||||||||
| 1259 | for (int column = 0; column < columnInfo.count
| 0 | ||||||||||||||||||||||||
| 1260 | QGridLayoutItem *item1 = itemAt(prevRow, column, orientation); | - | ||||||||||||||||||||||||
| 1261 | QGridLayoutItem *item2 = itemAt(row, column, orientation); | - | ||||||||||||||||||||||||
| 1262 | - | |||||||||||||||||||||||||
| 1263 | if (item1
| 0 | ||||||||||||||||||||||||
| 1264 | QLayoutPolicy::ControlTypes controls1 = item1->controlTypes(bottom); | - | ||||||||||||||||||||||||
| 1265 | QLayoutPolicy::ControlTypes controls2 = item2->controlTypes(top); | - | ||||||||||||||||||||||||
| 1266 | - | |||||||||||||||||||||||||
| 1267 | if (controls2 & QLayoutPolicy::PushButton
| 0 | ||||||||||||||||||||||||
| 1268 | if ((row == nextToLastRowAdHocData.q_row
| 0 | ||||||||||||||||||||||||
| 1269 | || (row == lastRowAdHocData.q_row
| 0 | ||||||||||||||||||||||||
| 1270 | controls2 &= ~QLayoutPolicy::PushButton; | - | ||||||||||||||||||||||||
| 1271 | controls2 |= QLayoutPolicy::ButtonBox; | - | ||||||||||||||||||||||||
| 1272 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1273 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1274 | - | |||||||||||||||||||||||||
| 1275 | qreal spacing = styleInfo->combinedLayoutSpacing(controls1, controls2, | - | ||||||||||||||||||||||||
| 1276 | orientation); | - | ||||||||||||||||||||||||
| 1277 | if (orientation == Qt::Horizontal
| 0 | ||||||||||||||||||||||||
| 1278 | qreal width1 = rowData->boxes.at(prevRow).q_minimumSize; | - | ||||||||||||||||||||||||
| 1279 | qreal width2 = rowData->boxes.at(row).q_minimumSize; | - | ||||||||||||||||||||||||
| 1280 | QRectF rect1 = item1->geometryWithin(0.0, 0.0, width1, 3.40282346638528859812e+38F, -1.0, effectiveAlignment(item1)); | - | ||||||||||||||||||||||||
| 1281 | QRectF rect2 = item2->geometryWithin(0.0, 0.0, width2, 3.40282346638528859812e+38F, -1.0, effectiveAlignment(item2)); | - | ||||||||||||||||||||||||
| 1282 | spacing -= (width1 - (rect1.x() + rect1.width())) + rect2.x(); | - | ||||||||||||||||||||||||
| 1283 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1284 | const QGridLayoutBox &box1 = rowData->boxes.at(prevRow); | - | ||||||||||||||||||||||||
| 1285 | const QGridLayoutBox &box2 = rowData->boxes.at(row); | - | ||||||||||||||||||||||||
| 1286 | qreal height1 = box1.q_minimumSize; | - | ||||||||||||||||||||||||
| 1287 | qreal height2 = box2.q_minimumSize; | - | ||||||||||||||||||||||||
| 1288 | qreal rowDescent1 = fixedDescent(box1.q_minimumDescent, | - | ||||||||||||||||||||||||
| 1289 | box1.q_minimumAscent, height1); | - | ||||||||||||||||||||||||
| 1290 | qreal rowDescent2 = fixedDescent(box2.q_minimumDescent, | - | ||||||||||||||||||||||||
| 1291 | box2.q_minimumAscent, height2); | - | ||||||||||||||||||||||||
| 1292 | QRectF rect1 = item1->geometryWithin(0.0, 0.0, 3.40282346638528859812e+38F, height1, | - | ||||||||||||||||||||||||
| 1293 | rowDescent1, effectiveAlignment(item1)); | - | ||||||||||||||||||||||||
| 1294 | QRectF rect2 = item2->geometryWithin(0.0, 0.0, 3.40282346638528859812e+38F, height2, | - | ||||||||||||||||||||||||
| 1295 | rowDescent2, effectiveAlignment(item2)); | - | ||||||||||||||||||||||||
| 1296 | spacing -= (height1 - (rect1.y() + rect1.height())) + rect2.y(); | - | ||||||||||||||||||||||||
| 1297 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1298 | rowSpacing = qMax(spacing, rowSpacing); | - | ||||||||||||||||||||||||
| 1299 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1300 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1301 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1302 | prevRow = row; | - | ||||||||||||||||||||||||
| 1303 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1304 | } never executed: else if (lastRowIsButtonBoxend of block
| 0 | ||||||||||||||||||||||||
| 1305 | - | |||||||||||||||||||||||||
| 1306 | - | |||||||||||||||||||||||||
| 1307 | - | |||||||||||||||||||||||||
| 1308 | - | |||||||||||||||||||||||||
| 1309 | - | |||||||||||||||||||||||||
| 1310 | int prevRow = lastRowIsButtonBox
| 0 | ||||||||||||||||||||||||
| 1311 | : nextToNextToLastRowAdHocData.q_row; | - | ||||||||||||||||||||||||
| 1312 | if (!defaultSpacing.isUser()
| 0 | ||||||||||||||||||||||||
| 1313 | qreal windowMargin = styleInfo->windowMargin(orientation); | - | ||||||||||||||||||||||||
| 1314 | qreal &rowSpacing = rowData->spacings[prevRow]; | - | ||||||||||||||||||||||||
| 1315 | rowSpacing = qMax(windowMargin, rowSpacing); | - | ||||||||||||||||||||||||
| 1316 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1317 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1318 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1319 | - | |||||||||||||||||||||||||
| 1320 | void QGridLayoutEngine::ensureEffectiveFirstAndLastRows() const | - | ||||||||||||||||||||||||
| 1321 | { | - | ||||||||||||||||||||||||
| 1322 | if (q_cachedEffectiveFirstRows[Hor] == -1
| 0 | ||||||||||||||||||||||||
| 1323 | int rowCount = this->rowCount(); | - | ||||||||||||||||||||||||
| 1324 | int columnCount = this->columnCount(); | - | ||||||||||||||||||||||||
| 1325 | - | |||||||||||||||||||||||||
| 1326 | q_cachedEffectiveFirstRows[Ver] = rowCount; | - | ||||||||||||||||||||||||
| 1327 | q_cachedEffectiveFirstRows[Hor] = columnCount; | - | ||||||||||||||||||||||||
| 1328 | q_cachedEffectiveLastRows[Ver] = -1; | - | ||||||||||||||||||||||||
| 1329 | q_cachedEffectiveLastRows[Hor] = -1; | - | ||||||||||||||||||||||||
| 1330 | - | |||||||||||||||||||||||||
| 1331 | for (int i = q_items.count() - 1; i >= 0
| 0 | ||||||||||||||||||||||||
| 1332 | const QGridLayoutItem *item = q_items.at(i); | - | ||||||||||||||||||||||||
| 1333 | - | |||||||||||||||||||||||||
| 1334 | for (int j = 0; j < NOrientations
| 0 | ||||||||||||||||||||||||
| 1335 | Qt::Orientation orientation = (
| 0 | ||||||||||||||||||||||||
| 1336 | if (item->firstRow(orientation) < q_cachedEffectiveFirstRows[j]
| 0 | ||||||||||||||||||||||||
| 1337 | q_cachedEffectiveFirstRows[j] = item->firstRow(orientation); never executed: q_cachedEffectiveFirstRows[j] = item->firstRow(orientation); | 0 | ||||||||||||||||||||||||
| 1338 | if (item->lastRow(orientation) > q_cachedEffectiveLastRows[j]
| 0 | ||||||||||||||||||||||||
| 1339 | q_cachedEffectiveLastRows[j] = item->lastRow(orientation); never executed: q_cachedEffectiveLastRows[j] = item->lastRow(orientation); | 0 | ||||||||||||||||||||||||
| 1340 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1341 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1342 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1343 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1344 | - | |||||||||||||||||||||||||
| 1345 | void QGridLayoutEngine::ensureColumnAndRowData(QGridLayoutRowData *rowData, QGridLayoutBox *totalBox, | - | ||||||||||||||||||||||||
| 1346 | const qreal *colPositions, const qreal *colSizes, | - | ||||||||||||||||||||||||
| 1347 | Qt::Orientation orientation, | - | ||||||||||||||||||||||||
| 1348 | const QAbstractLayoutStyleInfo *styleInfo) const | - | ||||||||||||||||||||||||
| 1349 | { | - | ||||||||||||||||||||||||
| 1350 | const int o = (orientation == Qt::Vertical
| 0 | ||||||||||||||||||||||||
| 1351 | const int cc = columnCount(orientation); | - | ||||||||||||||||||||||||
| 1352 | - | |||||||||||||||||||||||||
| 1353 | const qreal constraint = (colPositions
| 0 | ||||||||||||||||||||||||
| 1354 | qreal &cachedConstraint = q_totalBoxCachedConstraints[o]; | - | ||||||||||||||||||||||||
| 1355 | if (cachedConstraint == constraint
| 0 | ||||||||||||||||||||||||
| 1356 | if (totalBox != &q_totalBoxes[o]
| 0 | ||||||||||||||||||||||||
| 1357 | * never executed: totalBox = q_totalBoxes[o];*totalBox = q_totalBoxes[o];never executed: *totalBox = q_totalBoxes[o]; | 0 | ||||||||||||||||||||||||
| 1358 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1359 | } | - | ||||||||||||||||||||||||
| 1360 | rowData->reset(rowCount(orientation)); | - | ||||||||||||||||||||||||
| 1361 | fillRowData(rowData, colPositions, colSizes, orientation, styleInfo); | - | ||||||||||||||||||||||||
| 1362 | const QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical]; | - | ||||||||||||||||||||||||
| 1363 | rowData->distributeMultiCells(rowInfo, m_snapToPixelGrid); | - | ||||||||||||||||||||||||
| 1364 | *totalBox = rowData->totalBox(0, rowCount(orientation)); | - | ||||||||||||||||||||||||
| 1365 | - | |||||||||||||||||||||||||
| 1366 | if (totalBox != &q_totalBoxes[o]
| 0 | ||||||||||||||||||||||||
| 1367 | q_totalBoxes[o] = *totalBox; never executed: q_totalBoxes[o] = *totalBox; | 0 | ||||||||||||||||||||||||
| 1368 | - | |||||||||||||||||||||||||
| 1369 | cachedConstraint = constraint; | - | ||||||||||||||||||||||||
| 1370 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1371 | - | |||||||||||||||||||||||||
| 1372 | - | |||||||||||||||||||||||||
| 1373 | - | |||||||||||||||||||||||||
| 1374 | - | |||||||||||||||||||||||||
| 1375 | - | |||||||||||||||||||||||||
| 1376 | bool QGridLayoutEngine::ensureDynamicConstraint() const | - | ||||||||||||||||||||||||
| 1377 | { | - | ||||||||||||||||||||||||
| 1378 | if (q_cachedConstraintOrientation == UnknownConstraint
| 0 | ||||||||||||||||||||||||
| 1379 | for (int i = q_items.count() - 1; i >= 0
| 0 | ||||||||||||||||||||||||
| 1380 | QGridLayoutItem *item = q_items.at(i); | - | ||||||||||||||||||||||||
| 1381 | if (item->hasDynamicConstraint()
| 0 | ||||||||||||||||||||||||
| 1382 | Qt::Orientation itemConstraintOrientation = item->dynamicConstraintOrientation(); | - | ||||||||||||||||||||||||
| 1383 | if (q_cachedConstraintOrientation == UnknownConstraint
| 0 | ||||||||||||||||||||||||
| 1384 | q_cachedConstraintOrientation = itemConstraintOrientation; | - | ||||||||||||||||||||||||
| 1385 | } never executed: else if (q_cachedConstraintOrientation != itemConstraintOrientationend of block
| 0 | ||||||||||||||||||||||||
| 1386 | q_cachedConstraintOrientation = UnfeasibleConstraint; | - | ||||||||||||||||||||||||
| 1387 | QMessageLogger(__FILE__, 1581, __PRETTY_FUNCTION__).warning("QGridLayoutEngine: Unfeasible, cannot mix horizontal and" | - | ||||||||||||||||||||||||
| 1388 | " vertical constraint in the same layout"); | - | ||||||||||||||||||||||||
| 1389 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 1390 | } | - | ||||||||||||||||||||||||
| 1391 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1392 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1393 | if (q_cachedConstraintOrientation == UnknownConstraint
| 0 | ||||||||||||||||||||||||
| 1394 | q_cachedConstraintOrientation = NoConstraint; never executed: q_cachedConstraintOrientation = NoConstraint; | 0 | ||||||||||||||||||||||||
| 1395 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1396 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 1397 | } | - | ||||||||||||||||||||||||
| 1398 | - | |||||||||||||||||||||||||
| 1399 | bool QGridLayoutEngine::hasDynamicConstraint() const | - | ||||||||||||||||||||||||
| 1400 | { | - | ||||||||||||||||||||||||
| 1401 | if (!ensureDynamicConstraint()
| 0 | ||||||||||||||||||||||||
| 1402 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 1403 | return never executed: q_cachedConstraintOrientation != NoConstraint;return q_cachedConstraintOrientation != NoConstraint;never executed: return q_cachedConstraintOrientation != NoConstraint; | 0 | ||||||||||||||||||||||||
| 1404 | } | - | ||||||||||||||||||||||||
| 1405 | - | |||||||||||||||||||||||||
| 1406 | - | |||||||||||||||||||||||||
| 1407 | - | |||||||||||||||||||||||||
| 1408 | - | |||||||||||||||||||||||||
| 1409 | Qt::Orientation QGridLayoutEngine::constraintOrientation() const | - | ||||||||||||||||||||||||
| 1410 | { | - | ||||||||||||||||||||||||
| 1411 | (void)ensureDynamicConstraint(); | - | ||||||||||||||||||||||||
| 1412 | return never executed: (Qt::Orientation)q_cachedConstraintOrientation;return (Qt::Orientation)q_cachedConstraintOrientation;never executed: return (Qt::Orientation)q_cachedConstraintOrientation; | 0 | ||||||||||||||||||||||||
| 1413 | } | - | ||||||||||||||||||||||||
| 1414 | - | |||||||||||||||||||||||||
| 1415 | void QGridLayoutEngine::ensureGeometries(const QSizeF &size, | - | ||||||||||||||||||||||||
| 1416 | const QAbstractLayoutStyleInfo *styleInfo) const | - | ||||||||||||||||||||||||
| 1417 | { | - | ||||||||||||||||||||||||
| 1418 | if (q_cachedSize == size
| 0 | ||||||||||||||||||||||||
| 1419 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1420 | - | |||||||||||||||||||||||||
| 1421 | q_cachedSize = size; | - | ||||||||||||||||||||||||
| 1422 | - | |||||||||||||||||||||||||
| 1423 | q_xx.resize(columnCount()); | - | ||||||||||||||||||||||||
| 1424 | q_widths.resize(columnCount()); | - | ||||||||||||||||||||||||
| 1425 | q_yy.resize(rowCount()); | - | ||||||||||||||||||||||||
| 1426 | q_heights.resize(rowCount()); | - | ||||||||||||||||||||||||
| 1427 | q_descents.resize(rowCount()); | - | ||||||||||||||||||||||||
| 1428 | - | |||||||||||||||||||||||||
| 1429 | if (constraintOrientation() != Qt::Horizontal
| 0 | ||||||||||||||||||||||||
| 1430 | - | |||||||||||||||||||||||||
| 1431 | ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], __null, __null, Qt::Horizontal, styleInfo); | - | ||||||||||||||||||||||||
| 1432 | - | |||||||||||||||||||||||||
| 1433 | - | |||||||||||||||||||||||||
| 1434 | q_columnData.calculateGeometries(0, columnCount(), size.width(), q_xx.data(), q_widths.data(), | - | ||||||||||||||||||||||||
| 1435 | 0, q_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); | - | ||||||||||||||||||||||||
| 1436 | ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], q_xx.data(), q_widths.data(), Qt::Vertical, styleInfo); | - | ||||||||||||||||||||||||
| 1437 | - | |||||||||||||||||||||||||
| 1438 | q_rowData.calculateGeometries(0, rowCount(), size.height(), q_yy.data(), q_heights.data(), | - | ||||||||||||||||||||||||
| 1439 | q_descents.data(), q_totalBoxes[Ver], q_infos[Ver], m_snapToPixelGrid); | - | ||||||||||||||||||||||||
| 1440 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1441 | - | |||||||||||||||||||||||||
| 1442 | ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], __null, __null, Qt::Vertical, styleInfo); | - | ||||||||||||||||||||||||
| 1443 | - | |||||||||||||||||||||||||
| 1444 | - | |||||||||||||||||||||||||
| 1445 | q_rowData.calculateGeometries(0, rowCount(), size.height(), q_yy.data(), q_heights.data(), | - | ||||||||||||||||||||||||
| 1446 | q_descents.data(), q_totalBoxes[Ver], q_infos[Ver], m_snapToPixelGrid); | - | ||||||||||||||||||||||||
| 1447 | ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], q_yy.data(), q_heights.data(), Qt::Horizontal, styleInfo); | - | ||||||||||||||||||||||||
| 1448 | - | |||||||||||||||||||||||||
| 1449 | q_columnData.calculateGeometries(0, columnCount(), size.width(), q_xx.data(), q_widths.data(), | - | ||||||||||||||||||||||||
| 1450 | 0, q_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); | - | ||||||||||||||||||||||||
| 1451 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1452 | } | - | ||||||||||||||||||||||||
| 1453 | - | |||||||||||||||||||||||||
| 1454 | - | |||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |