OpenCoverage

qquickgridview.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickgridview.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
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-
54QT_BEGIN_NAMESPACE-
55-
56#ifndef QML_FLICK_SNAPONETHRESHOLD-
57#define QML_FLICK_SNAPONETHRESHOLD 30-
58#endif-
59-
60//-----------------------------------------------------------------------------
61-
62class FxGridItemSG : public FxViewItem-
63{-
64public:-
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 block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
51741
68-
69 qreal position() const override {-
70 return rowPos();
executed 61291 times by 4 tests: return rowPos();
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
61291
71 }-
72-
73 qreal endPosition() const override {-
74 return endRowPos();
executed 16817 times by 3 tests: return endRowPos();
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
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:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
13616
79 }-
80-
81 qreal sectionSize() const override {-
82 return 0.0;
executed 12548 times by 3 tests: return 0.0;
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
12548
83 }-
84-
85 qreal rowPos() const {-
86 if (view->flow() == QQuickGridView::FlowLeftToRight)
view->flow() =...lowLeftToRightDescription
TRUEevaluated 375994 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 338667 times by 1 test
Evaluated by:
  • tst_qquickgridview
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:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
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:
  • tst_qquickgridview
338667
90 }-
91-
92 qreal colPos() const {-
93 if (view->flow() == QQuickGridView::FlowLeftToRight) {
view->flow() =...lowLeftToRightDescription
TRUEevaluated 85100 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 67873 times by 1 test
Evaluated by:
  • tst_qquickgridview
67873-85100
94 if (view->effectiveLayoutDirection() == Qt::RightToLeft) {
view->effectiv...t::RightToLeftDescription
TRUEevaluated 14264 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 70836 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
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:
  • tst_qquickgridview
14264
98 } else {-
99 return itemX();
executed 70836 times by 4 tests: return itemX();
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
70836
100 }-
101 } else {-
102 if (view->verticalLayoutDirection() == QQuickItemView::BottomToTop) {
view->vertical...w::BottomToTopDescription
TRUEevaluated 13434 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 54439 times by 1 test
Evaluated by:
  • tst_qquickgridview
13434-54439
103 return -view->cellHeight() - itemY();
executed 13434 times by 1 test: return -view->cellHeight() - itemY();
Executed by:
  • tst_qquickgridview
13434
104 } else {-
105 return itemY();
executed 54439 times by 1 test: return itemY();
Executed by:
  • tst_qquickgridview
54439
106 }-
107 }-
108 }-
109 qreal endRowPos() const {-
110 if (view->flow() == QQuickGridView::FlowLeftToRight) {
view->flow() =...lowLeftToRightDescription
TRUEevaluated 11557 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
FALSEevaluated 5260 times by 1 test
Evaluated by:
  • tst_qquickgridview
5260-11557
111 if (view->verticalLayoutDirection() == QQuickItemView::BottomToTop)
view->vertical...w::BottomToTopDescription
TRUEevaluated 2332 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 9225 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
2332-9225
112 return -itemY();
executed 2332 times by 1 test: return -itemY();
Executed by:
  • tst_qquickgridview
2332
113 else-
114 return itemY() + view->cellHeight();
executed 9225 times by 3 tests: return itemY() + view->cellHeight();
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
9225
115 } else {-
116 if (view->effectiveLayoutDirection() == Qt::RightToLeft)
view->effectiv...t::RightToLeftDescription
TRUEevaluated 2790 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 2470 times by 1 test
Evaluated by:
  • tst_qquickgridview
2470-2790
117 return -itemX();
executed 2790 times by 1 test: return -itemX();
Executed by:
  • tst_qquickgridview
2790
118 else-
119 return itemX() + view->cellWidth();
executed 2470 times by 1 test: return itemX() + view->cellWidth();
Executed by:
  • tst_qquickgridview
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 block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
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:
  • tst_qquickgridview
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:
  • tst_qquickgridview
62
128 }-
129-
130 QQuickGridView *view;-
131-
132private:-
133 QPointF pointForPosition(qreal col, qreal row) const {-
134 qreal x;-
135 qreal y;-
136 if (view->flow() == QQuickGridView::FlowLeftToRight) {
view->flow() =...lowLeftToRightDescription
TRUEevaluated 74295 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 48557 times by 1 test
Evaluated by:
  • tst_qquickgridview
48557-74295
137 x = col;-
138 y = row;-
139 if (view->effectiveLayoutDirection() == Qt::RightToLeft) {
view->effectiv...t::RightToLeftDescription
TRUEevaluated 19984 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 54311 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
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 block
Executed by:
  • tst_qquickgridview
19984
143 } else {
executed 74295 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
74295
144 x = row;-
145 y = col;-
146 if (view->effectiveLayoutDirection() == Qt::RightToLeft)
view->effectiv...t::RightToLeftDescription
TRUEevaluated 24538 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 24019 times by 1 test
Evaluated by:
  • tst_qquickgridview
24019-24538
147 x = -view->cellWidth() - row;
executed 24538 times by 1 test: x = -view->cellWidth() - row;
Executed by:
  • tst_qquickgridview
24538
148 }
executed 48557 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
48557
149 if (view->verticalLayoutDirection() == QQuickItemView::BottomToTop)
view->vertical...w::BottomToTopDescription
TRUEevaluated 40896 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 81956 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
40896-81956
150 y = -view->cellHeight() - y;
executed 40896 times by 1 test: y = -view->cellHeight() - y;
Executed by:
  • tst_qquickgridview
40896
151 return QPointF(x, y);
executed 122852 times by 4 tests: return QPointF(x, y);
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
122852
152 }-
153};-
154-
155//-----------------------------------------------------------------------------
156-
157class QQuickGridViewPrivate : public QQuickItemViewPrivate-
158{-
159 Q_DECLARE_PUBLIC(QQuickGridView)-
160-
161public:-
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 block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
1782
235 ~QQuickGridViewPrivate()-
236 {-
237 delete highlightXAnimator;-
238 delete highlightYAnimator;-
239 }
executed 1782 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
1782
240};-
241-
242Qt::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:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
384171
245}-
246-
247bool 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:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
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:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
204260
253}-
254-
255void QQuickGridViewPrivate::changedVisibleIndex(int newIndex)-
256{-
257 visibleIndex = newIndex / columns * columns;-
258}
executed 56 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
56
259-
260void 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 block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
4555
266-
267qreal QQuickGridViewPrivate::originPosition() const-
268{-
269 qreal pos = 0;-
270 if (!visibleItems.isEmpty())
!visibleItems.isEmpty()Description
TRUEevaluated 22995 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 11274 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
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:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
22995
272 return pos;
executed 34269 times by 4 tests: return pos;
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
34269
273}-
274-
275qreal QQuickGridViewPrivate::lastPosition() const-
276{-
277 qreal pos = 0;-
278 if (model && (model->count() || !visibleItems.isEmpty())) {
model->count()Description
TRUEevaluated 23701 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 148 times by 1 test
Evaluated by:
  • tst_qquickgridview
!visibleItems.isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 146 times by 1 test
Evaluated by:
  • tst_qquickgridview
2-23701
279 qreal lastRowPos = model->count() ? rowPosAt(model->count() - 1) : 0;
model->count()Description
TRUEevaluated 23701 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
2-23701
280 if (!visibleItems.isEmpty()) {
!visibleItems.isEmpty()Description
TRUEevaluated 19743 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 3960 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
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 block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
19743
284 pos = lastRowPos + rowSize();-
285 }
executed 23703 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
23703
286 return pos;
executed 24955 times by 4 tests: return pos;
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
24955
287}-
288-
289qreal QQuickGridViewPrivate::positionAt(int index) const-
290{-
291 return rowPosAt(index);
executed 12241 times by 4 tests: return rowPosAt(index);
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
12241
292}-
293-
294qreal QQuickGridViewPrivate::endPositionAt(int index) const-
295{-
296 return rowPosAt(index) + rowSize();
executed 14266 times by 4 tests: return rowPosAt(index) + rowSize();
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
14266
297}-
298-
299qreal QQuickGridViewPrivate::rowSize() const {-
300 return flow == QQuickGridView::FlowLeftToRight ? cellHeight : cellWidth;
executed 602888 times by 4 tests: return flow == QQuickGridView::FlowLeftToRight ? cellHeight : cellWidth;
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
602888
301}-
302qreal QQuickGridViewPrivate::colSize() const {-
303 return flow == QQuickGridView::FlowLeftToRight ? cellWidth : cellHeight;
executed 417056 times by 4 tests: return flow == QQuickGridView::FlowLeftToRight ? cellWidth : cellHeight;
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
417056
304}-
305-
306qreal QQuickGridViewPrivate::colPosAt(int modelIndex) const-
307{-
308 if (FxViewItem *item = visibleItem(modelIndex))
FxViewItem *it...em(modelIndex)Description
TRUEevaluated 24370 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 2249 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
2249-24370
309 return static_cast<FxGridItemSG*>(item)->colPos();
executed 24370 times by 4 tests: return static_cast<FxGridItemSG*>(item)->colPos();
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
24370
310 if (!visibleItems.isEmpty()) {
!visibleItems.isEmpty()Description
TRUEevaluated 287 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 1962 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
287-1962
311 if (modelIndex == visibleIndex) {
modelIndex == visibleIndexDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 281 times by 1 test
Evaluated by:
  • tst_qquickgridview
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:
  • tst_qquickgridview
6
314 } else if (modelIndex < visibleIndex) {
modelIndex < visibleIndexDescription
TRUEevaluated 85 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 196 times by 1 test
Evaluated by:
  • tst_qquickgridview
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:
  • tst_qquickgridview
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:
  • tst_qquickgridview
196
325 }-
326 }-
327 return (modelIndex % columns) * colSize();
executed 1962 times by 3 tests: return (modelIndex % columns) * colSize();
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
1962
328}-
329-
330qreal QQuickGridViewPrivate::rowPosAt(int modelIndex) const-
331{-
332 if (FxViewItem *item = visibleItem(modelIndex))
FxViewItem *it...em(modelIndex)Description
TRUEevaluated 59550 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 38790 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
38790-59550
333 return static_cast<FxGridItemSG*>(item)->rowPos();
executed 59550 times by 4 tests: return static_cast<FxGridItemSG*>(item)->rowPos();
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
59550
334 if (!visibleItems.isEmpty()) {
!visibleItems.isEmpty()Description
TRUEevaluated 23558 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
FALSEevaluated 15232 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
15232-23558
335 if (modelIndex == visibleIndex) {
modelIndex == visibleIndexDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 23544 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
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:
  • tst_qquickgridview
14
338 } else if (modelIndex < visibleIndex) {
modelIndex < visibleIndexDescription
TRUEevaluated 1670 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 21874 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
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:
  • tst_qquickgridview
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:
  • tst_examples
  • tst_qquickgridview
21874
350 }-
351 }-
352 return (modelIndex / columns) * rowSize();
executed 15232 times by 4 tests: return (modelIndex / columns) * rowSize();
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
15232
353}-
354-
355-
356qreal QQuickGridViewPrivate::snapPosAt(qreal pos) const-
357{-
358 Q_Q(const QQuickGridView);-
359 qreal snapPos = 0;-
360 if (!visibleItems.isEmpty()) {
!visibleItems.isEmpty()Description
TRUEevaluated 138 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
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()) {
isContentFlowReversed()Description
TRUEevaluated 46 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 92 times by 1 test
Evaluated by:
  • tst_qquickgridview
46-92
370 maxExtent = q->minXExtent()-size();-
371 minExtent = q->maxXExtent()-size();-
372 } else {
executed 46 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
46
373 maxExtent = flow == QQuickGridView::FlowLeftToRight ? -q->maxYExtent() : -q->maxXExtent();
flow == QQuick...lowLeftToRightDescription
TRUEevaluated 46 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 46 times by 1 test
Evaluated by:
  • tst_qquickgridview
46
374 minExtent = flow == QQuickGridView::FlowLeftToRight ? -q->minYExtent() : -q->minXExtent();
flow == QQuick...lowLeftToRightDescription
TRUEevaluated 46 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 46 times by 1 test
Evaluated by:
  • tst_qquickgridview
46
375 }
executed 92 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
92
376 if (snapPos > maxExtent)
snapPos > maxExtentDescription
TRUEnever evaluated
FALSEevaluated 138 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-138
377 snapPos = maxExtent;
never executed: snapPos = maxExtent;
0
378 if (snapPos < minExtent)
snapPos < minExtentDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 132 times by 1 test
Evaluated by:
  • tst_qquickgridview
6-132
379 snapPos = minExtent;
executed 6 times by 1 test: snapPos = minExtent;
Executed by:
  • tst_qquickgridview
6
380 }
executed 138 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
138
381 return snapPos;
executed 138 times by 1 test: return snapPos;
Executed by:
  • tst_qquickgridview
138
382}-
383-
384FxViewItem *QQuickGridViewPrivate::snapItemAt(qreal pos) const-
385{-
386 for (FxViewItem *item : visibleItems) {-
387 if (item->index == -1)
item->index == -1Description
TRUEnever evaluated
FALSEevaluated 3988 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-3988
388 continue;
never executed: continue;
0
389 qreal itemTop = item->position();-
390 if (itemTop+rowSize()/2 >= pos && itemTop - rowSize()/2 <= pos)
itemTop+rowSize()/2 >= posDescription
TRUEevaluated 572 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 3416 times by 1 test
Evaluated by:
  • tst_qquickgridview
itemTop - rowSize()/2 <= posDescription
TRUEevaluated 524 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 48 times by 1 test
Evaluated by:
  • tst_qquickgridview
48-3416
391 return item;
executed 524 times by 1 test: return item;
Executed by:
  • tst_qquickgridview
524
392 }
executed 3464 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
3464
393 return nullptr;
executed 172 times by 1 test: return nullptr;
Executed by:
  • tst_qquickgridview
172
394}-
395-
396int QQuickGridViewPrivate::snapIndex() const-
397{-
398 int index = currentIndex;-
399 for (FxViewItem *item : visibleItems) {-
400 if (item->index == -1)
item->index == -1Description
TRUEnever evaluated
FALSEevaluated 23356 times by 1 test
Evaluated by:
  • tst_qquickgridview
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) {
itemTop >= hIt...()-rowSize()/2Description
TRUEevaluated 2729 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 20627 times by 1 test
Evaluated by:
  • tst_qquickgridview
itemTop < hIte...()+rowSize()/2Description
TRUEevaluated 2385 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 344 times by 1 test
Evaluated by:
  • tst_qquickgridview
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)
gridItem->colP...()-colSize()/2Description
TRUEevaluated 2385 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
gridItem->colP...()+colSize()/2Description
TRUEevaluated 2385 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
0-2385
408 return gridItem->index;
executed 2385 times by 1 test: return gridItem->index;
Executed by:
  • tst_qquickgridview
2385
409 }
never executed: end of block
0
410 }
executed 20971 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
20971
411 return index;
executed 87 times by 1 test: return index;
Executed by:
  • tst_qquickgridview
87
412}-
413-
414qreal QQuickGridViewPrivate::contentXForPosition(qreal pos) const-
415{-
416 Q_Q(const QQuickGridView);-
417 if (flow == QQuickGridView::FlowLeftToRight) {
flow == QQuick...lowLeftToRightDescription
TRUEevaluated 4757 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 1512 times by 1 test
Evaluated by:
  • tst_qquickgridview
1512-4757
418 // vertical scroll-
419 if (q->effectiveLayoutDirection() == Qt::LeftToRight) {
q->effectiveLa...t::LeftToRightDescription
TRUEevaluated 4164 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 593 times by 1 test
Evaluated by:
  • tst_qquickgridview
593-4164
420 return 0;
executed 4164 times by 4 tests: return 0;
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
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:
  • tst_qquickgridview
593
425 }-
426 } else {-
427 // horizontal scroll-
428 if (q->effectiveLayoutDirection() == Qt::LeftToRight)
q->effectiveLa...t::LeftToRightDescription
TRUEevaluated 690 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 822 times by 1 test
Evaluated by:
  • tst_qquickgridview
690-822
429 return pos;
executed 690 times by 1 test: return pos;
Executed by:
  • tst_qquickgridview
690
430 else-
431 return -pos - q->width();
executed 822 times by 1 test: return -pos - q->width();
Executed by:
  • tst_qquickgridview
822
432 }-
433}-
434-
435qreal QQuickGridViewPrivate::contentYForPosition(qreal pos) const-
436{-
437 Q_Q(const QQuickGridView);-
438 if (flow == QQuickGridView::FlowLeftToRight) {
flow == QQuick...lowLeftToRightDescription
TRUEevaluated 4763 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 1512 times by 1 test
Evaluated by:
  • tst_qquickgridview
1512-4763
439 // vertical scroll-
440 if (verticalLayoutDirection == QQuickItemView::TopToBottom)
verticalLayout...w::TopToBottomDescription
TRUEevaluated 4190 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 573 times by 1 test
Evaluated by:
  • tst_qquickgridview
573-4190
441 return pos;
executed 4190 times by 4 tests: return pos;
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
4190
442 else-
443 return -pos - q->height();
executed 573 times by 1 test: return -pos - q->height();
Executed by:
  • tst_qquickgridview
573
444 } else {-
445 // horizontal scroll-
446 if (verticalLayoutDirection == QQuickItemView::TopToBottom)
verticalLayout...w::TopToBottomDescription
TRUEevaluated 944 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 568 times by 1 test
Evaluated by:
  • tst_qquickgridview
568-944
447 return 0;
executed 944 times by 1 test: return 0;
Executed by:
  • tst_qquickgridview
944
448 else-
449 return -q->height();
executed 568 times by 1 test: return -q->height();
Executed by:
  • tst_qquickgridview
568
450 }-
451}-
452-
453void QQuickGridViewPrivate::resetColumns()-
454{-
455 Q_Q(QQuickGridView);-
456 qreal length = flow == QQuickGridView::FlowLeftToRight ? q->width() : q->height();
flow == QQuick...lowLeftToRightDescription
TRUEevaluated 14283 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 4360 times by 1 test
Evaluated by:
  • tst_qquickgridview
4360-14283
457 columns = qMax(1, qFloor(length / colSize()));-
458}
executed 18643 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
18643
459-
460FxViewItem *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:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
49543
465}-
466-
467void 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 block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
49543
474-
475bool 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()) {
visibleItems.count()Description
TRUEevaluated 21513 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 1954 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
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) {
++colNum >= columnsDescription
TRUEevaluated 13620 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 7893 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
7893-13620
484 colNum = 0;-
485 rowPos += rowSize();-
486 }
executed 13620 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
13620
487 colPos = colNum * colSize();-
488 }
executed 21513 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
21513
489-
490 int modelIndex = findLastVisibleIndex();-
491 modelIndex = modelIndex < 0 ? visibleIndex : modelIndex + 1;
modelIndex < 0Description
TRUEevaluated 1958 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
FALSEevaluated 21509 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
1958-21509
492-
493 if (visibleItems.count() && (bufferFrom > rowPos + rowSize()*2
visibleItems.count()Description
TRUEevaluated 21513 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 1954 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
bufferFrom > r... + rowSize()*2Description
TRUEnever evaluated
FALSEevaluated 21513 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
0-21513
494 || bufferTo < rowPosAt(visibleIndex) - rowSize())) {
bufferTo < row...x) - rowSize()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 21507 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
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())
modelIndex >= model->count()Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-6
501 modelIndex = model->count() - 1;
never executed: modelIndex = model->count() - 1;
0
502 else if (modelIndex < 0)
modelIndex < 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickgridview
2-4
503 modelIndex = 0;
executed 2 times by 1 test: modelIndex = 0;
Executed by:
  • tst_qquickgridview
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 block
Executed by:
  • tst_qquickgridview
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;
doBufferDescription
TRUEevaluated 6895 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 16572 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
6895-16572
515-
516 while (modelIndex < model->count() && rowPos <= fillTo + rowSize()*(columns - colNum)/(columns+1)) {
modelIndex < model->count()Description
TRUEevaluated 53610 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
FALSEevaluated 11039 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
rowPos <= fill...m)/(columns+1)Description
TRUEevaluated 41802 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
FALSEevaluated 11808 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
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;
qt_category_enabledDescription
TRUEnever evaluated
FALSEevaluated 41802 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
0-41802
518 if (!(item = static_cast<FxGridItemSG*>(createItem(modelIndex, incubationMode))))
!(item = stati...ubationMode)))Description
TRUEevaluated 620 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 41182 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
620-41182
519 break;
executed 620 times by 1 test: break;
Executed by:
  • tst_qquickgridview
620
520 if (!transitioner || !transitioner->canTransition(QQuickItemViewTransitioner::PopulateTransition, true)) // pos will be set by layoutVisibleItems()
!transitionerDescription
TRUEevaluated 36648 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
FALSEevaluated 4534 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
!transitioner-...nsition, true)Description
TRUEevaluated 4268 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
FALSEevaluated 266 times by 1 test
Evaluated by:
  • tst_qquickgridview
266-36648
521 item->setPosition(colPos, rowPos, true);
executed 40916 times by 3 tests: item->setPosition(colPos, rowPos, true);
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
40916
522 QQuickItemPrivate::get(item->item)->setCulled(doBuffer);-
523 visibleItems.append(item);-
524 if (++colNum >= columns) {
++colNum >= columnsDescription
TRUEevaluated 11151 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
FALSEevaluated 30031 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
11151-30031
525 colNum = 0;-
526 rowPos += rowSize();-
527 }
executed 11151 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
11151
528 colPos = colNum * colSize();-
529 ++modelIndex;-
530 changed = true;-
531 }
executed 41182 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
41182
532-
533 if (doBuffer && requestedIndex != -1) // already waiting for an item
doBufferDescription
TRUEevaluated 6895 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 16572 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
requestedIndex != -1Description
TRUEevaluated 590 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 6305 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
590-16572
534 return changed;
executed 590 times by 1 test: return changed;
Executed by:
  • tst_qquickgridview
590
535-
536 // Find first column-
537 if (visibleItems.count()) {
visibleItems.count()Description
TRUEevaluated 22871 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickgridview
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 block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
22871
542 colNum = qFloor((colPos+colSize()/2) / colSize());-
543 if (--colNum < 0) {
--colNum < 0Description
TRUEevaluated 21102 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 1775 times by 1 test
Evaluated by:
  • tst_qquickgridview
1775-21102
544 colNum = columns - 1;-
545 rowPos -= rowSize();-
546 }
executed 21102 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
21102
547-
548 // Prepend-
549 colPos = colNum * colSize();-
550 while (visibleIndex > 0 && rowPos + rowSize() - 1 >= fillFrom - rowSize()*(colNum+1)/(columns+1)){
visibleIndex > 0Description
TRUEevaluated 6698 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 17876 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
rowPos + rowSi...1)/(columns+1)Description
TRUEevaluated 1919 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 4779 times by 1 test
Evaluated by:
  • tst_qquickgridview
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;
qt_category_enabledDescription
TRUEnever evaluated
FALSEevaluated 1919 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-1919
552 if (!(item = static_cast<FxGridItemSG*>(createItem(visibleIndex-1, incubationMode))))
!(item = stati...ubationMode)))Description
TRUEevaluated 222 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 1697 times by 1 test
Evaluated by:
  • tst_qquickgridview
222-1697
553 break;
executed 222 times by 1 test: break;
Executed by:
  • tst_qquickgridview
222
554 --visibleIndex;-
555 if (!transitioner || !transitioner->canTransition(QQuickItemViewTransitioner::PopulateTransition, true)) // pos will be set by layoutVisibleItems()
!transitionerDescription
TRUEevaluated 1677 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickgridview
!transitioner-...nsition, true)Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
0-1677
556 item->setPosition(colPos, rowPos, true);
executed 1697 times by 1 test: item->setPosition(colPos, rowPos, true);
Executed by:
  • tst_qquickgridview
1697
557 QQuickItemPrivate::get(item->item)->setCulled(doBuffer);-
558 visibleItems.prepend(item);-
559 if (--colNum < 0) {
--colNum < 0Description
TRUEevaluated 537 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 1160 times by 1 test
Evaluated by:
  • tst_qquickgridview
537-1160
560 colNum = columns-1;-
561 rowPos -= rowSize();-
562 }
executed 537 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
537
563 colPos = colNum * colSize();-
564 changed = true;-
565 }
executed 1697 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
1697
566-
567 return changed;
executed 22877 times by 4 tests: return changed;
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
22877
568}-
569-
570void QQuickGridViewPrivate::removeItem(FxViewItem *item)-
571{-
572 if (item->transitionScheduledOrRunning()) {
item->transiti...ledOrRunning()Description
TRUEevaluated 178 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 5872 times by 1 test
Evaluated by:
  • tst_qquickgridview
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();
qt_category_enabledDescription
TRUEnever evaluated
FALSEevaluated 178 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-178
574 item->releaseAfterTransition = true;-
575 releasePendingTransition.append(item);-
576 } else {
executed 178 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
178
577 releaseItem(item);-
578 }
executed 5872 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
5872
579}-
580-
581bool QQuickGridViewPrivate::removeNonVisibleItems(qreal bufferFrom, qreal bufferTo)-
582{-
583 FxGridItemSG *item = nullptr;-
584 bool changed = false;-
585-
586 while (visibleItems.count() > 1
visibleItems.count() > 1Description
TRUEevaluated 20325 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 114 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
114-20325
587 && (item = static_cast<FxGridItemSG*>(visibleItems.constFirst()))
(item = static...constFirst()))Description
TRUEevaluated 20325 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEnever evaluated
0-20325
588 && item->rowPos()+rowSize()-1 < bufferFrom - rowSize()*(item->colPos()/colSize()+1)/(columns+1)) {
item->rowPos()...1)/(columns+1)Description
TRUEevaluated 3867 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 16458 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
3867-16458
589 if (item->attached->delayRemove())
item->attached->delayRemove()Description
TRUEnever evaluated
FALSEevaluated 3867 times by 1 test
Evaluated by:
  • tst_qquickgridview
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();
qt_category_enabledDescription
TRUEnever evaluated
FALSEevaluated 3867 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-3867
592 if (item->index != -1)
item->index != -1Description
TRUEevaluated 3867 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
0-3867
593 visibleIndex++;
executed 3867 times by 1 test: visibleIndex++;
Executed by:
  • tst_qquickgridview
3867
594 visibleItems.removeFirst();-
595 removeItem(item);-
596 changed = true;-
597 }
executed 3867 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
3867
598 while (visibleItems.count() > 1
visibleItems.count() > 1Description
TRUEevaluated 18640 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 114 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
114-18640
599 && (item = static_cast<FxGridItemSG*>(visibleItems.constLast()))
(item = static....constLast()))Description
TRUEevaluated 18640 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEnever evaluated
0-18640
600 && item->rowPos() > bufferTo + rowSize()*(columns - item->colPos()/colSize())/(columns+1)) {
item->rowPos()...))/(columns+1)Description
TRUEevaluated 2182 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 16458 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
2182-16458
601 if (item->attached->delayRemove())
item->attached->delayRemove()Description
TRUEnever evaluated
FALSEevaluated 2182 times by 1 test
Evaluated by:
  • tst_qquickgridview
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;
qt_category_enabledDescription
TRUEnever evaluated
FALSEevaluated 2182 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-2182
604 visibleItems.removeLast();-
605 removeItem(item);-
606 changed = true;-
607 }
executed 2182 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
2182
608-
609 return changed;
executed 16572 times by 4 tests: return changed;
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
16572
610}-
611-
612void QQuickGridViewPrivate::updateViewport()-
613{-
614 resetColumns();-
615 QQuickItemViewPrivate::updateViewport();-
616}
executed 14899 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
14899
617-
618void QQuickGridViewPrivate::layoutVisibleItems(int fromModelIndex)-
619{-
620 if (visibleItems.count()) {
visibleItems.count()Description
TRUEevaluated 4174 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 62 times by 1 test
Evaluated by:
  • tst_qquickgridview
62-4174
621 const qreal from = isContentFlowReversed() ? -position()-displayMarginBeginning-size() : position()-displayMarginBeginning;
isContentFlowReversed()Description
TRUEevaluated 1389 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 2785 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
1389-2785
622 const qreal to = isContentFlowReversed() ? -position()+displayMarginEnd : position()+size()+displayMarginEnd;
isContentFlowReversed()Description
TRUEevaluated 1389 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 2785 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
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()) {
colPos != col * colSize()Description
TRUEevaluated 212 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 3962 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
212-3962
629 colPos = col * colSize();-
630 firstItem->setPosition(colPos, rowPos);-
631 }
executed 212 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
212
632 firstItem->setVisible(firstItem->rowPos() + rowSize() >= from && firstItem->rowPos() <= to);-
633 for (int i = 1; i < visibleItems.count(); ++i) {
i < visibleItems.count()Description
TRUEevaluated 72706 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 4174 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
4174-72706
634 FxGridItemSG *item = static_cast<FxGridItemSG*>(visibleItems.at(i));-
635 if (++col >= columns) {
++col >= columnsDescription
TRUEevaluated 19077 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
FALSEevaluated 53629 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
19077-53629
636 col = 0;-
637 rowPos += rowSize();-
638 }
executed 19077 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
19077
639 colPos = col * colSize();-
640 if (item->index >= fromModelIndex) {
item->index >= fromModelIndexDescription
TRUEevaluated 68848 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 3858 times by 1 test
Evaluated by:
  • tst_qquickgridview
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 block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
68848
644 }
executed 72706 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
72706
645 }
executed 4174 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
4174
646}
executed 4236 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
4236
647-
648void 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 block
Executed by:
  • tst_qquickgridview
126
653-
654void QQuickGridViewPrivate::repositionPackageItemAt(QQuickItem *item, int index)-
655{-
656 Q_Q(QQuickGridView);-
657 qreal pos = position();-
658 if (flow == QQuickGridView::FlowLeftToRight) {
flow == QQuick...lowLeftToRightDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
0-28
659 if (item->y() + item->height() > pos && item->y() < pos + q->height()) {
item->y() + it...height() > posDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
item->y() < pos + q->height()Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
0-28
660 qreal y = (verticalLayoutDirection == QQuickItemView::TopToBottom)
(verticalLayou...::TopToBottom)Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
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 block
Executed by:
  • tst_qquickgridview
28
665 } else {
executed 28 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
28
666 if (item->x() + item->width() > pos && item->x() < pos + q->width()) {
item->x() + it...>width() > posDescription
TRUEnever evaluated
FALSEnever evaluated
item->x() < pos + q->width()Description
TRUEnever evaluated
FALSEnever evaluated
0
667 qreal y = (verticalLayoutDirection == QQuickItemView::TopToBottom)
(verticalLayou...::TopToBottom)Description
TRUEnever evaluated
FALSEnever evaluated
0
668 ? colPosAt(index)-
669 : -colPosAt(index) - item->height();-
670 if (flow == QQuickGridView::FlowTopToBottom && q->effectiveLayoutDirection() == Qt::RightToLeft)
flow == QQuick...lowTopToBottomDescription
TRUEnever evaluated
FALSEnever evaluated
q->effectiveLa...t::RightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
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-
678void 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 block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
621
683-
684void QQuickGridViewPrivate::adjustFirstItem(qreal forwards, qreal backwards, int changeBeforeVisible)-
685{-
686 if (!visibleItems.count())
!visibleItems.count()Description
TRUEnever evaluated
FALSEevaluated 1936 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-1936
687 return;
never executed: return;
0
688-
689 int moveCount = (forwards - backwards) / rowSize();-
690 if (moveCount == 0 && changeBeforeVisible != 0)
moveCount == 0Description
TRUEevaluated 1699 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 237 times by 1 test
Evaluated by:
  • tst_qquickgridview
changeBeforeVisible != 0Description
TRUEevaluated 170 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 1529 times by 1 test
Evaluated by:
  • tst_qquickgridview
170-1699
691 moveCount += (changeBeforeVisible % columns) - (columns - 1);
executed 170 times by 1 test: moveCount += (changeBeforeVisible % columns) - (columns - 1);
Executed by:
  • tst_qquickgridview
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 block
Executed by:
  • tst_qquickgridview
1936
696-
697void QQuickGridViewPrivate::createHighlight()-
698{-
699 Q_Q(QQuickGridView);-
700 bool changed = false;-
701 if (highlight) {
highlightDescription
TRUEevaluated 1986 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 3934 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
1986-3934
702 if (trackedItem == highlight)
trackedItem == highlightDescription
TRUEevaluated 1986 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEnever evaluated
0-1986
703 trackedItem = nullptr;
executed 1986 times by 4 tests: trackedItem = nullptr;
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
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 block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
1986
714-
715 if (currentItem) {
currentItemDescription
TRUEevaluated 1986 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 3934 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
1986-3934
716 QQuickItem *item = createHighlightItem();-
717 if (item) {
itemDescription
TRUEevaluated 1986 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEnever evaluated
0-1986
718 FxGridItemSG *newHighlight = new FxGridItemSG(item, q, true);-
719 newHighlight->trackGeometry(true);-
720 if (autoHighlight)
autoHighlightDescription
TRUEevaluated 1976 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 10 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
10-1976
721 resetHighlightPosition();
executed 1976 times by 4 tests: resetHighlightPosition();
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
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 block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
1986
732 }
executed 1986 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
1986
733 if (changed)
changedDescription
TRUEevaluated 3970 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 1950 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
1950-3970
734 emit q->highlightItemChanged();
executed 3970 times by 4 tests: q->highlightItemChanged();
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
3970
735}
executed 5920 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
5920
736-
737void QQuickGridViewPrivate::updateHighlight()-
738{-
739 applyPendingChanges();-
740-
741 if ((!currentItem && highlight) || (currentItem && !highlight))
!currentItemDescription
TRUEevaluated 66 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 9102 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
highlightDescription
TRUEevaluated 54 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickgridview
currentItemDescription
TRUEevaluated 9102 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickgridview
!highlightDescription
TRUEevaluated 1984 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 7118 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
12-9102
742 createHighlight();
executed 2038 times by 4 tests: createHighlight();
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
2038
743 bool strictHighlight = haveHighlightRange && highlightRange == QQuickGridView::StrictlyEnforceRange;
haveHighlightRangeDescription
TRUEevaluated 618 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 8550 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
highlightRange...lyEnforceRangeDescription
TRUEevaluated 614 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickgridview
4-8550
744 if (currentItem && autoHighlight && highlight && (!strictHighlight || !pressed)) {
currentItemDescription
TRUEevaluated 9102 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 66 times by 1 test
Evaluated by:
  • tst_qquickgridview
autoHighlightDescription
TRUEevaluated 9072 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 30 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
highlightDescription
TRUEevaluated 9072 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEnever evaluated
!strictHighlightDescription
TRUEevaluated 8458 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 614 times by 1 test
Evaluated by:
  • tst_qquickgridview
!pressedDescription
TRUEevaluated 520 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 94 times by 1 test
Evaluated by:
  • tst_qquickgridview
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 block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
8978
753 updateTrackedItem();-
754}
executed 9168 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
9168
755-
756void QQuickGridViewPrivate::resetHighlightPosition()-
757{-
758 if (highlight && currentItem) {
highlightDescription
TRUEevaluated 1854 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
FALSEevaluated 1976 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
currentItemDescription
TRUEevaluated 1854 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
FALSEnever evaluated
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 block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
1854
762}
executed 3830 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
3830
763-
764qreal QQuickGridViewPrivate::headerSize() const-
765{-
766 if (!header)
!headerDescription
TRUEevaluated 41523 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 2688 times by 1 test
Evaluated by:
  • tst_qquickgridview
2688-41523
767 return 0.0;
executed 41523 times by 4 tests: return 0.0;
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
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:
  • tst_qquickgridview
2688
769}-
770-
771qreal QQuickGridViewPrivate::footerSize() const-
772{-
773 if (!footer)
!footerDescription
TRUEevaluated 33518 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 1335 times by 1 test
Evaluated by:
  • tst_qquickgridview
1335-33518
774 return 0.0;
executed 33518 times by 4 tests: return 0.0;
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
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:
  • tst_qquickgridview
1335
776}-
777-
778bool QQuickGridViewPrivate::showHeaderForIndex(int index) const-
779{-
780 return index / columns == 0;
executed 6031 times by 3 tests: return index / columns == 0;
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
6031
781}-
782-
783bool 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:
  • tst_qquickgridview
1028
786}-
787-
788void QQuickGridViewPrivate::updateFooter()-
789{-
790 Q_Q(QQuickGridView);-
791 bool created = false;-
792 if (!footer) {
!footerDescription
TRUEevaluated 10626 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 483 times by 1 test
Evaluated by:
  • tst_qquickgridview
483-10626
793 QQuickItem *item = createComponentItem(footerComponent, 1.0);-
794 if (!item)
!itemDescription
TRUEevaluated 10540 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 86 times by 1 test
Evaluated by:
  • tst_qquickgridview
86-10540
795 return;
executed 10540 times by 4 tests: return;
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
10540
796 footer = new FxGridItemSG(item, q, true);-
797 footer->trackGeometry(true);-
798 created = true;-
799 }
executed 86 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
86
800-
801 FxGridItemSG *gridItem = static_cast<FxGridItemSG*>(footer);-
802 qreal colOffset = 0;-
803 qreal rowOffset = 0;-
804 if (q->effectiveLayoutDirection() == Qt::RightToLeft) {
q->effectiveLa...t::RightToLeftDescription
TRUEevaluated 192 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 377 times by 1 test
Evaluated by:
  • tst_qquickgridview
192-377
805 if (flow == QQuickGridView::FlowTopToBottom)
flow == QQuick...lowTopToBottomDescription
TRUEevaluated 98 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 94 times by 1 test
Evaluated by:
  • tst_qquickgridview
94-98
806 rowOffset += gridItem->item->width() - cellWidth;
executed 98 times by 1 test: rowOffset += gridItem->item->width() - cellWidth;
Executed by:
  • tst_qquickgridview
98
807 else-
808 colOffset += gridItem->item->width() - cellWidth;
executed 94 times by 1 test: colOffset += gridItem->item->width() - cellWidth;
Executed by:
  • tst_qquickgridview
94
809 }-
810 if (verticalLayoutDirection == QQuickItemView::BottomToTop) {
verticalLayout...w::BottomToTopDescription
TRUEevaluated 172 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 397 times by 1 test
Evaluated by:
  • tst_qquickgridview
172-397
811 if (flow == QQuickGridView::FlowTopToBottom)
flow == QQuick...lowTopToBottomDescription
TRUEevaluated 86 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 86 times by 1 test
Evaluated by:
  • tst_qquickgridview
86
812 colOffset += gridItem->item->height() - cellHeight;
executed 86 times by 1 test: colOffset += gridItem->item->height() - cellHeight;
Executed by:
  • tst_qquickgridview
86
813 else-
814 rowOffset += gridItem->item->height() - cellHeight;
executed 86 times by 1 test: rowOffset += gridItem->item->height() - cellHeight;
Executed by:
  • tst_qquickgridview
86
815 }-
816 if (visibleItems.count()) {
visibleItems.count()Description
TRUEevaluated 379 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 190 times by 1 test
Evaluated by:
  • tst_qquickgridview
190-379
817 qreal endPos = lastPosition();-
818 if (findLastVisibleIndex() == model->count()-1) {
findLastVisibl...del->count()-1Description
TRUEevaluated 321 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 58 times by 1 test
Evaluated by:
  • tst_qquickgridview
58-321
819 gridItem->setPosition(colOffset, endPos + rowOffset);-
820 } else {
executed 321 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
321
821 qreal visiblePos = isContentFlowReversed() ? -position() : position() + size();
isContentFlowReversed()Description
TRUEnever evaluated
FALSEevaluated 58 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-58
822 if (endPos <= visiblePos || gridItem->endPosition() <= endPos + rowOffset)
endPos <= visiblePosDescription
TRUEnever evaluated
FALSEevaluated 58 times by 1 test
Evaluated by:
  • tst_qquickgridview
gridItem->endP...os + rowOffsetDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 50 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-58
823 gridItem->setPosition(colOffset, endPos + rowOffset);
executed 8 times by 1 test: gridItem->setPosition(colOffset, endPos + rowOffset);
Executed by:
  • tst_qquickgridview
8
824 }
executed 58 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
58
825 } else {-
826 gridItem->setPosition(colOffset, rowOffset);-
827 }
executed 190 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
190
828-
829 if (created)
createdDescription
TRUEevaluated 86 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 483 times by 1 test
Evaluated by:
  • tst_qquickgridview
86-483
830 emit q->footerItemChanged();
executed 86 times by 1 test: q->footerItemChanged();
Executed by:
  • tst_qquickgridview
86
831}
executed 569 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
569
832-
833void QQuickGridViewPrivate::updateHeader()-
834{-
835 Q_Q(QQuickGridView);-
836 bool created = false;-
837 if (!header) {
!headerDescription
TRUEevaluated 10557 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 524 times by 1 test
Evaluated by:
  • tst_qquickgridview
524-10557
838 QQuickItem *item = createComponentItem(headerComponent, 1.0);-
839 if (!item)
!itemDescription
TRUEevaluated 10431 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 126 times by 1 test
Evaluated by:
  • tst_qquickgridview
126-10431
840 return;
executed 10431 times by 4 tests: return;
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
10431
841 header = new FxGridItemSG(item, q, true);-
842 header->trackGeometry(true);-
843 created = true;-
844 }
executed 126 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
126
845-
846 FxGridItemSG *gridItem = static_cast<FxGridItemSG*>(header);-
847 qreal colOffset = 0;-
848 qreal rowOffset = -headerSize();-
849 if (q->effectiveLayoutDirection() == Qt::RightToLeft) {
q->effectiveLa...t::RightToLeftDescription
TRUEevaluated 169 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 481 times by 1 test
Evaluated by:
  • tst_qquickgridview
169-481
850 if (flow == QQuickGridView::FlowTopToBottom)
flow == QQuick...lowTopToBottomDescription
TRUEevaluated 82 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 87 times by 1 test
Evaluated by:
  • tst_qquickgridview
82-87
851 rowOffset += gridItem->item->width() - cellWidth;
executed 82 times by 1 test: rowOffset += gridItem->item->width() - cellWidth;
Executed by:
  • tst_qquickgridview
82
852 else-
853 colOffset += gridItem->item->width() - cellWidth;
executed 87 times by 1 test: colOffset += gridItem->item->width() - cellWidth;
Executed by:
  • tst_qquickgridview
87
854 }-
855 if (verticalLayoutDirection == QQuickItemView::BottomToTop) {
verticalLayout...w::BottomToTopDescription
TRUEevaluated 140 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 510 times by 1 test
Evaluated by:
  • tst_qquickgridview
140-510
856 if (flow == QQuickGridView::FlowTopToBottom)
flow == QQuick...lowTopToBottomDescription
TRUEevaluated 74 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 66 times by 1 test
Evaluated by:
  • tst_qquickgridview
66-74
857 colOffset += gridItem->item->height() - cellHeight;
executed 74 times by 1 test: colOffset += gridItem->item->height() - cellHeight;
Executed by:
  • tst_qquickgridview
74
858 else-
859 rowOffset += gridItem->item->height() - cellHeight;
executed 66 times by 1 test: rowOffset += gridItem->item->height() - cellHeight;
Executed by:
  • tst_qquickgridview
66
860 }-
861 if (visibleItems.count()) {
visibleItems.count()Description
TRUEevaluated 342 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 308 times by 1 test
Evaluated by:
  • tst_qquickgridview
308-342
862 qreal startPos = originPosition();-
863 if (visibleIndex == 0) {
visibleIndex == 0Description
TRUEevaluated 295 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 47 times by 1 test
Evaluated by:
  • tst_qquickgridview
47-295
864 gridItem->setPosition(colOffset, startPos + rowOffset);-
865 } else {
executed 295 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
295
866 qreal tempPos = isContentFlowReversed() ? -position()-size() : position();
isContentFlowReversed()Description
TRUEnever evaluated
FALSEevaluated 47 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-47
867 qreal headerPos = isContentFlowReversed() ? gridItem->rowPos() + cellWidth - headerSize() : gridItem->rowPos();
isContentFlowReversed()Description
TRUEnever evaluated
FALSEevaluated 47 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-47
868 if (tempPos <= startPos || headerPos > startPos + rowOffset)
tempPos <= startPosDescription
TRUEnever evaluated
FALSEevaluated 47 times by 1 test
Evaluated by:
  • tst_qquickgridview
headerPos > st...os + rowOffsetDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 41 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-47
869 gridItem->setPosition(colOffset, startPos + rowOffset);
executed 6 times by 1 test: gridItem->setPosition(colOffset, startPos + rowOffset);
Executed by:
  • tst_qquickgridview
6
870 }
executed 47 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
47
871 } else {-
872 if (isContentFlowReversed())
isContentFlowReversed()Description
TRUEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 228 times by 1 test
Evaluated by:
  • tst_qquickgridview
80-228
873 gridItem->setPosition(colOffset, rowOffset);
executed 80 times by 1 test: gridItem->setPosition(colOffset, rowOffset);
Executed by:
  • tst_qquickgridview
80
874 else-
875 gridItem->setPosition(colOffset, -headerSize());
executed 228 times by 1 test: gridItem->setPosition(colOffset, -headerSize());
Executed by:
  • tst_qquickgridview
228
876 }-
877-
878 if (created)
createdDescription
TRUEevaluated 126 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 524 times by 1 test
Evaluated by:
  • tst_qquickgridview
126-524
879 emit q->headerItemChanged();
executed 126 times by 1 test: q->headerItemChanged();
Executed by:
  • tst_qquickgridview
126
880}
executed 650 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
650
881-
882void QQuickGridViewPrivate::initializeCurrentItem()-
883{-
884 if (currentItem && currentIndex >= 0) {
currentItemDescription
TRUEevaluated 3088 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEnever evaluated
currentIndex >= 0Description
TRUEevaluated 3088 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEnever evaluated
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()))
!actualItemDescription
TRUEevaluated 131 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 2957 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
!actualItem->t...ledOrRunning()Description
TRUEevaluated 2861 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 96 times by 1 test
Evaluated by:
  • tst_qquickgridview
96-2957
890 gridItem->setPosition(colPosAt(currentIndex), rowPosAt(currentIndex));
executed 2992 times by 4 tests: gridItem->setPosition(colPosAt(currentIndex), rowPosAt(currentIndex));
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
2992
891 }
executed 3088 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
3088
892}
executed 3088 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
3088
893-
894void QQuickGridViewPrivate::fixupPosition()-
895{-
896 if (flow == QQuickGridView::FlowLeftToRight)
flow == QQuick...lowLeftToRightDescription
TRUEevaluated 3845 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 2114 times by 1 test
Evaluated by:
  • tst_qquickgridview
2114-3845
897 fixupY();
executed 3845 times by 4 tests: fixupY();
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
3845
898 else-
899 fixupX();
executed 2114 times by 1 test: fixupX();
Executed by:
  • tst_qquickgridview
2114
900}-
901-
902void QQuickGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent)-
903{-
904 if ((flow == QQuickGridView::FlowTopToBottom && &data == &vData)
flow == QQuick...lowTopToBottomDescription
TRUEevaluated 3544 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 6293 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
&data == &vDataDescription
TRUEevaluated 222 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 3322 times by 1 test
Evaluated by:
  • tst_qquickgridview
222-6293
905 || (flow == QQuickGridView::FlowLeftToRight && &data == &hData))
flow == QQuick...lowLeftToRightDescription
TRUEevaluated 6293 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 3322 times by 1 test
Evaluated by:
  • tst_qquickgridview
&data == &hDataDescription
TRUEevaluated 176 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 6117 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
176-6293
906 return;
executed 398 times by 4 tests: return;
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
398
907-
908 fixupMode = moveReason == Mouse ? fixupMode : Immediate;
moveReason == MouseDescription
TRUEevaluated 196 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 9243 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
196-9243
909-
910 qreal viewPos = isContentFlowReversed() ? -position()-size() : position();
isContentFlowReversed()Description
TRUEevaluated 3055 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 6384 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
3055-6384
911-
912 bool strictHighlightRange = haveHighlightRange && highlightRange == QQuickGridView::StrictlyEnforceRange;
haveHighlightRangeDescription
TRUEevaluated 301 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 9138 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
highlightRange...lyEnforceRangeDescription
TRUEevaluated 297 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickgridview
4-9138
913 if (snapMode != QQuickGridView::NoSnap) {
snapMode != QQ...idView::NoSnapDescription
TRUEevaluated 348 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 9091 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
348-9091
914 qreal tempPosition = isContentFlowReversed() ? -position()-size() : position();
isContentFlowReversed()Description
TRUEevaluated 171 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 177 times by 1 test
Evaluated by:
  • tst_qquickgridview
171-177
915 if (snapMode == QQuickGridView::SnapOneRow && moveReason == Mouse) {
snapMode == QQ...ew::SnapOneRowDescription
TRUEevaluated 176 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 172 times by 1 test
Evaluated by:
  • tst_qquickgridview
moveReason == MouseDescription
TRUEevaluated 88 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 88 times by 1 test
Evaluated by:
  • tst_qquickgridview
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)
data.velocity > 0Description
TRUEevaluated 42 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 46 times by 1 test
Evaluated by:
  • tst_qquickgridview
dist > 30Description
TRUEevaluated 42 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
dist < rowSize()/2Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 32 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-46
920 bias = rowSize()/2;
executed 10 times by 1 test: bias = rowSize()/2;
Executed by:
  • tst_qquickgridview
10
921 else if (data.velocity < 0 && dist < -QML_FLICK_SNAPONETHRESHOLD && dist > -rowSize()/2)
data.velocity < 0Description
TRUEevaluated 46 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 32 times by 1 test
Evaluated by:
  • tst_qquickgridview
dist < -30Description
TRUEevaluated 44 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
dist > -rowSize()/2Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 30 times by 1 test
Evaluated by:
  • tst_qquickgridview
2-46
922 bias = -rowSize()/2;
executed 14 times by 1 test: bias = -rowSize()/2;
Executed by:
  • tst_qquickgridview
14
923 if (isContentFlowReversed())
isContentFlowReversed()Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 66 times by 1 test
Evaluated by:
  • tst_qquickgridview
22-66
924 bias = -bias;
executed 22 times by 1 test: bias = -bias;
Executed by:
  • tst_qquickgridview
22
925 tempPosition -= bias;-
926 }
executed 88 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
88
927 FxViewItem *topItem = snapItemAt(tempPosition+highlightRangeStart);-
928 if (strictHighlightRange && currentItem && (!topItem || (topItem->index != currentIndex && fixupMode == Immediate))) {
strictHighlightRangeDescription
TRUEevaluated 237 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 111 times by 1 test
Evaluated by:
  • tst_qquickgridview
currentItemDescription
TRUEevaluated 169 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 68 times by 1 test
Evaluated by:
  • tst_qquickgridview
!topItemDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 157 times by 1 test
Evaluated by:
  • tst_qquickgridview
topItem->index != currentIndexDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 145 times by 1 test
Evaluated by:
  • tst_qquickgridview
fixupMode == ImmediateDescription
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-237
929 // StrictlyEnforceRange always keeps an item in range-
930 updateHighlight();-
931 topItem = currentItem;-
932 }
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
12
933 FxViewItem *bottomItem = snapItemAt(tempPosition+highlightRangeEnd);-
934 if (strictHighlightRange && currentItem && (!bottomItem || (bottomItem->index != currentIndex && fixupMode == Immediate))) {
strictHighlightRangeDescription
TRUEevaluated 237 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 111 times by 1 test
Evaluated by:
  • tst_qquickgridview
currentItemDescription
TRUEevaluated 169 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 68 times by 1 test
Evaluated by:
  • tst_qquickgridview
!bottomItemDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 155 times by 1 test
Evaluated by:
  • tst_qquickgridview
bottomItem->in...= currentIndexDescription
TRUEevaluated 143 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickgridview
fixupMode == ImmediateDescription
TRUEevaluated 67 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 76 times by 1 test
Evaluated by:
  • tst_qquickgridview
12-237
935 // StrictlyEnforceRange always keeps an item in range-
936 updateHighlight();-
937 bottomItem = currentItem;-
938 }
executed 81 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
81
939 qreal pos;-
940 bool isInBounds = -position() > maxExtent && -position() <= minExtent;
-position() > maxExtentDescription
TRUEevaluated 263 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 85 times by 1 test
Evaluated by:
  • tst_qquickgridview
-position() <= minExtentDescription
TRUEevaluated 238 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 25 times by 1 test
Evaluated by:
  • tst_qquickgridview
25-263
941 if (topItem && (isInBounds || strictHighlightRange)) {
topItemDescription
TRUEevaluated 278 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 70 times by 1 test
Evaluated by:
  • tst_qquickgridview
isInBoundsDescription
TRUEevaluated 168 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 110 times by 1 test
Evaluated by:
  • tst_qquickgridview
strictHighlightRangeDescription
TRUEevaluated 79 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 31 times by 1 test
Evaluated by:
  • tst_qquickgridview
31-278
942 qreal headerPos = header ? static_cast<FxGridItemSG*>(header)->rowPos() : 0;
headerDescription
TRUEnever evaluated
FALSEevaluated 247 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-247
943 if (topItem->index == 0 && header && tempPosition+highlightRangeStart < headerPos+headerSize()/2 && !strictHighlightRange) {
topItem->index == 0Description
TRUEevaluated 95 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 152 times by 1 test
Evaluated by:
  • tst_qquickgridview
headerDescription
TRUEnever evaluated
FALSEevaluated 95 times by 1 test
Evaluated by:
  • tst_qquickgridview
tempPosition+h...headerSize()/2Description
TRUEnever evaluated
FALSEnever evaluated
!strictHighlightRangeDescription
TRUEnever evaluated
FALSEnever evaluated
0-152
944 pos = isContentFlowReversed() ? - headerPos + highlightRangeStart - size() : headerPos - highlightRangeStart;
isContentFlowReversed()Description
TRUEnever evaluated
FALSEnever evaluated
0
945 } else {
never executed: end of block
0
946 if (isContentFlowReversed())
isContentFlowReversed()Description
TRUEevaluated 103 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 144 times by 1 test
Evaluated by:
  • tst_qquickgridview
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:
  • tst_qquickgridview
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:
  • tst_qquickgridview
144
950 }-
951 } else if (bottomItem && isInBounds) {
bottomItemDescription
TRUEevaluated 25 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 76 times by 1 test
Evaluated by:
  • tst_qquickgridview
isInBoundsDescription
TRUEnever evaluated
FALSEevaluated 25 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-76
952 if (isContentFlowReversed())
isContentFlowReversed()Description
TRUEnever evaluated
FALSEnever evaluated
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:
  • tst_qquickgridview
101
959 }-
960-
961 qreal dist = qAbs(data.move + pos);-
962 if (dist > 0) {
dist > 0Description
TRUEevaluated 138 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 109 times by 1 test
Evaluated by:
  • tst_qquickgridview
109-138
963 timeline.reset(data.move);-
964 if (fixupMode != Immediate) {
fixupMode != ImmediateDescription
TRUEevaluated 112 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_qquickgridview
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 block
Executed by:
  • tst_qquickgridview
112
968 timeline.set(data.move, -pos);-
969 }
executed 26 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
26
970 vTime = timeline.time();-
971 }
executed 138 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
138
972 } else if (haveHighlightRange && highlightRange == QQuickGridView::StrictlyEnforceRange) {
executed 247 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
haveHighlightRangeDescription
TRUEevaluated 60 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 9031 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
highlightRange...lyEnforceRangeDescription
TRUEevaluated 60 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
0-9031
973 if (currentItem) {
currentItemDescription
TRUEevaluated 44 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickgridview
16-44
974 updateHighlight();-
975 qreal pos = static_cast<FxGridItemSG*>(currentItem)->rowPos();-
976 if (viewPos < pos + rowSize() - highlightRangeEnd)
viewPos < pos ...hlightRangeEndDescription
TRUEevaluated 32 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickgridview
12-32
977 viewPos = pos + rowSize() - highlightRangeEnd;
executed 32 times by 1 test: viewPos = pos + rowSize() - highlightRangeEnd;
Executed by:
  • tst_qquickgridview
32
978 if (viewPos > pos - highlightRangeStart)
viewPos > pos ...ightRangeStartDescription
TRUEevaluated 44 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
0-44
979 viewPos = pos - highlightRangeStart;
executed 44 times by 1 test: viewPos = pos - highlightRangeStart;
Executed by:
  • tst_qquickgridview
44
980 if (isContentFlowReversed())
isContentFlowReversed()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_qquickgridview
2-42
981 viewPos = -viewPos-size();
executed 2 times by 1 test: viewPos = -viewPos-size();
Executed by:
  • tst_qquickgridview
2
982 timeline.reset(data.move);-
983 if (viewPos != position()) {
viewPos != position()Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 30 times by 1 test
Evaluated by:
  • tst_qquickgridview
14-30
984 if (fixupMode != Immediate) {
fixupMode != ImmediateDescription
TRUEnever evaluated
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquickgridview
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 block
Executed by:
  • tst_qquickgridview
14
990 }-
991 vTime = timeline.time();-
992 }
executed 44 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
44
993 } else {
executed 60 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
60
994 QQuickItemViewPrivate::fixup(data, minExtent, maxExtent);-
995 }
executed 9031 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
9031
996 data.inOvershoot = false;-
997 fixupMode = Normal;-
998}
executed 9338 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
9338
999-
1000bool 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)
!haveHighlightRangeDescription
TRUEevaluated 90 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 90 times by 1 test
Evaluated by:
  • tst_qquickgridview
highlightRange...lyEnforceRangeDescription
TRUEnever evaluated
FALSEevaluated 90 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-90
1006 && snapMode == QQuickGridView::NoSnap) {
snapMode == QQ...idView::NoSnapDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 78 times by 1 test
Evaluated by:
  • tst_qquickgridview
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:
  • tst_qquickgridview
12
1008 }-
1009 qreal maxDistance = 0;-
1010 qreal dataValue = isContentFlowReversed() ? -data.move.value()+size() : data.move.value();
isContentFlowReversed()Description
TRUEevaluated 56 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 112 times by 1 test
Evaluated by:
  • tst_qquickgridview
56-112
1011 // -ve velocity means list is moving up/left-
1012 if (velocity > 0) {
velocity > 0Description
TRUEevaluated 82 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 86 times by 1 test
Evaluated by:
  • tst_qquickgridview
82-86
1013 if (data.move.value() < minExtent) {
data.move.value() < minExtentDescription
TRUEevaluated 74 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickgridview
8-74
1014 if (snapMode == QQuickGridView::SnapOneRow) {
snapMode == QQ...ew::SnapOneRowDescription
TRUEevaluated 30 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 44 times by 1 test
Evaluated by:
  • tst_qquickgridview
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;
dist < rowSize()/2Description
TRUEnever evaluated
FALSEevaluated 30 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-30
1018 if (isContentFlowReversed())
isContentFlowReversed()Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickgridview
10-20
1019 bias = -bias;
executed 10 times by 1 test: bias = -bias;
Executed by:
  • tst_qquickgridview
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 block
Executed by:
  • tst_qquickgridview
30
1024 maxDistance = qAbs(minExtent - data.move.value());-
1025 }
executed 44 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
44
1026 }-
1027 if (snapMode == QQuickGridView::NoSnap && highlightRange != QQuickGridView::StrictlyEnforceRange)
snapMode == QQ...idView::NoSnapDescription
TRUEnever evaluated
FALSEevaluated 82 times by 1 test
Evaluated by:
  • tst_qquickgridview
highlightRange...lyEnforceRangeDescription
TRUEnever evaluated
FALSEnever evaluated
0-82
1028 data.flickTarget = minExtent;
never executed: data.flickTarget = minExtent;
0
1029 } else {
executed 82 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
82
1030 if (data.move.value() > maxExtent) {
data.move.value() > maxExtentDescription
TRUEevaluated 76 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquickgridview
10-76
1031 if (snapMode == QQuickGridView::SnapOneRow) {
snapMode == QQ...ew::SnapOneRowDescription
TRUEevaluated 30 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 46 times by 1 test
Evaluated by:
  • tst_qquickgridview
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;
-dist < rowSize()/2Description
TRUEnever evaluated
FALSEevaluated 30 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-30
1035 if (isContentFlowReversed())
isContentFlowReversed()Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickgridview
10-20
1036 bias = -bias;
executed 10 times by 1 test: bias = -bias;
Executed by:
  • tst_qquickgridview
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 block
Executed by:
  • tst_qquickgridview
30
1041 maxDistance = qAbs(maxExtent - data.move.value());-
1042 }
executed 46 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
46
1043 }-
1044 if (snapMode == QQuickGridView::NoSnap && highlightRange != QQuickGridView::StrictlyEnforceRange)
snapMode == QQ...idView::NoSnapDescription
TRUEnever evaluated
FALSEevaluated 86 times by 1 test
Evaluated by:
  • tst_qquickgridview
highlightRange...lyEnforceRangeDescription
TRUEnever evaluated
FALSEnever evaluated
0-86
1045 data.flickTarget = maxExtent;
never executed: data.flickTarget = maxExtent;
0
1046 }
executed 86 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
86
1047 bool overShoot = boundsBehavior & QQuickFlickable::OvershootBounds;-
1048 if (maxDistance > 0 || overShoot) {
maxDistance > 0Description
TRUEevaluated 150 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquickgridview
overShootDescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
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)) {
maxVelocity != -1Description
TRUEevaluated 168 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
maxVelocity < qAbs(v)Description
TRUEnever evaluated
FALSEevaluated 168 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-168
1052 if (v < 0)
v < 0Description
TRUEnever evaluated
FALSEnever evaluated
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) {
maxDistance > 0.0Description
TRUEevaluated 150 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquickgridview
v2 / (2.0f * m...tance) < accelDescription
TRUEevaluated 78 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 72 times by 1 test
Evaluated by:
  • tst_qquickgridview
snapMode == QQ...ew::SnapOneRowDescription
TRUEevaluated 66 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickgridview
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)
v > 0Description
TRUEevaluated 70 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 74 times by 1 test
Evaluated by:
  • tst_qquickgridview
70-74
1065 dist = -dist;
executed 70 times by 1 test: dist = -dist;
Executed by:
  • tst_qquickgridview
70
1066 if (snapMode != QQuickGridView::SnapOneRow) {
snapMode != QQ...ew::SnapOneRowDescription
TRUEevaluated 78 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 66 times by 1 test
Evaluated by:
  • tst_qquickgridview
66-78
1067 qreal distTemp = isContentFlowReversed() ? -dist : dist;
isContentFlowReversed()Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 52 times by 1 test
Evaluated by:
  • tst_qquickgridview
26-52
1068 data.flickTarget = -snapPosAt(-dataValue + distTemp);-
1069 }
executed 78 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
78
1070 data.flickTarget = isContentFlowReversed() ? -data.flickTarget+size() : data.flickTarget;
isContentFlowReversed()Description
TRUEevaluated 48 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 96 times by 1 test
Evaluated by:
  • tst_qquickgridview
48-96
1071 if (overShoot) {
overShootDescription
TRUEevaluated 144 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
0-144
1072 if (data.flickTarget >= minExtent) {
data.flickTarget >= minExtentDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 134 times by 1 test
Evaluated by:
  • tst_qquickgridview
10-134
1073 overshootDist = overShootDistance(vSize);-
1074 data.flickTarget += overshootDist;-
1075 } else if (data.flickTarget <= maxExtent) {
executed 10 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
data.flickTarget <= maxExtentDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 124 times by 1 test
Evaluated by:
  • tst_qquickgridview
10-124
1076 overshootDist = overShootDistance(vSize);-
1077 data.flickTarget -= overshootDist;-
1078 }
executed 10 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
10
1079 }
executed 144 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
144
1080 qreal adjDist = -data.flickTarget + data.move.value();-
1081 if (qAbs(adjDist) > qAbs(dist)) {
qAbs(adjDist) > qAbs(dist)Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 122 times by 1 test
Evaluated by:
  • tst_qquickgridview
22-122
1082 // Prevent painfully slow flicking - adjust velocity to suit flickDeceleration-
1083 qreal adjv2 = accel * 2.0f * qAbs(adjDist);-
1084 if (adjv2 > v2) {
adjv2 > v2Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickgridview
10-12
1085 v2 = adjv2;-
1086 v = qSqrt(v2);-
1087 if (dist > 0)
dist > 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickgridview
4-6
1088 v = -v;
executed 4 times by 1 test: v = -v;
Executed by:
  • tst_qquickgridview
4
1089 }
executed 10 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
10
1090 }
executed 22 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
22
1091 dist = adjDist;-
1092 accel = v2 / (2.0f * qAbs(dist));-
1093 } else {
executed 144 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
144
1094 data.flickTarget = velocity > 0 ? minExtent : maxExtent;
velocity > 0Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickgridview
12
1095 overshootDist = overShoot ? overShootDistance(vSize) : 0;
overShootDescription
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
0-24
1096 }
executed 24 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
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:
  • tst_qquickgridview
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-
1240QQuickGridView::QQuickGridView(QQuickItem *parent)-
1241 : QQuickItemView(*(new QQuickGridViewPrivate), parent)-
1242{-
1243}
executed 1782 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
1782
1244-
1245QQuickGridView::~QQuickGridView()-
1246{-
1247}-
1248-
1249void QQuickGridView::setHighlightFollowsCurrentItem(bool autoHighlight)-
1250{-
1251 Q_D(QQuickGridView);-
1252 if (d->autoHighlight != autoHighlight) {
d->autoHighlig... autoHighlightDescription
TRUEevaluated 8 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
FALSEnever evaluated
0-8
1253 if (!autoHighlight && d->highlightXAnimator) {
!autoHighlightDescription
TRUEevaluated 8 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
FALSEnever evaluated
d->highlightXAnimatorDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
0-8
1254 d->highlightXAnimator->stop();-
1255 d->highlightYAnimator->stop();-
1256 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
2
1257 QQuickItemView::setHighlightFollowsCurrentItem(autoHighlight);-
1258 }
executed 8 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
8
1259}
executed 8 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
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-
1583void QQuickGridView::setHighlightMoveDuration(int duration)-
1584{-
1585 Q_D(QQuickGridView);-
1586 if (d->highlightMoveDuration != duration) {
d->highlightMo...on != durationDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
0-6
1587 if (d->highlightYAnimator) {
d->highlightYAnimatorDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickgridview
2-4
1588 d->highlightXAnimator->userDuration = duration;-
1589 d->highlightYAnimator->userDuration = duration;-
1590 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
2
1591 QQuickItemView::setHighlightMoveDuration(duration);-
1592 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
6
1593}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
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*/-
1606QQuickGridView::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:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
1044191
1610}-
1611-
1612void QQuickGridView::setFlow(Flow flow)-
1613{-
1614 Q_D(QQuickGridView);-
1615 if (d->flow != flow) {
d->flow != flowDescription
TRUEevaluated 666 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 638 times by 1 test
Evaluated by:
  • tst_qquickgridview
638-666
1616 d->flow = flow;-
1617 if (d->flow == FlowLeftToRight) {
d->flow == FlowLeftToRightDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 650 times by 1 test
Evaluated by:
  • tst_qquickgridview
16-650
1618 setContentWidth(-1);-
1619 setFlickableDirection(VerticalFlick);-
1620 } else {
executed 16 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
16
1621 setContentHeight(-1);-
1622 setFlickableDirection(HorizontalFlick);-
1623 }
executed 650 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
650
1624 setContentX(0);-
1625 setContentY(0);-
1626 d->regenerate(true);-
1627 emit flowChanged();-
1628 }
executed 666 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
666
1629}
executed 1304 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
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*/-
1640qreal QQuickGridView::cellWidth() const-
1641{-
1642 Q_D(const QQuickGridView);-
1643 return d->cellWidth;
executed 313945 times by 2 tests: return d->cellWidth;
Executed by:
  • tst_examples
  • tst_qquickgridview
313945
1644}-
1645-
1646void QQuickGridView::setCellWidth(qreal cellWidth)-
1647{-
1648 Q_D(QQuickGridView);-
1649 if (cellWidth != d->cellWidth && cellWidth > 0) {
cellWidth != d->cellWidthDescription
TRUEevaluated 1740 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
FALSEevaluated 10 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
cellWidth > 0Description
TRUEevaluated 1740 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
FALSEnever evaluated
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 block
Executed by:
  • tst_examples
  • tst_qquickgridview
1740
1655}
executed 1750 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
1750
1656-
1657qreal QQuickGridView::cellHeight() const-
1658{-
1659 Q_D(const QQuickGridView);-
1660 return d->cellHeight;
executed 182823 times by 3 tests: return d->cellHeight;
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
182823
1661}-
1662-
1663void QQuickGridView::setCellHeight(qreal cellHeight)-
1664{-
1665 Q_D(QQuickGridView);-
1666 if (cellHeight != d->cellHeight && cellHeight > 0) {
cellHeight != d->cellHeightDescription
TRUEevaluated 1686 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
FALSEevaluated 56 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
cellHeight > 0Description
TRUEevaluated 1686 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
FALSEnever evaluated
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 block
Executed by:
  • tst_examples
  • tst_qquickgridview
1686
1672}
executed 1742 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
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*/-
1689QQuickGridView::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:
  • tst_qquickgridview
2
1693}-
1694-
1695void QQuickGridView::setSnapMode(SnapMode mode)-
1696{-
1697 Q_D(QQuickGridView);-
1698 if (d->snapMode != mode) {
d->snapMode != modeDescription
TRUEevaluated 32 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
0-32
1699 d->snapMode = mode;-
1700 emit snapModeChanged();-
1701 }
executed 32 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
32
1702}
executed 32 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
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-
2027void QQuickGridView::viewportMoved(Qt::Orientations orient)-
2028{-
2029 Q_D(QQuickGridView);-
2030 QQuickItemView::viewportMoved(orient);-
2031 if (!d->itemCount)
!d->itemCountDescription
TRUEevaluated 1054 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 6739 times by 1 test
Evaluated by:
  • tst_qquickgridview
1054-6739
2032 return;
executed 1054 times by 1 test: return;
Executed by:
  • tst_qquickgridview
1054
2033 if (d->inViewportMoved)
d->inViewportMovedDescription
TRUEevaluated 19 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 6720 times by 1 test
Evaluated by:
  • tst_qquickgridview
19-6720
2034 return;
executed 19 times by 1 test: return;
Executed by:
  • tst_qquickgridview
19
2035 d->inViewportMoved = true;-
2036-
2037 if (yflick()) {
yflick()Description
TRUEevaluated 3105 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 3615 times by 1 test
Evaluated by:
  • tst_qquickgridview
3105-3615
2038 if (d->isContentFlowReversed())
d->isContentFlowReversed()Description
TRUEevaluated 190 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 2915 times by 1 test
Evaluated by:
  • tst_qquickgridview
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:
  • tst_qquickgridview
d->vData.smoothVelocity < 0Description
TRUEnever evaluated
FALSEevaluated 190 times by 1 test
Evaluated by:
  • tst_qquickgridview
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:
  • tst_qquickgridview
d->vData.smoothVelocity < 0Description
TRUEevaluated 1222 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 1693 times by 1 test
Evaluated by:
  • tst_qquickgridview
1222-2915
2042 } else {-
2043 if (d->isContentFlowReversed())
d->isContentFlowReversed()Description
TRUEevaluated 1844 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 1771 times by 1 test
Evaluated by:
  • tst_qquickgridview
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:
  • tst_qquickgridview
d->hData.smoothVelocity < 0Description
TRUEevaluated 737 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 1107 times by 1 test
Evaluated by:
  • tst_qquickgridview
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:
  • tst_qquickgridview
d->hData.smoothVelocity < 0Description
TRUEevaluated 766 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 1005 times by 1 test
Evaluated by:
  • tst_qquickgridview
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;
d->isContentFlowReversed()Description
TRUEevaluated 2034 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 4686 times by 1 test
Evaluated by:
  • tst_qquickgridview
2034-4686
2053 qreal to = d->isContentFlowReversed() ? -d->position()+d->displayMarginEnd : d->position()+d->size()+d->displayMarginEnd;
d->isContentFlowReversed()Description
TRUEevaluated 2034 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 4686 times by 1 test
Evaluated by:
  • tst_qquickgridview
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 block
Executed by:
  • tst_qquickgridview
142751
2058 if (d->currentItem) {
d->currentItemDescription
TRUEevaluated 6720 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
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 block
Executed by:
  • tst_qquickgridview
6720
2062-
2063 if (d->hData.flicking || d->vData.flicking || d->hData.moving || d->vData.moving)
d->hData.flickingDescription
TRUEevaluated 2558 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 4162 times by 1 test
Evaluated by:
  • tst_qquickgridview
d->vData.flickingDescription
TRUEevaluated 1425 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 2737 times by 1 test
Evaluated by:
  • tst_qquickgridview
d->hData.movingDescription
TRUEevaluated 440 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 2297 times by 1 test
Evaluated by:
  • tst_qquickgridview
d->vData.movingDescription
TRUEevaluated 657 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 1640 times by 1 test
Evaluated by:
  • tst_qquickgridview
440-4162
2064 d->moveReason = QQuickGridViewPrivate::Mouse;
executed 5080 times by 1 test: d->moveReason = QQuickGridViewPrivate::Mouse;
Executed by:
  • tst_qquickgridview
5080
2065 if (d->moveReason != QQuickGridViewPrivate::SetIndex) {
d->moveReason ...vate::SetIndexDescription
TRUEevaluated 6243 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 477 times by 1 test
Evaluated by:
  • tst_qquickgridview
477-6243
2066 if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) {
d->haveHighlightRangeDescription
TRUEevaluated 2472 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 3771 times by 1 test
Evaluated by:
  • tst_qquickgridview
d->highlightRa...lyEnforceRangeDescription
TRUEevaluated 2472 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
d->highlightDescription
TRUEevaluated 2472 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
0-3771
2067 // reposition highlight-
2068 qreal pos = d->highlight->position();-
2069 qreal viewPos = d->isContentFlowReversed() ? -d->position()-d->size() : d->position();
d->isContentFlowReversed()Description
TRUEevaluated 736 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 1736 times by 1 test
Evaluated by:
  • tst_qquickgridview
736-1736
2070 if (pos > viewPos + d->highlightRangeEnd - d->highlight->size())
pos > viewPos ...hlight->size()Description
TRUEevaluated 1277 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 1195 times by 1 test
Evaluated by:
  • tst_qquickgridview
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:
  • tst_qquickgridview
1277
2072 if (pos < viewPos + d->highlightRangeStart)
pos < viewPos ...ightRangeStartDescription
TRUEevaluated 1295 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 1177 times by 1 test
Evaluated by:
  • tst_qquickgridview
1177-1295
2073 pos = viewPos + d->highlightRangeStart;
executed 1295 times by 1 test: pos = viewPos + d->highlightRangeStart;
Executed by:
  • tst_qquickgridview
1295
2074-
2075 if (pos != d->highlight->position()) {
pos != d->high...ht->position()Description
TRUEevaluated 2446 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_qquickgridview
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 block
Executed by:
  • tst_qquickgridview
2446
2080 d->updateHighlight();-
2081 }
executed 26 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
26
2082-
2083 // update current index-
2084 int idx = d->snapIndex();-
2085 if (idx >= 0 && idx != d->currentIndex) {
idx >= 0Description
TRUEevaluated 2472 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
idx != d->currentIndexDescription
TRUEevaluated 222 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 2250 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-2472
2086 d->updateCurrent(idx);-
2087 if (d->currentItem && static_cast<FxGridItemSG*>(d->currentItem)->colPos() != static_cast<FxGridItemSG*>(d->highlight)->colPos() && d->autoHighlight) {
d->currentItemDescription
TRUEevaluated 222 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
static_cast<Fx...ght)->colPos()Description
TRUEnever evaluated
FALSEevaluated 222 times by 1 test
Evaluated by:
  • tst_qquickgridview
d->autoHighlightDescription
TRUEnever evaluated
FALSEnever evaluated
0-222
2088 if (d->flow == FlowLeftToRight)
d->flow == FlowLeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
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 block
Executed by:
  • tst_qquickgridview
222
2094 }
executed 2472 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
2472
2095 }
executed 6243 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
6243
2096-
2097 d->inViewportMoved = false;-
2098}
executed 6720 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
6720
2099-
2100void QQuickGridView::keyPressEvent(QKeyEvent *event)-
2101{-
2102 Q_D(QQuickGridView);-
2103 if (d->model && d->model->count() && ((d->interactive && !d->explicitKeyNavigationEnabled)
d->model->count()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
d->interactiveDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickgridview
!d->explicitKe...igationEnabledDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-6
2104 || (d->explicitKeyNavigationEnabled && d->keyNavigationEnabled))) {
d->explicitKey...igationEnabledDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
d->keyNavigationEnabledDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
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:
  • tst_qquickgridview
2
2118 moveCurrentIndexRight();-
2119 break;
executed 2 times by 1 test: break;
Executed by:
  • tst_qquickgridview
2
2120 default:
never executed: default:
0
2121 break;
never executed: break;
0
2122 }-
2123 if (oldCurrent != currentIndex() || d->wrap) {
oldCurrent != currentIndex()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
d->wrapDescription
TRUEnever evaluated
FALSEnever evaluated
0-2
2124 event->accept();-
2125 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_qquickgridview
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 block
Executed by:
  • tst_qquickgridview
4
2131-
2132void QQuickGridView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)-
2133{-
2134 Q_D(QQuickGridView);-
2135 d->resetColumns();-
2136-
2137 if (newGeometry.width() != oldGeometry.width()
newGeometry.wi...ometry.width()Description
TRUEevaluated 1802 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 1942 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
1802-1942
2138 && newGeometry.height() != oldGeometry.height()) {
newGeometry.he...metry.height()Description
TRUEevaluated 88 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEevaluated 1714 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
88-1714
2139 d->setPosition(d->position());-
2140 } else if (newGeometry.width() != oldGeometry.width()) {
executed 88 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
newGeometry.wi...ometry.width()Description
TRUEevaluated 1714 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
FALSEevaluated 1942 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
88-1942
2141 QQuickFlickable::setContentX(d->contentXForPosition(d->position()));-
2142 } else if (newGeometry.height() != oldGeometry.height()) {
executed 1714 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
newGeometry.he...metry.height()Description
TRUEevaluated 1720 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
FALSEevaluated 222 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
222-1720
2143 QQuickFlickable::setContentY(d->contentYForPosition(d->position()));-
2144 }
executed 1720 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
1720
2145-
2146 QQuickItemView::geometryChanged(newGeometry, oldGeometry);-
2147}
executed 3744 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
3744
2148-
2149void 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) {
itemDescription
TRUEevaluated 46119 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEnever evaluated
0-46119
2157 QQuickGridViewAttached *attached = static_cast<QQuickGridViewAttached *>(-
2158 qmlAttachedPropertiesObject<QQuickGridView>(item));-
2159 if (attached)
attachedDescription
TRUEevaluated 46119 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
FALSEnever evaluated
0-46119
2160 attached->setView(this);
executed 46119 times by 4 tests: attached->setView(this);
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
46119
2161 }
executed 46119 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
46119
2162}
executed 46119 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
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-
2175void QQuickGridView::moveCurrentIndexUp()-
2176{-
2177 Q_D(QQuickGridView);-
2178 const int count = d->model ? d->model->count() : 0;
d->modelDescription
TRUEnever evaluated
FALSEnever evaluated
0
2179 if (!count)
!countDescription
TRUEnever evaluated
FALSEnever evaluated
0
2180 return;
never executed: return;
0
2181 if (d->verticalLayoutDirection == QQuickItemView::TopToBottom) {
d->verticalLay...w::TopToBottomDescription
TRUEnever evaluated
FALSEnever evaluated
0
2182 if (d->flow == QQuickGridView::FlowLeftToRight) {
d->flow == QQu...lowLeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2183 if (currentIndex() >= d->columns || d->wrap) {
currentIndex() >= d->columnsDescription
TRUEnever evaluated
FALSEnever evaluated
d->wrapDescription
TRUEnever evaluated
FALSEnever evaluated
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) {
currentIndex() > 0Description
TRUEnever evaluated
FALSEnever evaluated
d->wrapDescription
TRUEnever evaluated
FALSEnever evaluated
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) {
d->flow == QQu...lowLeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2195 if (currentIndex() < count - d->columns || d->wrap) {
currentIndex()...t - d->columnsDescription
TRUEnever evaluated
FALSEnever evaluated
d->wrapDescription
TRUEnever evaluated
FALSEnever evaluated
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) {
currentIndex() < count - 1Description
TRUEnever evaluated
FALSEnever evaluated
d->wrapDescription
TRUEnever evaluated
FALSEnever evaluated
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*/-
2217void QQuickGridView::moveCurrentIndexDown()-
2218{-
2219 Q_D(QQuickGridView);-
2220 const int count = d->model ? d->model->count() : 0;
d->modelDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
0-2
2221 if (!count)
!countDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-2
2222 return;
never executed: return;
0
2223-
2224 if (d->verticalLayoutDirection == QQuickItemView::TopToBottom) {
d->verticalLay...w::TopToBottomDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
0-2
2225 if (d->flow == QQuickGridView::FlowLeftToRight) {
d->flow == QQu...lowLeftToRightDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
0-2
2226 if (currentIndex() < count - d->columns || d->wrap) {
currentIndex()...t - d->columnsDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
d->wrapDescription
TRUEnever evaluated
FALSEnever evaluated
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 block
Executed by:
  • tst_qquickgridview
2
2230 } else {
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
2
2231 if (currentIndex() < count - 1 || d->wrap) {
currentIndex() < count - 1Description
TRUEnever evaluated
FALSEnever evaluated
d->wrapDescription
TRUEnever evaluated
FALSEnever evaluated
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) {
d->flow == QQu...lowLeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2238 if (currentIndex() >= d->columns || d->wrap) {
currentIndex() >= d->columnsDescription
TRUEnever evaluated
FALSEnever evaluated
d->wrapDescription
TRUEnever evaluated
FALSEnever evaluated
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) {
currentIndex() > 0Description
TRUEnever evaluated
FALSEnever evaluated
d->wrapDescription
TRUEnever evaluated
FALSEnever evaluated
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*/-
2260void QQuickGridView::moveCurrentIndexLeft()-
2261{-
2262 Q_D(QQuickGridView);-
2263 const int count = d->model ? d->model->count() : 0;
d->modelDescription
TRUEnever evaluated
FALSEnever evaluated
0
2264 if (!count)
!countDescription
TRUEnever evaluated
FALSEnever evaluated
0
2265 return;
never executed: return;
0
2266 if (effectiveLayoutDirection() == Qt::LeftToRight) {
effectiveLayou...t::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2267 if (d->flow == QQuickGridView::FlowLeftToRight) {
d->flow == QQu...lowLeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2268 if (currentIndex() > 0 || d->wrap) {
currentIndex() > 0Description
TRUEnever evaluated
FALSEnever evaluated
d->wrapDescription
TRUEnever evaluated
FALSEnever evaluated
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) {
currentIndex() >= d->columnsDescription
TRUEnever evaluated
FALSEnever evaluated
d->wrapDescription
TRUEnever evaluated
FALSEnever evaluated
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) {
d->flow == QQu...lowLeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2280 if (currentIndex() < count - 1 || d->wrap) {
currentIndex() < count - 1Description
TRUEnever evaluated
FALSEnever evaluated
d->wrapDescription
TRUEnever evaluated
FALSEnever evaluated
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) {
currentIndex()...t - d->columnsDescription
TRUEnever evaluated
FALSEnever evaluated
d->wrapDescription
TRUEnever evaluated
FALSEnever evaluated
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*/-
2303void QQuickGridView::moveCurrentIndexRight()-
2304{-
2305 Q_D(QQuickGridView);-
2306 const int count = d->model ? d->model->count() : 0;
d->modelDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
0-2
2307 if (!count)
!countDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-2
2308 return;
never executed: return;
0
2309 if (effectiveLayoutDirection() == Qt::LeftToRight) {
effectiveLayou...t::LeftToRightDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
0-2
2310 if (d->flow == QQuickGridView::FlowLeftToRight) {
d->flow == QQu...lowLeftToRightDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
0-2
2311 if (currentIndex() < count - 1 || d->wrap) {
currentIndex() < count - 1Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
d->wrapDescription
TRUEnever evaluated
FALSEnever evaluated
0-2
2312 int index = currentIndex() + 1;-
2313 setCurrentIndex((index >= 0 && index < count) ? index : 0);-
2314 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
2
2315 } else {
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
2
2316 if (currentIndex() < count - d->columns || d->wrap) {
currentIndex()...t - d->columnsDescription
TRUEnever evaluated
FALSEnever evaluated
d->wrapDescription
TRUEnever evaluated
FALSEnever evaluated
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) {
d->flow == QQu...lowLeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2323 if (currentIndex() > 0 || d->wrap) {
currentIndex() > 0Description
TRUEnever evaluated
FALSEnever evaluated
d->wrapDescription
TRUEnever evaluated
FALSEnever evaluated
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) {
currentIndex() >= d->columnsDescription
TRUEnever evaluated
FALSEnever evaluated
d->wrapDescription
TRUEnever evaluated
FALSEnever evaluated
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-
2336bool 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;
visibleItems.count()Description
TRUEevaluated 1158 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 102 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
102-1158
2344-
2345 if (index < 0) {
index < 0Description
TRUEevaluated 228 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 1032 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
228-1032
2346 int i = visibleItems.count() - 1;-
2347 while (i > 0 && visibleItems.at(i)->index == -1)
i > 0Description
TRUEevaluated 220 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickgridview
visibleItems.a...)->index == -1Description
TRUEnever evaluated
FALSEevaluated 220 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-220
2348 --i;
never executed: --i;
0
2349 if (visibleItems.at(i)->index + 1 == modelIndex) {
visibleItems.a... == modelIndexDescription
TRUEevaluated 61 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 167 times by 1 test
Evaluated by:
  • tst_qquickgridview
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 block
Executed by:
  • tst_qquickgridview
61
2353 if (modelIndex <= visibleIndex) {
modelIndex <= visibleIndexDescription
TRUEevaluated 84 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 83 times by 1 test
Evaluated by:
  • tst_qquickgridview
83-84
2354 // Insert before visible items-
2355 visibleIndex += count;-
2356 for (FxViewItem *item : qAsConst(visibleItems)) {-
2357 if (item->index != -1 && item->index >= modelIndex)
item->index != -1Description
TRUEevaluated 1786 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
item->index >= modelIndexDescription
TRUEevaluated 1786 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
0-1786
2358 item->index += count;
executed 1786 times by 1 test: item->index += count;
Executed by:
  • tst_qquickgridview
1786
2359 }
executed 1786 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
1786
2360 }
executed 84 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
84
2361 return true;
executed 167 times by 1 test: return true;
Executed by:
  • tst_qquickgridview
167
2362 }-
2363 }-
2364-
2365 qreal tempPos = isContentFlowReversed() ? -position()-size()+q->width()+1 : position();
isContentFlowReversed()Description
TRUEevaluated 320 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 773 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
320-773
2366 qreal colPos = 0;-
2367 qreal rowPos = 0;-
2368 int colNum = 0;-
2369 if (visibleItems.count()) {
visibleItems.count()Description
TRUEevaluated 991 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 102 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
102-991
2370 if (index < visibleItems.count()) {
index < visibleItems.count()Description
TRUEevaluated 930 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 61 times by 1 test
Evaluated by:
  • tst_qquickgridview
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 block
Executed by:
  • tst_qquickgridview
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) {
++colNum >= columnsDescription
TRUEnever evaluated
FALSEevaluated 61 times by 1 test
Evaluated by:
  • tst_qquickgridview
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 block
Executed by:
  • tst_qquickgridview
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) {
item->index != -1Description
TRUEevaluated 17794 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
item->index >= modelIndexDescription
TRUEevaluated 10702 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 7092 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-17794
2391 item->index += count;-
2392 if (change.isMove())
change.isMove()Description
TRUEevaluated 5262 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 5440 times by 1 test
Evaluated by:
  • tst_qquickgridview
5262-5440
2393 item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::MoveTransition, false);
executed 5262 times by 1 test: item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::MoveTransition, false);
Executed by:
  • tst_qquickgridview
5262
2394 else-
2395 item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, false);
executed 5440 times by 1 test: item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, false);
Executed by:
  • tst_qquickgridview
5440
2396 }-
2397 }
executed 17794 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
17794
2398-
2399 int prevVisibleCount = visibleItems.count();-
2400 if (insertResult->visiblePos.isValid() && rowPos < insertResult->visiblePos) {
insertResult->...ePos.isValid()Description
TRUEevaluated 995 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 98 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
rowPos < inser...lt->visiblePosDescription
TRUEevaluated 96 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 899 times by 1 test
Evaluated by:
  • tst_qquickgridview
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) {
rowPos > fromDescription
TRUEevaluated 13 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 83 times by 1 test
Evaluated by:
  • tst_qquickgridview
insertionIdx < visibleIndexDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 11 times by 1 test
Evaluated by:
  • tst_qquickgridview
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 block
Executed by:
  • tst_qquickgridview
2
2411 while (i >= 0) {
i >= 0Description
TRUEevaluated 371 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 94 times by 1 test
Evaluated by:
  • tst_qquickgridview
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))))
change.isMove()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 369 times by 1 test
Evaluated by:
  • tst_qquickgridview
(item = curren...elIndex + i)))Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
0-369
2415 item->index = modelIndex + i;
never executed: item->index = modelIndex + i;
0
2416 if (!item)
!itemDescription
TRUEevaluated 371 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
0-371
2417 item = createItem(modelIndex + i, QQmlIncubator::Synchronous);
executed 371 times by 1 test: item = createItem(modelIndex + i, QQmlIncubator::Synchronous);
Executed by:
  • tst_qquickgridview
371
2418 if (!item)
!itemDescription
TRUEnever evaluated
FALSEevaluated 371 times by 1 test
Evaluated by:
  • tst_qquickgridview
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)
insertionIdx == 0Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 356 times by 1 test
Evaluated by:
  • tst_qquickgridview
15-356
2424 insertResult->changedFirstItem = true;
executed 15 times by 1 test: insertResult->changedFirstItem = true;
Executed by:
  • tst_qquickgridview
15
2425 if (!change.isMove()) {
!change.isMove()Description
TRUEevaluated 369 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgridview
2-369
2426 addedItems->append(item);-
2427 if (transitioner)
transitionerDescription
TRUEnever evaluated
FALSEevaluated 369 times by 1 test
Evaluated by:
  • tst_qquickgridview
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:
  • tst_qquickgridview
369
2431 }-
2432 insertResult->sizeChangesBeforeVisiblePos += rowSize();-
2433-
2434 if (--colNum < 0 ) {
--colNum < 0Description
TRUEevaluated 76 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 295 times by 1 test
Evaluated by:
  • tst_qquickgridview
76-295
2435 colNum = columns - 1;-
2436 rowPos -= rowSize();-
2437 }
executed 76 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
76
2438 colPos = colNum * colSize();-
2439 index++;-
2440 i--;-
2441 }
executed 371 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
371
2442 }
executed 94 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
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++) {
i <= insertionIdxDescription
TRUEevaluated 351 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 95 times by 1 test
Evaluated by:
  • tst_qquickgridview
i < visibleItems.count() - 1Description
TRUEevaluated 351 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
0-351
2449 if (visibleItems.at(i)->index + 1 != visibleItems.at(i + 1)->index) {
visibleItems.a...(i + 1)->indexDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 350 times by 1 test
Evaluated by:
  • tst_qquickgridview
1-350
2450 firstOkIdx = i + 1;-
2451 break;
executed 1 time by 1 test: break;
Executed by:
  • tst_qquickgridview
1
2452 }-
2453 }
executed 350 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
350
2454 // ... and remove all the items before that one-
2455 for (int i = 0; i < firstOkIdx; i++) {
i < firstOkIdxDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 96 times by 1 test
Evaluated by:
  • tst_qquickgridview
1-96
2456 FxViewItem *nvItem = visibleItems.takeFirst();-
2457 addedItems->removeOne(nvItem);-
2458 removeItem(nvItem);-
2459 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_qquickgridview
1
2460-
2461 } else {
executed 96 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
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)) {
i < countDescription
TRUEevaluated 4253 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
FALSEevaluated 953 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
rowPos <= to +...eal(columns+1)Description
TRUEevaluated 4209 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
FALSEevaluated 44 times by 1 test
Evaluated by:
  • tst_qquickgridview
44-4253
2465 FxViewItem *item = nullptr;-
2466 if (change.isMove() && (item = currentChanges.removedItems.take(change.moveKey(modelIndex + i))))
change.isMove()Description
TRUEevaluated 1358 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 2851 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
(item = curren...elIndex + i)))Description
TRUEevaluated 992 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 366 times by 1 test
Evaluated by:
  • tst_qquickgridview
366-2851
2467 item->index = modelIndex + i;
executed 992 times by 1 test: item->index = modelIndex + i;
Executed by:
  • tst_qquickgridview
992
2468 bool newItem = !item;-
2469 if (!item)
!itemDescription
TRUEevaluated 3217 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
FALSEevaluated 992 times by 1 test
Evaluated by:
  • tst_qquickgridview
992-3217
2470 item = createItem(modelIndex + i, QQmlIncubator::Synchronous);
executed 3217 times by 3 tests: item = createItem(modelIndex + i, QQmlIncubator::Synchronous);
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
3217
2471 if (!item)
!itemDescription
TRUEnever evaluated
FALSEevaluated 4209 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
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)
index == 0Description
TRUEevaluated 261 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
FALSEevaluated 3948 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
261-3948
2477 insertResult->changedFirstItem = true;
executed 261 times by 3 tests: insertResult->changedFirstItem = true;
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
261
2478 if (change.isMove()) {
change.isMove()Description
TRUEevaluated 1358 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 2851 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
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))
newItemDescription
TRUEevaluated 366 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 992 times by 1 test
Evaluated by:
  • tst_qquickgridview
transitionerDescription
TRUEevaluated 58 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 308 times by 1 test
Evaluated by:
  • tst_qquickgridview
transitioner->...nsition, true)Description
TRUEevaluated 58 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
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:
  • tst_qquickgridview
58
2483 } else {
executed 1358 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
1358
2484 addedItems->append(item);-
2485 if (transitioner)
transitionerDescription
TRUEevaluated 188 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 2663 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
188-2663
2486 item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, true);
executed 188 times by 1 test: item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, true);
Executed by:
  • tst_qquickgridview
188
2487 else-
2488 item->moveTo(QPointF(colPos, rowPos), true);
executed 2663 times by 3 tests: item->moveTo(QPointF(colPos, rowPos), true);
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
2663
2489 }-
2490 insertResult->sizeChangesAfterVisiblePos += rowSize();-
2491-
2492 if (++colNum >= columns) {
++colNum >= columnsDescription
TRUEevaluated 1170 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
FALSEevaluated 3039 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
1170-3039
2493 colNum = 0;-
2494 rowPos += rowSize();-
2495 }
executed 1170 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
1170
2496 colPos = colNum * colSize();-
2497 ++index;-
2498 ++i;-
2499 }
executed 4209 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
4209
2500 }
executed 997 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
997
2501-
2502 updateVisibleIndex();-
2503-
2504 return visibleItems.count() > prevVisibleCount;
executed 1093 times by 3 tests: return visibleItems.count() > prevVisibleCount;
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickvisualdatamodel
1093
2505}-
2506-
2507void QQuickGridViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex, const ChangeResult &insertionResult, const ChangeResult &removalResult)-
2508{-
2509 if (!transitioner)
!transitionerDescription
TRUEnever evaluated
FALSEevaluated 268 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
0-268
2510 return;
never executed: return;
0
2511-
2512 int markerItemIndex = -1;-
2513 for (int i=0; i<visibleItems.count(); i++) {
i<visibleItems.count()Description
TRUEevaluated 4792 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
FALSEnever evaluated
0-4792
2514 if (visibleItems.at(i)->index == afterModelIndex) {
visibleItems.a...fterModelIndexDescription
TRUEevaluated 268 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
FALSEevaluated 4524 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
268-4524
2515 markerItemIndex = i;-
2516 break;
executed 268 times by 2 tests: break;
Executed by:
  • tst_examples
  • tst_qquickgridview
268
2517 }-
2518 }
executed 4524 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
4524
2519 if (markerItemIndex < 0)
markerItemIndex < 0Description
TRUEnever evaluated
FALSEevaluated 268 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
0-268
2520 return;
never executed: return;
0
2521-
2522 const qreal viewEndPos = isContentFlowReversed() ? -position() : position() + size();
isContentFlowReversed()Description
TRUEnever evaluated
FALSEevaluated 268 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
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)
changeBeforeVisible != 0Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 248 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
20-248
2528 countItemsRemoved += (changeBeforeVisible % columns) - (columns - 1);
executed 20 times by 1 test: countItemsRemoved += (changeBeforeVisible % columns) - (columns - 1);
Executed by:
  • tst_qquickgridview
20
2529-
2530 countItemsRemoved -= removalResult.countChangeAfterVisibleItems;-
2531-
2532 for (int i=markerItemIndex+1; i<visibleItems.count(); i++) {
i<visibleItems.count()Description
TRUEevaluated 298 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 8 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
8-298
2533 FxGridItemSG *gridItem = static_cast<FxGridItemSG *>(visibleItems.at(i));-
2534 if (gridItem->position() >= viewEndPos)
gridItem->posi... >= viewEndPosDescription
TRUEevaluated 260 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEevaluated 38 times by 1 test
Evaluated by:
  • tst_qquickgridview
38-260
2535 break;
executed 260 times by 1 test: break;
Executed by:
  • tst_qquickgridview
260
2536 if (!gridItem->transitionScheduledOrRunning()) {
!gridItem->tra...ledOrRunning()Description
TRUEevaluated 38 times by 1 test
Evaluated by:
  • tst_qquickgridview
FALSEnever evaluated
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 block
Executed by:
  • tst_qquickgridview
38
2544 }
executed 38 times by 1 test: end of block
Executed by:
  • tst_qquickgridview
38
2545}
executed 268 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
268
2546-
2547bool 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:
  • tst_qquickgridview
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-
2652QQuickGridViewAttached *QQuickGridView::qmlAttachedProperties(QObject *obj)-
2653{-
2654 return new QQuickGridViewAttached(obj);
executed 48281 times by 4 tests: return new QQuickGridViewAttached(obj);
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickvisualdatamodel
48281
2655}-
2656-
2657QT_END_NAMESPACE-
2658-
2659#include "moc_qquickgridview_p.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0