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