| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickpositioners.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||||||||
| 5 | ** | - | ||||||||||||||||||||||||
| 6 | ** This file is part of the QtQuick module of the Qt Toolkit. | - | ||||||||||||||||||||||||
| 7 | ** | - | ||||||||||||||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||||||||
| 16 | ** | - | ||||||||||||||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||
| 19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||||||||
| 24 | ** | - | ||||||||||||||||||||||||
| 25 | ** GNU General Public License Usage | - | ||||||||||||||||||||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||||||||
| 35 | ** | - | ||||||||||||||||||||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||
| 37 | ** | - | ||||||||||||||||||||||||
| 38 | ****************************************************************************/ | - | ||||||||||||||||||||||||
| 39 | - | |||||||||||||||||||||||||
| 40 | #include "qquickpositioners_p.h" | - | ||||||||||||||||||||||||
| 41 | #include "qquickpositioners_p_p.h" | - | ||||||||||||||||||||||||
| 42 | - | |||||||||||||||||||||||||
| 43 | #include <QtQml/qqml.h> | - | ||||||||||||||||||||||||
| 44 | #include <QtQml/qqmlinfo.h> | - | ||||||||||||||||||||||||
| 45 | #include <QtCore/qcoreapplication.h> | - | ||||||||||||||||||||||||
| 46 | - | |||||||||||||||||||||||||
| 47 | #include <QtQuick/private/qquicktransition_p.h> | - | ||||||||||||||||||||||||
| 48 | - | |||||||||||||||||||||||||
| 49 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
| 50 | - | |||||||||||||||||||||||||
| 51 | static const QQuickItemPrivate::ChangeTypes watchedChanges | - | ||||||||||||||||||||||||
| 52 | = QQuickItemPrivate::Geometry | - | ||||||||||||||||||||||||
| 53 | | QQuickItemPrivate::SiblingOrder | - | ||||||||||||||||||||||||
| 54 | | QQuickItemPrivate::Visibility | - | ||||||||||||||||||||||||
| 55 | | QQuickItemPrivate::Destroyed; | - | ||||||||||||||||||||||||
| 56 | - | |||||||||||||||||||||||||
| 57 | void QQuickBasePositionerPrivate::watchChanges(QQuickItem *other) | - | ||||||||||||||||||||||||
| 58 | { | - | ||||||||||||||||||||||||
| 59 | QQuickItemPrivate *otherPrivate = QQuickItemPrivate::get(other); | - | ||||||||||||||||||||||||
| 60 | otherPrivate->addItemChangeListener(this, watchedChanges); | - | ||||||||||||||||||||||||
| 61 | } executed 37586 times by 23 tests: end of blockExecuted by:
| 37586 | ||||||||||||||||||||||||
| 62 | - | |||||||||||||||||||||||||
| 63 | void QQuickBasePositionerPrivate::unwatchChanges(QQuickItem* other) | - | ||||||||||||||||||||||||
| 64 | { | - | ||||||||||||||||||||||||
| 65 | QQuickItemPrivate *otherPrivate = QQuickItemPrivate::get(other); | - | ||||||||||||||||||||||||
| 66 | otherPrivate->removeItemChangeListener(this, watchedChanges); | - | ||||||||||||||||||||||||
| 67 | } executed 37574 times by 21 tests: end of blockExecuted by:
| 37574 | ||||||||||||||||||||||||
| 68 | - | |||||||||||||||||||||||||
| 69 | - | |||||||||||||||||||||||||
| 70 | QQuickBasePositioner::PositionedItem::PositionedItem(QQuickItem *i) | - | ||||||||||||||||||||||||
| 71 | : item(i) | - | ||||||||||||||||||||||||
| 72 | , transitionableItem(nullptr) | - | ||||||||||||||||||||||||
| 73 | , index(-1) | - | ||||||||||||||||||||||||
| 74 | , isNew(false) | - | ||||||||||||||||||||||||
| 75 | , isVisible(true) | - | ||||||||||||||||||||||||
| 76 | , topPadding(0) | - | ||||||||||||||||||||||||
| 77 | , leftPadding(0) | - | ||||||||||||||||||||||||
| 78 | , rightPadding(0) | - | ||||||||||||||||||||||||
| 79 | , bottomPadding(0) | - | ||||||||||||||||||||||||
| 80 | { | - | ||||||||||||||||||||||||
| 81 | } executed 121175 times by 23 tests: end of blockExecuted by:
| 121175 | ||||||||||||||||||||||||
| 82 | - | |||||||||||||||||||||||||
| 83 | QQuickBasePositioner::PositionedItem::~PositionedItem() | - | ||||||||||||||||||||||||
| 84 | { | - | ||||||||||||||||||||||||
| 85 | delete transitionableItem; | - | ||||||||||||||||||||||||
| 86 | } executed 121175 times by 23 tests: end of blockExecuted by:
| 121175 | ||||||||||||||||||||||||
| 87 | - | |||||||||||||||||||||||||
| 88 | qreal QQuickBasePositioner::PositionedItem::itemX() const | - | ||||||||||||||||||||||||
| 89 | { | - | ||||||||||||||||||||||||
| 90 | return transitionableItem ? transitionableItem->itemX() : item->x(); executed 231322 times by 21 tests: return transitionableItem ? transitionableItem->itemX() : item->x();Executed by:
| 231322 | ||||||||||||||||||||||||
| 91 | } | - | ||||||||||||||||||||||||
| 92 | - | |||||||||||||||||||||||||
| 93 | qreal QQuickBasePositioner::PositionedItem::itemY() const | - | ||||||||||||||||||||||||
| 94 | { | - | ||||||||||||||||||||||||
| 95 | return transitionableItem ? transitionableItem->itemY() : item->y(); executed 116212 times by 21 tests: return transitionableItem ? transitionableItem->itemY() : item->y();Executed by:
| 116212 | ||||||||||||||||||||||||
| 96 | } | - | ||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||
| 98 | void QQuickBasePositioner::PositionedItem::moveTo(const QPointF &pos) | - | ||||||||||||||||||||||||
| 99 | { | - | ||||||||||||||||||||||||
| 100 | if (transitionableItem)
| 6552-23629 | ||||||||||||||||||||||||
| 101 | transitionableItem->moveTo(pos); executed 6552 times by 1 test: transitionableItem->moveTo(pos);Executed by:
| 6552 | ||||||||||||||||||||||||
| 102 | else | - | ||||||||||||||||||||||||
| 103 | item->setPosition(pos); executed 23629 times by 19 tests: item->setPosition(pos);Executed by:
| 23629 | ||||||||||||||||||||||||
| 104 | } | - | ||||||||||||||||||||||||
| 105 | - | |||||||||||||||||||||||||
| 106 | void QQuickBasePositioner::PositionedItem::transitionNextReposition(QQuickItemViewTransitioner *transitioner, QQuickItemViewTransitioner::TransitionType type, bool asTarget) | - | ||||||||||||||||||||||||
| 107 | { | - | ||||||||||||||||||||||||
| 108 | if (!transitioner)
| 0-7488 | ||||||||||||||||||||||||
| 109 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 110 | if (!transitionableItem)
| 3248-4240 | ||||||||||||||||||||||||
| 111 | transitionableItem = new QQuickItemViewTransitionableItem(item); executed 4240 times by 2 tests: transitionableItem = new QQuickItemViewTransitionableItem(item);Executed by:
| 4240 | ||||||||||||||||||||||||
| 112 | transitioner->transitionNextReposition(transitionableItem, type, asTarget); | - | ||||||||||||||||||||||||
| 113 | } executed 7488 times by 2 tests: end of blockExecuted by:
| 7488 | ||||||||||||||||||||||||
| 114 | - | |||||||||||||||||||||||||
| 115 | bool QQuickBasePositioner::PositionedItem::prepareTransition(QQuickItemViewTransitioner *transitioner, const QRectF &viewBounds) | - | ||||||||||||||||||||||||
| 116 | { | - | ||||||||||||||||||||||||
| 117 | return transitionableItem ? transitionableItem->prepareTransition(transitioner, index, viewBounds) : false; executed 8060 times by 2 tests: return transitionableItem ? transitionableItem->prepareTransition(transitioner, index, viewBounds) : false;Executed by:
| 8060 | ||||||||||||||||||||||||
| 118 | } | - | ||||||||||||||||||||||||
| 119 | - | |||||||||||||||||||||||||
| 120 | void QQuickBasePositioner::PositionedItem::startTransition(QQuickItemViewTransitioner *transitioner) | - | ||||||||||||||||||||||||
| 121 | { | - | ||||||||||||||||||||||||
| 122 | if (transitionableItem)
| 572-7488 | ||||||||||||||||||||||||
| 123 | transitionableItem->startTransition(transitioner, index); executed 7488 times by 2 tests: transitionableItem->startTransition(transitioner, index);Executed by:
| 7488 | ||||||||||||||||||||||||
| 124 | } executed 8060 times by 2 tests: end of blockExecuted by:
| 8060 | ||||||||||||||||||||||||
| 125 | - | |||||||||||||||||||||||||
| 126 | void QQuickBasePositioner::PositionedItem::updatePadding(qreal lp, qreal tp, qreal rp, qreal bp) | - | ||||||||||||||||||||||||
| 127 | { | - | ||||||||||||||||||||||||
| 128 | leftPadding = lp; | - | ||||||||||||||||||||||||
| 129 | topPadding = tp; | - | ||||||||||||||||||||||||
| 130 | rightPadding = rp; | - | ||||||||||||||||||||||||
| 131 | bottomPadding = bp; | - | ||||||||||||||||||||||||
| 132 | } executed 120048 times by 21 tests: end of blockExecuted by:
| 120048 | ||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||
| 134 | QQuickBasePositioner::QQuickBasePositioner(PositionerType at, QQuickItem *parent) | - | ||||||||||||||||||||||||
| 135 | : QQuickImplicitSizeItem(*(new QQuickBasePositionerPrivate), parent) | - | ||||||||||||||||||||||||
| 136 | { | - | ||||||||||||||||||||||||
| 137 | Q_D(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 138 | d->init(at); | - | ||||||||||||||||||||||||
| 139 | } executed 11162 times by 16 tests: end of blockExecuted by:
| 11162 | ||||||||||||||||||||||||
| 140 | /*! | - | ||||||||||||||||||||||||
| 141 | \internal | - | ||||||||||||||||||||||||
| 142 | \class QQuickBasePositioner | - | ||||||||||||||||||||||||
| 143 | \brief For specifying a base for QQuickGraphics layouts | - | ||||||||||||||||||||||||
| 144 | - | |||||||||||||||||||||||||
| 145 | To create a QQuickGraphics Positioner, simply subclass QQuickBasePositioner and implement | - | ||||||||||||||||||||||||
| 146 | doLayout(), which is automatically called when the layout might need | - | ||||||||||||||||||||||||
| 147 | updating. In doLayout() use the setX and setY functions from QQuickBasePositioner, and the | - | ||||||||||||||||||||||||
| 148 | base class will apply the positions along with the appropriate transitions. The items to | - | ||||||||||||||||||||||||
| 149 | position are provided in order as the protected member positionedItems. | - | ||||||||||||||||||||||||
| 150 | - | |||||||||||||||||||||||||
| 151 | You also need to set a PositionerType, to declare whether you are positioning the x, y or both | - | ||||||||||||||||||||||||
| 152 | for the child items. Depending on the chosen type, only x or y changes will be applied. | - | ||||||||||||||||||||||||
| 153 | - | |||||||||||||||||||||||||
| 154 | Note that the subclass is responsible for adding the spacing in between items. | - | ||||||||||||||||||||||||
| 155 | - | |||||||||||||||||||||||||
| 156 | Positioning is batched and synchronized with painting to reduce the number of | - | ||||||||||||||||||||||||
| 157 | calculations needed. This means that positioners may not reposition items immediately | - | ||||||||||||||||||||||||
| 158 | when changes occur, but it will have moved by the next frame. | - | ||||||||||||||||||||||||
| 159 | */ | - | ||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||
| 161 | QQuickBasePositioner::QQuickBasePositioner(QQuickBasePositionerPrivate &dd, PositionerType at, QQuickItem *parent) | - | ||||||||||||||||||||||||
| 162 | : QQuickImplicitSizeItem(dd, parent) | - | ||||||||||||||||||||||||
| 163 | { | - | ||||||||||||||||||||||||
| 164 | Q_D(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 165 | d->init(at); | - | ||||||||||||||||||||||||
| 166 | } executed 1234 times by 15 tests: end of blockExecuted by:
| 1234 | ||||||||||||||||||||||||
| 167 | - | |||||||||||||||||||||||||
| 168 | QQuickBasePositioner::~QQuickBasePositioner() | - | ||||||||||||||||||||||||
| 169 | { | - | ||||||||||||||||||||||||
| 170 | Q_D(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 171 | delete d->transitioner; | - | ||||||||||||||||||||||||
| 172 | for (int i = 0; i < positionedItems.count(); ++i)
| 12382-37085 | ||||||||||||||||||||||||
| 173 | d->unwatchChanges(positionedItems.at(i).item); executed 37085 times by 19 tests: d->unwatchChanges(positionedItems.at(i).item);Executed by:
| 37085 | ||||||||||||||||||||||||
| 174 | for (int i = 0; i < unpositionedItems.count(); ++i)
| 207-12382 | ||||||||||||||||||||||||
| 175 | d->unwatchChanges(unpositionedItems.at(i).item); executed 207 times by 8 tests: d->unwatchChanges(unpositionedItems.at(i).item);Executed by:
| 207 | ||||||||||||||||||||||||
| 176 | clearPositionedItems(&positionedItems); | - | ||||||||||||||||||||||||
| 177 | clearPositionedItems(&unpositionedItems); | - | ||||||||||||||||||||||||
| 178 | } executed 12382 times by 21 tests: end of blockExecuted by:
| 12382 | ||||||||||||||||||||||||
| 179 | - | |||||||||||||||||||||||||
| 180 | void QQuickBasePositioner::updatePolish() | - | ||||||||||||||||||||||||
| 181 | { | - | ||||||||||||||||||||||||
| 182 | Q_D(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 183 | if (d->positioningDirty)
| 5513-27136 | ||||||||||||||||||||||||
| 184 | prePositioning(); executed 27136 times by 9 tests: prePositioning();Executed by:
| 27136 | ||||||||||||||||||||||||
| 185 | } executed 32649 times by 19 tests: end of blockExecuted by:
| 32649 | ||||||||||||||||||||||||
| 186 | - | |||||||||||||||||||||||||
| 187 | qreal QQuickBasePositioner::spacing() const | - | ||||||||||||||||||||||||
| 188 | { | - | ||||||||||||||||||||||||
| 189 | Q_D(const QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 190 | return d->spacing; executed 155980 times by 21 tests: return d->spacing;Executed by:
| 155980 | ||||||||||||||||||||||||
| 191 | } | - | ||||||||||||||||||||||||
| 192 | - | |||||||||||||||||||||||||
| 193 | void QQuickBasePositioner::setSpacing(qreal s) | - | ||||||||||||||||||||||||
| 194 | { | - | ||||||||||||||||||||||||
| 195 | Q_D(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 196 | if (s == d->spacing)
| 2-432 | ||||||||||||||||||||||||
| 197 | return; executed 2 times by 1 test: return;Executed by:
| 2 | ||||||||||||||||||||||||
| 198 | d->spacing = s; | - | ||||||||||||||||||||||||
| 199 | d->setPositioningDirty(); | - | ||||||||||||||||||||||||
| 200 | emit spacingChanged(); | - | ||||||||||||||||||||||||
| 201 | } executed 432 times by 9 tests: end of blockExecuted by:
| 432 | ||||||||||||||||||||||||
| 202 | - | |||||||||||||||||||||||||
| 203 | QQuickTransition *QQuickBasePositioner::populate() const | - | ||||||||||||||||||||||||
| 204 | { | - | ||||||||||||||||||||||||
| 205 | Q_D(const QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 206 | return d->transitioner ? d->transitioner->populateTransition : nullptr; never executed: return d->transitioner ? d->transitioner->populateTransition : nullptr; | 0 | ||||||||||||||||||||||||
| 207 | } | - | ||||||||||||||||||||||||
| 208 | - | |||||||||||||||||||||||||
| 209 | void QQuickBasePositioner::setPopulate(QQuickTransition *transition) | - | ||||||||||||||||||||||||
| 210 | { | - | ||||||||||||||||||||||||
| 211 | Q_D(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 212 | if (!d->transitioner)
| 20-1024 | ||||||||||||||||||||||||
| 213 | d->transitioner = new QQuickItemViewTransitioner; executed 1024 times by 1 test: d->transitioner = new QQuickItemViewTransitioner;Executed by:
| 1024 | ||||||||||||||||||||||||
| 214 | if (d->transitioner->populateTransition != transition) {
| 0-1044 | ||||||||||||||||||||||||
| 215 | d->transitioner->populateTransition = transition; | - | ||||||||||||||||||||||||
| 216 | emit populateChanged(); | - | ||||||||||||||||||||||||
| 217 | } executed 1044 times by 1 test: end of blockExecuted by:
| 1044 | ||||||||||||||||||||||||
| 218 | } executed 1044 times by 1 test: end of blockExecuted by:
| 1044 | ||||||||||||||||||||||||
| 219 | - | |||||||||||||||||||||||||
| 220 | QQuickTransition *QQuickBasePositioner::move() const | - | ||||||||||||||||||||||||
| 221 | { | - | ||||||||||||||||||||||||
| 222 | Q_D(const QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 223 | return d->transitioner ? d->transitioner->displacedTransition : nullptr; executed 4 times by 1 test: return d->transitioner ? d->transitioner->displacedTransition : nullptr;Executed by:
| 4 | ||||||||||||||||||||||||
| 224 | } | - | ||||||||||||||||||||||||
| 225 | - | |||||||||||||||||||||||||
| 226 | void QQuickBasePositioner::setMove(QQuickTransition *mt) | - | ||||||||||||||||||||||||
| 227 | { | - | ||||||||||||||||||||||||
| 228 | Q_D(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 229 | if (!d->transitioner)
| 32-1032 | ||||||||||||||||||||||||
| 230 | d->transitioner = new QQuickItemViewTransitioner; executed 32 times by 2 tests: d->transitioner = new QQuickItemViewTransitioner;Executed by:
| 32 | ||||||||||||||||||||||||
| 231 | if (mt == d->transitioner->displacedTransition)
| 2-1062 | ||||||||||||||||||||||||
| 232 | return; executed 2 times by 1 test: return;Executed by:
| 2 | ||||||||||||||||||||||||
| 233 | - | |||||||||||||||||||||||||
| 234 | d->transitioner->displacedTransition = mt; | - | ||||||||||||||||||||||||
| 235 | emit moveChanged(); | - | ||||||||||||||||||||||||
| 236 | } executed 1062 times by 2 tests: end of blockExecuted by:
| 1062 | ||||||||||||||||||||||||
| 237 | - | |||||||||||||||||||||||||
| 238 | QQuickTransition *QQuickBasePositioner::add() const | - | ||||||||||||||||||||||||
| 239 | { | - | ||||||||||||||||||||||||
| 240 | Q_D(const QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 241 | return d->transitioner ? d->transitioner->addTransition : nullptr; executed 4 times by 1 test: return d->transitioner ? d->transitioner->addTransition : nullptr;Executed by:
| 4 | ||||||||||||||||||||||||
| 242 | } | - | ||||||||||||||||||||||||
| 243 | - | |||||||||||||||||||||||||
| 244 | void QQuickBasePositioner::setAdd(QQuickTransition *add) | - | ||||||||||||||||||||||||
| 245 | { | - | ||||||||||||||||||||||||
| 246 | Q_D(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 247 | if (!d->transitioner)
| 2-1054 | ||||||||||||||||||||||||
| 248 | d->transitioner = new QQuickItemViewTransitioner; executed 2 times by 1 test: d->transitioner = new QQuickItemViewTransitioner;Executed by:
| 2 | ||||||||||||||||||||||||
| 249 | if (add == d->transitioner->addTransition)
| 2-1054 | ||||||||||||||||||||||||
| 250 | return; executed 2 times by 1 test: return;Executed by:
| 2 | ||||||||||||||||||||||||
| 251 | - | |||||||||||||||||||||||||
| 252 | d->transitioner->addTransition = add; | - | ||||||||||||||||||||||||
| 253 | emit addChanged(); | - | ||||||||||||||||||||||||
| 254 | } executed 1054 times by 1 test: end of blockExecuted by:
| 1054 | ||||||||||||||||||||||||
| 255 | - | |||||||||||||||||||||||||
| 256 | void QQuickBasePositioner::componentComplete() | - | ||||||||||||||||||||||||
| 257 | { | - | ||||||||||||||||||||||||
| 258 | Q_D(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 259 | QQuickItem::componentComplete(); | - | ||||||||||||||||||||||||
| 260 | if (d->transitioner)
| 1058-11338 | ||||||||||||||||||||||||
| 261 | d->transitioner->setPopulateTransitionEnabled(true); executed 1058 times by 2 tests: d->transitioner->setPopulateTransitionEnabled(true);Executed by:
| 1058 | ||||||||||||||||||||||||
| 262 | positionedItems.reserve(childItems().count()); | - | ||||||||||||||||||||||||
| 263 | prePositioning(); | - | ||||||||||||||||||||||||
| 264 | if (d->transitioner)
| 1058-11338 | ||||||||||||||||||||||||
| 265 | d->transitioner->setPopulateTransitionEnabled(false); executed 1058 times by 2 tests: d->transitioner->setPopulateTransitionEnabled(false);Executed by:
| 1058 | ||||||||||||||||||||||||
| 266 | } executed 12396 times by 23 tests: end of blockExecuted by:
| 12396 | ||||||||||||||||||||||||
| 267 | - | |||||||||||||||||||||||||
| 268 | void QQuickBasePositioner::itemChange(ItemChange change, const ItemChangeData &value) | - | ||||||||||||||||||||||||
| 269 | { | - | ||||||||||||||||||||||||
| 270 | Q_D(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 271 | if (change == ItemChildAddedChange) {
| 38962-49574 | ||||||||||||||||||||||||
| 272 | d->setPositioningDirty(); | - | ||||||||||||||||||||||||
| 273 | } else if (change == ItemChildRemovedChange) { executed 38962 times by 23 tests: end of blockExecuted by:
| 338-49236 | ||||||||||||||||||||||||
| 274 | QQuickItem *child = value.item; | - | ||||||||||||||||||||||||
| 275 | QQuickBasePositioner::PositionedItem posItem(child); | - | ||||||||||||||||||||||||
| 276 | int idx = positionedItems.find(posItem); | - | ||||||||||||||||||||||||
| 277 | if (idx >= 0) {
| 68-270 | ||||||||||||||||||||||||
| 278 | d->unwatchChanges(child); | - | ||||||||||||||||||||||||
| 279 | removePositionedItem(&positionedItems, idx); | - | ||||||||||||||||||||||||
| 280 | } else if ((idx = unpositionedItems.find(posItem)) >= 0) { executed 270 times by 3 tests: end of blockExecuted by:
| 12-270 | ||||||||||||||||||||||||
| 281 | d->unwatchChanges(child); | - | ||||||||||||||||||||||||
| 282 | removePositionedItem(&unpositionedItems, idx); | - | ||||||||||||||||||||||||
| 283 | } executed 12 times by 2 tests: end of blockExecuted by:
| 12 | ||||||||||||||||||||||||
| 284 | d->setPositioningDirty(); | - | ||||||||||||||||||||||||
| 285 | } executed 338 times by 5 tests: end of blockExecuted by:
| 338 | ||||||||||||||||||||||||
| 286 | - | |||||||||||||||||||||||||
| 287 | QQuickItem::itemChange(change, value); | - | ||||||||||||||||||||||||
| 288 | } executed 88536 times by 23 tests: end of blockExecuted by:
| 88536 | ||||||||||||||||||||||||
| 289 | - | |||||||||||||||||||||||||
| 290 | void QQuickBasePositioner::forceLayout() | - | ||||||||||||||||||||||||
| 291 | { | - | ||||||||||||||||||||||||
| 292 | updatePolish(); | - | ||||||||||||||||||||||||
| 293 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 294 | - | |||||||||||||||||||||||||
| 295 | void QQuickBasePositioner::prePositioning() | - | ||||||||||||||||||||||||
| 296 | { | - | ||||||||||||||||||||||||
| 297 | Q_D(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 298 | if (!isComponentComplete())
| 148-39652 | ||||||||||||||||||||||||
| 299 | return; executed 148 times by 6 tests: return;Executed by:
| 148 | ||||||||||||||||||||||||
| 300 | - | |||||||||||||||||||||||||
| 301 | if (d->doingPositioning)
| 0-39652 | ||||||||||||||||||||||||
| 302 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 303 | - | |||||||||||||||||||||||||
| 304 | d->positioningDirty = false; | - | ||||||||||||||||||||||||
| 305 | d->doingPositioning = true; | - | ||||||||||||||||||||||||
| 306 | //Need to order children by creation order modified by stacking order | - | ||||||||||||||||||||||||
| 307 | QList<QQuickItem *> children = childItems(); | - | ||||||||||||||||||||||||
| 308 | - | |||||||||||||||||||||||||
| 309 | QPODVector<PositionedItem,8> oldItems; | - | ||||||||||||||||||||||||
| 310 | positionedItems.copyAndClear(oldItems); | - | ||||||||||||||||||||||||
| 311 | for (int ii = 0; ii < unpositionedItems.count(); ii++)
| 104-39652 | ||||||||||||||||||||||||
| 312 | oldItems.append(unpositionedItems[ii]); executed 104 times by 5 tests: oldItems.append(unpositionedItems[ii]);Executed by:
| 104 | ||||||||||||||||||||||||
| 313 | unpositionedItems.clear(); | - | ||||||||||||||||||||||||
| 314 | int addedIndex = -1; | - | ||||||||||||||||||||||||
| 315 | - | |||||||||||||||||||||||||
| 316 | for (int ii = 0; ii < children.count(); ++ii) {
| 39652-122567 | ||||||||||||||||||||||||
| 317 | QQuickItem *child = children.at(ii); | - | ||||||||||||||||||||||||
| 318 | if (QQuickItemPrivate::get(child)->isTransparentForPositioner())
| 1730-120837 | ||||||||||||||||||||||||
| 319 | continue; executed 1730 times by 9 tests: continue;Executed by:
| 1730 | ||||||||||||||||||||||||
| 320 | QQuickItemPrivate *childPrivate = QQuickItemPrivate::get(child); | - | ||||||||||||||||||||||||
| 321 | PositionedItem posItem(child); | - | ||||||||||||||||||||||||
| 322 | int wIdx = oldItems.find(posItem); | - | ||||||||||||||||||||||||
| 323 | if (wIdx < 0) {
| 37586-83251 | ||||||||||||||||||||||||
| 324 | d->watchChanges(child); | - | ||||||||||||||||||||||||
| 325 | posItem.isNew = true; | - | ||||||||||||||||||||||||
| 326 | if (!childPrivate->explicitVisible || !child->width() || !child->height()) {
| 0-37520 | ||||||||||||||||||||||||
| 327 | posItem.isVisible = false; | - | ||||||||||||||||||||||||
| 328 | posItem.index = -1; | - | ||||||||||||||||||||||||
| 329 | unpositionedItems.append(posItem); | - | ||||||||||||||||||||||||
| 330 | } else { executed 258 times by 8 tests: end of blockExecuted by:
| 258 | ||||||||||||||||||||||||
| 331 | posItem.index = positionedItems.count(); | - | ||||||||||||||||||||||||
| 332 | positionedItems.append(posItem); | - | ||||||||||||||||||||||||
| 333 | - | |||||||||||||||||||||||||
| 334 | if (d->transitioner) {
| 4244-33084 | ||||||||||||||||||||||||
| 335 | if (addedIndex < 0)
| 450-3794 | ||||||||||||||||||||||||
| 336 | addedIndex = posItem.index; executed 450 times by 2 tests: addedIndex = posItem.index;Executed by:
| 450 | ||||||||||||||||||||||||
| 337 | PositionedItem *theItem = &positionedItems[positionedItems.count()-1]; | - | ||||||||||||||||||||||||
| 338 | if (d->transitioner->canTransition(QQuickItemViewTransitioner::PopulateTransition, true))
| 536-3708 | ||||||||||||||||||||||||
| 339 | theItem->transitionNextReposition(d->transitioner, QQuickItemViewTransitioner::PopulateTransition, true); executed 536 times by 1 test: theItem->transitionNextReposition(d->transitioner, QQuickItemViewTransitioner::PopulateTransition, true);Executed by:
| 536 | ||||||||||||||||||||||||
| 340 | else if (!d->transitioner->populateTransitionEnabled())
| 572-3136 | ||||||||||||||||||||||||
| 341 | theItem->transitionNextReposition(d->transitioner, QQuickItemViewTransitioner::AddTransition, true); executed 3136 times by 1 test: theItem->transitionNextReposition(d->transitioner, QQuickItemViewTransitioner::AddTransition, true);Executed by:
| 3136 | ||||||||||||||||||||||||
| 342 | } executed 4244 times by 2 tests: end of blockExecuted by:
| 4244 | ||||||||||||||||||||||||
| 343 | } executed 37328 times by 21 tests: end of blockExecuted by:
| 37328 | ||||||||||||||||||||||||
| 344 | } else { | - | ||||||||||||||||||||||||
| 345 | PositionedItem *item = &oldItems[wIdx]; | - | ||||||||||||||||||||||||
| 346 | // Items are only omitted from positioning if they are explicitly hidden | - | ||||||||||||||||||||||||
| 347 | // i.e. their positioning is not affected if an ancestor is hidden. | - | ||||||||||||||||||||||||
| 348 | if (!childPrivate->explicitVisible || !child->width() || !child->height()) {
| 0-83183 | ||||||||||||||||||||||||
| 349 | item->isVisible = false; | - | ||||||||||||||||||||||||
| 350 | item->index = -1; | - | ||||||||||||||||||||||||
| 351 | unpositionedItems.append(*item); | - | ||||||||||||||||||||||||
| 352 | } else if (!item->isVisible) { executed 69 times by 4 tests: end of blockExecuted by:
| 41-83141 | ||||||||||||||||||||||||
| 353 | // item changed from non-visible to visible, treat it as a "new" item | - | ||||||||||||||||||||||||
| 354 | item->isVisible = true; | - | ||||||||||||||||||||||||
| 355 | item->isNew = true; | - | ||||||||||||||||||||||||
| 356 | item->index = positionedItems.count(); | - | ||||||||||||||||||||||||
| 357 | positionedItems.append(*item); | - | ||||||||||||||||||||||||
| 358 | - | |||||||||||||||||||||||||
| 359 | if (d->transitioner) {
| 17-24 | ||||||||||||||||||||||||
| 360 | if (addedIndex < 0)
| 0-24 | ||||||||||||||||||||||||
| 361 | addedIndex = item->index; executed 24 times by 1 test: addedIndex = item->index;Executed by:
| 24 | ||||||||||||||||||||||||
| 362 | positionedItems[positionedItems.count()-1].transitionNextReposition(d->transitioner, QQuickItemViewTransitioner::AddTransition, true); | - | ||||||||||||||||||||||||
| 363 | } executed 24 times by 1 test: end of blockExecuted by:
| 24 | ||||||||||||||||||||||||
| 364 | } else { executed 41 times by 5 tests: end of blockExecuted by:
| 41 | ||||||||||||||||||||||||
| 365 | item->isNew = false; | - | ||||||||||||||||||||||||
| 366 | item->index = positionedItems.count(); | - | ||||||||||||||||||||||||
| 367 | positionedItems.append(*item); | - | ||||||||||||||||||||||||
| 368 | } executed 83141 times by 7 tests: end of blockExecuted by:
| 83141 | ||||||||||||||||||||||||
| 369 | } | - | ||||||||||||||||||||||||
| 370 | } | - | ||||||||||||||||||||||||
| 371 | - | |||||||||||||||||||||||||
| 372 | if (d->transitioner) {
| 1580-38072 | ||||||||||||||||||||||||
| 373 | for (int i=0; i<positionedItems.count(); i++) {
| 1580-8060 | ||||||||||||||||||||||||
| 374 | if (!positionedItems[i].isNew) {
| 3792-4268 | ||||||||||||||||||||||||
| 375 | if (addedIndex >= 0) {
| 848-2944 | ||||||||||||||||||||||||
| 376 | positionedItems[i].transitionNextReposition(d->transitioner, QQuickItemViewTransitioner::AddTransition, false); | - | ||||||||||||||||||||||||
| 377 | } else { executed 2944 times by 1 test: end of blockExecuted by:
| 2944 | ||||||||||||||||||||||||
| 378 | // just queue the item for a move-type displace - if the item hasn't | - | ||||||||||||||||||||||||
| 379 | // moved anywhere, it won't be transitioned anyway | - | ||||||||||||||||||||||||
| 380 | positionedItems[i].transitionNextReposition(d->transitioner, QQuickItemViewTransitioner::MoveTransition, false); | - | ||||||||||||||||||||||||
| 381 | } executed 848 times by 2 tests: end of blockExecuted by:
| 848 | ||||||||||||||||||||||||
| 382 | } | - | ||||||||||||||||||||||||
| 383 | } executed 8060 times by 2 tests: end of blockExecuted by:
| 8060 | ||||||||||||||||||||||||
| 384 | } executed 1580 times by 2 tests: end of blockExecuted by:
| 1580 | ||||||||||||||||||||||||
| 385 | - | |||||||||||||||||||||||||
| 386 | QSizeF contentSize(0,0); | - | ||||||||||||||||||||||||
| 387 | reportConflictingAnchors(); | - | ||||||||||||||||||||||||
| 388 | if (!d->anchorConflict) {
| 16-39636 | ||||||||||||||||||||||||
| 389 | doPositioning(&contentSize); | - | ||||||||||||||||||||||||
| 390 | updateAttachedProperties(); | - | ||||||||||||||||||||||||
| 391 | } executed 39636 times by 23 tests: end of blockExecuted by:
| 39636 | ||||||||||||||||||||||||
| 392 | - | |||||||||||||||||||||||||
| 393 | if (d->transitioner) {
| 1580-38072 | ||||||||||||||||||||||||
| 394 | QRectF viewBounds(QPointF(), contentSize); | - | ||||||||||||||||||||||||
| 395 | for (int i=0; i<positionedItems.count(); i++)
| 1580-8060 | ||||||||||||||||||||||||
| 396 | positionedItems[i].prepareTransition(d->transitioner, viewBounds); executed 8060 times by 2 tests: positionedItems[i].prepareTransition(d->transitioner, viewBounds);Executed by:
| 8060 | ||||||||||||||||||||||||
| 397 | for (int i=0; i<positionedItems.count(); i++)
| 1580-8060 | ||||||||||||||||||||||||
| 398 | positionedItems[i].startTransition(d->transitioner); executed 8060 times by 2 tests: positionedItems[i].startTransition(d->transitioner);Executed by:
| 8060 | ||||||||||||||||||||||||
| 399 | d->transitioner->resetTargetLists(); | - | ||||||||||||||||||||||||
| 400 | } executed 1580 times by 2 tests: end of blockExecuted by:
| 1580 | ||||||||||||||||||||||||
| 401 | - | |||||||||||||||||||||||||
| 402 | d->doingPositioning = false; | - | ||||||||||||||||||||||||
| 403 | - | |||||||||||||||||||||||||
| 404 | //Set implicit size to the size of its children | - | ||||||||||||||||||||||||
| 405 | setImplicitSize(contentSize.width(), contentSize.height()); | - | ||||||||||||||||||||||||
| 406 | - | |||||||||||||||||||||||||
| 407 | emit positioningComplete(); | - | ||||||||||||||||||||||||
| 408 | } executed 39652 times by 23 tests: end of blockExecuted by:
| 39652 | ||||||||||||||||||||||||
| 409 | - | |||||||||||||||||||||||||
| 410 | void QQuickBasePositioner::positionItem(qreal x, qreal y, PositionedItem *target) | - | ||||||||||||||||||||||||
| 411 | { | - | ||||||||||||||||||||||||
| 412 | if ( target->itemX() != x || target->itemY() != y )
| 7558-112490 | ||||||||||||||||||||||||
| 413 | target->moveTo(QPointF(x, y)); executed 29829 times by 19 tests: target->moveTo(QPointF(x, y));Executed by:
| 29829 | ||||||||||||||||||||||||
| 414 | } executed 120048 times by 21 tests: end of blockExecuted by:
| 120048 | ||||||||||||||||||||||||
| 415 | - | |||||||||||||||||||||||||
| 416 | void QQuickBasePositioner::positionItemX(qreal x, PositionedItem *target) | - | ||||||||||||||||||||||||
| 417 | { | - | ||||||||||||||||||||||||
| 418 | Q_D(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 419 | if (target->itemX() != x
| 86-300 | ||||||||||||||||||||||||
| 420 | && (d->type == Horizontal || d->type == Both)) {
| 0-300 | ||||||||||||||||||||||||
| 421 | target->moveTo(QPointF(x, target->itemY())); | - | ||||||||||||||||||||||||
| 422 | } executed 300 times by 1 test: end of blockExecuted by:
| 300 | ||||||||||||||||||||||||
| 423 | } executed 386 times by 1 test: end of blockExecuted by:
| 386 | ||||||||||||||||||||||||
| 424 | - | |||||||||||||||||||||||||
| 425 | void QQuickBasePositioner::positionItemY(qreal y, PositionedItem *target) | - | ||||||||||||||||||||||||
| 426 | { | - | ||||||||||||||||||||||||
| 427 | Q_D(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 428 | if (target->itemY() != y
| 52-334 | ||||||||||||||||||||||||
| 429 | && (d->type == Vertical || d->type == Both)) {
| 0-52 | ||||||||||||||||||||||||
| 430 | target->moveTo(QPointF(target->itemX(), y)); | - | ||||||||||||||||||||||||
| 431 | } executed 52 times by 1 test: end of blockExecuted by:
| 52 | ||||||||||||||||||||||||
| 432 | } executed 386 times by 1 test: end of blockExecuted by:
| 386 | ||||||||||||||||||||||||
| 433 | - | |||||||||||||||||||||||||
| 434 | /* | - | ||||||||||||||||||||||||
| 435 | Since PositionedItem values are stored by value, their internal transitionableItem pointers | - | ||||||||||||||||||||||||
| 436 | must be cleaned up when a PositionedItem is removed from a QPODVector, otherwise the pointer | - | ||||||||||||||||||||||||
| 437 | is never deleted since QPODVector doesn't invoke the destructor. | - | ||||||||||||||||||||||||
| 438 | */ | - | ||||||||||||||||||||||||
| 439 | void QQuickBasePositioner::removePositionedItem(QPODVector<PositionedItem,8> *items, int index) | - | ||||||||||||||||||||||||
| 440 | { | - | ||||||||||||||||||||||||
| 441 | Q_ASSERT(index >= 0 && index < items->count()); | - | ||||||||||||||||||||||||
| 442 | delete items->at(index).transitionableItem; | - | ||||||||||||||||||||||||
| 443 | items->remove(index); | - | ||||||||||||||||||||||||
| 444 | } executed 282 times by 5 tests: end of blockExecuted by:
| 282 | ||||||||||||||||||||||||
| 445 | void QQuickBasePositioner::clearPositionedItems(QPODVector<PositionedItem,8> *items) | - | ||||||||||||||||||||||||
| 446 | { | - | ||||||||||||||||||||||||
| 447 | for (int i=0; i<items->count(); i++)
| 24764-37292 | ||||||||||||||||||||||||
| 448 | delete items->at(i).transitionableItem; executed 37292 times by 21 tests: delete items->at(i).transitionableItem;Executed by:
| 37292 | ||||||||||||||||||||||||
| 449 | items->clear(); | - | ||||||||||||||||||||||||
| 450 | } executed 24764 times by 21 tests: end of blockExecuted by:
| 24764 | ||||||||||||||||||||||||
| 451 | - | |||||||||||||||||||||||||
| 452 | QQuickPositionerAttached *QQuickBasePositioner::qmlAttachedProperties(QObject *obj) | - | ||||||||||||||||||||||||
| 453 | { | - | ||||||||||||||||||||||||
| 454 | return new QQuickPositionerAttached(obj); executed 22 times by 1 test: return new QQuickPositionerAttached(obj);Executed by:
| 22 | ||||||||||||||||||||||||
| 455 | } | - | ||||||||||||||||||||||||
| 456 | - | |||||||||||||||||||||||||
| 457 | void QQuickBasePositioner::updateAttachedProperties(QQuickPositionerAttached *specificProperty, QQuickItem *specificPropertyOwner) const | - | ||||||||||||||||||||||||
| 458 | { | - | ||||||||||||||||||||||||
| 459 | // If this function is deemed too expensive or shows up in profiles, it could | - | ||||||||||||||||||||||||
| 460 | // be changed to run only when there are attached properties present. This | - | ||||||||||||||||||||||||
| 461 | // could be a flag in the positioner that is set by the attached property | - | ||||||||||||||||||||||||
| 462 | // constructor. | - | ||||||||||||||||||||||||
| 463 | QQuickPositionerAttached *prevLastProperty = nullptr; | - | ||||||||||||||||||||||||
| 464 | QQuickPositionerAttached *lastProperty = nullptr; | - | ||||||||||||||||||||||||
| 465 | - | |||||||||||||||||||||||||
| 466 | for (int ii = 0; ii < positionedItems.count(); ++ii) {
| 39658-120514 | ||||||||||||||||||||||||
| 467 | const PositionedItem &child = positionedItems.at(ii); | - | ||||||||||||||||||||||||
| 468 | if (!child.item)
| 0-120514 | ||||||||||||||||||||||||
| 469 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 470 | - | |||||||||||||||||||||||||
| 471 | QQuickPositionerAttached *property = nullptr; | - | ||||||||||||||||||||||||
| 472 | - | |||||||||||||||||||||||||
| 473 | if (specificProperty) {
| 20-120494 | ||||||||||||||||||||||||
| 474 | if (specificPropertyOwner == child.item) {
| 8-12 | ||||||||||||||||||||||||
| 475 | property = specificProperty; | - | ||||||||||||||||||||||||
| 476 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 477 | } else { executed 20 times by 1 test: end of blockExecuted by:
| 20 | ||||||||||||||||||||||||
| 478 | property = static_cast<QQuickPositionerAttached *>(qmlAttachedPropertiesObject<QQuickBasePositioner>(child.item, false)); | - | ||||||||||||||||||||||||
| 479 | } executed 120494 times by 21 tests: end of blockExecuted by:
| 120494 | ||||||||||||||||||||||||
| 480 | - | |||||||||||||||||||||||||
| 481 | if (property) {
| 32-120482 | ||||||||||||||||||||||||
| 482 | property->setIndex(ii); | - | ||||||||||||||||||||||||
| 483 | property->setIsFirstItem(ii == 0); | - | ||||||||||||||||||||||||
| 484 | - | |||||||||||||||||||||||||
| 485 | if (property->isLastItem()) {
| 2-30 | ||||||||||||||||||||||||
| 486 | if (prevLastProperty)
| 0-2 | ||||||||||||||||||||||||
| 487 | prevLastProperty->setIsLastItem(false); // there can be only one last property never executed: prevLastProperty->setIsLastItem(false); | 0 | ||||||||||||||||||||||||
| 488 | prevLastProperty = property; | - | ||||||||||||||||||||||||
| 489 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||
| 490 | } executed 32 times by 1 test: end of blockExecuted by:
| 32 | ||||||||||||||||||||||||
| 491 | - | |||||||||||||||||||||||||
| 492 | lastProperty = property; | - | ||||||||||||||||||||||||
| 493 | } executed 120514 times by 21 tests: end of blockExecuted by:
| 120514 | ||||||||||||||||||||||||
| 494 | - | |||||||||||||||||||||||||
| 495 | if (prevLastProperty && prevLastProperty != lastProperty)
| 0-39656 | ||||||||||||||||||||||||
| 496 | prevLastProperty->setIsLastItem(false); executed 2 times by 1 test: prevLastProperty->setIsLastItem(false);Executed by:
| 2 | ||||||||||||||||||||||||
| 497 | if (lastProperty)
| 14-39644 | ||||||||||||||||||||||||
| 498 | lastProperty->setIsLastItem(true); executed 14 times by 1 test: lastProperty->setIsLastItem(true);Executed by:
| 14 | ||||||||||||||||||||||||
| 499 | - | |||||||||||||||||||||||||
| 500 | // clear attached properties for unpositioned items | - | ||||||||||||||||||||||||
| 501 | for (int ii = 0; ii < unpositionedItems.count(); ++ii) {
| 343-39658 | ||||||||||||||||||||||||
| 502 | const PositionedItem &child = unpositionedItems.at(ii); | - | ||||||||||||||||||||||||
| 503 | if (!child.item)
| 0-343 | ||||||||||||||||||||||||
| 504 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 505 | - | |||||||||||||||||||||||||
| 506 | QQuickPositionerAttached *property = nullptr; | - | ||||||||||||||||||||||||
| 507 | - | |||||||||||||||||||||||||
| 508 | if (specificProperty) {
| 16-327 | ||||||||||||||||||||||||
| 509 | if (specificPropertyOwner == child.item) {
| 0-16 | ||||||||||||||||||||||||
| 510 | property = specificProperty; | - | ||||||||||||||||||||||||
| 511 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 512 | } else { executed 16 times by 1 test: end of blockExecuted by:
| 16 | ||||||||||||||||||||||||
| 513 | property = static_cast<QQuickPositionerAttached *>(qmlAttachedPropertiesObject<QQuickBasePositioner>(child.item, false)); | - | ||||||||||||||||||||||||
| 514 | } executed 327 times by 9 tests: end of blockExecuted by:
| 327 | ||||||||||||||||||||||||
| 515 | - | |||||||||||||||||||||||||
| 516 | if (property) {
| 0-343 | ||||||||||||||||||||||||
| 517 | property->setIndex(-1); | - | ||||||||||||||||||||||||
| 518 | property->setIsFirstItem(false); | - | ||||||||||||||||||||||||
| 519 | property->setIsLastItem(false); | - | ||||||||||||||||||||||||
| 520 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 521 | } executed 343 times by 9 tests: end of blockExecuted by:
| 343 | ||||||||||||||||||||||||
| 522 | } executed 39658 times by 23 tests: end of blockExecuted by:
| 39658 | ||||||||||||||||||||||||
| 523 | - | |||||||||||||||||||||||||
| 524 | qreal QQuickBasePositioner::padding() const | - | ||||||||||||||||||||||||
| 525 | { | - | ||||||||||||||||||||||||
| 526 | Q_D(const QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 527 | return d->padding(); executed 56 times by 1 test: return d->padding();Executed by:
| 56 | ||||||||||||||||||||||||
| 528 | } | - | ||||||||||||||||||||||||
| 529 | - | |||||||||||||||||||||||||
| 530 | void QQuickBasePositioner::setPadding(qreal padding) | - | ||||||||||||||||||||||||
| 531 | { | - | ||||||||||||||||||||||||
| 532 | Q_D(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 533 | if (qFuzzyCompare(d->padding(), padding))
| 0-610 | ||||||||||||||||||||||||
| 534 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 535 | - | |||||||||||||||||||||||||
| 536 | d->extra.value().padding = padding; | - | ||||||||||||||||||||||||
| 537 | d->setPositioningDirty(); | - | ||||||||||||||||||||||||
| 538 | emit paddingChanged(); | - | ||||||||||||||||||||||||
| 539 | if (!d->extra.isAllocated() || !d->extra->explicitTopPadding)
| 0-610 | ||||||||||||||||||||||||
| 540 | emit topPaddingChanged(); executed 72 times by 1 test: topPaddingChanged();Executed by:
| 72 | ||||||||||||||||||||||||
| 541 | if (!d->extra.isAllocated() || !d->extra->explicitLeftPadding)
| 0-610 | ||||||||||||||||||||||||
| 542 | emit leftPaddingChanged(); executed 72 times by 1 test: leftPaddingChanged();Executed by:
| 72 | ||||||||||||||||||||||||
| 543 | if (!d->extra.isAllocated() || !d->extra->explicitRightPadding)
| 0-610 | ||||||||||||||||||||||||
| 544 | emit rightPaddingChanged(); executed 72 times by 1 test: rightPaddingChanged();Executed by:
| 72 | ||||||||||||||||||||||||
| 545 | if (!d->extra.isAllocated() || !d->extra->explicitBottomPadding)
| 0-610 | ||||||||||||||||||||||||
| 546 | emit bottomPaddingChanged(); executed 72 times by 1 test: bottomPaddingChanged();Executed by:
| 72 | ||||||||||||||||||||||||
| 547 | } executed 610 times by 1 test: end of blockExecuted by:
| 610 | ||||||||||||||||||||||||
| 548 | - | |||||||||||||||||||||||||
| 549 | void QQuickBasePositioner::resetPadding() | - | ||||||||||||||||||||||||
| 550 | { | - | ||||||||||||||||||||||||
| 551 | setPadding(0); | - | ||||||||||||||||||||||||
| 552 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 553 | - | |||||||||||||||||||||||||
| 554 | qreal QQuickBasePositioner::topPadding() const | - | ||||||||||||||||||||||||
| 555 | { | - | ||||||||||||||||||||||||
| 556 | Q_D(const QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 557 | if (d->extra.isAllocated() && d->extra->explicitTopPadding)
| 804-194612 | ||||||||||||||||||||||||
| 558 | return d->extra->topPadding; executed 8806 times by 1 test: return d->extra->topPadding;Executed by:
| 8806 | ||||||||||||||||||||||||
| 559 | return d->padding(); executed 195416 times by 23 tests: return d->padding();Executed by:
| 195416 | ||||||||||||||||||||||||
| 560 | } | - | ||||||||||||||||||||||||
| 561 | - | |||||||||||||||||||||||||
| 562 | void QQuickBasePositioner::setTopPadding(qreal padding) | - | ||||||||||||||||||||||||
| 563 | { | - | ||||||||||||||||||||||||
| 564 | Q_D(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 565 | d->setTopPadding(padding); | - | ||||||||||||||||||||||||
| 566 | } executed 602 times by 1 test: end of blockExecuted by:
| 602 | ||||||||||||||||||||||||
| 567 | - | |||||||||||||||||||||||||
| 568 | void QQuickBasePositioner::resetTopPadding() | - | ||||||||||||||||||||||||
| 569 | { | - | ||||||||||||||||||||||||
| 570 | Q_D(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 571 | d->setTopPadding(0, true); | - | ||||||||||||||||||||||||
| 572 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 573 | - | |||||||||||||||||||||||||
| 574 | qreal QQuickBasePositioner::leftPadding() const | - | ||||||||||||||||||||||||
| 575 | { | - | ||||||||||||||||||||||||
| 576 | Q_D(const QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 577 | if (d->extra.isAllocated() && d->extra->explicitLeftPadding)
| 912-265904 | ||||||||||||||||||||||||
| 578 | return d->extra->leftPadding; executed 8672 times by 1 test: return d->extra->leftPadding;Executed by:
| 8672 | ||||||||||||||||||||||||
| 579 | return d->padding(); executed 266816 times by 23 tests: return d->padding();Executed by:
| 266816 | ||||||||||||||||||||||||
| 580 | } | - | ||||||||||||||||||||||||
| 581 | - | |||||||||||||||||||||||||
| 582 | void QQuickBasePositioner::setLeftPadding(qreal padding) | - | ||||||||||||||||||||||||
| 583 | { | - | ||||||||||||||||||||||||
| 584 | Q_D(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 585 | d->setLeftPadding(padding); | - | ||||||||||||||||||||||||
| 586 | } executed 602 times by 1 test: end of blockExecuted by:
| 602 | ||||||||||||||||||||||||
| 587 | - | |||||||||||||||||||||||||
| 588 | void QQuickBasePositioner::resetLeftPadding() | - | ||||||||||||||||||||||||
| 589 | { | - | ||||||||||||||||||||||||
| 590 | Q_D(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 591 | d->setLeftPadding(0, true); | - | ||||||||||||||||||||||||
| 592 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 593 | - | |||||||||||||||||||||||||
| 594 | qreal QQuickBasePositioner::rightPadding() const | - | ||||||||||||||||||||||||
| 595 | { | - | ||||||||||||||||||||||||
| 596 | Q_D(const QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 597 | if (d->extra.isAllocated() && d->extra->explicitRightPadding)
| 938-153996 | ||||||||||||||||||||||||
| 598 | return d->extra->rightPadding; executed 5994 times by 1 test: return d->extra->rightPadding;Executed by:
| 5994 | ||||||||||||||||||||||||
| 599 | return d->padding(); executed 154934 times by 23 tests: return d->padding();Executed by:
| 154934 | ||||||||||||||||||||||||
| 600 | } | - | ||||||||||||||||||||||||
| 601 | - | |||||||||||||||||||||||||
| 602 | void QQuickBasePositioner::setRightPadding(qreal padding) | - | ||||||||||||||||||||||||
| 603 | { | - | ||||||||||||||||||||||||
| 604 | Q_D(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 605 | d->setRightPadding(padding); | - | ||||||||||||||||||||||||
| 606 | } executed 602 times by 1 test: end of blockExecuted by:
| 602 | ||||||||||||||||||||||||
| 607 | - | |||||||||||||||||||||||||
| 608 | void QQuickBasePositioner::resetRightPadding() | - | ||||||||||||||||||||||||
| 609 | { | - | ||||||||||||||||||||||||
| 610 | Q_D(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 611 | d->setRightPadding(0, true); | - | ||||||||||||||||||||||||
| 612 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 613 | - | |||||||||||||||||||||||||
| 614 | qreal QQuickBasePositioner::bottomPadding() const | - | ||||||||||||||||||||||||
| 615 | { | - | ||||||||||||||||||||||||
| 616 | Q_D(const QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 617 | if (d->extra.isAllocated() && d->extra->explicitBottomPadding)
| 606-155904 | ||||||||||||||||||||||||
| 618 | return d->extra->bottomPadding; executed 7174 times by 1 test: return d->extra->bottomPadding;Executed by:
| 7174 | ||||||||||||||||||||||||
| 619 | return d->padding(); executed 156510 times by 23 tests: return d->padding();Executed by:
| 156510 | ||||||||||||||||||||||||
| 620 | } | - | ||||||||||||||||||||||||
| 621 | - | |||||||||||||||||||||||||
| 622 | void QQuickBasePositioner::setBottomPadding(qreal padding) | - | ||||||||||||||||||||||||
| 623 | { | - | ||||||||||||||||||||||||
| 624 | Q_D(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 625 | d->setBottomPadding(padding); | - | ||||||||||||||||||||||||
| 626 | } executed 602 times by 1 test: end of blockExecuted by:
| 602 | ||||||||||||||||||||||||
| 627 | - | |||||||||||||||||||||||||
| 628 | void QQuickBasePositioner::resetBottomPadding() | - | ||||||||||||||||||||||||
| 629 | { | - | ||||||||||||||||||||||||
| 630 | Q_D(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 631 | d->setBottomPadding(0, true); | - | ||||||||||||||||||||||||
| 632 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 633 | - | |||||||||||||||||||||||||
| 634 | QQuickBasePositionerPrivate::ExtraData::ExtraData() | - | ||||||||||||||||||||||||
| 635 | : padding(0) | - | ||||||||||||||||||||||||
| 636 | , topPadding(0) | - | ||||||||||||||||||||||||
| 637 | , leftPadding(0) | - | ||||||||||||||||||||||||
| 638 | , rightPadding(0) | - | ||||||||||||||||||||||||
| 639 | , bottomPadding(0) | - | ||||||||||||||||||||||||
| 640 | , explicitTopPadding(false) | - | ||||||||||||||||||||||||
| 641 | , explicitLeftPadding(false) | - | ||||||||||||||||||||||||
| 642 | , explicitRightPadding(false) | - | ||||||||||||||||||||||||
| 643 | , explicitBottomPadding(false) | - | ||||||||||||||||||||||||
| 644 | { | - | ||||||||||||||||||||||||
| 645 | } executed 594 times by 1 test: end of blockExecuted by:
| 594 | ||||||||||||||||||||||||
| 646 | - | |||||||||||||||||||||||||
| 647 | void QQuickBasePositionerPrivate::setTopPadding(qreal value, bool reset) | - | ||||||||||||||||||||||||
| 648 | { | - | ||||||||||||||||||||||||
| 649 | Q_Q(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 650 | qreal oldPadding = q->topPadding(); | - | ||||||||||||||||||||||||
| 651 | if (!reset || extra.isAllocated()) {
| 0-602 | ||||||||||||||||||||||||
| 652 | extra.value().topPadding = value; | - | ||||||||||||||||||||||||
| 653 | extra.value().explicitTopPadding = !reset; | - | ||||||||||||||||||||||||
| 654 | } executed 610 times by 1 test: end of blockExecuted by:
| 610 | ||||||||||||||||||||||||
| 655 | if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding()))) {
| 0-602 | ||||||||||||||||||||||||
| 656 | setPositioningDirty(); | - | ||||||||||||||||||||||||
| 657 | emit q->topPaddingChanged(); | - | ||||||||||||||||||||||||
| 658 | } executed 610 times by 1 test: end of blockExecuted by:
| 610 | ||||||||||||||||||||||||
| 659 | } executed 610 times by 1 test: end of blockExecuted by:
| 610 | ||||||||||||||||||||||||
| 660 | - | |||||||||||||||||||||||||
| 661 | void QQuickBasePositionerPrivate::setLeftPadding(qreal value, bool reset) | - | ||||||||||||||||||||||||
| 662 | { | - | ||||||||||||||||||||||||
| 663 | Q_Q(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 664 | qreal oldPadding = q->leftPadding(); | - | ||||||||||||||||||||||||
| 665 | if (!reset || extra.isAllocated()) {
| 0-602 | ||||||||||||||||||||||||
| 666 | extra.value().leftPadding = value; | - | ||||||||||||||||||||||||
| 667 | extra.value().explicitLeftPadding = !reset; | - | ||||||||||||||||||||||||
| 668 | } executed 610 times by 1 test: end of blockExecuted by:
| 610 | ||||||||||||||||||||||||
| 669 | if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding()))) {
| 0-602 | ||||||||||||||||||||||||
| 670 | setPositioningDirty(); | - | ||||||||||||||||||||||||
| 671 | emit q->leftPaddingChanged(); | - | ||||||||||||||||||||||||
| 672 | } executed 610 times by 1 test: end of blockExecuted by:
| 610 | ||||||||||||||||||||||||
| 673 | } executed 610 times by 1 test: end of blockExecuted by:
| 610 | ||||||||||||||||||||||||
| 674 | - | |||||||||||||||||||||||||
| 675 | void QQuickBasePositionerPrivate::setRightPadding(qreal value, bool reset) | - | ||||||||||||||||||||||||
| 676 | { | - | ||||||||||||||||||||||||
| 677 | Q_Q(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 678 | qreal oldPadding = q->rightPadding(); | - | ||||||||||||||||||||||||
| 679 | if (!reset || extra.isAllocated()) {
| 0-602 | ||||||||||||||||||||||||
| 680 | extra.value().rightPadding = value; | - | ||||||||||||||||||||||||
| 681 | extra.value().explicitRightPadding = !reset; | - | ||||||||||||||||||||||||
| 682 | } executed 610 times by 1 test: end of blockExecuted by:
| 610 | ||||||||||||||||||||||||
| 683 | if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding()))) {
| 0-602 | ||||||||||||||||||||||||
| 684 | setPositioningDirty(); | - | ||||||||||||||||||||||||
| 685 | emit q->rightPaddingChanged(); | - | ||||||||||||||||||||||||
| 686 | } executed 610 times by 1 test: end of blockExecuted by:
| 610 | ||||||||||||||||||||||||
| 687 | } executed 610 times by 1 test: end of blockExecuted by:
| 610 | ||||||||||||||||||||||||
| 688 | - | |||||||||||||||||||||||||
| 689 | void QQuickBasePositionerPrivate::setBottomPadding(qreal value, bool reset) | - | ||||||||||||||||||||||||
| 690 | { | - | ||||||||||||||||||||||||
| 691 | Q_Q(QQuickBasePositioner); | - | ||||||||||||||||||||||||
| 692 | qreal oldPadding = q->bottomPadding(); | - | ||||||||||||||||||||||||
| 693 | if (!reset || extra.isAllocated()) {
| 0-602 | ||||||||||||||||||||||||
| 694 | extra.value().bottomPadding = value; | - | ||||||||||||||||||||||||
| 695 | extra.value().explicitBottomPadding = !reset; | - | ||||||||||||||||||||||||
| 696 | } executed 610 times by 1 test: end of blockExecuted by:
| 610 | ||||||||||||||||||||||||
| 697 | if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding()))) {
| 0-602 | ||||||||||||||||||||||||
| 698 | setPositioningDirty(); | - | ||||||||||||||||||||||||
| 699 | emit q->bottomPaddingChanged(); | - | ||||||||||||||||||||||||
| 700 | } executed 610 times by 1 test: end of blockExecuted by:
| 610 | ||||||||||||||||||||||||
| 701 | } executed 610 times by 1 test: end of blockExecuted by:
| 610 | ||||||||||||||||||||||||
| 702 | - | |||||||||||||||||||||||||
| 703 | /*! | - | ||||||||||||||||||||||||
| 704 | \qmltype Positioner | - | ||||||||||||||||||||||||
| 705 | \instantiates QQuickPositionerAttached | - | ||||||||||||||||||||||||
| 706 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||
| 707 | \ingroup qtquick-positioners | - | ||||||||||||||||||||||||
| 708 | \brief Provides attached properties that contain details on where an item exists in a positioner. | - | ||||||||||||||||||||||||
| 709 | - | |||||||||||||||||||||||||
| 710 | An object of type Positioner is attached to the top-level child item within a | - | ||||||||||||||||||||||||
| 711 | Column, Row, Flow or Grid. It provides properties that allow a child item to determine | - | ||||||||||||||||||||||||
| 712 | where it exists within the layout of its parent Column, Row, Flow or Grid. | - | ||||||||||||||||||||||||
| 713 | - | |||||||||||||||||||||||||
| 714 | For example, below is a \l Grid with 16 child rectangles, as created through a \l Repeater. | - | ||||||||||||||||||||||||
| 715 | Each \l Rectangle displays its index in the Grid using \l {Positioner::index}{Positioner.index}, and the first | - | ||||||||||||||||||||||||
| 716 | item is colored differently by taking \l {Positioner::isFirstItem}{Positioner.isFirstItem} into account: | - | ||||||||||||||||||||||||
| 717 | - | |||||||||||||||||||||||||
| 718 | \code | - | ||||||||||||||||||||||||
| 719 | Grid { | - | ||||||||||||||||||||||||
| 720 | Repeater { | - | ||||||||||||||||||||||||
| 721 | model: 16 | - | ||||||||||||||||||||||||
| 722 | - | |||||||||||||||||||||||||
| 723 | Rectangle { | - | ||||||||||||||||||||||||
| 724 | id: rect | - | ||||||||||||||||||||||||
| 725 | width: 30; height: 30 | - | ||||||||||||||||||||||||
| 726 | border.width: 1 | - | ||||||||||||||||||||||||
| 727 | color: Positioner.isFirstItem ? "yellow" : "lightsteelblue" | - | ||||||||||||||||||||||||
| 728 | - | |||||||||||||||||||||||||
| 729 | Text { text: rect.Positioner.index } | - | ||||||||||||||||||||||||
| 730 | } | - | ||||||||||||||||||||||||
| 731 | } | - | ||||||||||||||||||||||||
| 732 | } | - | ||||||||||||||||||||||||
| 733 | \endcode | - | ||||||||||||||||||||||||
| 734 | - | |||||||||||||||||||||||||
| 735 | \image positioner-example.png | - | ||||||||||||||||||||||||
| 736 | */ | - | ||||||||||||||||||||||||
| 737 | - | |||||||||||||||||||||||||
| 738 | QQuickPositionerAttached::QQuickPositionerAttached(QObject *parent) : QObject(parent), m_index(-1), m_isFirstItem(false), m_isLastItem(false) | - | ||||||||||||||||||||||||
| 739 | { | - | ||||||||||||||||||||||||
| 740 | QQuickItem *attachedItem = qobject_cast<QQuickItem *>(parent); | - | ||||||||||||||||||||||||
| 741 | if (attachedItem) {
| 0-22 | ||||||||||||||||||||||||
| 742 | QQuickBasePositioner *positioner = qobject_cast<QQuickBasePositioner *>(attachedItem->parent()); | - | ||||||||||||||||||||||||
| 743 | if (positioner) {
| 0-22 | ||||||||||||||||||||||||
| 744 | positioner->updateAttachedProperties(this, attachedItem); | - | ||||||||||||||||||||||||
| 745 | } executed 22 times by 1 test: end of blockExecuted by:
| 22 | ||||||||||||||||||||||||
| 746 | } executed 22 times by 1 test: end of blockExecuted by:
| 22 | ||||||||||||||||||||||||
| 747 | } executed 22 times by 1 test: end of blockExecuted by:
| 22 | ||||||||||||||||||||||||
| 748 | - | |||||||||||||||||||||||||
| 749 | /*! | - | ||||||||||||||||||||||||
| 750 | \qmlattachedproperty int QtQuick::Positioner::index | - | ||||||||||||||||||||||||
| 751 | - | |||||||||||||||||||||||||
| 752 | This property allows the item to determine | - | ||||||||||||||||||||||||
| 753 | its index within the positioner. | - | ||||||||||||||||||||||||
| 754 | */ | - | ||||||||||||||||||||||||
| 755 | void QQuickPositionerAttached::setIndex(int index) | - | ||||||||||||||||||||||||
| 756 | { | - | ||||||||||||||||||||||||
| 757 | if (m_index == index)
| 10-22 | ||||||||||||||||||||||||
| 758 | return; executed 10 times by 1 test: return;Executed by:
| 10 | ||||||||||||||||||||||||
| 759 | m_index = index; | - | ||||||||||||||||||||||||
| 760 | emit indexChanged(); | - | ||||||||||||||||||||||||
| 761 | } executed 22 times by 1 test: end of blockExecuted by:
| 22 | ||||||||||||||||||||||||
| 762 | - | |||||||||||||||||||||||||
| 763 | /*! | - | ||||||||||||||||||||||||
| 764 | \qmlattachedproperty bool QtQuick::Positioner::isFirstItem | - | ||||||||||||||||||||||||
| 765 | \qmlattachedproperty bool QtQuick::Positioner::isLastItem | - | ||||||||||||||||||||||||
| 766 | - | |||||||||||||||||||||||||
| 767 | These properties allow the item to determine if it | - | ||||||||||||||||||||||||
| 768 | is the first or last item in the positioner, respectively. | - | ||||||||||||||||||||||||
| 769 | */ | - | ||||||||||||||||||||||||
| 770 | void QQuickPositionerAttached::setIsFirstItem(bool isFirstItem) | - | ||||||||||||||||||||||||
| 771 | { | - | ||||||||||||||||||||||||
| 772 | if (m_isFirstItem == isFirstItem)
| 10-22 | ||||||||||||||||||||||||
| 773 | return; executed 22 times by 1 test: return;Executed by:
| 22 | ||||||||||||||||||||||||
| 774 | m_isFirstItem = isFirstItem; | - | ||||||||||||||||||||||||
| 775 | emit isFirstItemChanged(); | - | ||||||||||||||||||||||||
| 776 | } executed 10 times by 1 test: end of blockExecuted by:
| 10 | ||||||||||||||||||||||||
| 777 | - | |||||||||||||||||||||||||
| 778 | void QQuickPositionerAttached::setIsLastItem(bool isLastItem) | - | ||||||||||||||||||||||||
| 779 | { | - | ||||||||||||||||||||||||
| 780 | if (m_isLastItem == isLastItem)
| 0-16 | ||||||||||||||||||||||||
| 781 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 782 | m_isLastItem = isLastItem; | - | ||||||||||||||||||||||||
| 783 | emit isLastItemChanged(); | - | ||||||||||||||||||||||||
| 784 | } executed 16 times by 1 test: end of blockExecuted by:
| 16 | ||||||||||||||||||||||||
| 785 | - | |||||||||||||||||||||||||
| 786 | /*! | - | ||||||||||||||||||||||||
| 787 | \qmltype Column | - | ||||||||||||||||||||||||
| 788 | \instantiates QQuickColumn | - | ||||||||||||||||||||||||
| 789 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||
| 790 | \inherits Item | - | ||||||||||||||||||||||||
| 791 | \ingroup qtquick-positioners | - | ||||||||||||||||||||||||
| 792 | \brief Positions its children in a column. | - | ||||||||||||||||||||||||
| 793 | - | |||||||||||||||||||||||||
| 794 | Column is a type that positions its child items along a single column. | - | ||||||||||||||||||||||||
| 795 | It can be used as a convenient way to vertically position a series of items without | - | ||||||||||||||||||||||||
| 796 | using \l {Positioning with Anchors}{anchors}. | - | ||||||||||||||||||||||||
| 797 | - | |||||||||||||||||||||||||
| 798 | Below is a Column that contains three rectangles of various sizes: | - | ||||||||||||||||||||||||
| 799 | - | |||||||||||||||||||||||||
| 800 | \snippet qml/column/vertical-positioner.qml document | - | ||||||||||||||||||||||||
| 801 | - | |||||||||||||||||||||||||
| 802 | The Column automatically positions these items in a vertical formation, like this: | - | ||||||||||||||||||||||||
| 803 | - | |||||||||||||||||||||||||
| 804 | \image verticalpositioner_example.png | - | ||||||||||||||||||||||||
| 805 | - | |||||||||||||||||||||||||
| 806 | If an item within a Column is not \l {Item::}{visible}, or if it has a width or | - | ||||||||||||||||||||||||
| 807 | height of 0, the item will not be laid out and it will not be visible within the | - | ||||||||||||||||||||||||
| 808 | column. Also, since a Column automatically positions its children vertically, a child | - | ||||||||||||||||||||||||
| 809 | item within a Column should not set its \l {Item::y}{y} position or vertically | - | ||||||||||||||||||||||||
| 810 | anchor itself using the \l {Item::anchors.top}{top}, \l {Item::anchors.bottom}{bottom}, | - | ||||||||||||||||||||||||
| 811 | \l {Item::anchors.verticalCenter}{anchors.verticalCenter}, \l {Item::anchors.fill}{fill} | - | ||||||||||||||||||||||||
| 812 | or \l {Item::anchors.centerIn}{centerIn} anchors. If you need to perform these actions, | - | ||||||||||||||||||||||||
| 813 | consider positioning the items without the use of a Column. | - | ||||||||||||||||||||||||
| 814 | - | |||||||||||||||||||||||||
| 815 | Note that items in a Column can use the \l Positioner attached property to access | - | ||||||||||||||||||||||||
| 816 | more information about its position within the Column. | - | ||||||||||||||||||||||||
| 817 | - | |||||||||||||||||||||||||
| 818 | For more information on using Column and other related positioner-types, see | - | ||||||||||||||||||||||||
| 819 | \l{Item Positioners}. | - | ||||||||||||||||||||||||
| 820 | - | |||||||||||||||||||||||||
| 821 | - | |||||||||||||||||||||||||
| 822 | \section1 Using Transitions | - | ||||||||||||||||||||||||
| 823 | - | |||||||||||||||||||||||||
| 824 | A Column animate items using specific transitions when items are added to or moved | - | ||||||||||||||||||||||||
| 825 | within a Column. | - | ||||||||||||||||||||||||
| 826 | - | |||||||||||||||||||||||||
| 827 | For example, the Column below sets the \l move property to a specific \l Transition: | - | ||||||||||||||||||||||||
| 828 | - | |||||||||||||||||||||||||
| 829 | \snippet qml/column/column-transitions.qml document | - | ||||||||||||||||||||||||
| 830 | - | |||||||||||||||||||||||||
| 831 | When the Space key is pressed, the \l {Item::visible}{visible} value of the green | - | ||||||||||||||||||||||||
| 832 | \l Rectangle is toggled. As it appears and disappears, the blue \l Rectangle moves within | - | ||||||||||||||||||||||||
| 833 | the Column, and the \l move transition is automatically applied to the blue \l Rectangle: | - | ||||||||||||||||||||||||
| 834 | - | |||||||||||||||||||||||||
| 835 | \image verticalpositioner_transition.gif | - | ||||||||||||||||||||||||
| 836 | - | |||||||||||||||||||||||||
| 837 | \sa Row, Grid, Flow, Positioner, ColumnLayout, {Qt Quick Examples - Positioners} | - | ||||||||||||||||||||||||
| 838 | */ | - | ||||||||||||||||||||||||
| 839 | /*! | - | ||||||||||||||||||||||||
| 840 | \since 5.6 | - | ||||||||||||||||||||||||
| 841 | \qmlproperty real QtQuick::Column::padding | - | ||||||||||||||||||||||||
| 842 | \qmlproperty real QtQuick::Column::topPadding | - | ||||||||||||||||||||||||
| 843 | \qmlproperty real QtQuick::Column::leftPadding | - | ||||||||||||||||||||||||
| 844 | \qmlproperty real QtQuick::Column::bottomPadding | - | ||||||||||||||||||||||||
| 845 | \qmlproperty real QtQuick::Column::rightPadding | - | ||||||||||||||||||||||||
| 846 | - | |||||||||||||||||||||||||
| 847 | These properties hold the padding around the content. | - | ||||||||||||||||||||||||
| 848 | */ | - | ||||||||||||||||||||||||
| 849 | /*! | - | ||||||||||||||||||||||||
| 850 | \qmlproperty Transition QtQuick::Column::populate | - | ||||||||||||||||||||||||
| 851 | - | |||||||||||||||||||||||||
| 852 | This property holds the transition to be run for items that are part of | - | ||||||||||||||||||||||||
| 853 | this positioner at the time of its creation. The transition is run when the positioner | - | ||||||||||||||||||||||||
| 854 | is first created. | - | ||||||||||||||||||||||||
| 855 | - | |||||||||||||||||||||||||
| 856 | The transition can use the \l ViewTransition property to access more details about | - | ||||||||||||||||||||||||
| 857 | the item that is being added. See the \l ViewTransition documentation for more details | - | ||||||||||||||||||||||||
| 858 | and examples on using these transitions. | - | ||||||||||||||||||||||||
| 859 | - | |||||||||||||||||||||||||
| 860 | \sa add, ViewTransition, {Qt Quick Examples - Positioners} | - | ||||||||||||||||||||||||
| 861 | */ | - | ||||||||||||||||||||||||
| 862 | /*! | - | ||||||||||||||||||||||||
| 863 | \qmlproperty Transition QtQuick::Column::add | - | ||||||||||||||||||||||||
| 864 | - | |||||||||||||||||||||||||
| 865 | This property holds the transition to be run for items that are added to this | - | ||||||||||||||||||||||||
| 866 | positioner. For a positioner, this applies to: | - | ||||||||||||||||||||||||
| 867 | - | |||||||||||||||||||||||||
| 868 | \list | - | ||||||||||||||||||||||||
| 869 | \li Items that are created or reparented as a child of the positioner after the | - | ||||||||||||||||||||||||
| 870 | positioner has been created | - | ||||||||||||||||||||||||
| 871 | \li Child items that change their \l Item::visible property from false to true, and thus | - | ||||||||||||||||||||||||
| 872 | are now visible | - | ||||||||||||||||||||||||
| 873 | \endlist | - | ||||||||||||||||||||||||
| 874 | - | |||||||||||||||||||||||||
| 875 | The transition can use the \l ViewTransition property to access more details about | - | ||||||||||||||||||||||||
| 876 | the item that is being added. See the \l ViewTransition documentation for more details | - | ||||||||||||||||||||||||
| 877 | and examples on using these transitions. | - | ||||||||||||||||||||||||
| 878 | - | |||||||||||||||||||||||||
| 879 | \note This transition is not applied to the items that are already part of the positioner | - | ||||||||||||||||||||||||
| 880 | at the time of its creation. In this case, the \l populate transition is applied instead. | - | ||||||||||||||||||||||||
| 881 | - | |||||||||||||||||||||||||
| 882 | \sa populate, ViewTransition, {Qt Quick Examples - Positioners} | - | ||||||||||||||||||||||||
| 883 | */ | - | ||||||||||||||||||||||||
| 884 | /*! | - | ||||||||||||||||||||||||
| 885 | \qmlproperty Transition QtQuick::Column::move | - | ||||||||||||||||||||||||
| 886 | - | |||||||||||||||||||||||||
| 887 | This property holds the transition to run for items that have moved within the | - | ||||||||||||||||||||||||
| 888 | positioner. For a positioner, this applies to: | - | ||||||||||||||||||||||||
| 889 | - | |||||||||||||||||||||||||
| 890 | \list | - | ||||||||||||||||||||||||
| 891 | \li Child items that move when they are displaced due to the addition, removal or | - | ||||||||||||||||||||||||
| 892 | rearrangement of other items in the positioner | - | ||||||||||||||||||||||||
| 893 | \li Child items that are repositioned due to the resizing of other items in the positioner | - | ||||||||||||||||||||||||
| 894 | \endlist | - | ||||||||||||||||||||||||
| 895 | - | |||||||||||||||||||||||||
| 896 | The transition can use the \l ViewTransition property to access more details about | - | ||||||||||||||||||||||||
| 897 | the item that is being moved. Note, however, that for this move transition, the | - | ||||||||||||||||||||||||
| 898 | ViewTransition.targetIndexes and ViewTransition.targetItems lists are only set when | - | ||||||||||||||||||||||||
| 899 | this transition is triggered by the addition of other items in the positioner; in other | - | ||||||||||||||||||||||||
| 900 | cases, these lists will be empty. See the \l ViewTransition documentation for more details | - | ||||||||||||||||||||||||
| 901 | and examples on using these transitions. | - | ||||||||||||||||||||||||
| 902 | - | |||||||||||||||||||||||||
| 903 | \note In \l {Qt Quick 1}, this transition was applied to all items that were part of the | - | ||||||||||||||||||||||||
| 904 | positioner at the time of its creation. From \l {Qt Quick}{Qt Quick 2} onwards, positioners apply the | - | ||||||||||||||||||||||||
| 905 | \l populate transition to these items instead. | - | ||||||||||||||||||||||||
| 906 | - | |||||||||||||||||||||||||
| 907 | \sa add, ViewTransition, {Qt Quick Examples - Positioners} | - | ||||||||||||||||||||||||
| 908 | */ | - | ||||||||||||||||||||||||
| 909 | /*! | - | ||||||||||||||||||||||||
| 910 | \qmlproperty real QtQuick::Column::spacing | - | ||||||||||||||||||||||||
| 911 | - | |||||||||||||||||||||||||
| 912 | The spacing is the amount in pixels left empty between adjacent | - | ||||||||||||||||||||||||
| 913 | items. The default spacing is 0. | - | ||||||||||||||||||||||||
| 914 | - | |||||||||||||||||||||||||
| 915 | \sa Grid::spacing | - | ||||||||||||||||||||||||
| 916 | */ | - | ||||||||||||||||||||||||
| 917 | /*! | - | ||||||||||||||||||||||||
| 918 | \qmlmethod QtQuick::Column::forceLayout() | - | ||||||||||||||||||||||||
| 919 | \since 5.9 | - | ||||||||||||||||||||||||
| 920 | - | |||||||||||||||||||||||||
| 921 | Column typically positions its children once per frame. This means that | - | ||||||||||||||||||||||||
| 922 | inside script blocks it is possible for the underlying children to have changed, | - | ||||||||||||||||||||||||
| 923 | but the Column to have not yet been updated accordingly. | - | ||||||||||||||||||||||||
| 924 | - | |||||||||||||||||||||||||
| 925 | This method forces the Column to immediately respond to any outstanding | - | ||||||||||||||||||||||||
| 926 | changes in its children. | - | ||||||||||||||||||||||||
| 927 | - | |||||||||||||||||||||||||
| 928 | \b Note: methods in general should only be called after the Component has completed. | - | ||||||||||||||||||||||||
| 929 | */ | - | ||||||||||||||||||||||||
| 930 | /*! | - | ||||||||||||||||||||||||
| 931 | \qmlsignal QtQuick::Column::positioningComplete() | - | ||||||||||||||||||||||||
| 932 | \since 5.9 | - | ||||||||||||||||||||||||
| 933 | - | |||||||||||||||||||||||||
| 934 | This signal is emitted when positioning has been completed. | - | ||||||||||||||||||||||||
| 935 | - | |||||||||||||||||||||||||
| 936 | The corresponding handler is \c onPositioningComplete. | - | ||||||||||||||||||||||||
| 937 | */ | - | ||||||||||||||||||||||||
| 938 | - | |||||||||||||||||||||||||
| 939 | QQuickColumn::QQuickColumn(QQuickItem *parent) | - | ||||||||||||||||||||||||
| 940 | : QQuickBasePositioner(Vertical, parent) | - | ||||||||||||||||||||||||
| 941 | { | - | ||||||||||||||||||||||||
| 942 | } executed 11162 times by 16 tests: end of blockExecuted by:
| 11162 | ||||||||||||||||||||||||
| 943 | - | |||||||||||||||||||||||||
| 944 | void QQuickColumn::doPositioning(QSizeF *contentSize) | - | ||||||||||||||||||||||||
| 945 | { | - | ||||||||||||||||||||||||
| 946 | //Precondition: All items in the positioned list have a valid item pointer and should be positioned | - | ||||||||||||||||||||||||
| 947 | qreal voffset = topPadding(); | - | ||||||||||||||||||||||||
| 948 | const qreal padding = leftPadding() + rightPadding(); | - | ||||||||||||||||||||||||
| 949 | contentSize->setWidth(qMax(contentSize->width(), padding)); | - | ||||||||||||||||||||||||
| 950 | - | |||||||||||||||||||||||||
| 951 | for (int ii = 0; ii < positionedItems.count(); ++ii) {
| 37564-110836 | ||||||||||||||||||||||||
| 952 | PositionedItem &child = positionedItems[ii]; | - | ||||||||||||||||||||||||
| 953 | positionItem(child.itemX() + leftPadding() - child.leftPadding, voffset, &child); | - | ||||||||||||||||||||||||
| 954 | child.updatePadding(leftPadding(), topPadding(), rightPadding(), bottomPadding()); | - | ||||||||||||||||||||||||
| 955 | contentSize->setWidth(qMax(contentSize->width(), child.item->width() + padding)); | - | ||||||||||||||||||||||||
| 956 | - | |||||||||||||||||||||||||
| 957 | voffset += child.item->height(); | - | ||||||||||||||||||||||||
| 958 | voffset += spacing(); | - | ||||||||||||||||||||||||
| 959 | } executed 110836 times by 15 tests: end of blockExecuted by:
| 110836 | ||||||||||||||||||||||||
| 960 | - | |||||||||||||||||||||||||
| 961 | if (voffset - topPadding() != 0)//If we positioned any items, undo the spacing from the last item
| 278-37286 | ||||||||||||||||||||||||
| 962 | voffset -= spacing(); executed 37286 times by 15 tests: voffset -= spacing();Executed by:
| 37286 | ||||||||||||||||||||||||
| 963 | contentSize->setHeight(voffset + bottomPadding()); | - | ||||||||||||||||||||||||
| 964 | } executed 37564 times by 16 tests: end of blockExecuted by:
| 37564 | ||||||||||||||||||||||||
| 965 | - | |||||||||||||||||||||||||
| 966 | void QQuickColumn::reportConflictingAnchors() | - | ||||||||||||||||||||||||
| 967 | { | - | ||||||||||||||||||||||||
| 968 | QQuickBasePositionerPrivate *d = static_cast<QQuickBasePositionerPrivate*>(QQuickBasePositionerPrivate::get(this)); | - | ||||||||||||||||||||||||
| 969 | for (int ii = 0; ii < positionedItems.count(); ++ii) {
| 37564-110840 | ||||||||||||||||||||||||
| 970 | const PositionedItem &child = positionedItems.at(ii); | - | ||||||||||||||||||||||||
| 971 | if (child.item) {
| 0-110840 | ||||||||||||||||||||||||
| 972 | QQuickAnchors *anchors = QQuickItemPrivate::get(static_cast<QQuickItem *>(child.item))->_anchors; | - | ||||||||||||||||||||||||
| 973 | if (anchors) {
| 180-110660 | ||||||||||||||||||||||||
| 974 | QQuickAnchors::Anchors usedAnchors = anchors->usedAnchors(); | - | ||||||||||||||||||||||||
| 975 | if (usedAnchors & QQuickAnchors::TopAnchor || | - | ||||||||||||||||||||||||
| 976 | usedAnchors & QQuickAnchors::BottomAnchor || | - | ||||||||||||||||||||||||
| 977 | usedAnchors & QQuickAnchors::VCenterAnchor || | - | ||||||||||||||||||||||||
| 978 | anchors->fill() || anchors->centerIn()) {
| 0-178 | ||||||||||||||||||||||||
| 979 | d->anchorConflict = true; | - | ||||||||||||||||||||||||
| 980 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||
| 981 | } | - | ||||||||||||||||||||||||
| 982 | } executed 176 times by 2 tests: end of blockExecuted by:
| 176 | ||||||||||||||||||||||||
| 983 | } executed 110836 times by 15 tests: end of blockExecuted by:
| 110836 | ||||||||||||||||||||||||
| 984 | } executed 110836 times by 15 tests: end of blockExecuted by:
| 110836 | ||||||||||||||||||||||||
| 985 | if (d->anchorConflict) {
| 4-37564 | ||||||||||||||||||||||||
| 986 | qmlWarning(this) << "Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column." | - | ||||||||||||||||||||||||
| 987 | << " Column will not function."; | - | ||||||||||||||||||||||||
| 988 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 989 | } executed 37568 times by 16 tests: end of blockExecuted by:
| 37568 | ||||||||||||||||||||||||
| 990 | /*! | - | ||||||||||||||||||||||||
| 991 | \qmltype Row | - | ||||||||||||||||||||||||
| 992 | \instantiates QQuickRow | - | ||||||||||||||||||||||||
| 993 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||
| 994 | \inherits Item | - | ||||||||||||||||||||||||
| 995 | \ingroup qtquick-positioners | - | ||||||||||||||||||||||||
| 996 | \brief Positions its children in a row. | - | ||||||||||||||||||||||||
| 997 | - | |||||||||||||||||||||||||
| 998 | Row is a type that positions its child items along a single row. | - | ||||||||||||||||||||||||
| 999 | It can be used as a convenient way to horizontally position a series of items without | - | ||||||||||||||||||||||||
| 1000 | using \l {Positioning with Anchors}{anchors}. | - | ||||||||||||||||||||||||
| 1001 | - | |||||||||||||||||||||||||
| 1002 | Below is a Row that contains three rectangles of various sizes: | - | ||||||||||||||||||||||||
| 1003 | - | |||||||||||||||||||||||||
| 1004 | \snippet qml/row/row.qml document | - | ||||||||||||||||||||||||
| 1005 | - | |||||||||||||||||||||||||
| 1006 | The Row automatically positions these items in a horizontal formation, like this: | - | ||||||||||||||||||||||||
| 1007 | - | |||||||||||||||||||||||||
| 1008 | \image horizontalpositioner_example.png | - | ||||||||||||||||||||||||
| 1009 | - | |||||||||||||||||||||||||
| 1010 | If an item within a Row is not \l {Item::}{visible}, or if it has a width or | - | ||||||||||||||||||||||||
| 1011 | height of 0, the item will not be laid out and it will not be visible within the | - | ||||||||||||||||||||||||
| 1012 | row. Also, since a Row automatically positions its children horizontally, a child | - | ||||||||||||||||||||||||
| 1013 | item within a Row should not set its \l {Item::x}{x} position or horizontally | - | ||||||||||||||||||||||||
| 1014 | anchor itself using the \l {Item::anchors.left}{left}, \l {Item::anchors.right}{right}, | - | ||||||||||||||||||||||||
| 1015 | \l {Item::anchors.horizontalCenter}{anchors.horizontalCenter}, \l {Item::anchors.fill}{fill} | - | ||||||||||||||||||||||||
| 1016 | or \l {Item::anchors.centerIn}{centerIn} anchors. If you need to perform these actions, | - | ||||||||||||||||||||||||
| 1017 | consider positioning the items without the use of a Row. | - | ||||||||||||||||||||||||
| 1018 | - | |||||||||||||||||||||||||
| 1019 | Note that items in a Row can use the \l Positioner attached property to access | - | ||||||||||||||||||||||||
| 1020 | more information about its position within the Row. | - | ||||||||||||||||||||||||
| 1021 | - | |||||||||||||||||||||||||
| 1022 | For more information on using Row and other related positioner-types, see | - | ||||||||||||||||||||||||
| 1023 | \l{Item Positioners}. | - | ||||||||||||||||||||||||
| 1024 | - | |||||||||||||||||||||||||
| 1025 | - | |||||||||||||||||||||||||
| 1026 | \sa Column, Grid, Flow, Positioner, RowLayout, {Qt Quick Examples - Positioners} | - | ||||||||||||||||||||||||
| 1027 | */ | - | ||||||||||||||||||||||||
| 1028 | /*! | - | ||||||||||||||||||||||||
| 1029 | \since 5.6 | - | ||||||||||||||||||||||||
| 1030 | \qmlproperty real QtQuick::Row::padding | - | ||||||||||||||||||||||||
| 1031 | \qmlproperty real QtQuick::Row::topPadding | - | ||||||||||||||||||||||||
| 1032 | \qmlproperty real QtQuick::Row::leftPadding | - | ||||||||||||||||||||||||
| 1033 | \qmlproperty real QtQuick::Row::bottomPadding | - | ||||||||||||||||||||||||
| 1034 | \qmlproperty real QtQuick::Row::rightPadding | - | ||||||||||||||||||||||||
| 1035 | - | |||||||||||||||||||||||||
| 1036 | These properties hold the padding around the content. | - | ||||||||||||||||||||||||
| 1037 | */ | - | ||||||||||||||||||||||||
| 1038 | /*! | - | ||||||||||||||||||||||||
| 1039 | \qmlproperty Transition QtQuick::Row::populate | - | ||||||||||||||||||||||||
| 1040 | - | |||||||||||||||||||||||||
| 1041 | This property holds the transition to be run for items that are part of | - | ||||||||||||||||||||||||
| 1042 | this positioner at the time of its creation. The transition is run when the positioner | - | ||||||||||||||||||||||||
| 1043 | is first created. | - | ||||||||||||||||||||||||
| 1044 | - | |||||||||||||||||||||||||
| 1045 | The transition can use the \l ViewTransition property to access more details about | - | ||||||||||||||||||||||||
| 1046 | the item that is being added. See the \l ViewTransition documentation for more details | - | ||||||||||||||||||||||||
| 1047 | and examples on using these transitions. | - | ||||||||||||||||||||||||
| 1048 | - | |||||||||||||||||||||||||
| 1049 | \sa add, ViewTransition, {Qt Quick Examples - Positioners} | - | ||||||||||||||||||||||||
| 1050 | */ | - | ||||||||||||||||||||||||
| 1051 | /*! | - | ||||||||||||||||||||||||
| 1052 | \qmlproperty Transition QtQuick::Row::add | - | ||||||||||||||||||||||||
| 1053 | - | |||||||||||||||||||||||||
| 1054 | This property holds the transition to be run for items that are added to this | - | ||||||||||||||||||||||||
| 1055 | positioner. For a positioner, this applies to: | - | ||||||||||||||||||||||||
| 1056 | - | |||||||||||||||||||||||||
| 1057 | \list | - | ||||||||||||||||||||||||
| 1058 | \li Items that are created or reparented as a child of the positioner after the | - | ||||||||||||||||||||||||
| 1059 | positioner has been created | - | ||||||||||||||||||||||||
| 1060 | \li Child items that change their \l Item::visible property from false to true, and thus | - | ||||||||||||||||||||||||
| 1061 | are now visible | - | ||||||||||||||||||||||||
| 1062 | \endlist | - | ||||||||||||||||||||||||
| 1063 | - | |||||||||||||||||||||||||
| 1064 | The transition can use the \l ViewTransition property to access more details about | - | ||||||||||||||||||||||||
| 1065 | the item that is being added. See the \l ViewTransition documentation for more details | - | ||||||||||||||||||||||||
| 1066 | and examples on using these transitions. | - | ||||||||||||||||||||||||
| 1067 | - | |||||||||||||||||||||||||
| 1068 | \note This transition is not applied to the items that are already part of the positioner | - | ||||||||||||||||||||||||
| 1069 | at the time of its creation. In this case, the \l populate transition is applied instead. | - | ||||||||||||||||||||||||
| 1070 | - | |||||||||||||||||||||||||
| 1071 | \sa populate, ViewTransition, {Qt Quick Examples - Positioners} | - | ||||||||||||||||||||||||
| 1072 | */ | - | ||||||||||||||||||||||||
| 1073 | /*! | - | ||||||||||||||||||||||||
| 1074 | \qmlproperty Transition QtQuick::Row::move | - | ||||||||||||||||||||||||
| 1075 | - | |||||||||||||||||||||||||
| 1076 | This property holds the transition to run for items that have moved within the | - | ||||||||||||||||||||||||
| 1077 | positioner. For a positioner, this applies to: | - | ||||||||||||||||||||||||
| 1078 | - | |||||||||||||||||||||||||
| 1079 | \list | - | ||||||||||||||||||||||||
| 1080 | \li Child items that move when they are displaced due to the addition, removal or | - | ||||||||||||||||||||||||
| 1081 | rearrangement of other items in the positioner | - | ||||||||||||||||||||||||
| 1082 | \li Child items that are repositioned due to the resizing of other items in the positioner | - | ||||||||||||||||||||||||
| 1083 | \endlist | - | ||||||||||||||||||||||||
| 1084 | - | |||||||||||||||||||||||||
| 1085 | The transition can use the \l ViewTransition property to access more details about | - | ||||||||||||||||||||||||
| 1086 | the item that is being moved. Note, however, that for this move transition, the | - | ||||||||||||||||||||||||
| 1087 | ViewTransition.targetIndexes and ViewTransition.targetItems lists are only set when | - | ||||||||||||||||||||||||
| 1088 | this transition is triggered by the addition of other items in the positioner; in other | - | ||||||||||||||||||||||||
| 1089 | cases, these lists will be empty. See the \l ViewTransition documentation for more details | - | ||||||||||||||||||||||||
| 1090 | and examples on using these transitions. | - | ||||||||||||||||||||||||
| 1091 | - | |||||||||||||||||||||||||
| 1092 | \note In \l {Qt Quick 1}, this transition was applied to all items that were part of the | - | ||||||||||||||||||||||||
| 1093 | positioner at the time of its creation. From \l {Qt Quick}{QtQuick 2} onwards, positioners apply the | - | ||||||||||||||||||||||||
| 1094 | \l populate transition to these items instead. | - | ||||||||||||||||||||||||
| 1095 | - | |||||||||||||||||||||||||
| 1096 | \sa add, ViewTransition, {Qt Quick Examples - Positioners} | - | ||||||||||||||||||||||||
| 1097 | */ | - | ||||||||||||||||||||||||
| 1098 | /*! | - | ||||||||||||||||||||||||
| 1099 | \qmlproperty real QtQuick::Row::spacing | - | ||||||||||||||||||||||||
| 1100 | - | |||||||||||||||||||||||||
| 1101 | The spacing is the amount in pixels left empty between adjacent | - | ||||||||||||||||||||||||
| 1102 | items. The default spacing is 0. | - | ||||||||||||||||||||||||
| 1103 | - | |||||||||||||||||||||||||
| 1104 | \sa Grid::spacing | - | ||||||||||||||||||||||||
| 1105 | */ | - | ||||||||||||||||||||||||
| 1106 | /*! | - | ||||||||||||||||||||||||
| 1107 | \qmlmethod QtQuick::Row::forceLayout() | - | ||||||||||||||||||||||||
| 1108 | \since 5.9 | - | ||||||||||||||||||||||||
| 1109 | - | |||||||||||||||||||||||||
| 1110 | Row typically positions its children once per frame. This means that | - | ||||||||||||||||||||||||
| 1111 | inside script blocks it is possible for the underlying children to have changed, | - | ||||||||||||||||||||||||
| 1112 | but the Row to have not yet been updated accordingly. | - | ||||||||||||||||||||||||
| 1113 | - | |||||||||||||||||||||||||
| 1114 | This method forces the Row to immediately respond to any outstanding | - | ||||||||||||||||||||||||
| 1115 | changes in its children. | - | ||||||||||||||||||||||||
| 1116 | - | |||||||||||||||||||||||||
| 1117 | \b Note: methods in general should only be called after the Component has completed. | - | ||||||||||||||||||||||||
| 1118 | */ | - | ||||||||||||||||||||||||
| 1119 | /*! | - | ||||||||||||||||||||||||
| 1120 | \qmlsignal QtQuick::Row::positioningComplete() | - | ||||||||||||||||||||||||
| 1121 | \since 5.9 | - | ||||||||||||||||||||||||
| 1122 | - | |||||||||||||||||||||||||
| 1123 | This signal is emitted when positioning has been completed. | - | ||||||||||||||||||||||||
| 1124 | - | |||||||||||||||||||||||||
| 1125 | The corresponding handler is \c onPositioningComplete. | - | ||||||||||||||||||||||||
| 1126 | */ | - | ||||||||||||||||||||||||
| 1127 | - | |||||||||||||||||||||||||
| 1128 | class QQuickRowPrivate : public QQuickBasePositionerPrivate | - | ||||||||||||||||||||||||
| 1129 | { | - | ||||||||||||||||||||||||
| 1130 | Q_DECLARE_PUBLIC(QQuickRow) | - | ||||||||||||||||||||||||
| 1131 | - | |||||||||||||||||||||||||
| 1132 | public: | - | ||||||||||||||||||||||||
| 1133 | QQuickRowPrivate() | - | ||||||||||||||||||||||||
| 1134 | : QQuickBasePositionerPrivate() | - | ||||||||||||||||||||||||
| 1135 | {} executed 564 times by 14 tests: end of blockExecuted by:
| 564 | ||||||||||||||||||||||||
| 1136 | - | |||||||||||||||||||||||||
| 1137 | void effectiveLayoutDirectionChange() override | - | ||||||||||||||||||||||||
| 1138 | { | - | ||||||||||||||||||||||||
| 1139 | Q_Q(QQuickRow); | - | ||||||||||||||||||||||||
| 1140 | // For RTL layout the positioning changes when the width changes. | - | ||||||||||||||||||||||||
| 1141 | if (getEffectiveLayoutDirection(q) == Qt::RightToLeft)
| 10-24 | ||||||||||||||||||||||||
| 1142 | addItemChangeListener(this, QQuickItemPrivate::Geometry); executed 24 times by 2 tests: addItemChangeListener(this, QQuickItemPrivate::Geometry);Executed by:
| 24 | ||||||||||||||||||||||||
| 1143 | else | - | ||||||||||||||||||||||||
| 1144 | removeItemChangeListener(this, QQuickItemPrivate::Geometry); executed 10 times by 2 tests: removeItemChangeListener(this, QQuickItemPrivate::Geometry);Executed by:
| 10 | ||||||||||||||||||||||||
| 1145 | // Don't postpone, as it might be the only trigger for visible changes. | - | ||||||||||||||||||||||||
| 1146 | q->prePositioning(); | - | ||||||||||||||||||||||||
| 1147 | emit q->effectiveLayoutDirectionChanged(); | - | ||||||||||||||||||||||||
| 1148 | } executed 34 times by 2 tests: end of blockExecuted by:
| 34 | ||||||||||||||||||||||||
| 1149 | }; | - | ||||||||||||||||||||||||
| 1150 | - | |||||||||||||||||||||||||
| 1151 | QQuickRow::QQuickRow(QQuickItem *parent) | - | ||||||||||||||||||||||||
| 1152 | : QQuickBasePositioner(*new QQuickRowPrivate, Horizontal, parent) | - | ||||||||||||||||||||||||
| 1153 | { | - | ||||||||||||||||||||||||
| 1154 | } executed 564 times by 14 tests: end of blockExecuted by:
| 564 | ||||||||||||||||||||||||
| 1155 | /*! | - | ||||||||||||||||||||||||
| 1156 | \qmlproperty enumeration QtQuick::Row::layoutDirection | - | ||||||||||||||||||||||||
| 1157 | - | |||||||||||||||||||||||||
| 1158 | This property holds the layoutDirection of the row. | - | ||||||||||||||||||||||||
| 1159 | - | |||||||||||||||||||||||||
| 1160 | Possible values: | - | ||||||||||||||||||||||||
| 1161 | - | |||||||||||||||||||||||||
| 1162 | \list | - | ||||||||||||||||||||||||
| 1163 | \li Qt.LeftToRight (default) - Items are laid out from left to right. If the width of the row is explicitly set, | - | ||||||||||||||||||||||||
| 1164 | the left anchor remains to the left of the row. | - | ||||||||||||||||||||||||
| 1165 | \li Qt.RightToLeft - Items are laid out from right to left. If the width of the row is explicitly set, | - | ||||||||||||||||||||||||
| 1166 | the right anchor remains to the right of the row. | - | ||||||||||||||||||||||||
| 1167 | \endlist | - | ||||||||||||||||||||||||
| 1168 | - | |||||||||||||||||||||||||
| 1169 | \sa Grid::layoutDirection, Flow::layoutDirection, {Qt Quick Examples - Right to Left} | - | ||||||||||||||||||||||||
| 1170 | */ | - | ||||||||||||||||||||||||
| 1171 | - | |||||||||||||||||||||||||
| 1172 | Qt::LayoutDirection QQuickRow::layoutDirection() const | - | ||||||||||||||||||||||||
| 1173 | { | - | ||||||||||||||||||||||||
| 1174 | return QQuickBasePositionerPrivate::getLayoutDirection(this); never executed: return QQuickBasePositionerPrivate::getLayoutDirection(this); | 0 | ||||||||||||||||||||||||
| 1175 | } | - | ||||||||||||||||||||||||
| 1176 | - | |||||||||||||||||||||||||
| 1177 | void QQuickRow::setLayoutDirection(Qt::LayoutDirection layoutDirection) | - | ||||||||||||||||||||||||
| 1178 | { | - | ||||||||||||||||||||||||
| 1179 | QQuickBasePositionerPrivate *d = static_cast<QQuickBasePositionerPrivate* >(QQuickBasePositionerPrivate::get(this)); | - | ||||||||||||||||||||||||
| 1180 | if (d->layoutDirection != layoutDirection) {
| 24-28 | ||||||||||||||||||||||||
| 1181 | d->layoutDirection = layoutDirection; | - | ||||||||||||||||||||||||
| 1182 | emit layoutDirectionChanged(); | - | ||||||||||||||||||||||||
| 1183 | d->effectiveLayoutDirectionChange(); | - | ||||||||||||||||||||||||
| 1184 | } executed 24 times by 2 tests: end of blockExecuted by:
| 24 | ||||||||||||||||||||||||
| 1185 | } executed 52 times by 2 tests: end of blockExecuted by:
| 52 | ||||||||||||||||||||||||
| 1186 | /*! | - | ||||||||||||||||||||||||
| 1187 | \qmlproperty enumeration QtQuick::Row::effectiveLayoutDirection | - | ||||||||||||||||||||||||
| 1188 | This property holds the effective layout direction of the row. | - | ||||||||||||||||||||||||
| 1189 | - | |||||||||||||||||||||||||
| 1190 | When using the attached property \l {LayoutMirroring::enabled}{LayoutMirroring::enabled} for locale layouts, | - | ||||||||||||||||||||||||
| 1191 | the visual layout direction of the row positioner will be mirrored. However, the | - | ||||||||||||||||||||||||
| 1192 | property \l {Row::layoutDirection}{layoutDirection} will remain unchanged. | - | ||||||||||||||||||||||||
| 1193 | - | |||||||||||||||||||||||||
| 1194 | \sa Row::layoutDirection, {LayoutMirroring}{LayoutMirroring} | - | ||||||||||||||||||||||||
| 1195 | */ | - | ||||||||||||||||||||||||
| 1196 | - | |||||||||||||||||||||||||
| 1197 | Qt::LayoutDirection QQuickRow::effectiveLayoutDirection() const | - | ||||||||||||||||||||||||
| 1198 | { | - | ||||||||||||||||||||||||
| 1199 | return QQuickBasePositionerPrivate::getEffectiveLayoutDirection(this); never executed: return QQuickBasePositionerPrivate::getEffectiveLayoutDirection(this); | 0 | ||||||||||||||||||||||||
| 1200 | } | - | ||||||||||||||||||||||||
| 1201 | - | |||||||||||||||||||||||||
| 1202 | void QQuickRow::doPositioning(QSizeF *contentSize) | - | ||||||||||||||||||||||||
| 1203 | { | - | ||||||||||||||||||||||||
| 1204 | //Precondition: All items in the positioned list have a valid item pointer and should be positioned | - | ||||||||||||||||||||||||
| 1205 | QQuickBasePositionerPrivate *d = static_cast<QQuickBasePositionerPrivate* >(QQuickBasePositionerPrivate::get(this)); | - | ||||||||||||||||||||||||
| 1206 | qreal hoffset1 = leftPadding(); | - | ||||||||||||||||||||||||
| 1207 | qreal hoffset2 = rightPadding(); | - | ||||||||||||||||||||||||
| 1208 | if (!d->isLeftToRight())
| 82-726 | ||||||||||||||||||||||||
| 1209 | qSwap(hoffset1, hoffset2); executed 82 times by 2 tests: qSwap(hoffset1, hoffset2);Executed by:
| 82 | ||||||||||||||||||||||||
| 1210 | qreal hoffset = hoffset1; | - | ||||||||||||||||||||||||
| 1211 | const qreal padding = topPadding() + bottomPadding(); | - | ||||||||||||||||||||||||
| 1212 | contentSize->setHeight(qMax(contentSize->height(), padding)); | - | ||||||||||||||||||||||||
| 1213 | - | |||||||||||||||||||||||||
| 1214 | QList<qreal> hoffsets; | - | ||||||||||||||||||||||||
| 1215 | for (int ii = 0; ii < positionedItems.count(); ++ii) {
| 808-3036 | ||||||||||||||||||||||||
| 1216 | PositionedItem &child = positionedItems[ii]; | - | ||||||||||||||||||||||||
| 1217 | - | |||||||||||||||||||||||||
| 1218 | if (d->isLeftToRight()) {
| 242-2794 | ||||||||||||||||||||||||
| 1219 | positionItem(hoffset, child.itemY() + topPadding() - child.topPadding, &child); | - | ||||||||||||||||||||||||
| 1220 | child.updatePadding(leftPadding(), topPadding(), rightPadding(), bottomPadding()); | - | ||||||||||||||||||||||||
| 1221 | } else { executed 2794 times by 13 tests: end of blockExecuted by:
| 2794 | ||||||||||||||||||||||||
| 1222 | hoffsets << hoffset; | - | ||||||||||||||||||||||||
| 1223 | } executed 242 times by 2 tests: end of blockExecuted by:
| 242 | ||||||||||||||||||||||||
| 1224 | - | |||||||||||||||||||||||||
| 1225 | contentSize->setHeight(qMax(contentSize->height(), child.item->height() + padding)); | - | ||||||||||||||||||||||||
| 1226 | - | |||||||||||||||||||||||||
| 1227 | hoffset += child.item->width(); | - | ||||||||||||||||||||||||
| 1228 | hoffset += spacing(); | - | ||||||||||||||||||||||||
| 1229 | } executed 3036 times by 13 tests: end of blockExecuted by:
| 3036 | ||||||||||||||||||||||||
| 1230 | - | |||||||||||||||||||||||||
| 1231 | if (hoffset - hoffset1 != 0)//If we positioned any items, undo the extra spacing from the last item
| 284-524 | ||||||||||||||||||||||||
| 1232 | hoffset -= spacing(); executed 524 times by 13 tests: hoffset -= spacing();Executed by:
| 524 | ||||||||||||||||||||||||
| 1233 | contentSize->setWidth(hoffset + hoffset2); | - | ||||||||||||||||||||||||
| 1234 | - | |||||||||||||||||||||||||
| 1235 | if (d->isLeftToRight())
| 82-726 | ||||||||||||||||||||||||
| 1236 | return; executed 726 times by 14 tests: return;Executed by:
| 726 | ||||||||||||||||||||||||
| 1237 | - | |||||||||||||||||||||||||
| 1238 | //Right to Left layout | - | ||||||||||||||||||||||||
| 1239 | qreal end = 0; | - | ||||||||||||||||||||||||
| 1240 | if (!widthValid())
| 30-52 | ||||||||||||||||||||||||
| 1241 | end = contentSize->width(); executed 52 times by 2 tests: end = contentSize->width();Executed by:
| 52 | ||||||||||||||||||||||||
| 1242 | else | - | ||||||||||||||||||||||||
| 1243 | end = width(); executed 30 times by 1 test: end = width();Executed by:
| 30 | ||||||||||||||||||||||||
| 1244 | - | |||||||||||||||||||||||||
| 1245 | int acc = 0; | - | ||||||||||||||||||||||||
| 1246 | for (int ii = 0; ii < positionedItems.count(); ++ii) {
| 82-242 | ||||||||||||||||||||||||
| 1247 | PositionedItem &child = positionedItems[ii]; | - | ||||||||||||||||||||||||
| 1248 | hoffset = end - hoffsets[acc++] - child.item->width(); | - | ||||||||||||||||||||||||
| 1249 | positionItem(hoffset, child.itemY() + topPadding() - child.topPadding, &child); | - | ||||||||||||||||||||||||
| 1250 | child.updatePadding(leftPadding(), topPadding(), rightPadding(), bottomPadding()); | - | ||||||||||||||||||||||||
| 1251 | } executed 242 times by 2 tests: end of blockExecuted by:
| 242 | ||||||||||||||||||||||||
| 1252 | } executed 82 times by 2 tests: end of blockExecuted by:
| 82 | ||||||||||||||||||||||||
| 1253 | - | |||||||||||||||||||||||||
| 1254 | void QQuickRow::reportConflictingAnchors() | - | ||||||||||||||||||||||||
| 1255 | { | - | ||||||||||||||||||||||||
| 1256 | QQuickBasePositionerPrivate *d = static_cast<QQuickBasePositionerPrivate*>(QQuickBasePositionerPrivate::get(this)); | - | ||||||||||||||||||||||||
| 1257 | for (int ii = 0; ii < positionedItems.count(); ++ii) {
| 808-3040 | ||||||||||||||||||||||||
| 1258 | const PositionedItem &child = positionedItems.at(ii); | - | ||||||||||||||||||||||||
| 1259 | if (child.item) {
| 0-3040 | ||||||||||||||||||||||||
| 1260 | QQuickAnchors *anchors = QQuickItemPrivate::get(static_cast<QQuickItem *>(child.item))->_anchors; | - | ||||||||||||||||||||||||
| 1261 | if (anchors) {
| 62-2978 | ||||||||||||||||||||||||
| 1262 | QQuickAnchors::Anchors usedAnchors = anchors->usedAnchors(); | - | ||||||||||||||||||||||||
| 1263 | if (usedAnchors & QQuickAnchors::LeftAnchor || | - | ||||||||||||||||||||||||
| 1264 | usedAnchors & QQuickAnchors::RightAnchor || | - | ||||||||||||||||||||||||
| 1265 | usedAnchors & QQuickAnchors::HCenterAnchor || | - | ||||||||||||||||||||||||
| 1266 | anchors->fill() || anchors->centerIn()) {
| 0-58 | ||||||||||||||||||||||||
| 1267 | d->anchorConflict = true; | - | ||||||||||||||||||||||||
| 1268 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||
| 1269 | } | - | ||||||||||||||||||||||||
| 1270 | } executed 58 times by 3 tests: end of blockExecuted by:
| 58 | ||||||||||||||||||||||||
| 1271 | } executed 3036 times by 13 tests: end of blockExecuted by:
| 3036 | ||||||||||||||||||||||||
| 1272 | } executed 3036 times by 13 tests: end of blockExecuted by:
| 3036 | ||||||||||||||||||||||||
| 1273 | if (d->anchorConflict)
| 4-808 | ||||||||||||||||||||||||
| 1274 | qmlWarning(this) << "Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row." executed 4 times by 1 test: qmlWarning(this) << "Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row." << " Row will not function.";Executed by:
| 4 | ||||||||||||||||||||||||
| 1275 | << " Row will not function."; executed 4 times by 1 test: qmlWarning(this) << "Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row." << " Row will not function.";Executed by:
| 4 | ||||||||||||||||||||||||
| 1276 | } executed 812 times by 14 tests: end of blockExecuted by:
| 812 | ||||||||||||||||||||||||
| 1277 | - | |||||||||||||||||||||||||
| 1278 | /*! | - | ||||||||||||||||||||||||
| 1279 | \qmltype Grid | - | ||||||||||||||||||||||||
| 1280 | \instantiates QQuickGrid | - | ||||||||||||||||||||||||
| 1281 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||
| 1282 | \inherits Item | - | ||||||||||||||||||||||||
| 1283 | \ingroup qtquick-positioners | - | ||||||||||||||||||||||||
| 1284 | \brief Positions its children in grid formation. | - | ||||||||||||||||||||||||
| 1285 | - | |||||||||||||||||||||||||
| 1286 | Grid is a type that positions its child items in grid formation. | - | ||||||||||||||||||||||||
| 1287 | - | |||||||||||||||||||||||||
| 1288 | A Grid creates a grid of cells that is large enough to hold all of its | - | ||||||||||||||||||||||||
| 1289 | child items, and places these items in the cells from left to right | - | ||||||||||||||||||||||||
| 1290 | and top to bottom. Each item is positioned at the top-left corner of its | - | ||||||||||||||||||||||||
| 1291 | cell with position (0, 0). | - | ||||||||||||||||||||||||
| 1292 | - | |||||||||||||||||||||||||
| 1293 | A Grid defaults to four columns, and creates as many rows as are necessary to | - | ||||||||||||||||||||||||
| 1294 | fit all of its child items. The number of rows and columns can be constrained | - | ||||||||||||||||||||||||
| 1295 | by setting the \l rows and \l columns properties. | - | ||||||||||||||||||||||||
| 1296 | - | |||||||||||||||||||||||||
| 1297 | For example, below is a Grid that contains five rectangles of various sizes: | - | ||||||||||||||||||||||||
| 1298 | - | |||||||||||||||||||||||||
| 1299 | \snippet qml/grid/grid.qml document | - | ||||||||||||||||||||||||
| 1300 | - | |||||||||||||||||||||||||
| 1301 | The Grid automatically positions the child items in a grid formation: | - | ||||||||||||||||||||||||
| 1302 | - | |||||||||||||||||||||||||
| 1303 | \image gridLayout_example.png | - | ||||||||||||||||||||||||
| 1304 | - | |||||||||||||||||||||||||
| 1305 | If an item within a Grid is not \l {Item::}{visible}, or if it has a width or | - | ||||||||||||||||||||||||
| 1306 | height of 0, the item will not be laid out and it will not be visible within the | - | ||||||||||||||||||||||||
| 1307 | column. Also, since a Grid automatically positions its children, a child | - | ||||||||||||||||||||||||
| 1308 | item within a Grid should not set its \l {Item::x}{x} or \l {Item::y}{y} positions | - | ||||||||||||||||||||||||
| 1309 | or anchor itself with any of the \l {Item::anchors}{anchor} properties. | - | ||||||||||||||||||||||||
| 1310 | - | |||||||||||||||||||||||||
| 1311 | For more information on using Grid and other related positioner-types, see | - | ||||||||||||||||||||||||
| 1312 | \l{Item Positioners}. | - | ||||||||||||||||||||||||
| 1313 | - | |||||||||||||||||||||||||
| 1314 | - | |||||||||||||||||||||||||
| 1315 | \sa Flow, Row, Column, Positioner, GridLayout, {Qt Quick Examples - Positioners} | - | ||||||||||||||||||||||||
| 1316 | */ | - | ||||||||||||||||||||||||
| 1317 | /*! | - | ||||||||||||||||||||||||
| 1318 | \since 5.6 | - | ||||||||||||||||||||||||
| 1319 | \qmlproperty real QtQuick::Grid::padding | - | ||||||||||||||||||||||||
| 1320 | \qmlproperty real QtQuick::Grid::topPadding | - | ||||||||||||||||||||||||
| 1321 | \qmlproperty real QtQuick::Grid::leftPadding | - | ||||||||||||||||||||||||
| 1322 | \qmlproperty real QtQuick::Grid::bottomPadding | - | ||||||||||||||||||||||||
| 1323 | \qmlproperty real QtQuick::Grid::rightPadding | - | ||||||||||||||||||||||||
| 1324 | - | |||||||||||||||||||||||||
| 1325 | These properties hold the padding around the content. | - | ||||||||||||||||||||||||
| 1326 | */ | - | ||||||||||||||||||||||||
| 1327 | /*! | - | ||||||||||||||||||||||||
| 1328 | \qmlproperty Transition QtQuick::Grid::populate | - | ||||||||||||||||||||||||
| 1329 | - | |||||||||||||||||||||||||
| 1330 | This property holds the transition to be run for items that are part of | - | ||||||||||||||||||||||||
| 1331 | this positioner at the time of its creation. The transition is run when the positioner | - | ||||||||||||||||||||||||
| 1332 | is first created. | - | ||||||||||||||||||||||||
| 1333 | - | |||||||||||||||||||||||||
| 1334 | The transition can use the \l ViewTransition property to access more details about | - | ||||||||||||||||||||||||
| 1335 | the item that is being added. See the \l ViewTransition documentation for more details | - | ||||||||||||||||||||||||
| 1336 | and examples on using these transitions. | - | ||||||||||||||||||||||||
| 1337 | - | |||||||||||||||||||||||||
| 1338 | \sa add, ViewTransition, {Qt Quick Examples - Positioners} | - | ||||||||||||||||||||||||
| 1339 | */ | - | ||||||||||||||||||||||||
| 1340 | /*! | - | ||||||||||||||||||||||||
| 1341 | \qmlproperty Transition QtQuick::Grid::add | - | ||||||||||||||||||||||||
| 1342 | - | |||||||||||||||||||||||||
| 1343 | This property holds the transition to be run for items that are added to this | - | ||||||||||||||||||||||||
| 1344 | positioner. For a positioner, this applies to: | - | ||||||||||||||||||||||||
| 1345 | - | |||||||||||||||||||||||||
| 1346 | \list | - | ||||||||||||||||||||||||
| 1347 | \li Items that are created or reparented as a child of the positioner after the | - | ||||||||||||||||||||||||
| 1348 | positioner has been created | - | ||||||||||||||||||||||||
| 1349 | \li Child items that change their \l Item::visible property from false to true, and thus | - | ||||||||||||||||||||||||
| 1350 | are now visible | - | ||||||||||||||||||||||||
| 1351 | \endlist | - | ||||||||||||||||||||||||
| 1352 | - | |||||||||||||||||||||||||
| 1353 | The transition can use the \l ViewTransition property to access more details about | - | ||||||||||||||||||||||||
| 1354 | the item that is being added. See the \l ViewTransition documentation for more details | - | ||||||||||||||||||||||||
| 1355 | and examples on using these transitions. | - | ||||||||||||||||||||||||
| 1356 | - | |||||||||||||||||||||||||
| 1357 | \note This transition is not applied to the items that are already part of the positioner | - | ||||||||||||||||||||||||
| 1358 | at the time of its creation. In this case, the \l populate transition is applied instead. | - | ||||||||||||||||||||||||
| 1359 | - | |||||||||||||||||||||||||
| 1360 | \sa populate, ViewTransition, {Qt Quick Examples - Positioners} | - | ||||||||||||||||||||||||
| 1361 | */ | - | ||||||||||||||||||||||||
| 1362 | /*! | - | ||||||||||||||||||||||||
| 1363 | \qmlproperty Transition QtQuick::Grid::move | - | ||||||||||||||||||||||||
| 1364 | - | |||||||||||||||||||||||||
| 1365 | This property holds the transition to run for items that have moved within the | - | ||||||||||||||||||||||||
| 1366 | positioner. For a positioner, this applies to: | - | ||||||||||||||||||||||||
| 1367 | - | |||||||||||||||||||||||||
| 1368 | \list | - | ||||||||||||||||||||||||
| 1369 | \li Child items that move when they are displaced due to the addition, removal or | - | ||||||||||||||||||||||||
| 1370 | rearrangement of other items in the positioner | - | ||||||||||||||||||||||||
| 1371 | \li Child items that are repositioned due to the resizing of other items in the positioner | - | ||||||||||||||||||||||||
| 1372 | \endlist | - | ||||||||||||||||||||||||
| 1373 | - | |||||||||||||||||||||||||
| 1374 | The transition can use the \l ViewTransition property to access more details about | - | ||||||||||||||||||||||||
| 1375 | the item that is being moved. Note, however, that for this move transition, the | - | ||||||||||||||||||||||||
| 1376 | ViewTransition.targetIndexes and ViewTransition.targetItems lists are only set when | - | ||||||||||||||||||||||||
| 1377 | this transition is triggered by the addition of other items in the positioner; in other | - | ||||||||||||||||||||||||
| 1378 | cases, these lists will be empty. See the \l ViewTransition documentation for more details | - | ||||||||||||||||||||||||
| 1379 | and examples on using these transitions. | - | ||||||||||||||||||||||||
| 1380 | - | |||||||||||||||||||||||||
| 1381 | \note In \l {Qt Quick 1}, this transition was applied to all items that were part of the | - | ||||||||||||||||||||||||
| 1382 | positioner at the time of its creation. From \l {Qt Quick}{QtQuick 2} onwards, positioners apply the | - | ||||||||||||||||||||||||
| 1383 | \l populate transition to these items instead. | - | ||||||||||||||||||||||||
| 1384 | - | |||||||||||||||||||||||||
| 1385 | \sa add, ViewTransition, {Qt Quick Examples - Positioners} | - | ||||||||||||||||||||||||
| 1386 | */ | - | ||||||||||||||||||||||||
| 1387 | /*! | - | ||||||||||||||||||||||||
| 1388 | \qmlproperty qreal QtQuick::Grid::spacing | - | ||||||||||||||||||||||||
| 1389 | - | |||||||||||||||||||||||||
| 1390 | The spacing is the amount in pixels left empty between adjacent | - | ||||||||||||||||||||||||
| 1391 | items. The amount of spacing applied will be the same in the | - | ||||||||||||||||||||||||
| 1392 | horizontal and vertical directions. The default spacing is 0. | - | ||||||||||||||||||||||||
| 1393 | - | |||||||||||||||||||||||||
| 1394 | The below example places a Grid containing a red, a blue and a | - | ||||||||||||||||||||||||
| 1395 | green rectangle on a gray background. The area the grid positioner | - | ||||||||||||||||||||||||
| 1396 | occupies is colored white. The positioner on the left has the | - | ||||||||||||||||||||||||
| 1397 | no spacing (the default), and the positioner on the right has | - | ||||||||||||||||||||||||
| 1398 | a spacing of 6. | - | ||||||||||||||||||||||||
| 1399 | - | |||||||||||||||||||||||||
| 1400 | \inlineimage qml-grid-no-spacing.png | - | ||||||||||||||||||||||||
| 1401 | \inlineimage qml-grid-spacing.png | - | ||||||||||||||||||||||||
| 1402 | - | |||||||||||||||||||||||||
| 1403 | \sa rows, columns | - | ||||||||||||||||||||||||
| 1404 | */ | - | ||||||||||||||||||||||||
| 1405 | /*! | - | ||||||||||||||||||||||||
| 1406 | \qmlmethod QtQuick::Grid::forceLayout() | - | ||||||||||||||||||||||||
| 1407 | \since 5.9 | - | ||||||||||||||||||||||||
| 1408 | - | |||||||||||||||||||||||||
| 1409 | Grid typically positions its children once per frame. This means that | - | ||||||||||||||||||||||||
| 1410 | inside script blocks it is possible for the underlying children to have changed, | - | ||||||||||||||||||||||||
| 1411 | but the Grid to have not yet been updated accordingly. | - | ||||||||||||||||||||||||
| 1412 | - | |||||||||||||||||||||||||
| 1413 | This method forces the Grid to immediately respond to any outstanding | - | ||||||||||||||||||||||||
| 1414 | changes in its children. | - | ||||||||||||||||||||||||
| 1415 | - | |||||||||||||||||||||||||
| 1416 | \b Note: methods in general should only be called after the Component has completed. | - | ||||||||||||||||||||||||
| 1417 | */ | - | ||||||||||||||||||||||||
| 1418 | /*! | - | ||||||||||||||||||||||||
| 1419 | \qmlsignal QtQuick::Grid::positioningComplete() | - | ||||||||||||||||||||||||
| 1420 | \since 5.9 | - | ||||||||||||||||||||||||
| 1421 | - | |||||||||||||||||||||||||
| 1422 | This signal is emitted when positioning has been completed. | - | ||||||||||||||||||||||||
| 1423 | - | |||||||||||||||||||||||||
| 1424 | The corresponding handler is \c onPositioningComplete. | - | ||||||||||||||||||||||||
| 1425 | */ | - | ||||||||||||||||||||||||
| 1426 | - | |||||||||||||||||||||||||
| 1427 | class QQuickGridPrivate : public QQuickBasePositionerPrivate | - | ||||||||||||||||||||||||
| 1428 | { | - | ||||||||||||||||||||||||
| 1429 | Q_DECLARE_PUBLIC(QQuickGrid) | - | ||||||||||||||||||||||||
| 1430 | - | |||||||||||||||||||||||||
| 1431 | public: | - | ||||||||||||||||||||||||
| 1432 | QQuickGridPrivate() | - | ||||||||||||||||||||||||
| 1433 | : QQuickBasePositionerPrivate() | - | ||||||||||||||||||||||||
| 1434 | {} executed 368 times by 7 tests: end of blockExecuted by:
| 368 | ||||||||||||||||||||||||
| 1435 | - | |||||||||||||||||||||||||
| 1436 | void effectiveLayoutDirectionChange() override | - | ||||||||||||||||||||||||
| 1437 | { | - | ||||||||||||||||||||||||
| 1438 | Q_Q(QQuickGrid); | - | ||||||||||||||||||||||||
| 1439 | // For RTL layout the positioning changes when the width changes. | - | ||||||||||||||||||||||||
| 1440 | if (getEffectiveLayoutDirection(q) == Qt::RightToLeft)
| 12-22 | ||||||||||||||||||||||||
| 1441 | addItemChangeListener(this, QQuickItemPrivate::Geometry); executed 22 times by 1 test: addItemChangeListener(this, QQuickItemPrivate::Geometry);Executed by:
| 22 | ||||||||||||||||||||||||
| 1442 | else | - | ||||||||||||||||||||||||
| 1443 | removeItemChangeListener(this, QQuickItemPrivate::Geometry); executed 12 times by 1 test: removeItemChangeListener(this, QQuickItemPrivate::Geometry);Executed by:
| 12 | ||||||||||||||||||||||||
| 1444 | // Don't postpone, as it might be the only trigger for visible changes. | - | ||||||||||||||||||||||||
| 1445 | q->prePositioning(); | - | ||||||||||||||||||||||||
| 1446 | emit q->effectiveLayoutDirectionChanged(); | - | ||||||||||||||||||||||||
| 1447 | emit q->effectiveHorizontalAlignmentChanged(q->effectiveHAlign()); | - | ||||||||||||||||||||||||
| 1448 | } executed 34 times by 1 test: end of blockExecuted by:
| 34 | ||||||||||||||||||||||||
| 1449 | }; | - | ||||||||||||||||||||||||
| 1450 | - | |||||||||||||||||||||||||
| 1451 | QQuickGrid::QQuickGrid(QQuickItem *parent) | - | ||||||||||||||||||||||||
| 1452 | : QQuickBasePositioner(*new QQuickGridPrivate, Both, parent) | - | ||||||||||||||||||||||||
| 1453 | , m_rows(-1) | - | ||||||||||||||||||||||||
| 1454 | , m_columns(-1) | - | ||||||||||||||||||||||||
| 1455 | , m_rowSpacing(-1) | - | ||||||||||||||||||||||||
| 1456 | , m_columnSpacing(-1) | - | ||||||||||||||||||||||||
| 1457 | , m_useRowSpacing(false) | - | ||||||||||||||||||||||||
| 1458 | , m_useColumnSpacing(false) | - | ||||||||||||||||||||||||
| 1459 | , m_flow(LeftToRight) | - | ||||||||||||||||||||||||
| 1460 | , m_hItemAlign(AlignLeft) | - | ||||||||||||||||||||||||
| 1461 | , m_vItemAlign(AlignTop) | - | ||||||||||||||||||||||||
| 1462 | { | - | ||||||||||||||||||||||||
| 1463 | } executed 368 times by 7 tests: end of blockExecuted by:
| 368 | ||||||||||||||||||||||||
| 1464 | - | |||||||||||||||||||||||||
| 1465 | /*! | - | ||||||||||||||||||||||||
| 1466 | \qmlproperty int QtQuick::Grid::columns | - | ||||||||||||||||||||||||
| 1467 | - | |||||||||||||||||||||||||
| 1468 | This property holds the number of columns in the grid. The default | - | ||||||||||||||||||||||||
| 1469 | number of columns is 4. | - | ||||||||||||||||||||||||
| 1470 | - | |||||||||||||||||||||||||
| 1471 | If the grid does not have enough items to fill the specified | - | ||||||||||||||||||||||||
| 1472 | number of columns, some columns will be of zero width. | - | ||||||||||||||||||||||||
| 1473 | */ | - | ||||||||||||||||||||||||
| 1474 | - | |||||||||||||||||||||||||
| 1475 | /*! | - | ||||||||||||||||||||||||
| 1476 | \qmlproperty int QtQuick::Grid::rows | - | ||||||||||||||||||||||||
| 1477 | This property holds the number of rows in the grid. | - | ||||||||||||||||||||||||
| 1478 | - | |||||||||||||||||||||||||
| 1479 | If the grid does not have enough items to fill the specified | - | ||||||||||||||||||||||||
| 1480 | number of rows, some rows will be of zero width. | - | ||||||||||||||||||||||||
| 1481 | */ | - | ||||||||||||||||||||||||
| 1482 | - | |||||||||||||||||||||||||
| 1483 | void QQuickGrid::setColumns(const int columns) | - | ||||||||||||||||||||||||
| 1484 | { | - | ||||||||||||||||||||||||
| 1485 | if (columns == m_columns)
| 2-98 | ||||||||||||||||||||||||
| 1486 | return; executed 2 times by 1 test: return;Executed by:
| 2 | ||||||||||||||||||||||||
| 1487 | m_columns = columns; | - | ||||||||||||||||||||||||
| 1488 | prePositioning(); | - | ||||||||||||||||||||||||
| 1489 | emit columnsChanged(); | - | ||||||||||||||||||||||||
| 1490 | } executed 98 times by 6 tests: end of blockExecuted by:
| 98 | ||||||||||||||||||||||||
| 1491 | - | |||||||||||||||||||||||||
| 1492 | void QQuickGrid::setRows(const int rows) | - | ||||||||||||||||||||||||
| 1493 | { | - | ||||||||||||||||||||||||
| 1494 | if (rows == m_rows)
| 2-18 | ||||||||||||||||||||||||
| 1495 | return; executed 2 times by 1 test: return;Executed by:
| 2 | ||||||||||||||||||||||||
| 1496 | m_rows = rows; | - | ||||||||||||||||||||||||
| 1497 | prePositioning(); | - | ||||||||||||||||||||||||
| 1498 | emit rowsChanged(); | - | ||||||||||||||||||||||||
| 1499 | } executed 18 times by 2 tests: end of blockExecuted by:
| 18 | ||||||||||||||||||||||||
| 1500 | - | |||||||||||||||||||||||||
| 1501 | /*! | - | ||||||||||||||||||||||||
| 1502 | \qmlproperty enumeration QtQuick::Grid::flow | - | ||||||||||||||||||||||||
| 1503 | This property holds the flow of the layout. | - | ||||||||||||||||||||||||
| 1504 | - | |||||||||||||||||||||||||
| 1505 | Possible values are: | - | ||||||||||||||||||||||||
| 1506 | - | |||||||||||||||||||||||||
| 1507 | \list | - | ||||||||||||||||||||||||
| 1508 | \li Grid.LeftToRight (default) - Items are positioned next to | - | ||||||||||||||||||||||||
| 1509 | each other in the \l layoutDirection, then wrapped to the next line. | - | ||||||||||||||||||||||||
| 1510 | \li Grid.TopToBottom - Items are positioned next to each | - | ||||||||||||||||||||||||
| 1511 | other from top to bottom, then wrapped to the next column. | - | ||||||||||||||||||||||||
| 1512 | \endlist | - | ||||||||||||||||||||||||
| 1513 | */ | - | ||||||||||||||||||||||||
| 1514 | QQuickGrid::Flow QQuickGrid::flow() const | - | ||||||||||||||||||||||||
| 1515 | { | - | ||||||||||||||||||||||||
| 1516 | return m_flow; executed 6 times by 1 test: return m_flow;Executed by:
| 6 | ||||||||||||||||||||||||
| 1517 | } | - | ||||||||||||||||||||||||
| 1518 | - | |||||||||||||||||||||||||
| 1519 | void QQuickGrid::setFlow(Flow flow) | - | ||||||||||||||||||||||||
| 1520 | { | - | ||||||||||||||||||||||||
| 1521 | if (m_flow != flow) {
| 0-6 | ||||||||||||||||||||||||
| 1522 | m_flow = flow; | - | ||||||||||||||||||||||||
| 1523 | prePositioning(); | - | ||||||||||||||||||||||||
| 1524 | emit flowChanged(); | - | ||||||||||||||||||||||||
| 1525 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||
| 1526 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||
| 1527 | - | |||||||||||||||||||||||||
| 1528 | /*! | - | ||||||||||||||||||||||||
| 1529 | \qmlproperty qreal QtQuick::Grid::rowSpacing | - | ||||||||||||||||||||||||
| 1530 | - | |||||||||||||||||||||||||
| 1531 | This property holds the spacing in pixels between rows. | - | ||||||||||||||||||||||||
| 1532 | - | |||||||||||||||||||||||||
| 1533 | If this property is not set, then spacing is used for the row spacing. | - | ||||||||||||||||||||||||
| 1534 | - | |||||||||||||||||||||||||
| 1535 | By default this property is not set. | - | ||||||||||||||||||||||||
| 1536 | - | |||||||||||||||||||||||||
| 1537 | \sa columnSpacing | - | ||||||||||||||||||||||||
| 1538 | \since 5.0 | - | ||||||||||||||||||||||||
| 1539 | */ | - | ||||||||||||||||||||||||
| 1540 | void QQuickGrid::setRowSpacing(const qreal rowSpacing) | - | ||||||||||||||||||||||||
| 1541 | { | - | ||||||||||||||||||||||||
| 1542 | if (rowSpacing == m_rowSpacing)
| 0-4 | ||||||||||||||||||||||||
| 1543 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1544 | m_rowSpacing = rowSpacing; | - | ||||||||||||||||||||||||
| 1545 | m_useRowSpacing = true; | - | ||||||||||||||||||||||||
| 1546 | prePositioning(); | - | ||||||||||||||||||||||||
| 1547 | emit rowSpacingChanged(); | - | ||||||||||||||||||||||||
| 1548 | } executed 4 times by 2 tests: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 1549 | - | |||||||||||||||||||||||||
| 1550 | /*! | - | ||||||||||||||||||||||||
| 1551 | \qmlproperty qreal QtQuick::Grid::columnSpacing | - | ||||||||||||||||||||||||
| 1552 | - | |||||||||||||||||||||||||
| 1553 | This property holds the spacing in pixels between columns. | - | ||||||||||||||||||||||||
| 1554 | - | |||||||||||||||||||||||||
| 1555 | If this property is not set, then spacing is used for the column spacing. | - | ||||||||||||||||||||||||
| 1556 | - | |||||||||||||||||||||||||
| 1557 | By default this property is not set. | - | ||||||||||||||||||||||||
| 1558 | - | |||||||||||||||||||||||||
| 1559 | \sa rowSpacing | - | ||||||||||||||||||||||||
| 1560 | \since 5.0 | - | ||||||||||||||||||||||||
| 1561 | */ | - | ||||||||||||||||||||||||
| 1562 | void QQuickGrid::setColumnSpacing(const qreal columnSpacing) | - | ||||||||||||||||||||||||
| 1563 | { | - | ||||||||||||||||||||||||
| 1564 | if (columnSpacing == m_columnSpacing)
| 0-4 | ||||||||||||||||||||||||
| 1565 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1566 | m_columnSpacing = columnSpacing; | - | ||||||||||||||||||||||||
| 1567 | m_useColumnSpacing = true; | - | ||||||||||||||||||||||||
| 1568 | prePositioning(); | - | ||||||||||||||||||||||||
| 1569 | emit columnSpacingChanged(); | - | ||||||||||||||||||||||||
| 1570 | } executed 4 times by 2 tests: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 1571 | - | |||||||||||||||||||||||||
| 1572 | /*! | - | ||||||||||||||||||||||||
| 1573 | \qmlproperty enumeration QtQuick::Grid::layoutDirection | - | ||||||||||||||||||||||||
| 1574 | - | |||||||||||||||||||||||||
| 1575 | This property holds the layout direction of the layout. | - | ||||||||||||||||||||||||
| 1576 | - | |||||||||||||||||||||||||
| 1577 | Possible values are: | - | ||||||||||||||||||||||||
| 1578 | - | |||||||||||||||||||||||||
| 1579 | \list | - | ||||||||||||||||||||||||
| 1580 | \li Qt.LeftToRight (default) - Items are positioned from the top to bottom, | - | ||||||||||||||||||||||||
| 1581 | and left to right. The flow direction is dependent on the | - | ||||||||||||||||||||||||
| 1582 | \l Grid::flow property. | - | ||||||||||||||||||||||||
| 1583 | \li Qt.RightToLeft - Items are positioned from the top to bottom, | - | ||||||||||||||||||||||||
| 1584 | and right to left. The flow direction is dependent on the | - | ||||||||||||||||||||||||
| 1585 | \l Grid::flow property. | - | ||||||||||||||||||||||||
| 1586 | \endlist | - | ||||||||||||||||||||||||
| 1587 | - | |||||||||||||||||||||||||
| 1588 | \sa Flow::layoutDirection, Row::layoutDirection, {Qt Quick Examples - Right to Left} | - | ||||||||||||||||||||||||
| 1589 | */ | - | ||||||||||||||||||||||||
| 1590 | Qt::LayoutDirection QQuickGrid::layoutDirection() const | - | ||||||||||||||||||||||||
| 1591 | { | - | ||||||||||||||||||||||||
| 1592 | return QQuickBasePositionerPrivate::getLayoutDirection(this); executed 2 times by 1 test: return QQuickBasePositionerPrivate::getLayoutDirection(this);Executed by:
| 2 | ||||||||||||||||||||||||
| 1593 | } | - | ||||||||||||||||||||||||
| 1594 | - | |||||||||||||||||||||||||
| 1595 | void QQuickGrid::setLayoutDirection(Qt::LayoutDirection layoutDirection) | - | ||||||||||||||||||||||||
| 1596 | { | - | ||||||||||||||||||||||||
| 1597 | QQuickBasePositionerPrivate *d = static_cast<QQuickBasePositionerPrivate*>(QQuickBasePositionerPrivate::get(this)); | - | ||||||||||||||||||||||||
| 1598 | if (d->layoutDirection != layoutDirection) {
| 24-30 | ||||||||||||||||||||||||
| 1599 | d->layoutDirection = layoutDirection; | - | ||||||||||||||||||||||||
| 1600 | emit layoutDirectionChanged(); | - | ||||||||||||||||||||||||
| 1601 | d->effectiveLayoutDirectionChange(); | - | ||||||||||||||||||||||||
| 1602 | } executed 30 times by 1 test: end of blockExecuted by:
| 30 | ||||||||||||||||||||||||
| 1603 | } executed 54 times by 2 tests: end of blockExecuted by:
| 54 | ||||||||||||||||||||||||
| 1604 | - | |||||||||||||||||||||||||
| 1605 | /*! | - | ||||||||||||||||||||||||
| 1606 | \qmlproperty enumeration QtQuick::Grid::effectiveLayoutDirection | - | ||||||||||||||||||||||||
| 1607 | This property holds the effective layout direction of the grid. | - | ||||||||||||||||||||||||
| 1608 | - | |||||||||||||||||||||||||
| 1609 | When using the attached property \l {LayoutMirroring::enabled}{LayoutMirroring::enabled} for locale layouts, | - | ||||||||||||||||||||||||
| 1610 | the visual layout direction of the grid positioner will be mirrored. However, the | - | ||||||||||||||||||||||||
| 1611 | property \l {Grid::layoutDirection}{layoutDirection} will remain unchanged. | - | ||||||||||||||||||||||||
| 1612 | - | |||||||||||||||||||||||||
| 1613 | \sa Grid::layoutDirection, {LayoutMirroring}{LayoutMirroring} | - | ||||||||||||||||||||||||
| 1614 | */ | - | ||||||||||||||||||||||||
| 1615 | Qt::LayoutDirection QQuickGrid::effectiveLayoutDirection() const | - | ||||||||||||||||||||||||
| 1616 | { | - | ||||||||||||||||||||||||
| 1617 | return QQuickBasePositionerPrivate::getEffectiveLayoutDirection(this); executed 3732 times by 7 tests: return QQuickBasePositionerPrivate::getEffectiveLayoutDirection(this);Executed by:
| 3732 | ||||||||||||||||||||||||
| 1618 | } | - | ||||||||||||||||||||||||
| 1619 | - | |||||||||||||||||||||||||
| 1620 | /*! | - | ||||||||||||||||||||||||
| 1621 | \qmlproperty enumeration QtQuick::Grid::horizontalItemAlignment | - | ||||||||||||||||||||||||
| 1622 | \qmlproperty enumeration QtQuick::Grid::verticalItemAlignment | - | ||||||||||||||||||||||||
| 1623 | \qmlproperty enumeration QtQuick::Grid::effectiveHorizontalItemAlignment | - | ||||||||||||||||||||||||
| 1624 | - | |||||||||||||||||||||||||
| 1625 | Sets the horizontal and vertical alignment of items in the Grid. By default, | - | ||||||||||||||||||||||||
| 1626 | the items are vertically aligned to the top. Horizontal | - | ||||||||||||||||||||||||
| 1627 | alignment follows the layoutDirection of the Grid, for example when having a layoutDirection | - | ||||||||||||||||||||||||
| 1628 | from LeftToRight, the items will be aligned on the left. | - | ||||||||||||||||||||||||
| 1629 | - | |||||||||||||||||||||||||
| 1630 | The valid values for \c horizontalItemAlignment are, \c Grid.AlignLeft, \c Grid.AlignRight and | - | ||||||||||||||||||||||||
| 1631 | \c Grid.AlignHCenter. | - | ||||||||||||||||||||||||
| 1632 | - | |||||||||||||||||||||||||
| 1633 | The valid values for \c verticalItemAlignment are \c Grid.AlignTop, \c Grid.AlignBottom | - | ||||||||||||||||||||||||
| 1634 | and \c Grid.AlignVCenter. | - | ||||||||||||||||||||||||
| 1635 | - | |||||||||||||||||||||||||
| 1636 | The below images show three examples of how to align items. | - | ||||||||||||||||||||||||
| 1637 | - | |||||||||||||||||||||||||
| 1638 | \table | - | ||||||||||||||||||||||||
| 1639 | \row | - | ||||||||||||||||||||||||
| 1640 | \li | - | ||||||||||||||||||||||||
| 1641 | \li \inlineimage gridLayout_aligntopleft.png | - | ||||||||||||||||||||||||
| 1642 | \li \inlineimage gridLayout_aligntop.png | - | ||||||||||||||||||||||||
| 1643 | \li \inlineimage gridLayout_aligncenter.png | - | ||||||||||||||||||||||||
| 1644 | \row | - | ||||||||||||||||||||||||
| 1645 | \li Horizontal alignment | - | ||||||||||||||||||||||||
| 1646 | \li AlignLeft | - | ||||||||||||||||||||||||
| 1647 | \li AlignHCenter | - | ||||||||||||||||||||||||
| 1648 | \li AlignHCenter | - | ||||||||||||||||||||||||
| 1649 | \row | - | ||||||||||||||||||||||||
| 1650 | \li Vertical alignment | - | ||||||||||||||||||||||||
| 1651 | \li AlignTop | - | ||||||||||||||||||||||||
| 1652 | \li AlignTop | - | ||||||||||||||||||||||||
| 1653 | \li AlignVCenter | - | ||||||||||||||||||||||||
| 1654 | \endtable | - | ||||||||||||||||||||||||
| 1655 | - | |||||||||||||||||||||||||
| 1656 | - | |||||||||||||||||||||||||
| 1657 | When mirroring the layout using either the attached property LayoutMirroring::enabled or | - | ||||||||||||||||||||||||
| 1658 | by setting the layoutDirection, the horizontal alignment of items will be mirrored as well. | - | ||||||||||||||||||||||||
| 1659 | However, the property \c horizontalItemAlignment will remain unchanged. | - | ||||||||||||||||||||||||
| 1660 | To query the effective horizontal alignment of items, use the read-only property | - | ||||||||||||||||||||||||
| 1661 | \c effectiveHorizontalItemAlignment. | - | ||||||||||||||||||||||||
| 1662 | - | |||||||||||||||||||||||||
| 1663 | \sa Grid::layoutDirection, {LayoutMirroring}{LayoutMirroring} | - | ||||||||||||||||||||||||
| 1664 | */ | - | ||||||||||||||||||||||||
| 1665 | QQuickGrid::HAlignment QQuickGrid::hItemAlign() const | - | ||||||||||||||||||||||||
| 1666 | { | - | ||||||||||||||||||||||||
| 1667 | return m_hItemAlign; executed 3732 times by 7 tests: return m_hItemAlign;Executed by:
| 3732 | ||||||||||||||||||||||||
| 1668 | } | - | ||||||||||||||||||||||||
| 1669 | void QQuickGrid::setHItemAlign(HAlignment align) | - | ||||||||||||||||||||||||
| 1670 | { | - | ||||||||||||||||||||||||
| 1671 | if (m_hItemAlign != align) {
| 12-22 | ||||||||||||||||||||||||
| 1672 | m_hItemAlign = align; | - | ||||||||||||||||||||||||
| 1673 | prePositioning(); | - | ||||||||||||||||||||||||
| 1674 | emit horizontalAlignmentChanged(align); | - | ||||||||||||||||||||||||
| 1675 | emit effectiveHorizontalAlignmentChanged(effectiveHAlign()); | - | ||||||||||||||||||||||||
| 1676 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||||||||||||||||||||
| 1677 | } executed 34 times by 1 test: end of blockExecuted by:
| 34 | ||||||||||||||||||||||||
| 1678 | - | |||||||||||||||||||||||||
| 1679 | QQuickGrid::HAlignment QQuickGrid::effectiveHAlign() const | - | ||||||||||||||||||||||||
| 1680 | { | - | ||||||||||||||||||||||||
| 1681 | HAlignment effectiveAlignment = m_hItemAlign; | - | ||||||||||||||||||||||||
| 1682 | if (effectiveLayoutDirection() == Qt::RightToLeft) {
| 470-3262 | ||||||||||||||||||||||||
| 1683 | switch (hItemAlign()) { | - | ||||||||||||||||||||||||
| 1684 | case AlignLeft: executed 422 times by 1 test: case AlignLeft:Executed by:
| 422 | ||||||||||||||||||||||||
| 1685 | effectiveAlignment = AlignRight; | - | ||||||||||||||||||||||||
| 1686 | break; executed 422 times by 1 test: break;Executed by:
| 422 | ||||||||||||||||||||||||
| 1687 | case AlignRight: executed 24 times by 1 test: case AlignRight:Executed by:
| 24 | ||||||||||||||||||||||||
| 1688 | effectiveAlignment = AlignLeft; | - | ||||||||||||||||||||||||
| 1689 | break; executed 24 times by 1 test: break;Executed by:
| 24 | ||||||||||||||||||||||||
| 1690 | default: executed 24 times by 1 test: default:Executed by:
| 24 | ||||||||||||||||||||||||
| 1691 | break; executed 24 times by 1 test: break;Executed by:
| 24 | ||||||||||||||||||||||||
| 1692 | } | - | ||||||||||||||||||||||||
| 1693 | } | - | ||||||||||||||||||||||||
| 1694 | return effectiveAlignment; executed 3732 times by 7 tests: return effectiveAlignment;Executed by:
| 3732 | ||||||||||||||||||||||||
| 1695 | } | - | ||||||||||||||||||||||||
| 1696 | - | |||||||||||||||||||||||||
| 1697 | - | |||||||||||||||||||||||||
| 1698 | QQuickGrid::VAlignment QQuickGrid::vItemAlign() const | - | ||||||||||||||||||||||||
| 1699 | { | - | ||||||||||||||||||||||||
| 1700 | return m_vItemAlign; never executed: return m_vItemAlign; | 0 | ||||||||||||||||||||||||
| 1701 | } | - | ||||||||||||||||||||||||
| 1702 | void QQuickGrid::setVItemAlign(VAlignment align) | - | ||||||||||||||||||||||||
| 1703 | { | - | ||||||||||||||||||||||||
| 1704 | if (m_vItemAlign != align) {
| 8-22 | ||||||||||||||||||||||||
| 1705 | m_vItemAlign = align; | - | ||||||||||||||||||||||||
| 1706 | prePositioning(); | - | ||||||||||||||||||||||||
| 1707 | emit verticalAlignmentChanged(align); | - | ||||||||||||||||||||||||
| 1708 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 1709 | } executed 30 times by 1 test: end of blockExecuted by:
| 30 | ||||||||||||||||||||||||
| 1710 | - | |||||||||||||||||||||||||
| 1711 | void QQuickGrid::doPositioning(QSizeF *contentSize) | - | ||||||||||||||||||||||||
| 1712 | { | - | ||||||||||||||||||||||||
| 1713 | //Precondition: All items in the positioned list have a valid item pointer and should be positioned | - | ||||||||||||||||||||||||
| 1714 | QQuickBasePositionerPrivate *d = static_cast<QQuickBasePositionerPrivate*>(QQuickBasePositionerPrivate::get(this)); | - | ||||||||||||||||||||||||
| 1715 | int c = m_columns; | - | ||||||||||||||||||||||||
| 1716 | int r = m_rows; | - | ||||||||||||||||||||||||
| 1717 | int numVisible = positionedItems.count(); | - | ||||||||||||||||||||||||
| 1718 | - | |||||||||||||||||||||||||
| 1719 | if (m_columns <= 0 && m_rows <= 0) {
| 10-402 | ||||||||||||||||||||||||
| 1720 | c = 4; | - | ||||||||||||||||||||||||
| 1721 | r = (numVisible+3)/4; | - | ||||||||||||||||||||||||
| 1722 | } else if (m_rows <= 0) { executed 392 times by 2 tests: end of blockExecuted by:
| 22-392 | ||||||||||||||||||||||||
| 1723 | r = (numVisible+(m_columns-1))/m_columns; | - | ||||||||||||||||||||||||
| 1724 | } else if (m_columns <= 0) { executed 256 times by 6 tests: end of blockExecuted by:
| 10-256 | ||||||||||||||||||||||||
| 1725 | c = (numVisible+(m_rows-1))/m_rows; | - | ||||||||||||||||||||||||
| 1726 | } executed 10 times by 1 test: end of blockExecuted by:
| 10 | ||||||||||||||||||||||||
| 1727 | - | |||||||||||||||||||||||||
| 1728 | if (r == 0 || c == 0) {
| 0-418 | ||||||||||||||||||||||||
| 1729 | contentSize->setHeight(topPadding() + bottomPadding()); | - | ||||||||||||||||||||||||
| 1730 | contentSize->setWidth(leftPadding() + rightPadding()); | - | ||||||||||||||||||||||||
| 1731 | return; //Nothing else to do executed 252 times by 1 test: return;Executed by:
| 252 | ||||||||||||||||||||||||
| 1732 | } | - | ||||||||||||||||||||||||
| 1733 | - | |||||||||||||||||||||||||
| 1734 | QList<qreal> maxColWidth; | - | ||||||||||||||||||||||||
| 1735 | QList<qreal> maxRowHeight; | - | ||||||||||||||||||||||||
| 1736 | int childIndex =0; | - | ||||||||||||||||||||||||
| 1737 | if (m_flow == LeftToRight) {
| 8-410 | ||||||||||||||||||||||||
| 1738 | for (int i = 0; i < r; i++) {
| 410-1304 | ||||||||||||||||||||||||
| 1739 | for (int j = 0; j < c; j++) {
| 964-3954 | ||||||||||||||||||||||||
| 1740 | if (j == 0)
| 1304-2650 | ||||||||||||||||||||||||
| 1741 | maxRowHeight << 0; executed 1304 times by 7 tests: maxRowHeight << 0;Executed by:
| 1304 | ||||||||||||||||||||||||
| 1742 | if (i == 0)
| 1342-2612 | ||||||||||||||||||||||||
| 1743 | maxColWidth << 0; executed 1342 times by 7 tests: maxColWidth << 0;Executed by:
| 1342 | ||||||||||||||||||||||||
| 1744 | - | |||||||||||||||||||||||||
| 1745 | if (childIndex == numVisible)
| 340-3614 | ||||||||||||||||||||||||
| 1746 | break; executed 340 times by 5 tests: break;Executed by:
| 340 | ||||||||||||||||||||||||
| 1747 | - | |||||||||||||||||||||||||
| 1748 | const PositionedItem &child = positionedItems.at(childIndex++); | - | ||||||||||||||||||||||||
| 1749 | if (child.item->width() > maxColWidth[j])
| 856-2758 | ||||||||||||||||||||||||
| 1750 | maxColWidth[j] = child.item->width(); executed 2758 times by 7 tests: maxColWidth[j] = child.item->width();Executed by:
| 2758 | ||||||||||||||||||||||||
| 1751 | if (child.item->height() > maxRowHeight[i])
| 918-2696 | ||||||||||||||||||||||||
| 1752 | maxRowHeight[i] = child.item->height(); executed 2696 times by 7 tests: maxRowHeight[i] = child.item->height();Executed by:
| 2696 | ||||||||||||||||||||||||
| 1753 | } executed 3614 times by 7 tests: end of blockExecuted by:
| 3614 | ||||||||||||||||||||||||
| 1754 | } executed 1304 times by 7 tests: end of blockExecuted by:
| 1304 | ||||||||||||||||||||||||
| 1755 | } else { executed 410 times by 7 tests: end of blockExecuted by:
| 410 | ||||||||||||||||||||||||
| 1756 | for (int j = 0; j < c; j++) {
| 8-36 | ||||||||||||||||||||||||
| 1757 | for (int i = 0; i < r; i++) {
| 28-80 | ||||||||||||||||||||||||
| 1758 | if (j == 0)
| 20-60 | ||||||||||||||||||||||||
| 1759 | maxRowHeight << 0; executed 20 times by 1 test: maxRowHeight << 0;Executed by:
| 20 | ||||||||||||||||||||||||
| 1760 | if (i == 0)
| 36-44 | ||||||||||||||||||||||||
| 1761 | maxColWidth << 0; executed 36 times by 1 test: maxColWidth << 0;Executed by:
| 36 | ||||||||||||||||||||||||
| 1762 | - | |||||||||||||||||||||||||
| 1763 | if (childIndex == numVisible)
| 8-72 | ||||||||||||||||||||||||
| 1764 | break; executed 8 times by 1 test: break;Executed by:
| 8 | ||||||||||||||||||||||||
| 1765 | - | |||||||||||||||||||||||||
| 1766 | const PositionedItem &child = positionedItems.at(childIndex++); | - | ||||||||||||||||||||||||
| 1767 | if (child.item->width() > maxColWidth[j])
| 36 | ||||||||||||||||||||||||
| 1768 | maxColWidth[j] = child.item->width(); executed 36 times by 1 test: maxColWidth[j] = child.item->width();Executed by:
| 36 | ||||||||||||||||||||||||
| 1769 | if (child.item->height() > maxRowHeight[i])
| 20-52 | ||||||||||||||||||||||||
| 1770 | maxRowHeight[i] = child.item->height(); executed 20 times by 1 test: maxRowHeight[i] = child.item->height();Executed by:
| 20 | ||||||||||||||||||||||||
| 1771 | } executed 72 times by 1 test: end of blockExecuted by:
| 72 | ||||||||||||||||||||||||
| 1772 | } executed 36 times by 1 test: end of blockExecuted by:
| 36 | ||||||||||||||||||||||||
| 1773 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 1774 | - | |||||||||||||||||||||||||
| 1775 | qreal columnSpacing = m_useColumnSpacing ? m_columnSpacing : spacing();
| 6-412 | ||||||||||||||||||||||||
| 1776 | qreal rowSpacing = m_useRowSpacing ? m_rowSpacing : spacing();
| 6-412 | ||||||||||||||||||||||||
| 1777 | - | |||||||||||||||||||||||||
| 1778 | qreal widthSum = 0; | - | ||||||||||||||||||||||||
| 1779 | for (int j = 0; j < maxColWidth.size(); j++) {
| 418-1378 | ||||||||||||||||||||||||
| 1780 | if (j)
| 418-960 | ||||||||||||||||||||||||
| 1781 | widthSum += columnSpacing; executed 960 times by 7 tests: widthSum += columnSpacing;Executed by:
| 960 | ||||||||||||||||||||||||
| 1782 | widthSum += maxColWidth[j]; | - | ||||||||||||||||||||||||
| 1783 | } executed 1378 times by 7 tests: end of blockExecuted by:
| 1378 | ||||||||||||||||||||||||
| 1784 | widthSum += leftPadding() + rightPadding(); | - | ||||||||||||||||||||||||
| 1785 | - | |||||||||||||||||||||||||
| 1786 | qreal heightSum = 0; | - | ||||||||||||||||||||||||
| 1787 | for (int i = 0; i < maxRowHeight.size(); i++) {
| 418-1324 | ||||||||||||||||||||||||
| 1788 | if (i)
| 418-906 | ||||||||||||||||||||||||
| 1789 | heightSum += rowSpacing; executed 906 times by 6 tests: heightSum += rowSpacing;Executed by:
| 906 | ||||||||||||||||||||||||
| 1790 | heightSum += maxRowHeight[i]; | - | ||||||||||||||||||||||||
| 1791 | } executed 1324 times by 7 tests: end of blockExecuted by:
| 1324 | ||||||||||||||||||||||||
| 1792 | heightSum += topPadding() + bottomPadding(); | - | ||||||||||||||||||||||||
| 1793 | - | |||||||||||||||||||||||||
| 1794 | contentSize->setHeight(heightSum); | - | ||||||||||||||||||||||||
| 1795 | contentSize->setWidth(widthSum); | - | ||||||||||||||||||||||||
| 1796 | - | |||||||||||||||||||||||||
| 1797 | int end = 0; | - | ||||||||||||||||||||||||
| 1798 | if (widthValid())
| 194-224 | ||||||||||||||||||||||||
| 1799 | end = width(); executed 224 times by 4 tests: end = width();Executed by:
| 224 | ||||||||||||||||||||||||
| 1800 | else | - | ||||||||||||||||||||||||
| 1801 | end = widthSum; executed 194 times by 5 tests: end = widthSum;Executed by:
| 194 | ||||||||||||||||||||||||
| 1802 | - | |||||||||||||||||||||||||
| 1803 | qreal xoffset = leftPadding(); | - | ||||||||||||||||||||||||
| 1804 | if (!d->isLeftToRight())
| 92-326 | ||||||||||||||||||||||||
| 1805 | xoffset = end - rightPadding(); executed 92 times by 1 test: xoffset = end - rightPadding();Executed by:
| 92 | ||||||||||||||||||||||||
| 1806 | qreal yoffset = topPadding(); | - | ||||||||||||||||||||||||
| 1807 | int curRow =0; | - | ||||||||||||||||||||||||
| 1808 | int curCol =0; | - | ||||||||||||||||||||||||
| 1809 | for (int i = 0; i < positionedItems.count(); ++i) {
| 348-3686 | ||||||||||||||||||||||||
| 1810 | PositionedItem &child = positionedItems[i]; | - | ||||||||||||||||||||||||
| 1811 | qreal childXOffset = xoffset; | - | ||||||||||||||||||||||||
| 1812 | - | |||||||||||||||||||||||||
| 1813 | if (effectiveHAlign() == AlignRight)
| 424-3262 | ||||||||||||||||||||||||
| 1814 | childXOffset += maxColWidth[curCol] - child.item->width(); executed 424 times by 1 test: childXOffset += maxColWidth[curCol] - child.item->width();Executed by:
| 424 | ||||||||||||||||||||||||
| 1815 | else if (hItemAlign() == AlignHCenter)
| 50-3212 | ||||||||||||||||||||||||
| 1816 | childXOffset += (maxColWidth[curCol] - child.item->width())/2.0; executed 50 times by 1 test: childXOffset += (maxColWidth[curCol] - child.item->width())/2.0;Executed by:
| 50 | ||||||||||||||||||||||||
| 1817 | - | |||||||||||||||||||||||||
| 1818 | if (!d->isLeftToRight())
| 444-3242 | ||||||||||||||||||||||||
| 1819 | childXOffset -= maxColWidth[curCol]; executed 444 times by 1 test: childXOffset -= maxColWidth[curCol];Executed by:
| 444 | ||||||||||||||||||||||||
| 1820 | - | |||||||||||||||||||||||||
| 1821 | qreal alignYOffset = yoffset; | - | ||||||||||||||||||||||||
| 1822 | if (m_vItemAlign == AlignVCenter)
| 30-3656 | ||||||||||||||||||||||||
| 1823 | alignYOffset += (maxRowHeight[curRow] - child.item->height())/2.0; executed 30 times by 1 test: alignYOffset += (maxRowHeight[curRow] - child.item->height())/2.0;Executed by:
| 30 | ||||||||||||||||||||||||
| 1824 | else if (m_vItemAlign == AlignBottom)
| 20-3636 | ||||||||||||||||||||||||
| 1825 | alignYOffset += maxRowHeight[curRow] - child.item->height(); executed 20 times by 1 test: alignYOffset += maxRowHeight[curRow] - child.item->height();Executed by:
| 20 | ||||||||||||||||||||||||
| 1826 | - | |||||||||||||||||||||||||
| 1827 | positionItem(childXOffset, alignYOffset, &child); | - | ||||||||||||||||||||||||
| 1828 | child.updatePadding(leftPadding(), topPadding(), rightPadding(), bottomPadding()); | - | ||||||||||||||||||||||||
| 1829 | - | |||||||||||||||||||||||||
| 1830 | if (m_flow == LeftToRight) {
| 72-3614 | ||||||||||||||||||||||||
| 1831 | if (d->isLeftToRight())
| 444-3170 | ||||||||||||||||||||||||
| 1832 | xoffset += maxColWidth[curCol]+columnSpacing; executed 3170 times by 7 tests: xoffset += maxColWidth[curCol]+columnSpacing;Executed by:
| 3170 | ||||||||||||||||||||||||
| 1833 | else | - | ||||||||||||||||||||||||
| 1834 | xoffset -= maxColWidth[curCol]+columnSpacing; executed 444 times by 1 test: xoffset -= maxColWidth[curCol]+columnSpacing;Executed by:
| 444 | ||||||||||||||||||||||||
| 1835 | curCol++; | - | ||||||||||||||||||||||||
| 1836 | curCol %= c; | - | ||||||||||||||||||||||||
| 1837 | if (!curCol) {
| 964-2650 | ||||||||||||||||||||||||
| 1838 | yoffset += maxRowHeight[curRow]+rowSpacing; | - | ||||||||||||||||||||||||
| 1839 | if (d->isLeftToRight())
| 92-872 | ||||||||||||||||||||||||
| 1840 | xoffset = leftPadding(); executed 872 times by 6 tests: xoffset = leftPadding();Executed by:
| 872 | ||||||||||||||||||||||||
| 1841 | else | - | ||||||||||||||||||||||||
| 1842 | xoffset = end - rightPadding(); executed 92 times by 1 test: xoffset = end - rightPadding();Executed by:
| 92 | ||||||||||||||||||||||||
| 1843 | curRow++; | - | ||||||||||||||||||||||||
| 1844 | if (curRow>=r)
| 70-894 | ||||||||||||||||||||||||
| 1845 | break; executed 70 times by 6 tests: break;Executed by:
| 70 | ||||||||||||||||||||||||
| 1846 | } executed 894 times by 6 tests: end of blockExecuted by:
| 894 | ||||||||||||||||||||||||
| 1847 | } else { executed 3544 times by 7 tests: end of blockExecuted by:
| 3544 | ||||||||||||||||||||||||
| 1848 | yoffset += maxRowHeight[curRow]+rowSpacing; | - | ||||||||||||||||||||||||
| 1849 | curRow++; | - | ||||||||||||||||||||||||
| 1850 | curRow %= r; | - | ||||||||||||||||||||||||
| 1851 | if (!curRow) {
| 28-44 | ||||||||||||||||||||||||
| 1852 | if (d->isLeftToRight())
| 0-28 | ||||||||||||||||||||||||
| 1853 | xoffset += maxColWidth[curCol]+columnSpacing; executed 28 times by 1 test: xoffset += maxColWidth[curCol]+columnSpacing;Executed by:
| 28 | ||||||||||||||||||||||||
| 1854 | else | - | ||||||||||||||||||||||||
| 1855 | xoffset -= maxColWidth[curCol]+columnSpacing; never executed: xoffset -= maxColWidth[curCol]+columnSpacing; | 0 | ||||||||||||||||||||||||
| 1856 | yoffset = topPadding(); | - | ||||||||||||||||||||||||
| 1857 | curCol++; | - | ||||||||||||||||||||||||
| 1858 | if (curCol>=c)
| 0-28 | ||||||||||||||||||||||||
| 1859 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1860 | } executed 28 times by 1 test: end of blockExecuted by:
| 28 | ||||||||||||||||||||||||
| 1861 | } executed 72 times by 1 test: end of blockExecuted by:
| 72 | ||||||||||||||||||||||||
| 1862 | } | - | ||||||||||||||||||||||||
| 1863 | } executed 418 times by 7 tests: end of blockExecuted by:
| 418 | ||||||||||||||||||||||||
| 1864 | - | |||||||||||||||||||||||||
| 1865 | void QQuickGrid::reportConflictingAnchors() | - | ||||||||||||||||||||||||
| 1866 | { | - | ||||||||||||||||||||||||
| 1867 | QQuickBasePositionerPrivate *d = static_cast<QQuickBasePositionerPrivate*>(QQuickBasePositionerPrivate::get(this)); | - | ||||||||||||||||||||||||
| 1868 | for (int ii = 0; ii < positionedItems.count(); ++ii) {
| 670-3750 | ||||||||||||||||||||||||
| 1869 | const PositionedItem &child = positionedItems.at(ii); | - | ||||||||||||||||||||||||
| 1870 | if (child.item) {
| 0-3750 | ||||||||||||||||||||||||
| 1871 | QQuickAnchors *anchors = QQuickItemPrivate::get(static_cast<QQuickItem *>(child.item))->_anchors; | - | ||||||||||||||||||||||||
| 1872 | if (anchors && (anchors->usedAnchors() || anchors->fill() || anchors->centerIn())) {
| 0-3746 | ||||||||||||||||||||||||
| 1873 | d->anchorConflict = true; | - | ||||||||||||||||||||||||
| 1874 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||
| 1875 | } | - | ||||||||||||||||||||||||
| 1876 | } executed 3746 times by 7 tests: end of blockExecuted by:
| 3746 | ||||||||||||||||||||||||
| 1877 | } executed 3746 times by 7 tests: end of blockExecuted by:
| 3746 | ||||||||||||||||||||||||
| 1878 | if (d->anchorConflict)
| 4-670 | ||||||||||||||||||||||||
| 1879 | qmlWarning(this) << "Cannot specify anchors for items inside Grid." << " Grid will not function."; executed 4 times by 1 test: qmlWarning(this) << "Cannot specify anchors for items inside Grid." << " Grid will not function.";Executed by:
| 4 | ||||||||||||||||||||||||
| 1880 | } executed 674 times by 7 tests: end of blockExecuted by:
| 674 | ||||||||||||||||||||||||
| 1881 | - | |||||||||||||||||||||||||
| 1882 | /*! | - | ||||||||||||||||||||||||
| 1883 | \qmltype Flow | - | ||||||||||||||||||||||||
| 1884 | \instantiates QQuickFlow | - | ||||||||||||||||||||||||
| 1885 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||
| 1886 | \inherits Item | - | ||||||||||||||||||||||||
| 1887 | \ingroup qtquick-positioners | - | ||||||||||||||||||||||||
| 1888 | \brief Positions its children side by side, wrapping as necessary. | - | ||||||||||||||||||||||||
| 1889 | - | |||||||||||||||||||||||||
| 1890 | The Flow item positions its child items like words on a page, wrapping them | - | ||||||||||||||||||||||||
| 1891 | to create rows or columns of items. | - | ||||||||||||||||||||||||
| 1892 | - | |||||||||||||||||||||||||
| 1893 | Below is a Flow that contains various \l Text items: | - | ||||||||||||||||||||||||
| 1894 | - | |||||||||||||||||||||||||
| 1895 | \snippet qml/flow.qml flow item | - | ||||||||||||||||||||||||
| 1896 | - | |||||||||||||||||||||||||
| 1897 | The Flow item automatically positions the child \l Text items side by | - | ||||||||||||||||||||||||
| 1898 | side, wrapping as necessary: | - | ||||||||||||||||||||||||
| 1899 | - | |||||||||||||||||||||||||
| 1900 | \image qml-flow-snippet.png | - | ||||||||||||||||||||||||
| 1901 | - | |||||||||||||||||||||||||
| 1902 | If an item within a Flow is not \l {Item::}{visible}, or if it has a width or | - | ||||||||||||||||||||||||
| 1903 | height of 0, the item will not be laid out and it will not be visible within the | - | ||||||||||||||||||||||||
| 1904 | Flow. Also, since a Flow automatically positions its children, a child | - | ||||||||||||||||||||||||
| 1905 | item within a Flow should not set its \l {Item::x}{x} or \l {Item::y}{y} positions | - | ||||||||||||||||||||||||
| 1906 | or anchor itself with any of the \l {Item::anchors}{anchor} properties. | - | ||||||||||||||||||||||||
| 1907 | - | |||||||||||||||||||||||||
| 1908 | For more information on using Flow and other related positioner-types, see | - | ||||||||||||||||||||||||
| 1909 | \l{Item Positioners}. | - | ||||||||||||||||||||||||
| 1910 | - | |||||||||||||||||||||||||
| 1911 | \sa Column, Row, Grid, Positioner, {Qt Quick Examples - Positioners} | - | ||||||||||||||||||||||||
| 1912 | */ | - | ||||||||||||||||||||||||
| 1913 | /*! | - | ||||||||||||||||||||||||
| 1914 | \since 5.6 | - | ||||||||||||||||||||||||
| 1915 | \qmlproperty real QtQuick::Flow::padding | - | ||||||||||||||||||||||||
| 1916 | \qmlproperty real QtQuick::Flow::topPadding | - | ||||||||||||||||||||||||
| 1917 | \qmlproperty real QtQuick::Flow::leftPadding | - | ||||||||||||||||||||||||
| 1918 | \qmlproperty real QtQuick::Flow::bottomPadding | - | ||||||||||||||||||||||||
| 1919 | \qmlproperty real QtQuick::Flow::rightPadding | - | ||||||||||||||||||||||||
| 1920 | - | |||||||||||||||||||||||||
| 1921 | These properties hold the padding around the content. | - | ||||||||||||||||||||||||
| 1922 | */ | - | ||||||||||||||||||||||||
| 1923 | /*! | - | ||||||||||||||||||||||||
| 1924 | \qmlproperty Transition QtQuick::Flow::populate | - | ||||||||||||||||||||||||
| 1925 | - | |||||||||||||||||||||||||
| 1926 | This property holds the transition to be run for items that are part of | - | ||||||||||||||||||||||||
| 1927 | this positioner at the time of its creation. The transition is run when the positioner | - | ||||||||||||||||||||||||
| 1928 | is first created. | - | ||||||||||||||||||||||||
| 1929 | - | |||||||||||||||||||||||||
| 1930 | The transition can use the \l ViewTransition property to access more details about | - | ||||||||||||||||||||||||
| 1931 | the item that is being added. See the \l ViewTransition documentation for more details | - | ||||||||||||||||||||||||
| 1932 | and examples on using these transitions. | - | ||||||||||||||||||||||||
| 1933 | - | |||||||||||||||||||||||||
| 1934 | \sa add, ViewTransition, {Qt Quick Examples - Positioners} | - | ||||||||||||||||||||||||
| 1935 | */ | - | ||||||||||||||||||||||||
| 1936 | /*! | - | ||||||||||||||||||||||||
| 1937 | \qmlproperty Transition QtQuick::Flow::add | - | ||||||||||||||||||||||||
| 1938 | - | |||||||||||||||||||||||||
| 1939 | This property holds the transition to be run for items that are added to this | - | ||||||||||||||||||||||||
| 1940 | positioner. For a positioner, this applies to: | - | ||||||||||||||||||||||||
| 1941 | - | |||||||||||||||||||||||||
| 1942 | \list | - | ||||||||||||||||||||||||
| 1943 | \li Items that are created or reparented as a child of the positioner after the | - | ||||||||||||||||||||||||
| 1944 | positioner has been created | - | ||||||||||||||||||||||||
| 1945 | \li Child items that change their \l Item::visible property from false to true, and thus | - | ||||||||||||||||||||||||
| 1946 | are now visible | - | ||||||||||||||||||||||||
| 1947 | \endlist | - | ||||||||||||||||||||||||
| 1948 | - | |||||||||||||||||||||||||
| 1949 | The transition can use the \l ViewTransition property to access more details about | - | ||||||||||||||||||||||||
| 1950 | the item that is being added. See the \l ViewTransition documentation for more details | - | ||||||||||||||||||||||||
| 1951 | and examples on using these transitions. | - | ||||||||||||||||||||||||
| 1952 | - | |||||||||||||||||||||||||
| 1953 | \note This transition is not applied to the items that are already part of the positioner | - | ||||||||||||||||||||||||
| 1954 | at the time of its creation. In this case, the \l populate transition is applied instead. | - | ||||||||||||||||||||||||
| 1955 | - | |||||||||||||||||||||||||
| 1956 | \sa populate, ViewTransition, {Qt Quick Examples - Positioners} | - | ||||||||||||||||||||||||
| 1957 | */ | - | ||||||||||||||||||||||||
| 1958 | /*! | - | ||||||||||||||||||||||||
| 1959 | \qmlproperty Transition QtQuick::Flow::move | - | ||||||||||||||||||||||||
| 1960 | - | |||||||||||||||||||||||||
| 1961 | This property holds the transition to run for items that have moved within the | - | ||||||||||||||||||||||||
| 1962 | positioner. For a positioner, this applies to: | - | ||||||||||||||||||||||||
| 1963 | - | |||||||||||||||||||||||||
| 1964 | \list | - | ||||||||||||||||||||||||
| 1965 | \li Child items that move when they are displaced due to the addition, removal or | - | ||||||||||||||||||||||||
| 1966 | rearrangement of other items in the positioner | - | ||||||||||||||||||||||||
| 1967 | \li Child items that are repositioned due to the resizing of other items in the positioner | - | ||||||||||||||||||||||||
| 1968 | \endlist | - | ||||||||||||||||||||||||
| 1969 | - | |||||||||||||||||||||||||
| 1970 | The transition can use the \l ViewTransition property to access more details about | - | ||||||||||||||||||||||||
| 1971 | the item that is being moved. Note, however, that for this move transition, the | - | ||||||||||||||||||||||||
| 1972 | ViewTransition.targetIndexes and ViewTransition.targetItems lists are only set when | - | ||||||||||||||||||||||||
| 1973 | this transition is triggered by the addition of other items in the positioner; in other | - | ||||||||||||||||||||||||
| 1974 | cases, these lists will be empty. See the \l ViewTransition documentation for more details | - | ||||||||||||||||||||||||
| 1975 | and examples on using these transitions. | - | ||||||||||||||||||||||||
| 1976 | - | |||||||||||||||||||||||||
| 1977 | \note In \l {Qt Quick 1}, this transition was applied to all items that were part of the | - | ||||||||||||||||||||||||
| 1978 | positioner at the time of its creation. From \l {Qt Quick}{QtQuick 2} onwards, positioners apply the | - | ||||||||||||||||||||||||
| 1979 | \l populate transition to these items instead. | - | ||||||||||||||||||||||||
| 1980 | - | |||||||||||||||||||||||||
| 1981 | \sa add, ViewTransition, {Qt Quick Examples - Positioners} | - | ||||||||||||||||||||||||
| 1982 | */ | - | ||||||||||||||||||||||||
| 1983 | /*! | - | ||||||||||||||||||||||||
| 1984 | \qmlproperty real QtQuick::Flow::spacing | - | ||||||||||||||||||||||||
| 1985 | - | |||||||||||||||||||||||||
| 1986 | spacing is the amount in pixels left empty between each adjacent | - | ||||||||||||||||||||||||
| 1987 | item, and defaults to 0. | - | ||||||||||||||||||||||||
| 1988 | - | |||||||||||||||||||||||||
| 1989 | \sa Grid::spacing | - | ||||||||||||||||||||||||
| 1990 | */ | - | ||||||||||||||||||||||||
| 1991 | /*! | - | ||||||||||||||||||||||||
| 1992 | \qmlmethod QtQuick::Flow::forceLayout() | - | ||||||||||||||||||||||||
| 1993 | \since 5.9 | - | ||||||||||||||||||||||||
| 1994 | - | |||||||||||||||||||||||||
| 1995 | Flow typically positions its children once per frame. This means that | - | ||||||||||||||||||||||||
| 1996 | inside script blocks it is possible for the underlying children to have changed, | - | ||||||||||||||||||||||||
| 1997 | but the Flow to have not yet been updated accordingly. | - | ||||||||||||||||||||||||
| 1998 | - | |||||||||||||||||||||||||
| 1999 | This method forces the Flow to immediately respond to any outstanding | - | ||||||||||||||||||||||||
| 2000 | changes in its children. | - | ||||||||||||||||||||||||
| 2001 | - | |||||||||||||||||||||||||
| 2002 | - | |||||||||||||||||||||||||
| 2003 | \b Note: methods in general should only be called after the Component has completed. | - | ||||||||||||||||||||||||
| 2004 | */ | - | ||||||||||||||||||||||||
| 2005 | /*! | - | ||||||||||||||||||||||||
| 2006 | \qmlsignal QtQuick::Flow::positioningComplete() | - | ||||||||||||||||||||||||
| 2007 | \since 5.9 | - | ||||||||||||||||||||||||
| 2008 | - | |||||||||||||||||||||||||
| 2009 | This signal is emitted when positioning has been completed. | - | ||||||||||||||||||||||||
| 2010 | - | |||||||||||||||||||||||||
| 2011 | The corresponding handler is \c onPositioningComplete. | - | ||||||||||||||||||||||||
| 2012 | */ | - | ||||||||||||||||||||||||
| 2013 | - | |||||||||||||||||||||||||
| 2014 | class QQuickFlowPrivate : public QQuickBasePositionerPrivate | - | ||||||||||||||||||||||||
| 2015 | { | - | ||||||||||||||||||||||||
| 2016 | Q_DECLARE_PUBLIC(QQuickFlow) | - | ||||||||||||||||||||||||
| 2017 | - | |||||||||||||||||||||||||
| 2018 | public: | - | ||||||||||||||||||||||||
| 2019 | QQuickFlowPrivate() | - | ||||||||||||||||||||||||
| 2020 | : QQuickBasePositionerPrivate(), flow(QQuickFlow::LeftToRight) | - | ||||||||||||||||||||||||
| 2021 | {} executed 302 times by 3 tests: end of blockExecuted by:
| 302 | ||||||||||||||||||||||||
| 2022 | - | |||||||||||||||||||||||||
| 2023 | void effectiveLayoutDirectionChange() override | - | ||||||||||||||||||||||||
| 2024 | { | - | ||||||||||||||||||||||||
| 2025 | Q_Q(QQuickFlow); | - | ||||||||||||||||||||||||
| 2026 | // Don't postpone, as it might be the only trigger for visible changes. | - | ||||||||||||||||||||||||
| 2027 | q->prePositioning(); | - | ||||||||||||||||||||||||
| 2028 | emit q->effectiveLayoutDirectionChanged(); | - | ||||||||||||||||||||||||
| 2029 | } executed 30 times by 1 test: end of blockExecuted by:
| 30 | ||||||||||||||||||||||||
| 2030 | - | |||||||||||||||||||||||||
| 2031 | QQuickFlow::Flow flow; | - | ||||||||||||||||||||||||
| 2032 | }; | - | ||||||||||||||||||||||||
| 2033 | - | |||||||||||||||||||||||||
| 2034 | QQuickFlow::QQuickFlow(QQuickItem *parent) | - | ||||||||||||||||||||||||
| 2035 | : QQuickBasePositioner(*(new QQuickFlowPrivate), Both, parent) | - | ||||||||||||||||||||||||
| 2036 | { | - | ||||||||||||||||||||||||
| 2037 | Q_D(QQuickFlow); | - | ||||||||||||||||||||||||
| 2038 | // Flow layout requires relayout if its own size changes too. | - | ||||||||||||||||||||||||
| 2039 | d->addItemChangeListener(d, QQuickItemPrivate::Geometry); | - | ||||||||||||||||||||||||
| 2040 | } executed 302 times by 3 tests: end of blockExecuted by:
| 302 | ||||||||||||||||||||||||
| 2041 | - | |||||||||||||||||||||||||
| 2042 | /*! | - | ||||||||||||||||||||||||
| 2043 | \qmlproperty enumeration QtQuick::Flow::flow | - | ||||||||||||||||||||||||
| 2044 | This property holds the flow of the layout. | - | ||||||||||||||||||||||||
| 2045 | - | |||||||||||||||||||||||||
| 2046 | Possible values are: | - | ||||||||||||||||||||||||
| 2047 | - | |||||||||||||||||||||||||
| 2048 | \list | - | ||||||||||||||||||||||||
| 2049 | \li Flow.LeftToRight (default) - Items are positioned next to | - | ||||||||||||||||||||||||
| 2050 | to each other according to the \l layoutDirection until the width of the Flow | - | ||||||||||||||||||||||||
| 2051 | is exceeded, then wrapped to the next line. | - | ||||||||||||||||||||||||
| 2052 | \li Flow.TopToBottom - Items are positioned next to each | - | ||||||||||||||||||||||||
| 2053 | other from top to bottom until the height of the Flow is exceeded, | - | ||||||||||||||||||||||||
| 2054 | then wrapped to the next column. | - | ||||||||||||||||||||||||
| 2055 | \endlist | - | ||||||||||||||||||||||||
| 2056 | */ | - | ||||||||||||||||||||||||
| 2057 | QQuickFlow::Flow QQuickFlow::flow() const | - | ||||||||||||||||||||||||
| 2058 | { | - | ||||||||||||||||||||||||
| 2059 | Q_D(const QQuickFlow); | - | ||||||||||||||||||||||||
| 2060 | return d->flow; executed 8 times by 1 test: return d->flow;Executed by:
| 8 | ||||||||||||||||||||||||
| 2061 | } | - | ||||||||||||||||||||||||
| 2062 | - | |||||||||||||||||||||||||
| 2063 | void QQuickFlow::setFlow(Flow flow) | - | ||||||||||||||||||||||||
| 2064 | { | - | ||||||||||||||||||||||||
| 2065 | Q_D(QQuickFlow); | - | ||||||||||||||||||||||||
| 2066 | if (d->flow != flow) {
| 0-20 | ||||||||||||||||||||||||
| 2067 | d->flow = flow; | - | ||||||||||||||||||||||||
| 2068 | prePositioning(); | - | ||||||||||||||||||||||||
| 2069 | emit flowChanged(); | - | ||||||||||||||||||||||||
| 2070 | } executed 20 times by 1 test: end of blockExecuted by:
| 20 | ||||||||||||||||||||||||
| 2071 | } executed 20 times by 1 test: end of blockExecuted by:
| 20 | ||||||||||||||||||||||||
| 2072 | - | |||||||||||||||||||||||||
| 2073 | /*! | - | ||||||||||||||||||||||||
| 2074 | \qmlproperty enumeration QtQuick::Flow::layoutDirection | - | ||||||||||||||||||||||||
| 2075 | - | |||||||||||||||||||||||||
| 2076 | This property holds the layout direction of the layout. | - | ||||||||||||||||||||||||
| 2077 | - | |||||||||||||||||||||||||
| 2078 | Possible values are: | - | ||||||||||||||||||||||||
| 2079 | - | |||||||||||||||||||||||||
| 2080 | \list | - | ||||||||||||||||||||||||
| 2081 | \li Qt.LeftToRight (default) - Items are positioned from the top to bottom, | - | ||||||||||||||||||||||||
| 2082 | and left to right. The flow direction is dependent on the | - | ||||||||||||||||||||||||
| 2083 | \l Flow::flow property. | - | ||||||||||||||||||||||||
| 2084 | \li Qt.RightToLeft - Items are positioned from the top to bottom, | - | ||||||||||||||||||||||||
| 2085 | and right to left. The flow direction is dependent on the | - | ||||||||||||||||||||||||
| 2086 | \l Flow::flow property. | - | ||||||||||||||||||||||||
| 2087 | \endlist | - | ||||||||||||||||||||||||
| 2088 | - | |||||||||||||||||||||||||
| 2089 | \sa Grid::layoutDirection, Row::layoutDirection, {Qt Quick Examples - Right to Left} | - | ||||||||||||||||||||||||
| 2090 | */ | - | ||||||||||||||||||||||||
| 2091 | - | |||||||||||||||||||||||||
| 2092 | Qt::LayoutDirection QQuickFlow::layoutDirection() const | - | ||||||||||||||||||||||||
| 2093 | { | - | ||||||||||||||||||||||||
| 2094 | Q_D(const QQuickFlow); | - | ||||||||||||||||||||||||
| 2095 | return d->layoutDirection; executed 4 times by 1 test: return d->layoutDirection;Executed by:
| 4 | ||||||||||||||||||||||||
| 2096 | } | - | ||||||||||||||||||||||||
| 2097 | - | |||||||||||||||||||||||||
| 2098 | void QQuickFlow::setLayoutDirection(Qt::LayoutDirection layoutDirection) | - | ||||||||||||||||||||||||
| 2099 | { | - | ||||||||||||||||||||||||
| 2100 | Q_D(QQuickFlow); | - | ||||||||||||||||||||||||
| 2101 | if (d->layoutDirection != layoutDirection) {
| 26-40 | ||||||||||||||||||||||||
| 2102 | d->layoutDirection = layoutDirection; | - | ||||||||||||||||||||||||
| 2103 | emit layoutDirectionChanged(); | - | ||||||||||||||||||||||||
| 2104 | d->effectiveLayoutDirectionChange(); | - | ||||||||||||||||||||||||
| 2105 | } executed 26 times by 1 test: end of blockExecuted by:
| 26 | ||||||||||||||||||||||||
| 2106 | } executed 66 times by 2 tests: end of blockExecuted by:
| 66 | ||||||||||||||||||||||||
| 2107 | - | |||||||||||||||||||||||||
| 2108 | /*! | - | ||||||||||||||||||||||||
| 2109 | \qmlproperty enumeration QtQuick::Flow::effectiveLayoutDirection | - | ||||||||||||||||||||||||
| 2110 | This property holds the effective layout direction of the flow. | - | ||||||||||||||||||||||||
| 2111 | - | |||||||||||||||||||||||||
| 2112 | When using the attached property \l {LayoutMirroring::enabled}{LayoutMirroring::enabled} for locale layouts, | - | ||||||||||||||||||||||||
| 2113 | the visual layout direction of the grid positioner will be mirrored. However, the | - | ||||||||||||||||||||||||
| 2114 | property \l {Flow::layoutDirection}{layoutDirection} will remain unchanged. | - | ||||||||||||||||||||||||
| 2115 | - | |||||||||||||||||||||||||
| 2116 | \sa Flow::layoutDirection, {LayoutMirroring}{LayoutMirroring} | - | ||||||||||||||||||||||||
| 2117 | */ | - | ||||||||||||||||||||||||
| 2118 | - | |||||||||||||||||||||||||
| 2119 | Qt::LayoutDirection QQuickFlow::effectiveLayoutDirection() const | - | ||||||||||||||||||||||||
| 2120 | { | - | ||||||||||||||||||||||||
| 2121 | return QQuickBasePositionerPrivate::getEffectiveLayoutDirection(this); never executed: return QQuickBasePositionerPrivate::getEffectiveLayoutDirection(this); | 0 | ||||||||||||||||||||||||
| 2122 | } | - | ||||||||||||||||||||||||
| 2123 | - | |||||||||||||||||||||||||
| 2124 | void QQuickFlow::doPositioning(QSizeF *contentSize) | - | ||||||||||||||||||||||||
| 2125 | { | - | ||||||||||||||||||||||||
| 2126 | //Precondition: All items in the positioned list have a valid item pointer and should be positioned | - | ||||||||||||||||||||||||
| 2127 | Q_D(QQuickFlow); | - | ||||||||||||||||||||||||
| 2128 | - | |||||||||||||||||||||||||
| 2129 | qreal hoffset1 = leftPadding(); | - | ||||||||||||||||||||||||
| 2130 | qreal hoffset2 = rightPadding(); | - | ||||||||||||||||||||||||
| 2131 | if (!d->isLeftToRight())
| 82-512 | ||||||||||||||||||||||||
| 2132 | qSwap(hoffset1, hoffset2); executed 82 times by 1 test: qSwap(hoffset1, hoffset2);Executed by:
| 82 | ||||||||||||||||||||||||
| 2133 | qreal hoffset = hoffset1; | - | ||||||||||||||||||||||||
| 2134 | const qreal voffset1 = topPadding(); | - | ||||||||||||||||||||||||
| 2135 | qreal voffset = voffset1; | - | ||||||||||||||||||||||||
| 2136 | qreal linemax = 0; | - | ||||||||||||||||||||||||
| 2137 | QList<qreal> hoffsets; | - | ||||||||||||||||||||||||
| 2138 | contentSize->setWidth(qMax(contentSize->width(), hoffset1 + hoffset2)); | - | ||||||||||||||||||||||||
| 2139 | contentSize->setHeight(qMax(contentSize->height(), voffset + bottomPadding())); | - | ||||||||||||||||||||||||
| 2140 | - | |||||||||||||||||||||||||
| 2141 | for (int i = 0; i < positionedItems.count(); ++i) {
| 594-2876 | ||||||||||||||||||||||||
| 2142 | PositionedItem &child = positionedItems[i]; | - | ||||||||||||||||||||||||
| 2143 | - | |||||||||||||||||||||||||
| 2144 | if (d->flow == LeftToRight) {
| 120-2756 | ||||||||||||||||||||||||
| 2145 | if (widthValid() && hoffset != hoffset1 && hoffset + child.item->width() + hoffset2 > width()) {
| 26-2730 | ||||||||||||||||||||||||
| 2146 | hoffset = hoffset1; | - | ||||||||||||||||||||||||
| 2147 | voffset += linemax + spacing(); | - | ||||||||||||||||||||||||
| 2148 | linemax = 0; | - | ||||||||||||||||||||||||
| 2149 | } executed 566 times by 2 tests: end of blockExecuted by:
| 566 | ||||||||||||||||||||||||
| 2150 | } else { executed 2756 times by 3 tests: end of blockExecuted by:
| 2756 | ||||||||||||||||||||||||
| 2151 | if (heightValid() && voffset != voffset1 && voffset + child.item->height() + bottomPadding() > height()) {
| 16-80 | ||||||||||||||||||||||||
| 2152 | voffset = voffset1; | - | ||||||||||||||||||||||||
| 2153 | hoffset += linemax + spacing(); | - | ||||||||||||||||||||||||
| 2154 | linemax = 0; | - | ||||||||||||||||||||||||
| 2155 | } executed 32 times by 1 test: end of blockExecuted by:
| 32 | ||||||||||||||||||||||||
| 2156 | } executed 120 times by 1 test: end of blockExecuted by:
| 120 | ||||||||||||||||||||||||
| 2157 | - | |||||||||||||||||||||||||
| 2158 | if (d->isLeftToRight()) {
| 386-2490 | ||||||||||||||||||||||||
| 2159 | positionItem(hoffset, voffset, &child); | - | ||||||||||||||||||||||||
| 2160 | child.updatePadding(leftPadding(), topPadding(), rightPadding(), bottomPadding()); | - | ||||||||||||||||||||||||
| 2161 | } else { executed 2490 times by 3 tests: end of blockExecuted by:
| 2490 | ||||||||||||||||||||||||
| 2162 | hoffsets << hoffset; | - | ||||||||||||||||||||||||
| 2163 | positionItemY(voffset, &child); | - | ||||||||||||||||||||||||
| 2164 | child.topPadding = topPadding(); | - | ||||||||||||||||||||||||
| 2165 | child.bottomPadding = bottomPadding(); | - | ||||||||||||||||||||||||
| 2166 | } executed 386 times by 1 test: end of blockExecuted by:
| 386 | ||||||||||||||||||||||||
| 2167 | - | |||||||||||||||||||||||||
| 2168 | contentSize->setWidth(qMax(contentSize->width(), hoffset + child.item->width() + hoffset2)); | - | ||||||||||||||||||||||||
| 2169 | contentSize->setHeight(qMax(contentSize->height(), voffset + child.item->height() + bottomPadding())); | - | ||||||||||||||||||||||||
| 2170 | - | |||||||||||||||||||||||||
| 2171 | if (d->flow == LeftToRight) {
| 120-2756 | ||||||||||||||||||||||||
| 2172 | hoffset += child.item->width(); | - | ||||||||||||||||||||||||
| 2173 | hoffset += spacing(); | - | ||||||||||||||||||||||||
| 2174 | linemax = qMax(linemax, child.item->height()); | - | ||||||||||||||||||||||||
| 2175 | } else { executed 2756 times by 3 tests: end of blockExecuted by:
| 2756 | ||||||||||||||||||||||||
| 2176 | voffset += child.item->height(); | - | ||||||||||||||||||||||||
| 2177 | voffset += spacing(); | - | ||||||||||||||||||||||||
| 2178 | linemax = qMax(linemax, child.item->width()); | - | ||||||||||||||||||||||||
| 2179 | } executed 120 times by 1 test: end of blockExecuted by:
| 120 | ||||||||||||||||||||||||
| 2180 | } | - | ||||||||||||||||||||||||
| 2181 | - | |||||||||||||||||||||||||
| 2182 | if (d->isLeftToRight())
| 82-512 | ||||||||||||||||||||||||
| 2183 | return; executed 512 times by 3 tests: return;Executed by:
| 512 | ||||||||||||||||||||||||
| 2184 | - | |||||||||||||||||||||||||
| 2185 | qreal end; | - | ||||||||||||||||||||||||
| 2186 | if (widthValid())
| 12-70 | ||||||||||||||||||||||||
| 2187 | end = width(); executed 70 times by 1 test: end = width();Executed by:
| 70 | ||||||||||||||||||||||||
| 2188 | else | - | ||||||||||||||||||||||||
| 2189 | end = contentSize->width(); executed 12 times by 1 test: end = contentSize->width();Executed by:
| 12 | ||||||||||||||||||||||||
| 2190 | int acc = 0; | - | ||||||||||||||||||||||||
| 2191 | for (int i = 0; i < positionedItems.count(); ++i) {
| 82-386 | ||||||||||||||||||||||||
| 2192 | PositionedItem &child = positionedItems[i]; | - | ||||||||||||||||||||||||
| 2193 | hoffset = end - hoffsets[acc++] - child.item->width(); | - | ||||||||||||||||||||||||
| 2194 | positionItemX(hoffset, &child); | - | ||||||||||||||||||||||||
| 2195 | child.leftPadding = leftPadding(); | - | ||||||||||||||||||||||||
| 2196 | child.rightPadding = rightPadding(); | - | ||||||||||||||||||||||||
| 2197 | } executed 386 times by 1 test: end of blockExecuted by:
| 386 | ||||||||||||||||||||||||
| 2198 | } executed 82 times by 1 test: end of blockExecuted by:
| 82 | ||||||||||||||||||||||||
| 2199 | - | |||||||||||||||||||||||||
| 2200 | void QQuickFlow::reportConflictingAnchors() | - | ||||||||||||||||||||||||
| 2201 | { | - | ||||||||||||||||||||||||
| 2202 | Q_D(QQuickFlow); | - | ||||||||||||||||||||||||
| 2203 | for (int ii = 0; ii < positionedItems.count(); ++ii) {
| 594-2880 | ||||||||||||||||||||||||
| 2204 | const PositionedItem &child = positionedItems.at(ii); | - | ||||||||||||||||||||||||
| 2205 | if (child.item) {
| 0-2880 | ||||||||||||||||||||||||
| 2206 | QQuickAnchors *anchors = QQuickItemPrivate::get(static_cast<QQuickItem *>(child.item))->_anchors; | - | ||||||||||||||||||||||||
| 2207 | if (anchors && (anchors->usedAnchors() || anchors->fill() || anchors->centerIn())) {
| 0-2876 | ||||||||||||||||||||||||
| 2208 | d->anchorConflict = true; | - | ||||||||||||||||||||||||
| 2209 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||
| 2210 | } | - | ||||||||||||||||||||||||
| 2211 | } executed 2876 times by 3 tests: end of blockExecuted by:
| 2876 | ||||||||||||||||||||||||
| 2212 | } executed 2876 times by 3 tests: end of blockExecuted by:
| 2876 | ||||||||||||||||||||||||
| 2213 | if (d->anchorConflict)
| 4-594 | ||||||||||||||||||||||||
| 2214 | qmlWarning(this) << "Cannot specify anchors for items inside Flow." << " Flow will not function."; executed 4 times by 1 test: qmlWarning(this) << "Cannot specify anchors for items inside Flow." << " Flow will not function.";Executed by:
| 4 | ||||||||||||||||||||||||
| 2215 | } executed 598 times by 3 tests: end of blockExecuted by:
| 598 | ||||||||||||||||||||||||
| 2216 | - | |||||||||||||||||||||||||
| 2217 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
| 2218 | - | |||||||||||||||||||||||||
| 2219 | #include "moc_qquickpositioners_p.cpp" | - | ||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |