| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickgridview.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 "qquickgridview_p.h" | - | ||||||||||||||||||||||||||||||
| 41 | #include "qquickflickable_p_p.h" | - | ||||||||||||||||||||||||||||||
| 42 | #include "qquickitemview_p_p.h" | - | ||||||||||||||||||||||||||||||
| 43 | - | |||||||||||||||||||||||||||||||
| 44 | #include <private/qqmlobjectmodel_p.h> | - | ||||||||||||||||||||||||||||||
| 45 | #include <private/qquicksmoothedanimation_p_p.h> | - | ||||||||||||||||||||||||||||||
| 46 | - | |||||||||||||||||||||||||||||||
| 47 | #include <QtGui/qevent.h> | - | ||||||||||||||||||||||||||||||
| 48 | #include <QtCore/qmath.h> | - | ||||||||||||||||||||||||||||||
| 49 | #include <QtCore/qcoreapplication.h> | - | ||||||||||||||||||||||||||||||
| 50 | #include "qplatformdefs.h" | - | ||||||||||||||||||||||||||||||
| 51 | - | |||||||||||||||||||||||||||||||
| 52 | #include <cmath> | - | ||||||||||||||||||||||||||||||
| 53 | - | |||||||||||||||||||||||||||||||
| 54 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||||||||
| 55 | - | |||||||||||||||||||||||||||||||
| 56 | #ifndef QML_FLICK_SNAPONETHRESHOLD | - | ||||||||||||||||||||||||||||||
| 57 | #define QML_FLICK_SNAPONETHRESHOLD 30 | - | ||||||||||||||||||||||||||||||
| 58 | #endif | - | ||||||||||||||||||||||||||||||
| 59 | - | |||||||||||||||||||||||||||||||
| 60 | //---------------------------------------------------------------------------- | - | ||||||||||||||||||||||||||||||
| 61 | - | |||||||||||||||||||||||||||||||
| 62 | class FxGridItemSG : public FxViewItem | - | ||||||||||||||||||||||||||||||
| 63 | { | - | ||||||||||||||||||||||||||||||
| 64 | public: | - | ||||||||||||||||||||||||||||||
| 65 | FxGridItemSG(QQuickItem *i, QQuickGridView *v, bool own) : FxViewItem(i, v, own, static_cast<QQuickItemViewAttached*>(qmlAttachedPropertiesObject<QQuickGridView>(i))), view(v) | - | ||||||||||||||||||||||||||||||
| 66 | { | - | ||||||||||||||||||||||||||||||
| 67 | } executed 51741 times by 4 tests: end of blockExecuted by:
| 51741 | ||||||||||||||||||||||||||||||
| 68 | - | |||||||||||||||||||||||||||||||
| 69 | qreal position() const override { | - | ||||||||||||||||||||||||||||||
| 70 | return rowPos(); executed 61291 times by 4 tests: return rowPos();Executed by:
| 61291 | ||||||||||||||||||||||||||||||
| 71 | } | - | ||||||||||||||||||||||||||||||
| 72 | - | |||||||||||||||||||||||||||||||
| 73 | qreal endPosition() const override { | - | ||||||||||||||||||||||||||||||
| 74 | return endRowPos(); executed 16817 times by 3 tests: return endRowPos();Executed by:
| 16817 | ||||||||||||||||||||||||||||||
| 75 | } | - | ||||||||||||||||||||||||||||||
| 76 | - | |||||||||||||||||||||||||||||||
| 77 | qreal size() const override { | - | ||||||||||||||||||||||||||||||
| 78 | return view->flow() == QQuickGridView::FlowLeftToRight ? view->cellHeight() : view->cellWidth(); executed 13616 times by 3 tests: return view->flow() == QQuickGridView::FlowLeftToRight ? view->cellHeight() : view->cellWidth();Executed by:
| 13616 | ||||||||||||||||||||||||||||||
| 79 | } | - | ||||||||||||||||||||||||||||||
| 80 | - | |||||||||||||||||||||||||||||||
| 81 | qreal sectionSize() const override { | - | ||||||||||||||||||||||||||||||
| 82 | return 0.0; executed 12548 times by 3 tests: return 0.0;Executed by:
| 12548 | ||||||||||||||||||||||||||||||
| 83 | } | - | ||||||||||||||||||||||||||||||
| 84 | - | |||||||||||||||||||||||||||||||
| 85 | qreal rowPos() const { | - | ||||||||||||||||||||||||||||||
| 86 | if (view->flow() == QQuickGridView::FlowLeftToRight)
| 338667-375994 | ||||||||||||||||||||||||||||||
| 87 | return (view->verticalLayoutDirection() == QQuickItemView::BottomToTop ? -view->cellHeight()-itemY() : itemY()); executed 375994 times by 4 tests: return (view->verticalLayoutDirection() == QQuickItemView::BottomToTop ? -view->cellHeight()-itemY() : itemY());Executed by:
| 375994 | ||||||||||||||||||||||||||||||
| 88 | else | - | ||||||||||||||||||||||||||||||
| 89 | return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -view->cellWidth()-itemX() : itemX()); executed 338667 times by 1 test: return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -view->cellWidth()-itemX() : itemX());Executed by:
| 338667 | ||||||||||||||||||||||||||||||
| 90 | } | - | ||||||||||||||||||||||||||||||
| 91 | - | |||||||||||||||||||||||||||||||
| 92 | qreal colPos() const { | - | ||||||||||||||||||||||||||||||
| 93 | if (view->flow() == QQuickGridView::FlowLeftToRight) {
| 67873-85100 | ||||||||||||||||||||||||||||||
| 94 | if (view->effectiveLayoutDirection() == Qt::RightToLeft) {
| 14264-70836 | ||||||||||||||||||||||||||||||
| 95 | qreal colSize = view->cellWidth(); | - | ||||||||||||||||||||||||||||||
| 96 | int columns = view->width()/colSize; | - | ||||||||||||||||||||||||||||||
| 97 | return colSize * (columns-1) - itemX(); executed 14264 times by 1 test: return colSize * (columns-1) - itemX();Executed by:
| 14264 | ||||||||||||||||||||||||||||||
| 98 | } else { | - | ||||||||||||||||||||||||||||||
| 99 | return itemX(); executed 70836 times by 4 tests: return itemX();Executed by:
| 70836 | ||||||||||||||||||||||||||||||
| 100 | } | - | ||||||||||||||||||||||||||||||
| 101 | } else { | - | ||||||||||||||||||||||||||||||
| 102 | if (view->verticalLayoutDirection() == QQuickItemView::BottomToTop) {
| 13434-54439 | ||||||||||||||||||||||||||||||
| 103 | return -view->cellHeight() - itemY(); executed 13434 times by 1 test: return -view->cellHeight() - itemY();Executed by:
| 13434 | ||||||||||||||||||||||||||||||
| 104 | } else { | - | ||||||||||||||||||||||||||||||
| 105 | return itemY(); executed 54439 times by 1 test: return itemY();Executed by:
| 54439 | ||||||||||||||||||||||||||||||
| 106 | } | - | ||||||||||||||||||||||||||||||
| 107 | } | - | ||||||||||||||||||||||||||||||
| 108 | } | - | ||||||||||||||||||||||||||||||
| 109 | qreal endRowPos() const { | - | ||||||||||||||||||||||||||||||
| 110 | if (view->flow() == QQuickGridView::FlowLeftToRight) {
| 5260-11557 | ||||||||||||||||||||||||||||||
| 111 | if (view->verticalLayoutDirection() == QQuickItemView::BottomToTop)
| 2332-9225 | ||||||||||||||||||||||||||||||
| 112 | return -itemY(); executed 2332 times by 1 test: return -itemY();Executed by:
| 2332 | ||||||||||||||||||||||||||||||
| 113 | else | - | ||||||||||||||||||||||||||||||
| 114 | return itemY() + view->cellHeight(); executed 9225 times by 3 tests: return itemY() + view->cellHeight();Executed by:
| 9225 | ||||||||||||||||||||||||||||||
| 115 | } else { | - | ||||||||||||||||||||||||||||||
| 116 | if (view->effectiveLayoutDirection() == Qt::RightToLeft)
| 2470-2790 | ||||||||||||||||||||||||||||||
| 117 | return -itemX(); executed 2790 times by 1 test: return -itemX();Executed by:
| 2790 | ||||||||||||||||||||||||||||||
| 118 | else | - | ||||||||||||||||||||||||||||||
| 119 | return itemX() + view->cellWidth(); executed 2470 times by 1 test: return itemX() + view->cellWidth();Executed by:
| 2470 | ||||||||||||||||||||||||||||||
| 120 | } | - | ||||||||||||||||||||||||||||||
| 121 | } | - | ||||||||||||||||||||||||||||||
| 122 | void setPosition(qreal col, qreal row, bool immediate = false) { | - | ||||||||||||||||||||||||||||||
| 123 | moveTo(pointForPosition(col, row), immediate); | - | ||||||||||||||||||||||||||||||
| 124 | } executed 122852 times by 4 tests: end of blockExecuted by:
| 122852 | ||||||||||||||||||||||||||||||
| 125 | bool contains(qreal x, qreal y) const override { | - | ||||||||||||||||||||||||||||||
| 126 | return (x >= itemX() && x < itemX() + view->cellWidth() && executed 62 times by 1 test: return (x >= itemX() && x < itemX() + view->cellWidth() && y >= itemY() && y < itemY() + view->cellHeight());Executed by:
| 62 | ||||||||||||||||||||||||||||||
| 127 | y >= itemY() && y < itemY() + view->cellHeight()); executed 62 times by 1 test: return (x >= itemX() && x < itemX() + view->cellWidth() && y >= itemY() && y < itemY() + view->cellHeight());Executed by:
| 62 | ||||||||||||||||||||||||||||||
| 128 | } | - | ||||||||||||||||||||||||||||||
| 129 | - | |||||||||||||||||||||||||||||||
| 130 | QQuickGridView *view; | - | ||||||||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||||||||
| 132 | private: | - | ||||||||||||||||||||||||||||||
| 133 | QPointF pointForPosition(qreal col, qreal row) const { | - | ||||||||||||||||||||||||||||||
| 134 | qreal x; | - | ||||||||||||||||||||||||||||||
| 135 | qreal y; | - | ||||||||||||||||||||||||||||||
| 136 | if (view->flow() == QQuickGridView::FlowLeftToRight) {
| 48557-74295 | ||||||||||||||||||||||||||||||
| 137 | x = col; | - | ||||||||||||||||||||||||||||||
| 138 | y = row; | - | ||||||||||||||||||||||||||||||
| 139 | if (view->effectiveLayoutDirection() == Qt::RightToLeft) {
| 19984-54311 | ||||||||||||||||||||||||||||||
| 140 | int columns = view->width()/view->cellWidth(); | - | ||||||||||||||||||||||||||||||
| 141 | x = view->cellWidth() * (columns-1) - col; | - | ||||||||||||||||||||||||||||||
| 142 | } executed 19984 times by 1 test: end of blockExecuted by:
| 19984 | ||||||||||||||||||||||||||||||
| 143 | } else { executed 74295 times by 4 tests: end of blockExecuted by:
| 74295 | ||||||||||||||||||||||||||||||
| 144 | x = row; | - | ||||||||||||||||||||||||||||||
| 145 | y = col; | - | ||||||||||||||||||||||||||||||
| 146 | if (view->effectiveLayoutDirection() == Qt::RightToLeft)
| 24019-24538 | ||||||||||||||||||||||||||||||
| 147 | x = -view->cellWidth() - row; executed 24538 times by 1 test: x = -view->cellWidth() - row;Executed by:
| 24538 | ||||||||||||||||||||||||||||||
| 148 | } executed 48557 times by 1 test: end of blockExecuted by:
| 48557 | ||||||||||||||||||||||||||||||
| 149 | if (view->verticalLayoutDirection() == QQuickItemView::BottomToTop)
| 40896-81956 | ||||||||||||||||||||||||||||||
| 150 | y = -view->cellHeight() - y; executed 40896 times by 1 test: y = -view->cellHeight() - y;Executed by:
| 40896 | ||||||||||||||||||||||||||||||
| 151 | return QPointF(x, y); executed 122852 times by 4 tests: return QPointF(x, y);Executed by:
| 122852 | ||||||||||||||||||||||||||||||
| 152 | } | - | ||||||||||||||||||||||||||||||
| 153 | }; | - | ||||||||||||||||||||||||||||||
| 154 | - | |||||||||||||||||||||||||||||||
| 155 | //---------------------------------------------------------------------------- | - | ||||||||||||||||||||||||||||||
| 156 | - | |||||||||||||||||||||||||||||||
| 157 | class QQuickGridViewPrivate : public QQuickItemViewPrivate | - | ||||||||||||||||||||||||||||||
| 158 | { | - | ||||||||||||||||||||||||||||||
| 159 | Q_DECLARE_PUBLIC(QQuickGridView) | - | ||||||||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||||||||
| 161 | public: | - | ||||||||||||||||||||||||||||||
| 162 | Qt::Orientation layoutOrientation() const override; | - | ||||||||||||||||||||||||||||||
| 163 | bool isContentFlowReversed() const override; | - | ||||||||||||||||||||||||||||||
| 164 | - | |||||||||||||||||||||||||||||||
| 165 | qreal positionAt(int index) const override; | - | ||||||||||||||||||||||||||||||
| 166 | qreal endPositionAt(int index) const override; | - | ||||||||||||||||||||||||||||||
| 167 | qreal originPosition() const override; | - | ||||||||||||||||||||||||||||||
| 168 | qreal lastPosition() const override; | - | ||||||||||||||||||||||||||||||
| 169 | - | |||||||||||||||||||||||||||||||
| 170 | qreal rowSize() const; | - | ||||||||||||||||||||||||||||||
| 171 | qreal colSize() const; | - | ||||||||||||||||||||||||||||||
| 172 | qreal colPosAt(int modelIndex) const; | - | ||||||||||||||||||||||||||||||
| 173 | qreal rowPosAt(int modelIndex) const; | - | ||||||||||||||||||||||||||||||
| 174 | qreal snapPosAt(qreal pos) const; | - | ||||||||||||||||||||||||||||||
| 175 | FxViewItem *snapItemAt(qreal pos) const; | - | ||||||||||||||||||||||||||||||
| 176 | int snapIndex() const; | - | ||||||||||||||||||||||||||||||
| 177 | qreal contentXForPosition(qreal pos) const; | - | ||||||||||||||||||||||||||||||
| 178 | qreal contentYForPosition(qreal pos) const; | - | ||||||||||||||||||||||||||||||
| 179 | - | |||||||||||||||||||||||||||||||
| 180 | void resetColumns(); | - | ||||||||||||||||||||||||||||||
| 181 | - | |||||||||||||||||||||||||||||||
| 182 | bool addVisibleItems(qreal fillFrom, qreal fillTo, qreal bufferFrom, qreal bufferTo, bool doBuffer) override; | - | ||||||||||||||||||||||||||||||
| 183 | bool removeNonVisibleItems(qreal bufferFrom, qreal bufferTo) override; | - | ||||||||||||||||||||||||||||||
| 184 | - | |||||||||||||||||||||||||||||||
| 185 | void removeItem(FxViewItem *item); | - | ||||||||||||||||||||||||||||||
| 186 | - | |||||||||||||||||||||||||||||||
| 187 | FxViewItem *newViewItem(int index, QQuickItem *item) override; | - | ||||||||||||||||||||||||||||||
| 188 | void initializeViewItem(FxViewItem *item) override; | - | ||||||||||||||||||||||||||||||
| 189 | void repositionItemAt(FxViewItem *item, int index, qreal sizeBuffer) override; | - | ||||||||||||||||||||||||||||||
| 190 | void repositionPackageItemAt(QQuickItem *item, int index) override; | - | ||||||||||||||||||||||||||||||
| 191 | void resetFirstItemPosition(qreal pos = 0.0) override; | - | ||||||||||||||||||||||||||||||
| 192 | void adjustFirstItem(qreal forwards, qreal backwards, int changeBeforeVisible) override; | - | ||||||||||||||||||||||||||||||
| 193 | - | |||||||||||||||||||||||||||||||
| 194 | void createHighlight() override; | - | ||||||||||||||||||||||||||||||
| 195 | void updateHighlight() override; | - | ||||||||||||||||||||||||||||||
| 196 | void resetHighlightPosition() override; | - | ||||||||||||||||||||||||||||||
| 197 | - | |||||||||||||||||||||||||||||||
| 198 | void setPosition(qreal pos) override; | - | ||||||||||||||||||||||||||||||
| 199 | void layoutVisibleItems(int fromModelIndex = 0) override; | - | ||||||||||||||||||||||||||||||
| 200 | bool applyInsertionChange(const QQmlChangeSet::Change &insert, ChangeResult *changeResult, QList<FxViewItem *> *addedItems, QList<MovedItem> *movingIntoView) override; | - | ||||||||||||||||||||||||||||||
| 201 | void translateAndTransitionItemsAfter(int afterModelIndex, const ChangeResult &insertionResult, const ChangeResult &removalResult) override; | - | ||||||||||||||||||||||||||||||
| 202 | bool needsRefillForAddedOrRemovedIndex(int index) const override; | - | ||||||||||||||||||||||||||||||
| 203 | - | |||||||||||||||||||||||||||||||
| 204 | qreal headerSize() const override; | - | ||||||||||||||||||||||||||||||
| 205 | qreal footerSize() const override; | - | ||||||||||||||||||||||||||||||
| 206 | bool showHeaderForIndex(int index) const override; | - | ||||||||||||||||||||||||||||||
| 207 | bool showFooterForIndex(int index) const override; | - | ||||||||||||||||||||||||||||||
| 208 | void updateHeader() override; | - | ||||||||||||||||||||||||||||||
| 209 | void updateFooter() override; | - | ||||||||||||||||||||||||||||||
| 210 | - | |||||||||||||||||||||||||||||||
| 211 | void changedVisibleIndex(int newIndex) override; | - | ||||||||||||||||||||||||||||||
| 212 | void initializeCurrentItem() override; | - | ||||||||||||||||||||||||||||||
| 213 | - | |||||||||||||||||||||||||||||||
| 214 | void updateViewport() override; | - | ||||||||||||||||||||||||||||||
| 215 | void fixupPosition() override; | - | ||||||||||||||||||||||||||||||
| 216 | void fixup(AxisData &data, qreal minExtent, qreal maxExtent) override; | - | ||||||||||||||||||||||||||||||
| 217 | bool flick(QQuickItemViewPrivate::AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, | - | ||||||||||||||||||||||||||||||
| 218 | QQuickTimeLineCallback::Callback fixupCallback, qreal velocity) override; | - | ||||||||||||||||||||||||||||||
| 219 | - | |||||||||||||||||||||||||||||||
| 220 | QQuickGridView::Flow flow; | - | ||||||||||||||||||||||||||||||
| 221 | qreal cellWidth; | - | ||||||||||||||||||||||||||||||
| 222 | qreal cellHeight; | - | ||||||||||||||||||||||||||||||
| 223 | int columns; | - | ||||||||||||||||||||||||||||||
| 224 | QQuickGridView::SnapMode snapMode; | - | ||||||||||||||||||||||||||||||
| 225 | - | |||||||||||||||||||||||||||||||
| 226 | QSmoothedAnimation *highlightXAnimator; | - | ||||||||||||||||||||||||||||||
| 227 | QSmoothedAnimation *highlightYAnimator; | - | ||||||||||||||||||||||||||||||
| 228 | - | |||||||||||||||||||||||||||||||
| 229 | QQuickGridViewPrivate() | - | ||||||||||||||||||||||||||||||
| 230 | : flow(QQuickGridView::FlowLeftToRight) | - | ||||||||||||||||||||||||||||||
| 231 | , cellWidth(100), cellHeight(100), columns(1) | - | ||||||||||||||||||||||||||||||
| 232 | , snapMode(QQuickGridView::NoSnap) | - | ||||||||||||||||||||||||||||||
| 233 | , highlightXAnimator(nullptr), highlightYAnimator(nullptr) | - | ||||||||||||||||||||||||||||||
| 234 | {} executed 1782 times by 4 tests: end of blockExecuted by:
| 1782 | ||||||||||||||||||||||||||||||
| 235 | ~QQuickGridViewPrivate() | - | ||||||||||||||||||||||||||||||
| 236 | { | - | ||||||||||||||||||||||||||||||
| 237 | delete highlightXAnimator; | - | ||||||||||||||||||||||||||||||
| 238 | delete highlightYAnimator; | - | ||||||||||||||||||||||||||||||
| 239 | } executed 1782 times by 4 tests: end of blockExecuted by:
| 1782 | ||||||||||||||||||||||||||||||
| 240 | }; | - | ||||||||||||||||||||||||||||||
| 241 | - | |||||||||||||||||||||||||||||||
| 242 | Qt::Orientation QQuickGridViewPrivate::layoutOrientation() const | - | ||||||||||||||||||||||||||||||
| 243 | { | - | ||||||||||||||||||||||||||||||
| 244 | return flow == QQuickGridView::FlowLeftToRight ? Qt::Vertical : Qt::Horizontal; executed 384171 times by 4 tests: return flow == QQuickGridView::FlowLeftToRight ? Qt::Vertical : Qt::Horizontal;Executed by:
| 384171 | ||||||||||||||||||||||||||||||
| 245 | } | - | ||||||||||||||||||||||||||||||
| 246 | - | |||||||||||||||||||||||||||||||
| 247 | bool QQuickGridViewPrivate::isContentFlowReversed() const | - | ||||||||||||||||||||||||||||||
| 248 | { | - | ||||||||||||||||||||||||||||||
| 249 | Q_Q(const QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 250 | - | |||||||||||||||||||||||||||||||
| 251 | return (flow == QQuickGridView::FlowLeftToRight && verticalLayoutDirection == QQuickItemView::BottomToTop) executed 204260 times by 4 tests: return (flow == QQuickGridView::FlowLeftToRight && verticalLayoutDirection == QQuickItemView::BottomToTop) || (flow == QQuickGridView::FlowTopToBottom && q->effectiveLayoutDirection() == Qt::RightToLeft);Executed by:
| 204260 | ||||||||||||||||||||||||||||||
| 252 | || (flow == QQuickGridView::FlowTopToBottom && q->effectiveLayoutDirection() == Qt::RightToLeft); executed 204260 times by 4 tests: return (flow == QQuickGridView::FlowLeftToRight && verticalLayoutDirection == QQuickItemView::BottomToTop) || (flow == QQuickGridView::FlowTopToBottom && q->effectiveLayoutDirection() == Qt::RightToLeft);Executed by:
| 204260 | ||||||||||||||||||||||||||||||
| 253 | } | - | ||||||||||||||||||||||||||||||
| 254 | - | |||||||||||||||||||||||||||||||
| 255 | void QQuickGridViewPrivate::changedVisibleIndex(int newIndex) | - | ||||||||||||||||||||||||||||||
| 256 | { | - | ||||||||||||||||||||||||||||||
| 257 | visibleIndex = newIndex / columns * columns; | - | ||||||||||||||||||||||||||||||
| 258 | } executed 56 times by 1 test: end of blockExecuted by:
| 56 | ||||||||||||||||||||||||||||||
| 259 | - | |||||||||||||||||||||||||||||||
| 260 | void QQuickGridViewPrivate::setPosition(qreal pos) | - | ||||||||||||||||||||||||||||||
| 261 | { | - | ||||||||||||||||||||||||||||||
| 262 | Q_Q(QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 263 | q->QQuickFlickable::setContentX(contentXForPosition(pos)); | - | ||||||||||||||||||||||||||||||
| 264 | q->QQuickFlickable::setContentY(contentYForPosition(pos)); | - | ||||||||||||||||||||||||||||||
| 265 | } executed 4555 times by 4 tests: end of blockExecuted by:
| 4555 | ||||||||||||||||||||||||||||||
| 266 | - | |||||||||||||||||||||||||||||||
| 267 | qreal QQuickGridViewPrivate::originPosition() const | - | ||||||||||||||||||||||||||||||
| 268 | { | - | ||||||||||||||||||||||||||||||
| 269 | qreal pos = 0; | - | ||||||||||||||||||||||||||||||
| 270 | if (!visibleItems.isEmpty())
| 11274-22995 | ||||||||||||||||||||||||||||||
| 271 | pos = static_cast<FxGridItemSG*>(visibleItems.first())->rowPos() - visibleIndex / columns * rowSize(); executed 22995 times by 4 tests: pos = static_cast<FxGridItemSG*>(visibleItems.first())->rowPos() - visibleIndex / columns * rowSize();Executed by:
| 22995 | ||||||||||||||||||||||||||||||
| 272 | return pos; executed 34269 times by 4 tests: return pos;Executed by:
| 34269 | ||||||||||||||||||||||||||||||
| 273 | } | - | ||||||||||||||||||||||||||||||
| 274 | - | |||||||||||||||||||||||||||||||
| 275 | qreal QQuickGridViewPrivate::lastPosition() const | - | ||||||||||||||||||||||||||||||
| 276 | { | - | ||||||||||||||||||||||||||||||
| 277 | qreal pos = 0; | - | ||||||||||||||||||||||||||||||
| 278 | if (model && (model->count() || !visibleItems.isEmpty())) {
| 2-23701 | ||||||||||||||||||||||||||||||
| 279 | qreal lastRowPos = model->count() ? rowPosAt(model->count() - 1) : 0;
| 2-23701 | ||||||||||||||||||||||||||||||
| 280 | if (!visibleItems.isEmpty()) {
| 3960-19743 | ||||||||||||||||||||||||||||||
| 281 | // If there are items in delayRemove state, they may be after any items linked to the model | - | ||||||||||||||||||||||||||||||
| 282 | lastRowPos = qMax(lastRowPos, static_cast<FxGridItemSG*>(visibleItems.last())->rowPos()); | - | ||||||||||||||||||||||||||||||
| 283 | } executed 19743 times by 4 tests: end of blockExecuted by:
| 19743 | ||||||||||||||||||||||||||||||
| 284 | pos = lastRowPos + rowSize(); | - | ||||||||||||||||||||||||||||||
| 285 | } executed 23703 times by 4 tests: end of blockExecuted by:
| 23703 | ||||||||||||||||||||||||||||||
| 286 | return pos; executed 24955 times by 4 tests: return pos;Executed by:
| 24955 | ||||||||||||||||||||||||||||||
| 287 | } | - | ||||||||||||||||||||||||||||||
| 288 | - | |||||||||||||||||||||||||||||||
| 289 | qreal QQuickGridViewPrivate::positionAt(int index) const | - | ||||||||||||||||||||||||||||||
| 290 | { | - | ||||||||||||||||||||||||||||||
| 291 | return rowPosAt(index); executed 12241 times by 4 tests: return rowPosAt(index);Executed by:
| 12241 | ||||||||||||||||||||||||||||||
| 292 | } | - | ||||||||||||||||||||||||||||||
| 293 | - | |||||||||||||||||||||||||||||||
| 294 | qreal QQuickGridViewPrivate::endPositionAt(int index) const | - | ||||||||||||||||||||||||||||||
| 295 | { | - | ||||||||||||||||||||||||||||||
| 296 | return rowPosAt(index) + rowSize(); executed 14266 times by 4 tests: return rowPosAt(index) + rowSize();Executed by:
| 14266 | ||||||||||||||||||||||||||||||
| 297 | } | - | ||||||||||||||||||||||||||||||
| 298 | - | |||||||||||||||||||||||||||||||
| 299 | qreal QQuickGridViewPrivate::rowSize() const { | - | ||||||||||||||||||||||||||||||
| 300 | return flow == QQuickGridView::FlowLeftToRight ? cellHeight : cellWidth; executed 602888 times by 4 tests: return flow == QQuickGridView::FlowLeftToRight ? cellHeight : cellWidth;Executed by:
| 602888 | ||||||||||||||||||||||||||||||
| 301 | } | - | ||||||||||||||||||||||||||||||
| 302 | qreal QQuickGridViewPrivate::colSize() const { | - | ||||||||||||||||||||||||||||||
| 303 | return flow == QQuickGridView::FlowLeftToRight ? cellWidth : cellHeight; executed 417056 times by 4 tests: return flow == QQuickGridView::FlowLeftToRight ? cellWidth : cellHeight;Executed by:
| 417056 | ||||||||||||||||||||||||||||||
| 304 | } | - | ||||||||||||||||||||||||||||||
| 305 | - | |||||||||||||||||||||||||||||||
| 306 | qreal QQuickGridViewPrivate::colPosAt(int modelIndex) const | - | ||||||||||||||||||||||||||||||
| 307 | { | - | ||||||||||||||||||||||||||||||
| 308 | if (FxViewItem *item = visibleItem(modelIndex))
| 2249-24370 | ||||||||||||||||||||||||||||||
| 309 | return static_cast<FxGridItemSG*>(item)->colPos(); executed 24370 times by 4 tests: return static_cast<FxGridItemSG*>(item)->colPos();Executed by:
| 24370 | ||||||||||||||||||||||||||||||
| 310 | if (!visibleItems.isEmpty()) {
| 287-1962 | ||||||||||||||||||||||||||||||
| 311 | if (modelIndex == visibleIndex) {
| 6-281 | ||||||||||||||||||||||||||||||
| 312 | FxGridItemSG *firstItem = static_cast<FxGridItemSG*>(visibleItems.first()); | - | ||||||||||||||||||||||||||||||
| 313 | return firstItem->colPos(); executed 6 times by 1 test: return firstItem->colPos();Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 314 | } else if (modelIndex < visibleIndex) {
| 85-196 | ||||||||||||||||||||||||||||||
| 315 | int count = (visibleIndex - modelIndex) % columns; | - | ||||||||||||||||||||||||||||||
| 316 | int col = static_cast<FxGridItemSG*>(visibleItems.first())->colPos() / colSize(); | - | ||||||||||||||||||||||||||||||
| 317 | col = (columns - count + col) % columns; | - | ||||||||||||||||||||||||||||||
| 318 | return col * colSize(); executed 85 times by 1 test: return col * colSize();Executed by:
| 85 | ||||||||||||||||||||||||||||||
| 319 | } else { | - | ||||||||||||||||||||||||||||||
| 320 | FxGridItemSG *lastItem = static_cast<FxGridItemSG*>(visibleItems.last()); | - | ||||||||||||||||||||||||||||||
| 321 | int count = modelIndex - lastItem->index; | - | ||||||||||||||||||||||||||||||
| 322 | int col = lastItem->colPos() / colSize(); | - | ||||||||||||||||||||||||||||||
| 323 | col = (col + count) % columns; | - | ||||||||||||||||||||||||||||||
| 324 | return col * colSize(); executed 196 times by 1 test: return col * colSize();Executed by:
| 196 | ||||||||||||||||||||||||||||||
| 325 | } | - | ||||||||||||||||||||||||||||||
| 326 | } | - | ||||||||||||||||||||||||||||||
| 327 | return (modelIndex % columns) * colSize(); executed 1962 times by 3 tests: return (modelIndex % columns) * colSize();Executed by:
| 1962 | ||||||||||||||||||||||||||||||
| 328 | } | - | ||||||||||||||||||||||||||||||
| 329 | - | |||||||||||||||||||||||||||||||
| 330 | qreal QQuickGridViewPrivate::rowPosAt(int modelIndex) const | - | ||||||||||||||||||||||||||||||
| 331 | { | - | ||||||||||||||||||||||||||||||
| 332 | if (FxViewItem *item = visibleItem(modelIndex))
| 38790-59550 | ||||||||||||||||||||||||||||||
| 333 | return static_cast<FxGridItemSG*>(item)->rowPos(); executed 59550 times by 4 tests: return static_cast<FxGridItemSG*>(item)->rowPos();Executed by:
| 59550 | ||||||||||||||||||||||||||||||
| 334 | if (!visibleItems.isEmpty()) {
| 15232-23558 | ||||||||||||||||||||||||||||||
| 335 | if (modelIndex == visibleIndex) {
| 14-23544 | ||||||||||||||||||||||||||||||
| 336 | FxGridItemSG *firstItem = static_cast<FxGridItemSG*>(visibleItems.first()); | - | ||||||||||||||||||||||||||||||
| 337 | return firstItem->rowPos(); executed 14 times by 1 test: return firstItem->rowPos();Executed by:
| 14 | ||||||||||||||||||||||||||||||
| 338 | } else if (modelIndex < visibleIndex) {
| 1670-21874 | ||||||||||||||||||||||||||||||
| 339 | FxGridItemSG *firstItem = static_cast<FxGridItemSG*>(visibleItems.first()); | - | ||||||||||||||||||||||||||||||
| 340 | int firstCol = firstItem->colPos() / colSize(); | - | ||||||||||||||||||||||||||||||
| 341 | int col = visibleIndex - modelIndex + (columns - firstCol - 1); | - | ||||||||||||||||||||||||||||||
| 342 | int rows = col / columns; | - | ||||||||||||||||||||||||||||||
| 343 | return firstItem->rowPos() - rows * rowSize(); executed 1670 times by 1 test: return firstItem->rowPos() - rows * rowSize();Executed by:
| 1670 | ||||||||||||||||||||||||||||||
| 344 | } else { | - | ||||||||||||||||||||||||||||||
| 345 | FxGridItemSG *lastItem = static_cast<FxGridItemSG*>(visibleItems.last()); | - | ||||||||||||||||||||||||||||||
| 346 | int count = modelIndex - lastItem->index; | - | ||||||||||||||||||||||||||||||
| 347 | int col = lastItem->colPos() + count * colSize(); | - | ||||||||||||||||||||||||||||||
| 348 | int rows = col / (columns * colSize()); | - | ||||||||||||||||||||||||||||||
| 349 | return lastItem->rowPos() + rows * rowSize(); executed 21874 times by 2 tests: return lastItem->rowPos() + rows * rowSize();Executed by:
| 21874 | ||||||||||||||||||||||||||||||
| 350 | } | - | ||||||||||||||||||||||||||||||
| 351 | } | - | ||||||||||||||||||||||||||||||
| 352 | return (modelIndex / columns) * rowSize(); executed 15232 times by 4 tests: return (modelIndex / columns) * rowSize();Executed by:
| 15232 | ||||||||||||||||||||||||||||||
| 353 | } | - | ||||||||||||||||||||||||||||||
| 354 | - | |||||||||||||||||||||||||||||||
| 355 | - | |||||||||||||||||||||||||||||||
| 356 | qreal QQuickGridViewPrivate::snapPosAt(qreal pos) const | - | ||||||||||||||||||||||||||||||
| 357 | { | - | ||||||||||||||||||||||||||||||
| 358 | Q_Q(const QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 359 | qreal snapPos = 0; | - | ||||||||||||||||||||||||||||||
| 360 | if (!visibleItems.isEmpty()) {
| 0-138 | ||||||||||||||||||||||||||||||
| 361 | qreal highlightStart = highlightRangeStart; | - | ||||||||||||||||||||||||||||||
| 362 | pos += highlightStart; | - | ||||||||||||||||||||||||||||||
| 363 | pos += rowSize()/2; | - | ||||||||||||||||||||||||||||||
| 364 | snapPos = static_cast<FxGridItemSG*>(visibleItems.first())->rowPos() - visibleIndex / columns * rowSize(); | - | ||||||||||||||||||||||||||||||
| 365 | snapPos = pos - std::fmod(pos - snapPos, qreal(rowSize())); | - | ||||||||||||||||||||||||||||||
| 366 | snapPos -= highlightStart; | - | ||||||||||||||||||||||||||||||
| 367 | qreal maxExtent; | - | ||||||||||||||||||||||||||||||
| 368 | qreal minExtent; | - | ||||||||||||||||||||||||||||||
| 369 | if (isContentFlowReversed()) {
| 46-92 | ||||||||||||||||||||||||||||||
| 370 | maxExtent = q->minXExtent()-size(); | - | ||||||||||||||||||||||||||||||
| 371 | minExtent = q->maxXExtent()-size(); | - | ||||||||||||||||||||||||||||||
| 372 | } else { executed 46 times by 1 test: end of blockExecuted by:
| 46 | ||||||||||||||||||||||||||||||
| 373 | maxExtent = flow == QQuickGridView::FlowLeftToRight ? -q->maxYExtent() : -q->maxXExtent();
| 46 | ||||||||||||||||||||||||||||||
| 374 | minExtent = flow == QQuickGridView::FlowLeftToRight ? -q->minYExtent() : -q->minXExtent();
| 46 | ||||||||||||||||||||||||||||||
| 375 | } executed 92 times by 1 test: end of blockExecuted by:
| 92 | ||||||||||||||||||||||||||||||
| 376 | if (snapPos > maxExtent)
| 0-138 | ||||||||||||||||||||||||||||||
| 377 | snapPos = maxExtent; never executed: snapPos = maxExtent; | 0 | ||||||||||||||||||||||||||||||
| 378 | if (snapPos < minExtent)
| 6-132 | ||||||||||||||||||||||||||||||
| 379 | snapPos = minExtent; executed 6 times by 1 test: snapPos = minExtent;Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 380 | } executed 138 times by 1 test: end of blockExecuted by:
| 138 | ||||||||||||||||||||||||||||||
| 381 | return snapPos; executed 138 times by 1 test: return snapPos;Executed by:
| 138 | ||||||||||||||||||||||||||||||
| 382 | } | - | ||||||||||||||||||||||||||||||
| 383 | - | |||||||||||||||||||||||||||||||
| 384 | FxViewItem *QQuickGridViewPrivate::snapItemAt(qreal pos) const | - | ||||||||||||||||||||||||||||||
| 385 | { | - | ||||||||||||||||||||||||||||||
| 386 | for (FxViewItem *item : visibleItems) { | - | ||||||||||||||||||||||||||||||
| 387 | if (item->index == -1)
| 0-3988 | ||||||||||||||||||||||||||||||
| 388 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 389 | qreal itemTop = item->position(); | - | ||||||||||||||||||||||||||||||
| 390 | if (itemTop+rowSize()/2 >= pos && itemTop - rowSize()/2 <= pos)
| 48-3416 | ||||||||||||||||||||||||||||||
| 391 | return item; executed 524 times by 1 test: return item;Executed by:
| 524 | ||||||||||||||||||||||||||||||
| 392 | } executed 3464 times by 1 test: end of blockExecuted by:
| 3464 | ||||||||||||||||||||||||||||||
| 393 | return nullptr; executed 172 times by 1 test: return nullptr;Executed by:
| 172 | ||||||||||||||||||||||||||||||
| 394 | } | - | ||||||||||||||||||||||||||||||
| 395 | - | |||||||||||||||||||||||||||||||
| 396 | int QQuickGridViewPrivate::snapIndex() const | - | ||||||||||||||||||||||||||||||
| 397 | { | - | ||||||||||||||||||||||||||||||
| 398 | int index = currentIndex; | - | ||||||||||||||||||||||||||||||
| 399 | for (FxViewItem *item : visibleItems) { | - | ||||||||||||||||||||||||||||||
| 400 | if (item->index == -1)
| 0-23356 | ||||||||||||||||||||||||||||||
| 401 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 402 | qreal itemTop = item->position(); | - | ||||||||||||||||||||||||||||||
| 403 | FxGridItemSG *hItem = static_cast<FxGridItemSG*>(highlight); | - | ||||||||||||||||||||||||||||||
| 404 | if (itemTop >= hItem->rowPos()-rowSize()/2 && itemTop < hItem->rowPos()+rowSize()/2) {
| 344-20627 | ||||||||||||||||||||||||||||||
| 405 | FxGridItemSG *gridItem = static_cast<FxGridItemSG*>(item); | - | ||||||||||||||||||||||||||||||
| 406 | index = gridItem->index; | - | ||||||||||||||||||||||||||||||
| 407 | if (gridItem->colPos() >= hItem->colPos()-colSize()/2 && gridItem->colPos() < hItem->colPos()+colSize()/2)
| 0-2385 | ||||||||||||||||||||||||||||||
| 408 | return gridItem->index; executed 2385 times by 1 test: return gridItem->index;Executed by:
| 2385 | ||||||||||||||||||||||||||||||
| 409 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 410 | } executed 20971 times by 1 test: end of blockExecuted by:
| 20971 | ||||||||||||||||||||||||||||||
| 411 | return index; executed 87 times by 1 test: return index;Executed by:
| 87 | ||||||||||||||||||||||||||||||
| 412 | } | - | ||||||||||||||||||||||||||||||
| 413 | - | |||||||||||||||||||||||||||||||
| 414 | qreal QQuickGridViewPrivate::contentXForPosition(qreal pos) const | - | ||||||||||||||||||||||||||||||
| 415 | { | - | ||||||||||||||||||||||||||||||
| 416 | Q_Q(const QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 417 | if (flow == QQuickGridView::FlowLeftToRight) {
| 1512-4757 | ||||||||||||||||||||||||||||||
| 418 | // vertical scroll | - | ||||||||||||||||||||||||||||||
| 419 | if (q->effectiveLayoutDirection() == Qt::LeftToRight) {
| 593-4164 | ||||||||||||||||||||||||||||||
| 420 | return 0; executed 4164 times by 4 tests: return 0;Executed by:
| 4164 | ||||||||||||||||||||||||||||||
| 421 | } else { | - | ||||||||||||||||||||||||||||||
| 422 | qreal colSize = cellWidth; | - | ||||||||||||||||||||||||||||||
| 423 | int columns = q->width()/colSize; | - | ||||||||||||||||||||||||||||||
| 424 | return -q->width() + (cellWidth * columns); executed 593 times by 1 test: return -q->width() + (cellWidth * columns);Executed by:
| 593 | ||||||||||||||||||||||||||||||
| 425 | } | - | ||||||||||||||||||||||||||||||
| 426 | } else { | - | ||||||||||||||||||||||||||||||
| 427 | // horizontal scroll | - | ||||||||||||||||||||||||||||||
| 428 | if (q->effectiveLayoutDirection() == Qt::LeftToRight)
| 690-822 | ||||||||||||||||||||||||||||||
| 429 | return pos; executed 690 times by 1 test: return pos;Executed by:
| 690 | ||||||||||||||||||||||||||||||
| 430 | else | - | ||||||||||||||||||||||||||||||
| 431 | return -pos - q->width(); executed 822 times by 1 test: return -pos - q->width();Executed by:
| 822 | ||||||||||||||||||||||||||||||
| 432 | } | - | ||||||||||||||||||||||||||||||
| 433 | } | - | ||||||||||||||||||||||||||||||
| 434 | - | |||||||||||||||||||||||||||||||
| 435 | qreal QQuickGridViewPrivate::contentYForPosition(qreal pos) const | - | ||||||||||||||||||||||||||||||
| 436 | { | - | ||||||||||||||||||||||||||||||
| 437 | Q_Q(const QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 438 | if (flow == QQuickGridView::FlowLeftToRight) {
| 1512-4763 | ||||||||||||||||||||||||||||||
| 439 | // vertical scroll | - | ||||||||||||||||||||||||||||||
| 440 | if (verticalLayoutDirection == QQuickItemView::TopToBottom)
| 573-4190 | ||||||||||||||||||||||||||||||
| 441 | return pos; executed 4190 times by 4 tests: return pos;Executed by:
| 4190 | ||||||||||||||||||||||||||||||
| 442 | else | - | ||||||||||||||||||||||||||||||
| 443 | return -pos - q->height(); executed 573 times by 1 test: return -pos - q->height();Executed by:
| 573 | ||||||||||||||||||||||||||||||
| 444 | } else { | - | ||||||||||||||||||||||||||||||
| 445 | // horizontal scroll | - | ||||||||||||||||||||||||||||||
| 446 | if (verticalLayoutDirection == QQuickItemView::TopToBottom)
| 568-944 | ||||||||||||||||||||||||||||||
| 447 | return 0; executed 944 times by 1 test: return 0;Executed by:
| 944 | ||||||||||||||||||||||||||||||
| 448 | else | - | ||||||||||||||||||||||||||||||
| 449 | return -q->height(); executed 568 times by 1 test: return -q->height();Executed by:
| 568 | ||||||||||||||||||||||||||||||
| 450 | } | - | ||||||||||||||||||||||||||||||
| 451 | } | - | ||||||||||||||||||||||||||||||
| 452 | - | |||||||||||||||||||||||||||||||
| 453 | void QQuickGridViewPrivate::resetColumns() | - | ||||||||||||||||||||||||||||||
| 454 | { | - | ||||||||||||||||||||||||||||||
| 455 | Q_Q(QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 456 | qreal length = flow == QQuickGridView::FlowLeftToRight ? q->width() : q->height();
| 4360-14283 | ||||||||||||||||||||||||||||||
| 457 | columns = qMax(1, qFloor(length / colSize())); | - | ||||||||||||||||||||||||||||||
| 458 | } executed 18643 times by 4 tests: end of blockExecuted by:
| 18643 | ||||||||||||||||||||||||||||||
| 459 | - | |||||||||||||||||||||||||||||||
| 460 | FxViewItem *QQuickGridViewPrivate::newViewItem(int modelIndex, QQuickItem *item) | - | ||||||||||||||||||||||||||||||
| 461 | { | - | ||||||||||||||||||||||||||||||
| 462 | Q_Q(QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 463 | Q_UNUSED(modelIndex); | - | ||||||||||||||||||||||||||||||
| 464 | return new FxGridItemSG(item, q, false); executed 49543 times by 4 tests: return new FxGridItemSG(item, q, false);Executed by:
| 49543 | ||||||||||||||||||||||||||||||
| 465 | } | - | ||||||||||||||||||||||||||||||
| 466 | - | |||||||||||||||||||||||||||||||
| 467 | void QQuickGridViewPrivate::initializeViewItem(FxViewItem *item) | - | ||||||||||||||||||||||||||||||
| 468 | { | - | ||||||||||||||||||||||||||||||
| 469 | QQuickItemViewPrivate::initializeViewItem(item); | - | ||||||||||||||||||||||||||||||
| 470 | - | |||||||||||||||||||||||||||||||
| 471 | // need to track current items that are animating | - | ||||||||||||||||||||||||||||||
| 472 | item->trackGeometry(true); | - | ||||||||||||||||||||||||||||||
| 473 | } executed 49543 times by 4 tests: end of blockExecuted by:
| 49543 | ||||||||||||||||||||||||||||||
| 474 | - | |||||||||||||||||||||||||||||||
| 475 | bool QQuickGridViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, qreal bufferFrom, qreal bufferTo, bool doBuffer) | - | ||||||||||||||||||||||||||||||
| 476 | { | - | ||||||||||||||||||||||||||||||
| 477 | qreal colPos = colPosAt(visibleIndex); | - | ||||||||||||||||||||||||||||||
| 478 | qreal rowPos = rowPosAt(visibleIndex); | - | ||||||||||||||||||||||||||||||
| 479 | if (visibleItems.count()) {
| 1954-21513 | ||||||||||||||||||||||||||||||
| 480 | FxGridItemSG *lastItem = static_cast<FxGridItemSG*>(visibleItems.constLast()); | - | ||||||||||||||||||||||||||||||
| 481 | rowPos = lastItem->rowPos(); | - | ||||||||||||||||||||||||||||||
| 482 | int colNum = qFloor((lastItem->colPos()+colSize()/2) / colSize()); | - | ||||||||||||||||||||||||||||||
| 483 | if (++colNum >= columns) {
| 7893-13620 | ||||||||||||||||||||||||||||||
| 484 | colNum = 0; | - | ||||||||||||||||||||||||||||||
| 485 | rowPos += rowSize(); | - | ||||||||||||||||||||||||||||||
| 486 | } executed 13620 times by 4 tests: end of blockExecuted by:
| 13620 | ||||||||||||||||||||||||||||||
| 487 | colPos = colNum * colSize(); | - | ||||||||||||||||||||||||||||||
| 488 | } executed 21513 times by 4 tests: end of blockExecuted by:
| 21513 | ||||||||||||||||||||||||||||||
| 489 | - | |||||||||||||||||||||||||||||||
| 490 | int modelIndex = findLastVisibleIndex(); | - | ||||||||||||||||||||||||||||||
| 491 | modelIndex = modelIndex < 0 ? visibleIndex : modelIndex + 1;
| 1958-21509 | ||||||||||||||||||||||||||||||
| 492 | - | |||||||||||||||||||||||||||||||
| 493 | if (visibleItems.count() && (bufferFrom > rowPos + rowSize()*2
| 0-21513 | ||||||||||||||||||||||||||||||
| 494 | || bufferTo < rowPosAt(visibleIndex) - rowSize())) {
| 6-21507 | ||||||||||||||||||||||||||||||
| 495 | // We've jumped more than a page. Estimate which items are now | - | ||||||||||||||||||||||||||||||
| 496 | // visible and fill from there. | - | ||||||||||||||||||||||||||||||
| 497 | int count = (fillFrom - (rowPos + rowSize())) / (rowSize()) * columns; | - | ||||||||||||||||||||||||||||||
| 498 | releaseVisibleItems(); | - | ||||||||||||||||||||||||||||||
| 499 | modelIndex += count; | - | ||||||||||||||||||||||||||||||
| 500 | if (modelIndex >= model->count())
| 0-6 | ||||||||||||||||||||||||||||||
| 501 | modelIndex = model->count() - 1; never executed: modelIndex = model->count() - 1; | 0 | ||||||||||||||||||||||||||||||
| 502 | else if (modelIndex < 0)
| 2-4 | ||||||||||||||||||||||||||||||
| 503 | modelIndex = 0; executed 2 times by 1 test: modelIndex = 0;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 504 | modelIndex = modelIndex / columns * columns; | - | ||||||||||||||||||||||||||||||
| 505 | visibleIndex = modelIndex; | - | ||||||||||||||||||||||||||||||
| 506 | colPos = colPosAt(visibleIndex); | - | ||||||||||||||||||||||||||||||
| 507 | rowPos = rowPosAt(visibleIndex); | - | ||||||||||||||||||||||||||||||
| 508 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||||||||
| 509 | - | |||||||||||||||||||||||||||||||
| 510 | int colNum = qFloor((colPos+colSize()/2) / colSize()); | - | ||||||||||||||||||||||||||||||
| 511 | FxGridItemSG *item = nullptr; | - | ||||||||||||||||||||||||||||||
| 512 | bool changed = false; | - | ||||||||||||||||||||||||||||||
| 513 | - | |||||||||||||||||||||||||||||||
| 514 | QQmlIncubator::IncubationMode incubationMode = doBuffer ? QQmlIncubator::Asynchronous : QQmlIncubator::AsynchronousIfNested;
| 6895-16572 | ||||||||||||||||||||||||||||||
| 515 | - | |||||||||||||||||||||||||||||||
| 516 | while (modelIndex < model->count() && rowPos <= fillTo + rowSize()*(columns - colNum)/(columns+1)) {
| 11039-53610 | ||||||||||||||||||||||||||||||
| 517 | qCDebug(lcItemViewDelegateLifecycle) << "refill: append item" << modelIndex << colPos << rowPos; never executed: QMessageLogger(__FILE__, 517, __PRETTY_FUNCTION__, lcItemViewDelegateLifecycle().categoryName()).debug() << "refill: append item" << modelIndex << colPos << rowPos;
| 0-41802 | ||||||||||||||||||||||||||||||
| 518 | if (!(item = static_cast<FxGridItemSG*>(createItem(modelIndex, incubationMode))))
| 620-41182 | ||||||||||||||||||||||||||||||
| 519 | break; executed 620 times by 1 test: break;Executed by:
| 620 | ||||||||||||||||||||||||||||||
| 520 | if (!transitioner || !transitioner->canTransition(QQuickItemViewTransitioner::PopulateTransition, true)) // pos will be set by layoutVisibleItems()
| 266-36648 | ||||||||||||||||||||||||||||||
| 521 | item->setPosition(colPos, rowPos, true); executed 40916 times by 3 tests: item->setPosition(colPos, rowPos, true);Executed by:
| 40916 | ||||||||||||||||||||||||||||||
| 522 | QQuickItemPrivate::get(item->item)->setCulled(doBuffer); | - | ||||||||||||||||||||||||||||||
| 523 | visibleItems.append(item); | - | ||||||||||||||||||||||||||||||
| 524 | if (++colNum >= columns) {
| 11151-30031 | ||||||||||||||||||||||||||||||
| 525 | colNum = 0; | - | ||||||||||||||||||||||||||||||
| 526 | rowPos += rowSize(); | - | ||||||||||||||||||||||||||||||
| 527 | } executed 11151 times by 3 tests: end of blockExecuted by:
| 11151 | ||||||||||||||||||||||||||||||
| 528 | colPos = colNum * colSize(); | - | ||||||||||||||||||||||||||||||
| 529 | ++modelIndex; | - | ||||||||||||||||||||||||||||||
| 530 | changed = true; | - | ||||||||||||||||||||||||||||||
| 531 | } executed 41182 times by 3 tests: end of blockExecuted by:
| 41182 | ||||||||||||||||||||||||||||||
| 532 | - | |||||||||||||||||||||||||||||||
| 533 | if (doBuffer && requestedIndex != -1) // already waiting for an item
| 590-16572 | ||||||||||||||||||||||||||||||
| 534 | return changed; executed 590 times by 1 test: return changed;Executed by:
| 590 | ||||||||||||||||||||||||||||||
| 535 | - | |||||||||||||||||||||||||||||||
| 536 | // Find first column | - | ||||||||||||||||||||||||||||||
| 537 | if (visibleItems.count()) {
| 6-22871 | ||||||||||||||||||||||||||||||
| 538 | FxGridItemSG *firstItem = static_cast<FxGridItemSG*>(visibleItems.constFirst()); | - | ||||||||||||||||||||||||||||||
| 539 | rowPos = firstItem->rowPos(); | - | ||||||||||||||||||||||||||||||
| 540 | colPos = firstItem->colPos(); | - | ||||||||||||||||||||||||||||||
| 541 | } executed 22871 times by 4 tests: end of blockExecuted by:
| 22871 | ||||||||||||||||||||||||||||||
| 542 | colNum = qFloor((colPos+colSize()/2) / colSize()); | - | ||||||||||||||||||||||||||||||
| 543 | if (--colNum < 0) {
| 1775-21102 | ||||||||||||||||||||||||||||||
| 544 | colNum = columns - 1; | - | ||||||||||||||||||||||||||||||
| 545 | rowPos -= rowSize(); | - | ||||||||||||||||||||||||||||||
| 546 | } executed 21102 times by 4 tests: end of blockExecuted by:
| 21102 | ||||||||||||||||||||||||||||||
| 547 | - | |||||||||||||||||||||||||||||||
| 548 | // Prepend | - | ||||||||||||||||||||||||||||||
| 549 | colPos = colNum * colSize(); | - | ||||||||||||||||||||||||||||||
| 550 | while (visibleIndex > 0 && rowPos + rowSize() - 1 >= fillFrom - rowSize()*(colNum+1)/(columns+1)){
| 1919-17876 | ||||||||||||||||||||||||||||||
| 551 | qCDebug(lcItemViewDelegateLifecycle) << "refill: prepend item" << visibleIndex-1 << "top pos" << rowPos << colPos; never executed: QMessageLogger(__FILE__, 551, __PRETTY_FUNCTION__, lcItemViewDelegateLifecycle().categoryName()).debug() << "refill: prepend item" << visibleIndex-1 << "top pos" << rowPos << colPos;
| 0-1919 | ||||||||||||||||||||||||||||||
| 552 | if (!(item = static_cast<FxGridItemSG*>(createItem(visibleIndex-1, incubationMode))))
| 222-1697 | ||||||||||||||||||||||||||||||
| 553 | break; executed 222 times by 1 test: break;Executed by:
| 222 | ||||||||||||||||||||||||||||||
| 554 | --visibleIndex; | - | ||||||||||||||||||||||||||||||
| 555 | if (!transitioner || !transitioner->canTransition(QQuickItemViewTransitioner::PopulateTransition, true)) // pos will be set by layoutVisibleItems()
| 0-1677 | ||||||||||||||||||||||||||||||
| 556 | item->setPosition(colPos, rowPos, true); executed 1697 times by 1 test: item->setPosition(colPos, rowPos, true);Executed by:
| 1697 | ||||||||||||||||||||||||||||||
| 557 | QQuickItemPrivate::get(item->item)->setCulled(doBuffer); | - | ||||||||||||||||||||||||||||||
| 558 | visibleItems.prepend(item); | - | ||||||||||||||||||||||||||||||
| 559 | if (--colNum < 0) {
| 537-1160 | ||||||||||||||||||||||||||||||
| 560 | colNum = columns-1; | - | ||||||||||||||||||||||||||||||
| 561 | rowPos -= rowSize(); | - | ||||||||||||||||||||||||||||||
| 562 | } executed 537 times by 1 test: end of blockExecuted by:
| 537 | ||||||||||||||||||||||||||||||
| 563 | colPos = colNum * colSize(); | - | ||||||||||||||||||||||||||||||
| 564 | changed = true; | - | ||||||||||||||||||||||||||||||
| 565 | } executed 1697 times by 1 test: end of blockExecuted by:
| 1697 | ||||||||||||||||||||||||||||||
| 566 | - | |||||||||||||||||||||||||||||||
| 567 | return changed; executed 22877 times by 4 tests: return changed;Executed by:
| 22877 | ||||||||||||||||||||||||||||||
| 568 | } | - | ||||||||||||||||||||||||||||||
| 569 | - | |||||||||||||||||||||||||||||||
| 570 | void QQuickGridViewPrivate::removeItem(FxViewItem *item) | - | ||||||||||||||||||||||||||||||
| 571 | { | - | ||||||||||||||||||||||||||||||
| 572 | if (item->transitionScheduledOrRunning()) {
| 178-5872 | ||||||||||||||||||||||||||||||
| 573 | qCDebug(lcItemViewDelegateLifecycle) << "\tnot releasing animating item:" << item->index << item->item->objectName(); never executed: QMessageLogger(__FILE__, 573, __PRETTY_FUNCTION__, lcItemViewDelegateLifecycle().categoryName()).debug() << "\tnot releasing animating item:" << item->index << item->item->objectName();
| 0-178 | ||||||||||||||||||||||||||||||
| 574 | item->releaseAfterTransition = true; | - | ||||||||||||||||||||||||||||||
| 575 | releasePendingTransition.append(item); | - | ||||||||||||||||||||||||||||||
| 576 | } else { executed 178 times by 1 test: end of blockExecuted by:
| 178 | ||||||||||||||||||||||||||||||
| 577 | releaseItem(item); | - | ||||||||||||||||||||||||||||||
| 578 | } executed 5872 times by 1 test: end of blockExecuted by:
| 5872 | ||||||||||||||||||||||||||||||
| 579 | } | - | ||||||||||||||||||||||||||||||
| 580 | - | |||||||||||||||||||||||||||||||
| 581 | bool QQuickGridViewPrivate::removeNonVisibleItems(qreal bufferFrom, qreal bufferTo) | - | ||||||||||||||||||||||||||||||
| 582 | { | - | ||||||||||||||||||||||||||||||
| 583 | FxGridItemSG *item = nullptr; | - | ||||||||||||||||||||||||||||||
| 584 | bool changed = false; | - | ||||||||||||||||||||||||||||||
| 585 | - | |||||||||||||||||||||||||||||||
| 586 | while (visibleItems.count() > 1
| 114-20325 | ||||||||||||||||||||||||||||||
| 587 | && (item = static_cast<FxGridItemSG*>(visibleItems.constFirst()))
| 0-20325 | ||||||||||||||||||||||||||||||
| 588 | && item->rowPos()+rowSize()-1 < bufferFrom - rowSize()*(item->colPos()/colSize()+1)/(columns+1)) {
| 3867-16458 | ||||||||||||||||||||||||||||||
| 589 | if (item->attached->delayRemove())
| 0-3867 | ||||||||||||||||||||||||||||||
| 590 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 591 | qCDebug(lcItemViewDelegateLifecycle) << "refill: remove first" << visibleIndex << "top end pos" << item->endRowPos(); never executed: QMessageLogger(__FILE__, 591, __PRETTY_FUNCTION__, lcItemViewDelegateLifecycle().categoryName()).debug() << "refill: remove first" << visibleIndex << "top end pos" << item->endRowPos();
| 0-3867 | ||||||||||||||||||||||||||||||
| 592 | if (item->index != -1)
| 0-3867 | ||||||||||||||||||||||||||||||
| 593 | visibleIndex++; executed 3867 times by 1 test: visibleIndex++;Executed by:
| 3867 | ||||||||||||||||||||||||||||||
| 594 | visibleItems.removeFirst(); | - | ||||||||||||||||||||||||||||||
| 595 | removeItem(item); | - | ||||||||||||||||||||||||||||||
| 596 | changed = true; | - | ||||||||||||||||||||||||||||||
| 597 | } executed 3867 times by 1 test: end of blockExecuted by:
| 3867 | ||||||||||||||||||||||||||||||
| 598 | while (visibleItems.count() > 1
| 114-18640 | ||||||||||||||||||||||||||||||
| 599 | && (item = static_cast<FxGridItemSG*>(visibleItems.constLast()))
| 0-18640 | ||||||||||||||||||||||||||||||
| 600 | && item->rowPos() > bufferTo + rowSize()*(columns - item->colPos()/colSize())/(columns+1)) {
| 2182-16458 | ||||||||||||||||||||||||||||||
| 601 | if (item->attached->delayRemove())
| 0-2182 | ||||||||||||||||||||||||||||||
| 602 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 603 | qCDebug(lcItemViewDelegateLifecycle) << "refill: remove last" << visibleIndex+visibleItems.count()-1; never executed: QMessageLogger(__FILE__, 603, __PRETTY_FUNCTION__, lcItemViewDelegateLifecycle().categoryName()).debug() << "refill: remove last" << visibleIndex+visibleItems.count()-1;
| 0-2182 | ||||||||||||||||||||||||||||||
| 604 | visibleItems.removeLast(); | - | ||||||||||||||||||||||||||||||
| 605 | removeItem(item); | - | ||||||||||||||||||||||||||||||
| 606 | changed = true; | - | ||||||||||||||||||||||||||||||
| 607 | } executed 2182 times by 1 test: end of blockExecuted by:
| 2182 | ||||||||||||||||||||||||||||||
| 608 | - | |||||||||||||||||||||||||||||||
| 609 | return changed; executed 16572 times by 4 tests: return changed;Executed by:
| 16572 | ||||||||||||||||||||||||||||||
| 610 | } | - | ||||||||||||||||||||||||||||||
| 611 | - | |||||||||||||||||||||||||||||||
| 612 | void QQuickGridViewPrivate::updateViewport() | - | ||||||||||||||||||||||||||||||
| 613 | { | - | ||||||||||||||||||||||||||||||
| 614 | resetColumns(); | - | ||||||||||||||||||||||||||||||
| 615 | QQuickItemViewPrivate::updateViewport(); | - | ||||||||||||||||||||||||||||||
| 616 | } executed 14899 times by 4 tests: end of blockExecuted by:
| 14899 | ||||||||||||||||||||||||||||||
| 617 | - | |||||||||||||||||||||||||||||||
| 618 | void QQuickGridViewPrivate::layoutVisibleItems(int fromModelIndex) | - | ||||||||||||||||||||||||||||||
| 619 | { | - | ||||||||||||||||||||||||||||||
| 620 | if (visibleItems.count()) {
| 62-4174 | ||||||||||||||||||||||||||||||
| 621 | const qreal from = isContentFlowReversed() ? -position()-displayMarginBeginning-size() : position()-displayMarginBeginning;
| 1389-2785 | ||||||||||||||||||||||||||||||
| 622 | const qreal to = isContentFlowReversed() ? -position()+displayMarginEnd : position()+size()+displayMarginEnd;
| 1389-2785 | ||||||||||||||||||||||||||||||
| 623 | - | |||||||||||||||||||||||||||||||
| 624 | FxGridItemSG *firstItem = static_cast<FxGridItemSG*>(visibleItems.constFirst()); | - | ||||||||||||||||||||||||||||||
| 625 | qreal rowPos = firstItem->rowPos(); | - | ||||||||||||||||||||||||||||||
| 626 | qreal colPos = firstItem->colPos(); | - | ||||||||||||||||||||||||||||||
| 627 | int col = visibleIndex % columns; | - | ||||||||||||||||||||||||||||||
| 628 | if (colPos != col * colSize()) {
| 212-3962 | ||||||||||||||||||||||||||||||
| 629 | colPos = col * colSize(); | - | ||||||||||||||||||||||||||||||
| 630 | firstItem->setPosition(colPos, rowPos); | - | ||||||||||||||||||||||||||||||
| 631 | } executed 212 times by 1 test: end of blockExecuted by:
| 212 | ||||||||||||||||||||||||||||||
| 632 | firstItem->setVisible(firstItem->rowPos() + rowSize() >= from && firstItem->rowPos() <= to); | - | ||||||||||||||||||||||||||||||
| 633 | for (int i = 1; i < visibleItems.count(); ++i) {
| 4174-72706 | ||||||||||||||||||||||||||||||
| 634 | FxGridItemSG *item = static_cast<FxGridItemSG*>(visibleItems.at(i)); | - | ||||||||||||||||||||||||||||||
| 635 | if (++col >= columns) {
| 19077-53629 | ||||||||||||||||||||||||||||||
| 636 | col = 0; | - | ||||||||||||||||||||||||||||||
| 637 | rowPos += rowSize(); | - | ||||||||||||||||||||||||||||||
| 638 | } executed 19077 times by 3 tests: end of blockExecuted by:
| 19077 | ||||||||||||||||||||||||||||||
| 639 | colPos = col * colSize(); | - | ||||||||||||||||||||||||||||||
| 640 | if (item->index >= fromModelIndex) {
| 3858-68848 | ||||||||||||||||||||||||||||||
| 641 | item->setPosition(colPos, rowPos); | - | ||||||||||||||||||||||||||||||
| 642 | item->setVisible(item->rowPos() + rowSize() >= from && item->rowPos() <= to); | - | ||||||||||||||||||||||||||||||
| 643 | } executed 68848 times by 4 tests: end of blockExecuted by:
| 68848 | ||||||||||||||||||||||||||||||
| 644 | } executed 72706 times by 4 tests: end of blockExecuted by:
| 72706 | ||||||||||||||||||||||||||||||
| 645 | } executed 4174 times by 4 tests: end of blockExecuted by:
| 4174 | ||||||||||||||||||||||||||||||
| 646 | } executed 4236 times by 4 tests: end of blockExecuted by:
| 4236 | ||||||||||||||||||||||||||||||
| 647 | - | |||||||||||||||||||||||||||||||
| 648 | void QQuickGridViewPrivate::repositionItemAt(FxViewItem *item, int index, qreal sizeBuffer) | - | ||||||||||||||||||||||||||||||
| 649 | { | - | ||||||||||||||||||||||||||||||
| 650 | int count = sizeBuffer / rowSize(); | - | ||||||||||||||||||||||||||||||
| 651 | static_cast<FxGridItemSG *>(item)->setPosition(colPosAt(index + count), rowPosAt(index + count)); | - | ||||||||||||||||||||||||||||||
| 652 | } executed 126 times by 1 test: end of blockExecuted by:
| 126 | ||||||||||||||||||||||||||||||
| 653 | - | |||||||||||||||||||||||||||||||
| 654 | void QQuickGridViewPrivate::repositionPackageItemAt(QQuickItem *item, int index) | - | ||||||||||||||||||||||||||||||
| 655 | { | - | ||||||||||||||||||||||||||||||
| 656 | Q_Q(QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 657 | qreal pos = position(); | - | ||||||||||||||||||||||||||||||
| 658 | if (flow == QQuickGridView::FlowLeftToRight) {
| 0-28 | ||||||||||||||||||||||||||||||
| 659 | if (item->y() + item->height() > pos && item->y() < pos + q->height()) {
| 0-28 | ||||||||||||||||||||||||||||||
| 660 | qreal y = (verticalLayoutDirection == QQuickItemView::TopToBottom)
| 0-28 | ||||||||||||||||||||||||||||||
| 661 | ? rowPosAt(index) | - | ||||||||||||||||||||||||||||||
| 662 | : -rowPosAt(index) - item->height(); | - | ||||||||||||||||||||||||||||||
| 663 | item->setPosition(QPointF(colPosAt(index), y)); | - | ||||||||||||||||||||||||||||||
| 664 | } executed 28 times by 1 test: end of blockExecuted by:
| 28 | ||||||||||||||||||||||||||||||
| 665 | } else { executed 28 times by 1 test: end of blockExecuted by:
| 28 | ||||||||||||||||||||||||||||||
| 666 | if (item->x() + item->width() > pos && item->x() < pos + q->width()) {
| 0 | ||||||||||||||||||||||||||||||
| 667 | qreal y = (verticalLayoutDirection == QQuickItemView::TopToBottom)
| 0 | ||||||||||||||||||||||||||||||
| 668 | ? colPosAt(index) | - | ||||||||||||||||||||||||||||||
| 669 | : -colPosAt(index) - item->height(); | - | ||||||||||||||||||||||||||||||
| 670 | if (flow == QQuickGridView::FlowTopToBottom && q->effectiveLayoutDirection() == Qt::RightToLeft)
| 0 | ||||||||||||||||||||||||||||||
| 671 | item->setPosition(QPointF(-rowPosAt(index)-item->width(), y)); never executed: item->setPosition(QPointF(-rowPosAt(index)-item->width(), y)); | 0 | ||||||||||||||||||||||||||||||
| 672 | else | - | ||||||||||||||||||||||||||||||
| 673 | item->setPosition(QPointF(rowPosAt(index), y)); never executed: item->setPosition(QPointF(rowPosAt(index), y)); | 0 | ||||||||||||||||||||||||||||||
| 674 | } | - | ||||||||||||||||||||||||||||||
| 675 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 676 | } | - | ||||||||||||||||||||||||||||||
| 677 | - | |||||||||||||||||||||||||||||||
| 678 | void QQuickGridViewPrivate::resetFirstItemPosition(qreal pos) | - | ||||||||||||||||||||||||||||||
| 679 | { | - | ||||||||||||||||||||||||||||||
| 680 | FxGridItemSG *item = static_cast<FxGridItemSG*>(visibleItems.constFirst()); | - | ||||||||||||||||||||||||||||||
| 681 | item->setPosition(0, pos); | - | ||||||||||||||||||||||||||||||
| 682 | } executed 621 times by 3 tests: end of blockExecuted by:
| 621 | ||||||||||||||||||||||||||||||
| 683 | - | |||||||||||||||||||||||||||||||
| 684 | void QQuickGridViewPrivate::adjustFirstItem(qreal forwards, qreal backwards, int changeBeforeVisible) | - | ||||||||||||||||||||||||||||||
| 685 | { | - | ||||||||||||||||||||||||||||||
| 686 | if (!visibleItems.count())
| 0-1936 | ||||||||||||||||||||||||||||||
| 687 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 688 | - | |||||||||||||||||||||||||||||||
| 689 | int moveCount = (forwards - backwards) / rowSize(); | - | ||||||||||||||||||||||||||||||
| 690 | if (moveCount == 0 && changeBeforeVisible != 0)
| 170-1699 | ||||||||||||||||||||||||||||||
| 691 | moveCount += (changeBeforeVisible % columns) - (columns - 1); executed 170 times by 1 test: moveCount += (changeBeforeVisible % columns) - (columns - 1);Executed by:
| 170 | ||||||||||||||||||||||||||||||
| 692 | - | |||||||||||||||||||||||||||||||
| 693 | FxGridItemSG *gridItem = static_cast<FxGridItemSG*>(visibleItems.constFirst()); | - | ||||||||||||||||||||||||||||||
| 694 | gridItem->setPosition(gridItem->colPos(), gridItem->rowPos() + ((moveCount / columns) * rowSize())); | - | ||||||||||||||||||||||||||||||
| 695 | } executed 1936 times by 1 test: end of blockExecuted by:
| 1936 | ||||||||||||||||||||||||||||||
| 696 | - | |||||||||||||||||||||||||||||||
| 697 | void QQuickGridViewPrivate::createHighlight() | - | ||||||||||||||||||||||||||||||
| 698 | { | - | ||||||||||||||||||||||||||||||
| 699 | Q_Q(QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 700 | bool changed = false; | - | ||||||||||||||||||||||||||||||
| 701 | if (highlight) {
| 1986-3934 | ||||||||||||||||||||||||||||||
| 702 | if (trackedItem == highlight)
| 0-1986 | ||||||||||||||||||||||||||||||
| 703 | trackedItem = nullptr; executed 1986 times by 4 tests: trackedItem = nullptr;Executed by:
| 1986 | ||||||||||||||||||||||||||||||
| 704 | delete highlight; | - | ||||||||||||||||||||||||||||||
| 705 | highlight = nullptr; | - | ||||||||||||||||||||||||||||||
| 706 | - | |||||||||||||||||||||||||||||||
| 707 | delete highlightXAnimator; | - | ||||||||||||||||||||||||||||||
| 708 | delete highlightYAnimator; | - | ||||||||||||||||||||||||||||||
| 709 | highlightXAnimator = nullptr; | - | ||||||||||||||||||||||||||||||
| 710 | highlightYAnimator = nullptr; | - | ||||||||||||||||||||||||||||||
| 711 | - | |||||||||||||||||||||||||||||||
| 712 | changed = true; | - | ||||||||||||||||||||||||||||||
| 713 | } executed 1986 times by 4 tests: end of blockExecuted by:
| 1986 | ||||||||||||||||||||||||||||||
| 714 | - | |||||||||||||||||||||||||||||||
| 715 | if (currentItem) {
| 1986-3934 | ||||||||||||||||||||||||||||||
| 716 | QQuickItem *item = createHighlightItem(); | - | ||||||||||||||||||||||||||||||
| 717 | if (item) {
| 0-1986 | ||||||||||||||||||||||||||||||
| 718 | FxGridItemSG *newHighlight = new FxGridItemSG(item, q, true); | - | ||||||||||||||||||||||||||||||
| 719 | newHighlight->trackGeometry(true); | - | ||||||||||||||||||||||||||||||
| 720 | if (autoHighlight)
| 10-1976 | ||||||||||||||||||||||||||||||
| 721 | resetHighlightPosition(); executed 1976 times by 4 tests: resetHighlightPosition();Executed by:
| 1976 | ||||||||||||||||||||||||||||||
| 722 | highlightXAnimator = new QSmoothedAnimation; | - | ||||||||||||||||||||||||||||||
| 723 | highlightXAnimator->target = QQmlProperty(item, QLatin1String("x")); | - | ||||||||||||||||||||||||||||||
| 724 | highlightXAnimator->userDuration = highlightMoveDuration; | - | ||||||||||||||||||||||||||||||
| 725 | highlightYAnimator = new QSmoothedAnimation; | - | ||||||||||||||||||||||||||||||
| 726 | highlightYAnimator->target = QQmlProperty(item, QLatin1String("y")); | - | ||||||||||||||||||||||||||||||
| 727 | highlightYAnimator->userDuration = highlightMoveDuration; | - | ||||||||||||||||||||||||||||||
| 728 | - | |||||||||||||||||||||||||||||||
| 729 | highlight = newHighlight; | - | ||||||||||||||||||||||||||||||
| 730 | changed = true; | - | ||||||||||||||||||||||||||||||
| 731 | } executed 1986 times by 4 tests: end of blockExecuted by:
| 1986 | ||||||||||||||||||||||||||||||
| 732 | } executed 1986 times by 4 tests: end of blockExecuted by:
| 1986 | ||||||||||||||||||||||||||||||
| 733 | if (changed)
| 1950-3970 | ||||||||||||||||||||||||||||||
| 734 | emit q->highlightItemChanged(); executed 3970 times by 4 tests: q->highlightItemChanged();Executed by:
| 3970 | ||||||||||||||||||||||||||||||
| 735 | } executed 5920 times by 4 tests: end of blockExecuted by:
| 5920 | ||||||||||||||||||||||||||||||
| 736 | - | |||||||||||||||||||||||||||||||
| 737 | void QQuickGridViewPrivate::updateHighlight() | - | ||||||||||||||||||||||||||||||
| 738 | { | - | ||||||||||||||||||||||||||||||
| 739 | applyPendingChanges(); | - | ||||||||||||||||||||||||||||||
| 740 | - | |||||||||||||||||||||||||||||||
| 741 | if ((!currentItem && highlight) || (currentItem && !highlight))
| 12-9102 | ||||||||||||||||||||||||||||||
| 742 | createHighlight(); executed 2038 times by 4 tests: createHighlight();Executed by:
| 2038 | ||||||||||||||||||||||||||||||
| 743 | bool strictHighlight = haveHighlightRange && highlightRange == QQuickGridView::StrictlyEnforceRange;
| 4-8550 | ||||||||||||||||||||||||||||||
| 744 | if (currentItem && autoHighlight && highlight && (!strictHighlight || !pressed)) {
| 0-9102 | ||||||||||||||||||||||||||||||
| 745 | // auto-update highlight | - | ||||||||||||||||||||||||||||||
| 746 | highlightXAnimator->to = currentItem->itemX(); | - | ||||||||||||||||||||||||||||||
| 747 | highlightYAnimator->to = currentItem->itemY(); | - | ||||||||||||||||||||||||||||||
| 748 | highlight->item->setSize(currentItem->item->size()); | - | ||||||||||||||||||||||||||||||
| 749 | - | |||||||||||||||||||||||||||||||
| 750 | highlightXAnimator->restart(); | - | ||||||||||||||||||||||||||||||
| 751 | highlightYAnimator->restart(); | - | ||||||||||||||||||||||||||||||
| 752 | } executed 8978 times by 4 tests: end of blockExecuted by:
| 8978 | ||||||||||||||||||||||||||||||
| 753 | updateTrackedItem(); | - | ||||||||||||||||||||||||||||||
| 754 | } executed 9168 times by 4 tests: end of blockExecuted by:
| 9168 | ||||||||||||||||||||||||||||||
| 755 | - | |||||||||||||||||||||||||||||||
| 756 | void QQuickGridViewPrivate::resetHighlightPosition() | - | ||||||||||||||||||||||||||||||
| 757 | { | - | ||||||||||||||||||||||||||||||
| 758 | if (highlight && currentItem) {
| 0-1976 | ||||||||||||||||||||||||||||||
| 759 | FxGridItemSG *cItem = static_cast<FxGridItemSG*>(currentItem); | - | ||||||||||||||||||||||||||||||
| 760 | static_cast<FxGridItemSG*>(highlight)->setPosition(cItem->colPos(), cItem->rowPos()); | - | ||||||||||||||||||||||||||||||
| 761 | } executed 1854 times by 3 tests: end of blockExecuted by:
| 1854 | ||||||||||||||||||||||||||||||
| 762 | } executed 3830 times by 4 tests: end of blockExecuted by:
| 3830 | ||||||||||||||||||||||||||||||
| 763 | - | |||||||||||||||||||||||||||||||
| 764 | qreal QQuickGridViewPrivate::headerSize() const | - | ||||||||||||||||||||||||||||||
| 765 | { | - | ||||||||||||||||||||||||||||||
| 766 | if (!header)
| 2688-41523 | ||||||||||||||||||||||||||||||
| 767 | return 0.0; executed 41523 times by 4 tests: return 0.0;Executed by:
| 41523 | ||||||||||||||||||||||||||||||
| 768 | return flow == QQuickGridView::FlowLeftToRight ? header->item->height() : header->item->width(); executed 2688 times by 1 test: return flow == QQuickGridView::FlowLeftToRight ? header->item->height() : header->item->width();Executed by:
| 2688 | ||||||||||||||||||||||||||||||
| 769 | } | - | ||||||||||||||||||||||||||||||
| 770 | - | |||||||||||||||||||||||||||||||
| 771 | qreal QQuickGridViewPrivate::footerSize() const | - | ||||||||||||||||||||||||||||||
| 772 | { | - | ||||||||||||||||||||||||||||||
| 773 | if (!footer)
| 1335-33518 | ||||||||||||||||||||||||||||||
| 774 | return 0.0; executed 33518 times by 4 tests: return 0.0;Executed by:
| 33518 | ||||||||||||||||||||||||||||||
| 775 | return flow == QQuickGridView::FlowLeftToRight? footer->item->height() : footer->item->width(); executed 1335 times by 1 test: return flow == QQuickGridView::FlowLeftToRight? footer->item->height() : footer->item->width();Executed by:
| 1335 | ||||||||||||||||||||||||||||||
| 776 | } | - | ||||||||||||||||||||||||||||||
| 777 | - | |||||||||||||||||||||||||||||||
| 778 | bool QQuickGridViewPrivate::showHeaderForIndex(int index) const | - | ||||||||||||||||||||||||||||||
| 779 | { | - | ||||||||||||||||||||||||||||||
| 780 | return index / columns == 0; executed 6031 times by 3 tests: return index / columns == 0;Executed by:
| 6031 | ||||||||||||||||||||||||||||||
| 781 | } | - | ||||||||||||||||||||||||||||||
| 782 | - | |||||||||||||||||||||||||||||||
| 783 | bool QQuickGridViewPrivate::showFooterForIndex(int index) const | - | ||||||||||||||||||||||||||||||
| 784 | { | - | ||||||||||||||||||||||||||||||
| 785 | return index / columns == (model->count()-1) / columns; executed 1028 times by 1 test: return index / columns == (model->count()-1) / columns;Executed by:
| 1028 | ||||||||||||||||||||||||||||||
| 786 | } | - | ||||||||||||||||||||||||||||||
| 787 | - | |||||||||||||||||||||||||||||||
| 788 | void QQuickGridViewPrivate::updateFooter() | - | ||||||||||||||||||||||||||||||
| 789 | { | - | ||||||||||||||||||||||||||||||
| 790 | Q_Q(QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 791 | bool created = false; | - | ||||||||||||||||||||||||||||||
| 792 | if (!footer) {
| 483-10626 | ||||||||||||||||||||||||||||||
| 793 | QQuickItem *item = createComponentItem(footerComponent, 1.0); | - | ||||||||||||||||||||||||||||||
| 794 | if (!item)
| 86-10540 | ||||||||||||||||||||||||||||||
| 795 | return; executed 10540 times by 4 tests: return;Executed by:
| 10540 | ||||||||||||||||||||||||||||||
| 796 | footer = new FxGridItemSG(item, q, true); | - | ||||||||||||||||||||||||||||||
| 797 | footer->trackGeometry(true); | - | ||||||||||||||||||||||||||||||
| 798 | created = true; | - | ||||||||||||||||||||||||||||||
| 799 | } executed 86 times by 1 test: end of blockExecuted by:
| 86 | ||||||||||||||||||||||||||||||
| 800 | - | |||||||||||||||||||||||||||||||
| 801 | FxGridItemSG *gridItem = static_cast<FxGridItemSG*>(footer); | - | ||||||||||||||||||||||||||||||
| 802 | qreal colOffset = 0; | - | ||||||||||||||||||||||||||||||
| 803 | qreal rowOffset = 0; | - | ||||||||||||||||||||||||||||||
| 804 | if (q->effectiveLayoutDirection() == Qt::RightToLeft) {
| 192-377 | ||||||||||||||||||||||||||||||
| 805 | if (flow == QQuickGridView::FlowTopToBottom)
| 94-98 | ||||||||||||||||||||||||||||||
| 806 | rowOffset += gridItem->item->width() - cellWidth; executed 98 times by 1 test: rowOffset += gridItem->item->width() - cellWidth;Executed by:
| 98 | ||||||||||||||||||||||||||||||
| 807 | else | - | ||||||||||||||||||||||||||||||
| 808 | colOffset += gridItem->item->width() - cellWidth; executed 94 times by 1 test: colOffset += gridItem->item->width() - cellWidth;Executed by:
| 94 | ||||||||||||||||||||||||||||||
| 809 | } | - | ||||||||||||||||||||||||||||||
| 810 | if (verticalLayoutDirection == QQuickItemView::BottomToTop) {
| 172-397 | ||||||||||||||||||||||||||||||
| 811 | if (flow == QQuickGridView::FlowTopToBottom)
| 86 | ||||||||||||||||||||||||||||||
| 812 | colOffset += gridItem->item->height() - cellHeight; executed 86 times by 1 test: colOffset += gridItem->item->height() - cellHeight;Executed by:
| 86 | ||||||||||||||||||||||||||||||
| 813 | else | - | ||||||||||||||||||||||||||||||
| 814 | rowOffset += gridItem->item->height() - cellHeight; executed 86 times by 1 test: rowOffset += gridItem->item->height() - cellHeight;Executed by:
| 86 | ||||||||||||||||||||||||||||||
| 815 | } | - | ||||||||||||||||||||||||||||||
| 816 | if (visibleItems.count()) {
| 190-379 | ||||||||||||||||||||||||||||||
| 817 | qreal endPos = lastPosition(); | - | ||||||||||||||||||||||||||||||
| 818 | if (findLastVisibleIndex() == model->count()-1) {
| 58-321 | ||||||||||||||||||||||||||||||
| 819 | gridItem->setPosition(colOffset, endPos + rowOffset); | - | ||||||||||||||||||||||||||||||
| 820 | } else { executed 321 times by 1 test: end of blockExecuted by:
| 321 | ||||||||||||||||||||||||||||||
| 821 | qreal visiblePos = isContentFlowReversed() ? -position() : position() + size();
| 0-58 | ||||||||||||||||||||||||||||||
| 822 | if (endPos <= visiblePos || gridItem->endPosition() <= endPos + rowOffset)
| 0-58 | ||||||||||||||||||||||||||||||
| 823 | gridItem->setPosition(colOffset, endPos + rowOffset); executed 8 times by 1 test: gridItem->setPosition(colOffset, endPos + rowOffset);Executed by:
| 8 | ||||||||||||||||||||||||||||||
| 824 | } executed 58 times by 1 test: end of blockExecuted by:
| 58 | ||||||||||||||||||||||||||||||
| 825 | } else { | - | ||||||||||||||||||||||||||||||
| 826 | gridItem->setPosition(colOffset, rowOffset); | - | ||||||||||||||||||||||||||||||
| 827 | } executed 190 times by 1 test: end of blockExecuted by:
| 190 | ||||||||||||||||||||||||||||||
| 828 | - | |||||||||||||||||||||||||||||||
| 829 | if (created)
| 86-483 | ||||||||||||||||||||||||||||||
| 830 | emit q->footerItemChanged(); executed 86 times by 1 test: q->footerItemChanged();Executed by:
| 86 | ||||||||||||||||||||||||||||||
| 831 | } executed 569 times by 1 test: end of blockExecuted by:
| 569 | ||||||||||||||||||||||||||||||
| 832 | - | |||||||||||||||||||||||||||||||
| 833 | void QQuickGridViewPrivate::updateHeader() | - | ||||||||||||||||||||||||||||||
| 834 | { | - | ||||||||||||||||||||||||||||||
| 835 | Q_Q(QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 836 | bool created = false; | - | ||||||||||||||||||||||||||||||
| 837 | if (!header) {
| 524-10557 | ||||||||||||||||||||||||||||||
| 838 | QQuickItem *item = createComponentItem(headerComponent, 1.0); | - | ||||||||||||||||||||||||||||||
| 839 | if (!item)
| 126-10431 | ||||||||||||||||||||||||||||||
| 840 | return; executed 10431 times by 4 tests: return;Executed by:
| 10431 | ||||||||||||||||||||||||||||||
| 841 | header = new FxGridItemSG(item, q, true); | - | ||||||||||||||||||||||||||||||
| 842 | header->trackGeometry(true); | - | ||||||||||||||||||||||||||||||
| 843 | created = true; | - | ||||||||||||||||||||||||||||||
| 844 | } executed 126 times by 1 test: end of blockExecuted by:
| 126 | ||||||||||||||||||||||||||||||
| 845 | - | |||||||||||||||||||||||||||||||
| 846 | FxGridItemSG *gridItem = static_cast<FxGridItemSG*>(header); | - | ||||||||||||||||||||||||||||||
| 847 | qreal colOffset = 0; | - | ||||||||||||||||||||||||||||||
| 848 | qreal rowOffset = -headerSize(); | - | ||||||||||||||||||||||||||||||
| 849 | if (q->effectiveLayoutDirection() == Qt::RightToLeft) {
| 169-481 | ||||||||||||||||||||||||||||||
| 850 | if (flow == QQuickGridView::FlowTopToBottom)
| 82-87 | ||||||||||||||||||||||||||||||
| 851 | rowOffset += gridItem->item->width() - cellWidth; executed 82 times by 1 test: rowOffset += gridItem->item->width() - cellWidth;Executed by:
| 82 | ||||||||||||||||||||||||||||||
| 852 | else | - | ||||||||||||||||||||||||||||||
| 853 | colOffset += gridItem->item->width() - cellWidth; executed 87 times by 1 test: colOffset += gridItem->item->width() - cellWidth;Executed by:
| 87 | ||||||||||||||||||||||||||||||
| 854 | } | - | ||||||||||||||||||||||||||||||
| 855 | if (verticalLayoutDirection == QQuickItemView::BottomToTop) {
| 140-510 | ||||||||||||||||||||||||||||||
| 856 | if (flow == QQuickGridView::FlowTopToBottom)
| 66-74 | ||||||||||||||||||||||||||||||
| 857 | colOffset += gridItem->item->height() - cellHeight; executed 74 times by 1 test: colOffset += gridItem->item->height() - cellHeight;Executed by:
| 74 | ||||||||||||||||||||||||||||||
| 858 | else | - | ||||||||||||||||||||||||||||||
| 859 | rowOffset += gridItem->item->height() - cellHeight; executed 66 times by 1 test: rowOffset += gridItem->item->height() - cellHeight;Executed by:
| 66 | ||||||||||||||||||||||||||||||
| 860 | } | - | ||||||||||||||||||||||||||||||
| 861 | if (visibleItems.count()) {
| 308-342 | ||||||||||||||||||||||||||||||
| 862 | qreal startPos = originPosition(); | - | ||||||||||||||||||||||||||||||
| 863 | if (visibleIndex == 0) {
| 47-295 | ||||||||||||||||||||||||||||||
| 864 | gridItem->setPosition(colOffset, startPos + rowOffset); | - | ||||||||||||||||||||||||||||||
| 865 | } else { executed 295 times by 1 test: end of blockExecuted by:
| 295 | ||||||||||||||||||||||||||||||
| 866 | qreal tempPos = isContentFlowReversed() ? -position()-size() : position();
| 0-47 | ||||||||||||||||||||||||||||||
| 867 | qreal headerPos = isContentFlowReversed() ? gridItem->rowPos() + cellWidth - headerSize() : gridItem->rowPos();
| 0-47 | ||||||||||||||||||||||||||||||
| 868 | if (tempPos <= startPos || headerPos > startPos + rowOffset)
| 0-47 | ||||||||||||||||||||||||||||||
| 869 | gridItem->setPosition(colOffset, startPos + rowOffset); executed 6 times by 1 test: gridItem->setPosition(colOffset, startPos + rowOffset);Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 870 | } executed 47 times by 1 test: end of blockExecuted by:
| 47 | ||||||||||||||||||||||||||||||
| 871 | } else { | - | ||||||||||||||||||||||||||||||
| 872 | if (isContentFlowReversed())
| 80-228 | ||||||||||||||||||||||||||||||
| 873 | gridItem->setPosition(colOffset, rowOffset); executed 80 times by 1 test: gridItem->setPosition(colOffset, rowOffset);Executed by:
| 80 | ||||||||||||||||||||||||||||||
| 874 | else | - | ||||||||||||||||||||||||||||||
| 875 | gridItem->setPosition(colOffset, -headerSize()); executed 228 times by 1 test: gridItem->setPosition(colOffset, -headerSize());Executed by:
| 228 | ||||||||||||||||||||||||||||||
| 876 | } | - | ||||||||||||||||||||||||||||||
| 877 | - | |||||||||||||||||||||||||||||||
| 878 | if (created)
| 126-524 | ||||||||||||||||||||||||||||||
| 879 | emit q->headerItemChanged(); executed 126 times by 1 test: q->headerItemChanged();Executed by:
| 126 | ||||||||||||||||||||||||||||||
| 880 | } executed 650 times by 1 test: end of blockExecuted by:
| 650 | ||||||||||||||||||||||||||||||
| 881 | - | |||||||||||||||||||||||||||||||
| 882 | void QQuickGridViewPrivate::initializeCurrentItem() | - | ||||||||||||||||||||||||||||||
| 883 | { | - | ||||||||||||||||||||||||||||||
| 884 | if (currentItem && currentIndex >= 0) {
| 0-3088 | ||||||||||||||||||||||||||||||
| 885 | FxGridItemSG *gridItem = static_cast<FxGridItemSG*>(currentItem); | - | ||||||||||||||||||||||||||||||
| 886 | FxViewItem *actualItem = visibleItem(currentIndex); | - | ||||||||||||||||||||||||||||||
| 887 | - | |||||||||||||||||||||||||||||||
| 888 | // don't reposition the item if it's about to be transitioned to another position | - | ||||||||||||||||||||||||||||||
| 889 | if ((!actualItem || !actualItem->transitionScheduledOrRunning()))
| 96-2957 | ||||||||||||||||||||||||||||||
| 890 | gridItem->setPosition(colPosAt(currentIndex), rowPosAt(currentIndex)); executed 2992 times by 4 tests: gridItem->setPosition(colPosAt(currentIndex), rowPosAt(currentIndex));Executed by:
| 2992 | ||||||||||||||||||||||||||||||
| 891 | } executed 3088 times by 4 tests: end of blockExecuted by:
| 3088 | ||||||||||||||||||||||||||||||
| 892 | } executed 3088 times by 4 tests: end of blockExecuted by:
| 3088 | ||||||||||||||||||||||||||||||
| 893 | - | |||||||||||||||||||||||||||||||
| 894 | void QQuickGridViewPrivate::fixupPosition() | - | ||||||||||||||||||||||||||||||
| 895 | { | - | ||||||||||||||||||||||||||||||
| 896 | if (flow == QQuickGridView::FlowLeftToRight)
| 2114-3845 | ||||||||||||||||||||||||||||||
| 897 | fixupY(); executed 3845 times by 4 tests: fixupY();Executed by:
| 3845 | ||||||||||||||||||||||||||||||
| 898 | else | - | ||||||||||||||||||||||||||||||
| 899 | fixupX(); executed 2114 times by 1 test: fixupX();Executed by:
| 2114 | ||||||||||||||||||||||||||||||
| 900 | } | - | ||||||||||||||||||||||||||||||
| 901 | - | |||||||||||||||||||||||||||||||
| 902 | void QQuickGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent) | - | ||||||||||||||||||||||||||||||
| 903 | { | - | ||||||||||||||||||||||||||||||
| 904 | if ((flow == QQuickGridView::FlowTopToBottom && &data == &vData)
| 222-6293 | ||||||||||||||||||||||||||||||
| 905 | || (flow == QQuickGridView::FlowLeftToRight && &data == &hData))
| 176-6293 | ||||||||||||||||||||||||||||||
| 906 | return; executed 398 times by 4 tests: return;Executed by:
| 398 | ||||||||||||||||||||||||||||||
| 907 | - | |||||||||||||||||||||||||||||||
| 908 | fixupMode = moveReason == Mouse ? fixupMode : Immediate;
| 196-9243 | ||||||||||||||||||||||||||||||
| 909 | - | |||||||||||||||||||||||||||||||
| 910 | qreal viewPos = isContentFlowReversed() ? -position()-size() : position();
| 3055-6384 | ||||||||||||||||||||||||||||||
| 911 | - | |||||||||||||||||||||||||||||||
| 912 | bool strictHighlightRange = haveHighlightRange && highlightRange == QQuickGridView::StrictlyEnforceRange;
| 4-9138 | ||||||||||||||||||||||||||||||
| 913 | if (snapMode != QQuickGridView::NoSnap) {
| 348-9091 | ||||||||||||||||||||||||||||||
| 914 | qreal tempPosition = isContentFlowReversed() ? -position()-size() : position();
| 171-177 | ||||||||||||||||||||||||||||||
| 915 | if (snapMode == QQuickGridView::SnapOneRow && moveReason == Mouse) {
| 88-176 | ||||||||||||||||||||||||||||||
| 916 | // if we've been dragged < rowSize()/2 then bias towards the next row | - | ||||||||||||||||||||||||||||||
| 917 | qreal dist = data.move.value() - data.pressPos; | - | ||||||||||||||||||||||||||||||
| 918 | qreal bias = 0; | - | ||||||||||||||||||||||||||||||
| 919 | if (data.velocity > 0 && dist > QML_FLICK_SNAPONETHRESHOLD && dist < rowSize()/2)
| 0-46 | ||||||||||||||||||||||||||||||
| 920 | bias = rowSize()/2; executed 10 times by 1 test: bias = rowSize()/2;Executed by:
| 10 | ||||||||||||||||||||||||||||||
| 921 | else if (data.velocity < 0 && dist < -QML_FLICK_SNAPONETHRESHOLD && dist > -rowSize()/2)
| 2-46 | ||||||||||||||||||||||||||||||
| 922 | bias = -rowSize()/2; executed 14 times by 1 test: bias = -rowSize()/2;Executed by:
| 14 | ||||||||||||||||||||||||||||||
| 923 | if (isContentFlowReversed())
| 22-66 | ||||||||||||||||||||||||||||||
| 924 | bias = -bias; executed 22 times by 1 test: bias = -bias;Executed by:
| 22 | ||||||||||||||||||||||||||||||
| 925 | tempPosition -= bias; | - | ||||||||||||||||||||||||||||||
| 926 | } executed 88 times by 1 test: end of blockExecuted by:
| 88 | ||||||||||||||||||||||||||||||
| 927 | FxViewItem *topItem = snapItemAt(tempPosition+highlightRangeStart); | - | ||||||||||||||||||||||||||||||
| 928 | if (strictHighlightRange && currentItem && (!topItem || (topItem->index != currentIndex && fixupMode == Immediate))) {
| 0-237 | ||||||||||||||||||||||||||||||
| 929 | // StrictlyEnforceRange always keeps an item in range | - | ||||||||||||||||||||||||||||||
| 930 | updateHighlight(); | - | ||||||||||||||||||||||||||||||
| 931 | topItem = currentItem; | - | ||||||||||||||||||||||||||||||
| 932 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||||||||||||||||||||||||||
| 933 | FxViewItem *bottomItem = snapItemAt(tempPosition+highlightRangeEnd); | - | ||||||||||||||||||||||||||||||
| 934 | if (strictHighlightRange && currentItem && (!bottomItem || (bottomItem->index != currentIndex && fixupMode == Immediate))) {
| 12-237 | ||||||||||||||||||||||||||||||
| 935 | // StrictlyEnforceRange always keeps an item in range | - | ||||||||||||||||||||||||||||||
| 936 | updateHighlight(); | - | ||||||||||||||||||||||||||||||
| 937 | bottomItem = currentItem; | - | ||||||||||||||||||||||||||||||
| 938 | } executed 81 times by 1 test: end of blockExecuted by:
| 81 | ||||||||||||||||||||||||||||||
| 939 | qreal pos; | - | ||||||||||||||||||||||||||||||
| 940 | bool isInBounds = -position() > maxExtent && -position() <= minExtent;
| 25-263 | ||||||||||||||||||||||||||||||
| 941 | if (topItem && (isInBounds || strictHighlightRange)) {
| 31-278 | ||||||||||||||||||||||||||||||
| 942 | qreal headerPos = header ? static_cast<FxGridItemSG*>(header)->rowPos() : 0;
| 0-247 | ||||||||||||||||||||||||||||||
| 943 | if (topItem->index == 0 && header && tempPosition+highlightRangeStart < headerPos+headerSize()/2 && !strictHighlightRange) {
| 0-152 | ||||||||||||||||||||||||||||||
| 944 | pos = isContentFlowReversed() ? - headerPos + highlightRangeStart - size() : headerPos - highlightRangeStart;
| 0 | ||||||||||||||||||||||||||||||
| 945 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 946 | if (isContentFlowReversed())
| 103-144 | ||||||||||||||||||||||||||||||
| 947 | pos = qMax(qMin(-topItem->position() + highlightRangeStart - size(), -maxExtent), -minExtent); executed 103 times by 1 test: pos = qMax(qMin(-topItem->position() + highlightRangeStart - size(), -maxExtent), -minExtent);Executed by:
| 103 | ||||||||||||||||||||||||||||||
| 948 | else | - | ||||||||||||||||||||||||||||||
| 949 | pos = qMax(qMin(topItem->position() - highlightRangeStart, -maxExtent), -minExtent); executed 144 times by 1 test: pos = qMax(qMin(topItem->position() - highlightRangeStart, -maxExtent), -minExtent);Executed by:
| 144 | ||||||||||||||||||||||||||||||
| 950 | } | - | ||||||||||||||||||||||||||||||
| 951 | } else if (bottomItem && isInBounds) {
| 0-76 | ||||||||||||||||||||||||||||||
| 952 | if (isContentFlowReversed())
| 0 | ||||||||||||||||||||||||||||||
| 953 | pos = qMax(qMin(-bottomItem->position() + highlightRangeEnd - size(), -maxExtent), -minExtent); never executed: pos = qMax(qMin(-bottomItem->position() + highlightRangeEnd - size(), -maxExtent), -minExtent); | 0 | ||||||||||||||||||||||||||||||
| 954 | else | - | ||||||||||||||||||||||||||||||
| 955 | pos = qMax(qMin(bottomItem->position() - highlightRangeEnd, -maxExtent), -minExtent); never executed: pos = qMax(qMin(bottomItem->position() - highlightRangeEnd, -maxExtent), -minExtent); | 0 | ||||||||||||||||||||||||||||||
| 956 | } else { | - | ||||||||||||||||||||||||||||||
| 957 | QQuickItemViewPrivate::fixup(data, minExtent, maxExtent); | - | ||||||||||||||||||||||||||||||
| 958 | return; executed 101 times by 1 test: return;Executed by:
| 101 | ||||||||||||||||||||||||||||||
| 959 | } | - | ||||||||||||||||||||||||||||||
| 960 | - | |||||||||||||||||||||||||||||||
| 961 | qreal dist = qAbs(data.move + pos); | - | ||||||||||||||||||||||||||||||
| 962 | if (dist > 0) {
| 109-138 | ||||||||||||||||||||||||||||||
| 963 | timeline.reset(data.move); | - | ||||||||||||||||||||||||||||||
| 964 | if (fixupMode != Immediate) {
| 26-112 | ||||||||||||||||||||||||||||||
| 965 | timeline.move(data.move, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); | - | ||||||||||||||||||||||||||||||
| 966 | data.fixingUp = true; | - | ||||||||||||||||||||||||||||||
| 967 | } else { executed 112 times by 1 test: end of blockExecuted by:
| 112 | ||||||||||||||||||||||||||||||
| 968 | timeline.set(data.move, -pos); | - | ||||||||||||||||||||||||||||||
| 969 | } executed 26 times by 1 test: end of blockExecuted by:
| 26 | ||||||||||||||||||||||||||||||
| 970 | vTime = timeline.time(); | - | ||||||||||||||||||||||||||||||
| 971 | } executed 138 times by 1 test: end of blockExecuted by:
| 138 | ||||||||||||||||||||||||||||||
| 972 | } else if (haveHighlightRange && highlightRange == QQuickGridView::StrictlyEnforceRange) { executed 247 times by 1 test: end of blockExecuted by:
| 0-9031 | ||||||||||||||||||||||||||||||
| 973 | if (currentItem) {
| 16-44 | ||||||||||||||||||||||||||||||
| 974 | updateHighlight(); | - | ||||||||||||||||||||||||||||||
| 975 | qreal pos = static_cast<FxGridItemSG*>(currentItem)->rowPos(); | - | ||||||||||||||||||||||||||||||
| 976 | if (viewPos < pos + rowSize() - highlightRangeEnd)
| 12-32 | ||||||||||||||||||||||||||||||
| 977 | viewPos = pos + rowSize() - highlightRangeEnd; executed 32 times by 1 test: viewPos = pos + rowSize() - highlightRangeEnd;Executed by:
| 32 | ||||||||||||||||||||||||||||||
| 978 | if (viewPos > pos - highlightRangeStart)
| 0-44 | ||||||||||||||||||||||||||||||
| 979 | viewPos = pos - highlightRangeStart; executed 44 times by 1 test: viewPos = pos - highlightRangeStart;Executed by:
| 44 | ||||||||||||||||||||||||||||||
| 980 | if (isContentFlowReversed())
| 2-42 | ||||||||||||||||||||||||||||||
| 981 | viewPos = -viewPos-size(); executed 2 times by 1 test: viewPos = -viewPos-size();Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 982 | timeline.reset(data.move); | - | ||||||||||||||||||||||||||||||
| 983 | if (viewPos != position()) {
| 14-30 | ||||||||||||||||||||||||||||||
| 984 | if (fixupMode != Immediate) {
| 0-14 | ||||||||||||||||||||||||||||||
| 985 | timeline.move(data.move, -viewPos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); | - | ||||||||||||||||||||||||||||||
| 986 | data.fixingUp = true; | - | ||||||||||||||||||||||||||||||
| 987 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 988 | timeline.set(data.move, -viewPos); | - | ||||||||||||||||||||||||||||||
| 989 | } executed 14 times by 1 test: end of blockExecuted by:
| 14 | ||||||||||||||||||||||||||||||
| 990 | } | - | ||||||||||||||||||||||||||||||
| 991 | vTime = timeline.time(); | - | ||||||||||||||||||||||||||||||
| 992 | } executed 44 times by 1 test: end of blockExecuted by:
| 44 | ||||||||||||||||||||||||||||||
| 993 | } else { executed 60 times by 1 test: end of blockExecuted by:
| 60 | ||||||||||||||||||||||||||||||
| 994 | QQuickItemViewPrivate::fixup(data, minExtent, maxExtent); | - | ||||||||||||||||||||||||||||||
| 995 | } executed 9031 times by 4 tests: end of blockExecuted by:
| 9031 | ||||||||||||||||||||||||||||||
| 996 | data.inOvershoot = false; | - | ||||||||||||||||||||||||||||||
| 997 | fixupMode = Normal; | - | ||||||||||||||||||||||||||||||
| 998 | } executed 9338 times by 4 tests: end of blockExecuted by:
| 9338 | ||||||||||||||||||||||||||||||
| 999 | - | |||||||||||||||||||||||||||||||
| 1000 | bool QQuickGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, | - | ||||||||||||||||||||||||||||||
| 1001 | QQuickTimeLineCallback::Callback fixupCallback, qreal velocity) | - | ||||||||||||||||||||||||||||||
| 1002 | { | - | ||||||||||||||||||||||||||||||
| 1003 | data.fixingUp = false; | - | ||||||||||||||||||||||||||||||
| 1004 | moveReason = Mouse; | - | ||||||||||||||||||||||||||||||
| 1005 | if ((!haveHighlightRange || highlightRange != QQuickGridView::StrictlyEnforceRange)
| 0-90 | ||||||||||||||||||||||||||||||
| 1006 | && snapMode == QQuickGridView::NoSnap) {
| 12-78 | ||||||||||||||||||||||||||||||
| 1007 | return QQuickItemViewPrivate::flick(data, minExtent, maxExtent, vSize, fixupCallback, velocity); executed 12 times by 1 test: return QQuickItemViewPrivate::flick(data, minExtent, maxExtent, vSize, fixupCallback, velocity);Executed by:
| 12 | ||||||||||||||||||||||||||||||
| 1008 | } | - | ||||||||||||||||||||||||||||||
| 1009 | qreal maxDistance = 0; | - | ||||||||||||||||||||||||||||||
| 1010 | qreal dataValue = isContentFlowReversed() ? -data.move.value()+size() : data.move.value();
| 56-112 | ||||||||||||||||||||||||||||||
| 1011 | // -ve velocity means list is moving up/left | - | ||||||||||||||||||||||||||||||
| 1012 | if (velocity > 0) {
| 82-86 | ||||||||||||||||||||||||||||||
| 1013 | if (data.move.value() < minExtent) {
| 8-74 | ||||||||||||||||||||||||||||||
| 1014 | if (snapMode == QQuickGridView::SnapOneRow) {
| 30-44 | ||||||||||||||||||||||||||||||
| 1015 | // if we've been dragged < averageSize/2 then bias towards the next item | - | ||||||||||||||||||||||||||||||
| 1016 | qreal dist = data.move.value() - data.pressPos; | - | ||||||||||||||||||||||||||||||
| 1017 | qreal bias = dist < rowSize()/2 ? rowSize()/2 : 0;
| 0-30 | ||||||||||||||||||||||||||||||
| 1018 | if (isContentFlowReversed())
| 10-20 | ||||||||||||||||||||||||||||||
| 1019 | bias = -bias; executed 10 times by 1 test: bias = -bias;Executed by:
| 10 | ||||||||||||||||||||||||||||||
| 1020 | data.flickTarget = -snapPosAt(-dataValue - bias); | - | ||||||||||||||||||||||||||||||
| 1021 | maxDistance = qAbs(data.flickTarget - data.move.value()); | - | ||||||||||||||||||||||||||||||
| 1022 | velocity = maxVelocity; | - | ||||||||||||||||||||||||||||||
| 1023 | } else { executed 30 times by 1 test: end of blockExecuted by:
| 30 | ||||||||||||||||||||||||||||||
| 1024 | maxDistance = qAbs(minExtent - data.move.value()); | - | ||||||||||||||||||||||||||||||
| 1025 | } executed 44 times by 1 test: end of blockExecuted by:
| 44 | ||||||||||||||||||||||||||||||
| 1026 | } | - | ||||||||||||||||||||||||||||||
| 1027 | if (snapMode == QQuickGridView::NoSnap && highlightRange != QQuickGridView::StrictlyEnforceRange)
| 0-82 | ||||||||||||||||||||||||||||||
| 1028 | data.flickTarget = minExtent; never executed: data.flickTarget = minExtent; | 0 | ||||||||||||||||||||||||||||||
| 1029 | } else { executed 82 times by 1 test: end of blockExecuted by:
| 82 | ||||||||||||||||||||||||||||||
| 1030 | if (data.move.value() > maxExtent) {
| 10-76 | ||||||||||||||||||||||||||||||
| 1031 | if (snapMode == QQuickGridView::SnapOneRow) {
| 30-46 | ||||||||||||||||||||||||||||||
| 1032 | // if we've been dragged < averageSize/2 then bias towards the next item | - | ||||||||||||||||||||||||||||||
| 1033 | qreal dist = data.move.value() - data.pressPos; | - | ||||||||||||||||||||||||||||||
| 1034 | qreal bias = -dist < rowSize()/2 ? rowSize()/2 : 0;
| 0-30 | ||||||||||||||||||||||||||||||
| 1035 | if (isContentFlowReversed())
| 10-20 | ||||||||||||||||||||||||||||||
| 1036 | bias = -bias; executed 10 times by 1 test: bias = -bias;Executed by:
| 10 | ||||||||||||||||||||||||||||||
| 1037 | data.flickTarget = -snapPosAt(-dataValue + bias); | - | ||||||||||||||||||||||||||||||
| 1038 | maxDistance = qAbs(data.flickTarget - data.move.value()); | - | ||||||||||||||||||||||||||||||
| 1039 | velocity = -maxVelocity; | - | ||||||||||||||||||||||||||||||
| 1040 | } else { executed 30 times by 1 test: end of blockExecuted by:
| 30 | ||||||||||||||||||||||||||||||
| 1041 | maxDistance = qAbs(maxExtent - data.move.value()); | - | ||||||||||||||||||||||||||||||
| 1042 | } executed 46 times by 1 test: end of blockExecuted by:
| 46 | ||||||||||||||||||||||||||||||
| 1043 | } | - | ||||||||||||||||||||||||||||||
| 1044 | if (snapMode == QQuickGridView::NoSnap && highlightRange != QQuickGridView::StrictlyEnforceRange)
| 0-86 | ||||||||||||||||||||||||||||||
| 1045 | data.flickTarget = maxExtent; never executed: data.flickTarget = maxExtent; | 0 | ||||||||||||||||||||||||||||||
| 1046 | } executed 86 times by 1 test: end of blockExecuted by:
| 86 | ||||||||||||||||||||||||||||||
| 1047 | bool overShoot = boundsBehavior & QQuickFlickable::OvershootBounds; | - | ||||||||||||||||||||||||||||||
| 1048 | if (maxDistance > 0 || overShoot) {
| 0-150 | ||||||||||||||||||||||||||||||
| 1049 | // This mode requires the grid to stop exactly on a row boundary. | - | ||||||||||||||||||||||||||||||
| 1050 | qreal v = velocity; | - | ||||||||||||||||||||||||||||||
| 1051 | if (maxVelocity != -1 && maxVelocity < qAbs(v)) {
| 0-168 | ||||||||||||||||||||||||||||||
| 1052 | if (v < 0)
| 0 | ||||||||||||||||||||||||||||||
| 1053 | v = -maxVelocity; never executed: v = -maxVelocity; | 0 | ||||||||||||||||||||||||||||||
| 1054 | else | - | ||||||||||||||||||||||||||||||
| 1055 | v = maxVelocity; never executed: v = maxVelocity; | 0 | ||||||||||||||||||||||||||||||
| 1056 | } | - | ||||||||||||||||||||||||||||||
| 1057 | qreal accel = deceleration; | - | ||||||||||||||||||||||||||||||
| 1058 | qreal v2 = v * v; | - | ||||||||||||||||||||||||||||||
| 1059 | qreal overshootDist = 0.0; | - | ||||||||||||||||||||||||||||||
| 1060 | if ((maxDistance > 0.0 && v2 / (2.0f * maxDistance) < accel) || snapMode == QQuickGridView::SnapOneRow) {
| 18-150 | ||||||||||||||||||||||||||||||
| 1061 | // + rowSize()/4 to encourage moving at least one item in the flick direction | - | ||||||||||||||||||||||||||||||
| 1062 | qreal dist = v2 / (accel * 2.0) + rowSize()/4; | - | ||||||||||||||||||||||||||||||
| 1063 | dist = qMin(dist, maxDistance); | - | ||||||||||||||||||||||||||||||
| 1064 | if (v > 0)
| 70-74 | ||||||||||||||||||||||||||||||
| 1065 | dist = -dist; executed 70 times by 1 test: dist = -dist;Executed by:
| 70 | ||||||||||||||||||||||||||||||
| 1066 | if (snapMode != QQuickGridView::SnapOneRow) {
| 66-78 | ||||||||||||||||||||||||||||||
| 1067 | qreal distTemp = isContentFlowReversed() ? -dist : dist;
| 26-52 | ||||||||||||||||||||||||||||||
| 1068 | data.flickTarget = -snapPosAt(-dataValue + distTemp); | - | ||||||||||||||||||||||||||||||
| 1069 | } executed 78 times by 1 test: end of blockExecuted by:
| 78 | ||||||||||||||||||||||||||||||
| 1070 | data.flickTarget = isContentFlowReversed() ? -data.flickTarget+size() : data.flickTarget;
| 48-96 | ||||||||||||||||||||||||||||||
| 1071 | if (overShoot) {
| 0-144 | ||||||||||||||||||||||||||||||
| 1072 | if (data.flickTarget >= minExtent) {
| 10-134 | ||||||||||||||||||||||||||||||
| 1073 | overshootDist = overShootDistance(vSize); | - | ||||||||||||||||||||||||||||||
| 1074 | data.flickTarget += overshootDist; | - | ||||||||||||||||||||||||||||||
| 1075 | } else if (data.flickTarget <= maxExtent) { executed 10 times by 1 test: end of blockExecuted by:
| 10-124 | ||||||||||||||||||||||||||||||
| 1076 | overshootDist = overShootDistance(vSize); | - | ||||||||||||||||||||||||||||||
| 1077 | data.flickTarget -= overshootDist; | - | ||||||||||||||||||||||||||||||
| 1078 | } executed 10 times by 1 test: end of blockExecuted by:
| 10 | ||||||||||||||||||||||||||||||
| 1079 | } executed 144 times by 1 test: end of blockExecuted by:
| 144 | ||||||||||||||||||||||||||||||
| 1080 | qreal adjDist = -data.flickTarget + data.move.value(); | - | ||||||||||||||||||||||||||||||
| 1081 | if (qAbs(adjDist) > qAbs(dist)) {
| 22-122 | ||||||||||||||||||||||||||||||
| 1082 | // Prevent painfully slow flicking - adjust velocity to suit flickDeceleration | - | ||||||||||||||||||||||||||||||
| 1083 | qreal adjv2 = accel * 2.0f * qAbs(adjDist); | - | ||||||||||||||||||||||||||||||
| 1084 | if (adjv2 > v2) {
| 10-12 | ||||||||||||||||||||||||||||||
| 1085 | v2 = adjv2; | - | ||||||||||||||||||||||||||||||
| 1086 | v = qSqrt(v2); | - | ||||||||||||||||||||||||||||||
| 1087 | if (dist > 0)
| 4-6 | ||||||||||||||||||||||||||||||
| 1088 | v = -v; executed 4 times by 1 test: v = -v;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 1089 | } executed 10 times by 1 test: end of blockExecuted by:
| 10 | ||||||||||||||||||||||||||||||
| 1090 | } executed 22 times by 1 test: end of blockExecuted by:
| 22 | ||||||||||||||||||||||||||||||
| 1091 | dist = adjDist; | - | ||||||||||||||||||||||||||||||
| 1092 | accel = v2 / (2.0f * qAbs(dist)); | - | ||||||||||||||||||||||||||||||
| 1093 | } else { executed 144 times by 1 test: end of blockExecuted by:
| 144 | ||||||||||||||||||||||||||||||
| 1094 | data.flickTarget = velocity > 0 ? minExtent : maxExtent;
| 12 | ||||||||||||||||||||||||||||||
| 1095 | overshootDist = overShoot ? overShootDistance(vSize) : 0;
| 0-24 | ||||||||||||||||||||||||||||||
| 1096 | } executed 24 times by 1 test: end of blockExecuted by:
| 24 | ||||||||||||||||||||||||||||||
| 1097 | timeline.reset(data.move); | - | ||||||||||||||||||||||||||||||
| 1098 | timeline.accel(data.move, v, accel, maxDistance + overshootDist); | - | ||||||||||||||||||||||||||||||
| 1099 | timeline.callback(QQuickTimeLineCallback(&data.move, fixupCallback, this)); | - | ||||||||||||||||||||||||||||||
| 1100 | return true; executed 168 times by 1 test: return true;Executed by:
| 168 | ||||||||||||||||||||||||||||||
| 1101 | } else { | - | ||||||||||||||||||||||||||||||
| 1102 | timeline.reset(data.move); | - | ||||||||||||||||||||||||||||||
| 1103 | fixup(data, minExtent, maxExtent); | - | ||||||||||||||||||||||||||||||
| 1104 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 1105 | } | - | ||||||||||||||||||||||||||||||
| 1106 | } | - | ||||||||||||||||||||||||||||||
| 1107 | - | |||||||||||||||||||||||||||||||
| 1108 | - | |||||||||||||||||||||||||||||||
| 1109 | //---------------------------------------------------------------------------- | - | ||||||||||||||||||||||||||||||
| 1110 | /*! | - | ||||||||||||||||||||||||||||||
| 1111 | \qmltype GridView | - | ||||||||||||||||||||||||||||||
| 1112 | \instantiates QQuickGridView | - | ||||||||||||||||||||||||||||||
| 1113 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||||||||
| 1114 | \ingroup qtquick-views | - | ||||||||||||||||||||||||||||||
| 1115 | - | |||||||||||||||||||||||||||||||
| 1116 | \inherits Flickable | - | ||||||||||||||||||||||||||||||
| 1117 | \brief For specifying a grid view of items provided by a model. | - | ||||||||||||||||||||||||||||||
| 1118 | - | |||||||||||||||||||||||||||||||
| 1119 | A GridView displays data from models created from built-in QML types like ListModel | - | ||||||||||||||||||||||||||||||
| 1120 | and XmlListModel, or custom model classes defined in C++ that inherit from | - | ||||||||||||||||||||||||||||||
| 1121 | QAbstractListModel. | - | ||||||||||||||||||||||||||||||
| 1122 | - | |||||||||||||||||||||||||||||||
| 1123 | A GridView has a \l model, which defines the data to be displayed, and | - | ||||||||||||||||||||||||||||||
| 1124 | a \l delegate, which defines how the data should be displayed. Items in a | - | ||||||||||||||||||||||||||||||
| 1125 | GridView are laid out horizontally or vertically. Grid views are inherently flickable | - | ||||||||||||||||||||||||||||||
| 1126 | as GridView inherits from \l Flickable. | - | ||||||||||||||||||||||||||||||
| 1127 | - | |||||||||||||||||||||||||||||||
| 1128 | \section1 Example Usage | - | ||||||||||||||||||||||||||||||
| 1129 | - | |||||||||||||||||||||||||||||||
| 1130 | The following example shows the definition of a simple list model defined | - | ||||||||||||||||||||||||||||||
| 1131 | in a file called \c ContactModel.qml: | - | ||||||||||||||||||||||||||||||
| 1132 | - | |||||||||||||||||||||||||||||||
| 1133 | \snippet qml/gridview/ContactModel.qml 0 | - | ||||||||||||||||||||||||||||||
| 1134 | - | |||||||||||||||||||||||||||||||
| 1135 | \div {class="float-right"} | - | ||||||||||||||||||||||||||||||
| 1136 | \inlineimage gridview-simple.png | - | ||||||||||||||||||||||||||||||
| 1137 | \enddiv | - | ||||||||||||||||||||||||||||||
| 1138 | - | |||||||||||||||||||||||||||||||
| 1139 | This model can be referenced as \c ContactModel in other QML files. See \l{QML Modules} | - | ||||||||||||||||||||||||||||||
| 1140 | for more information about creating reusable components like this. | - | ||||||||||||||||||||||||||||||
| 1141 | - | |||||||||||||||||||||||||||||||
| 1142 | Another component can display this model data in a GridView, as in the following | - | ||||||||||||||||||||||||||||||
| 1143 | example, which creates a \c ContactModel component for its model, and a \l Column | - | ||||||||||||||||||||||||||||||
| 1144 | (containing \l Image and \l Text items) for its delegate. | - | ||||||||||||||||||||||||||||||
| 1145 | - | |||||||||||||||||||||||||||||||
| 1146 | \clearfloat | - | ||||||||||||||||||||||||||||||
| 1147 | \snippet qml/gridview/gridview.qml import | - | ||||||||||||||||||||||||||||||
| 1148 | \codeline | - | ||||||||||||||||||||||||||||||
| 1149 | \snippet qml/gridview/gridview.qml classdocs simple | - | ||||||||||||||||||||||||||||||
| 1150 | - | |||||||||||||||||||||||||||||||
| 1151 | \div {class="float-right"} | - | ||||||||||||||||||||||||||||||
| 1152 | \inlineimage gridview-highlight.png | - | ||||||||||||||||||||||||||||||
| 1153 | \enddiv | - | ||||||||||||||||||||||||||||||
| 1154 | - | |||||||||||||||||||||||||||||||
| 1155 | The view will create a new delegate for each item in the model. Note that the delegate | - | ||||||||||||||||||||||||||||||
| 1156 | is able to access the model's \c name and \c portrait data directly. | - | ||||||||||||||||||||||||||||||
| 1157 | - | |||||||||||||||||||||||||||||||
| 1158 | An improved grid view is shown below. The delegate is visually improved and is moved | - | ||||||||||||||||||||||||||||||
| 1159 | into a separate \c contactDelegate component. | - | ||||||||||||||||||||||||||||||
| 1160 | - | |||||||||||||||||||||||||||||||
| 1161 | \clearfloat | - | ||||||||||||||||||||||||||||||
| 1162 | \snippet qml/gridview/gridview.qml classdocs advanced | - | ||||||||||||||||||||||||||||||
| 1163 | - | |||||||||||||||||||||||||||||||
| 1164 | The currently selected item is highlighted with a blue \l Rectangle using the \l highlight property, | - | ||||||||||||||||||||||||||||||
| 1165 | and \c focus is set to \c true to enable keyboard navigation for the grid view. | - | ||||||||||||||||||||||||||||||
| 1166 | The grid view itself is a focus scope (see \l{Keyboard Focus in Qt Quick} for more details). | - | ||||||||||||||||||||||||||||||
| 1167 | - | |||||||||||||||||||||||||||||||
| 1168 | Delegates are instantiated as needed and may be destroyed at any time. | - | ||||||||||||||||||||||||||||||
| 1169 | State should \e never be stored in a delegate. | - | ||||||||||||||||||||||||||||||
| 1170 | - | |||||||||||||||||||||||||||||||
| 1171 | GridView attaches a number of properties to the root item of the delegate, for example | - | ||||||||||||||||||||||||||||||
| 1172 | \c {GridView.isCurrentItem}. In the following example, the root delegate item can access | - | ||||||||||||||||||||||||||||||
| 1173 | this attached property directly as \c GridView.isCurrentItem, while the child | - | ||||||||||||||||||||||||||||||
| 1174 | \c contactInfo object must refer to this property as \c wrapper.GridView.isCurrentItem. | - | ||||||||||||||||||||||||||||||
| 1175 | - | |||||||||||||||||||||||||||||||
| 1176 | \snippet qml/gridview/gridview.qml isCurrentItem | - | ||||||||||||||||||||||||||||||
| 1177 | - | |||||||||||||||||||||||||||||||
| 1178 | \note Views do not set the \l{Item::}{clip} property automatically. | - | ||||||||||||||||||||||||||||||
| 1179 | If the view is not clipped by another item or the screen, it will be necessary | - | ||||||||||||||||||||||||||||||
| 1180 | to set this property to true in order to clip the items that are partially or | - | ||||||||||||||||||||||||||||||
| 1181 | fully outside the view. | - | ||||||||||||||||||||||||||||||
| 1182 | - | |||||||||||||||||||||||||||||||
| 1183 | - | |||||||||||||||||||||||||||||||
| 1184 | \section1 GridView Layouts | - | ||||||||||||||||||||||||||||||
| 1185 | - | |||||||||||||||||||||||||||||||
| 1186 | The layout of the items in a GridView can be controlled by these properties: | - | ||||||||||||||||||||||||||||||
| 1187 | - | |||||||||||||||||||||||||||||||
| 1188 | \list | - | ||||||||||||||||||||||||||||||
| 1189 | \li \l flow - controls whether items flow from left to right (as a series of rows) | - | ||||||||||||||||||||||||||||||
| 1190 | or from top to bottom (as a series of columns). This value can be either | - | ||||||||||||||||||||||||||||||
| 1191 | GridView.FlowLeftToRight or GridView.FlowTopToBottom. | - | ||||||||||||||||||||||||||||||
| 1192 | \li \l layoutDirection - controls the horizontal layout direction: that is, whether items | - | ||||||||||||||||||||||||||||||
| 1193 | are laid out from the left side of the view to the right, or vice-versa. This value can | - | ||||||||||||||||||||||||||||||
| 1194 | be either Qt.LeftToRight or Qt.RightToLeft. | - | ||||||||||||||||||||||||||||||
| 1195 | \li \l verticalLayoutDirection - controls the vertical layout direction: that is, whether items | - | ||||||||||||||||||||||||||||||
| 1196 | are laid out from the top of the view down towards the bottom of the view, or vice-versa. | - | ||||||||||||||||||||||||||||||
| 1197 | This value can be either GridView.TopToBottom or GridView.BottomToTop. | - | ||||||||||||||||||||||||||||||
| 1198 | \endlist | - | ||||||||||||||||||||||||||||||
| 1199 | - | |||||||||||||||||||||||||||||||
| 1200 | By default, a GridView flows from left to right, and items are laid out from left to right | - | ||||||||||||||||||||||||||||||
| 1201 | horizontally, and from top to bottom vertically. | - | ||||||||||||||||||||||||||||||
| 1202 | - | |||||||||||||||||||||||||||||||
| 1203 | These properties can be combined to produce a variety of layouts, as shown in the table below. | - | ||||||||||||||||||||||||||||||
| 1204 | The GridViews in the first row all have a \l flow value of GridView.FlowLeftToRight, but use | - | ||||||||||||||||||||||||||||||
| 1205 | different combinations of horizontal and vertical layout directions (specified by \l layoutDirection | - | ||||||||||||||||||||||||||||||
| 1206 | and \l verticalLayoutDirection respectively). Similarly, the GridViews in the second row below | - | ||||||||||||||||||||||||||||||
| 1207 | all have a \l flow value of GridView.FlowTopToBottom, but use different combinations of horizontal and | - | ||||||||||||||||||||||||||||||
| 1208 | vertical layout directions to lay out their items in different ways. | - | ||||||||||||||||||||||||||||||
| 1209 | - | |||||||||||||||||||||||||||||||
| 1210 | \table | - | ||||||||||||||||||||||||||||||
| 1211 | \header | - | ||||||||||||||||||||||||||||||
| 1212 | \li {4, 1} | - | ||||||||||||||||||||||||||||||
| 1213 | \b GridViews with GridView.FlowLeftToRight flow | - | ||||||||||||||||||||||||||||||
| 1214 | \row | - | ||||||||||||||||||||||||||||||
| 1215 | \li \b (H) Left to right \b (V) Top to bottom | - | ||||||||||||||||||||||||||||||
| 1216 | \image gridview-layout-lefttoright-ltr-ttb.png | - | ||||||||||||||||||||||||||||||
| 1217 | \li \b (H) Right to left \b (V) Top to bottom | - | ||||||||||||||||||||||||||||||
| 1218 | \image gridview-layout-lefttoright-rtl-ttb.png | - | ||||||||||||||||||||||||||||||
| 1219 | \li \b (H) Left to right \b (V) Bottom to top | - | ||||||||||||||||||||||||||||||
| 1220 | \image gridview-layout-lefttoright-ltr-btt.png | - | ||||||||||||||||||||||||||||||
| 1221 | \li \b (H) Right to left \b (V) Bottom to top | - | ||||||||||||||||||||||||||||||
| 1222 | \image gridview-layout-lefttoright-rtl-btt.png | - | ||||||||||||||||||||||||||||||
| 1223 | \header | - | ||||||||||||||||||||||||||||||
| 1224 | \li {4, 1} | - | ||||||||||||||||||||||||||||||
| 1225 | \b GridViews with GridView.FlowTopToBottom flow | - | ||||||||||||||||||||||||||||||
| 1226 | \row | - | ||||||||||||||||||||||||||||||
| 1227 | \li \b (H) Left to right \b (V) Top to bottom | - | ||||||||||||||||||||||||||||||
| 1228 | \image gridview-layout-toptobottom-ltr-ttb.png | - | ||||||||||||||||||||||||||||||
| 1229 | \li \b (H) Right to left \b (V) Top to bottom | - | ||||||||||||||||||||||||||||||
| 1230 | \image gridview-layout-toptobottom-rtl-ttb.png | - | ||||||||||||||||||||||||||||||
| 1231 | \li \b (H) Left to right \b (V) Bottom to top | - | ||||||||||||||||||||||||||||||
| 1232 | \image gridview-layout-toptobottom-ltr-btt.png | - | ||||||||||||||||||||||||||||||
| 1233 | \li \b (H) Right to left \b (V) Bottom to top | - | ||||||||||||||||||||||||||||||
| 1234 | \image gridview-layout-toptobottom-rtl-btt.png | - | ||||||||||||||||||||||||||||||
| 1235 | \endtable | - | ||||||||||||||||||||||||||||||
| 1236 | - | |||||||||||||||||||||||||||||||
| 1237 | \sa {QML Data Models}, ListView, PathView, {Qt Quick Examples - Views} | - | ||||||||||||||||||||||||||||||
| 1238 | */ | - | ||||||||||||||||||||||||||||||
| 1239 | - | |||||||||||||||||||||||||||||||
| 1240 | QQuickGridView::QQuickGridView(QQuickItem *parent) | - | ||||||||||||||||||||||||||||||
| 1241 | : QQuickItemView(*(new QQuickGridViewPrivate), parent) | - | ||||||||||||||||||||||||||||||
| 1242 | { | - | ||||||||||||||||||||||||||||||
| 1243 | } executed 1782 times by 4 tests: end of blockExecuted by:
| 1782 | ||||||||||||||||||||||||||||||
| 1244 | - | |||||||||||||||||||||||||||||||
| 1245 | QQuickGridView::~QQuickGridView() | - | ||||||||||||||||||||||||||||||
| 1246 | { | - | ||||||||||||||||||||||||||||||
| 1247 | } | - | ||||||||||||||||||||||||||||||
| 1248 | - | |||||||||||||||||||||||||||||||
| 1249 | void QQuickGridView::setHighlightFollowsCurrentItem(bool autoHighlight) | - | ||||||||||||||||||||||||||||||
| 1250 | { | - | ||||||||||||||||||||||||||||||
| 1251 | Q_D(QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 1252 | if (d->autoHighlight != autoHighlight) {
| 0-8 | ||||||||||||||||||||||||||||||
| 1253 | if (!autoHighlight && d->highlightXAnimator) {
| 0-8 | ||||||||||||||||||||||||||||||
| 1254 | d->highlightXAnimator->stop(); | - | ||||||||||||||||||||||||||||||
| 1255 | d->highlightYAnimator->stop(); | - | ||||||||||||||||||||||||||||||
| 1256 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 1257 | QQuickItemView::setHighlightFollowsCurrentItem(autoHighlight); | - | ||||||||||||||||||||||||||||||
| 1258 | } executed 8 times by 2 tests: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||||||||
| 1259 | } executed 8 times by 2 tests: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||||||||
| 1260 | - | |||||||||||||||||||||||||||||||
| 1261 | /*! | - | ||||||||||||||||||||||||||||||
| 1262 | \qmlattachedproperty bool QtQuick::GridView::isCurrentItem | - | ||||||||||||||||||||||||||||||
| 1263 | This attached property is true if this delegate is the current item; otherwise false. | - | ||||||||||||||||||||||||||||||
| 1264 | - | |||||||||||||||||||||||||||||||
| 1265 | It is attached to each instance of the delegate. | - | ||||||||||||||||||||||||||||||
| 1266 | */ | - | ||||||||||||||||||||||||||||||
| 1267 | - | |||||||||||||||||||||||||||||||
| 1268 | /*! | - | ||||||||||||||||||||||||||||||
| 1269 | \qmlattachedproperty GridView QtQuick::GridView::view | - | ||||||||||||||||||||||||||||||
| 1270 | This attached property holds the view that manages this delegate instance. | - | ||||||||||||||||||||||||||||||
| 1271 | - | |||||||||||||||||||||||||||||||
| 1272 | It is attached to each instance of the delegate and also to the header, the footer | - | ||||||||||||||||||||||||||||||
| 1273 | and the highlight delegates. | - | ||||||||||||||||||||||||||||||
| 1274 | - | |||||||||||||||||||||||||||||||
| 1275 | \snippet qml/gridview/gridview.qml isCurrentItem | - | ||||||||||||||||||||||||||||||
| 1276 | */ | - | ||||||||||||||||||||||||||||||
| 1277 | - | |||||||||||||||||||||||||||||||
| 1278 | /*! | - | ||||||||||||||||||||||||||||||
| 1279 | \qmlattachedproperty bool QtQuick::GridView::delayRemove | - | ||||||||||||||||||||||||||||||
| 1280 | This attached property holds whether the delegate may be destroyed. It | - | ||||||||||||||||||||||||||||||
| 1281 | is attached to each instance of the delegate. The default value is false. | - | ||||||||||||||||||||||||||||||
| 1282 | - | |||||||||||||||||||||||||||||||
| 1283 | It is sometimes necessary to delay the destruction of an item | - | ||||||||||||||||||||||||||||||
| 1284 | until an animation completes. The example delegate below ensures that the | - | ||||||||||||||||||||||||||||||
| 1285 | animation completes before the item is removed from the list. | - | ||||||||||||||||||||||||||||||
| 1286 | - | |||||||||||||||||||||||||||||||
| 1287 | \snippet qml/gridview/gridview.qml delayRemove | - | ||||||||||||||||||||||||||||||
| 1288 | - | |||||||||||||||||||||||||||||||
| 1289 | If a \l remove transition has been specified, it will not be applied until | - | ||||||||||||||||||||||||||||||
| 1290 | delayRemove is returned to \c false. | - | ||||||||||||||||||||||||||||||
| 1291 | */ | - | ||||||||||||||||||||||||||||||
| 1292 | - | |||||||||||||||||||||||||||||||
| 1293 | /*! | - | ||||||||||||||||||||||||||||||
| 1294 | \qmlattachedsignal QtQuick::GridView::add() | - | ||||||||||||||||||||||||||||||
| 1295 | This attached signal is emitted immediately after an item is added to the view. | - | ||||||||||||||||||||||||||||||
| 1296 | - | |||||||||||||||||||||||||||||||
| 1297 | The corresponding handler is \c onAdd. | - | ||||||||||||||||||||||||||||||
| 1298 | */ | - | ||||||||||||||||||||||||||||||
| 1299 | - | |||||||||||||||||||||||||||||||
| 1300 | /*! | - | ||||||||||||||||||||||||||||||
| 1301 | \qmlattachedsignal QtQuick::GridView::remove() | - | ||||||||||||||||||||||||||||||
| 1302 | This attached signal is emitted immediately before an item is removed from the view. | - | ||||||||||||||||||||||||||||||
| 1303 | - | |||||||||||||||||||||||||||||||
| 1304 | If a \l remove transition has been specified, it is applied after | - | ||||||||||||||||||||||||||||||
| 1305 | this signal is handled, providing that \l delayRemove is false. | - | ||||||||||||||||||||||||||||||
| 1306 | - | |||||||||||||||||||||||||||||||
| 1307 | The corresponding handler is \c onRemove. | - | ||||||||||||||||||||||||||||||
| 1308 | */ | - | ||||||||||||||||||||||||||||||
| 1309 | - | |||||||||||||||||||||||||||||||
| 1310 | - | |||||||||||||||||||||||||||||||
| 1311 | /*! | - | ||||||||||||||||||||||||||||||
| 1312 | \qmlproperty model QtQuick::GridView::model | - | ||||||||||||||||||||||||||||||
| 1313 | This property holds the model providing data for the grid. | - | ||||||||||||||||||||||||||||||
| 1314 | - | |||||||||||||||||||||||||||||||
| 1315 | The model provides the set of data that is used to create the items | - | ||||||||||||||||||||||||||||||
| 1316 | in the view. Models can be created directly in QML using \l ListModel, \l XmlListModel | - | ||||||||||||||||||||||||||||||
| 1317 | or \l VisualItemModel, or provided by C++ model classes. If a C++ model class is | - | ||||||||||||||||||||||||||||||
| 1318 | used, it must be a subclass of \l QAbstractItemModel or a simple list. | - | ||||||||||||||||||||||||||||||
| 1319 | - | |||||||||||||||||||||||||||||||
| 1320 | \sa {qml-data-models}{Data Models} | - | ||||||||||||||||||||||||||||||
| 1321 | */ | - | ||||||||||||||||||||||||||||||
| 1322 | - | |||||||||||||||||||||||||||||||
| 1323 | /*! | - | ||||||||||||||||||||||||||||||
| 1324 | \qmlproperty Component QtQuick::GridView::delegate | - | ||||||||||||||||||||||||||||||
| 1325 | - | |||||||||||||||||||||||||||||||
| 1326 | The delegate provides a template defining each item instantiated by the view. | - | ||||||||||||||||||||||||||||||
| 1327 | The index is exposed as an accessible \c index property. Properties of the | - | ||||||||||||||||||||||||||||||
| 1328 | model are also available depending upon the type of \l {qml-data-models}{Data Model}. | - | ||||||||||||||||||||||||||||||
| 1329 | - | |||||||||||||||||||||||||||||||
| 1330 | The number of objects and bindings in the delegate has a direct effect on the | - | ||||||||||||||||||||||||||||||
| 1331 | flicking performance of the view. If at all possible, place functionality | - | ||||||||||||||||||||||||||||||
| 1332 | that is not needed for the normal display of the delegate in a \l Loader which | - | ||||||||||||||||||||||||||||||
| 1333 | can load additional components when needed. | - | ||||||||||||||||||||||||||||||
| 1334 | - | |||||||||||||||||||||||||||||||
| 1335 | The item size of the GridView is determined by cellHeight and cellWidth. It will not resize the items | - | ||||||||||||||||||||||||||||||
| 1336 | based on the size of the root item in the delegate. | - | ||||||||||||||||||||||||||||||
| 1337 | - | |||||||||||||||||||||||||||||||
| 1338 | The default \l {QQuickItem::z}{stacking order} of delegate instances is \c 1. | - | ||||||||||||||||||||||||||||||
| 1339 | - | |||||||||||||||||||||||||||||||
| 1340 | \note Delegates are instantiated as needed and may be destroyed at any time. | - | ||||||||||||||||||||||||||||||
| 1341 | State should \e never be stored in a delegate. | - | ||||||||||||||||||||||||||||||
| 1342 | */ | - | ||||||||||||||||||||||||||||||
| 1343 | - | |||||||||||||||||||||||||||||||
| 1344 | /*! | - | ||||||||||||||||||||||||||||||
| 1345 | \qmlproperty int QtQuick::GridView::currentIndex | - | ||||||||||||||||||||||||||||||
| 1346 | \qmlproperty Item QtQuick::GridView::currentItem | - | ||||||||||||||||||||||||||||||
| 1347 | - | |||||||||||||||||||||||||||||||
| 1348 | The \c currentIndex property holds the index of the current item, and | - | ||||||||||||||||||||||||||||||
| 1349 | \c currentItem holds the current item. Setting the currentIndex to -1 | - | ||||||||||||||||||||||||||||||
| 1350 | will clear the highlight and set currentItem to null. | - | ||||||||||||||||||||||||||||||
| 1351 | - | |||||||||||||||||||||||||||||||
| 1352 | If highlightFollowsCurrentItem is \c true, setting either of these | - | ||||||||||||||||||||||||||||||
| 1353 | properties will smoothly scroll the GridView so that the current | - | ||||||||||||||||||||||||||||||
| 1354 | item becomes visible. | - | ||||||||||||||||||||||||||||||
| 1355 | - | |||||||||||||||||||||||||||||||
| 1356 | Note that the position of the current item | - | ||||||||||||||||||||||||||||||
| 1357 | may only be approximate until it becomes visible in the view. | - | ||||||||||||||||||||||||||||||
| 1358 | */ | - | ||||||||||||||||||||||||||||||
| 1359 | - | |||||||||||||||||||||||||||||||
| 1360 | - | |||||||||||||||||||||||||||||||
| 1361 | /*! | - | ||||||||||||||||||||||||||||||
| 1362 | \qmlproperty Item QtQuick::GridView::highlightItem | - | ||||||||||||||||||||||||||||||
| 1363 | - | |||||||||||||||||||||||||||||||
| 1364 | This holds the highlight item created from the \l highlight component. | - | ||||||||||||||||||||||||||||||
| 1365 | - | |||||||||||||||||||||||||||||||
| 1366 | The highlightItem is managed by the view unless | - | ||||||||||||||||||||||||||||||
| 1367 | \l highlightFollowsCurrentItem is set to false. | - | ||||||||||||||||||||||||||||||
| 1368 | The default \l {QQuickItem::z}{stacking order} | - | ||||||||||||||||||||||||||||||
| 1369 | of the highlight item is \c 0. | - | ||||||||||||||||||||||||||||||
| 1370 | - | |||||||||||||||||||||||||||||||
| 1371 | \sa highlight, highlightFollowsCurrentItem | - | ||||||||||||||||||||||||||||||
| 1372 | */ | - | ||||||||||||||||||||||||||||||
| 1373 | - | |||||||||||||||||||||||||||||||
| 1374 | - | |||||||||||||||||||||||||||||||
| 1375 | /*! | - | ||||||||||||||||||||||||||||||
| 1376 | \qmlproperty int QtQuick::GridView::count | - | ||||||||||||||||||||||||||||||
| 1377 | This property holds the number of items in the view. | - | ||||||||||||||||||||||||||||||
| 1378 | */ | - | ||||||||||||||||||||||||||||||
| 1379 | - | |||||||||||||||||||||||||||||||
| 1380 | - | |||||||||||||||||||||||||||||||
| 1381 | /*! | - | ||||||||||||||||||||||||||||||
| 1382 | \qmlproperty Component QtQuick::GridView::highlight | - | ||||||||||||||||||||||||||||||
| 1383 | This property holds the component to use as the highlight. | - | ||||||||||||||||||||||||||||||
| 1384 | - | |||||||||||||||||||||||||||||||
| 1385 | An instance of the highlight component is created for each view. | - | ||||||||||||||||||||||||||||||
| 1386 | The geometry of the resulting component instance will be managed by the view | - | ||||||||||||||||||||||||||||||
| 1387 | so as to stay with the current item, unless the highlightFollowsCurrentItem property is false. | - | ||||||||||||||||||||||||||||||
| 1388 | The default \l {QQuickItem::z}{stacking order} of the highlight item is \c 0. | - | ||||||||||||||||||||||||||||||
| 1389 | - | |||||||||||||||||||||||||||||||
| 1390 | \sa highlightItem, highlightFollowsCurrentItem | - | ||||||||||||||||||||||||||||||
| 1391 | */ | - | ||||||||||||||||||||||||||||||
| 1392 | - | |||||||||||||||||||||||||||||||
| 1393 | /*! | - | ||||||||||||||||||||||||||||||
| 1394 | \qmlproperty bool QtQuick::GridView::highlightFollowsCurrentItem | - | ||||||||||||||||||||||||||||||
| 1395 | This property sets whether the highlight is managed by the view. | - | ||||||||||||||||||||||||||||||
| 1396 | - | |||||||||||||||||||||||||||||||
| 1397 | If this property is true (the default value), the highlight is moved smoothly | - | ||||||||||||||||||||||||||||||
| 1398 | to follow the current item. Otherwise, the | - | ||||||||||||||||||||||||||||||
| 1399 | highlight is not moved by the view, and any movement must be implemented | - | ||||||||||||||||||||||||||||||
| 1400 | by the highlight. | - | ||||||||||||||||||||||||||||||
| 1401 | - | |||||||||||||||||||||||||||||||
| 1402 | Here is a highlight with its motion defined by a \l {SpringAnimation} item: | - | ||||||||||||||||||||||||||||||
| 1403 | - | |||||||||||||||||||||||||||||||
| 1404 | \snippet qml/gridview/gridview.qml highlightFollowsCurrentItem | - | ||||||||||||||||||||||||||||||
| 1405 | */ | - | ||||||||||||||||||||||||||||||
| 1406 | - | |||||||||||||||||||||||||||||||
| 1407 | - | |||||||||||||||||||||||||||||||
| 1408 | /*! | - | ||||||||||||||||||||||||||||||
| 1409 | \qmlproperty int QtQuick::GridView::highlightMoveDuration | - | ||||||||||||||||||||||||||||||
| 1410 | This property holds the move animation duration of the highlight delegate. | - | ||||||||||||||||||||||||||||||
| 1411 | - | |||||||||||||||||||||||||||||||
| 1412 | highlightFollowsCurrentItem must be true for this property | - | ||||||||||||||||||||||||||||||
| 1413 | to have effect. | - | ||||||||||||||||||||||||||||||
| 1414 | - | |||||||||||||||||||||||||||||||
| 1415 | The default value for the duration is 150ms. | - | ||||||||||||||||||||||||||||||
| 1416 | - | |||||||||||||||||||||||||||||||
| 1417 | \sa highlightFollowsCurrentItem | - | ||||||||||||||||||||||||||||||
| 1418 | */ | - | ||||||||||||||||||||||||||||||
| 1419 | - | |||||||||||||||||||||||||||||||
| 1420 | /*! | - | ||||||||||||||||||||||||||||||
| 1421 | \qmlproperty real QtQuick::GridView::preferredHighlightBegin | - | ||||||||||||||||||||||||||||||
| 1422 | \qmlproperty real QtQuick::GridView::preferredHighlightEnd | - | ||||||||||||||||||||||||||||||
| 1423 | \qmlproperty enumeration QtQuick::GridView::highlightRangeMode | - | ||||||||||||||||||||||||||||||
| 1424 | - | |||||||||||||||||||||||||||||||
| 1425 | These properties define the preferred range of the highlight (for the current item) | - | ||||||||||||||||||||||||||||||
| 1426 | within the view. The \c preferredHighlightBegin value must be less than the | - | ||||||||||||||||||||||||||||||
| 1427 | \c preferredHighlightEnd value. | - | ||||||||||||||||||||||||||||||
| 1428 | - | |||||||||||||||||||||||||||||||
| 1429 | These properties affect the position of the current item when the view is scrolled. | - | ||||||||||||||||||||||||||||||
| 1430 | For example, if the currently selected item should stay in the middle of the | - | ||||||||||||||||||||||||||||||
| 1431 | view when it is scrolled, set the \c preferredHighlightBegin and | - | ||||||||||||||||||||||||||||||
| 1432 | \c preferredHighlightEnd values to the top and bottom coordinates of where the middle | - | ||||||||||||||||||||||||||||||
| 1433 | item would be. If the \c currentItem is changed programmatically, the view will | - | ||||||||||||||||||||||||||||||
| 1434 | automatically scroll so that the current item is in the middle of the view. | - | ||||||||||||||||||||||||||||||
| 1435 | Furthermore, the behavior of the current item index will occur whether or not a | - | ||||||||||||||||||||||||||||||
| 1436 | highlight exists. | - | ||||||||||||||||||||||||||||||
| 1437 | - | |||||||||||||||||||||||||||||||
| 1438 | Valid values for \c highlightRangeMode are: | - | ||||||||||||||||||||||||||||||
| 1439 | - | |||||||||||||||||||||||||||||||
| 1440 | \list | - | ||||||||||||||||||||||||||||||
| 1441 | \li GridView.ApplyRange - the view attempts to maintain the highlight within the range. | - | ||||||||||||||||||||||||||||||
| 1442 | However, the highlight can move outside of the range at the ends of the view or due | - | ||||||||||||||||||||||||||||||
| 1443 | to mouse interaction. | - | ||||||||||||||||||||||||||||||
| 1444 | \li GridView.StrictlyEnforceRange - the highlight never moves outside of the range. | - | ||||||||||||||||||||||||||||||
| 1445 | The current item changes if a keyboard or mouse action would cause the highlight to move | - | ||||||||||||||||||||||||||||||
| 1446 | outside of the range. | - | ||||||||||||||||||||||||||||||
| 1447 | \li GridView.NoHighlightRange - this is the default value. | - | ||||||||||||||||||||||||||||||
| 1448 | \endlist | - | ||||||||||||||||||||||||||||||
| 1449 | */ | - | ||||||||||||||||||||||||||||||
| 1450 | - | |||||||||||||||||||||||||||||||
| 1451 | - | |||||||||||||||||||||||||||||||
| 1452 | /*! | - | ||||||||||||||||||||||||||||||
| 1453 | \qmlproperty enumeration QtQuick::GridView::layoutDirection | - | ||||||||||||||||||||||||||||||
| 1454 | This property holds the layout direction of the grid. | - | ||||||||||||||||||||||||||||||
| 1455 | - | |||||||||||||||||||||||||||||||
| 1456 | Possible values: | - | ||||||||||||||||||||||||||||||
| 1457 | - | |||||||||||||||||||||||||||||||
| 1458 | \list | - | ||||||||||||||||||||||||||||||
| 1459 | \li Qt.LeftToRight (default) - Items will be laid out starting in the top, left corner. The flow is | - | ||||||||||||||||||||||||||||||
| 1460 | dependent on the \l GridView::flow property. | - | ||||||||||||||||||||||||||||||
| 1461 | \li Qt.RightToLeft - Items will be laid out starting in the top, right corner. The flow is dependent | - | ||||||||||||||||||||||||||||||
| 1462 | on the \l GridView::flow property. | - | ||||||||||||||||||||||||||||||
| 1463 | \endlist | - | ||||||||||||||||||||||||||||||
| 1464 | - | |||||||||||||||||||||||||||||||
| 1465 | \b Note: If GridView::flow is set to GridView.FlowLeftToRight, this is not to be confused if | - | ||||||||||||||||||||||||||||||
| 1466 | GridView::layoutDirection is set to Qt.RightToLeft. The GridView.FlowLeftToRight flow value simply | - | ||||||||||||||||||||||||||||||
| 1467 | indicates that the flow is horizontal. | - | ||||||||||||||||||||||||||||||
| 1468 | - | |||||||||||||||||||||||||||||||
| 1469 | \sa GridView::effectiveLayoutDirection, GridView::verticalLayoutDirection | - | ||||||||||||||||||||||||||||||
| 1470 | */ | - | ||||||||||||||||||||||||||||||
| 1471 | - | |||||||||||||||||||||||||||||||
| 1472 | - | |||||||||||||||||||||||||||||||
| 1473 | /*! | - | ||||||||||||||||||||||||||||||
| 1474 | \qmlproperty enumeration QtQuick::GridView::effectiveLayoutDirection | - | ||||||||||||||||||||||||||||||
| 1475 | This property holds the effective layout direction of the grid. | - | ||||||||||||||||||||||||||||||
| 1476 | - | |||||||||||||||||||||||||||||||
| 1477 | When using the attached property \l {LayoutMirroring::enabled}{LayoutMirroring::enabled} for locale layouts, | - | ||||||||||||||||||||||||||||||
| 1478 | the visual layout direction of the grid will be mirrored. However, the | - | ||||||||||||||||||||||||||||||
| 1479 | property \l {GridView::layoutDirection}{layoutDirection} will remain unchanged. | - | ||||||||||||||||||||||||||||||
| 1480 | - | |||||||||||||||||||||||||||||||
| 1481 | \sa GridView::layoutDirection, {LayoutMirroring}{LayoutMirroring} | - | ||||||||||||||||||||||||||||||
| 1482 | */ | - | ||||||||||||||||||||||||||||||
| 1483 | - | |||||||||||||||||||||||||||||||
| 1484 | /*! | - | ||||||||||||||||||||||||||||||
| 1485 | \qmlproperty enumeration QtQuick::GridView::verticalLayoutDirection | - | ||||||||||||||||||||||||||||||
| 1486 | This property holds the vertical layout direction of the grid. | - | ||||||||||||||||||||||||||||||
| 1487 | - | |||||||||||||||||||||||||||||||
| 1488 | Possible values: | - | ||||||||||||||||||||||||||||||
| 1489 | - | |||||||||||||||||||||||||||||||
| 1490 | \list | - | ||||||||||||||||||||||||||||||
| 1491 | \li GridView.TopToBottom (default) - Items are laid out from the top of the view down to the bottom of the view. | - | ||||||||||||||||||||||||||||||
| 1492 | \li GridView.BottomToTop - Items are laid out from the bottom of the view up to the top of the view. | - | ||||||||||||||||||||||||||||||
| 1493 | \endlist | - | ||||||||||||||||||||||||||||||
| 1494 | - | |||||||||||||||||||||||||||||||
| 1495 | \sa GridView::layoutDirection | - | ||||||||||||||||||||||||||||||
| 1496 | */ | - | ||||||||||||||||||||||||||||||
| 1497 | - | |||||||||||||||||||||||||||||||
| 1498 | /*! | - | ||||||||||||||||||||||||||||||
| 1499 | \qmlproperty bool QtQuick::GridView::keyNavigationWraps | - | ||||||||||||||||||||||||||||||
| 1500 | This property holds whether the grid wraps key navigation | - | ||||||||||||||||||||||||||||||
| 1501 | - | |||||||||||||||||||||||||||||||
| 1502 | If this is true, key navigation that would move the current item selection | - | ||||||||||||||||||||||||||||||
| 1503 | past one end of the view instead wraps around and moves the selection to | - | ||||||||||||||||||||||||||||||
| 1504 | the other end of the view. | - | ||||||||||||||||||||||||||||||
| 1505 | - | |||||||||||||||||||||||||||||||
| 1506 | By default, key navigation is not wrapped. | - | ||||||||||||||||||||||||||||||
| 1507 | */ | - | ||||||||||||||||||||||||||||||
| 1508 | - | |||||||||||||||||||||||||||||||
| 1509 | /*! | - | ||||||||||||||||||||||||||||||
| 1510 | \qmlproperty bool QtQuick::GridView::keyNavigationEnabled | - | ||||||||||||||||||||||||||||||
| 1511 | \since 5.7 | - | ||||||||||||||||||||||||||||||
| 1512 | - | |||||||||||||||||||||||||||||||
| 1513 | This property holds whether the key navigation of the grid is enabled. | - | ||||||||||||||||||||||||||||||
| 1514 | - | |||||||||||||||||||||||||||||||
| 1515 | If this is \c true, the user can navigate the view with a keyboard. | - | ||||||||||||||||||||||||||||||
| 1516 | It is useful for applications that need to selectively enable or | - | ||||||||||||||||||||||||||||||
| 1517 | disable mouse and keyboard interaction. | - | ||||||||||||||||||||||||||||||
| 1518 | - | |||||||||||||||||||||||||||||||
| 1519 | By default, the value of this property is bound to | - | ||||||||||||||||||||||||||||||
| 1520 | \l {Flickable::}{interactive} to ensure behavior compatibility for | - | ||||||||||||||||||||||||||||||
| 1521 | existing applications. When explicitly set, it will cease to be bound to | - | ||||||||||||||||||||||||||||||
| 1522 | the interactive property. | - | ||||||||||||||||||||||||||||||
| 1523 | - | |||||||||||||||||||||||||||||||
| 1524 | \sa {Flickable::}{interactive} | - | ||||||||||||||||||||||||||||||
| 1525 | */ | - | ||||||||||||||||||||||||||||||
| 1526 | - | |||||||||||||||||||||||||||||||
| 1527 | /*! | - | ||||||||||||||||||||||||||||||
| 1528 | \qmlproperty int QtQuick::GridView::cacheBuffer | - | ||||||||||||||||||||||||||||||
| 1529 | This property determines whether delegates are retained outside the | - | ||||||||||||||||||||||||||||||
| 1530 | visible area of the view. | - | ||||||||||||||||||||||||||||||
| 1531 | - | |||||||||||||||||||||||||||||||
| 1532 | If this value is greater than zero, the view may keep as many delegates | - | ||||||||||||||||||||||||||||||
| 1533 | instantiated as will fit within the buffer specified. For example, | - | ||||||||||||||||||||||||||||||
| 1534 | if in a vertical view the delegate is 20 pixels high, there are 3 | - | ||||||||||||||||||||||||||||||
| 1535 | columns and \c cacheBuffer is | - | ||||||||||||||||||||||||||||||
| 1536 | set to 40, then up to 6 delegates above and 6 delegates below the visible | - | ||||||||||||||||||||||||||||||
| 1537 | area may be created/retained. The buffered delegates are created asynchronously, | - | ||||||||||||||||||||||||||||||
| 1538 | allowing creation to occur across multiple frames and reducing the | - | ||||||||||||||||||||||||||||||
| 1539 | likelihood of skipping frames. In order to improve painting performance | - | ||||||||||||||||||||||||||||||
| 1540 | delegates outside the visible area are not painted. | - | ||||||||||||||||||||||||||||||
| 1541 | - | |||||||||||||||||||||||||||||||
| 1542 | The default value of this property is platform dependent, but will usually | - | ||||||||||||||||||||||||||||||
| 1543 | be a value greater than zero. Negative values are ignored. | - | ||||||||||||||||||||||||||||||
| 1544 | - | |||||||||||||||||||||||||||||||
| 1545 | Note that cacheBuffer is not a pixel buffer - it only maintains additional | - | ||||||||||||||||||||||||||||||
| 1546 | instantiated delegates. | - | ||||||||||||||||||||||||||||||
| 1547 | - | |||||||||||||||||||||||||||||||
| 1548 | \note Setting this property is not a replacement for creating efficient delegates. | - | ||||||||||||||||||||||||||||||
| 1549 | It can improve the smoothness of scrolling behavior at the expense of additional | - | ||||||||||||||||||||||||||||||
| 1550 | memory usage. The fewer objects and bindings in a delegate, the faster a | - | ||||||||||||||||||||||||||||||
| 1551 | view can be scrolled. It is important to realize that setting a cacheBuffer | - | ||||||||||||||||||||||||||||||
| 1552 | will only postpone issues caused by slow-loading delegates, it is not a | - | ||||||||||||||||||||||||||||||
| 1553 | solution for this scenario. | - | ||||||||||||||||||||||||||||||
| 1554 | - | |||||||||||||||||||||||||||||||
| 1555 | The cacheBuffer operates outside of any display margins specified by | - | ||||||||||||||||||||||||||||||
| 1556 | displayMarginBeginning or displayMarginEnd. | - | ||||||||||||||||||||||||||||||
| 1557 | */ | - | ||||||||||||||||||||||||||||||
| 1558 | - | |||||||||||||||||||||||||||||||
| 1559 | /*! | - | ||||||||||||||||||||||||||||||
| 1560 | \qmlproperty int QtQuick::GridView::displayMarginBeginning | - | ||||||||||||||||||||||||||||||
| 1561 | \qmlproperty int QtQuick::GridView::displayMarginEnd | - | ||||||||||||||||||||||||||||||
| 1562 | \since QtQuick 2.3 | - | ||||||||||||||||||||||||||||||
| 1563 | - | |||||||||||||||||||||||||||||||
| 1564 | This property allows delegates to be displayed outside of the view geometry. | - | ||||||||||||||||||||||||||||||
| 1565 | - | |||||||||||||||||||||||||||||||
| 1566 | If this value is non-zero, the view will create extra delegates before the | - | ||||||||||||||||||||||||||||||
| 1567 | start of the view, or after the end. The view will create as many delegates | - | ||||||||||||||||||||||||||||||
| 1568 | as it can fit into the pixel size specified. | - | ||||||||||||||||||||||||||||||
| 1569 | - | |||||||||||||||||||||||||||||||
| 1570 | For example, if in a vertical view the delegate is 20 pixels high, | - | ||||||||||||||||||||||||||||||
| 1571 | there are 3 columns, and | - | ||||||||||||||||||||||||||||||
| 1572 | \c displayMarginBeginning and \c displayMarginEnd are both set to 40, | - | ||||||||||||||||||||||||||||||
| 1573 | then 6 delegates above and 6 delegates below will be created and shown. | - | ||||||||||||||||||||||||||||||
| 1574 | - | |||||||||||||||||||||||||||||||
| 1575 | The default value is 0. | - | ||||||||||||||||||||||||||||||
| 1576 | - | |||||||||||||||||||||||||||||||
| 1577 | This property is meant for allowing certain UI configurations, | - | ||||||||||||||||||||||||||||||
| 1578 | and not as a performance optimization. If you wish to create delegates | - | ||||||||||||||||||||||||||||||
| 1579 | outside of the view geometry for performance reasons, you probably | - | ||||||||||||||||||||||||||||||
| 1580 | want to use the cacheBuffer property instead. | - | ||||||||||||||||||||||||||||||
| 1581 | */ | - | ||||||||||||||||||||||||||||||
| 1582 | - | |||||||||||||||||||||||||||||||
| 1583 | void QQuickGridView::setHighlightMoveDuration(int duration) | - | ||||||||||||||||||||||||||||||
| 1584 | { | - | ||||||||||||||||||||||||||||||
| 1585 | Q_D(QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 1586 | if (d->highlightMoveDuration != duration) {
| 0-6 | ||||||||||||||||||||||||||||||
| 1587 | if (d->highlightYAnimator) {
| 2-4 | ||||||||||||||||||||||||||||||
| 1588 | d->highlightXAnimator->userDuration = duration; | - | ||||||||||||||||||||||||||||||
| 1589 | d->highlightYAnimator->userDuration = duration; | - | ||||||||||||||||||||||||||||||
| 1590 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 1591 | QQuickItemView::setHighlightMoveDuration(duration); | - | ||||||||||||||||||||||||||||||
| 1592 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||||||||
| 1593 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||||||||
| 1594 | - | |||||||||||||||||||||||||||||||
| 1595 | /*! | - | ||||||||||||||||||||||||||||||
| 1596 | \qmlproperty enumeration QtQuick::GridView::flow | - | ||||||||||||||||||||||||||||||
| 1597 | This property holds the flow of the grid. | - | ||||||||||||||||||||||||||||||
| 1598 | - | |||||||||||||||||||||||||||||||
| 1599 | Possible values: | - | ||||||||||||||||||||||||||||||
| 1600 | - | |||||||||||||||||||||||||||||||
| 1601 | \list | - | ||||||||||||||||||||||||||||||
| 1602 | \li GridView.FlowLeftToRight (default) - Items are laid out from left to right, and the view scrolls vertically | - | ||||||||||||||||||||||||||||||
| 1603 | \li GridView.FlowTopToBottom - Items are laid out from top to bottom, and the view scrolls horizontally | - | ||||||||||||||||||||||||||||||
| 1604 | \endlist | - | ||||||||||||||||||||||||||||||
| 1605 | */ | - | ||||||||||||||||||||||||||||||
| 1606 | QQuickGridView::Flow QQuickGridView::flow() const | - | ||||||||||||||||||||||||||||||
| 1607 | { | - | ||||||||||||||||||||||||||||||
| 1608 | Q_D(const QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 1609 | return d->flow; executed 1044191 times by 4 tests: return d->flow;Executed by:
| 1044191 | ||||||||||||||||||||||||||||||
| 1610 | } | - | ||||||||||||||||||||||||||||||
| 1611 | - | |||||||||||||||||||||||||||||||
| 1612 | void QQuickGridView::setFlow(Flow flow) | - | ||||||||||||||||||||||||||||||
| 1613 | { | - | ||||||||||||||||||||||||||||||
| 1614 | Q_D(QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 1615 | if (d->flow != flow) {
| 638-666 | ||||||||||||||||||||||||||||||
| 1616 | d->flow = flow; | - | ||||||||||||||||||||||||||||||
| 1617 | if (d->flow == FlowLeftToRight) {
| 16-650 | ||||||||||||||||||||||||||||||
| 1618 | setContentWidth(-1); | - | ||||||||||||||||||||||||||||||
| 1619 | setFlickableDirection(VerticalFlick); | - | ||||||||||||||||||||||||||||||
| 1620 | } else { executed 16 times by 1 test: end of blockExecuted by:
| 16 | ||||||||||||||||||||||||||||||
| 1621 | setContentHeight(-1); | - | ||||||||||||||||||||||||||||||
| 1622 | setFlickableDirection(HorizontalFlick); | - | ||||||||||||||||||||||||||||||
| 1623 | } executed 650 times by 1 test: end of blockExecuted by:
| 650 | ||||||||||||||||||||||||||||||
| 1624 | setContentX(0); | - | ||||||||||||||||||||||||||||||
| 1625 | setContentY(0); | - | ||||||||||||||||||||||||||||||
| 1626 | d->regenerate(true); | - | ||||||||||||||||||||||||||||||
| 1627 | emit flowChanged(); | - | ||||||||||||||||||||||||||||||
| 1628 | } executed 666 times by 1 test: end of blockExecuted by:
| 666 | ||||||||||||||||||||||||||||||
| 1629 | } executed 1304 times by 1 test: end of blockExecuted by:
| 1304 | ||||||||||||||||||||||||||||||
| 1630 | - | |||||||||||||||||||||||||||||||
| 1631 | - | |||||||||||||||||||||||||||||||
| 1632 | /*! | - | ||||||||||||||||||||||||||||||
| 1633 | \qmlproperty real QtQuick::GridView::cellWidth | - | ||||||||||||||||||||||||||||||
| 1634 | \qmlproperty real QtQuick::GridView::cellHeight | - | ||||||||||||||||||||||||||||||
| 1635 | - | |||||||||||||||||||||||||||||||
| 1636 | These properties holds the width and height of each cell in the grid. | - | ||||||||||||||||||||||||||||||
| 1637 | - | |||||||||||||||||||||||||||||||
| 1638 | The default cell size is 100x100. | - | ||||||||||||||||||||||||||||||
| 1639 | */ | - | ||||||||||||||||||||||||||||||
| 1640 | qreal QQuickGridView::cellWidth() const | - | ||||||||||||||||||||||||||||||
| 1641 | { | - | ||||||||||||||||||||||||||||||
| 1642 | Q_D(const QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 1643 | return d->cellWidth; executed 313945 times by 2 tests: return d->cellWidth;Executed by:
| 313945 | ||||||||||||||||||||||||||||||
| 1644 | } | - | ||||||||||||||||||||||||||||||
| 1645 | - | |||||||||||||||||||||||||||||||
| 1646 | void QQuickGridView::setCellWidth(qreal cellWidth) | - | ||||||||||||||||||||||||||||||
| 1647 | { | - | ||||||||||||||||||||||||||||||
| 1648 | Q_D(QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 1649 | if (cellWidth != d->cellWidth && cellWidth > 0) {
| 0-1740 | ||||||||||||||||||||||||||||||
| 1650 | d->cellWidth = qMax(qreal(1), cellWidth); | - | ||||||||||||||||||||||||||||||
| 1651 | d->updateViewport(); | - | ||||||||||||||||||||||||||||||
| 1652 | emit cellWidthChanged(); | - | ||||||||||||||||||||||||||||||
| 1653 | d->forceLayoutPolish(); | - | ||||||||||||||||||||||||||||||
| 1654 | } executed 1740 times by 2 tests: end of blockExecuted by:
| 1740 | ||||||||||||||||||||||||||||||
| 1655 | } executed 1750 times by 2 tests: end of blockExecuted by:
| 1750 | ||||||||||||||||||||||||||||||
| 1656 | - | |||||||||||||||||||||||||||||||
| 1657 | qreal QQuickGridView::cellHeight() const | - | ||||||||||||||||||||||||||||||
| 1658 | { | - | ||||||||||||||||||||||||||||||
| 1659 | Q_D(const QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 1660 | return d->cellHeight; executed 182823 times by 3 tests: return d->cellHeight;Executed by:
| 182823 | ||||||||||||||||||||||||||||||
| 1661 | } | - | ||||||||||||||||||||||||||||||
| 1662 | - | |||||||||||||||||||||||||||||||
| 1663 | void QQuickGridView::setCellHeight(qreal cellHeight) | - | ||||||||||||||||||||||||||||||
| 1664 | { | - | ||||||||||||||||||||||||||||||
| 1665 | Q_D(QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 1666 | if (cellHeight != d->cellHeight && cellHeight > 0) {
| 0-1686 | ||||||||||||||||||||||||||||||
| 1667 | d->cellHeight = qMax(qreal(1), cellHeight); | - | ||||||||||||||||||||||||||||||
| 1668 | d->updateViewport(); | - | ||||||||||||||||||||||||||||||
| 1669 | emit cellHeightChanged(); | - | ||||||||||||||||||||||||||||||
| 1670 | d->forceLayoutPolish(); | - | ||||||||||||||||||||||||||||||
| 1671 | } executed 1686 times by 2 tests: end of blockExecuted by:
| 1686 | ||||||||||||||||||||||||||||||
| 1672 | } executed 1742 times by 2 tests: end of blockExecuted by:
| 1742 | ||||||||||||||||||||||||||||||
| 1673 | /*! | - | ||||||||||||||||||||||||||||||
| 1674 | \qmlproperty enumeration QtQuick::GridView::snapMode | - | ||||||||||||||||||||||||||||||
| 1675 | - | |||||||||||||||||||||||||||||||
| 1676 | This property determines how the view scrolling will settle following a drag or flick. | - | ||||||||||||||||||||||||||||||
| 1677 | The possible values are: | - | ||||||||||||||||||||||||||||||
| 1678 | - | |||||||||||||||||||||||||||||||
| 1679 | \list | - | ||||||||||||||||||||||||||||||
| 1680 | \li GridView.NoSnap (default) - the view stops anywhere within the visible area. | - | ||||||||||||||||||||||||||||||
| 1681 | \li GridView.SnapToRow - the view settles with a row (or column for \c GridView.FlowTopToBottom flow) | - | ||||||||||||||||||||||||||||||
| 1682 | aligned with the start of the view. | - | ||||||||||||||||||||||||||||||
| 1683 | \li GridView.SnapOneRow - the view will settle no more than one row (or column for \c GridView.FlowTopToBottom flow) | - | ||||||||||||||||||||||||||||||
| 1684 | away from the first visible row at the time the mouse button is released. | - | ||||||||||||||||||||||||||||||
| 1685 | This mode is particularly useful for moving one page at a time. | - | ||||||||||||||||||||||||||||||
| 1686 | \endlist | - | ||||||||||||||||||||||||||||||
| 1687 | - | |||||||||||||||||||||||||||||||
| 1688 | */ | - | ||||||||||||||||||||||||||||||
| 1689 | QQuickGridView::SnapMode QQuickGridView::snapMode() const | - | ||||||||||||||||||||||||||||||
| 1690 | { | - | ||||||||||||||||||||||||||||||
| 1691 | Q_D(const QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 1692 | return d->snapMode; executed 2 times by 1 test: return d->snapMode;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 1693 | } | - | ||||||||||||||||||||||||||||||
| 1694 | - | |||||||||||||||||||||||||||||||
| 1695 | void QQuickGridView::setSnapMode(SnapMode mode) | - | ||||||||||||||||||||||||||||||
| 1696 | { | - | ||||||||||||||||||||||||||||||
| 1697 | Q_D(QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 1698 | if (d->snapMode != mode) {
| 0-32 | ||||||||||||||||||||||||||||||
| 1699 | d->snapMode = mode; | - | ||||||||||||||||||||||||||||||
| 1700 | emit snapModeChanged(); | - | ||||||||||||||||||||||||||||||
| 1701 | } executed 32 times by 1 test: end of blockExecuted by:
| 32 | ||||||||||||||||||||||||||||||
| 1702 | } executed 32 times by 1 test: end of blockExecuted by:
| 32 | ||||||||||||||||||||||||||||||
| 1703 | - | |||||||||||||||||||||||||||||||
| 1704 | - | |||||||||||||||||||||||||||||||
| 1705 | /*! | - | ||||||||||||||||||||||||||||||
| 1706 | \qmlproperty Component QtQuick::GridView::footer | - | ||||||||||||||||||||||||||||||
| 1707 | This property holds the component to use as the footer. | - | ||||||||||||||||||||||||||||||
| 1708 | - | |||||||||||||||||||||||||||||||
| 1709 | An instance of the footer component is created for each view. The | - | ||||||||||||||||||||||||||||||
| 1710 | footer is positioned at the end of the view, after any items. The | - | ||||||||||||||||||||||||||||||
| 1711 | default \l {QQuickItem::z}{stacking order} of the footer is \c 1. | - | ||||||||||||||||||||||||||||||
| 1712 | - | |||||||||||||||||||||||||||||||
| 1713 | \sa header, footerItem | - | ||||||||||||||||||||||||||||||
| 1714 | */ | - | ||||||||||||||||||||||||||||||
| 1715 | /*! | - | ||||||||||||||||||||||||||||||
| 1716 | \qmlproperty Component QtQuick::GridView::header | - | ||||||||||||||||||||||||||||||
| 1717 | This property holds the component to use as the header. | - | ||||||||||||||||||||||||||||||
| 1718 | - | |||||||||||||||||||||||||||||||
| 1719 | An instance of the header component is created for each view. The | - | ||||||||||||||||||||||||||||||
| 1720 | header is positioned at the beginning of the view, before any items. | - | ||||||||||||||||||||||||||||||
| 1721 | The default \l {QQuickItem::z}{stacking order} of the header is \c 1. | - | ||||||||||||||||||||||||||||||
| 1722 | - | |||||||||||||||||||||||||||||||
| 1723 | \sa footer, headerItem | - | ||||||||||||||||||||||||||||||
| 1724 | */ | - | ||||||||||||||||||||||||||||||
| 1725 | - | |||||||||||||||||||||||||||||||
| 1726 | /*! | - | ||||||||||||||||||||||||||||||
| 1727 | \qmlproperty Item QtQuick::GridView::headerItem | - | ||||||||||||||||||||||||||||||
| 1728 | This holds the header item created from the \l header component. | - | ||||||||||||||||||||||||||||||
| 1729 | - | |||||||||||||||||||||||||||||||
| 1730 | An instance of the header component is created for each view. The | - | ||||||||||||||||||||||||||||||
| 1731 | header is positioned at the beginning of the view, before any items. | - | ||||||||||||||||||||||||||||||
| 1732 | The default \l {QQuickItem::z}{stacking order} of the header is \c 1. | - | ||||||||||||||||||||||||||||||
| 1733 | - | |||||||||||||||||||||||||||||||
| 1734 | \sa header, footerItem | - | ||||||||||||||||||||||||||||||
| 1735 | */ | - | ||||||||||||||||||||||||||||||
| 1736 | - | |||||||||||||||||||||||||||||||
| 1737 | /*! | - | ||||||||||||||||||||||||||||||
| 1738 | \qmlproperty Item QtQuick::GridView::footerItem | - | ||||||||||||||||||||||||||||||
| 1739 | This holds the footer item created from the \l footer component. | - | ||||||||||||||||||||||||||||||
| 1740 | - | |||||||||||||||||||||||||||||||
| 1741 | An instance of the footer component is created for each view. The | - | ||||||||||||||||||||||||||||||
| 1742 | footer is positioned at the end of the view, after any items. The | - | ||||||||||||||||||||||||||||||
| 1743 | default \l {QQuickItem::z}{stacking order} of the footer is \c 1. | - | ||||||||||||||||||||||||||||||
| 1744 | - | |||||||||||||||||||||||||||||||
| 1745 | \sa footer, headerItem | - | ||||||||||||||||||||||||||||||
| 1746 | */ | - | ||||||||||||||||||||||||||||||
| 1747 | - | |||||||||||||||||||||||||||||||
| 1748 | /*! | - | ||||||||||||||||||||||||||||||
| 1749 | \qmlproperty Transition QtQuick::GridView::populate | - | ||||||||||||||||||||||||||||||
| 1750 | - | |||||||||||||||||||||||||||||||
| 1751 | This property holds the transition to apply to the items that are initially created | - | ||||||||||||||||||||||||||||||
| 1752 | for a view. | - | ||||||||||||||||||||||||||||||
| 1753 | - | |||||||||||||||||||||||||||||||
| 1754 | It is applied to all items that are created when: | - | ||||||||||||||||||||||||||||||
| 1755 | - | |||||||||||||||||||||||||||||||
| 1756 | \list | - | ||||||||||||||||||||||||||||||
| 1757 | \li The view is first created | - | ||||||||||||||||||||||||||||||
| 1758 | \li The view's \l model changes | - | ||||||||||||||||||||||||||||||
| 1759 | \li The view's \l model is \l {QAbstractItemModel::reset()}{reset}, if the model is a QAbstractItemModel subclass | - | ||||||||||||||||||||||||||||||
| 1760 | \endlist | - | ||||||||||||||||||||||||||||||
| 1761 | - | |||||||||||||||||||||||||||||||
| 1762 | For example, here is a view that specifies such a transition: | - | ||||||||||||||||||||||||||||||
| 1763 | - | |||||||||||||||||||||||||||||||
| 1764 | \code | - | ||||||||||||||||||||||||||||||
| 1765 | GridView { | - | ||||||||||||||||||||||||||||||
| 1766 | ... | - | ||||||||||||||||||||||||||||||
| 1767 | populate: Transition { | - | ||||||||||||||||||||||||||||||
| 1768 | NumberAnimation { properties: "x,y"; duration: 1000 } | - | ||||||||||||||||||||||||||||||
| 1769 | } | - | ||||||||||||||||||||||||||||||
| 1770 | } | - | ||||||||||||||||||||||||||||||
| 1771 | \endcode | - | ||||||||||||||||||||||||||||||
| 1772 | - | |||||||||||||||||||||||||||||||
| 1773 | When the view is initialized, the view will create all the necessary items for the view, | - | ||||||||||||||||||||||||||||||
| 1774 | then animate them to their correct positions within the view over one second. | - | ||||||||||||||||||||||||||||||
| 1775 | - | |||||||||||||||||||||||||||||||
| 1776 | For more details and examples on how to use view transitions, see the ViewTransition | - | ||||||||||||||||||||||||||||||
| 1777 | documentation. | - | ||||||||||||||||||||||||||||||
| 1778 | - | |||||||||||||||||||||||||||||||
| 1779 | \sa add, ViewTransition | - | ||||||||||||||||||||||||||||||
| 1780 | */ | - | ||||||||||||||||||||||||||||||
| 1781 | - | |||||||||||||||||||||||||||||||
| 1782 | /*! | - | ||||||||||||||||||||||||||||||
| 1783 | \qmlproperty Transition QtQuick::GridView::add | - | ||||||||||||||||||||||||||||||
| 1784 | - | |||||||||||||||||||||||||||||||
| 1785 | This property holds the transition to apply to items that are added to the view. | - | ||||||||||||||||||||||||||||||
| 1786 | - | |||||||||||||||||||||||||||||||
| 1787 | For example, here is a view that specifies such a transition: | - | ||||||||||||||||||||||||||||||
| 1788 | - | |||||||||||||||||||||||||||||||
| 1789 | \code | - | ||||||||||||||||||||||||||||||
| 1790 | GridView { | - | ||||||||||||||||||||||||||||||
| 1791 | ... | - | ||||||||||||||||||||||||||||||
| 1792 | add: Transition { | - | ||||||||||||||||||||||||||||||
| 1793 | NumberAnimation { properties: "x,y"; from: 100; duration: 1000 } | - | ||||||||||||||||||||||||||||||
| 1794 | } | - | ||||||||||||||||||||||||||||||
| 1795 | } | - | ||||||||||||||||||||||||||||||
| 1796 | \endcode | - | ||||||||||||||||||||||||||||||
| 1797 | - | |||||||||||||||||||||||||||||||
| 1798 | Whenever an item is added to the above view, the item will be animated from the position (100,100) | - | ||||||||||||||||||||||||||||||
| 1799 | to its final x,y position within the view, over one second. The transition only applies to | - | ||||||||||||||||||||||||||||||
| 1800 | the new items that are added to the view; it does not apply to the items below that are | - | ||||||||||||||||||||||||||||||
| 1801 | displaced by the addition of the new items. To animate the displaced items, set the \l displaced | - | ||||||||||||||||||||||||||||||
| 1802 | or \l addDisplaced properties. | - | ||||||||||||||||||||||||||||||
| 1803 | - | |||||||||||||||||||||||||||||||
| 1804 | For more details and examples on how to use view transitions, see the ViewTransition | - | ||||||||||||||||||||||||||||||
| 1805 | documentation. | - | ||||||||||||||||||||||||||||||
| 1806 | - | |||||||||||||||||||||||||||||||
| 1807 | \note This transition is not applied to the items that are created when the view is initially | - | ||||||||||||||||||||||||||||||
| 1808 | populated, or when the view's \l model changes. (In those cases, the \l populate transition is | - | ||||||||||||||||||||||||||||||
| 1809 | applied instead.) Additionally, this transition should \e not animate the height of the new item; | - | ||||||||||||||||||||||||||||||
| 1810 | doing so will cause any items beneath the new item to be laid out at the wrong position. Instead, | - | ||||||||||||||||||||||||||||||
| 1811 | the height can be animated within the \l {add}{onAdd} handler in the delegate. | - | ||||||||||||||||||||||||||||||
| 1812 | - | |||||||||||||||||||||||||||||||
| 1813 | \sa addDisplaced, populate, ViewTransition | - | ||||||||||||||||||||||||||||||
| 1814 | */ | - | ||||||||||||||||||||||||||||||
| 1815 | - | |||||||||||||||||||||||||||||||
| 1816 | /*! | - | ||||||||||||||||||||||||||||||
| 1817 | \qmlproperty Transition QtQuick::GridView::addDisplaced | - | ||||||||||||||||||||||||||||||
| 1818 | - | |||||||||||||||||||||||||||||||
| 1819 | This property holds the transition to apply to items within the view that are displaced by | - | ||||||||||||||||||||||||||||||
| 1820 | the addition of other items to the view. | - | ||||||||||||||||||||||||||||||
| 1821 | - | |||||||||||||||||||||||||||||||
| 1822 | For example, here is a view that specifies such a transition: | - | ||||||||||||||||||||||||||||||
| 1823 | - | |||||||||||||||||||||||||||||||
| 1824 | \code | - | ||||||||||||||||||||||||||||||
| 1825 | GridView { | - | ||||||||||||||||||||||||||||||
| 1826 | ... | - | ||||||||||||||||||||||||||||||
| 1827 | addDisplaced: Transition { | - | ||||||||||||||||||||||||||||||
| 1828 | NumberAnimation { properties: "x,y"; duration: 1000 } | - | ||||||||||||||||||||||||||||||
| 1829 | } | - | ||||||||||||||||||||||||||||||
| 1830 | } | - | ||||||||||||||||||||||||||||||
| 1831 | \endcode | - | ||||||||||||||||||||||||||||||
| 1832 | - | |||||||||||||||||||||||||||||||
| 1833 | Whenever an item is added to the above view, all items beneath the new item are displaced, causing | - | ||||||||||||||||||||||||||||||
| 1834 | them to move down (or sideways, if horizontally orientated) within the view. As this | - | ||||||||||||||||||||||||||||||
| 1835 | displacement occurs, the items' movement to their new x,y positions within the view will be | - | ||||||||||||||||||||||||||||||
| 1836 | animated by a NumberAnimation over one second, as specified. This transition is not applied to | - | ||||||||||||||||||||||||||||||
| 1837 | the new item that has been added to the view; to animate the added items, set the \l add | - | ||||||||||||||||||||||||||||||
| 1838 | property. | - | ||||||||||||||||||||||||||||||
| 1839 | - | |||||||||||||||||||||||||||||||
| 1840 | If an item is displaced by multiple types of operations at the same time, it is not defined as to | - | ||||||||||||||||||||||||||||||
| 1841 | whether the addDisplaced, moveDisplaced or removeDisplaced transition will be applied. Additionally, | - | ||||||||||||||||||||||||||||||
| 1842 | if it is not necessary to specify different transitions depending on whether an item is displaced | - | ||||||||||||||||||||||||||||||
| 1843 | by an add, move or remove operation, consider setting the \l displaced property instead. | - | ||||||||||||||||||||||||||||||
| 1844 | - | |||||||||||||||||||||||||||||||
| 1845 | For more details and examples on how to use view transitions, see the ViewTransition | - | ||||||||||||||||||||||||||||||
| 1846 | documentation. | - | ||||||||||||||||||||||||||||||
| 1847 | - | |||||||||||||||||||||||||||||||
| 1848 | \note This transition is not applied to the items that are created when the view is initially | - | ||||||||||||||||||||||||||||||
| 1849 | populated, or when the view's \l model changes. In those cases, the \l populate transition is | - | ||||||||||||||||||||||||||||||
| 1850 | applied instead. | - | ||||||||||||||||||||||||||||||
| 1851 | - | |||||||||||||||||||||||||||||||
| 1852 | \sa displaced, add, populate, ViewTransition | - | ||||||||||||||||||||||||||||||
| 1853 | */ | - | ||||||||||||||||||||||||||||||
| 1854 | /*! | - | ||||||||||||||||||||||||||||||
| 1855 | \qmlproperty Transition QtQuick::GridView::move | - | ||||||||||||||||||||||||||||||
| 1856 | - | |||||||||||||||||||||||||||||||
| 1857 | This property holds the transition to apply to items in the view that are being moved due | - | ||||||||||||||||||||||||||||||
| 1858 | to a move operation in the view's \l model. | - | ||||||||||||||||||||||||||||||
| 1859 | - | |||||||||||||||||||||||||||||||
| 1860 | For example, here is a view that specifies such a transition: | - | ||||||||||||||||||||||||||||||
| 1861 | - | |||||||||||||||||||||||||||||||
| 1862 | \code | - | ||||||||||||||||||||||||||||||
| 1863 | GridView { | - | ||||||||||||||||||||||||||||||
| 1864 | ... | - | ||||||||||||||||||||||||||||||
| 1865 | move: Transition { | - | ||||||||||||||||||||||||||||||
| 1866 | NumberAnimation { properties: "x,y"; duration: 1000 } | - | ||||||||||||||||||||||||||||||
| 1867 | } | - | ||||||||||||||||||||||||||||||
| 1868 | } | - | ||||||||||||||||||||||||||||||
| 1869 | \endcode | - | ||||||||||||||||||||||||||||||
| 1870 | - | |||||||||||||||||||||||||||||||
| 1871 | Whenever the \l model performs a move operation to move a particular set of indexes, the | - | ||||||||||||||||||||||||||||||
| 1872 | respective items in the view will be animated to their new positions in the view over one | - | ||||||||||||||||||||||||||||||
| 1873 | second. The transition only applies to the items that are the subject of the move operation | - | ||||||||||||||||||||||||||||||
| 1874 | in the model; it does not apply to items below them that are displaced by the move operation. | - | ||||||||||||||||||||||||||||||
| 1875 | To animate the displaced items, set the \l displaced or \l moveDisplaced properties. | - | ||||||||||||||||||||||||||||||
| 1876 | - | |||||||||||||||||||||||||||||||
| 1877 | For more details and examples on how to use view transitions, see the ViewTransition | - | ||||||||||||||||||||||||||||||
| 1878 | documentation. | - | ||||||||||||||||||||||||||||||
| 1879 | - | |||||||||||||||||||||||||||||||
| 1880 | \sa moveDisplaced, ViewTransition | - | ||||||||||||||||||||||||||||||
| 1881 | */ | - | ||||||||||||||||||||||||||||||
| 1882 | - | |||||||||||||||||||||||||||||||
| 1883 | /*! | - | ||||||||||||||||||||||||||||||
| 1884 | \qmlproperty Transition QtQuick::GridView::moveDisplaced | - | ||||||||||||||||||||||||||||||
| 1885 | - | |||||||||||||||||||||||||||||||
| 1886 | This property holds the transition to apply to items that are displaced by a move operation in | - | ||||||||||||||||||||||||||||||
| 1887 | the view's \l model. | - | ||||||||||||||||||||||||||||||
| 1888 | - | |||||||||||||||||||||||||||||||
| 1889 | For example, here is a view that specifies such a transition: | - | ||||||||||||||||||||||||||||||
| 1890 | - | |||||||||||||||||||||||||||||||
| 1891 | \code | - | ||||||||||||||||||||||||||||||
| 1892 | GridView { | - | ||||||||||||||||||||||||||||||
| 1893 | ... | - | ||||||||||||||||||||||||||||||
| 1894 | moveDisplaced: Transition { | - | ||||||||||||||||||||||||||||||
| 1895 | NumberAnimation { properties: "x,y"; duration: 1000 } | - | ||||||||||||||||||||||||||||||
| 1896 | } | - | ||||||||||||||||||||||||||||||
| 1897 | } | - | ||||||||||||||||||||||||||||||
| 1898 | \endcode | - | ||||||||||||||||||||||||||||||
| 1899 | - | |||||||||||||||||||||||||||||||
| 1900 | Whenever the \l model performs a move operation to move a particular set of indexes, the items | - | ||||||||||||||||||||||||||||||
| 1901 | between the source and destination indexes of the move operation are displaced, causing them | - | ||||||||||||||||||||||||||||||
| 1902 | to move upwards or downwards (or sideways, if horizontally orientated) within the view. As this | - | ||||||||||||||||||||||||||||||
| 1903 | displacement occurs, the items' movement to their new x,y positions within the view will be | - | ||||||||||||||||||||||||||||||
| 1904 | animated by a NumberAnimation over one second, as specified. This transition is not applied to | - | ||||||||||||||||||||||||||||||
| 1905 | the items that are the actual subjects of the move operation; to animate the moved items, set | - | ||||||||||||||||||||||||||||||
| 1906 | the \l move property. | - | ||||||||||||||||||||||||||||||
| 1907 | - | |||||||||||||||||||||||||||||||
| 1908 | If an item is displaced by multiple types of operations at the same time, it is not defined as to | - | ||||||||||||||||||||||||||||||
| 1909 | whether the addDisplaced, moveDisplaced or removeDisplaced transition will be applied. Additionally, | - | ||||||||||||||||||||||||||||||
| 1910 | if it is not necessary to specify different transitions depending on whether an item is displaced | - | ||||||||||||||||||||||||||||||
| 1911 | by an add, move or remove operation, consider setting the \l displaced property instead. | - | ||||||||||||||||||||||||||||||
| 1912 | - | |||||||||||||||||||||||||||||||
| 1913 | For more details and examples on how to use view transitions, see the ViewTransition | - | ||||||||||||||||||||||||||||||
| 1914 | documentation. | - | ||||||||||||||||||||||||||||||
| 1915 | - | |||||||||||||||||||||||||||||||
| 1916 | \sa displaced, move, ViewTransition | - | ||||||||||||||||||||||||||||||
| 1917 | */ | - | ||||||||||||||||||||||||||||||
| 1918 | - | |||||||||||||||||||||||||||||||
| 1919 | /*! | - | ||||||||||||||||||||||||||||||
| 1920 | \qmlproperty Transition QtQuick::GridView::remove | - | ||||||||||||||||||||||||||||||
| 1921 | - | |||||||||||||||||||||||||||||||
| 1922 | This property holds the transition to apply to items that are removed from the view. | - | ||||||||||||||||||||||||||||||
| 1923 | - | |||||||||||||||||||||||||||||||
| 1924 | For example, here is a view that specifies such a transition: | - | ||||||||||||||||||||||||||||||
| 1925 | - | |||||||||||||||||||||||||||||||
| 1926 | \code | - | ||||||||||||||||||||||||||||||
| 1927 | GridView { | - | ||||||||||||||||||||||||||||||
| 1928 | ... | - | ||||||||||||||||||||||||||||||
| 1929 | remove: Transition { | - | ||||||||||||||||||||||||||||||
| 1930 | ParallelAnimation { | - | ||||||||||||||||||||||||||||||
| 1931 | NumberAnimation { property: "opacity"; to: 0; duration: 1000 } | - | ||||||||||||||||||||||||||||||
| 1932 | NumberAnimation { properties: "x,y"; to: 100; duration: 1000 } | - | ||||||||||||||||||||||||||||||
| 1933 | } | - | ||||||||||||||||||||||||||||||
| 1934 | } | - | ||||||||||||||||||||||||||||||
| 1935 | } | - | ||||||||||||||||||||||||||||||
| 1936 | \endcode | - | ||||||||||||||||||||||||||||||
| 1937 | - | |||||||||||||||||||||||||||||||
| 1938 | Whenever an item is removed from the above view, the item will be animated to the position (100,100) | - | ||||||||||||||||||||||||||||||
| 1939 | over one second, and in parallel will also change its opacity to 0. The transition | - | ||||||||||||||||||||||||||||||
| 1940 | only applies to the items that are removed from the view; it does not apply to the items below | - | ||||||||||||||||||||||||||||||
| 1941 | them that are displaced by the removal of the items. To animate the displaced items, set the | - | ||||||||||||||||||||||||||||||
| 1942 | \l displaced or \l removeDisplaced properties. | - | ||||||||||||||||||||||||||||||
| 1943 | - | |||||||||||||||||||||||||||||||
| 1944 | Note that by the time the transition is applied, the item has already been removed from the | - | ||||||||||||||||||||||||||||||
| 1945 | model; any references to the model data for the removed index will not be valid. | - | ||||||||||||||||||||||||||||||
| 1946 | - | |||||||||||||||||||||||||||||||
| 1947 | Additionally, if the \l delayRemove attached property has been set for a delegate item, the | - | ||||||||||||||||||||||||||||||
| 1948 | remove transition will not be applied until \l delayRemove becomes false again. | - | ||||||||||||||||||||||||||||||
| 1949 | - | |||||||||||||||||||||||||||||||
| 1950 | For more details and examples on how to use view transitions, see the ViewTransition | - | ||||||||||||||||||||||||||||||
| 1951 | documentation. | - | ||||||||||||||||||||||||||||||
| 1952 | - | |||||||||||||||||||||||||||||||
| 1953 | \sa removeDisplaced, ViewTransition | - | ||||||||||||||||||||||||||||||
| 1954 | */ | - | ||||||||||||||||||||||||||||||
| 1955 | - | |||||||||||||||||||||||||||||||
| 1956 | /*! | - | ||||||||||||||||||||||||||||||
| 1957 | \qmlproperty Transition QtQuick::GridView::removeDisplaced | - | ||||||||||||||||||||||||||||||
| 1958 | - | |||||||||||||||||||||||||||||||
| 1959 | This property holds the transition to apply to items in the view that are displaced by the | - | ||||||||||||||||||||||||||||||
| 1960 | removal of other items in the view. | - | ||||||||||||||||||||||||||||||
| 1961 | - | |||||||||||||||||||||||||||||||
| 1962 | For example, here is a view that specifies such a transition: | - | ||||||||||||||||||||||||||||||
| 1963 | - | |||||||||||||||||||||||||||||||
| 1964 | \code | - | ||||||||||||||||||||||||||||||
| 1965 | GridView { | - | ||||||||||||||||||||||||||||||
| 1966 | ... | - | ||||||||||||||||||||||||||||||
| 1967 | removeDisplaced: Transition { | - | ||||||||||||||||||||||||||||||
| 1968 | NumberAnimation { properties: "x,y"; duration: 1000 } | - | ||||||||||||||||||||||||||||||
| 1969 | } | - | ||||||||||||||||||||||||||||||
| 1970 | } | - | ||||||||||||||||||||||||||||||
| 1971 | \endcode | - | ||||||||||||||||||||||||||||||
| 1972 | - | |||||||||||||||||||||||||||||||
| 1973 | Whenever an item is removed from the above view, all items beneath it are displaced, causing | - | ||||||||||||||||||||||||||||||
| 1974 | them to move upwards (or sideways, if horizontally orientated) within the view. As this | - | ||||||||||||||||||||||||||||||
| 1975 | displacement occurs, the items' movement to their new x,y positions within the view will be | - | ||||||||||||||||||||||||||||||
| 1976 | animated by a NumberAnimation over one second, as specified. This transition is not applied to | - | ||||||||||||||||||||||||||||||
| 1977 | the item that has actually been removed from the view; to animate the removed items, set the | - | ||||||||||||||||||||||||||||||
| 1978 | \l remove property. | - | ||||||||||||||||||||||||||||||
| 1979 | - | |||||||||||||||||||||||||||||||
| 1980 | If an item is displaced by multiple types of operations at the same time, it is not defined as to | - | ||||||||||||||||||||||||||||||
| 1981 | whether the addDisplaced, moveDisplaced or removeDisplaced transition will be applied. Additionally, | - | ||||||||||||||||||||||||||||||
| 1982 | if it is not necessary to specify different transitions depending on whether an item is displaced | - | ||||||||||||||||||||||||||||||
| 1983 | by an add, move or remove operation, consider setting the \l displaced property instead. | - | ||||||||||||||||||||||||||||||
| 1984 | - | |||||||||||||||||||||||||||||||
| 1985 | For more details and examples on how to use view transitions, see the ViewTransition | - | ||||||||||||||||||||||||||||||
| 1986 | documentation. | - | ||||||||||||||||||||||||||||||
| 1987 | - | |||||||||||||||||||||||||||||||
| 1988 | \sa displaced, remove, ViewTransition | - | ||||||||||||||||||||||||||||||
| 1989 | */ | - | ||||||||||||||||||||||||||||||
| 1990 | - | |||||||||||||||||||||||||||||||
| 1991 | /*! | - | ||||||||||||||||||||||||||||||
| 1992 | \qmlproperty Transition QtQuick::GridView::displaced | - | ||||||||||||||||||||||||||||||
| 1993 | This property holds the generic transition to apply to items that have been displaced by | - | ||||||||||||||||||||||||||||||
| 1994 | any model operation that affects the view. | - | ||||||||||||||||||||||||||||||
| 1995 | - | |||||||||||||||||||||||||||||||
| 1996 | This is a convenience for specifying a generic transition for items that are displaced | - | ||||||||||||||||||||||||||||||
| 1997 | by add, move or remove operations, without having to specify the individual addDisplaced, | - | ||||||||||||||||||||||||||||||
| 1998 | moveDisplaced and removeDisplaced properties. For example, here is a view that specifies | - | ||||||||||||||||||||||||||||||
| 1999 | a displaced transition: | - | ||||||||||||||||||||||||||||||
| 2000 | - | |||||||||||||||||||||||||||||||
| 2001 | \code | - | ||||||||||||||||||||||||||||||
| 2002 | GridView { | - | ||||||||||||||||||||||||||||||
| 2003 | ... | - | ||||||||||||||||||||||||||||||
| 2004 | displaced: Transition { | - | ||||||||||||||||||||||||||||||
| 2005 | NumberAnimation { properties: "x,y"; duration: 1000 } | - | ||||||||||||||||||||||||||||||
| 2006 | } | - | ||||||||||||||||||||||||||||||
| 2007 | } | - | ||||||||||||||||||||||||||||||
| 2008 | \endcode | - | ||||||||||||||||||||||||||||||
| 2009 | - | |||||||||||||||||||||||||||||||
| 2010 | When any item is added, moved or removed within the above view, the items below it are | - | ||||||||||||||||||||||||||||||
| 2011 | displaced, causing them to move down (or sideways, if horizontally orientated) within the | - | ||||||||||||||||||||||||||||||
| 2012 | view. As this displacement occurs, the items' movement to their new x,y positions within | - | ||||||||||||||||||||||||||||||
| 2013 | the view will be animated by a NumberAnimation over one second, as specified. | - | ||||||||||||||||||||||||||||||
| 2014 | - | |||||||||||||||||||||||||||||||
| 2015 | If a view specifies this generic displaced transition as well as a specific addDisplaced, | - | ||||||||||||||||||||||||||||||
| 2016 | moveDisplaced or removeDisplaced transition, the more specific transition will be used | - | ||||||||||||||||||||||||||||||
| 2017 | instead of the generic displaced transition when the relevant operation occurs, providing that | - | ||||||||||||||||||||||||||||||
| 2018 | the more specific transition has not been disabled (by setting \l {Transition::enabled}{enabled} | - | ||||||||||||||||||||||||||||||
| 2019 | to false). If it has indeed been disabled, the generic displaced transition is applied instead. | - | ||||||||||||||||||||||||||||||
| 2020 | - | |||||||||||||||||||||||||||||||
| 2021 | For more details and examples on how to use view transitions, see the ViewTransition | - | ||||||||||||||||||||||||||||||
| 2022 | documentation. | - | ||||||||||||||||||||||||||||||
| 2023 | - | |||||||||||||||||||||||||||||||
| 2024 | \sa addDisplaced, moveDisplaced, removeDisplaced, ViewTransition | - | ||||||||||||||||||||||||||||||
| 2025 | */ | - | ||||||||||||||||||||||||||||||
| 2026 | - | |||||||||||||||||||||||||||||||
| 2027 | void QQuickGridView::viewportMoved(Qt::Orientations orient) | - | ||||||||||||||||||||||||||||||
| 2028 | { | - | ||||||||||||||||||||||||||||||
| 2029 | Q_D(QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 2030 | QQuickItemView::viewportMoved(orient); | - | ||||||||||||||||||||||||||||||
| 2031 | if (!d->itemCount)
| 1054-6739 | ||||||||||||||||||||||||||||||
| 2032 | return; executed 1054 times by 1 test: return;Executed by:
| 1054 | ||||||||||||||||||||||||||||||
| 2033 | if (d->inViewportMoved)
| 19-6720 | ||||||||||||||||||||||||||||||
| 2034 | return; executed 19 times by 1 test: return;Executed by:
| 19 | ||||||||||||||||||||||||||||||
| 2035 | d->inViewportMoved = true; | - | ||||||||||||||||||||||||||||||
| 2036 | - | |||||||||||||||||||||||||||||||
| 2037 | if (yflick()) {
| 3105-3615 | ||||||||||||||||||||||||||||||
| 2038 | if (d->isContentFlowReversed())
| 190-2915 | ||||||||||||||||||||||||||||||
| 2039 | d->bufferMode = d->vData.smoothVelocity < 0 ? QQuickItemViewPrivate::BufferAfter : QQuickItemViewPrivate::BufferBefore; executed 190 times by 1 test: d->bufferMode = d->vData.smoothVelocity < 0 ? QQuickItemViewPrivate::BufferAfter : QQuickItemViewPrivate::BufferBefore;Executed by:
| 0-190 | ||||||||||||||||||||||||||||||
| 2040 | else | - | ||||||||||||||||||||||||||||||
| 2041 | d->bufferMode = d->vData.smoothVelocity < 0 ? QQuickItemViewPrivate::BufferBefore : QQuickItemViewPrivate::BufferAfter; executed 2915 times by 1 test: d->bufferMode = d->vData.smoothVelocity < 0 ? QQuickItemViewPrivate::BufferBefore : QQuickItemViewPrivate::BufferAfter;Executed by:
| 1222-2915 | ||||||||||||||||||||||||||||||
| 2042 | } else { | - | ||||||||||||||||||||||||||||||
| 2043 | if (d->isContentFlowReversed())
| 1771-1844 | ||||||||||||||||||||||||||||||
| 2044 | d->bufferMode = d->hData.smoothVelocity < 0 ? QQuickItemViewPrivate::BufferAfter : QQuickItemViewPrivate::BufferBefore; executed 1844 times by 1 test: d->bufferMode = d->hData.smoothVelocity < 0 ? QQuickItemViewPrivate::BufferAfter : QQuickItemViewPrivate::BufferBefore;Executed by:
| 737-1844 | ||||||||||||||||||||||||||||||
| 2045 | else | - | ||||||||||||||||||||||||||||||
| 2046 | d->bufferMode = d->hData.smoothVelocity < 0 ? QQuickItemViewPrivate::BufferBefore : QQuickItemViewPrivate::BufferAfter; executed 1771 times by 1 test: d->bufferMode = d->hData.smoothVelocity < 0 ? QQuickItemViewPrivate::BufferBefore : QQuickItemViewPrivate::BufferAfter;Executed by:
| 766-1771 | ||||||||||||||||||||||||||||||
| 2047 | } | - | ||||||||||||||||||||||||||||||
| 2048 | - | |||||||||||||||||||||||||||||||
| 2049 | d->refillOrLayout(); | - | ||||||||||||||||||||||||||||||
| 2050 | - | |||||||||||||||||||||||||||||||
| 2051 | // Set visibility of items to eliminate cost of items outside the visible area. | - | ||||||||||||||||||||||||||||||
| 2052 | qreal from = d->isContentFlowReversed() ? -d->position()-d->displayMarginBeginning-d->size() : d->position()-d->displayMarginBeginning;
| 2034-4686 | ||||||||||||||||||||||||||||||
| 2053 | qreal to = d->isContentFlowReversed() ? -d->position()+d->displayMarginEnd : d->position()+d->size()+d->displayMarginEnd;
| 2034-4686 | ||||||||||||||||||||||||||||||
| 2054 | for (FxViewItem *item : qAsConst(d->visibleItems)) { | - | ||||||||||||||||||||||||||||||
| 2055 | FxGridItemSG *gridItem = static_cast<FxGridItemSG*>(item); | - | ||||||||||||||||||||||||||||||
| 2056 | QQuickItemPrivate::get(gridItem->item)->setCulled(gridItem->rowPos() + d->rowSize() < from || gridItem->rowPos() > to); | - | ||||||||||||||||||||||||||||||
| 2057 | } executed 142751 times by 1 test: end of blockExecuted by:
| 142751 | ||||||||||||||||||||||||||||||
| 2058 | if (d->currentItem) {
| 0-6720 | ||||||||||||||||||||||||||||||
| 2059 | FxGridItemSG *item = static_cast<FxGridItemSG*>(d->currentItem); | - | ||||||||||||||||||||||||||||||
| 2060 | QQuickItemPrivate::get(item->item)->setCulled(item->rowPos() + d->rowSize() < from || item->rowPos() > to); | - | ||||||||||||||||||||||||||||||
| 2061 | } executed 6720 times by 1 test: end of blockExecuted by:
| 6720 | ||||||||||||||||||||||||||||||
| 2062 | - | |||||||||||||||||||||||||||||||
| 2063 | if (d->hData.flicking || d->vData.flicking || d->hData.moving || d->vData.moving)
| 440-4162 | ||||||||||||||||||||||||||||||
| 2064 | d->moveReason = QQuickGridViewPrivate::Mouse; executed 5080 times by 1 test: d->moveReason = QQuickGridViewPrivate::Mouse;Executed by:
| 5080 | ||||||||||||||||||||||||||||||
| 2065 | if (d->moveReason != QQuickGridViewPrivate::SetIndex) {
| 477-6243 | ||||||||||||||||||||||||||||||
| 2066 | if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) {
| 0-3771 | ||||||||||||||||||||||||||||||
| 2067 | // reposition highlight | - | ||||||||||||||||||||||||||||||
| 2068 | qreal pos = d->highlight->position(); | - | ||||||||||||||||||||||||||||||
| 2069 | qreal viewPos = d->isContentFlowReversed() ? -d->position()-d->size() : d->position();
| 736-1736 | ||||||||||||||||||||||||||||||
| 2070 | if (pos > viewPos + d->highlightRangeEnd - d->highlight->size())
| 1195-1277 | ||||||||||||||||||||||||||||||
| 2071 | pos = viewPos + d->highlightRangeEnd - d->highlight->size(); executed 1277 times by 1 test: pos = viewPos + d->highlightRangeEnd - d->highlight->size();Executed by:
| 1277 | ||||||||||||||||||||||||||||||
| 2072 | if (pos < viewPos + d->highlightRangeStart)
| 1177-1295 | ||||||||||||||||||||||||||||||
| 2073 | pos = viewPos + d->highlightRangeStart; executed 1295 times by 1 test: pos = viewPos + d->highlightRangeStart;Executed by:
| 1295 | ||||||||||||||||||||||||||||||
| 2074 | - | |||||||||||||||||||||||||||||||
| 2075 | if (pos != d->highlight->position()) {
| 26-2446 | ||||||||||||||||||||||||||||||
| 2076 | d->highlightXAnimator->stop(); | - | ||||||||||||||||||||||||||||||
| 2077 | d->highlightYAnimator->stop(); | - | ||||||||||||||||||||||||||||||
| 2078 | static_cast<FxGridItemSG*>(d->highlight)->setPosition(static_cast<FxGridItemSG*>(d->highlight)->colPos(), pos); | - | ||||||||||||||||||||||||||||||
| 2079 | } else { executed 2446 times by 1 test: end of blockExecuted by:
| 2446 | ||||||||||||||||||||||||||||||
| 2080 | d->updateHighlight(); | - | ||||||||||||||||||||||||||||||
| 2081 | } executed 26 times by 1 test: end of blockExecuted by:
| 26 | ||||||||||||||||||||||||||||||
| 2082 | - | |||||||||||||||||||||||||||||||
| 2083 | // update current index | - | ||||||||||||||||||||||||||||||
| 2084 | int idx = d->snapIndex(); | - | ||||||||||||||||||||||||||||||
| 2085 | if (idx >= 0 && idx != d->currentIndex) {
| 0-2472 | ||||||||||||||||||||||||||||||
| 2086 | d->updateCurrent(idx); | - | ||||||||||||||||||||||||||||||
| 2087 | if (d->currentItem && static_cast<FxGridItemSG*>(d->currentItem)->colPos() != static_cast<FxGridItemSG*>(d->highlight)->colPos() && d->autoHighlight) {
| 0-222 | ||||||||||||||||||||||||||||||
| 2088 | if (d->flow == FlowLeftToRight)
| 0 | ||||||||||||||||||||||||||||||
| 2089 | d->highlightXAnimator->to = d->currentItem->itemX(); never executed: d->highlightXAnimator->to = d->currentItem->itemX(); | 0 | ||||||||||||||||||||||||||||||
| 2090 | else | - | ||||||||||||||||||||||||||||||
| 2091 | d->highlightYAnimator->to = d->currentItem->itemY(); never executed: d->highlightYAnimator->to = d->currentItem->itemY(); | 0 | ||||||||||||||||||||||||||||||
| 2092 | } | - | ||||||||||||||||||||||||||||||
| 2093 | } executed 222 times by 1 test: end of blockExecuted by:
| 222 | ||||||||||||||||||||||||||||||
| 2094 | } executed 2472 times by 1 test: end of blockExecuted by:
| 2472 | ||||||||||||||||||||||||||||||
| 2095 | } executed 6243 times by 1 test: end of blockExecuted by:
| 6243 | ||||||||||||||||||||||||||||||
| 2096 | - | |||||||||||||||||||||||||||||||
| 2097 | d->inViewportMoved = false; | - | ||||||||||||||||||||||||||||||
| 2098 | } executed 6720 times by 1 test: end of blockExecuted by:
| 6720 | ||||||||||||||||||||||||||||||
| 2099 | - | |||||||||||||||||||||||||||||||
| 2100 | void QQuickGridView::keyPressEvent(QKeyEvent *event) | - | ||||||||||||||||||||||||||||||
| 2101 | { | - | ||||||||||||||||||||||||||||||
| 2102 | Q_D(QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 2103 | if (d->model && d->model->count() && ((d->interactive && !d->explicitKeyNavigationEnabled)
| 0-6 | ||||||||||||||||||||||||||||||
| 2104 | || (d->explicitKeyNavigationEnabled && d->keyNavigationEnabled))) {
| 2-4 | ||||||||||||||||||||||||||||||
| 2105 | d->moveReason = QQuickGridViewPrivate::SetIndex; | - | ||||||||||||||||||||||||||||||
| 2106 | int oldCurrent = currentIndex(); | - | ||||||||||||||||||||||||||||||
| 2107 | switch (event->key()) { | - | ||||||||||||||||||||||||||||||
| 2108 | case Qt::Key_Up: never executed: case Qt::Key_Up: | 0 | ||||||||||||||||||||||||||||||
| 2109 | moveCurrentIndexUp(); | - | ||||||||||||||||||||||||||||||
| 2110 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 2111 | case Qt::Key_Down: never executed: case Qt::Key_Down: | 0 | ||||||||||||||||||||||||||||||
| 2112 | moveCurrentIndexDown(); | - | ||||||||||||||||||||||||||||||
| 2113 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 2114 | case Qt::Key_Left: never executed: case Qt::Key_Left: | 0 | ||||||||||||||||||||||||||||||
| 2115 | moveCurrentIndexLeft(); | - | ||||||||||||||||||||||||||||||
| 2116 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 2117 | case Qt::Key_Right: executed 2 times by 1 test: case Qt::Key_Right:Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 2118 | moveCurrentIndexRight(); | - | ||||||||||||||||||||||||||||||
| 2119 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 2120 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 2121 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 2122 | } | - | ||||||||||||||||||||||||||||||
| 2123 | if (oldCurrent != currentIndex() || d->wrap) {
| 0-2 | ||||||||||||||||||||||||||||||
| 2124 | event->accept(); | - | ||||||||||||||||||||||||||||||
| 2125 | return; executed 2 times by 1 test: return;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 2126 | } | - | ||||||||||||||||||||||||||||||
| 2127 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2128 | event->ignore(); | - | ||||||||||||||||||||||||||||||
| 2129 | QQuickItemView::keyPressEvent(event); | - | ||||||||||||||||||||||||||||||
| 2130 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||||||||
| 2131 | - | |||||||||||||||||||||||||||||||
| 2132 | void QQuickGridView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | - | ||||||||||||||||||||||||||||||
| 2133 | { | - | ||||||||||||||||||||||||||||||
| 2134 | Q_D(QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 2135 | d->resetColumns(); | - | ||||||||||||||||||||||||||||||
| 2136 | - | |||||||||||||||||||||||||||||||
| 2137 | if (newGeometry.width() != oldGeometry.width()
| 1802-1942 | ||||||||||||||||||||||||||||||
| 2138 | && newGeometry.height() != oldGeometry.height()) {
| 88-1714 | ||||||||||||||||||||||||||||||
| 2139 | d->setPosition(d->position()); | - | ||||||||||||||||||||||||||||||
| 2140 | } else if (newGeometry.width() != oldGeometry.width()) { executed 88 times by 4 tests: end of blockExecuted by:
| 88-1942 | ||||||||||||||||||||||||||||||
| 2141 | QQuickFlickable::setContentX(d->contentXForPosition(d->position())); | - | ||||||||||||||||||||||||||||||
| 2142 | } else if (newGeometry.height() != oldGeometry.height()) { executed 1714 times by 2 tests: end of blockExecuted by:
| 222-1720 | ||||||||||||||||||||||||||||||
| 2143 | QQuickFlickable::setContentY(d->contentYForPosition(d->position())); | - | ||||||||||||||||||||||||||||||
| 2144 | } executed 1720 times by 2 tests: end of blockExecuted by:
| 1720 | ||||||||||||||||||||||||||||||
| 2145 | - | |||||||||||||||||||||||||||||||
| 2146 | QQuickItemView::geometryChanged(newGeometry, oldGeometry); | - | ||||||||||||||||||||||||||||||
| 2147 | } executed 3744 times by 4 tests: end of blockExecuted by:
| 3744 | ||||||||||||||||||||||||||||||
| 2148 | - | |||||||||||||||||||||||||||||||
| 2149 | void QQuickGridView::initItem(int index, QObject *obj) | - | ||||||||||||||||||||||||||||||
| 2150 | { | - | ||||||||||||||||||||||||||||||
| 2151 | QQuickItemView::initItem(index, obj); | - | ||||||||||||||||||||||||||||||
| 2152 | - | |||||||||||||||||||||||||||||||
| 2153 | // setting the view from the FxViewItem wrapper is too late if the delegate | - | ||||||||||||||||||||||||||||||
| 2154 | // needs access to the view in Component.onCompleted | - | ||||||||||||||||||||||||||||||
| 2155 | QQuickItem *item = qmlobject_cast<QQuickItem*>(obj); | - | ||||||||||||||||||||||||||||||
| 2156 | if (item) {
| 0-46119 | ||||||||||||||||||||||||||||||
| 2157 | QQuickGridViewAttached *attached = static_cast<QQuickGridViewAttached *>( | - | ||||||||||||||||||||||||||||||
| 2158 | qmlAttachedPropertiesObject<QQuickGridView>(item)); | - | ||||||||||||||||||||||||||||||
| 2159 | if (attached)
| 0-46119 | ||||||||||||||||||||||||||||||
| 2160 | attached->setView(this); executed 46119 times by 4 tests: attached->setView(this);Executed by:
| 46119 | ||||||||||||||||||||||||||||||
| 2161 | } executed 46119 times by 4 tests: end of blockExecuted by:
| 46119 | ||||||||||||||||||||||||||||||
| 2162 | } executed 46119 times by 4 tests: end of blockExecuted by:
| 46119 | ||||||||||||||||||||||||||||||
| 2163 | - | |||||||||||||||||||||||||||||||
| 2164 | /*! | - | ||||||||||||||||||||||||||||||
| 2165 | \qmlmethod QtQuick::GridView::moveCurrentIndexUp() | - | ||||||||||||||||||||||||||||||
| 2166 | - | |||||||||||||||||||||||||||||||
| 2167 | Move the currentIndex up one item in the view. | - | ||||||||||||||||||||||||||||||
| 2168 | The current index will wrap if keyNavigationWraps is true and it | - | ||||||||||||||||||||||||||||||
| 2169 | is currently at the end. This method has no effect if the \l count is zero. | - | ||||||||||||||||||||||||||||||
| 2170 | - | |||||||||||||||||||||||||||||||
| 2171 | \b Note: methods should only be called after the Component has completed. | - | ||||||||||||||||||||||||||||||
| 2172 | */ | - | ||||||||||||||||||||||||||||||
| 2173 | - | |||||||||||||||||||||||||||||||
| 2174 | - | |||||||||||||||||||||||||||||||
| 2175 | void QQuickGridView::moveCurrentIndexUp() | - | ||||||||||||||||||||||||||||||
| 2176 | { | - | ||||||||||||||||||||||||||||||
| 2177 | Q_D(QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 2178 | const int count = d->model ? d->model->count() : 0;
| 0 | ||||||||||||||||||||||||||||||
| 2179 | if (!count)
| 0 | ||||||||||||||||||||||||||||||
| 2180 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2181 | if (d->verticalLayoutDirection == QQuickItemView::TopToBottom) {
| 0 | ||||||||||||||||||||||||||||||
| 2182 | if (d->flow == QQuickGridView::FlowLeftToRight) {
| 0 | ||||||||||||||||||||||||||||||
| 2183 | if (currentIndex() >= d->columns || d->wrap) {
| 0 | ||||||||||||||||||||||||||||||
| 2184 | int index = currentIndex() - d->columns; | - | ||||||||||||||||||||||||||||||
| 2185 | setCurrentIndex((index >= 0 && index < count) ? index : count-1); | - | ||||||||||||||||||||||||||||||
| 2186 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2187 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2188 | if (currentIndex() > 0 || d->wrap) {
| 0 | ||||||||||||||||||||||||||||||
| 2189 | int index = currentIndex() - 1; | - | ||||||||||||||||||||||||||||||
| 2190 | setCurrentIndex((index >= 0 && index < count) ? index : count-1); | - | ||||||||||||||||||||||||||||||
| 2191 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2192 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2193 | } else { | - | ||||||||||||||||||||||||||||||
| 2194 | if (d->flow == QQuickGridView::FlowLeftToRight) {
| 0 | ||||||||||||||||||||||||||||||
| 2195 | if (currentIndex() < count - d->columns || d->wrap) {
| 0 | ||||||||||||||||||||||||||||||
| 2196 | int index = currentIndex()+d->columns; | - | ||||||||||||||||||||||||||||||
| 2197 | setCurrentIndex((index >= 0 && index < count) ? index : 0); | - | ||||||||||||||||||||||||||||||
| 2198 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2199 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2200 | if (currentIndex() < count - 1 || d->wrap) {
| 0 | ||||||||||||||||||||||||||||||
| 2201 | int index = currentIndex() + 1; | - | ||||||||||||||||||||||||||||||
| 2202 | setCurrentIndex((index >= 0 && index < count) ? index : 0); | - | ||||||||||||||||||||||||||||||
| 2203 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2204 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2205 | } | - | ||||||||||||||||||||||||||||||
| 2206 | } | - | ||||||||||||||||||||||||||||||
| 2207 | - | |||||||||||||||||||||||||||||||
| 2208 | /*! | - | ||||||||||||||||||||||||||||||
| 2209 | \qmlmethod QtQuick::GridView::moveCurrentIndexDown() | - | ||||||||||||||||||||||||||||||
| 2210 | - | |||||||||||||||||||||||||||||||
| 2211 | Move the currentIndex down one item in the view. | - | ||||||||||||||||||||||||||||||
| 2212 | The current index will wrap if keyNavigationWraps is true and it | - | ||||||||||||||||||||||||||||||
| 2213 | is currently at the end. This method has no effect if the \l count is zero. | - | ||||||||||||||||||||||||||||||
| 2214 | - | |||||||||||||||||||||||||||||||
| 2215 | \b Note: methods should only be called after the Component has completed. | - | ||||||||||||||||||||||||||||||
| 2216 | */ | - | ||||||||||||||||||||||||||||||
| 2217 | void QQuickGridView::moveCurrentIndexDown() | - | ||||||||||||||||||||||||||||||
| 2218 | { | - | ||||||||||||||||||||||||||||||
| 2219 | Q_D(QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 2220 | const int count = d->model ? d->model->count() : 0;
| 0-2 | ||||||||||||||||||||||||||||||
| 2221 | if (!count)
| 0-2 | ||||||||||||||||||||||||||||||
| 2222 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2223 | - | |||||||||||||||||||||||||||||||
| 2224 | if (d->verticalLayoutDirection == QQuickItemView::TopToBottom) {
| 0-2 | ||||||||||||||||||||||||||||||
| 2225 | if (d->flow == QQuickGridView::FlowLeftToRight) {
| 0-2 | ||||||||||||||||||||||||||||||
| 2226 | if (currentIndex() < count - d->columns || d->wrap) {
| 0-2 | ||||||||||||||||||||||||||||||
| 2227 | int index = currentIndex()+d->columns; | - | ||||||||||||||||||||||||||||||
| 2228 | setCurrentIndex((index >= 0 && index < count) ? index : 0); | - | ||||||||||||||||||||||||||||||
| 2229 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 2230 | } else { executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 2231 | if (currentIndex() < count - 1 || d->wrap) {
| 0 | ||||||||||||||||||||||||||||||
| 2232 | int index = currentIndex() + 1; | - | ||||||||||||||||||||||||||||||
| 2233 | setCurrentIndex((index >= 0 && index < count) ? index : 0); | - | ||||||||||||||||||||||||||||||
| 2234 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2235 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2236 | } else { | - | ||||||||||||||||||||||||||||||
| 2237 | if (d->flow == QQuickGridView::FlowLeftToRight) {
| 0 | ||||||||||||||||||||||||||||||
| 2238 | if (currentIndex() >= d->columns || d->wrap) {
| 0 | ||||||||||||||||||||||||||||||
| 2239 | int index = currentIndex() - d->columns; | - | ||||||||||||||||||||||||||||||
| 2240 | setCurrentIndex((index >= 0 && index < count) ? index : count-1); | - | ||||||||||||||||||||||||||||||
| 2241 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2242 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2243 | if (currentIndex() > 0 || d->wrap) {
| 0 | ||||||||||||||||||||||||||||||
| 2244 | int index = currentIndex() - 1; | - | ||||||||||||||||||||||||||||||
| 2245 | setCurrentIndex((index >= 0 && index < count) ? index : count-1); | - | ||||||||||||||||||||||||||||||
| 2246 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2247 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2248 | } | - | ||||||||||||||||||||||||||||||
| 2249 | } | - | ||||||||||||||||||||||||||||||
| 2250 | - | |||||||||||||||||||||||||||||||
| 2251 | /*! | - | ||||||||||||||||||||||||||||||
| 2252 | \qmlmethod QtQuick::GridView::moveCurrentIndexLeft() | - | ||||||||||||||||||||||||||||||
| 2253 | - | |||||||||||||||||||||||||||||||
| 2254 | Move the currentIndex left one item in the view. | - | ||||||||||||||||||||||||||||||
| 2255 | The current index will wrap if keyNavigationWraps is true and it | - | ||||||||||||||||||||||||||||||
| 2256 | is currently at the end. This method has no effect if the \l count is zero. | - | ||||||||||||||||||||||||||||||
| 2257 | - | |||||||||||||||||||||||||||||||
| 2258 | \b Note: methods should only be called after the Component has completed. | - | ||||||||||||||||||||||||||||||
| 2259 | */ | - | ||||||||||||||||||||||||||||||
| 2260 | void QQuickGridView::moveCurrentIndexLeft() | - | ||||||||||||||||||||||||||||||
| 2261 | { | - | ||||||||||||||||||||||||||||||
| 2262 | Q_D(QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 2263 | const int count = d->model ? d->model->count() : 0;
| 0 | ||||||||||||||||||||||||||||||
| 2264 | if (!count)
| 0 | ||||||||||||||||||||||||||||||
| 2265 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2266 | if (effectiveLayoutDirection() == Qt::LeftToRight) {
| 0 | ||||||||||||||||||||||||||||||
| 2267 | if (d->flow == QQuickGridView::FlowLeftToRight) {
| 0 | ||||||||||||||||||||||||||||||
| 2268 | if (currentIndex() > 0 || d->wrap) {
| 0 | ||||||||||||||||||||||||||||||
| 2269 | int index = currentIndex() - 1; | - | ||||||||||||||||||||||||||||||
| 2270 | setCurrentIndex((index >= 0 && index < count) ? index : count-1); | - | ||||||||||||||||||||||||||||||
| 2271 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2272 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2273 | if (currentIndex() >= d->columns || d->wrap) {
| 0 | ||||||||||||||||||||||||||||||
| 2274 | int index = currentIndex() - d->columns; | - | ||||||||||||||||||||||||||||||
| 2275 | setCurrentIndex((index >= 0 && index < count) ? index : count-1); | - | ||||||||||||||||||||||||||||||
| 2276 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2277 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2278 | } else { | - | ||||||||||||||||||||||||||||||
| 2279 | if (d->flow == QQuickGridView::FlowLeftToRight) {
| 0 | ||||||||||||||||||||||||||||||
| 2280 | if (currentIndex() < count - 1 || d->wrap) {
| 0 | ||||||||||||||||||||||||||||||
| 2281 | int index = currentIndex() + 1; | - | ||||||||||||||||||||||||||||||
| 2282 | setCurrentIndex((index >= 0 && index < count) ? index : 0); | - | ||||||||||||||||||||||||||||||
| 2283 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2284 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2285 | if (currentIndex() < count - d->columns || d->wrap) {
| 0 | ||||||||||||||||||||||||||||||
| 2286 | int index = currentIndex() + d->columns; | - | ||||||||||||||||||||||||||||||
| 2287 | setCurrentIndex((index >= 0 && index < count) ? index : 0); | - | ||||||||||||||||||||||||||||||
| 2288 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2289 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2290 | } | - | ||||||||||||||||||||||||||||||
| 2291 | } | - | ||||||||||||||||||||||||||||||
| 2292 | - | |||||||||||||||||||||||||||||||
| 2293 | - | |||||||||||||||||||||||||||||||
| 2294 | /*! | - | ||||||||||||||||||||||||||||||
| 2295 | \qmlmethod QtQuick::GridView::moveCurrentIndexRight() | - | ||||||||||||||||||||||||||||||
| 2296 | - | |||||||||||||||||||||||||||||||
| 2297 | Move the currentIndex right one item in the view. | - | ||||||||||||||||||||||||||||||
| 2298 | The current index will wrap if keyNavigationWraps is true and it | - | ||||||||||||||||||||||||||||||
| 2299 | is currently at the end. This method has no effect if the \l count is zero. | - | ||||||||||||||||||||||||||||||
| 2300 | - | |||||||||||||||||||||||||||||||
| 2301 | \b Note: methods should only be called after the Component has completed. | - | ||||||||||||||||||||||||||||||
| 2302 | */ | - | ||||||||||||||||||||||||||||||
| 2303 | void QQuickGridView::moveCurrentIndexRight() | - | ||||||||||||||||||||||||||||||
| 2304 | { | - | ||||||||||||||||||||||||||||||
| 2305 | Q_D(QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 2306 | const int count = d->model ? d->model->count() : 0;
| 0-2 | ||||||||||||||||||||||||||||||
| 2307 | if (!count)
| 0-2 | ||||||||||||||||||||||||||||||
| 2308 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2309 | if (effectiveLayoutDirection() == Qt::LeftToRight) {
| 0-2 | ||||||||||||||||||||||||||||||
| 2310 | if (d->flow == QQuickGridView::FlowLeftToRight) {
| 0-2 | ||||||||||||||||||||||||||||||
| 2311 | if (currentIndex() < count - 1 || d->wrap) {
| 0-2 | ||||||||||||||||||||||||||||||
| 2312 | int index = currentIndex() + 1; | - | ||||||||||||||||||||||||||||||
| 2313 | setCurrentIndex((index >= 0 && index < count) ? index : 0); | - | ||||||||||||||||||||||||||||||
| 2314 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 2315 | } else { executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 2316 | if (currentIndex() < count - d->columns || d->wrap) {
| 0 | ||||||||||||||||||||||||||||||
| 2317 | int index = currentIndex()+d->columns; | - | ||||||||||||||||||||||||||||||
| 2318 | setCurrentIndex((index >= 0 && index < count) ? index : 0); | - | ||||||||||||||||||||||||||||||
| 2319 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2320 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2321 | } else { | - | ||||||||||||||||||||||||||||||
| 2322 | if (d->flow == QQuickGridView::FlowLeftToRight) {
| 0 | ||||||||||||||||||||||||||||||
| 2323 | if (currentIndex() > 0 || d->wrap) {
| 0 | ||||||||||||||||||||||||||||||
| 2324 | int index = currentIndex() - 1; | - | ||||||||||||||||||||||||||||||
| 2325 | setCurrentIndex((index >= 0 && index < count) ? index : count-1); | - | ||||||||||||||||||||||||||||||
| 2326 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2327 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2328 | if (currentIndex() >= d->columns || d->wrap) {
| 0 | ||||||||||||||||||||||||||||||
| 2329 | int index = currentIndex() - d->columns; | - | ||||||||||||||||||||||||||||||
| 2330 | setCurrentIndex((index >= 0 && index < count) ? index : count-1); | - | ||||||||||||||||||||||||||||||
| 2331 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2332 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2333 | } | - | ||||||||||||||||||||||||||||||
| 2334 | } | - | ||||||||||||||||||||||||||||||
| 2335 | - | |||||||||||||||||||||||||||||||
| 2336 | bool QQuickGridViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &change, ChangeResult *insertResult, QList<FxViewItem *> *addedItems, QList<MovedItem> *movingIntoView) | - | ||||||||||||||||||||||||||||||
| 2337 | { | - | ||||||||||||||||||||||||||||||
| 2338 | Q_Q(QQuickGridView); | - | ||||||||||||||||||||||||||||||
| 2339 | - | |||||||||||||||||||||||||||||||
| 2340 | int modelIndex = change.index; | - | ||||||||||||||||||||||||||||||
| 2341 | int count = change.count; | - | ||||||||||||||||||||||||||||||
| 2342 | - | |||||||||||||||||||||||||||||||
| 2343 | int index = visibleItems.count() ? mapFromModel(modelIndex) : 0;
| 102-1158 | ||||||||||||||||||||||||||||||
| 2344 | - | |||||||||||||||||||||||||||||||
| 2345 | if (index < 0) {
| 228-1032 | ||||||||||||||||||||||||||||||
| 2346 | int i = visibleItems.count() - 1; | - | ||||||||||||||||||||||||||||||
| 2347 | while (i > 0 && visibleItems.at(i)->index == -1)
| 0-220 | ||||||||||||||||||||||||||||||
| 2348 | --i; never executed: --i; | 0 | ||||||||||||||||||||||||||||||
| 2349 | if (visibleItems.at(i)->index + 1 == modelIndex) {
| 61-167 | ||||||||||||||||||||||||||||||
| 2350 | // Special case of appending an item to the model. | - | ||||||||||||||||||||||||||||||
| 2351 | index = visibleItems.count(); | - | ||||||||||||||||||||||||||||||
| 2352 | } else { executed 61 times by 1 test: end of blockExecuted by:
| 61 | ||||||||||||||||||||||||||||||
| 2353 | if (modelIndex <= visibleIndex) {
| 83-84 | ||||||||||||||||||||||||||||||
| 2354 | // Insert before visible items | - | ||||||||||||||||||||||||||||||
| 2355 | visibleIndex += count; | - | ||||||||||||||||||||||||||||||
| 2356 | for (FxViewItem *item : qAsConst(visibleItems)) { | - | ||||||||||||||||||||||||||||||
| 2357 | if (item->index != -1 && item->index >= modelIndex)
| 0-1786 | ||||||||||||||||||||||||||||||
| 2358 | item->index += count; executed 1786 times by 1 test: item->index += count;Executed by:
| 1786 | ||||||||||||||||||||||||||||||
| 2359 | } executed 1786 times by 1 test: end of blockExecuted by:
| 1786 | ||||||||||||||||||||||||||||||
| 2360 | } executed 84 times by 1 test: end of blockExecuted by:
| 84 | ||||||||||||||||||||||||||||||
| 2361 | return true; executed 167 times by 1 test: return true;Executed by:
| 167 | ||||||||||||||||||||||||||||||
| 2362 | } | - | ||||||||||||||||||||||||||||||
| 2363 | } | - | ||||||||||||||||||||||||||||||
| 2364 | - | |||||||||||||||||||||||||||||||
| 2365 | qreal tempPos = isContentFlowReversed() ? -position()-size()+q->width()+1 : position();
| 320-773 | ||||||||||||||||||||||||||||||
| 2366 | qreal colPos = 0; | - | ||||||||||||||||||||||||||||||
| 2367 | qreal rowPos = 0; | - | ||||||||||||||||||||||||||||||
| 2368 | int colNum = 0; | - | ||||||||||||||||||||||||||||||
| 2369 | if (visibleItems.count()) {
| 102-991 | ||||||||||||||||||||||||||||||
| 2370 | if (index < visibleItems.count()) {
| 61-930 | ||||||||||||||||||||||||||||||
| 2371 | FxGridItemSG *gridItem = static_cast<FxGridItemSG*>(visibleItems.at(index)); | - | ||||||||||||||||||||||||||||||
| 2372 | colPos = gridItem->colPos(); | - | ||||||||||||||||||||||||||||||
| 2373 | rowPos = gridItem->rowPos(); | - | ||||||||||||||||||||||||||||||
| 2374 | colNum = qFloor((colPos+colSize()/2) / colSize()); | - | ||||||||||||||||||||||||||||||
| 2375 | } else { executed 930 times by 1 test: end of blockExecuted by:
| 930 | ||||||||||||||||||||||||||||||
| 2376 | // appending items to visible list | - | ||||||||||||||||||||||||||||||
| 2377 | FxGridItemSG *gridItem = static_cast<FxGridItemSG*>(visibleItems.at(index-1)); | - | ||||||||||||||||||||||||||||||
| 2378 | rowPos = gridItem->rowPos(); | - | ||||||||||||||||||||||||||||||
| 2379 | colNum = qFloor((gridItem->colPos()+colSize()/2) / colSize()); | - | ||||||||||||||||||||||||||||||
| 2380 | if (++colNum >= columns) {
| 0-61 | ||||||||||||||||||||||||||||||
| 2381 | colNum = 0; | - | ||||||||||||||||||||||||||||||
| 2382 | rowPos += rowSize(); | - | ||||||||||||||||||||||||||||||
| 2383 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2384 | colPos = colNum * colSize(); | - | ||||||||||||||||||||||||||||||
| 2385 | } executed 61 times by 1 test: end of blockExecuted by:
| 61 | ||||||||||||||||||||||||||||||
| 2386 | } | - | ||||||||||||||||||||||||||||||
| 2387 | - | |||||||||||||||||||||||||||||||
| 2388 | // Update the indexes of the following visible items. | - | ||||||||||||||||||||||||||||||
| 2389 | for (FxViewItem *item : qAsConst(visibleItems)) { | - | ||||||||||||||||||||||||||||||
| 2390 | if (item->index != -1 && item->index >= modelIndex) {
| 0-17794 | ||||||||||||||||||||||||||||||
| 2391 | item->index += count; | - | ||||||||||||||||||||||||||||||
| 2392 | if (change.isMove())
| 5262-5440 | ||||||||||||||||||||||||||||||
| 2393 | item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::MoveTransition, false); executed 5262 times by 1 test: item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::MoveTransition, false);Executed by:
| 5262 | ||||||||||||||||||||||||||||||
| 2394 | else | - | ||||||||||||||||||||||||||||||
| 2395 | item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, false); executed 5440 times by 1 test: item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, false);Executed by:
| 5440 | ||||||||||||||||||||||||||||||
| 2396 | } | - | ||||||||||||||||||||||||||||||
| 2397 | } executed 17794 times by 1 test: end of blockExecuted by:
| 17794 | ||||||||||||||||||||||||||||||
| 2398 | - | |||||||||||||||||||||||||||||||
| 2399 | int prevVisibleCount = visibleItems.count(); | - | ||||||||||||||||||||||||||||||
| 2400 | if (insertResult->visiblePos.isValid() && rowPos < insertResult->visiblePos) {
| 96-995 | ||||||||||||||||||||||||||||||
| 2401 | // Insert items before the visible item. | - | ||||||||||||||||||||||||||||||
| 2402 | int insertionIdx = index; | - | ||||||||||||||||||||||||||||||
| 2403 | int i = count - 1; | - | ||||||||||||||||||||||||||||||
| 2404 | int from = tempPos - buffer - displayMarginBeginning; | - | ||||||||||||||||||||||||||||||
| 2405 | - | |||||||||||||||||||||||||||||||
| 2406 | if (rowPos > from && insertionIdx < visibleIndex) {
| 2-83 | ||||||||||||||||||||||||||||||
| 2407 | // items won't be visible, just note the size for repositioning | - | ||||||||||||||||||||||||||||||
| 2408 | insertResult->countChangeBeforeVisible += count; | - | ||||||||||||||||||||||||||||||
| 2409 | insertResult->sizeChangesBeforeVisiblePos += ((count + columns - 1) / columns) * rowSize(); | - | ||||||||||||||||||||||||||||||
| 2410 | } else { executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 2411 | while (i >= 0) {
| 94-371 | ||||||||||||||||||||||||||||||
| 2412 | // item is before first visible e.g. in cache buffer | - | ||||||||||||||||||||||||||||||
| 2413 | FxViewItem *item = nullptr; | - | ||||||||||||||||||||||||||||||
| 2414 | if (change.isMove() && (item = currentChanges.removedItems.take(change.moveKey(modelIndex + i))))
| 0-369 | ||||||||||||||||||||||||||||||
| 2415 | item->index = modelIndex + i; never executed: item->index = modelIndex + i; | 0 | ||||||||||||||||||||||||||||||
| 2416 | if (!item)
| 0-371 | ||||||||||||||||||||||||||||||
| 2417 | item = createItem(modelIndex + i, QQmlIncubator::Synchronous); executed 371 times by 1 test: item = createItem(modelIndex + i, QQmlIncubator::Synchronous);Executed by:
| 371 | ||||||||||||||||||||||||||||||
| 2418 | if (!item)
| 0-371 | ||||||||||||||||||||||||||||||
| 2419 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 2420 | - | |||||||||||||||||||||||||||||||
| 2421 | QQuickItemPrivate::get(item->item)->setCulled(false); | - | ||||||||||||||||||||||||||||||
| 2422 | visibleItems.insert(insertionIdx, item); | - | ||||||||||||||||||||||||||||||
| 2423 | if (insertionIdx == 0)
| 15-356 | ||||||||||||||||||||||||||||||
| 2424 | insertResult->changedFirstItem = true; executed 15 times by 1 test: insertResult->changedFirstItem = true;Executed by:
| 15 | ||||||||||||||||||||||||||||||
| 2425 | if (!change.isMove()) {
| 2-369 | ||||||||||||||||||||||||||||||
| 2426 | addedItems->append(item); | - | ||||||||||||||||||||||||||||||
| 2427 | if (transitioner)
| 0-369 | ||||||||||||||||||||||||||||||
| 2428 | item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, true); never executed: item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, true); | 0 | ||||||||||||||||||||||||||||||
| 2429 | else | - | ||||||||||||||||||||||||||||||
| 2430 | item->moveTo(QPointF(colPos, rowPos), true); executed 369 times by 1 test: item->moveTo(QPointF(colPos, rowPos), true);Executed by:
| 369 | ||||||||||||||||||||||||||||||
| 2431 | } | - | ||||||||||||||||||||||||||||||
| 2432 | insertResult->sizeChangesBeforeVisiblePos += rowSize(); | - | ||||||||||||||||||||||||||||||
| 2433 | - | |||||||||||||||||||||||||||||||
| 2434 | if (--colNum < 0 ) {
| 76-295 | ||||||||||||||||||||||||||||||
| 2435 | colNum = columns - 1; | - | ||||||||||||||||||||||||||||||
| 2436 | rowPos -= rowSize(); | - | ||||||||||||||||||||||||||||||
| 2437 | } executed 76 times by 1 test: end of blockExecuted by:
| 76 | ||||||||||||||||||||||||||||||
| 2438 | colPos = colNum * colSize(); | - | ||||||||||||||||||||||||||||||
| 2439 | index++; | - | ||||||||||||||||||||||||||||||
| 2440 | i--; | - | ||||||||||||||||||||||||||||||
| 2441 | } executed 371 times by 1 test: end of blockExecuted by:
| 371 | ||||||||||||||||||||||||||||||
| 2442 | } executed 94 times by 1 test: end of blockExecuted by:
| 94 | ||||||||||||||||||||||||||||||
| 2443 | - | |||||||||||||||||||||||||||||||
| 2444 | // There may be gaps in the index sequence of visibleItems because | - | ||||||||||||||||||||||||||||||
| 2445 | // of the index shift/update done before the insertion just above. | - | ||||||||||||||||||||||||||||||
| 2446 | // Find if there is any... | - | ||||||||||||||||||||||||||||||
| 2447 | int firstOkIdx = -1; | - | ||||||||||||||||||||||||||||||
| 2448 | for (int i = 0; i <= insertionIdx && i < visibleItems.count() - 1; i++) {
| 0-351 | ||||||||||||||||||||||||||||||
| 2449 | if (visibleItems.at(i)->index + 1 != visibleItems.at(i + 1)->index) {
| 1-350 | ||||||||||||||||||||||||||||||
| 2450 | firstOkIdx = i + 1; | - | ||||||||||||||||||||||||||||||
| 2451 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 2452 | } | - | ||||||||||||||||||||||||||||||
| 2453 | } executed 350 times by 1 test: end of blockExecuted by:
| 350 | ||||||||||||||||||||||||||||||
| 2454 | // ... and remove all the items before that one | - | ||||||||||||||||||||||||||||||
| 2455 | for (int i = 0; i < firstOkIdx; i++) {
| 1-96 | ||||||||||||||||||||||||||||||
| 2456 | FxViewItem *nvItem = visibleItems.takeFirst(); | - | ||||||||||||||||||||||||||||||
| 2457 | addedItems->removeOne(nvItem); | - | ||||||||||||||||||||||||||||||
| 2458 | removeItem(nvItem); | - | ||||||||||||||||||||||||||||||
| 2459 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||||||||
| 2460 | - | |||||||||||||||||||||||||||||||
| 2461 | } else { executed 96 times by 1 test: end of blockExecuted by:
| 96 | ||||||||||||||||||||||||||||||
| 2462 | int i = 0; | - | ||||||||||||||||||||||||||||||
| 2463 | int to = buffer+displayMarginEnd+tempPos+size()-1; | - | ||||||||||||||||||||||||||||||
| 2464 | while (i < count && rowPos <= to + rowSize()*(columns - colNum)/qreal(columns+1)) {
| 44-4253 | ||||||||||||||||||||||||||||||
| 2465 | FxViewItem *item = nullptr; | - | ||||||||||||||||||||||||||||||
| 2466 | if (change.isMove() && (item = currentChanges.removedItems.take(change.moveKey(modelIndex + i))))
| 366-2851 | ||||||||||||||||||||||||||||||
| 2467 | item->index = modelIndex + i; executed 992 times by 1 test: item->index = modelIndex + i;Executed by:
| 992 | ||||||||||||||||||||||||||||||
| 2468 | bool newItem = !item; | - | ||||||||||||||||||||||||||||||
| 2469 | if (!item)
| 992-3217 | ||||||||||||||||||||||||||||||
| 2470 | item = createItem(modelIndex + i, QQmlIncubator::Synchronous); executed 3217 times by 3 tests: item = createItem(modelIndex + i, QQmlIncubator::Synchronous);Executed by:
| 3217 | ||||||||||||||||||||||||||||||
| 2471 | if (!item)
| 0-4209 | ||||||||||||||||||||||||||||||
| 2472 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 2473 | - | |||||||||||||||||||||||||||||||
| 2474 | QQuickItemPrivate::get(item->item)->setCulled(false); | - | ||||||||||||||||||||||||||||||
| 2475 | visibleItems.insert(index, item); | - | ||||||||||||||||||||||||||||||
| 2476 | if (index == 0)
| 261-3948 | ||||||||||||||||||||||||||||||
| 2477 | insertResult->changedFirstItem = true; executed 261 times by 3 tests: insertResult->changedFirstItem = true;Executed by:
| 261 | ||||||||||||||||||||||||||||||
| 2478 | if (change.isMove()) {
| 1358-2851 | ||||||||||||||||||||||||||||||
| 2479 | // we know this is a move target, since move displaced items that are | - | ||||||||||||||||||||||||||||||
| 2480 | // shuffled into view due to a move would be added in refill() | - | ||||||||||||||||||||||||||||||
| 2481 | if (newItem && transitioner && transitioner->canTransition(QQuickItemViewTransitioner::MoveTransition, true))
| 0-992 | ||||||||||||||||||||||||||||||
| 2482 | movingIntoView->append(MovedItem(item, change.moveKey(item->index))); executed 58 times by 1 test: movingIntoView->append(MovedItem(item, change.moveKey(item->index)));Executed by:
| 58 | ||||||||||||||||||||||||||||||
| 2483 | } else { executed 1358 times by 1 test: end of blockExecuted by:
| 1358 | ||||||||||||||||||||||||||||||
| 2484 | addedItems->append(item); | - | ||||||||||||||||||||||||||||||
| 2485 | if (transitioner)
| 188-2663 | ||||||||||||||||||||||||||||||
| 2486 | item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, true); executed 188 times by 1 test: item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, true);Executed by:
| 188 | ||||||||||||||||||||||||||||||
| 2487 | else | - | ||||||||||||||||||||||||||||||
| 2488 | item->moveTo(QPointF(colPos, rowPos), true); executed 2663 times by 3 tests: item->moveTo(QPointF(colPos, rowPos), true);Executed by:
| 2663 | ||||||||||||||||||||||||||||||
| 2489 | } | - | ||||||||||||||||||||||||||||||
| 2490 | insertResult->sizeChangesAfterVisiblePos += rowSize(); | - | ||||||||||||||||||||||||||||||
| 2491 | - | |||||||||||||||||||||||||||||||
| 2492 | if (++colNum >= columns) {
| 1170-3039 | ||||||||||||||||||||||||||||||
| 2493 | colNum = 0; | - | ||||||||||||||||||||||||||||||
| 2494 | rowPos += rowSize(); | - | ||||||||||||||||||||||||||||||
| 2495 | } executed 1170 times by 3 tests: end of blockExecuted by:
| 1170 | ||||||||||||||||||||||||||||||
| 2496 | colPos = colNum * colSize(); | - | ||||||||||||||||||||||||||||||
| 2497 | ++index; | - | ||||||||||||||||||||||||||||||
| 2498 | ++i; | - | ||||||||||||||||||||||||||||||
| 2499 | } executed 4209 times by 3 tests: end of blockExecuted by:
| 4209 | ||||||||||||||||||||||||||||||
| 2500 | } executed 997 times by 3 tests: end of blockExecuted by:
| 997 | ||||||||||||||||||||||||||||||
| 2501 | - | |||||||||||||||||||||||||||||||
| 2502 | updateVisibleIndex(); | - | ||||||||||||||||||||||||||||||
| 2503 | - | |||||||||||||||||||||||||||||||
| 2504 | return visibleItems.count() > prevVisibleCount; executed 1093 times by 3 tests: return visibleItems.count() > prevVisibleCount;Executed by:
| 1093 | ||||||||||||||||||||||||||||||
| 2505 | } | - | ||||||||||||||||||||||||||||||
| 2506 | - | |||||||||||||||||||||||||||||||
| 2507 | void QQuickGridViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex, const ChangeResult &insertionResult, const ChangeResult &removalResult) | - | ||||||||||||||||||||||||||||||
| 2508 | { | - | ||||||||||||||||||||||||||||||
| 2509 | if (!transitioner)
| 0-268 | ||||||||||||||||||||||||||||||
| 2510 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2511 | - | |||||||||||||||||||||||||||||||
| 2512 | int markerItemIndex = -1; | - | ||||||||||||||||||||||||||||||
| 2513 | for (int i=0; i<visibleItems.count(); i++) {
| 0-4792 | ||||||||||||||||||||||||||||||
| 2514 | if (visibleItems.at(i)->index == afterModelIndex) {
| 268-4524 | ||||||||||||||||||||||||||||||
| 2515 | markerItemIndex = i; | - | ||||||||||||||||||||||||||||||
| 2516 | break; executed 268 times by 2 tests: break;Executed by:
| 268 | ||||||||||||||||||||||||||||||
| 2517 | } | - | ||||||||||||||||||||||||||||||
| 2518 | } executed 4524 times by 2 tests: end of blockExecuted by:
| 4524 | ||||||||||||||||||||||||||||||
| 2519 | if (markerItemIndex < 0)
| 0-268 | ||||||||||||||||||||||||||||||
| 2520 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2521 | - | |||||||||||||||||||||||||||||||
| 2522 | const qreal viewEndPos = isContentFlowReversed() ? -position() : position() + size();
| 0-268 | ||||||||||||||||||||||||||||||
| 2523 | int countItemsRemoved = -(removalResult.sizeChangesAfterVisiblePos / rowSize()); | - | ||||||||||||||||||||||||||||||
| 2524 | - | |||||||||||||||||||||||||||||||
| 2525 | // account for whether first item has changed if < 1 row was removed before visible | - | ||||||||||||||||||||||||||||||
| 2526 | int changeBeforeVisible = insertionResult.countChangeBeforeVisible - removalResult.countChangeBeforeVisible; | - | ||||||||||||||||||||||||||||||
| 2527 | if (changeBeforeVisible != 0)
| 20-248 | ||||||||||||||||||||||||||||||
| 2528 | countItemsRemoved += (changeBeforeVisible % columns) - (columns - 1); executed 20 times by 1 test: countItemsRemoved += (changeBeforeVisible % columns) - (columns - 1);Executed by:
| 20 | ||||||||||||||||||||||||||||||
| 2529 | - | |||||||||||||||||||||||||||||||
| 2530 | countItemsRemoved -= removalResult.countChangeAfterVisibleItems; | - | ||||||||||||||||||||||||||||||
| 2531 | - | |||||||||||||||||||||||||||||||
| 2532 | for (int i=markerItemIndex+1; i<visibleItems.count(); i++) {
| 8-298 | ||||||||||||||||||||||||||||||
| 2533 | FxGridItemSG *gridItem = static_cast<FxGridItemSG *>(visibleItems.at(i)); | - | ||||||||||||||||||||||||||||||
| 2534 | if (gridItem->position() >= viewEndPos)
| 38-260 | ||||||||||||||||||||||||||||||
| 2535 | break; executed 260 times by 1 test: break;Executed by:
| 260 | ||||||||||||||||||||||||||||||
| 2536 | if (!gridItem->transitionScheduledOrRunning()) {
| 0-38 | ||||||||||||||||||||||||||||||
| 2537 | qreal origRowPos = gridItem->colPos(); | - | ||||||||||||||||||||||||||||||
| 2538 | qreal origColPos = gridItem->rowPos(); | - | ||||||||||||||||||||||||||||||
| 2539 | int indexDiff = gridItem->index - countItemsRemoved; | - | ||||||||||||||||||||||||||||||
| 2540 | gridItem->setPosition((indexDiff % columns) * colSize(), (indexDiff / columns) * rowSize()); | - | ||||||||||||||||||||||||||||||
| 2541 | gridItem->transitionNextReposition(transitioner, QQuickItemViewTransitioner::RemoveTransition, false); | - | ||||||||||||||||||||||||||||||
| 2542 | gridItem->setPosition(origRowPos, origColPos); | - | ||||||||||||||||||||||||||||||
| 2543 | } executed 38 times by 1 test: end of blockExecuted by:
| 38 | ||||||||||||||||||||||||||||||
| 2544 | } executed 38 times by 1 test: end of blockExecuted by:
| 38 | ||||||||||||||||||||||||||||||
| 2545 | } executed 268 times by 2 tests: end of blockExecuted by:
| 268 | ||||||||||||||||||||||||||||||
| 2546 | - | |||||||||||||||||||||||||||||||
| 2547 | bool QQuickGridViewPrivate::needsRefillForAddedOrRemovedIndex(int modelIndex) const | - | ||||||||||||||||||||||||||||||
| 2548 | { | - | ||||||||||||||||||||||||||||||
| 2549 | // If we add or remove items before visible items, a layout may be | - | ||||||||||||||||||||||||||||||
| 2550 | // required to ensure item 0 is in the first column. | - | ||||||||||||||||||||||||||||||
| 2551 | return modelIndex < visibleIndex; executed 119 times by 1 test: return modelIndex < visibleIndex;Executed by:
| 119 | ||||||||||||||||||||||||||||||
| 2552 | } | - | ||||||||||||||||||||||||||||||
| 2553 | - | |||||||||||||||||||||||||||||||
| 2554 | /*! | - | ||||||||||||||||||||||||||||||
| 2555 | \qmlmethod QtQuick::GridView::positionViewAtIndex(int index, PositionMode mode) | - | ||||||||||||||||||||||||||||||
| 2556 | - | |||||||||||||||||||||||||||||||
| 2557 | Positions the view such that the \a index is at the position specified by | - | ||||||||||||||||||||||||||||||
| 2558 | \a mode: | - | ||||||||||||||||||||||||||||||
| 2559 | - | |||||||||||||||||||||||||||||||
| 2560 | \list | - | ||||||||||||||||||||||||||||||
| 2561 | \li GridView.Beginning - position item at the top (or left for \c GridView.FlowTopToBottom flow) of the view. | - | ||||||||||||||||||||||||||||||
| 2562 | \li GridView.Center - position item in the center of the view. | - | ||||||||||||||||||||||||||||||
| 2563 | \li GridView.End - position item at bottom (or right for horizontal orientation) of the view. | - | ||||||||||||||||||||||||||||||
| 2564 | \li GridView.Visible - if any part of the item is visible then take no action, otherwise | - | ||||||||||||||||||||||||||||||
| 2565 | bring the item into view. | - | ||||||||||||||||||||||||||||||
| 2566 | \li GridView.Contain - ensure the entire item is visible. If the item is larger than | - | ||||||||||||||||||||||||||||||
| 2567 | the view the item is positioned at the top (or left for \c GridView.FlowTopToBottom flow) of the view. | - | ||||||||||||||||||||||||||||||
| 2568 | \li GridView.SnapPosition - position the item at \l preferredHighlightBegin. This mode | - | ||||||||||||||||||||||||||||||
| 2569 | is only valid if \l highlightRangeMode is StrictlyEnforceRange or snapping is enabled | - | ||||||||||||||||||||||||||||||
| 2570 | via \l snapMode. | - | ||||||||||||||||||||||||||||||
| 2571 | \endlist | - | ||||||||||||||||||||||||||||||
| 2572 | - | |||||||||||||||||||||||||||||||
| 2573 | If positioning the view at the index would cause empty space to be displayed at | - | ||||||||||||||||||||||||||||||
| 2574 | the beginning or end of the view, the view will be positioned at the boundary. | - | ||||||||||||||||||||||||||||||
| 2575 | - | |||||||||||||||||||||||||||||||
| 2576 | It is not recommended to use \l {Flickable::}{contentX} or \l {Flickable::}{contentY} to position the view | - | ||||||||||||||||||||||||||||||
| 2577 | at a particular index. This is unreliable since removing items from the start | - | ||||||||||||||||||||||||||||||
| 2578 | of the view does not cause all other items to be repositioned. | - | ||||||||||||||||||||||||||||||
| 2579 | The correct way to bring an item into view is with \c positionViewAtIndex. | - | ||||||||||||||||||||||||||||||
| 2580 | - | |||||||||||||||||||||||||||||||
| 2581 | \b Note: methods should only be called after the Component has completed. To position | - | ||||||||||||||||||||||||||||||
| 2582 | the view at startup, this method should be called by Component.onCompleted. For | - | ||||||||||||||||||||||||||||||
| 2583 | example, to position the view at the end: | - | ||||||||||||||||||||||||||||||
| 2584 | - | |||||||||||||||||||||||||||||||
| 2585 | \code | - | ||||||||||||||||||||||||||||||
| 2586 | Component.onCompleted: positionViewAtIndex(count - 1, GridView.Beginning) | - | ||||||||||||||||||||||||||||||
| 2587 | \endcode | - | ||||||||||||||||||||||||||||||
| 2588 | */ | - | ||||||||||||||||||||||||||||||
| 2589 | - | |||||||||||||||||||||||||||||||
| 2590 | /*! | - | ||||||||||||||||||||||||||||||
| 2591 | \qmlmethod QtQuick::GridView::positionViewAtBeginning() | - | ||||||||||||||||||||||||||||||
| 2592 | \qmlmethod QtQuick::GridView::positionViewAtEnd() | - | ||||||||||||||||||||||||||||||
| 2593 | - | |||||||||||||||||||||||||||||||
| 2594 | Positions the view at the beginning or end, taking into account any header or footer. | - | ||||||||||||||||||||||||||||||
| 2595 | - | |||||||||||||||||||||||||||||||
| 2596 | It is not recommended to use \l {Flickable::}{contentX} or \l {Flickable::}{contentY} to position the view | - | ||||||||||||||||||||||||||||||
| 2597 | at a particular index. This is unreliable since removing items from the start | - | ||||||||||||||||||||||||||||||
| 2598 | of the list does not cause all other items to be repositioned, and because | - | ||||||||||||||||||||||||||||||
| 2599 | the actual start of the view can vary based on the size of the delegates. | - | ||||||||||||||||||||||||||||||
| 2600 | - | |||||||||||||||||||||||||||||||
| 2601 | \b Note: methods should only be called after the Component has completed. To position | - | ||||||||||||||||||||||||||||||
| 2602 | the view at startup, this method should be called by Component.onCompleted. For | - | ||||||||||||||||||||||||||||||
| 2603 | example, to position the view at the end on startup: | - | ||||||||||||||||||||||||||||||
| 2604 | - | |||||||||||||||||||||||||||||||
| 2605 | \code | - | ||||||||||||||||||||||||||||||
| 2606 | Component.onCompleted: positionViewAtEnd() | - | ||||||||||||||||||||||||||||||
| 2607 | \endcode | - | ||||||||||||||||||||||||||||||
| 2608 | */ | - | ||||||||||||||||||||||||||||||
| 2609 | - | |||||||||||||||||||||||||||||||
| 2610 | /*! | - | ||||||||||||||||||||||||||||||
| 2611 | \qmlmethod int QtQuick::GridView::indexAt(real x, real y) | - | ||||||||||||||||||||||||||||||
| 2612 | - | |||||||||||||||||||||||||||||||
| 2613 | Returns the index of the visible item containing the point \a x, \a y in content | - | ||||||||||||||||||||||||||||||
| 2614 | coordinates. If there is no item at the point specified, or the item is | - | ||||||||||||||||||||||||||||||
| 2615 | not visible -1 is returned. | - | ||||||||||||||||||||||||||||||
| 2616 | - | |||||||||||||||||||||||||||||||
| 2617 | If the item is outside the visible area, -1 is returned, regardless of | - | ||||||||||||||||||||||||||||||
| 2618 | whether an item will exist at that point when scrolled into view. | - | ||||||||||||||||||||||||||||||
| 2619 | - | |||||||||||||||||||||||||||||||
| 2620 | \b Note: methods should only be called after the Component has completed. | - | ||||||||||||||||||||||||||||||
| 2621 | */ | - | ||||||||||||||||||||||||||||||
| 2622 | - | |||||||||||||||||||||||||||||||
| 2623 | /*! | - | ||||||||||||||||||||||||||||||
| 2624 | \qmlmethod Item QtQuick::GridView::itemAt(real x, real y) | - | ||||||||||||||||||||||||||||||
| 2625 | - | |||||||||||||||||||||||||||||||
| 2626 | Returns the visible item containing the point \a x, \a y in content | - | ||||||||||||||||||||||||||||||
| 2627 | coordinates. If there is no item at the point specified, or the item is | - | ||||||||||||||||||||||||||||||
| 2628 | not visible null is returned. | - | ||||||||||||||||||||||||||||||
| 2629 | - | |||||||||||||||||||||||||||||||
| 2630 | If the item is outside the visible area, null is returned, regardless of | - | ||||||||||||||||||||||||||||||
| 2631 | whether an item will exist at that point when scrolled into view. | - | ||||||||||||||||||||||||||||||
| 2632 | - | |||||||||||||||||||||||||||||||
| 2633 | \b Note: methods should only be called after the Component has completed. | - | ||||||||||||||||||||||||||||||
| 2634 | */ | - | ||||||||||||||||||||||||||||||
| 2635 | - | |||||||||||||||||||||||||||||||
| 2636 | - | |||||||||||||||||||||||||||||||
| 2637 | /*! | - | ||||||||||||||||||||||||||||||
| 2638 | \qmlmethod QtQuick::GridView::forceLayout() | - | ||||||||||||||||||||||||||||||
| 2639 | - | |||||||||||||||||||||||||||||||
| 2640 | Responding to changes in the model is usually batched to happen only once | - | ||||||||||||||||||||||||||||||
| 2641 | per frame. This means that inside script blocks it is possible for the | - | ||||||||||||||||||||||||||||||
| 2642 | underlying model to have changed, but the GridView has not caught up yet. | - | ||||||||||||||||||||||||||||||
| 2643 | - | |||||||||||||||||||||||||||||||
| 2644 | This method forces the GridView to immediately respond to any outstanding | - | ||||||||||||||||||||||||||||||
| 2645 | changes in the model. | - | ||||||||||||||||||||||||||||||
| 2646 | - | |||||||||||||||||||||||||||||||
| 2647 | \since 5.1 | - | ||||||||||||||||||||||||||||||
| 2648 | - | |||||||||||||||||||||||||||||||
| 2649 | \b Note: methods should only be called after the Component has completed. | - | ||||||||||||||||||||||||||||||
| 2650 | */ | - | ||||||||||||||||||||||||||||||
| 2651 | - | |||||||||||||||||||||||||||||||
| 2652 | QQuickGridViewAttached *QQuickGridView::qmlAttachedProperties(QObject *obj) | - | ||||||||||||||||||||||||||||||
| 2653 | { | - | ||||||||||||||||||||||||||||||
| 2654 | return new QQuickGridViewAttached(obj); executed 48281 times by 4 tests: return new QQuickGridViewAttached(obj);Executed by:
| 48281 | ||||||||||||||||||||||||||||||
| 2655 | } | - | ||||||||||||||||||||||||||||||
| 2656 | - | |||||||||||||||||||||||||||||||
| 2657 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||||||||
| 2658 | - | |||||||||||||||||||||||||||||||
| 2659 | #include "moc_qquickgridview_p.cpp" | - | ||||||||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |