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