Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquicklistview.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||||||||||||||
2 | ** | - | ||||||||||||||||||||||||||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||||||||||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||||||||||||||
5 | ** | - | ||||||||||||||||||||||||||||||
6 | ** This file is part of the QtQuick module of the Qt Toolkit. | - | ||||||||||||||||||||||||||||||
7 | ** | - | ||||||||||||||||||||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||||||||||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||||||||||||||
16 | ** | - | ||||||||||||||||||||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||||||||||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||||||||||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||||||||||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||||||||||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||||||||||||||
24 | ** | - | ||||||||||||||||||||||||||||||
25 | ** GNU General Public License Usage | - | ||||||||||||||||||||||||||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||||||||||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||||||||||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||||||||||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||||||||||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||||||||||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||||||||||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||||||||||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||||||||||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||||||||||||||
35 | ** | - | ||||||||||||||||||||||||||||||
36 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||||||||
37 | ** | - | ||||||||||||||||||||||||||||||
38 | ****************************************************************************/ | - | ||||||||||||||||||||||||||||||
39 | - | |||||||||||||||||||||||||||||||
40 | #include "qquicklistview_p.h" | - | ||||||||||||||||||||||||||||||
41 | #include "qquickitemview_p_p.h" | - | ||||||||||||||||||||||||||||||
42 | - | |||||||||||||||||||||||||||||||
43 | #include <private/qqmlobjectmodel_p.h> | - | ||||||||||||||||||||||||||||||
44 | #include <QtQml/qqmlexpression.h> | - | ||||||||||||||||||||||||||||||
45 | #include <QtQml/qqmlengine.h> | - | ||||||||||||||||||||||||||||||
46 | #include <QtQml/qqmlinfo.h> | - | ||||||||||||||||||||||||||||||
47 | #include <QtGui/qevent.h> | - | ||||||||||||||||||||||||||||||
48 | #include <QtCore/qcoreapplication.h> | - | ||||||||||||||||||||||||||||||
49 | #include <QtCore/qmath.h> | - | ||||||||||||||||||||||||||||||
50 | - | |||||||||||||||||||||||||||||||
51 | #include <private/qquicksmoothedanimation_p_p.h> | - | ||||||||||||||||||||||||||||||
52 | #include "qplatformdefs.h" | - | ||||||||||||||||||||||||||||||
53 | - | |||||||||||||||||||||||||||||||
54 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||||||||
55 | - | |||||||||||||||||||||||||||||||
56 | #ifndef QML_FLICK_SNAPONETHRESHOLD | - | ||||||||||||||||||||||||||||||
57 | #define QML_FLICK_SNAPONETHRESHOLD 30 | - | ||||||||||||||||||||||||||||||
58 | #endif | - | ||||||||||||||||||||||||||||||
59 | - | |||||||||||||||||||||||||||||||
60 | class FxListItemSG; | - | ||||||||||||||||||||||||||||||
61 | - | |||||||||||||||||||||||||||||||
62 | class QQuickListViewPrivate : public QQuickItemViewPrivate | - | ||||||||||||||||||||||||||||||
63 | { | - | ||||||||||||||||||||||||||||||
64 | Q_DECLARE_PUBLIC(QQuickListView) | - | ||||||||||||||||||||||||||||||
65 | public: | - | ||||||||||||||||||||||||||||||
66 | static QQuickListViewPrivate* get(QQuickListView *item) { return item->d_func(); } executed 46 times by 4 tests: return item->d_func(); Executed by:
| 46 | ||||||||||||||||||||||||||||||
67 | - | |||||||||||||||||||||||||||||||
68 | Qt::Orientation layoutOrientation() const override; | - | ||||||||||||||||||||||||||||||
69 | bool isContentFlowReversed() const override; | - | ||||||||||||||||||||||||||||||
70 | bool isRightToLeft() const; | - | ||||||||||||||||||||||||||||||
71 | bool isBottomToTop() const; | - | ||||||||||||||||||||||||||||||
72 | - | |||||||||||||||||||||||||||||||
73 | qreal positionAt(int index) const override; | - | ||||||||||||||||||||||||||||||
74 | qreal endPositionAt(int index) const override; | - | ||||||||||||||||||||||||||||||
75 | qreal originPosition() const override; | - | ||||||||||||||||||||||||||||||
76 | qreal lastPosition() const override; | - | ||||||||||||||||||||||||||||||
77 | - | |||||||||||||||||||||||||||||||
78 | FxViewItem *itemBefore(int modelIndex) const; | - | ||||||||||||||||||||||||||||||
79 | QString sectionAt(int modelIndex); | - | ||||||||||||||||||||||||||||||
80 | qreal snapPosAt(qreal pos); | - | ||||||||||||||||||||||||||||||
81 | FxViewItem *snapItemAt(qreal pos); | - | ||||||||||||||||||||||||||||||
82 | - | |||||||||||||||||||||||||||||||
83 | void init() override; | - | ||||||||||||||||||||||||||||||
84 | void clear() override; | - | ||||||||||||||||||||||||||||||
85 | - | |||||||||||||||||||||||||||||||
86 | bool addVisibleItems(qreal fillFrom, qreal fillTo, qreal bufferFrom, qreal bufferTo, bool doBuffer) override; | - | ||||||||||||||||||||||||||||||
87 | bool removeNonVisibleItems(qreal bufferFrom, qreal bufferTo) override; | - | ||||||||||||||||||||||||||||||
88 | void visibleItemsChanged() override; | - | ||||||||||||||||||||||||||||||
89 | - | |||||||||||||||||||||||||||||||
90 | void removeItem(FxViewItem *item); | - | ||||||||||||||||||||||||||||||
91 | - | |||||||||||||||||||||||||||||||
92 | FxViewItem *newViewItem(int index, QQuickItem *item) override; | - | ||||||||||||||||||||||||||||||
93 | void initializeViewItem(FxViewItem *item) override; | - | ||||||||||||||||||||||||||||||
94 | bool releaseItem(FxViewItem *item) override; | - | ||||||||||||||||||||||||||||||
95 | void repositionItemAt(FxViewItem *item, int index, qreal sizeBuffer) override; | - | ||||||||||||||||||||||||||||||
96 | void repositionPackageItemAt(QQuickItem *item, int index) override; | - | ||||||||||||||||||||||||||||||
97 | void resetFirstItemPosition(qreal pos = 0.0) override; | - | ||||||||||||||||||||||||||||||
98 | void adjustFirstItem(qreal forwards, qreal backwards, int) override; | - | ||||||||||||||||||||||||||||||
99 | void updateSizeChangesBeforeVisiblePos(FxViewItem *item, ChangeResult *removeResult) override; | - | ||||||||||||||||||||||||||||||
100 | - | |||||||||||||||||||||||||||||||
101 | void createHighlight() override; | - | ||||||||||||||||||||||||||||||
102 | void updateHighlight() override; | - | ||||||||||||||||||||||||||||||
103 | void resetHighlightPosition() override; | - | ||||||||||||||||||||||||||||||
104 | bool movingFromHighlight() override; | - | ||||||||||||||||||||||||||||||
105 | - | |||||||||||||||||||||||||||||||
106 | void setPosition(qreal pos) override; | - | ||||||||||||||||||||||||||||||
107 | void layoutVisibleItems(int fromModelIndex = 0) override; | - | ||||||||||||||||||||||||||||||
108 | - | |||||||||||||||||||||||||||||||
109 | bool applyInsertionChange(const QQmlChangeSet::Change &insert, ChangeResult *changeResult, QList<FxViewItem *> *addedItems, QList<MovedItem> *movingIntoView) override; | - | ||||||||||||||||||||||||||||||
110 | void translateAndTransitionItemsAfter(int afterIndex, const ChangeResult &insertionResult, const ChangeResult &removalResult) override; | - | ||||||||||||||||||||||||||||||
111 | - | |||||||||||||||||||||||||||||||
112 | void updateSectionCriteria() override; | - | ||||||||||||||||||||||||||||||
113 | void updateSections() override; | - | ||||||||||||||||||||||||||||||
114 | QQuickItem *getSectionItem(const QString §ion); | - | ||||||||||||||||||||||||||||||
115 | void releaseSectionItem(QQuickItem *item); | - | ||||||||||||||||||||||||||||||
116 | void releaseSectionItems(); | - | ||||||||||||||||||||||||||||||
117 | void updateInlineSection(FxListItemSG *); | - | ||||||||||||||||||||||||||||||
118 | void updateCurrentSection(); | - | ||||||||||||||||||||||||||||||
119 | void updateStickySections(); | - | ||||||||||||||||||||||||||||||
120 | - | |||||||||||||||||||||||||||||||
121 | qreal headerSize() const override; | - | ||||||||||||||||||||||||||||||
122 | qreal footerSize() const override; | - | ||||||||||||||||||||||||||||||
123 | bool showHeaderForIndex(int index) const override; | - | ||||||||||||||||||||||||||||||
124 | bool showFooterForIndex(int index) const override; | - | ||||||||||||||||||||||||||||||
125 | void updateHeader() override; | - | ||||||||||||||||||||||||||||||
126 | void updateFooter() override; | - | ||||||||||||||||||||||||||||||
127 | bool hasStickyHeader() const override; | - | ||||||||||||||||||||||||||||||
128 | bool hasStickyFooter() const override; | - | ||||||||||||||||||||||||||||||
129 | - | |||||||||||||||||||||||||||||||
130 | void changedVisibleIndex(int newIndex) override; | - | ||||||||||||||||||||||||||||||
131 | void initializeCurrentItem() override; | - | ||||||||||||||||||||||||||||||
132 | - | |||||||||||||||||||||||||||||||
133 | void updateAverage(); | - | ||||||||||||||||||||||||||||||
134 | - | |||||||||||||||||||||||||||||||
135 | void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &oldGeometry) override; | - | ||||||||||||||||||||||||||||||
136 | void fixupPosition() override; | - | ||||||||||||||||||||||||||||||
137 | void fixup(AxisData &data, qreal minExtent, qreal maxExtent) override; | - | ||||||||||||||||||||||||||||||
138 | bool flick(QQuickItemViewPrivate::AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, | - | ||||||||||||||||||||||||||||||
139 | QQuickTimeLineCallback::Callback fixupCallback, qreal velocity) override; | - | ||||||||||||||||||||||||||||||
140 | - | |||||||||||||||||||||||||||||||
141 | QQuickListView::Orientation orient; | - | ||||||||||||||||||||||||||||||
142 | qreal visiblePos; | - | ||||||||||||||||||||||||||||||
143 | qreal averageSize; | - | ||||||||||||||||||||||||||||||
144 | qreal spacing; | - | ||||||||||||||||||||||||||||||
145 | QQuickListView::SnapMode snapMode; | - | ||||||||||||||||||||||||||||||
146 | - | |||||||||||||||||||||||||||||||
147 | QQuickListView::HeaderPositioning headerPositioning; | - | ||||||||||||||||||||||||||||||
148 | QQuickListView::FooterPositioning footerPositioning; | - | ||||||||||||||||||||||||||||||
149 | - | |||||||||||||||||||||||||||||||
150 | QSmoothedAnimation *highlightPosAnimator; | - | ||||||||||||||||||||||||||||||
151 | QSmoothedAnimation *highlightWidthAnimator; | - | ||||||||||||||||||||||||||||||
152 | QSmoothedAnimation *highlightHeightAnimator; | - | ||||||||||||||||||||||||||||||
153 | qreal highlightMoveVelocity; | - | ||||||||||||||||||||||||||||||
154 | qreal highlightResizeVelocity; | - | ||||||||||||||||||||||||||||||
155 | int highlightResizeDuration; | - | ||||||||||||||||||||||||||||||
156 | - | |||||||||||||||||||||||||||||||
157 | QQuickViewSection *sectionCriteria; | - | ||||||||||||||||||||||||||||||
158 | QString currentSection; | - | ||||||||||||||||||||||||||||||
159 | static const int sectionCacheSize = 5; | - | ||||||||||||||||||||||||||||||
160 | QQuickItem *sectionCache[sectionCacheSize]; | - | ||||||||||||||||||||||||||||||
161 | QQuickItem *currentSectionItem; | - | ||||||||||||||||||||||||||||||
162 | QString currentStickySection; | - | ||||||||||||||||||||||||||||||
163 | QQuickItem *nextSectionItem; | - | ||||||||||||||||||||||||||||||
164 | QString nextStickySection; | - | ||||||||||||||||||||||||||||||
165 | QString lastVisibleSection; | - | ||||||||||||||||||||||||||||||
166 | QString nextSection; | - | ||||||||||||||||||||||||||||||
167 | - | |||||||||||||||||||||||||||||||
168 | qreal overshootDist; | - | ||||||||||||||||||||||||||||||
169 | bool correctFlick : 1; | - | ||||||||||||||||||||||||||||||
170 | bool inFlickCorrection : 1; | - | ||||||||||||||||||||||||||||||
171 | - | |||||||||||||||||||||||||||||||
172 | QQuickListViewPrivate() | - | ||||||||||||||||||||||||||||||
173 | : orient(QQuickListView::Vertical) | - | ||||||||||||||||||||||||||||||
174 | , visiblePos(0) | - | ||||||||||||||||||||||||||||||
175 | , averageSize(100.0), spacing(0.0) | - | ||||||||||||||||||||||||||||||
176 | , snapMode(QQuickListView::NoSnap) | - | ||||||||||||||||||||||||||||||
177 | , headerPositioning(QQuickListView::InlineHeader) | - | ||||||||||||||||||||||||||||||
178 | , footerPositioning(QQuickListView::InlineFooter) | - | ||||||||||||||||||||||||||||||
179 | , highlightPosAnimator(nullptr), highlightWidthAnimator(nullptr), highlightHeightAnimator(nullptr) | - | ||||||||||||||||||||||||||||||
180 | , highlightMoveVelocity(400), highlightResizeVelocity(400), highlightResizeDuration(-1) | - | ||||||||||||||||||||||||||||||
181 | , sectionCriteria(nullptr), currentSectionItem(nullptr), nextSectionItem(nullptr) | - | ||||||||||||||||||||||||||||||
182 | , overshootDist(0.0), correctFlick(false), inFlickCorrection(false) | - | ||||||||||||||||||||||||||||||
183 | { | - | ||||||||||||||||||||||||||||||
184 | highlightMoveDuration = -1; //override default value set in base class | - | ||||||||||||||||||||||||||||||
185 | } executed 1920 times by 11 tests: end of block Executed by:
| 1920 | ||||||||||||||||||||||||||||||
186 | ~QQuickListViewPrivate() { | - | ||||||||||||||||||||||||||||||
187 | delete highlightPosAnimator; | - | ||||||||||||||||||||||||||||||
188 | delete highlightWidthAnimator; | - | ||||||||||||||||||||||||||||||
189 | delete highlightHeightAnimator; | - | ||||||||||||||||||||||||||||||
190 | } executed 1912 times by 9 tests: end of block Executed by:
| 1912 | ||||||||||||||||||||||||||||||
191 | - | |||||||||||||||||||||||||||||||
192 | friend class QQuickViewSection; | - | ||||||||||||||||||||||||||||||
193 | }; | - | ||||||||||||||||||||||||||||||
194 | - | |||||||||||||||||||||||||||||||
195 | //---------------------------------------------------------------------------- | - | ||||||||||||||||||||||||||||||
196 | - | |||||||||||||||||||||||||||||||
197 | QQuickViewSection::QQuickViewSection(QQuickListView *parent) | - | ||||||||||||||||||||||||||||||
198 | : QObject(parent), m_criteria(FullString), m_delegate(nullptr), m_labelPositioning(InlineLabels) | - | ||||||||||||||||||||||||||||||
199 | , m_view(parent ? QQuickListViewPrivate::get(parent) : nullptr) | - | ||||||||||||||||||||||||||||||
200 | { | - | ||||||||||||||||||||||||||||||
201 | } executed 46 times by 4 tests: end of block Executed by:
| 46 | ||||||||||||||||||||||||||||||
202 | - | |||||||||||||||||||||||||||||||
203 | void QQuickViewSection::setProperty(const QString &property) | - | ||||||||||||||||||||||||||||||
204 | { | - | ||||||||||||||||||||||||||||||
205 | if (property != m_property) {
| 0-58 | ||||||||||||||||||||||||||||||
206 | m_property = property; | - | ||||||||||||||||||||||||||||||
207 | emit propertyChanged(); | - | ||||||||||||||||||||||||||||||
208 | // notify view that the contents of the sections must be recalculated | - | ||||||||||||||||||||||||||||||
209 | m_view->updateSectionCriteria(); | - | ||||||||||||||||||||||||||||||
210 | } executed 58 times by 4 tests: end of block Executed by:
| 58 | ||||||||||||||||||||||||||||||
211 | } executed 58 times by 4 tests: end of block Executed by:
| 58 | ||||||||||||||||||||||||||||||
212 | - | |||||||||||||||||||||||||||||||
213 | void QQuickViewSection::setCriteria(QQuickViewSection::SectionCriteria criteria) | - | ||||||||||||||||||||||||||||||
214 | { | - | ||||||||||||||||||||||||||||||
215 | if (criteria != m_criteria) {
| 2-8 | ||||||||||||||||||||||||||||||
216 | m_criteria = criteria; | - | ||||||||||||||||||||||||||||||
217 | emit criteriaChanged(); | - | ||||||||||||||||||||||||||||||
218 | // notify view that the contents of the sections must be recalculated | - | ||||||||||||||||||||||||||||||
219 | m_view->updateSectionCriteria(); | - | ||||||||||||||||||||||||||||||
220 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||||||||
221 | } executed 10 times by 3 tests: end of block Executed by:
| 10 | ||||||||||||||||||||||||||||||
222 | - | |||||||||||||||||||||||||||||||
223 | void QQuickViewSection::setDelegate(QQmlComponent *delegate) | - | ||||||||||||||||||||||||||||||
224 | { | - | ||||||||||||||||||||||||||||||
225 | if (delegate != m_delegate) {
| 0-42 | ||||||||||||||||||||||||||||||
226 | if (m_delegate)
| 2-40 | ||||||||||||||||||||||||||||||
227 | m_view->releaseSectionItems(); executed 2 times by 1 test: m_view->releaseSectionItems(); Executed by:
| 2 | ||||||||||||||||||||||||||||||
228 | m_delegate = delegate; | - | ||||||||||||||||||||||||||||||
229 | emit delegateChanged(); | - | ||||||||||||||||||||||||||||||
230 | m_view->forceLayoutPolish(); | - | ||||||||||||||||||||||||||||||
231 | } executed 42 times by 3 tests: end of block Executed by:
| 42 | ||||||||||||||||||||||||||||||
232 | } executed 42 times by 3 tests: end of block Executed by:
| 42 | ||||||||||||||||||||||||||||||
233 | - | |||||||||||||||||||||||||||||||
234 | QString QQuickViewSection::sectionString(const QString &value) | - | ||||||||||||||||||||||||||||||
235 | { | - | ||||||||||||||||||||||||||||||
236 | if (m_criteria == FirstCharacter)
| 12-7392 | ||||||||||||||||||||||||||||||
237 | return value.isEmpty() ? QString() : value.at(0); executed 12 times by 1 test: return value.isEmpty() ? QString() : value.at(0); Executed by:
| 12 | ||||||||||||||||||||||||||||||
238 | else | - | ||||||||||||||||||||||||||||||
239 | return value; executed 7392 times by 4 tests: return value; Executed by:
| 7392 | ||||||||||||||||||||||||||||||
240 | } | - | ||||||||||||||||||||||||||||||
241 | - | |||||||||||||||||||||||||||||||
242 | void QQuickViewSection::setLabelPositioning(int l) | - | ||||||||||||||||||||||||||||||
243 | { | - | ||||||||||||||||||||||||||||||
244 | if (m_labelPositioning != l) {
| 8-14 | ||||||||||||||||||||||||||||||
245 | m_labelPositioning = l; | - | ||||||||||||||||||||||||||||||
246 | emit labelPositioningChanged(); | - | ||||||||||||||||||||||||||||||
247 | m_view->forceLayoutPolish(); | - | ||||||||||||||||||||||||||||||
248 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||||||||
249 | } executed 22 times by 1 test: end of block Executed by:
| 22 | ||||||||||||||||||||||||||||||
250 | - | |||||||||||||||||||||||||||||||
251 | //---------------------------------------------------------------------------- | - | ||||||||||||||||||||||||||||||
252 | - | |||||||||||||||||||||||||||||||
253 | class FxListItemSG : public FxViewItem | - | ||||||||||||||||||||||||||||||
254 | { | - | ||||||||||||||||||||||||||||||
255 | public: | - | ||||||||||||||||||||||||||||||
256 | FxListItemSG(QQuickItem *i, QQuickListView *v, bool own) : FxViewItem(i, v, own, static_cast<QQuickItemViewAttached*>(qmlAttachedPropertiesObject<QQuickListView>(i))), view(v) | - | ||||||||||||||||||||||||||||||
257 | { | - | ||||||||||||||||||||||||||||||
258 | } executed 36217 times by 10 tests: end of block Executed by:
| 36217 | ||||||||||||||||||||||||||||||
259 | - | |||||||||||||||||||||||||||||||
260 | inline QQuickItem *section() const { | - | ||||||||||||||||||||||||||||||
261 | return item && attached ? static_cast<QQuickListViewAttached*>(attached)->m_sectionItem : nullptr; executed 817572 times by 10 tests: return item && attached ? static_cast<QQuickListViewAttached*>(attached)->m_sectionItem : nullptr; Executed by:
| 817572 | ||||||||||||||||||||||||||||||
262 | } | - | ||||||||||||||||||||||||||||||
263 | void setSection(QQuickItem *s) { | - | ||||||||||||||||||||||||||||||
264 | static_cast<QQuickListViewAttached*>(attached)->m_sectionItem = s; | - | ||||||||||||||||||||||||||||||
265 | } executed 226 times by 3 tests: end of block Executed by:
| 226 | ||||||||||||||||||||||||||||||
266 | - | |||||||||||||||||||||||||||||||
267 | qreal position() const override { | - | ||||||||||||||||||||||||||||||
268 | if (section()) {
| 9212-284354 | ||||||||||||||||||||||||||||||
269 | if (view->orientation() == QQuickListView::Vertical)
| 0-9212 | ||||||||||||||||||||||||||||||
270 | return (view->verticalLayoutDirection() == QQuickItemView::BottomToTop ? -section()->height()-section()->y() : section()->y()); executed 9212 times by 3 tests: return (view->verticalLayoutDirection() == QQuickItemView::BottomToTop ? -section()->height()-section()->y() : section()->y()); Executed by:
| 9212 | ||||||||||||||||||||||||||||||
271 | else | - | ||||||||||||||||||||||||||||||
272 | return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -section()->width()-section()->x() : section()->x()); never executed: return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -section()->width()-section()->x() : section()->x()); | 0 | ||||||||||||||||||||||||||||||
273 | } else { | - | ||||||||||||||||||||||||||||||
274 | return itemPosition(); executed 284354 times by 10 tests: return itemPosition(); Executed by:
| 284354 | ||||||||||||||||||||||||||||||
275 | } | - | ||||||||||||||||||||||||||||||
276 | } | - | ||||||||||||||||||||||||||||||
277 | qreal itemPosition() const { | - | ||||||||||||||||||||||||||||||
278 | if (view->orientation() == QQuickListView::Vertical)
| 58592-241869 | ||||||||||||||||||||||||||||||
279 | return (view->verticalLayoutDirection() == QQuickItemView::BottomToTop ? -itemHeight()-itemY() : itemY()); executed 241869 times by 10 tests: return (view->verticalLayoutDirection() == QQuickItemView::BottomToTop ? -itemHeight()-itemY() : itemY()); Executed by:
| 241869 | ||||||||||||||||||||||||||||||
280 | else | - | ||||||||||||||||||||||||||||||
281 | return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -itemWidth()-itemX() : itemX()); executed 58592 times by 2 tests: return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -itemWidth()-itemX() : itemX()); Executed by:
| 58592 | ||||||||||||||||||||||||||||||
282 | } | - | ||||||||||||||||||||||||||||||
283 | qreal size() const override { | - | ||||||||||||||||||||||||||||||
284 | if (section())
| 5536-305361 | ||||||||||||||||||||||||||||||
285 | return (view->orientation() == QQuickListView::Vertical ? itemHeight()+section()->height() : itemWidth()+section()->width()); executed 5536 times by 3 tests: return (view->orientation() == QQuickListView::Vertical ? itemHeight()+section()->height() : itemWidth()+section()->width()); Executed by:
| 5536 | ||||||||||||||||||||||||||||||
286 | else | - | ||||||||||||||||||||||||||||||
287 | return (view->orientation() == QQuickListView::Vertical ? itemHeight() : itemWidth()); executed 305361 times by 10 tests: return (view->orientation() == QQuickListView::Vertical ? itemHeight() : itemWidth()); Executed by:
| 305361 | ||||||||||||||||||||||||||||||
288 | } | - | ||||||||||||||||||||||||||||||
289 | qreal itemSize() const { | - | ||||||||||||||||||||||||||||||
290 | return (view->orientation() == QQuickListView::Vertical ? itemHeight() : itemWidth()); executed 3458 times by 10 tests: return (view->orientation() == QQuickListView::Vertical ? itemHeight() : itemWidth()); Executed by:
| 3458 | ||||||||||||||||||||||||||||||
291 | } | - | ||||||||||||||||||||||||||||||
292 | qreal sectionSize() const override { | - | ||||||||||||||||||||||||||||||
293 | if (section())
| 194-13500 | ||||||||||||||||||||||||||||||
294 | return (view->orientation() == QQuickListView::Vertical ? section()->height() : section()->width()); executed 194 times by 3 tests: return (view->orientation() == QQuickListView::Vertical ? section()->height() : section()->width()); Executed by:
| 194 | ||||||||||||||||||||||||||||||
295 | return 0.0; executed 13500 times by 9 tests: return 0.0; Executed by:
| 13500 | ||||||||||||||||||||||||||||||
296 | } | - | ||||||||||||||||||||||||||||||
297 | qreal endPosition() const override { | - | ||||||||||||||||||||||||||||||
298 | if (view->orientation() == QQuickListView::Vertical) {
| 48962-223019 | ||||||||||||||||||||||||||||||
299 | return (view->verticalLayoutDirection() == QQuickItemView::BottomToTop executed 223019 times by 10 tests: return (view->verticalLayoutDirection() == QQuickItemView::BottomToTop ? -itemY() : itemY() + itemHeight()); Executed by:
| 223019 | ||||||||||||||||||||||||||||||
300 | ? -itemY() executed 223019 times by 10 tests: return (view->verticalLayoutDirection() == QQuickItemView::BottomToTop ? -itemY() : itemY() + itemHeight()); Executed by:
| 223019 | ||||||||||||||||||||||||||||||
301 | : itemY() + itemHeight()); executed 223019 times by 10 tests: return (view->verticalLayoutDirection() == QQuickItemView::BottomToTop ? -itemY() : itemY() + itemHeight()); Executed by:
| 223019 | ||||||||||||||||||||||||||||||
302 | } else { | - | ||||||||||||||||||||||||||||||
303 | return (view->effectiveLayoutDirection() == Qt::RightToLeft executed 48962 times by 2 tests: return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -itemX() : itemX() + itemWidth()); Executed by:
| 48962 | ||||||||||||||||||||||||||||||
304 | ? -itemX() executed 48962 times by 2 tests: return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -itemX() : itemX() + itemWidth()); Executed by:
| 48962 | ||||||||||||||||||||||||||||||
305 | : itemX() + itemWidth()); executed 48962 times by 2 tests: return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -itemX() : itemX() + itemWidth()); Executed by:
| 48962 | ||||||||||||||||||||||||||||||
306 | } | - | ||||||||||||||||||||||||||||||
307 | } | - | ||||||||||||||||||||||||||||||
308 | void setPosition(qreal pos, bool immediate = false) { | - | ||||||||||||||||||||||||||||||
309 | // position the section immediately even if there is a transition | - | ||||||||||||||||||||||||||||||
310 | if (section()) {
| 2669-77366 | ||||||||||||||||||||||||||||||
311 | if (view->orientation() == QQuickListView::Vertical) {
| 0-2669 | ||||||||||||||||||||||||||||||
312 | if (view->verticalLayoutDirection() == QQuickItemView::BottomToTop)
| 0-2669 | ||||||||||||||||||||||||||||||
313 | section()->setY(-section()->height()-pos); never executed: section()->setY(-section()->height()-pos); | 0 | ||||||||||||||||||||||||||||||
314 | else | - | ||||||||||||||||||||||||||||||
315 | section()->setY(pos); executed 2669 times by 3 tests: section()->setY(pos); Executed by:
| 2669 | ||||||||||||||||||||||||||||||
316 | } else { | - | ||||||||||||||||||||||||||||||
317 | if (view->effectiveLayoutDirection() == Qt::RightToLeft)
| 0 | ||||||||||||||||||||||||||||||
318 | section()->setX(-section()->width()-pos); never executed: section()->setX(-section()->width()-pos); | 0 | ||||||||||||||||||||||||||||||
319 | else | - | ||||||||||||||||||||||||||||||
320 | section()->setX(pos); never executed: section()->setX(pos); | 0 | ||||||||||||||||||||||||||||||
321 | } | - | ||||||||||||||||||||||||||||||
322 | } | - | ||||||||||||||||||||||||||||||
323 | moveTo(pointForPosition(pos), immediate); | - | ||||||||||||||||||||||||||||||
324 | } executed 80035 times by 10 tests: end of block Executed by:
| 80035 | ||||||||||||||||||||||||||||||
325 | void setSize(qreal size) { | - | ||||||||||||||||||||||||||||||
326 | if (view->orientation() == QQuickListView::Vertical)
| 210-1984 | ||||||||||||||||||||||||||||||
327 | item->setHeight(size); executed 1984 times by 10 tests: item->setHeight(size); Executed by:
| 1984 | ||||||||||||||||||||||||||||||
328 | else | - | ||||||||||||||||||||||||||||||
329 | item->setWidth(size); executed 210 times by 2 tests: item->setWidth(size); Executed by:
| 210 | ||||||||||||||||||||||||||||||
330 | } | - | ||||||||||||||||||||||||||||||
331 | bool contains(qreal x, qreal y) const override { | - | ||||||||||||||||||||||||||||||
332 | return (x >= itemX() && x < itemX() + itemWidth() && executed 13428 times by 1 test: return (x >= itemX() && x < itemX() + itemWidth() && y >= itemY() && y < itemY() + itemHeight()); Executed by:
| 13428 | ||||||||||||||||||||||||||||||
333 | y >= itemY() && y < itemY() + itemHeight()); executed 13428 times by 1 test: return (x >= itemX() && x < itemX() + itemWidth() && y >= itemY() && y < itemY() + itemHeight()); Executed by:
| 13428 | ||||||||||||||||||||||||||||||
334 | } | - | ||||||||||||||||||||||||||||||
335 | - | |||||||||||||||||||||||||||||||
336 | QQuickListView *view; | - | ||||||||||||||||||||||||||||||
337 | - | |||||||||||||||||||||||||||||||
338 | private: | - | ||||||||||||||||||||||||||||||
339 | QPointF pointForPosition(qreal pos) const { | - | ||||||||||||||||||||||||||||||
340 | if (view->orientation() == QQuickListView::Vertical) {
| 5091-74944 | ||||||||||||||||||||||||||||||
341 | if (view->verticalLayoutDirection() == QQuickItemView::BottomToTop) {
| 9413-65531 | ||||||||||||||||||||||||||||||
342 | if (section())
| 0-9413 | ||||||||||||||||||||||||||||||
343 | pos += section()->height(); never executed: pos += section()->height(); | 0 | ||||||||||||||||||||||||||||||
344 | return QPointF(itemX(), -itemHeight() - pos); executed 9413 times by 1 test: return QPointF(itemX(), -itemHeight() - pos); Executed by:
| 9413 | ||||||||||||||||||||||||||||||
345 | } else { | - | ||||||||||||||||||||||||||||||
346 | if (section())
| 2669-62862 | ||||||||||||||||||||||||||||||
347 | pos += section()->height(); executed 2669 times by 3 tests: pos += section()->height(); Executed by:
| 2669 | ||||||||||||||||||||||||||||||
348 | return QPointF(itemX(), pos); executed 65531 times by 10 tests: return QPointF(itemX(), pos); Executed by:
| 65531 | ||||||||||||||||||||||||||||||
349 | } | - | ||||||||||||||||||||||||||||||
350 | } else { | - | ||||||||||||||||||||||||||||||
351 | if (view->effectiveLayoutDirection() == Qt::RightToLeft) {
| 1915-3176 | ||||||||||||||||||||||||||||||
352 | if (section())
| 0-1915 | ||||||||||||||||||||||||||||||
353 | pos += section()->width(); never executed: pos += section()->width(); | 0 | ||||||||||||||||||||||||||||||
354 | return QPointF(-itemWidth() - pos, itemY()); executed 1915 times by 1 test: return QPointF(-itemWidth() - pos, itemY()); Executed by:
| 1915 | ||||||||||||||||||||||||||||||
355 | } else { | - | ||||||||||||||||||||||||||||||
356 | if (section())
| 0-3176 | ||||||||||||||||||||||||||||||
357 | pos += section()->width(); never executed: pos += section()->width(); | 0 | ||||||||||||||||||||||||||||||
358 | return QPointF(pos, itemY()); executed 3176 times by 2 tests: return QPointF(pos, itemY()); Executed by:
| 3176 | ||||||||||||||||||||||||||||||
359 | } | - | ||||||||||||||||||||||||||||||
360 | } | - | ||||||||||||||||||||||||||||||
361 | } | - | ||||||||||||||||||||||||||||||
362 | }; | - | ||||||||||||||||||||||||||||||
363 | - | |||||||||||||||||||||||||||||||
364 | //---------------------------------------------------------------------------- | - | ||||||||||||||||||||||||||||||
365 | - | |||||||||||||||||||||||||||||||
366 | bool QQuickListViewPrivate::isContentFlowReversed() const | - | ||||||||||||||||||||||||||||||
367 | { | - | ||||||||||||||||||||||||||||||
368 | return isRightToLeft() || isBottomToTop(); executed 231360 times by 11 tests: return isRightToLeft() || isBottomToTop(); Executed by:
| 231360 | ||||||||||||||||||||||||||||||
369 | } | - | ||||||||||||||||||||||||||||||
370 | - | |||||||||||||||||||||||||||||||
371 | Qt::Orientation QQuickListViewPrivate::layoutOrientation() const | - | ||||||||||||||||||||||||||||||
372 | { | - | ||||||||||||||||||||||||||||||
373 | return static_cast<Qt::Orientation>(orient); executed 559523 times by 11 tests: return static_cast<Qt::Orientation>(orient); Executed by:
| 559523 | ||||||||||||||||||||||||||||||
374 | } | - | ||||||||||||||||||||||||||||||
375 | - | |||||||||||||||||||||||||||||||
376 | bool QQuickListViewPrivate::isRightToLeft() const | - | ||||||||||||||||||||||||||||||
377 | { | - | ||||||||||||||||||||||||||||||
378 | Q_Q(const QQuickListView); | - | ||||||||||||||||||||||||||||||
379 | return orient == QQuickListView::Horizontal && q->effectiveLayoutDirection() == Qt::RightToLeft; executed 239349 times by 11 tests: return orient == QQuickListView::Horizontal && q->effectiveLayoutDirection() == Qt::RightToLeft; Executed by:
| 239349 | ||||||||||||||||||||||||||||||
380 | } | - | ||||||||||||||||||||||||||||||
381 | - | |||||||||||||||||||||||||||||||
382 | bool QQuickListViewPrivate::isBottomToTop() const | - | ||||||||||||||||||||||||||||||
383 | { | - | ||||||||||||||||||||||||||||||
384 | return orient == QQuickListView::Vertical && verticalLayoutDirection == QQuickItemView::BottomToTop; executed 233222 times by 11 tests: return orient == QQuickListView::Vertical && verticalLayoutDirection == QQuickItemView::BottomToTop; Executed by:
| 233222 | ||||||||||||||||||||||||||||||
385 | } | - | ||||||||||||||||||||||||||||||
386 | - | |||||||||||||||||||||||||||||||
387 | // Returns the item before modelIndex, if created. | - | ||||||||||||||||||||||||||||||
388 | // May return an item marked for removal. | - | ||||||||||||||||||||||||||||||
389 | FxViewItem *QQuickListViewPrivate::itemBefore(int modelIndex) const | - | ||||||||||||||||||||||||||||||
390 | { | - | ||||||||||||||||||||||||||||||
391 | if (modelIndex < visibleIndex)
| 46-460 | ||||||||||||||||||||||||||||||
392 | return nullptr; executed 46 times by 1 test: return nullptr; Executed by:
| 46 | ||||||||||||||||||||||||||||||
393 | int idx = 1; | - | ||||||||||||||||||||||||||||||
394 | int lastIndex = -1; | - | ||||||||||||||||||||||||||||||
395 | while (idx < visibleItems.count()) {
| 456-3492 | ||||||||||||||||||||||||||||||
396 | FxViewItem *item = visibleItems.at(idx); | - | ||||||||||||||||||||||||||||||
397 | if (item->index != -1)
| 4-3488 | ||||||||||||||||||||||||||||||
398 | lastIndex = item->index; executed 3488 times by 3 tests: lastIndex = item->index; Executed by:
| 3488 | ||||||||||||||||||||||||||||||
399 | if (item->index == modelIndex)
| 4-3488 | ||||||||||||||||||||||||||||||
400 | return visibleItems.at(idx-1); executed 4 times by 1 test: return visibleItems.at(idx-1); Executed by:
| 4 | ||||||||||||||||||||||||||||||
401 | ++idx; | - | ||||||||||||||||||||||||||||||
402 | } executed 3488 times by 3 tests: end of block Executed by:
| 3488 | ||||||||||||||||||||||||||||||
403 | if (lastIndex == modelIndex-1)
| 64-392 | ||||||||||||||||||||||||||||||
404 | return visibleItems.constLast(); executed 392 times by 3 tests: return visibleItems.constLast(); Executed by:
| 392 | ||||||||||||||||||||||||||||||
405 | return nullptr; executed 64 times by 3 tests: return nullptr; Executed by:
| 64 | ||||||||||||||||||||||||||||||
406 | } | - | ||||||||||||||||||||||||||||||
407 | - | |||||||||||||||||||||||||||||||
408 | void QQuickListViewPrivate::setPosition(qreal pos) | - | ||||||||||||||||||||||||||||||
409 | { | - | ||||||||||||||||||||||||||||||
410 | Q_Q(QQuickListView); | - | ||||||||||||||||||||||||||||||
411 | if (orient == QQuickListView::Vertical) {
| 533-5030 | ||||||||||||||||||||||||||||||
412 | if (isBottomToTop())
| 208-4822 | ||||||||||||||||||||||||||||||
413 | q->QQuickFlickable::setContentY(-pos-size()); executed 208 times by 1 test: q->QQuickFlickable::setContentY(-pos-size()); Executed by:
| 208 | ||||||||||||||||||||||||||||||
414 | else | - | ||||||||||||||||||||||||||||||
415 | q->QQuickFlickable::setContentY(pos); executed 4822 times by 11 tests: q->QQuickFlickable::setContentY(pos); Executed by:
| 4822 | ||||||||||||||||||||||||||||||
416 | } else { | - | ||||||||||||||||||||||||||||||
417 | if (isRightToLeft())
| 130-403 | ||||||||||||||||||||||||||||||
418 | q->QQuickFlickable::setContentX(-pos-size()); executed 130 times by 1 test: q->QQuickFlickable::setContentX(-pos-size()); Executed by:
| 130 | ||||||||||||||||||||||||||||||
419 | else | - | ||||||||||||||||||||||||||||||
420 | q->QQuickFlickable::setContentX(pos); executed 403 times by 2 tests: q->QQuickFlickable::setContentX(pos); Executed by:
| 403 | ||||||||||||||||||||||||||||||
421 | } | - | ||||||||||||||||||||||||||||||
422 | } | - | ||||||||||||||||||||||||||||||
423 | - | |||||||||||||||||||||||||||||||
424 | qreal QQuickListViewPrivate::originPosition() const | - | ||||||||||||||||||||||||||||||
425 | { | - | ||||||||||||||||||||||||||||||
426 | qreal pos = 0; | - | ||||||||||||||||||||||||||||||
427 | if (!visibleItems.isEmpty()) {
| 9076-25232 | ||||||||||||||||||||||||||||||
428 | pos = (*visibleItems.constBegin())->position(); | - | ||||||||||||||||||||||||||||||
429 | if (visibleIndex > 0)
| 4445-20787 | ||||||||||||||||||||||||||||||
430 | pos -= visibleIndex * (averageSize + spacing); executed 4445 times by 3 tests: pos -= visibleIndex * (averageSize + spacing); Executed by:
| 4445 | ||||||||||||||||||||||||||||||
431 | } executed 25232 times by 10 tests: end of block Executed by:
| 25232 | ||||||||||||||||||||||||||||||
432 | return pos; executed 34308 times by 11 tests: return pos; Executed by:
| 34308 | ||||||||||||||||||||||||||||||
433 | } | - | ||||||||||||||||||||||||||||||
434 | - | |||||||||||||||||||||||||||||||
435 | qreal QQuickListViewPrivate::lastPosition() const | - | ||||||||||||||||||||||||||||||
436 | { | - | ||||||||||||||||||||||||||||||
437 | qreal pos = 0; | - | ||||||||||||||||||||||||||||||
438 | if (!visibleItems.isEmpty()) {
| 4366-23622 | ||||||||||||||||||||||||||||||
439 | int invisibleCount = INT_MIN; | - | ||||||||||||||||||||||||||||||
440 | int delayRemovedCount = 0; | - | ||||||||||||||||||||||||||||||
441 | for (int i = visibleItems.count()-1; i >= 0; --i) {
| 15-23803 | ||||||||||||||||||||||||||||||
442 | FxViewItem *item = visibleItems.at(i); | - | ||||||||||||||||||||||||||||||
443 | if (item->index != -1) {
| 196-23607 | ||||||||||||||||||||||||||||||
444 | // Find the invisible count after the last visible item with known index | - | ||||||||||||||||||||||||||||||
445 | invisibleCount = model->count() - (item->index + 1 + delayRemovedCount); | - | ||||||||||||||||||||||||||||||
446 | break; executed 23607 times by 10 tests: break; Executed by:
| 23607 | ||||||||||||||||||||||||||||||
447 | } else if (item->attached->delayRemove()) {
| 0-196 | ||||||||||||||||||||||||||||||
448 | ++delayRemovedCount; | - | ||||||||||||||||||||||||||||||
449 | } executed 196 times by 1 test: end of block Executed by:
| 196 | ||||||||||||||||||||||||||||||
450 | } executed 196 times by 1 test: end of block Executed by:
| 196 | ||||||||||||||||||||||||||||||
451 | if (invisibleCount == INT_MIN) {
| 15-23607 | ||||||||||||||||||||||||||||||
452 | // All visible items are in delayRemove state | - | ||||||||||||||||||||||||||||||
453 | invisibleCount = model->count(); | - | ||||||||||||||||||||||||||||||
454 | } executed 15 times by 1 test: end of block Executed by:
| 15 | ||||||||||||||||||||||||||||||
455 | pos = (*(--visibleItems.constEnd()))->endPosition(); | - | ||||||||||||||||||||||||||||||
456 | if (invisibleCount > 0)
| 8551-15071 | ||||||||||||||||||||||||||||||
457 | pos += invisibleCount * (averageSize + spacing); executed 15071 times by 6 tests: pos += invisibleCount * (averageSize + spacing); Executed by:
| 15071 | ||||||||||||||||||||||||||||||
458 | } else if (model && model->count()) { executed 23622 times by 10 tests: end of block Executed by:
| 66-23622 | ||||||||||||||||||||||||||||||
459 | pos = (model->count() * averageSize + (model->count()-1) * spacing); | - | ||||||||||||||||||||||||||||||
460 | } executed 4300 times by 10 tests: end of block Executed by:
| 4300 | ||||||||||||||||||||||||||||||
461 | return pos; executed 27988 times by 10 tests: return pos; Executed by:
| 27988 | ||||||||||||||||||||||||||||||
462 | } | - | ||||||||||||||||||||||||||||||
463 | - | |||||||||||||||||||||||||||||||
464 | qreal QQuickListViewPrivate::positionAt(int modelIndex) const | - | ||||||||||||||||||||||||||||||
465 | { | - | ||||||||||||||||||||||||||||||
466 | if (FxViewItem *item = visibleItem(modelIndex)) {
| 5319-11425 | ||||||||||||||||||||||||||||||
467 | return item->position(); executed 5319 times by 8 tests: return item->position(); Executed by:
| 5319 | ||||||||||||||||||||||||||||||
468 | } | - | ||||||||||||||||||||||||||||||
469 | if (!visibleItems.isEmpty()) {
| 2238-9187 | ||||||||||||||||||||||||||||||
470 | if (modelIndex < visibleIndex) {
| 1174-8013 | ||||||||||||||||||||||||||||||
471 | int count = visibleIndex - modelIndex; | - | ||||||||||||||||||||||||||||||
472 | qreal cs = 0; | - | ||||||||||||||||||||||||||||||
473 | if (modelIndex == currentIndex && currentItem) {
| 0-1154 | ||||||||||||||||||||||||||||||
474 | cs = currentItem->size() + spacing; | - | ||||||||||||||||||||||||||||||
475 | --count; | - | ||||||||||||||||||||||||||||||
476 | } executed 1154 times by 3 tests: end of block Executed by:
| 1154 | ||||||||||||||||||||||||||||||
477 | return (*visibleItems.constBegin())->position() - count * (averageSize + spacing) - cs; executed 1174 times by 3 tests: return (*visibleItems.constBegin())->position() - count * (averageSize + spacing) - cs; Executed by:
| 1174 | ||||||||||||||||||||||||||||||
478 | } else { | - | ||||||||||||||||||||||||||||||
479 | int count = modelIndex - findLastVisibleIndex(visibleIndex) - 1; | - | ||||||||||||||||||||||||||||||
480 | return (*(--visibleItems.constEnd()))->endPosition() + spacing + count * (averageSize + spacing); executed 8013 times by 6 tests: return (*(--visibleItems.constEnd()))->endPosition() + spacing + count * (averageSize + spacing); Executed by:
| 8013 | ||||||||||||||||||||||||||||||
481 | } | - | ||||||||||||||||||||||||||||||
482 | } | - | ||||||||||||||||||||||||||||||
483 | return 0; executed 2238 times by 10 tests: return 0; Executed by:
| 2238 | ||||||||||||||||||||||||||||||
484 | } | - | ||||||||||||||||||||||||||||||
485 | - | |||||||||||||||||||||||||||||||
486 | qreal QQuickListViewPrivate::endPositionAt(int modelIndex) const | - | ||||||||||||||||||||||||||||||
487 | { | - | ||||||||||||||||||||||||||||||
488 | if (FxViewItem *item = visibleItem(modelIndex))
| 7739-9775 | ||||||||||||||||||||||||||||||
489 | return item->endPosition(); executed 9775 times by 10 tests: return item->endPosition(); Executed by:
| 9775 | ||||||||||||||||||||||||||||||
490 | if (!visibleItems.isEmpty()) {
| 1431-6308 | ||||||||||||||||||||||||||||||
491 | if (modelIndex < visibleIndex) {
| 28-1403 | ||||||||||||||||||||||||||||||
492 | int count = visibleIndex - modelIndex; | - | ||||||||||||||||||||||||||||||
493 | return (*visibleItems.constBegin())->position() - (count - 1) * (averageSize + spacing) - spacing; executed 1403 times by 3 tests: return (*visibleItems.constBegin())->position() - (count - 1) * (averageSize + spacing) - spacing; Executed by:
| 1403 | ||||||||||||||||||||||||||||||
494 | } else { | - | ||||||||||||||||||||||||||||||
495 | int count = modelIndex - findLastVisibleIndex(visibleIndex) - 1; | - | ||||||||||||||||||||||||||||||
496 | return (*(--visibleItems.constEnd()))->endPosition() + count * (averageSize + spacing); executed 28 times by 1 test: return (*(--visibleItems.constEnd()))->endPosition() + count * (averageSize + spacing); Executed by:
| 28 | ||||||||||||||||||||||||||||||
497 | } | - | ||||||||||||||||||||||||||||||
498 | } | - | ||||||||||||||||||||||||||||||
499 | return 0; executed 6308 times by 11 tests: return 0; Executed by:
| 6308 | ||||||||||||||||||||||||||||||
500 | } | - | ||||||||||||||||||||||||||||||
501 | - | |||||||||||||||||||||||||||||||
502 | QString QQuickListViewPrivate::sectionAt(int modelIndex) | - | ||||||||||||||||||||||||||||||
503 | { | - | ||||||||||||||||||||||||||||||
504 | if (FxViewItem *item = visibleItem(modelIndex))
| 660-5898 | ||||||||||||||||||||||||||||||
505 | return item->attached->section(); executed 5898 times by 3 tests: return item->attached->section(); Executed by:
| 5898 | ||||||||||||||||||||||||||||||
506 | - | |||||||||||||||||||||||||||||||
507 | QString section; | - | ||||||||||||||||||||||||||||||
508 | if (sectionCriteria && modelIndex >= 0 && modelIndex < itemCount) {
| 0-660 | ||||||||||||||||||||||||||||||
509 | QString propValue = model->stringValue(modelIndex, sectionCriteria->property()); | - | ||||||||||||||||||||||||||||||
510 | section = sectionCriteria->sectionString(propValue); | - | ||||||||||||||||||||||||||||||
511 | } executed 610 times by 4 tests: end of block Executed by:
| 610 | ||||||||||||||||||||||||||||||
512 | - | |||||||||||||||||||||||||||||||
513 | return section; executed 660 times by 4 tests: return section; Executed by:
| 660 | ||||||||||||||||||||||||||||||
514 | } | - | ||||||||||||||||||||||||||||||
515 | - | |||||||||||||||||||||||||||||||
516 | qreal QQuickListViewPrivate::snapPosAt(qreal pos) | - | ||||||||||||||||||||||||||||||
517 | { | - | ||||||||||||||||||||||||||||||
518 | if (FxViewItem *snapItem = snapItemAt(pos))
| 11-1989 | ||||||||||||||||||||||||||||||
519 | return snapItem->position(); executed 1989 times by 1 test: return snapItem->position(); Executed by:
| 1989 | ||||||||||||||||||||||||||||||
520 | if (visibleItems.count()) {
| 0-11 | ||||||||||||||||||||||||||||||
521 | qreal firstPos = (*visibleItems.constBegin())->position(); | - | ||||||||||||||||||||||||||||||
522 | qreal endPos = (*(--visibleItems.constEnd()))->position(); | - | ||||||||||||||||||||||||||||||
523 | if (pos < firstPos) {
| 0-11 | ||||||||||||||||||||||||||||||
524 | return firstPos - qRound((firstPos - pos) / averageSize) * averageSize; executed 11 times by 1 test: return firstPos - qRound((firstPos - pos) / averageSize) * averageSize; Executed by:
| 11 | ||||||||||||||||||||||||||||||
525 | } else if (pos > endPos)
| 0 | ||||||||||||||||||||||||||||||
526 | return endPos + qRound((pos - endPos) / averageSize) * averageSize; never executed: return endPos + qRound((pos - endPos) / averageSize) * averageSize; | 0 | ||||||||||||||||||||||||||||||
527 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
528 | return qRound((pos - originPosition()) / averageSize) * averageSize + originPosition(); never executed: return qRound((pos - originPosition()) / averageSize) * averageSize + originPosition(); | 0 | ||||||||||||||||||||||||||||||
529 | } | - | ||||||||||||||||||||||||||||||
530 | - | |||||||||||||||||||||||||||||||
531 | FxViewItem *QQuickListViewPrivate::snapItemAt(qreal pos) | - | ||||||||||||||||||||||||||||||
532 | { | - | ||||||||||||||||||||||||||||||
533 | FxViewItem *snapItem = nullptr; | - | ||||||||||||||||||||||||||||||
534 | qreal prevItemSize = 0; | - | ||||||||||||||||||||||||||||||
535 | for (FxViewItem *item : qAsConst(visibleItems)) { | - | ||||||||||||||||||||||||||||||
536 | if (item->index == -1)
| 0-38694 | ||||||||||||||||||||||||||||||
537 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
538 | qreal itemTop = item->position(); | - | ||||||||||||||||||||||||||||||
539 | if (highlight && itemTop >= pos && item->endPosition() <= pos + highlight->size())
| 592-38102 | ||||||||||||||||||||||||||||||
540 | return item; executed 2410 times by 2 tests: return item; Executed by:
| 2410 | ||||||||||||||||||||||||||||||
541 | - | |||||||||||||||||||||||||||||||
542 | // Middle of item and spacing (i.e. the middle of the distance between this item and the next | - | ||||||||||||||||||||||||||||||
543 | qreal halfwayToNextItem = itemTop + (item->size()+spacing) / 2; | - | ||||||||||||||||||||||||||||||
544 | qreal halfwayToPrevItem = itemTop - (prevItemSize+spacing) / 2; | - | ||||||||||||||||||||||||||||||
545 | if (halfwayToNextItem >= pos && halfwayToPrevItem < pos)
| 3286-21909 | ||||||||||||||||||||||||||||||
546 | snapItem = item; executed 3286 times by 1 test: snapItem = item; Executed by:
| 3286 | ||||||||||||||||||||||||||||||
547 | - | |||||||||||||||||||||||||||||||
548 | prevItemSize = item->size(); | - | ||||||||||||||||||||||||||||||
549 | } executed 36284 times by 2 tests: end of block Executed by:
| 36284 | ||||||||||||||||||||||||||||||
550 | return snapItem; executed 4271 times by 2 tests: return snapItem; Executed by:
| 4271 | ||||||||||||||||||||||||||||||
551 | } | - | ||||||||||||||||||||||||||||||
552 | - | |||||||||||||||||||||||||||||||
553 | void QQuickListViewPrivate::changedVisibleIndex(int newIndex) | - | ||||||||||||||||||||||||||||||
554 | { | - | ||||||||||||||||||||||||||||||
555 | visiblePos = positionAt(newIndex); | - | ||||||||||||||||||||||||||||||
556 | visibleIndex = newIndex; | - | ||||||||||||||||||||||||||||||
557 | } executed 118 times by 3 tests: end of block Executed by:
| 118 | ||||||||||||||||||||||||||||||
558 | - | |||||||||||||||||||||||||||||||
559 | void QQuickListViewPrivate::init() | - | ||||||||||||||||||||||||||||||
560 | { | - | ||||||||||||||||||||||||||||||
561 | QQuickItemViewPrivate::init(); | - | ||||||||||||||||||||||||||||||
562 | ::memset(sectionCache, 0, sizeof(QQuickItem*) * sectionCacheSize); | - | ||||||||||||||||||||||||||||||
563 | } executed 1920 times by 11 tests: end of block Executed by:
| 1920 | ||||||||||||||||||||||||||||||
564 | - | |||||||||||||||||||||||||||||||
565 | void QQuickListViewPrivate::clear() | - | ||||||||||||||||||||||||||||||
566 | { | - | ||||||||||||||||||||||||||||||
567 | for (int i = 0; i < sectionCacheSize; ++i) {
| 4208-21040 | ||||||||||||||||||||||||||||||
568 | delete sectionCache[i]; | - | ||||||||||||||||||||||||||||||
569 | sectionCache[i] = nullptr; | - | ||||||||||||||||||||||||||||||
570 | } executed 21040 times by 11 tests: end of block Executed by:
| 21040 | ||||||||||||||||||||||||||||||
571 | visiblePos = 0; | - | ||||||||||||||||||||||||||||||
572 | releaseSectionItem(currentSectionItem); | - | ||||||||||||||||||||||||||||||
573 | currentSectionItem = nullptr; | - | ||||||||||||||||||||||||||||||
574 | releaseSectionItem(nextSectionItem); | - | ||||||||||||||||||||||||||||||
575 | nextSectionItem = nullptr; | - | ||||||||||||||||||||||||||||||
576 | lastVisibleSection = QString(); | - | ||||||||||||||||||||||||||||||
577 | QQuickItemViewPrivate::clear(); | - | ||||||||||||||||||||||||||||||
578 | } executed 4208 times by 11 tests: end of block Executed by:
| 4208 | ||||||||||||||||||||||||||||||
579 | - | |||||||||||||||||||||||||||||||
580 | FxViewItem *QQuickListViewPrivate::newViewItem(int modelIndex, QQuickItem *item) | - | ||||||||||||||||||||||||||||||
581 | { | - | ||||||||||||||||||||||||||||||
582 | Q_Q(QQuickListView); | - | ||||||||||||||||||||||||||||||
583 | - | |||||||||||||||||||||||||||||||
584 | FxListItemSG *listItem = new FxListItemSG(item, q, false); | - | ||||||||||||||||||||||||||||||
585 | listItem->index = modelIndex; | - | ||||||||||||||||||||||||||||||
586 | - | |||||||||||||||||||||||||||||||
587 | // initialise attached properties | - | ||||||||||||||||||||||||||||||
588 | if (sectionCriteria) {
| 620-33073 | ||||||||||||||||||||||||||||||
589 | QString propValue = model->stringValue(modelIndex, sectionCriteria->property()); | - | ||||||||||||||||||||||||||||||
590 | QString section = sectionCriteria->sectionString(propValue); | - | ||||||||||||||||||||||||||||||
591 | QString prevSection; | - | ||||||||||||||||||||||||||||||
592 | QString nextSection; | - | ||||||||||||||||||||||||||||||
593 | if (modelIndex > 0) {
| 114-506 | ||||||||||||||||||||||||||||||
594 | if (FxViewItem *item = itemBefore(modelIndex))
| 110-396 | ||||||||||||||||||||||||||||||
595 | prevSection = item->attached->section(); executed 396 times by 3 tests: prevSection = item->attached->section(); Executed by:
| 396 | ||||||||||||||||||||||||||||||
596 | else | - | ||||||||||||||||||||||||||||||
597 | prevSection = sectionAt(modelIndex-1); executed 110 times by 3 tests: prevSection = sectionAt(modelIndex-1); Executed by:
| 110 | ||||||||||||||||||||||||||||||
598 | } | - | ||||||||||||||||||||||||||||||
599 | if (modelIndex < model->count()-1) {
| 46-574 | ||||||||||||||||||||||||||||||
600 | nextSection = sectionAt(modelIndex+1); | - | ||||||||||||||||||||||||||||||
601 | } executed 574 times by 4 tests: end of block Executed by:
| 574 | ||||||||||||||||||||||||||||||
602 | listItem->attached->setSections(prevSection, section, nextSection); | - | ||||||||||||||||||||||||||||||
603 | } executed 620 times by 4 tests: end of block Executed by:
| 620 | ||||||||||||||||||||||||||||||
604 | - | |||||||||||||||||||||||||||||||
605 | return listItem; executed 33693 times by 10 tests: return listItem; Executed by:
| 33693 | ||||||||||||||||||||||||||||||
606 | } | - | ||||||||||||||||||||||||||||||
607 | - | |||||||||||||||||||||||||||||||
608 | void QQuickListViewPrivate::initializeViewItem(FxViewItem *item) | - | ||||||||||||||||||||||||||||||
609 | { | - | ||||||||||||||||||||||||||||||
610 | QQuickItemViewPrivate::initializeViewItem(item); | - | ||||||||||||||||||||||||||||||
611 | - | |||||||||||||||||||||||||||||||
612 | // need to track current items that are animating | - | ||||||||||||||||||||||||||||||
613 | item->trackGeometry(true); | - | ||||||||||||||||||||||||||||||
614 | - | |||||||||||||||||||||||||||||||
615 | if (sectionCriteria && sectionCriteria->delegate()) {
| 118-33073 | ||||||||||||||||||||||||||||||
616 | if (QString::compare(item->attached->m_prevSection, item->attached->m_section, Qt::CaseInsensitive))
| 206-296 | ||||||||||||||||||||||||||||||
617 | updateInlineSection(static_cast<FxListItemSG*>(item)); executed 206 times by 3 tests: updateInlineSection(static_cast<FxListItemSG*>(item)); Executed by:
| 206 | ||||||||||||||||||||||||||||||
618 | } executed 502 times by 3 tests: end of block Executed by:
| 502 | ||||||||||||||||||||||||||||||
619 | } executed 33693 times by 10 tests: end of block Executed by:
| 33693 | ||||||||||||||||||||||||||||||
620 | - | |||||||||||||||||||||||||||||||
621 | bool QQuickListViewPrivate::releaseItem(FxViewItem *item) | - | ||||||||||||||||||||||||||||||
622 | { | - | ||||||||||||||||||||||||||||||
623 | if (!item || !model)
| 2410-33683 | ||||||||||||||||||||||||||||||
624 | return true; executed 7012 times by 11 tests: return true; Executed by:
| 7012 | ||||||||||||||||||||||||||||||
625 | - | |||||||||||||||||||||||||||||||
626 | QPointer<QQuickItem> it = item->item; | - | ||||||||||||||||||||||||||||||
627 | QQuickListViewAttached *att = static_cast<QQuickListViewAttached*>(item->attached); | - | ||||||||||||||||||||||||||||||
628 | - | |||||||||||||||||||||||||||||||
629 | bool released = QQuickItemViewPrivate::releaseItem(item); | - | ||||||||||||||||||||||||||||||
630 | if (released && it && att && att->m_sectionItem) {
| 0-29071 | ||||||||||||||||||||||||||||||
631 | // We hold no more references to this item | - | ||||||||||||||||||||||||||||||
632 | int i = 0; | - | ||||||||||||||||||||||||||||||
633 | do { | - | ||||||||||||||||||||||||||||||
634 | if (!sectionCache[i]) {
| 132-198 | ||||||||||||||||||||||||||||||
635 | sectionCache[i] = att->m_sectionItem; | - | ||||||||||||||||||||||||||||||
636 | sectionCache[i]->setVisible(false); | - | ||||||||||||||||||||||||||||||
637 | att->m_sectionItem = nullptr; | - | ||||||||||||||||||||||||||||||
638 | break; executed 132 times by 3 tests: break; Executed by:
| 132 | ||||||||||||||||||||||||||||||
639 | } | - | ||||||||||||||||||||||||||||||
640 | ++i; | - | ||||||||||||||||||||||||||||||
641 | } while (i < sectionCacheSize); executed 198 times by 2 tests: end of block Executed by:
| 10-198 | ||||||||||||||||||||||||||||||
642 | delete att->m_sectionItem; | - | ||||||||||||||||||||||||||||||
643 | att->m_sectionItem = nullptr; | - | ||||||||||||||||||||||||||||||
644 | } executed 142 times by 3 tests: end of block Executed by:
| 142 | ||||||||||||||||||||||||||||||
645 | - | |||||||||||||||||||||||||||||||
646 | return released; executed 31273 times by 9 tests: return released; Executed by:
| 31273 | ||||||||||||||||||||||||||||||
647 | } | - | ||||||||||||||||||||||||||||||
648 | - | |||||||||||||||||||||||||||||||
649 | bool QQuickListViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, qreal bufferFrom, qreal bufferTo, bool doBuffer) | - | ||||||||||||||||||||||||||||||
650 | { | - | ||||||||||||||||||||||||||||||
651 | qreal itemEnd = visiblePos; | - | ||||||||||||||||||||||||||||||
652 | if (visibleItems.count()) {
| 2190-30181 | ||||||||||||||||||||||||||||||
653 | visiblePos = (*visibleItems.constBegin())->position(); | - | ||||||||||||||||||||||||||||||
654 | itemEnd = (*(--visibleItems.constEnd()))->endPosition() + spacing; | - | ||||||||||||||||||||||||||||||
655 | } executed 30181 times by 7 tests: end of block Executed by:
| 30181 | ||||||||||||||||||||||||||||||
656 | - | |||||||||||||||||||||||||||||||
657 | int modelIndex = findLastVisibleIndex(); | - | ||||||||||||||||||||||||||||||
658 | bool haveValidItems = modelIndex >= 0; | - | ||||||||||||||||||||||||||||||
659 | modelIndex = modelIndex < 0 ? visibleIndex : modelIndex + 1;
| 2190-30181 | ||||||||||||||||||||||||||||||
660 | - | |||||||||||||||||||||||||||||||
661 | if (haveValidItems && (bufferFrom > itemEnd+averageSize+spacing
| 60-30181 | ||||||||||||||||||||||||||||||
662 | || bufferTo < visiblePos - averageSize - spacing)) {
| 16-30105 | ||||||||||||||||||||||||||||||
663 | // We've jumped more than a page. Estimate which items are now | - | ||||||||||||||||||||||||||||||
664 | // visible and fill from there. | - | ||||||||||||||||||||||||||||||
665 | int count = (fillFrom - itemEnd) / (averageSize + spacing); | - | ||||||||||||||||||||||||||||||
666 | int newModelIdx = qBound(0, modelIndex + count, model->count()); | - | ||||||||||||||||||||||||||||||
667 | count = newModelIdx - modelIndex; | - | ||||||||||||||||||||||||||||||
668 | if (count) {
| 34-42 | ||||||||||||||||||||||||||||||
669 | releaseVisibleItems(); | - | ||||||||||||||||||||||||||||||
670 | modelIndex = newModelIdx; | - | ||||||||||||||||||||||||||||||
671 | visibleIndex = modelIndex; | - | ||||||||||||||||||||||||||||||
672 | visiblePos = itemEnd + count * (averageSize + spacing); | - | ||||||||||||||||||||||||||||||
673 | itemEnd = visiblePos; | - | ||||||||||||||||||||||||||||||
674 | } executed 42 times by 1 test: end of block Executed by:
| 42 | ||||||||||||||||||||||||||||||
675 | } executed 76 times by 1 test: end of block Executed by:
| 76 | ||||||||||||||||||||||||||||||
676 | - | |||||||||||||||||||||||||||||||
677 | QQmlIncubator::IncubationMode incubationMode = doBuffer ? QQmlIncubator::Asynchronous : QQmlIncubator::AsynchronousIfNested;
| 12752-19619 | ||||||||||||||||||||||||||||||
678 | - | |||||||||||||||||||||||||||||||
679 | bool changed = false; | - | ||||||||||||||||||||||||||||||
680 | FxListItemSG *item = nullptr; | - | ||||||||||||||||||||||||||||||
681 | qreal pos = itemEnd; | - | ||||||||||||||||||||||||||||||
682 | while (modelIndex < model->count() && pos <= fillTo) {
| 11897-37706 | ||||||||||||||||||||||||||||||
683 | if (!(item = static_cast<FxListItemSG*>(createItem(modelIndex, incubationMode))))
| 1783-24026 | ||||||||||||||||||||||||||||||
684 | break; executed 1783 times by 3 tests: break; Executed by:
| 1783 | ||||||||||||||||||||||||||||||
685 | qCDebug(lcItemViewDelegateLifecycle) << "refill: append item" << modelIndex << "pos" << pos << "buffer" << doBuffer << "item" << (QObject *)(item->item); never executed: QMessageLogger(__FILE__, 685, __PRETTY_FUNCTION__, lcItemViewDelegateLifecycle().categoryName()).debug() << "refill: append item" << modelIndex << "pos" << pos << "buffer" << doBuffer << "item" << (QObject *)(item->item);
| 0-24026 | ||||||||||||||||||||||||||||||
686 | if (!transitioner || !transitioner->canTransition(QQuickItemViewTransitioner::PopulateTransition, true)) // pos will be set by layoutVisibleItems()
| 140-20118 | ||||||||||||||||||||||||||||||
687 | item->setPosition(pos, true); executed 23886 times by 9 tests: item->setPosition(pos, true); Executed by:
| 23886 | ||||||||||||||||||||||||||||||
688 | if (item->item)
| 0-24026 | ||||||||||||||||||||||||||||||
689 | QQuickItemPrivate::get(item->item)->setCulled(doBuffer); executed 24026 times by 10 tests: QQuickItemPrivate::get(item->item)->setCulled(doBuffer); Executed by:
| 24026 | ||||||||||||||||||||||||||||||
690 | pos += item->size() + spacing; | - | ||||||||||||||||||||||||||||||
691 | visibleItems.append(item); | - | ||||||||||||||||||||||||||||||
692 | ++modelIndex; | - | ||||||||||||||||||||||||||||||
693 | changed = true; | - | ||||||||||||||||||||||||||||||
694 | } executed 24026 times by 10 tests: end of block Executed by:
| 24026 | ||||||||||||||||||||||||||||||
695 | - | |||||||||||||||||||||||||||||||
696 | if (doBuffer && requestedIndex != -1) // already waiting for an item
| 1761-19619 | ||||||||||||||||||||||||||||||
697 | return changed; executed 1761 times by 3 tests: return changed; Executed by:
| 1761 | ||||||||||||||||||||||||||||||
698 | - | |||||||||||||||||||||||||||||||
699 | while (visibleIndex > 0 && visibleIndex <= model->count() && visiblePos > fillFrom) {
| 0-25180 | ||||||||||||||||||||||||||||||
700 | if (!(item = static_cast<FxListItemSG*>(createItem(visibleIndex-1, incubationMode))))
| 147-1681 | ||||||||||||||||||||||||||||||
701 | break; executed 147 times by 1 test: break; Executed by:
| 147 | ||||||||||||||||||||||||||||||
702 | qCDebug(lcItemViewDelegateLifecycle) << "refill: prepend item" << visibleIndex-1 << "current top pos" << visiblePos << "buffer" << doBuffer << "item" << (QObject *)(item->item); never executed: QMessageLogger(__FILE__, 702, __PRETTY_FUNCTION__, lcItemViewDelegateLifecycle().categoryName()).debug() << "refill: prepend item" << visibleIndex-1 << "current top pos" << visiblePos << "buffer" << doBuffer << "item" << (QObject *)(item->item);
| 0-1681 | ||||||||||||||||||||||||||||||
703 | --visibleIndex; | - | ||||||||||||||||||||||||||||||
704 | visiblePos -= item->size() + spacing; | - | ||||||||||||||||||||||||||||||
705 | if (!transitioner || !transitioner->canTransition(QQuickItemViewTransitioner::PopulateTransition, true)) // pos will be set by layoutVisibleItems()
| 0-1673 | ||||||||||||||||||||||||||||||
706 | item->setPosition(visiblePos, true); executed 1681 times by 2 tests: item->setPosition(visiblePos, true); Executed by:
| 1681 | ||||||||||||||||||||||||||||||
707 | if (item->item)
| 0-1681 | ||||||||||||||||||||||||||||||
708 | QQuickItemPrivate::get(item->item)->setCulled(doBuffer); executed 1681 times by 2 tests: QQuickItemPrivate::get(item->item)->setCulled(doBuffer); Executed by:
| 1681 | ||||||||||||||||||||||||||||||
709 | visibleItems.prepend(item); | - | ||||||||||||||||||||||||||||||
710 | changed = true; | - | ||||||||||||||||||||||||||||||
711 | } executed 1681 times by 2 tests: end of block Executed by:
| 1681 | ||||||||||||||||||||||||||||||
712 | - | |||||||||||||||||||||||||||||||
713 | return changed; executed 30610 times by 10 tests: return changed; Executed by:
| 30610 | ||||||||||||||||||||||||||||||
714 | } | - | ||||||||||||||||||||||||||||||
715 | - | |||||||||||||||||||||||||||||||
716 | void QQuickListViewPrivate::removeItem(FxViewItem *item) | - | ||||||||||||||||||||||||||||||
717 | { | - | ||||||||||||||||||||||||||||||
718 | if (item->transitionScheduledOrRunning()) {
| 14-2578 | ||||||||||||||||||||||||||||||
719 | qCDebug(lcItemViewDelegateLifecycle) << "\tnot releasing animating item" << item->index << (QObject *)(item->item); never executed: QMessageLogger(__FILE__, 719, __PRETTY_FUNCTION__, lcItemViewDelegateLifecycle().categoryName()).debug() << "\tnot releasing animating item" << item->index << (QObject *)(item->item);
| 0-14 | ||||||||||||||||||||||||||||||
720 | item->releaseAfterTransition = true; | - | ||||||||||||||||||||||||||||||
721 | releasePendingTransition.append(item); | - | ||||||||||||||||||||||||||||||
722 | } else { executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||||||||||||||
723 | qCDebug(lcItemViewDelegateLifecycle) << "\treleasing stationary item" << item->index << (QObject *)(item->item); never executed: QMessageLogger(__FILE__, 723, __PRETTY_FUNCTION__, lcItemViewDelegateLifecycle().categoryName()).debug() << "\treleasing stationary item" << item->index << (QObject *)(item->item);
| 0-2578 | ||||||||||||||||||||||||||||||
724 | releaseItem(item); | - | ||||||||||||||||||||||||||||||
725 | } executed 2578 times by 2 tests: end of block Executed by:
| 2578 | ||||||||||||||||||||||||||||||
726 | } | - | ||||||||||||||||||||||||||||||
727 | - | |||||||||||||||||||||||||||||||
728 | bool QQuickListViewPrivate::removeNonVisibleItems(qreal bufferFrom, qreal bufferTo) | - | ||||||||||||||||||||||||||||||
729 | { | - | ||||||||||||||||||||||||||||||
730 | FxViewItem *item = nullptr; | - | ||||||||||||||||||||||||||||||
731 | bool changed = false; | - | ||||||||||||||||||||||||||||||
732 | - | |||||||||||||||||||||||||||||||
733 | // Remove items from the start of the view. | - | ||||||||||||||||||||||||||||||
734 | // Zero-sized items shouldn't be removed unless a non-zero-sized item is also being | - | ||||||||||||||||||||||||||||||
735 | // removed, otherwise a zero-sized item is infinitely added and removed over and | - | ||||||||||||||||||||||||||||||
736 | // over by refill(). | - | ||||||||||||||||||||||||||||||
737 | int index = 0; | - | ||||||||||||||||||||||||||||||
738 | while (visibleItems.count() > 1 && index < visibleItems.count()
| 0-20597 | ||||||||||||||||||||||||||||||
739 | && (item = visibleItems.at(index)) && item->endPosition() < bufferFrom) {
| 0-20597 | ||||||||||||||||||||||||||||||
740 | if (item->attached->delayRemove())
| 0-1300 | ||||||||||||||||||||||||||||||
741 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
742 | - | |||||||||||||||||||||||||||||||
743 | if (item->size() > 0) {
| 8-1292 | ||||||||||||||||||||||||||||||
744 | qCDebug(lcItemViewDelegateLifecycle) << "refill: remove first" << visibleIndex << "top end pos" << item->endPosition(); never executed: QMessageLogger(__FILE__, 744, __PRETTY_FUNCTION__, lcItemViewDelegateLifecycle().categoryName()).debug() << "refill: remove first" << visibleIndex << "top end pos" << item->endPosition();
| 0-1292 | ||||||||||||||||||||||||||||||
745 | // remove this item and all zero-sized items before it | - | ||||||||||||||||||||||||||||||
746 | while (item) {
| 0-1296 | ||||||||||||||||||||||||||||||
747 | if (item->index != -1)
| 0-1296 | ||||||||||||||||||||||||||||||
748 | visibleIndex++; executed 1296 times by 2 tests: visibleIndex++; Executed by:
| 1296 | ||||||||||||||||||||||||||||||
749 | visibleItems.removeAt(index); | - | ||||||||||||||||||||||||||||||
750 | removeItem(item); | - | ||||||||||||||||||||||||||||||
751 | if (index == 0)
| 4-1292 | ||||||||||||||||||||||||||||||
752 | break; executed 1292 times by 2 tests: break; Executed by:
| 1292 | ||||||||||||||||||||||||||||||
753 | item = visibleItems.at(--index); | - | ||||||||||||||||||||||||||||||
754 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||||||||
755 | changed = true; | - | ||||||||||||||||||||||||||||||
756 | } else { executed 1292 times by 2 tests: end of block Executed by:
| 1292 | ||||||||||||||||||||||||||||||
757 | index++; | - | ||||||||||||||||||||||||||||||
758 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||||||||
759 | } | - | ||||||||||||||||||||||||||||||
760 | - | |||||||||||||||||||||||||||||||
761 | while (visibleItems.count() > 1 && (item = visibleItems.constLast()) && item->position() > bufferTo) {
| 0-20492 | ||||||||||||||||||||||||||||||
762 | if (item->attached->delayRemove())
| 0-1197 | ||||||||||||||||||||||||||||||
763 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
764 | qCDebug(lcItemViewDelegateLifecycle) << "refill: remove last" << visibleIndex+visibleItems.count()-1 << item->position() << (QObject *)(item->item); never executed: QMessageLogger(__FILE__, 764, __PRETTY_FUNCTION__, lcItemViewDelegateLifecycle().categoryName()).debug() << "refill: remove last" << visibleIndex+visibleItems.count()-1 << item->position() << (QObject *)(item->item);
| 0-1197 | ||||||||||||||||||||||||||||||
765 | visibleItems.removeLast(); | - | ||||||||||||||||||||||||||||||
766 | removeItem(item); | - | ||||||||||||||||||||||||||||||
767 | changed = true; | - | ||||||||||||||||||||||||||||||
768 | } executed 1197 times by 2 tests: end of block Executed by:
| 1197 | ||||||||||||||||||||||||||||||
769 | - | |||||||||||||||||||||||||||||||
770 | return changed; executed 19619 times by 10 tests: return changed; Executed by:
| 19619 | ||||||||||||||||||||||||||||||
771 | } | - | ||||||||||||||||||||||||||||||
772 | - | |||||||||||||||||||||||||||||||
773 | void QQuickListViewPrivate::visibleItemsChanged() | - | ||||||||||||||||||||||||||||||
774 | { | - | ||||||||||||||||||||||||||||||
775 | if (visibleItems.count())
| 0-5566 | ||||||||||||||||||||||||||||||
776 | visiblePos = (*visibleItems.constBegin())->position(); executed 5566 times by 10 tests: visiblePos = (*visibleItems.constBegin())->position(); Executed by:
| 5566 | ||||||||||||||||||||||||||||||
777 | updateAverage(); | - | ||||||||||||||||||||||||||||||
778 | if (currentIndex >= 0 && currentItem && !visibleItem(currentIndex)) {
| 290-3918 | ||||||||||||||||||||||||||||||
779 | static_cast<FxListItemSG*>(currentItem)->setPosition(positionAt(currentIndex)); | - | ||||||||||||||||||||||||||||||
780 | updateHighlight(); | - | ||||||||||||||||||||||||||||||
781 | } executed 901 times by 3 tests: end of block Executed by:
| 901 | ||||||||||||||||||||||||||||||
782 | if (sectionCriteria)
| 201-5365 | ||||||||||||||||||||||||||||||
783 | updateCurrentSection(); executed 201 times by 4 tests: updateCurrentSection(); Executed by:
| 201 | ||||||||||||||||||||||||||||||
784 | updateUnrequestedPositions(); | - | ||||||||||||||||||||||||||||||
785 | } executed 5566 times by 10 tests: end of block Executed by:
| 5566 | ||||||||||||||||||||||||||||||
786 | - | |||||||||||||||||||||||||||||||
787 | void QQuickListViewPrivate::layoutVisibleItems(int fromModelIndex) | - | ||||||||||||||||||||||||||||||
788 | { | - | ||||||||||||||||||||||||||||||
789 | if (!visibleItems.isEmpty()) {
| 124-3341 | ||||||||||||||||||||||||||||||
790 | const qreal from = isContentFlowReversed() ? -position()-displayMarginBeginning-size() : position()-displayMarginBeginning;
| 370-2971 | ||||||||||||||||||||||||||||||
791 | const qreal to = isContentFlowReversed() ? -position()+displayMarginEnd : position()+size()+displayMarginEnd;
| 370-2971 | ||||||||||||||||||||||||||||||
792 | - | |||||||||||||||||||||||||||||||
793 | FxViewItem *firstItem = *visibleItems.constBegin(); | - | ||||||||||||||||||||||||||||||
794 | bool fixedCurrent = currentItem && firstItem->item == currentItem->item;
| 23-3318 | ||||||||||||||||||||||||||||||
795 | qreal sum = firstItem->size(); | - | ||||||||||||||||||||||||||||||
796 | qreal pos = firstItem->position() + firstItem->size() + spacing; | - | ||||||||||||||||||||||||||||||
797 | firstItem->setVisible(firstItem->endPosition() >= from && firstItem->position() <= to); | - | ||||||||||||||||||||||||||||||
798 | - | |||||||||||||||||||||||||||||||
799 | for (int i=1; i < visibleItems.count(); ++i) {
| 3341-39094 | ||||||||||||||||||||||||||||||
800 | FxListItemSG *item = static_cast<FxListItemSG*>(visibleItems.at(i)); | - | ||||||||||||||||||||||||||||||
801 | if (item->index >= fromModelIndex) {
| 2191-36903 | ||||||||||||||||||||||||||||||
802 | item->setPosition(pos); | - | ||||||||||||||||||||||||||||||
803 | item->setVisible(item->endPosition() >= from && item->position() <= to); | - | ||||||||||||||||||||||||||||||
804 | } executed 36903 times by 6 tests: end of block Executed by:
| 36903 | ||||||||||||||||||||||||||||||
805 | pos += item->size() + spacing; | - | ||||||||||||||||||||||||||||||
806 | sum += item->size(); | - | ||||||||||||||||||||||||||||||
807 | fixedCurrent = fixedCurrent || (currentItem && item->item == currentItem->item);
| 201-29997 | ||||||||||||||||||||||||||||||
808 | } executed 39094 times by 6 tests: end of block Executed by:
| 39094 | ||||||||||||||||||||||||||||||
809 | averageSize = qRound(sum / visibleItems.count()); | - | ||||||||||||||||||||||||||||||
810 | - | |||||||||||||||||||||||||||||||
811 | // move current item if it is not a visible item. | - | ||||||||||||||||||||||||||||||
812 | if (currentIndex >= 0 && currentItem && !fixedCurrent)
| 2-3320 | ||||||||||||||||||||||||||||||
813 | static_cast<FxListItemSG*>(currentItem)->setPosition(positionAt(currentIndex)); executed 385 times by 2 tests: static_cast<FxListItemSG*>(currentItem)->setPosition(positionAt(currentIndex)); Executed by:
| 385 | ||||||||||||||||||||||||||||||
814 | - | |||||||||||||||||||||||||||||||
815 | updateCurrentSection(); | - | ||||||||||||||||||||||||||||||
816 | updateStickySections(); | - | ||||||||||||||||||||||||||||||
817 | } executed 3341 times by 7 tests: end of block Executed by:
| 3341 | ||||||||||||||||||||||||||||||
818 | } executed 3465 times by 7 tests: end of block Executed by:
| 3465 | ||||||||||||||||||||||||||||||
819 | - | |||||||||||||||||||||||||||||||
820 | void QQuickListViewPrivate::repositionItemAt(FxViewItem *item, int index, qreal sizeBuffer) | - | ||||||||||||||||||||||||||||||
821 | { | - | ||||||||||||||||||||||||||||||
822 | static_cast<FxListItemSG *>(item)->setPosition(positionAt(index) + sizeBuffer); | - | ||||||||||||||||||||||||||||||
823 | } executed 34 times by 1 test: end of block Executed by:
| 34 | ||||||||||||||||||||||||||||||
824 | - | |||||||||||||||||||||||||||||||
825 | void QQuickListViewPrivate::repositionPackageItemAt(QQuickItem *item, int index) | - | ||||||||||||||||||||||||||||||
826 | { | - | ||||||||||||||||||||||||||||||
827 | Q_Q(QQuickListView); | - | ||||||||||||||||||||||||||||||
828 | qreal pos = position(); | - | ||||||||||||||||||||||||||||||
829 | if (orient == QQuickListView::Vertical) {
| 0-342 | ||||||||||||||||||||||||||||||
830 | if (item->y() + item->height() > pos && item->y() < pos + q->height()) {
| 16-320 | ||||||||||||||||||||||||||||||
831 | if (isBottomToTop())
| 4-300 | ||||||||||||||||||||||||||||||
832 | item->setY(-positionAt(index)-item->height()); executed 4 times by 1 test: item->setY(-positionAt(index)-item->height()); Executed by:
| 4 | ||||||||||||||||||||||||||||||
833 | else | - | ||||||||||||||||||||||||||||||
834 | item->setY(positionAt(index)); executed 300 times by 2 tests: item->setY(positionAt(index)); Executed by:
| 300 | ||||||||||||||||||||||||||||||
835 | } | - | ||||||||||||||||||||||||||||||
836 | } else { executed 342 times by 2 tests: end of block Executed by:
| 342 | ||||||||||||||||||||||||||||||
837 | if (item->x() + item->width() > pos && item->x() < pos + q->width()) {
| 0 | ||||||||||||||||||||||||||||||
838 | if (isRightToLeft())
| 0 | ||||||||||||||||||||||||||||||
839 | item->setX(-positionAt(index)-item->width()); never executed: item->setX(-positionAt(index)-item->width()); | 0 | ||||||||||||||||||||||||||||||
840 | else | - | ||||||||||||||||||||||||||||||
841 | item->setX(positionAt(index)); never executed: item->setX(positionAt(index)); | 0 | ||||||||||||||||||||||||||||||
842 | } | - | ||||||||||||||||||||||||||||||
843 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
844 | } | - | ||||||||||||||||||||||||||||||
845 | - | |||||||||||||||||||||||||||||||
846 | void QQuickListViewPrivate::resetFirstItemPosition(qreal pos) | - | ||||||||||||||||||||||||||||||
847 | { | - | ||||||||||||||||||||||||||||||
848 | FxListItemSG *item = static_cast<FxListItemSG*>(visibleItems.constFirst()); | - | ||||||||||||||||||||||||||||||
849 | item->setPosition(pos); | - | ||||||||||||||||||||||||||||||
850 | } executed 817 times by 3 tests: end of block Executed by:
| 817 | ||||||||||||||||||||||||||||||
851 | - | |||||||||||||||||||||||||||||||
852 | void QQuickListViewPrivate::adjustFirstItem(qreal forwards, qreal backwards, int) | - | ||||||||||||||||||||||||||||||
853 | { | - | ||||||||||||||||||||||||||||||
854 | if (!visibleItems.count())
| 0-1443 | ||||||||||||||||||||||||||||||
855 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
856 | qreal diff = forwards - backwards; | - | ||||||||||||||||||||||||||||||
857 | static_cast<FxListItemSG*>(visibleItems.constFirst())->setPosition(visibleItems.constFirst()->position() + diff); | - | ||||||||||||||||||||||||||||||
858 | } executed 1443 times by 2 tests: end of block Executed by:
| 1443 | ||||||||||||||||||||||||||||||
859 | - | |||||||||||||||||||||||||||||||
860 | void QQuickListViewPrivate::updateSizeChangesBeforeVisiblePos(FxViewItem *item, ChangeResult *removeResult) | - | ||||||||||||||||||||||||||||||
861 | { | - | ||||||||||||||||||||||||||||||
862 | if (item != visibleItems.constFirst())
| 28-78 | ||||||||||||||||||||||||||||||
863 | QQuickItemViewPrivate::updateSizeChangesBeforeVisiblePos(item, removeResult); executed 28 times by 1 test: QQuickItemViewPrivate::updateSizeChangesBeforeVisiblePos(item, removeResult); Executed by:
| 28 | ||||||||||||||||||||||||||||||
864 | } executed 106 times by 1 test: end of block Executed by:
| 106 | ||||||||||||||||||||||||||||||
865 | - | |||||||||||||||||||||||||||||||
866 | void QQuickListViewPrivate::createHighlight() | - | ||||||||||||||||||||||||||||||
867 | { | - | ||||||||||||||||||||||||||||||
868 | Q_Q(QQuickListView); | - | ||||||||||||||||||||||||||||||
869 | bool changed = false; | - | ||||||||||||||||||||||||||||||
870 | if (highlight) {
| 2200-4924 | ||||||||||||||||||||||||||||||
871 | if (trackedItem == highlight)
| 0-2200 | ||||||||||||||||||||||||||||||
872 | trackedItem = nullptr; executed 2200 times by 9 tests: trackedItem = nullptr; Executed by:
| 2200 | ||||||||||||||||||||||||||||||
873 | delete highlight; | - | ||||||||||||||||||||||||||||||
874 | highlight = nullptr; | - | ||||||||||||||||||||||||||||||
875 | - | |||||||||||||||||||||||||||||||
876 | delete highlightPosAnimator; | - | ||||||||||||||||||||||||||||||
877 | delete highlightWidthAnimator; | - | ||||||||||||||||||||||||||||||
878 | delete highlightHeightAnimator; | - | ||||||||||||||||||||||||||||||
879 | highlightPosAnimator = nullptr; | - | ||||||||||||||||||||||||||||||
880 | highlightWidthAnimator = nullptr; | - | ||||||||||||||||||||||||||||||
881 | highlightHeightAnimator = nullptr; | - | ||||||||||||||||||||||||||||||
882 | - | |||||||||||||||||||||||||||||||
883 | changed = true; | - | ||||||||||||||||||||||||||||||
884 | } executed 2200 times by 9 tests: end of block Executed by:
| 2200 | ||||||||||||||||||||||||||||||
885 | - | |||||||||||||||||||||||||||||||
886 | if (currentItem) {
| 2212-4912 | ||||||||||||||||||||||||||||||
887 | QQuickItem *item = createHighlightItem(); | - | ||||||||||||||||||||||||||||||
888 | if (item) {
| 8-2204 | ||||||||||||||||||||||||||||||
889 | FxListItemSG *newHighlight = new FxListItemSG(item, q, true); | - | ||||||||||||||||||||||||||||||
890 | newHighlight->trackGeometry(true); | - | ||||||||||||||||||||||||||||||
891 | - | |||||||||||||||||||||||||||||||
892 | if (autoHighlight) {
| 10-2194 | ||||||||||||||||||||||||||||||
893 | newHighlight->setSize(static_cast<FxListItemSG*>(currentItem)->itemSize()); | - | ||||||||||||||||||||||||||||||
894 | newHighlight->setPosition(static_cast<FxListItemSG*>(currentItem)->itemPosition()); | - | ||||||||||||||||||||||||||||||
895 | } executed 2194 times by 10 tests: end of block Executed by:
| 2194 | ||||||||||||||||||||||||||||||
896 | const QLatin1String posProp(orient == QQuickListView::Vertical ? "y" : "x"); | - | ||||||||||||||||||||||||||||||
897 | highlightPosAnimator = new QSmoothedAnimation; | - | ||||||||||||||||||||||||||||||
898 | highlightPosAnimator->target = QQmlProperty(item, posProp); | - | ||||||||||||||||||||||||||||||
899 | highlightPosAnimator->velocity = highlightMoveVelocity; | - | ||||||||||||||||||||||||||||||
900 | highlightPosAnimator->userDuration = highlightMoveDuration; | - | ||||||||||||||||||||||||||||||
901 | - | |||||||||||||||||||||||||||||||
902 | highlightWidthAnimator = new QSmoothedAnimation; | - | ||||||||||||||||||||||||||||||
903 | highlightWidthAnimator->velocity = highlightResizeVelocity; | - | ||||||||||||||||||||||||||||||
904 | highlightWidthAnimator->userDuration = highlightResizeDuration; | - | ||||||||||||||||||||||||||||||
905 | highlightWidthAnimator->target = QQmlProperty(item, QStringLiteral("width")); executed 2204 times by 10 tests: return qstring_literal_temp; Executed by:
| 2204 | ||||||||||||||||||||||||||||||
906 | - | |||||||||||||||||||||||||||||||
907 | highlightHeightAnimator = new QSmoothedAnimation; | - | ||||||||||||||||||||||||||||||
908 | highlightHeightAnimator->velocity = highlightResizeVelocity; | - | ||||||||||||||||||||||||||||||
909 | highlightHeightAnimator->userDuration = highlightResizeDuration; | - | ||||||||||||||||||||||||||||||
910 | highlightHeightAnimator->target = QQmlProperty(item, QStringLiteral("height")); executed 2204 times by 10 tests: return qstring_literal_temp; Executed by:
| 2204 | ||||||||||||||||||||||||||||||
911 | - | |||||||||||||||||||||||||||||||
912 | highlight = newHighlight; | - | ||||||||||||||||||||||||||||||
913 | changed = true; | - | ||||||||||||||||||||||||||||||
914 | } executed 2204 times by 10 tests: end of block Executed by:
| 2204 | ||||||||||||||||||||||||||||||
915 | } executed 2212 times by 10 tests: end of block Executed by:
| 2212 | ||||||||||||||||||||||||||||||
916 | if (changed)
| 2722-4402 | ||||||||||||||||||||||||||||||
917 | emit q->highlightItemChanged(); executed 4402 times by 10 tests: q->highlightItemChanged(); Executed by:
| 4402 | ||||||||||||||||||||||||||||||
918 | } executed 7124 times by 11 tests: end of block Executed by:
| 7124 | ||||||||||||||||||||||||||||||
919 | - | |||||||||||||||||||||||||||||||
920 | void QQuickListViewPrivate::updateHighlight() | - | ||||||||||||||||||||||||||||||
921 | { | - | ||||||||||||||||||||||||||||||
922 | applyPendingChanges(); | - | ||||||||||||||||||||||||||||||
923 | - | |||||||||||||||||||||||||||||||
924 | if ((!currentItem && highlight) || (currentItem && !highlight))
| 27-11043 | ||||||||||||||||||||||||||||||
925 | createHighlight(); executed 2254 times by 10 tests: createHighlight(); Executed by:
| 2254 | ||||||||||||||||||||||||||||||
926 | bool strictHighlight = haveHighlightRange && highlightRange == QQuickListView::StrictlyEnforceRange;
| 18-9762 | ||||||||||||||||||||||||||||||
927 | if (currentItem && autoHighlight && highlight && (!strictHighlight || !pressed)) {
| 4-11043 | ||||||||||||||||||||||||||||||
928 | // auto-update highlight | - | ||||||||||||||||||||||||||||||
929 | FxListItemSG *listItem = static_cast<FxListItemSG*>(currentItem); | - | ||||||||||||||||||||||||||||||
930 | highlightPosAnimator->to = isContentFlowReversed()
| 1124-9789 | ||||||||||||||||||||||||||||||
931 | ? -listItem->itemPosition()-listItem->itemSize() | - | ||||||||||||||||||||||||||||||
932 | : listItem->itemPosition(); | - | ||||||||||||||||||||||||||||||
933 | highlightWidthAnimator->to = listItem->item->width(); | - | ||||||||||||||||||||||||||||||
934 | highlightHeightAnimator->to = listItem->item->height(); | - | ||||||||||||||||||||||||||||||
935 | if (orient == QQuickListView::Vertical) {
| 977-9936 | ||||||||||||||||||||||||||||||
936 | if (highlight->item->width() == 0)
| 1935-8001 | ||||||||||||||||||||||||||||||
937 | highlight->item->setWidth(currentItem->item->width()); executed 1935 times by 10 tests: highlight->item->setWidth(currentItem->item->width()); Executed by:
| 1935 | ||||||||||||||||||||||||||||||
938 | } else { executed 9936 times by 10 tests: end of block Executed by:
| 9936 | ||||||||||||||||||||||||||||||
939 | if (highlight->item->height() == 0)
| 178-799 | ||||||||||||||||||||||||||||||
940 | highlight->item->setHeight(currentItem->item->height()); executed 178 times by 2 tests: highlight->item->setHeight(currentItem->item->height()); Executed by:
| 178 | ||||||||||||||||||||||||||||||
941 | } executed 977 times by 2 tests: end of block Executed by:
| 977 | ||||||||||||||||||||||||||||||
942 | - | |||||||||||||||||||||||||||||||
943 | highlightPosAnimator->restart(); | - | ||||||||||||||||||||||||||||||
944 | highlightWidthAnimator->restart(); | - | ||||||||||||||||||||||||||||||
945 | highlightHeightAnimator->restart(); | - | ||||||||||||||||||||||||||||||
946 | } executed 10913 times by 10 tests: end of block Executed by:
| 10913 | ||||||||||||||||||||||||||||||
947 | updateTrackedItem(); | - | ||||||||||||||||||||||||||||||
948 | } executed 11122 times by 10 tests: end of block Executed by:
| 11122 | ||||||||||||||||||||||||||||||
949 | - | |||||||||||||||||||||||||||||||
950 | void QQuickListViewPrivate::resetHighlightPosition() | - | ||||||||||||||||||||||||||||||
951 | { | - | ||||||||||||||||||||||||||||||
952 | if (highlight && currentItem)
| 0-1930 | ||||||||||||||||||||||||||||||
953 | static_cast<FxListItemSG*>(highlight)->setPosition(static_cast<FxListItemSG*>(currentItem)->itemPosition()); executed 1930 times by 10 tests: static_cast<FxListItemSG*>(highlight)->setPosition(static_cast<FxListItemSG*>(currentItem)->itemPosition()); Executed by:
| 1930 | ||||||||||||||||||||||||||||||
954 | } executed 1930 times by 10 tests: end of block Executed by:
| 1930 | ||||||||||||||||||||||||||||||
955 | - | |||||||||||||||||||||||||||||||
956 | bool QQuickListViewPrivate::movingFromHighlight() | - | ||||||||||||||||||||||||||||||
957 | { | - | ||||||||||||||||||||||||||||||
958 | if (!haveHighlightRange || highlightRange != QQuickListView::StrictlyEnforceRange)
| 2-2893 | ||||||||||||||||||||||||||||||
959 | return false; executed 2895 times by 7 tests: return false; Executed by:
| 2895 | ||||||||||||||||||||||||||||||
960 | - | |||||||||||||||||||||||||||||||
961 | return (highlightPosAnimator && highlightPosAnimator->isRunning()) || executed 126 times by 2 tests: return (highlightPosAnimator && highlightPosAnimator->isRunning()) || (highlightHeightAnimator && highlightHeightAnimator->isRunning()) || (highlightWidthAnimator && highlightWidthAnimator->isRunning()); Executed by:
| 126 | ||||||||||||||||||||||||||||||
962 | (highlightHeightAnimator && highlightHeightAnimator->isRunning()) || executed 126 times by 2 tests: return (highlightPosAnimator && highlightPosAnimator->isRunning()) || (highlightHeightAnimator && highlightHeightAnimator->isRunning()) || (highlightWidthAnimator && highlightWidthAnimator->isRunning()); Executed by:
| 126 | ||||||||||||||||||||||||||||||
963 | (highlightWidthAnimator && highlightWidthAnimator->isRunning()); executed 126 times by 2 tests: return (highlightPosAnimator && highlightPosAnimator->isRunning()) || (highlightHeightAnimator && highlightHeightAnimator->isRunning()) || (highlightWidthAnimator && highlightWidthAnimator->isRunning()); Executed by:
| 126 | ||||||||||||||||||||||||||||||
964 | } | - | ||||||||||||||||||||||||||||||
965 | - | |||||||||||||||||||||||||||||||
966 | - | |||||||||||||||||||||||||||||||
967 | QQuickItem * QQuickListViewPrivate::getSectionItem(const QString §ion) | - | ||||||||||||||||||||||||||||||
968 | { | - | ||||||||||||||||||||||||||||||
969 | Q_Q(QQuickListView); | - | ||||||||||||||||||||||||||||||
970 | QQuickItem *sectionItem = nullptr; | - | ||||||||||||||||||||||||||||||
971 | int i = sectionCacheSize-1; | - | ||||||||||||||||||||||||||||||
972 | while (i >= 0 && !sectionCache[i])
| 20-1008 | ||||||||||||||||||||||||||||||
973 | --i; executed 988 times by 3 tests: --i; Executed by:
| 988 | ||||||||||||||||||||||||||||||
974 | if (i >= 0) {
| 20-182 | ||||||||||||||||||||||||||||||
975 | sectionItem = sectionCache[i]; | - | ||||||||||||||||||||||||||||||
976 | sectionCache[i] = nullptr; | - | ||||||||||||||||||||||||||||||
977 | sectionItem->setVisible(true); | - | ||||||||||||||||||||||||||||||
978 | QQmlContext *context = QQmlEngine::contextForObject(sectionItem)->parentContext(); | - | ||||||||||||||||||||||||||||||
979 | context->setContextProperty(QLatin1String("section"), section); | - | ||||||||||||||||||||||||||||||
980 | } else { executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||||||||||||||
981 | QQmlContext *creationContext = sectionCriteria->delegate()->creationContext(); | - | ||||||||||||||||||||||||||||||
982 | QQmlContext *context = new QQmlContext( | - | ||||||||||||||||||||||||||||||
983 | creationContext ? creationContext : qmlContext(q)); | - | ||||||||||||||||||||||||||||||
984 | context->setContextProperty(QLatin1String("section"), section); | - | ||||||||||||||||||||||||||||||
985 | QObject *nobj = sectionCriteria->delegate()->beginCreate(context); | - | ||||||||||||||||||||||||||||||
986 | if (nobj) {
| 0-182 | ||||||||||||||||||||||||||||||
987 | QQml_setParent_noEvent(context, nobj); | - | ||||||||||||||||||||||||||||||
988 | sectionItem = qobject_cast<QQuickItem *>(nobj); | - | ||||||||||||||||||||||||||||||
989 | if (!sectionItem) {
| 0-182 | ||||||||||||||||||||||||||||||
990 | delete nobj; | - | ||||||||||||||||||||||||||||||
991 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
992 | if (qFuzzyIsNull(sectionItem->z()))
| 2-180 | ||||||||||||||||||||||||||||||
993 | sectionItem->setZ(2); executed 180 times by 3 tests: sectionItem->setZ(2); Executed by:
| 180 | ||||||||||||||||||||||||||||||
994 | QQml_setParent_noEvent(sectionItem, contentItem); | - | ||||||||||||||||||||||||||||||
995 | sectionItem->setParentItem(contentItem); | - | ||||||||||||||||||||||||||||||
996 | } executed 182 times by 3 tests: end of block Executed by:
| 182 | ||||||||||||||||||||||||||||||
997 | // sections are not controlled by FxListItemSG, so apply attached properties here | - | ||||||||||||||||||||||||||||||
998 | QQuickItemViewAttached *attached = static_cast<QQuickItemViewAttached*>(qmlAttachedPropertiesObject<QQuickListView>(sectionItem)); | - | ||||||||||||||||||||||||||||||
999 | attached->setView(q); | - | ||||||||||||||||||||||||||||||
1000 | } else { executed 182 times by 3 tests: end of block Executed by:
| 182 | ||||||||||||||||||||||||||||||
1001 | delete context; | - | ||||||||||||||||||||||||||||||
1002 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1003 | sectionCriteria->delegate()->completeCreate(); | - | ||||||||||||||||||||||||||||||
1004 | } executed 182 times by 3 tests: end of block Executed by:
| 182 | ||||||||||||||||||||||||||||||
1005 | - | |||||||||||||||||||||||||||||||
1006 | return sectionItem; executed 202 times by 3 tests: return sectionItem; Executed by:
| 202 | ||||||||||||||||||||||||||||||
1007 | } | - | ||||||||||||||||||||||||||||||
1008 | - | |||||||||||||||||||||||||||||||
1009 | void QQuickListViewPrivate::releaseSectionItem(QQuickItem *item) | - | ||||||||||||||||||||||||||||||
1010 | { | - | ||||||||||||||||||||||||||||||
1011 | if (!item)
| 40-8416 | ||||||||||||||||||||||||||||||
1012 | return; executed 8416 times by 11 tests: return; Executed by:
| 8416 | ||||||||||||||||||||||||||||||
1013 | int i = 0; | - | ||||||||||||||||||||||||||||||
1014 | do { | - | ||||||||||||||||||||||||||||||
1015 | if (!sectionCache[i]) {
| 24-106 | ||||||||||||||||||||||||||||||
1016 | sectionCache[i] = item; | - | ||||||||||||||||||||||||||||||
1017 | sectionCache[i]->setVisible(false); | - | ||||||||||||||||||||||||||||||
1018 | return; executed 24 times by 1 test: return; Executed by:
| 24 | ||||||||||||||||||||||||||||||
1019 | } | - | ||||||||||||||||||||||||||||||
1020 | ++i; | - | ||||||||||||||||||||||||||||||
1021 | } while (i < sectionCacheSize); executed 106 times by 1 test: end of block Executed by:
| 16-106 | ||||||||||||||||||||||||||||||
1022 | delete item; | - | ||||||||||||||||||||||||||||||
1023 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||||||||||||||
1024 | - | |||||||||||||||||||||||||||||||
1025 | - | |||||||||||||||||||||||||||||||
1026 | void QQuickListViewPrivate::releaseSectionItems() | - | ||||||||||||||||||||||||||||||
1027 | { | - | ||||||||||||||||||||||||||||||
1028 | for (FxViewItem *item : qAsConst(visibleItems)) { | - | ||||||||||||||||||||||||||||||
1029 | FxListItemSG *listItem = static_cast<FxListItemSG *>(item); | - | ||||||||||||||||||||||||||||||
1030 | if (listItem->section()) {
| 0-26 | ||||||||||||||||||||||||||||||
1031 | qreal pos = listItem->position(); | - | ||||||||||||||||||||||||||||||
1032 | releaseSectionItem(listItem->section()); | - | ||||||||||||||||||||||||||||||
1033 | listItem->setSection(nullptr); | - | ||||||||||||||||||||||||||||||
1034 | listItem->setPosition(pos); | - | ||||||||||||||||||||||||||||||
1035 | } executed 26 times by 1 test: end of block Executed by:
| 26 | ||||||||||||||||||||||||||||||
1036 | } executed 26 times by 1 test: end of block Executed by:
| 26 | ||||||||||||||||||||||||||||||
1037 | for (int i = 0; i < sectionCacheSize; ++i) {
| 2-10 | ||||||||||||||||||||||||||||||
1038 | delete sectionCache[i]; | - | ||||||||||||||||||||||||||||||
1039 | sectionCache[i] = nullptr; | - | ||||||||||||||||||||||||||||||
1040 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||||||||
1041 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||||||||
1042 | - | |||||||||||||||||||||||||||||||
1043 | void QQuickListViewPrivate::updateInlineSection(FxListItemSG *listItem) | - | ||||||||||||||||||||||||||||||
1044 | { | - | ||||||||||||||||||||||||||||||
1045 | if (!sectionCriteria || !sectionCriteria->delegate())
| 0-6418 | ||||||||||||||||||||||||||||||
1046 | return; executed 792 times by 2 tests: return; Executed by:
| 792 | ||||||||||||||||||||||||||||||
1047 | if (QString::compare(listItem->attached->m_prevSection, listItem->attached->m_section, Qt::CaseInsensitive)
| 938-4688 | ||||||||||||||||||||||||||||||
1048 | && (sectionCriteria->labelPositioning() & QQuickViewSection::InlineLabels
| 0-4688 | ||||||||||||||||||||||||||||||
1049 | || (listItem->index == 0 && sectionCriteria->labelPositioning() & QQuickViewSection::CurrentLabelAtStart))) {
| 0 | ||||||||||||||||||||||||||||||
1050 | if (!listItem->section()) {
| 194-4494 | ||||||||||||||||||||||||||||||
1051 | qreal pos = listItem->position(); | - | ||||||||||||||||||||||||||||||
1052 | listItem->setSection(getSectionItem(listItem->attached->m_section)); | - | ||||||||||||||||||||||||||||||
1053 | listItem->setPosition(pos); | - | ||||||||||||||||||||||||||||||
1054 | } else { executed 194 times by 3 tests: end of block Executed by:
| 194 | ||||||||||||||||||||||||||||||
1055 | QQmlContext *context = QQmlEngine::contextForObject(listItem->section())->parentContext(); | - | ||||||||||||||||||||||||||||||
1056 | context->setContextProperty(QLatin1String("section"), listItem->attached->m_section); | - | ||||||||||||||||||||||||||||||
1057 | } executed 4494 times by 3 tests: end of block Executed by:
| 4494 | ||||||||||||||||||||||||||||||
1058 | } else if (listItem->section()) {
| 6-932 | ||||||||||||||||||||||||||||||
1059 | qreal pos = listItem->position(); | - | ||||||||||||||||||||||||||||||
1060 | releaseSectionItem(listItem->section()); | - | ||||||||||||||||||||||||||||||
1061 | listItem->setSection(nullptr); | - | ||||||||||||||||||||||||||||||
1062 | listItem->setPosition(pos); | - | ||||||||||||||||||||||||||||||
1063 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||||||||
1064 | } executed 5626 times by 3 tests: end of block Executed by:
| 5626 | ||||||||||||||||||||||||||||||
1065 | - | |||||||||||||||||||||||||||||||
1066 | void QQuickListViewPrivate::updateStickySections() | - | ||||||||||||||||||||||||||||||
1067 | { | - | ||||||||||||||||||||||||||||||
1068 | if (!sectionCriteria || !sectionCriteria->delegate()
| 50-3014 | ||||||||||||||||||||||||||||||
1069 | || (!sectionCriteria->labelPositioning() && !currentSectionItem && !nextSectionItem))
| 0-925 | ||||||||||||||||||||||||||||||
1070 | return; executed 3064 times by 6 tests: return; Executed by:
| 3064 | ||||||||||||||||||||||||||||||
1071 | - | |||||||||||||||||||||||||||||||
1072 | bool isFlowReversed = isContentFlowReversed(); | - | ||||||||||||||||||||||||||||||
1073 | qreal viewPos = isFlowReversed ? -position()-size() : position();
| 0-925 | ||||||||||||||||||||||||||||||
1074 | qreal startPos = hasStickyHeader() ? header->endPosition() : viewPos;
| 0-925 | ||||||||||||||||||||||||||||||
1075 | qreal endPos = hasStickyFooter() ? footer->position() : viewPos + size();
| 0-925 | ||||||||||||||||||||||||||||||
1076 | - | |||||||||||||||||||||||||||||||
1077 | QQuickItem *sectionItem = nullptr; | - | ||||||||||||||||||||||||||||||
1078 | QQuickItem *lastSectionItem = nullptr; | - | ||||||||||||||||||||||||||||||
1079 | int index = 0; | - | ||||||||||||||||||||||||||||||
1080 | while (index < visibleItems.count()) {
| 925-8887 | ||||||||||||||||||||||||||||||
1081 | if (QQuickItem *section = static_cast<FxListItemSG *>(visibleItems.at(index))->section()) {
| 3872-5015 | ||||||||||||||||||||||||||||||
1082 | // Find the current section header and last visible section header | - | ||||||||||||||||||||||||||||||
1083 | // and hide them if they will overlap a static section header. | - | ||||||||||||||||||||||||||||||
1084 | qreal sectionPos = orient == QQuickListView::Vertical ? section->y() : section->x();
| 0-3872 | ||||||||||||||||||||||||||||||
1085 | qreal sectionSize = orient == QQuickListView::Vertical ? section->height() : section->width();
| 0-3872 | ||||||||||||||||||||||||||||||
1086 | bool visTop = true; | - | ||||||||||||||||||||||||||||||
1087 | if (sectionCriteria->labelPositioning() & QQuickViewSection::CurrentLabelAtStart)
| 403-3469 | ||||||||||||||||||||||||||||||
1088 | visTop = isFlowReversed ? -sectionPos-sectionSize >= startPos : sectionPos >= startPos; executed 403 times by 1 test: visTop = isFlowReversed ? -sectionPos-sectionSize >= startPos : sectionPos >= startPos; Executed by:
| 0-403 | ||||||||||||||||||||||||||||||
1089 | bool visBot = true; | - | ||||||||||||||||||||||||||||||
1090 | if (sectionCriteria->labelPositioning() & QQuickViewSection::NextLabelAtEnd)
| 383-3489 | ||||||||||||||||||||||||||||||
1091 | visBot = isFlowReversed ? -sectionPos <= endPos : sectionPos + sectionSize < endPos; executed 383 times by 1 test: visBot = isFlowReversed ? -sectionPos <= endPos : sectionPos + sectionSize < endPos; Executed by:
| 0-383 | ||||||||||||||||||||||||||||||
1092 | section->setVisible(visBot && visTop); | - | ||||||||||||||||||||||||||||||
1093 | if (visTop && !sectionItem)
| 40-3832 | ||||||||||||||||||||||||||||||
1094 | sectionItem = section; executed 865 times by 3 tests: sectionItem = section; Executed by:
| 865 | ||||||||||||||||||||||||||||||
1095 | if (isFlowReversed) {
| 0-3872 | ||||||||||||||||||||||||||||||
1096 | if (-sectionPos <= endPos)
| 0 | ||||||||||||||||||||||||||||||
1097 | lastSectionItem = section; never executed: lastSectionItem = section; | 0 | ||||||||||||||||||||||||||||||
1098 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1099 | if (sectionPos + sectionSize < endPos)
| 660-3212 | ||||||||||||||||||||||||||||||
1100 | lastSectionItem = section; executed 3212 times by 3 tests: lastSectionItem = section; Executed by:
| 3212 | ||||||||||||||||||||||||||||||
1101 | } executed 3872 times by 3 tests: end of block Executed by:
| 3872 | ||||||||||||||||||||||||||||||
1102 | } | - | ||||||||||||||||||||||||||||||
1103 | ++index; | - | ||||||||||||||||||||||||||||||
1104 | } executed 8887 times by 3 tests: end of block Executed by:
| 8887 | ||||||||||||||||||||||||||||||
1105 | - | |||||||||||||||||||||||||||||||
1106 | // Current section header | - | ||||||||||||||||||||||||||||||
1107 | if (sectionCriteria->labelPositioning() & QQuickViewSection::CurrentLabelAtStart && isValid() && visibleItems.count()) {
| 0-822 | ||||||||||||||||||||||||||||||
1108 | if (!currentSectionItem) {
| 4-86 | ||||||||||||||||||||||||||||||
1109 | currentSectionItem = getSectionItem(currentSection); | - | ||||||||||||||||||||||||||||||
1110 | } else if (QString::compare(currentStickySection, currentSection, Qt::CaseInsensitive)) { executed 4 times by 1 test: end of block Executed by:
| 4-76 | ||||||||||||||||||||||||||||||
1111 | QQmlContext *context = QQmlEngine::contextForObject(currentSectionItem)->parentContext(); | - | ||||||||||||||||||||||||||||||
1112 | context->setContextProperty(QLatin1String("section"), currentSection); | - | ||||||||||||||||||||||||||||||
1113 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||||||||
1114 | currentStickySection = currentSection; | - | ||||||||||||||||||||||||||||||
1115 | if (!currentSectionItem)
| 0-90 | ||||||||||||||||||||||||||||||
1116 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
1117 | - | |||||||||||||||||||||||||||||||
1118 | qreal sectionSize = orient == QQuickListView::Vertical ? currentSectionItem->height() : currentSectionItem->width();
| 0-90 | ||||||||||||||||||||||||||||||
1119 | bool atBeginning = orient == QQuickListView::Vertical ? (isBottomToTop() ? vData.atEnd : vData.atBeginning) : (isRightToLeft() ? hData.atEnd : hData.atBeginning);
| 0-90 | ||||||||||||||||||||||||||||||
1120 | - | |||||||||||||||||||||||||||||||
1121 | currentSectionItem->setVisible(!atBeginning && (!header || hasStickyHeader() || header->endPosition() < viewPos)); | - | ||||||||||||||||||||||||||||||
1122 | qreal pos = isFlowReversed ? position() + size() - sectionSize : startPos;
| 0-90 | ||||||||||||||||||||||||||||||
1123 | if (header)
| 0-90 | ||||||||||||||||||||||||||||||
1124 | pos = isFlowReversed ? qMin(-header->endPosition() - sectionSize, pos) : qMax(header->endPosition(), pos); never executed: pos = isFlowReversed ? qMin(-header->endPosition() - sectionSize, pos) : qMax(header->endPosition(), pos);
| 0 | ||||||||||||||||||||||||||||||
1125 | if (sectionItem) {
| 0-90 | ||||||||||||||||||||||||||||||
1126 | qreal sectionPos = orient == QQuickListView::Vertical ? sectionItem->y() : sectionItem->x();
| 0-90 | ||||||||||||||||||||||||||||||
1127 | pos = isFlowReversed ? qMax(pos, sectionPos + sectionSize) : qMin(pos, sectionPos - sectionSize);
| 0-90 | ||||||||||||||||||||||||||||||
1128 | } executed 90 times by 1 test: end of block Executed by:
| 90 | ||||||||||||||||||||||||||||||
1129 | if (footer)
| 0-90 | ||||||||||||||||||||||||||||||
1130 | pos = isFlowReversed ? qMax(-footer->position(), pos) : qMin(footer->position() - sectionSize, pos); never executed: pos = isFlowReversed ? qMax(-footer->position(), pos) : qMin(footer->position() - sectionSize, pos);
| 0 | ||||||||||||||||||||||||||||||
1131 | if (orient == QQuickListView::Vertical)
| 0-90 | ||||||||||||||||||||||||||||||
1132 | currentSectionItem->setY(pos); executed 90 times by 1 test: currentSectionItem->setY(pos); Executed by:
| 90 | ||||||||||||||||||||||||||||||
1133 | else | - | ||||||||||||||||||||||||||||||
1134 | currentSectionItem->setX(pos); never executed: currentSectionItem->setX(pos); | 0 | ||||||||||||||||||||||||||||||
1135 | } else if (currentSectionItem) {
| 4-831 | ||||||||||||||||||||||||||||||
1136 | releaseSectionItem(currentSectionItem); | - | ||||||||||||||||||||||||||||||
1137 | currentSectionItem = nullptr; | - | ||||||||||||||||||||||||||||||
1138 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||||||||
1139 | - | |||||||||||||||||||||||||||||||
1140 | // Next section footer | - | ||||||||||||||||||||||||||||||
1141 | if (sectionCriteria->labelPositioning() & QQuickViewSection::NextLabelAtEnd && isValid() && visibleItems.count()) {
| 0-826 | ||||||||||||||||||||||||||||||
1142 | if (!nextSectionItem) {
| 4-82 | ||||||||||||||||||||||||||||||
1143 | nextSectionItem = getSectionItem(nextSection); | - | ||||||||||||||||||||||||||||||
1144 | } else if (QString::compare(nextStickySection, nextSection, Qt::CaseInsensitive)) { executed 4 times by 1 test: end of block Executed by:
| 4-66 | ||||||||||||||||||||||||||||||
1145 | QQmlContext *context = QQmlEngine::contextForObject(nextSectionItem)->parentContext(); | - | ||||||||||||||||||||||||||||||
1146 | context->setContextProperty(QLatin1String("section"), nextSection); | - | ||||||||||||||||||||||||||||||
1147 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||||||||||||||
1148 | nextStickySection = nextSection; | - | ||||||||||||||||||||||||||||||
1149 | if (!nextSectionItem)
| 0-86 | ||||||||||||||||||||||||||||||
1150 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
1151 | - | |||||||||||||||||||||||||||||||
1152 | qreal sectionSize = orient == QQuickListView::Vertical ? nextSectionItem->height() : nextSectionItem->width();
| 0-86 | ||||||||||||||||||||||||||||||
1153 | nextSectionItem->setVisible(!nextSection.isEmpty()); | - | ||||||||||||||||||||||||||||||
1154 | qreal pos = isFlowReversed ? position() : endPos - sectionSize;
| 0-86 | ||||||||||||||||||||||||||||||
1155 | if (footer)
| 0-86 | ||||||||||||||||||||||||||||||
1156 | pos = isFlowReversed ? qMax(-footer->position(), pos) : qMin(footer->position() - sectionSize, pos); never executed: pos = isFlowReversed ? qMax(-footer->position(), pos) : qMin(footer->position() - sectionSize, pos);
| 0 | ||||||||||||||||||||||||||||||
1157 | if (lastSectionItem) {
| 0-86 | ||||||||||||||||||||||||||||||
1158 | qreal sectionPos = orient == QQuickListView::Vertical ? lastSectionItem->y() : lastSectionItem->x();
| 0-86 | ||||||||||||||||||||||||||||||
1159 | pos = isFlowReversed ? qMin(pos, sectionPos - sectionSize) : qMax(pos, sectionPos + sectionSize);
| 0-86 | ||||||||||||||||||||||||||||||
1160 | } executed 86 times by 1 test: end of block Executed by:
| 86 | ||||||||||||||||||||||||||||||
1161 | if (header)
| 0-86 | ||||||||||||||||||||||||||||||
1162 | pos = isFlowReversed ? qMin(-header->endPosition() - sectionSize, pos) : qMax(header->endPosition(), pos); never executed: pos = isFlowReversed ? qMin(-header->endPosition() - sectionSize, pos) : qMax(header->endPosition(), pos);
| 0 | ||||||||||||||||||||||||||||||
1163 | if (orient == QQuickListView::Vertical)
| 0-86 | ||||||||||||||||||||||||||||||
1164 | nextSectionItem->setY(pos); executed 86 times by 1 test: nextSectionItem->setY(pos); Executed by:
| 86 | ||||||||||||||||||||||||||||||
1165 | else | - | ||||||||||||||||||||||||||||||
1166 | nextSectionItem->setX(pos); never executed: nextSectionItem->setX(pos); | 0 | ||||||||||||||||||||||||||||||
1167 | } else if (nextSectionItem) {
| 4-835 | ||||||||||||||||||||||||||||||
1168 | releaseSectionItem(nextSectionItem); | - | ||||||||||||||||||||||||||||||
1169 | nextSectionItem = nullptr; | - | ||||||||||||||||||||||||||||||
1170 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||||||||
1171 | } executed 925 times by 3 tests: end of block Executed by:
| 925 | ||||||||||||||||||||||||||||||
1172 | - | |||||||||||||||||||||||||||||||
1173 | void QQuickListViewPrivate::updateSections() | - | ||||||||||||||||||||||||||||||
1174 | { | - | ||||||||||||||||||||||||||||||
1175 | Q_Q(QQuickListView); | - | ||||||||||||||||||||||||||||||
1176 | if (!q->isComponentComplete())
| 0-6944 | ||||||||||||||||||||||||||||||
1177 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
1178 | - | |||||||||||||||||||||||||||||||
1179 | QQuickItemViewPrivate::updateSections(); | - | ||||||||||||||||||||||||||||||
1180 | - | |||||||||||||||||||||||||||||||
1181 | if (sectionCriteria && !visibleItems.isEmpty() && isValid()) {
| 15-6317 | ||||||||||||||||||||||||||||||
1182 | QString prevSection; | - | ||||||||||||||||||||||||||||||
1183 | if (visibleIndex > 0)
| 4-556 | ||||||||||||||||||||||||||||||
1184 | prevSection = sectionAt(visibleIndex-1); executed 4 times by 1 test: prevSection = sectionAt(visibleIndex-1); Executed by:
| 4 | ||||||||||||||||||||||||||||||
1185 | QQuickListViewAttached *prevAtt = nullptr; | - | ||||||||||||||||||||||||||||||
1186 | int prevIdx = -1; | - | ||||||||||||||||||||||||||||||
1187 | int idx = -1; | - | ||||||||||||||||||||||||||||||
1188 | for (FxViewItem *item : qAsConst(visibleItems)) { | - | ||||||||||||||||||||||||||||||
1189 | QQuickListViewAttached *attached = static_cast<QQuickListViewAttached*>(item->attached); | - | ||||||||||||||||||||||||||||||
1190 | attached->setPrevSection(prevSection); | - | ||||||||||||||||||||||||||||||
1191 | if (item->index != -1) {
| 38-6174 | ||||||||||||||||||||||||||||||
1192 | QString propValue = model->stringValue(item->index, sectionCriteria->property()); | - | ||||||||||||||||||||||||||||||
1193 | attached->setSection(sectionCriteria->sectionString(propValue)); | - | ||||||||||||||||||||||||||||||
1194 | idx = item->index; | - | ||||||||||||||||||||||||||||||
1195 | } executed 6174 times by 4 tests: end of block Executed by:
| 6174 | ||||||||||||||||||||||||||||||
1196 | updateInlineSection(static_cast<FxListItemSG*>(item)); | - | ||||||||||||||||||||||||||||||
1197 | if (prevAtt)
| 560-5652 | ||||||||||||||||||||||||||||||
1198 | prevAtt->setNextSection(sectionAt(prevIdx+1)); executed 5652 times by 3 tests: prevAtt->setNextSection(sectionAt(prevIdx+1)); Executed by:
| 5652 | ||||||||||||||||||||||||||||||
1199 | prevSection = attached->section(); | - | ||||||||||||||||||||||||||||||
1200 | prevAtt = attached; | - | ||||||||||||||||||||||||||||||
1201 | prevIdx = item->index; | - | ||||||||||||||||||||||||||||||
1202 | } executed 6212 times by 4 tests: end of block Executed by:
| 6212 | ||||||||||||||||||||||||||||||
1203 | if (prevAtt) {
| 0-560 | ||||||||||||||||||||||||||||||
1204 | if (idx > 0 && idx < model->count()-1)
| 4-556 | ||||||||||||||||||||||||||||||
1205 | prevAtt->setNextSection(sectionAt(idx+1)); executed 114 times by 2 tests: prevAtt->setNextSection(sectionAt(idx+1)); Executed by:
| 114 | ||||||||||||||||||||||||||||||
1206 | else | - | ||||||||||||||||||||||||||||||
1207 | prevAtt->setNextSection(QString()); executed 446 times by 4 tests: prevAtt->setNextSection(QString()); Executed by:
| 446 | ||||||||||||||||||||||||||||||
1208 | } | - | ||||||||||||||||||||||||||||||
1209 | } executed 560 times by 4 tests: end of block Executed by:
| 560 | ||||||||||||||||||||||||||||||
1210 | - | |||||||||||||||||||||||||||||||
1211 | lastVisibleSection = QString(); | - | ||||||||||||||||||||||||||||||
1212 | } executed 6944 times by 11 tests: end of block Executed by:
| 6944 | ||||||||||||||||||||||||||||||
1213 | - | |||||||||||||||||||||||||||||||
1214 | void QQuickListViewPrivate::updateCurrentSection() | - | ||||||||||||||||||||||||||||||
1215 | { | - | ||||||||||||||||||||||||||||||
1216 | Q_Q(QQuickListView); | - | ||||||||||||||||||||||||||||||
1217 | if (!sectionCriteria || visibleItems.isEmpty()) {
| 14-3014 | ||||||||||||||||||||||||||||||
1218 | if (!currentSection.isEmpty()) {
| 2-3026 | ||||||||||||||||||||||||||||||
1219 | currentSection.clear(); | - | ||||||||||||||||||||||||||||||
1220 | emit q->currentSectionChanged(); | - | ||||||||||||||||||||||||||||||
1221 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||||||||
1222 | return; executed 3028 times by 6 tests: return; Executed by:
| 3028 | ||||||||||||||||||||||||||||||
1223 | } | - | ||||||||||||||||||||||||||||||
1224 | bool inlineSections = sectionCriteria->labelPositioning() & QQuickViewSection::InlineLabels; | - | ||||||||||||||||||||||||||||||
1225 | qreal viewPos = isContentFlowReversed() ? -position()-size() : position();
| 0-986 | ||||||||||||||||||||||||||||||
1226 | qreal startPos = hasStickyHeader() ? header->endPosition() : viewPos;
| 0-986 | ||||||||||||||||||||||||||||||
1227 | int index = 0; | - | ||||||||||||||||||||||||||||||
1228 | int modelIndex = visibleIndex; | - | ||||||||||||||||||||||||||||||
1229 | while (index < visibleItems.count()) {
| 57-1380 | ||||||||||||||||||||||||||||||
1230 | FxViewItem *item = visibleItems.at(index); | - | ||||||||||||||||||||||||||||||
1231 | if (item->endPosition() > startPos)
| 451-929 | ||||||||||||||||||||||||||||||
1232 | break; executed 929 times by 4 tests: break; Executed by:
| 929 | ||||||||||||||||||||||||||||||
1233 | if (item->index != -1)
| 0-451 | ||||||||||||||||||||||||||||||
1234 | modelIndex = item->index; executed 451 times by 1 test: modelIndex = item->index; Executed by:
| 451 | ||||||||||||||||||||||||||||||
1235 | ++index; | - | ||||||||||||||||||||||||||||||
1236 | } executed 451 times by 1 test: end of block Executed by:
| 451 | ||||||||||||||||||||||||||||||
1237 | - | |||||||||||||||||||||||||||||||
1238 | QString newSection = currentSection; | - | ||||||||||||||||||||||||||||||
1239 | if (index < visibleItems.count())
| 57-929 | ||||||||||||||||||||||||||||||
1240 | newSection = visibleItems.at(index)->attached->section(); executed 929 times by 4 tests: newSection = visibleItems.at(index)->attached->section(); Executed by:
| 929 | ||||||||||||||||||||||||||||||
1241 | else | - | ||||||||||||||||||||||||||||||
1242 | newSection = (*visibleItems.constBegin())->attached->section(); executed 57 times by 1 test: newSection = (*visibleItems.constBegin())->attached->section(); Executed by:
| 57 | ||||||||||||||||||||||||||||||
1243 | if (newSection != currentSection) {
| 142-844 | ||||||||||||||||||||||||||||||
1244 | currentSection = newSection; | - | ||||||||||||||||||||||||||||||
1245 | updateStickySections(); | - | ||||||||||||||||||||||||||||||
1246 | emit q->currentSectionChanged(); | - | ||||||||||||||||||||||||||||||
1247 | } executed 142 times by 4 tests: end of block Executed by:
| 142 | ||||||||||||||||||||||||||||||
1248 | - | |||||||||||||||||||||||||||||||
1249 | if (sectionCriteria->labelPositioning() & QQuickViewSection::NextLabelAtEnd) {
| 69-917 | ||||||||||||||||||||||||||||||
1250 | // Don't want to scan for next section on every movement, so remember | - | ||||||||||||||||||||||||||||||
1251 | // the last section in the visible area and only scan for the next | - | ||||||||||||||||||||||||||||||
1252 | // section when that changes. Clearing lastVisibleSection will also | - | ||||||||||||||||||||||||||||||
1253 | // force searching. | - | ||||||||||||||||||||||||||||||
1254 | QString lastSection = currentSection; | - | ||||||||||||||||||||||||||||||
1255 | qreal endPos = hasStickyFooter() ? footer->position() : viewPos + size();
| 0-69 | ||||||||||||||||||||||||||||||
1256 | if (nextSectionItem && !inlineSections)
| 0-54 | ||||||||||||||||||||||||||||||
1257 | endPos -= orient == QQuickListView::Vertical ? nextSectionItem->height() : nextSectionItem->width(); never executed: endPos -= orient == QQuickListView::Vertical ? nextSectionItem->height() : nextSectionItem->width();
| 0 | ||||||||||||||||||||||||||||||
1258 | while (index < visibleItems.count()) {
| 4-994 | ||||||||||||||||||||||||||||||
1259 | FxListItemSG *listItem = static_cast<FxListItemSG *>(visibleItems.at(index)); | - | ||||||||||||||||||||||||||||||
1260 | if (listItem->itemPosition() >= endPos)
| 65-929 | ||||||||||||||||||||||||||||||
1261 | break; executed 65 times by 1 test: break; Executed by:
| 65 | ||||||||||||||||||||||||||||||
1262 | if (listItem->index != -1)
| 193-736 | ||||||||||||||||||||||||||||||
1263 | modelIndex = listItem->index; executed 736 times by 1 test: modelIndex = listItem->index; Executed by:
| 736 | ||||||||||||||||||||||||||||||
1264 | lastSection = listItem->attached->section(); | - | ||||||||||||||||||||||||||||||
1265 | ++index; | - | ||||||||||||||||||||||||||||||
1266 | } executed 929 times by 1 test: end of block Executed by:
| 929 | ||||||||||||||||||||||||||||||
1267 | - | |||||||||||||||||||||||||||||||
1268 | if (lastVisibleSection != lastSection) {
| 22-47 | ||||||||||||||||||||||||||||||
1269 | nextSection = QString(); | - | ||||||||||||||||||||||||||||||
1270 | lastVisibleSection = lastSection; | - | ||||||||||||||||||||||||||||||
1271 | for (int i = modelIndex; i < itemCount; ++i) {
| 13-104 | ||||||||||||||||||||||||||||||
1272 | QString section = sectionAt(i); | - | ||||||||||||||||||||||||||||||
1273 | if (section != lastSection) {
| 34-70 | ||||||||||||||||||||||||||||||
1274 | nextSection = section; | - | ||||||||||||||||||||||||||||||
1275 | updateStickySections(); | - | ||||||||||||||||||||||||||||||
1276 | break; executed 34 times by 1 test: break; Executed by:
| 34 | ||||||||||||||||||||||||||||||
1277 | } | - | ||||||||||||||||||||||||||||||
1278 | } executed 70 times by 1 test: end of block Executed by:
| 70 | ||||||||||||||||||||||||||||||
1279 | } executed 47 times by 1 test: end of block Executed by:
| 47 | ||||||||||||||||||||||||||||||
1280 | } executed 69 times by 1 test: end of block Executed by:
| 69 | ||||||||||||||||||||||||||||||
1281 | } executed 986 times by 4 tests: end of block Executed by:
| 986 | ||||||||||||||||||||||||||||||
1282 | - | |||||||||||||||||||||||||||||||
1283 | void QQuickListViewPrivate::initializeCurrentItem() | - | ||||||||||||||||||||||||||||||
1284 | { | - | ||||||||||||||||||||||||||||||
1285 | QQuickItemViewPrivate::initializeCurrentItem(); | - | ||||||||||||||||||||||||||||||
1286 | - | |||||||||||||||||||||||||||||||
1287 | if (currentItem) {
| 0-3584 | ||||||||||||||||||||||||||||||
1288 | FxListItemSG *listItem = static_cast<FxListItemSG *>(currentItem); | - | ||||||||||||||||||||||||||||||
1289 | - | |||||||||||||||||||||||||||||||
1290 | // don't reposition the item if it is already in the visibleItems list | - | ||||||||||||||||||||||||||||||
1291 | FxViewItem *actualItem = visibleItem(currentIndex); | - | ||||||||||||||||||||||||||||||
1292 | if (!actualItem) {
| 167-3417 | ||||||||||||||||||||||||||||||
1293 | if (currentIndex == visibleIndex - 1 && visibleItems.count()) {
| 0-167 | ||||||||||||||||||||||||||||||
1294 | // We can calculate exact postion in this case | - | ||||||||||||||||||||||||||||||
1295 | listItem->setPosition(visibleItems.constFirst()->position() - currentItem->size() - spacing); | - | ||||||||||||||||||||||||||||||
1296 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1297 | // Create current item now and position as best we can. | - | ||||||||||||||||||||||||||||||
1298 | // Its position will be corrected when it becomes visible. | - | ||||||||||||||||||||||||||||||
1299 | listItem->setPosition(positionAt(currentIndex)); | - | ||||||||||||||||||||||||||||||
1300 | } executed 167 times by 2 tests: end of block Executed by:
| 167 | ||||||||||||||||||||||||||||||
1301 | } | - | ||||||||||||||||||||||||||||||
1302 | - | |||||||||||||||||||||||||||||||
1303 | if (visibleItems.isEmpty())
| 50-3534 | ||||||||||||||||||||||||||||||
1304 | averageSize = listItem->size(); executed 50 times by 1 test: averageSize = listItem->size(); Executed by:
| 50 | ||||||||||||||||||||||||||||||
1305 | } executed 3584 times by 10 tests: end of block Executed by:
| 3584 | ||||||||||||||||||||||||||||||
1306 | } executed 3584 times by 10 tests: end of block Executed by:
| 3584 | ||||||||||||||||||||||||||||||
1307 | - | |||||||||||||||||||||||||||||||
1308 | void QQuickListViewPrivate::updateAverage() | - | ||||||||||||||||||||||||||||||
1309 | { | - | ||||||||||||||||||||||||||||||
1310 | if (!visibleItems.count())
| 0-5566 | ||||||||||||||||||||||||||||||
1311 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
1312 | qreal sum = 0.0; | - | ||||||||||||||||||||||||||||||
1313 | for (FxViewItem *item : qAsConst(visibleItems)) | - | ||||||||||||||||||||||||||||||
1314 | sum += item->size(); executed 70254 times by 10 tests: sum += item->size(); Executed by:
| 70254 | ||||||||||||||||||||||||||||||
1315 | averageSize = qRound(sum / visibleItems.count()); | - | ||||||||||||||||||||||||||||||
1316 | } executed 5566 times by 10 tests: end of block Executed by:
| 5566 | ||||||||||||||||||||||||||||||
1317 | - | |||||||||||||||||||||||||||||||
1318 | qreal QQuickListViewPrivate::headerSize() const | - | ||||||||||||||||||||||||||||||
1319 | { | - | ||||||||||||||||||||||||||||||
1320 | return header ? header->size() : 0.0; executed 42252 times by 11 tests: return header ? header->size() : 0.0; Executed by:
| 42252 | ||||||||||||||||||||||||||||||
1321 | } | - | ||||||||||||||||||||||||||||||
1322 | - | |||||||||||||||||||||||||||||||
1323 | qreal QQuickListViewPrivate::footerSize() const | - | ||||||||||||||||||||||||||||||
1324 | { | - | ||||||||||||||||||||||||||||||
1325 | return footer ? footer->size() : 0.0; executed 33805 times by 11 tests: return footer ? footer->size() : 0.0; Executed by:
| 33805 | ||||||||||||||||||||||||||||||
1326 | } | - | ||||||||||||||||||||||||||||||
1327 | - | |||||||||||||||||||||||||||||||
1328 | bool QQuickListViewPrivate::showHeaderForIndex(int index) const | - | ||||||||||||||||||||||||||||||
1329 | { | - | ||||||||||||||||||||||||||||||
1330 | return index == 0; executed 6526 times by 10 tests: return index == 0; Executed by:
| 6526 | ||||||||||||||||||||||||||||||
1331 | } | - | ||||||||||||||||||||||||||||||
1332 | - | |||||||||||||||||||||||||||||||
1333 | bool QQuickListViewPrivate::showFooterForIndex(int index) const | - | ||||||||||||||||||||||||||||||
1334 | { | - | ||||||||||||||||||||||||||||||
1335 | return model && index == model->count()-1; executed 2661 times by 3 tests: return model && index == model->count()-1; Executed by:
| 2661 | ||||||||||||||||||||||||||||||
1336 | } | - | ||||||||||||||||||||||||||||||
1337 | - | |||||||||||||||||||||||||||||||
1338 | void QQuickListViewPrivate::updateFooter() | - | ||||||||||||||||||||||||||||||
1339 | { | - | ||||||||||||||||||||||||||||||
1340 | Q_Q(QQuickListView); | - | ||||||||||||||||||||||||||||||
1341 | bool created = false; | - | ||||||||||||||||||||||||||||||
1342 | if (!footer) {
| 1140-10385 | ||||||||||||||||||||||||||||||
1343 | QQuickItem *item = createComponentItem(footerComponent, 1.0); | - | ||||||||||||||||||||||||||||||
1344 | if (!item)
| 144-10241 | ||||||||||||||||||||||||||||||
1345 | return; executed 10241 times by 11 tests: return; Executed by:
| 10241 | ||||||||||||||||||||||||||||||
1346 | footer = new FxListItemSG(item, q, true); | - | ||||||||||||||||||||||||||||||
1347 | footer->trackGeometry(true); | - | ||||||||||||||||||||||||||||||
1348 | created = true; | - | ||||||||||||||||||||||||||||||
1349 | } executed 144 times by 2 tests: end of block Executed by:
| 144 | ||||||||||||||||||||||||||||||
1350 | - | |||||||||||||||||||||||||||||||
1351 | FxListItemSG *listItem = static_cast<FxListItemSG*>(footer); | - | ||||||||||||||||||||||||||||||
1352 | if (footerPositioning == QQuickListView::OverlayFooter) {
| 92-1192 | ||||||||||||||||||||||||||||||
1353 | listItem->setPosition(isContentFlowReversed() ? -position() - footerSize() : position() + size() - footerSize()); | - | ||||||||||||||||||||||||||||||
1354 | } else if (visibleItems.count()) { executed 92 times by 1 test: end of block Executed by:
| 92-922 | ||||||||||||||||||||||||||||||
1355 | if (footerPositioning == QQuickListView::PullBackFooter) {
| 238-684 | ||||||||||||||||||||||||||||||
1356 | qreal viewPos = isContentFlowReversed() ? -position() : position() + size();
| 196-488 | ||||||||||||||||||||||||||||||
1357 | qreal clampedPos = qBound(originPosition() - footerSize() + size(), listItem->position(), lastPosition()); | - | ||||||||||||||||||||||||||||||
1358 | listItem->setPosition(qBound(viewPos - footerSize(), clampedPos, viewPos)); | - | ||||||||||||||||||||||||||||||
1359 | } else { executed 684 times by 1 test: end of block Executed by:
| 684 | ||||||||||||||||||||||||||||||
1360 | qreal endPos = lastPosition(); | - | ||||||||||||||||||||||||||||||
1361 | if (findLastVisibleIndex() == model->count()-1) {
| 50-188 | ||||||||||||||||||||||||||||||
1362 | listItem->setPosition(endPos); | - | ||||||||||||||||||||||||||||||
1363 | } else { executed 188 times by 2 tests: end of block Executed by:
| 188 | ||||||||||||||||||||||||||||||
1364 | qreal visiblePos = position() + q->height(); | - | ||||||||||||||||||||||||||||||
1365 | if (endPos <= visiblePos || listItem->position() < endPos)
| 0-50 | ||||||||||||||||||||||||||||||
1366 | listItem->setPosition(endPos); executed 22 times by 1 test: listItem->setPosition(endPos); Executed by:
| 22 | ||||||||||||||||||||||||||||||
1367 | } executed 50 times by 1 test: end of block Executed by:
| 50 | ||||||||||||||||||||||||||||||
1368 | } | - | ||||||||||||||||||||||||||||||
1369 | } else { | - | ||||||||||||||||||||||||||||||
1370 | listItem->setPosition(visiblePos); | - | ||||||||||||||||||||||||||||||
1371 | } executed 270 times by 2 tests: end of block Executed by:
| 270 | ||||||||||||||||||||||||||||||
1372 | - | |||||||||||||||||||||||||||||||
1373 | if (created)
| 144-1140 | ||||||||||||||||||||||||||||||
1374 | emit q->footerItemChanged(); executed 144 times by 2 tests: q->footerItemChanged(); Executed by:
| 144 | ||||||||||||||||||||||||||||||
1375 | } executed 1284 times by 2 tests: end of block Executed by:
| 1284 | ||||||||||||||||||||||||||||||
1376 | - | |||||||||||||||||||||||||||||||
1377 | void QQuickListViewPrivate::updateHeader() | - | ||||||||||||||||||||||||||||||
1378 | { | - | ||||||||||||||||||||||||||||||
1379 | Q_Q(QQuickListView); | - | ||||||||||||||||||||||||||||||
1380 | bool created = false; | - | ||||||||||||||||||||||||||||||
1381 | if (!header) {
| 1079-10332 | ||||||||||||||||||||||||||||||
1382 | QQuickItem *item = createComponentItem(headerComponent, 1.0); | - | ||||||||||||||||||||||||||||||
1383 | if (!item)
| 176-10156 | ||||||||||||||||||||||||||||||
1384 | return; executed 10156 times by 11 tests: return; Executed by:
| 10156 | ||||||||||||||||||||||||||||||
1385 | header = new FxListItemSG(item, q, true); | - | ||||||||||||||||||||||||||||||
1386 | header->trackGeometry(true); | - | ||||||||||||||||||||||||||||||
1387 | created = true; | - | ||||||||||||||||||||||||||||||
1388 | } executed 176 times by 2 tests: end of block Executed by:
| 176 | ||||||||||||||||||||||||||||||
1389 | - | |||||||||||||||||||||||||||||||
1390 | FxListItemSG *listItem = static_cast<FxListItemSG*>(header); | - | ||||||||||||||||||||||||||||||
1391 | if (headerPositioning == QQuickListView::OverlayHeader) {
| 128-1127 | ||||||||||||||||||||||||||||||
1392 | listItem->setPosition(isContentFlowReversed() ? -position() - size() : position()); | - | ||||||||||||||||||||||||||||||
1393 | } else if (visibleItems.count()) { executed 128 times by 1 test: end of block Executed by:
| 128-717 | ||||||||||||||||||||||||||||||
1394 | if (headerPositioning == QQuickListView::PullBackHeader) {
| 215-502 | ||||||||||||||||||||||||||||||
1395 | qreal viewPos = isContentFlowReversed() ? -position() - size() : position();
| 124-378 | ||||||||||||||||||||||||||||||
1396 | qreal clampedPos = qBound(originPosition() - headerSize(), listItem->position(), lastPosition() - headerSize() - size()); | - | ||||||||||||||||||||||||||||||
1397 | listItem->setPosition(qBound(viewPos - headerSize(), clampedPos, viewPos)); | - | ||||||||||||||||||||||||||||||
1398 | } else { executed 502 times by 1 test: end of block Executed by:
| 502 | ||||||||||||||||||||||||||||||
1399 | qreal startPos = originPosition(); | - | ||||||||||||||||||||||||||||||
1400 | if (visibleIndex == 0) {
| 12-203 | ||||||||||||||||||||||||||||||
1401 | listItem->setPosition(startPos - headerSize()); | - | ||||||||||||||||||||||||||||||
1402 | } else { executed 203 times by 2 tests: end of block Executed by:
| 203 | ||||||||||||||||||||||||||||||
1403 | if (position() <= startPos || listItem->position() > startPos - headerSize())
| 0-12 | ||||||||||||||||||||||||||||||
1404 | listItem->setPosition(startPos - headerSize()); executed 2 times by 1 test: listItem->setPosition(startPos - headerSize()); Executed by:
| 2 | ||||||||||||||||||||||||||||||
1405 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||||||||
1406 | } | - | ||||||||||||||||||||||||||||||
1407 | } else { | - | ||||||||||||||||||||||||||||||
1408 | listItem->setPosition(-headerSize()); | - | ||||||||||||||||||||||||||||||
1409 | } executed 410 times by 2 tests: end of block Executed by:
| 410 | ||||||||||||||||||||||||||||||
1410 | - | |||||||||||||||||||||||||||||||
1411 | if (created)
| 176-1079 | ||||||||||||||||||||||||||||||
1412 | emit q->headerItemChanged(); executed 176 times by 2 tests: q->headerItemChanged(); Executed by:
| 176 | ||||||||||||||||||||||||||||||
1413 | } executed 1255 times by 2 tests: end of block Executed by:
| 1255 | ||||||||||||||||||||||||||||||
1414 | - | |||||||||||||||||||||||||||||||
1415 | bool QQuickListViewPrivate::hasStickyHeader() const | - | ||||||||||||||||||||||||||||||
1416 | { | - | ||||||||||||||||||||||||||||||
1417 | return header && headerPositioning != QQuickListView::InlineHeader; executed 12278 times by 5 tests: return header && headerPositioning != QQuickListView::InlineHeader; Executed by:
| 12278 | ||||||||||||||||||||||||||||||
1418 | } | - | ||||||||||||||||||||||||||||||
1419 | - | |||||||||||||||||||||||||||||||
1420 | bool QQuickListViewPrivate::hasStickyFooter() const | - | ||||||||||||||||||||||||||||||
1421 | { | - | ||||||||||||||||||||||||||||||
1422 | return footer && footerPositioning != QQuickListView::InlineFooter; executed 11361 times by 5 tests: return footer && footerPositioning != QQuickListView::InlineFooter; Executed by:
| 11361 | ||||||||||||||||||||||||||||||
1423 | } | - | ||||||||||||||||||||||||||||||
1424 | - | |||||||||||||||||||||||||||||||
1425 | void QQuickListViewPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, | - | ||||||||||||||||||||||||||||||
1426 | const QRectF &oldGeometry) | - | ||||||||||||||||||||||||||||||
1427 | { | - | ||||||||||||||||||||||||||||||
1428 | Q_Q(QQuickListView); | - | ||||||||||||||||||||||||||||||
1429 | - | |||||||||||||||||||||||||||||||
1430 | QQuickItemViewPrivate::itemGeometryChanged(item, change, oldGeometry); | - | ||||||||||||||||||||||||||||||
1431 | if (!q->isComponentComplete())
| 3412-80231 | ||||||||||||||||||||||||||||||
1432 | return; executed 3412 times by 8 tests: return; Executed by:
| 3412 | ||||||||||||||||||||||||||||||
1433 | - | |||||||||||||||||||||||||||||||
1434 | if (currentItem && currentItem->item == item) {
| 2939-55640 | ||||||||||||||||||||||||||||||
1435 | const bool contentFlowReversed = isContentFlowReversed(); | - | ||||||||||||||||||||||||||||||
1436 | const qreal pos = position(); | - | ||||||||||||||||||||||||||||||
1437 | const qreal sz = size(); | - | ||||||||||||||||||||||||||||||
1438 | const qreal from = contentFlowReversed ? -pos - displayMarginBeginning - sz : pos - displayMarginBeginning;
| 74-2865 | ||||||||||||||||||||||||||||||
1439 | const qreal to = contentFlowReversed ? -pos + displayMarginEnd : pos + sz + displayMarginEnd;
| 74-2865 | ||||||||||||||||||||||||||||||
1440 | QQuickItemPrivate::get(currentItem->item)->setCulled(currentItem->endPosition() < from || currentItem->position() > to); | - | ||||||||||||||||||||||||||||||
1441 | } executed 2939 times by 4 tests: end of block Executed by:
| 2939 | ||||||||||||||||||||||||||||||
1442 | - | |||||||||||||||||||||||||||||||
1443 | if (item != contentItem && (!highlight || item != highlight->item)) {
| 7803-63911 | ||||||||||||||||||||||||||||||
1444 | if ((orient == QQuickListView::Vertical && change.heightChange())
| 2578-53530 | ||||||||||||||||||||||||||||||
1445 | || (orient == QQuickListView::Horizontal && change.widthChange())) {
| 222-50665 | ||||||||||||||||||||||||||||||
1446 | - | |||||||||||||||||||||||||||||||
1447 | // if visibleItems.first() has resized, adjust its pos since it is used to | - | ||||||||||||||||||||||||||||||
1448 | // position all subsequent items | - | ||||||||||||||||||||||||||||||
1449 | if (visibleItems.count() && item == visibleItems.constFirst()->item) {
| 30-3057 | ||||||||||||||||||||||||||||||
1450 | FxListItemSG *listItem = static_cast<FxListItemSG*>(visibleItems.constFirst()); | - | ||||||||||||||||||||||||||||||
1451 | if (listItem->transitionScheduledOrRunning())
| 16-110 | ||||||||||||||||||||||||||||||
1452 | return; executed 16 times by 1 test: return; Executed by:
| 16 | ||||||||||||||||||||||||||||||
1453 | if (orient == QQuickListView::Vertical) {
| 4-106 | ||||||||||||||||||||||||||||||
1454 | const qreal oldItemEndPosition = verticalLayoutDirection == QQuickItemView::BottomToTop ? -oldGeometry.y() : oldGeometry.y() + oldGeometry.height();
| 0-106 | ||||||||||||||||||||||||||||||
1455 | const qreal heightDiff = item->height() - oldGeometry.height(); | - | ||||||||||||||||||||||||||||||
1456 | if (verticalLayoutDirection == QQuickListView::TopToBottom && oldItemEndPosition < q->contentY())
| 0-106 | ||||||||||||||||||||||||||||||
1457 | listItem->setPosition(listItem->position() - heightDiff, true); executed 8 times by 1 test: listItem->setPosition(listItem->position() - heightDiff, true); Executed by:
| 8 | ||||||||||||||||||||||||||||||
1458 | else if (verticalLayoutDirection == QQuickListView::BottomToTop && oldItemEndPosition > q->contentY())
| 0-98 | ||||||||||||||||||||||||||||||
1459 | listItem->setPosition(listItem->position() + heightDiff, true); never executed: listItem->setPosition(listItem->position() + heightDiff, true); | 0 | ||||||||||||||||||||||||||||||
1460 | } else { executed 106 times by 1 test: end of block Executed by:
| 106 | ||||||||||||||||||||||||||||||
1461 | const qreal oldItemEndPosition = q->effectiveLayoutDirection() == Qt::RightToLeft ? -oldGeometry.x() : oldGeometry.x() + oldGeometry.width();
| 0-4 | ||||||||||||||||||||||||||||||
1462 | const qreal widthDiff = item->width() - oldGeometry.width(); | - | ||||||||||||||||||||||||||||||
1463 | if (q->effectiveLayoutDirection() == Qt::LeftToRight && oldItemEndPosition < q->contentX())
| 0-4 | ||||||||||||||||||||||||||||||
1464 | listItem->setPosition(listItem->position() - widthDiff, true); executed 4 times by 1 test: listItem->setPosition(listItem->position() - widthDiff, true); Executed by:
| 4 | ||||||||||||||||||||||||||||||
1465 | else if (q->effectiveLayoutDirection() == Qt::RightToLeft && oldItemEndPosition > q->contentX())
| 0 | ||||||||||||||||||||||||||||||
1466 | listItem->setPosition(listItem->position() + widthDiff, true); never executed: listItem->setPosition(listItem->position() + widthDiff, true); | 0 | ||||||||||||||||||||||||||||||
1467 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||||||||
1468 | } | - | ||||||||||||||||||||||||||||||
1469 | forceLayoutPolish(); | - | ||||||||||||||||||||||||||||||
1470 | } executed 3071 times by 10 tests: end of block Executed by:
| 3071 | ||||||||||||||||||||||||||||||
1471 | } executed 56092 times by 10 tests: end of block Executed by:
| 56092 | ||||||||||||||||||||||||||||||
1472 | } executed 80215 times by 10 tests: end of block Executed by:
| 80215 | ||||||||||||||||||||||||||||||
1473 | - | |||||||||||||||||||||||||||||||
1474 | void QQuickListViewPrivate::fixupPosition() | - | ||||||||||||||||||||||||||||||
1475 | { | - | ||||||||||||||||||||||||||||||
1476 | if (orient == QQuickListView::Vertical)
| 686-5117 | ||||||||||||||||||||||||||||||
1477 | fixupY(); executed 5117 times by 10 tests: fixupY(); Executed by:
| 5117 | ||||||||||||||||||||||||||||||
1478 | else | - | ||||||||||||||||||||||||||||||
1479 | fixupX(); executed 686 times by 2 tests: fixupX(); Executed by:
| 686 | ||||||||||||||||||||||||||||||
1480 | } | - | ||||||||||||||||||||||||||||||
1481 | - | |||||||||||||||||||||||||||||||
1482 | void QQuickListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent) | - | ||||||||||||||||||||||||||||||
1483 | { | - | ||||||||||||||||||||||||||||||
1484 | if (orient == QQuickListView::Horizontal && &data == &vData) {
| 190-11081 | ||||||||||||||||||||||||||||||
1485 | if (flickableDirection != QQuickFlickable::HorizontalFlick)
| 0-190 | ||||||||||||||||||||||||||||||
1486 | QQuickItemViewPrivate::fixup(data, minExtent, maxExtent); never executed: QQuickItemViewPrivate::fixup(data, minExtent, maxExtent); | 0 | ||||||||||||||||||||||||||||||
1487 | return; executed 190 times by 2 tests: return; Executed by:
| 190 | ||||||||||||||||||||||||||||||
1488 | } else if (orient == QQuickListView::Vertical && &data == &hData) {
| 352-11081 | ||||||||||||||||||||||||||||||
1489 | if (flickableDirection != QQuickFlickable::VerticalFlick)
| 0-352 | ||||||||||||||||||||||||||||||
1490 | QQuickItemViewPrivate::fixup(data, minExtent, maxExtent); never executed: QQuickItemViewPrivate::fixup(data, minExtent, maxExtent); | 0 | ||||||||||||||||||||||||||||||
1491 | return; executed 352 times by 4 tests: return; Executed by:
| 352 | ||||||||||||||||||||||||||||||
1492 | } | - | ||||||||||||||||||||||||||||||
1493 | - | |||||||||||||||||||||||||||||||
1494 | correctFlick = false; | - | ||||||||||||||||||||||||||||||
1495 | fixupMode = moveReason == Mouse ? fixupMode : Immediate;
| 317-11696 | ||||||||||||||||||||||||||||||
1496 | bool strictHighlightRange = haveHighlightRange && highlightRange == QQuickListView::StrictlyEnforceRange;
| 48-11428 | ||||||||||||||||||||||||||||||
1497 | - | |||||||||||||||||||||||||||||||
1498 | qreal viewPos = isContentFlowReversed() ? -position()-size() : position();
| 1146-10867 | ||||||||||||||||||||||||||||||
1499 | - | |||||||||||||||||||||||||||||||
1500 | if (snapMode != QQuickListView::NoSnap && moveReason != QQuickListViewPrivate::SetIndex) {
| 78-11068 | ||||||||||||||||||||||||||||||
1501 | qreal tempPosition = isContentFlowReversed() ? -position()-size() : position();
| 330-537 | ||||||||||||||||||||||||||||||
1502 | if (snapMode == QQuickListView::SnapOneItem && moveReason == Mouse) {
| 121-546 | ||||||||||||||||||||||||||||||
1503 | // if we've been dragged < averageSize/2 then bias towards the next item | - | ||||||||||||||||||||||||||||||
1504 | qreal dist = data.move.value() - data.pressPos; | - | ||||||||||||||||||||||||||||||
1505 | qreal bias = 0; | - | ||||||||||||||||||||||||||||||
1506 | if (data.velocity > 0 && dist > QML_FLICK_SNAPONETHRESHOLD && dist < averageSize/2)
| 0-61 | ||||||||||||||||||||||||||||||
1507 | bias = averageSize/2; executed 12 times by 1 test: bias = averageSize/2; Executed by:
| 12 | ||||||||||||||||||||||||||||||
1508 | else if (data.velocity < 0 && dist < -QML_FLICK_SNAPONETHRESHOLD && dist > -averageSize/2)
| 0-60 | ||||||||||||||||||||||||||||||
1509 | bias = -averageSize/2; executed 12 times by 1 test: bias = -averageSize/2; Executed by:
| 12 | ||||||||||||||||||||||||||||||
1510 | if (isContentFlowReversed())
| 48-73 | ||||||||||||||||||||||||||||||
1511 | bias = -bias; executed 48 times by 1 test: bias = -bias; Executed by:
| 48 | ||||||||||||||||||||||||||||||
1512 | tempPosition -= bias; | - | ||||||||||||||||||||||||||||||
1513 | } executed 121 times by 1 test: end of block Executed by:
| 121 | ||||||||||||||||||||||||||||||
1514 | FxViewItem *topItem = snapItemAt(tempPosition+highlightRangeStart); | - | ||||||||||||||||||||||||||||||
1515 | if (strictHighlightRange && currentItem && (!topItem || (topItem->index != currentIndex && fixupMode == Immediate))) {
| 1-476 | ||||||||||||||||||||||||||||||
1516 | // StrictlyEnforceRange always keeps an item in range | - | ||||||||||||||||||||||||||||||
1517 | updateHighlight(); | - | ||||||||||||||||||||||||||||||
1518 | topItem = currentItem; | - | ||||||||||||||||||||||||||||||
1519 | } executed 27 times by 1 test: end of block Executed by:
| 27 | ||||||||||||||||||||||||||||||
1520 | FxViewItem *bottomItem = snapItemAt(tempPosition+highlightRangeEnd); | - | ||||||||||||||||||||||||||||||
1521 | if (strictHighlightRange && currentItem && (!bottomItem || (bottomItem->index != currentIndex && fixupMode == Immediate))) {
| 19-476 | ||||||||||||||||||||||||||||||
1522 | // StrictlyEnforceRange always keeps an item in range | - | ||||||||||||||||||||||||||||||
1523 | updateHighlight(); | - | ||||||||||||||||||||||||||||||
1524 | bottomItem = currentItem; | - | ||||||||||||||||||||||||||||||
1525 | } executed 103 times by 1 test: end of block Executed by:
| 103 | ||||||||||||||||||||||||||||||
1526 | qreal pos; | - | ||||||||||||||||||||||||||||||
1527 | bool isInBounds = -position() > maxExtent && -position() <= minExtent;
| 71-633 | ||||||||||||||||||||||||||||||
1528 | if (topItem && (isInBounds || strictHighlightRange)) {
| 54-461 | ||||||||||||||||||||||||||||||
1529 | if (topItem->index == 0 && header && tempPosition+highlightRangeStart < header->position()+header->size()/2 && !strictHighlightRange) {
| 0-227 | ||||||||||||||||||||||||||||||
1530 | pos = isContentFlowReversed() ? - header->position() + highlightRangeStart - size() : header->position() - highlightRangeStart;
| 0 | ||||||||||||||||||||||||||||||
1531 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1532 | if (isContentFlowReversed())
| 168-239 | ||||||||||||||||||||||||||||||
1533 | pos = qMax(qMin(-topItem->position() + highlightRangeStart - size(), -maxExtent), -minExtent); executed 168 times by 1 test: pos = qMax(qMin(-topItem->position() + highlightRangeStart - size(), -maxExtent), -minExtent); Executed by:
| 168 | ||||||||||||||||||||||||||||||
1534 | else | - | ||||||||||||||||||||||||||||||
1535 | pos = qMax(qMin(topItem->position() - highlightRangeStart, -maxExtent), -minExtent); executed 239 times by 2 tests: pos = qMax(qMin(topItem->position() - highlightRangeStart, -maxExtent), -minExtent); Executed by:
| 239 | ||||||||||||||||||||||||||||||
1536 | } | - | ||||||||||||||||||||||||||||||
1537 | } else if (bottomItem && isInBounds) {
| 0-398 | ||||||||||||||||||||||||||||||
1538 | if (isContentFlowReversed())
| 0 | ||||||||||||||||||||||||||||||
1539 | pos = qMax(qMin(-bottomItem->position() + highlightRangeEnd - size(), -maxExtent), -minExtent); never executed: pos = qMax(qMin(-bottomItem->position() + highlightRangeEnd - size(), -maxExtent), -minExtent); | 0 | ||||||||||||||||||||||||||||||
1540 | else | - | ||||||||||||||||||||||||||||||
1541 | pos = qMax(qMin(bottomItem->position() - highlightRangeEnd, -maxExtent), -minExtent); never executed: pos = qMax(qMin(bottomItem->position() - highlightRangeEnd, -maxExtent), -minExtent); | 0 | ||||||||||||||||||||||||||||||
1542 | } else { | - | ||||||||||||||||||||||||||||||
1543 | QQuickItemViewPrivate::fixup(data, minExtent, maxExtent); | - | ||||||||||||||||||||||||||||||
1544 | return; executed 460 times by 2 tests: return; Executed by:
| 460 | ||||||||||||||||||||||||||||||
1545 | } | - | ||||||||||||||||||||||||||||||
1546 | - | |||||||||||||||||||||||||||||||
1547 | qreal dist = qAbs(data.move + pos); | - | ||||||||||||||||||||||||||||||
1548 | if (dist > 0) {
| 168-239 | ||||||||||||||||||||||||||||||
1549 | timeline.reset(data.move); | - | ||||||||||||||||||||||||||||||
1550 | if (fixupMode != Immediate) {
| 94-145 | ||||||||||||||||||||||||||||||
1551 | timeline.move(data.move, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); | - | ||||||||||||||||||||||||||||||
1552 | data.fixingUp = true; | - | ||||||||||||||||||||||||||||||
1553 | } else { executed 145 times by 1 test: end of block Executed by:
| 145 | ||||||||||||||||||||||||||||||
1554 | timeline.set(data.move, -pos); | - | ||||||||||||||||||||||||||||||
1555 | } executed 94 times by 1 test: end of block Executed by:
| 94 | ||||||||||||||||||||||||||||||
1556 | vTime = timeline.time(); | - | ||||||||||||||||||||||||||||||
1557 | } executed 239 times by 1 test: end of block Executed by:
| 239 | ||||||||||||||||||||||||||||||
1558 | } else if (currentItem && strictHighlightRange && moveReason != QQuickListViewPrivate::SetIndex) { executed 407 times by 2 tests: end of block Executed by:
| 2-6934 | ||||||||||||||||||||||||||||||
1559 | updateHighlight(); | - | ||||||||||||||||||||||||||||||
1560 | qreal pos = static_cast<FxListItemSG*>(currentItem)->itemPosition(); | - | ||||||||||||||||||||||||||||||
1561 | if (viewPos < pos + static_cast<FxListItemSG*>(currentItem)->itemSize() - highlightRangeEnd)
| 12-64 | ||||||||||||||||||||||||||||||
1562 | viewPos = pos + static_cast<FxListItemSG*>(currentItem)->itemSize() - highlightRangeEnd; executed 64 times by 2 tests: viewPos = pos + static_cast<FxListItemSG*>(currentItem)->itemSize() - highlightRangeEnd; Executed by:
| 64 | ||||||||||||||||||||||||||||||
1563 | if (viewPos > pos - highlightRangeStart)
| 0-76 | ||||||||||||||||||||||||||||||
1564 | viewPos = pos - highlightRangeStart; executed 76 times by 2 tests: viewPos = pos - highlightRangeStart; Executed by:
| 76 | ||||||||||||||||||||||||||||||
1565 | if (isContentFlowReversed())
| 10-66 | ||||||||||||||||||||||||||||||
1566 | viewPos = -viewPos-size(); executed 10 times by 1 test: viewPos = -viewPos-size(); Executed by:
| 10 | ||||||||||||||||||||||||||||||
1567 | - | |||||||||||||||||||||||||||||||
1568 | timeline.reset(data.move); | - | ||||||||||||||||||||||||||||||
1569 | if (viewPos != position()) {
| 16-60 | ||||||||||||||||||||||||||||||
1570 | if (fixupMode != Immediate) {
| 2-14 | ||||||||||||||||||||||||||||||
1571 | timeline.move(data.move, -viewPos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); | - | ||||||||||||||||||||||||||||||
1572 | data.fixingUp = true; | - | ||||||||||||||||||||||||||||||
1573 | } else { executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||||||||
1574 | timeline.set(data.move, -viewPos); | - | ||||||||||||||||||||||||||||||
1575 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||||||||||||||
1576 | } | - | ||||||||||||||||||||||||||||||
1577 | vTime = timeline.time(); | - | ||||||||||||||||||||||||||||||
1578 | } else { executed 76 times by 2 tests: end of block Executed by:
| 76 | ||||||||||||||||||||||||||||||
1579 | QQuickItemViewPrivate::fixup(data, minExtent, maxExtent); | - | ||||||||||||||||||||||||||||||
1580 | } executed 11070 times by 11 tests: end of block Executed by:
| 11070 | ||||||||||||||||||||||||||||||
1581 | data.inOvershoot = false; | - | ||||||||||||||||||||||||||||||
1582 | fixupMode = Normal; | - | ||||||||||||||||||||||||||||||
1583 | } executed 11553 times by 11 tests: end of block Executed by:
| 11553 | ||||||||||||||||||||||||||||||
1584 | - | |||||||||||||||||||||||||||||||
1585 | bool QQuickListViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, | - | ||||||||||||||||||||||||||||||
1586 | QQuickTimeLineCallback::Callback fixupCallback, qreal velocity) | - | ||||||||||||||||||||||||||||||
1587 | { | - | ||||||||||||||||||||||||||||||
1588 | data.fixingUp = false; | - | ||||||||||||||||||||||||||||||
1589 | moveReason = Mouse; | - | ||||||||||||||||||||||||||||||
1590 | if ((!haveHighlightRange || highlightRange != QQuickListView::StrictlyEnforceRange) && snapMode == QQuickListView::NoSnap) {
| 0-1097 | ||||||||||||||||||||||||||||||
1591 | correctFlick = true; | - | ||||||||||||||||||||||||||||||
1592 | return QQuickItemViewPrivate::flick(data, minExtent, maxExtent, vSize, fixupCallback, velocity); executed 51 times by 1 test: return QQuickItemViewPrivate::flick(data, minExtent, maxExtent, vSize, fixupCallback, velocity); Executed by:
| 51 | ||||||||||||||||||||||||||||||
1593 | } | - | ||||||||||||||||||||||||||||||
1594 | qreal maxDistance = 0; | - | ||||||||||||||||||||||||||||||
1595 | qreal dataValue = isContentFlowReversed() ? -data.move.value()+size() : data.move.value();
| 1000-1048 | ||||||||||||||||||||||||||||||
1596 | - | |||||||||||||||||||||||||||||||
1597 | // -ve velocity means list is moving up/left | - | ||||||||||||||||||||||||||||||
1598 | if (velocity > 0) {
| 1006-1042 | ||||||||||||||||||||||||||||||
1599 | if (data.move.value() < minExtent) {
| 14-992 | ||||||||||||||||||||||||||||||
1600 | if (snapMode == QQuickListView::SnapOneItem && !hData.flicking && !vData.flicking) {
| 48-780 | ||||||||||||||||||||||||||||||
1601 | // if we've been dragged < averageSize/2 then bias towards the next item | - | ||||||||||||||||||||||||||||||
1602 | qreal dist = data.move.value() - data.pressPos; | - | ||||||||||||||||||||||||||||||
1603 | qreal bias = dist < averageSize/2 ? averageSize/2 : 0;
| 0-48 | ||||||||||||||||||||||||||||||
1604 | if (isContentFlowReversed())
| 24 | ||||||||||||||||||||||||||||||
1605 | bias = -bias; executed 24 times by 1 test: bias = -bias; Executed by:
| 24 | ||||||||||||||||||||||||||||||
1606 | data.flickTarget = -snapPosAt(-(dataValue - highlightRangeStart) - bias) + highlightRangeStart; | - | ||||||||||||||||||||||||||||||
1607 | maxDistance = qAbs(data.flickTarget - data.move.value()); | - | ||||||||||||||||||||||||||||||
1608 | velocity = maxVelocity; | - | ||||||||||||||||||||||||||||||
1609 | } else { executed 48 times by 1 test: end of block Executed by:
| 48 | ||||||||||||||||||||||||||||||
1610 | maxDistance = qAbs(minExtent - data.move.value()); | - | ||||||||||||||||||||||||||||||
1611 | } executed 944 times by 1 test: end of block Executed by:
| 944 | ||||||||||||||||||||||||||||||
1612 | } | - | ||||||||||||||||||||||||||||||
1613 | if (snapMode == QQuickListView::NoSnap && highlightRange != QQuickListView::StrictlyEnforceRange)
| 0-1002 | ||||||||||||||||||||||||||||||
1614 | data.flickTarget = minExtent; never executed: data.flickTarget = minExtent; | 0 | ||||||||||||||||||||||||||||||
1615 | } else { executed 1006 times by 1 test: end of block Executed by:
| 1006 | ||||||||||||||||||||||||||||||
1616 | if (data.move.value() > maxExtent) {
| 16-1026 | ||||||||||||||||||||||||||||||
1617 | if (snapMode == QQuickListView::SnapOneItem && !hData.flicking && !vData.flicking) {
| 48-811 | ||||||||||||||||||||||||||||||
1618 | // if we've been dragged < averageSize/2 then bias towards the next item | - | ||||||||||||||||||||||||||||||
1619 | qreal dist = data.move.value() - data.pressPos; | - | ||||||||||||||||||||||||||||||
1620 | qreal bias = -dist < averageSize/2 ? averageSize/2 : 0;
| 0-48 | ||||||||||||||||||||||||||||||
1621 | if (isContentFlowReversed())
| 24 | ||||||||||||||||||||||||||||||
1622 | bias = -bias; executed 24 times by 1 test: bias = -bias; Executed by:
| 24 | ||||||||||||||||||||||||||||||
1623 | data.flickTarget = -snapPosAt(-(dataValue - highlightRangeStart) + bias) + highlightRangeStart; | - | ||||||||||||||||||||||||||||||
1624 | maxDistance = qAbs(data.flickTarget - data.move.value()); | - | ||||||||||||||||||||||||||||||
1625 | velocity = -maxVelocity; | - | ||||||||||||||||||||||||||||||
1626 | } else { executed 48 times by 1 test: end of block Executed by:
| 48 | ||||||||||||||||||||||||||||||
1627 | maxDistance = qAbs(maxExtent - data.move.value()); | - | ||||||||||||||||||||||||||||||
1628 | } executed 978 times by 1 test: end of block Executed by:
| 978 | ||||||||||||||||||||||||||||||
1629 | } | - | ||||||||||||||||||||||||||||||
1630 | if (snapMode == QQuickListView::NoSnap && highlightRange != QQuickListView::StrictlyEnforceRange)
| 0-1038 | ||||||||||||||||||||||||||||||
1631 | data.flickTarget = maxExtent; never executed: data.flickTarget = maxExtent; | 0 | ||||||||||||||||||||||||||||||
1632 | } executed 1042 times by 1 test: end of block Executed by:
| 1042 | ||||||||||||||||||||||||||||||
1633 | bool overShoot = boundsBehavior & QQuickFlickable::OvershootBounds; | - | ||||||||||||||||||||||||||||||
1634 | if (maxDistance > 0 || overShoot) {
| 0-2018 | ||||||||||||||||||||||||||||||
1635 | // These modes require the list to stop exactly on an item boundary. | - | ||||||||||||||||||||||||||||||
1636 | // The initial flick will estimate the boundary to stop on. | - | ||||||||||||||||||||||||||||||
1637 | // Since list items can have variable sizes, the boundary will be | - | ||||||||||||||||||||||||||||||
1638 | // reevaluated and adjusted as we approach the boundary. | - | ||||||||||||||||||||||||||||||
1639 | qreal v = velocity; | - | ||||||||||||||||||||||||||||||
1640 | if (maxVelocity != -1 && maxVelocity < qAbs(v)) {
| 0-2048 | ||||||||||||||||||||||||||||||
1641 | if (v < 0)
| 1-2 | ||||||||||||||||||||||||||||||
1642 | v = -maxVelocity; executed 2 times by 1 test: v = -maxVelocity; Executed by:
| 2 | ||||||||||||||||||||||||||||||
1643 | else | - | ||||||||||||||||||||||||||||||
1644 | v = maxVelocity; executed 1 time by 1 test: v = maxVelocity; Executed by:
| 1 | ||||||||||||||||||||||||||||||
1645 | } | - | ||||||||||||||||||||||||||||||
1646 | if (!hData.flicking && !vData.flicking) {
| 210-1113 | ||||||||||||||||||||||||||||||
1647 | // the initial flick - estimate boundary | - | ||||||||||||||||||||||||||||||
1648 | qreal accel = deceleration; | - | ||||||||||||||||||||||||||||||
1649 | qreal v2 = v * v; | - | ||||||||||||||||||||||||||||||
1650 | overshootDist = 0.0; | - | ||||||||||||||||||||||||||||||
1651 | // + averageSize/4 to encourage moving at least one item in the flick direction | - | ||||||||||||||||||||||||||||||
1652 | qreal dist = v2 / (accel * 2.0) + averageSize/4; | - | ||||||||||||||||||||||||||||||
1653 | if (maxDistance > 0)
| 30-180 | ||||||||||||||||||||||||||||||
1654 | dist = qMin(dist, maxDistance); executed 180 times by 1 test: dist = qMin(dist, maxDistance); Executed by:
| 180 | ||||||||||||||||||||||||||||||
1655 | if (v > 0)
| 102-108 | ||||||||||||||||||||||||||||||
1656 | dist = -dist; executed 102 times by 1 test: dist = -dist; Executed by:
| 102 | ||||||||||||||||||||||||||||||
1657 | if ((maxDistance > 0.0 && v2 / (2.0f * maxDistance) < accel) || snapMode == QQuickListView::SnapOneItem) {
| 30-180 | ||||||||||||||||||||||||||||||
1658 | if (snapMode != QQuickListView::SnapOneItem) {
| 66-98 | ||||||||||||||||||||||||||||||
1659 | qreal distTemp = isContentFlowReversed() ? -dist : dist;
| 32-34 | ||||||||||||||||||||||||||||||
1660 | data.flickTarget = -snapPosAt(-(dataValue - highlightRangeStart) + distTemp) + highlightRangeStart; | - | ||||||||||||||||||||||||||||||
1661 | } executed 66 times by 1 test: end of block Executed by:
| 66 | ||||||||||||||||||||||||||||||
1662 | data.flickTarget = isContentFlowReversed() ? -data.flickTarget+size() : data.flickTarget;
| 80-84 | ||||||||||||||||||||||||||||||
1663 | if (overShoot) {
| 0-164 | ||||||||||||||||||||||||||||||
1664 | if (data.flickTarget > minExtent) {
| 10-154 | ||||||||||||||||||||||||||||||
1665 | overshootDist = overShootDistance(vSize); | - | ||||||||||||||||||||||||||||||
1666 | data.flickTarget += overshootDist; | - | ||||||||||||||||||||||||||||||
1667 | } else if (data.flickTarget < maxExtent) { executed 10 times by 1 test: end of block Executed by:
| 8-146 | ||||||||||||||||||||||||||||||
1668 | overshootDist = overShootDistance(vSize); | - | ||||||||||||||||||||||||||||||
1669 | data.flickTarget -= overshootDist; | - | ||||||||||||||||||||||||||||||
1670 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||||||||
1671 | } executed 164 times by 1 test: end of block Executed by:
| 164 | ||||||||||||||||||||||||||||||
1672 | qreal adjDist = -data.flickTarget + data.move.value(); | - | ||||||||||||||||||||||||||||||
1673 | if (qAbs(adjDist) > qAbs(dist)) {
| 15-149 | ||||||||||||||||||||||||||||||
1674 | // Prevent painfully slow flicking - adjust velocity to suit flickDeceleration | - | ||||||||||||||||||||||||||||||
1675 | qreal adjv2 = accel * 2.0f * qAbs(adjDist); | - | ||||||||||||||||||||||||||||||
1676 | if (adjv2 > v2) {
| 7-8 | ||||||||||||||||||||||||||||||
1677 | v2 = adjv2; | - | ||||||||||||||||||||||||||||||
1678 | v = qSqrt(v2); | - | ||||||||||||||||||||||||||||||
1679 | if (dist > 0)
| 2-5 | ||||||||||||||||||||||||||||||
1680 | v = -v; executed 2 times by 1 test: v = -v; Executed by:
| 2 | ||||||||||||||||||||||||||||||
1681 | } executed 7 times by 1 test: end of block Executed by:
| 7 | ||||||||||||||||||||||||||||||
1682 | } executed 15 times by 1 test: end of block Executed by:
| 15 | ||||||||||||||||||||||||||||||
1683 | dist = adjDist; | - | ||||||||||||||||||||||||||||||
1684 | accel = v2 / (2.0f * qAbs(dist)); | - | ||||||||||||||||||||||||||||||
1685 | } else if (overShoot) { executed 164 times by 1 test: end of block Executed by:
| 0-164 | ||||||||||||||||||||||||||||||
1686 | data.flickTarget = data.move.value() - dist; | - | ||||||||||||||||||||||||||||||
1687 | if (data.flickTarget > minExtent) {
| 12-34 | ||||||||||||||||||||||||||||||
1688 | overshootDist = overShootDistance(vSize); | - | ||||||||||||||||||||||||||||||
1689 | data.flickTarget += overshootDist; | - | ||||||||||||||||||||||||||||||
1690 | } else if (data.flickTarget < maxExtent) { executed 12 times by 1 test: end of block Executed by:
| 12-18 | ||||||||||||||||||||||||||||||
1691 | overshootDist = overShootDistance(vSize); | - | ||||||||||||||||||||||||||||||
1692 | data.flickTarget -= overshootDist; | - | ||||||||||||||||||||||||||||||
1693 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||||||||||||||
1694 | } executed 46 times by 1 test: end of block Executed by:
| 46 | ||||||||||||||||||||||||||||||
1695 | timeline.reset(data.move); | - | ||||||||||||||||||||||||||||||
1696 | timeline.accel(data.move, v, accel, maxDistance + overshootDist); | - | ||||||||||||||||||||||||||||||
1697 | timeline.callback(QQuickTimeLineCallback(&data.move, fixupCallback, this)); | - | ||||||||||||||||||||||||||||||
1698 | correctFlick = true; | - | ||||||||||||||||||||||||||||||
1699 | return true; executed 210 times by 1 test: return true; Executed by:
| 210 | ||||||||||||||||||||||||||||||
1700 | } else { | - | ||||||||||||||||||||||||||||||
1701 | // reevaluate the target boundary. | - | ||||||||||||||||||||||||||||||
1702 | qreal newtarget = data.flickTarget; | - | ||||||||||||||||||||||||||||||
1703 | if (snapMode != QQuickListView::NoSnap || highlightRange == QQuickListView::StrictlyEnforceRange) {
| 0-1838 | ||||||||||||||||||||||||||||||
1704 | qreal tempFlickTarget = isContentFlowReversed() ? -data.flickTarget+size() : data.flickTarget;
| 904-934 | ||||||||||||||||||||||||||||||
1705 | newtarget = -snapPosAt(-(tempFlickTarget - highlightRangeStart)) + highlightRangeStart; | - | ||||||||||||||||||||||||||||||
1706 | newtarget = isContentFlowReversed() ? -newtarget+size() : newtarget;
| 904-934 | ||||||||||||||||||||||||||||||
1707 | } executed 1838 times by 1 test: end of block Executed by:
| 1838 | ||||||||||||||||||||||||||||||
1708 | if (velocity < 0 && newtarget <= maxExtent)
| 12-934 | ||||||||||||||||||||||||||||||
1709 | newtarget = maxExtent - overshootDist; executed 12 times by 1 test: newtarget = maxExtent - overshootDist; Executed by:
| 12 | ||||||||||||||||||||||||||||||
1710 | else if (velocity > 0 && newtarget >= minExtent)
| 13-922 | ||||||||||||||||||||||||||||||
1711 | newtarget = minExtent + overshootDist; executed 13 times by 1 test: newtarget = minExtent + overshootDist; Executed by:
| 13 | ||||||||||||||||||||||||||||||
1712 | if (newtarget == data.flickTarget) { // boundary unchanged - nothing to do
| 16-1822 | ||||||||||||||||||||||||||||||
1713 | if (qAbs(velocity) < MinimumFlickVelocity)
| 93-1729 | ||||||||||||||||||||||||||||||
1714 | correctFlick = false; executed 93 times by 1 test: correctFlick = false; Executed by:
| 93 | ||||||||||||||||||||||||||||||
1715 | return false; executed 1822 times by 1 test: return false; Executed by:
| 1822 | ||||||||||||||||||||||||||||||
1716 | } | - | ||||||||||||||||||||||||||||||
1717 | data.flickTarget = newtarget; | - | ||||||||||||||||||||||||||||||
1718 | qreal dist = -newtarget + data.move.value(); | - | ||||||||||||||||||||||||||||||
1719 | if ((v < 0 && dist < 0) || (v > 0 && dist > 0)) {
| 0-8 | ||||||||||||||||||||||||||||||
1720 | correctFlick = false; | - | ||||||||||||||||||||||||||||||
1721 | timeline.reset(data.move); | - | ||||||||||||||||||||||||||||||
1722 | fixup(data, minExtent, maxExtent); | - | ||||||||||||||||||||||||||||||
1723 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||
1724 | } | - | ||||||||||||||||||||||||||||||
1725 | timeline.reset(data.move); | - | ||||||||||||||||||||||||||||||
1726 | timeline.accelDistance(data.move, v, -dist); | - | ||||||||||||||||||||||||||||||
1727 | timeline.callback(QQuickTimeLineCallback(&data.move, fixupCallback, this)); | - | ||||||||||||||||||||||||||||||
1728 | return false; executed 16 times by 1 test: return false; Executed by:
| 16 | ||||||||||||||||||||||||||||||
1729 | } | - | ||||||||||||||||||||||||||||||
1730 | } else { | - | ||||||||||||||||||||||||||||||
1731 | correctFlick = false; | - | ||||||||||||||||||||||||||||||
1732 | timeline.reset(data.move); | - | ||||||||||||||||||||||||||||||
1733 | fixup(data, minExtent, maxExtent); | - | ||||||||||||||||||||||||||||||
1734 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||
1735 | } | - | ||||||||||||||||||||||||||||||
1736 | } | - | ||||||||||||||||||||||||||||||
1737 | - | |||||||||||||||||||||||||||||||
1738 | //---------------------------------------------------------------------------- | - | ||||||||||||||||||||||||||||||
1739 | - | |||||||||||||||||||||||||||||||
1740 | /*! | - | ||||||||||||||||||||||||||||||
1741 | \qmltype ListView | - | ||||||||||||||||||||||||||||||
1742 | \instantiates QQuickListView | - | ||||||||||||||||||||||||||||||
1743 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||||||||
1744 | \ingroup qtquick-views | - | ||||||||||||||||||||||||||||||
1745 | \inherits Flickable | - | ||||||||||||||||||||||||||||||
1746 | \brief Provides a list view of items provided by a model. | - | ||||||||||||||||||||||||||||||
1747 | - | |||||||||||||||||||||||||||||||
1748 | A ListView displays data from models created from built-in QML types like ListModel | - | ||||||||||||||||||||||||||||||
1749 | and XmlListModel, or custom model classes defined in C++ that inherit from | - | ||||||||||||||||||||||||||||||
1750 | QAbstractItemModel or QAbstractListModel. | - | ||||||||||||||||||||||||||||||
1751 | - | |||||||||||||||||||||||||||||||
1752 | A ListView has a \l model, which defines the data to be displayed, and | - | ||||||||||||||||||||||||||||||
1753 | a \l delegate, which defines how the data should be displayed. Items in a | - | ||||||||||||||||||||||||||||||
1754 | ListView are laid out horizontally or vertically. List views are inherently | - | ||||||||||||||||||||||||||||||
1755 | flickable because ListView inherits from \l Flickable. | - | ||||||||||||||||||||||||||||||
1756 | - | |||||||||||||||||||||||||||||||
1757 | \section1 Example Usage | - | ||||||||||||||||||||||||||||||
1758 | - | |||||||||||||||||||||||||||||||
1759 | The following example shows the definition of a simple list model defined | - | ||||||||||||||||||||||||||||||
1760 | in a file called \c ContactModel.qml: | - | ||||||||||||||||||||||||||||||
1761 | - | |||||||||||||||||||||||||||||||
1762 | \snippet qml/listview/ContactModel.qml 0 | - | ||||||||||||||||||||||||||||||
1763 | - | |||||||||||||||||||||||||||||||
1764 | Another component can display this model data in a ListView, like this: | - | ||||||||||||||||||||||||||||||
1765 | - | |||||||||||||||||||||||||||||||
1766 | \snippet qml/listview/listview.qml import | - | ||||||||||||||||||||||||||||||
1767 | \codeline | - | ||||||||||||||||||||||||||||||
1768 | \snippet qml/listview/listview.qml classdocs simple | - | ||||||||||||||||||||||||||||||
1769 | - | |||||||||||||||||||||||||||||||
1770 | \image listview-simple.png | - | ||||||||||||||||||||||||||||||
1771 | - | |||||||||||||||||||||||||||||||
1772 | Here, the ListView creates a \c ContactModel component for its model, and a \l Text item | - | ||||||||||||||||||||||||||||||
1773 | for its delegate. The view will create a new \l Text component for each item in the model. Notice | - | ||||||||||||||||||||||||||||||
1774 | the delegate is able to access the model's \c name and \c number data directly. | - | ||||||||||||||||||||||||||||||
1775 | - | |||||||||||||||||||||||||||||||
1776 | An improved list view is shown below. The delegate is visually improved and is moved | - | ||||||||||||||||||||||||||||||
1777 | into a separate \c contactDelegate component. | - | ||||||||||||||||||||||||||||||
1778 | - | |||||||||||||||||||||||||||||||
1779 | \snippet qml/listview/listview.qml classdocs advanced | - | ||||||||||||||||||||||||||||||
1780 | \image listview-highlight.png | - | ||||||||||||||||||||||||||||||
1781 | - | |||||||||||||||||||||||||||||||
1782 | The currently selected item is highlighted with a blue \l Rectangle using the \l highlight property, | - | ||||||||||||||||||||||||||||||
1783 | and \c focus is set to \c true to enable keyboard navigation for the list view. | - | ||||||||||||||||||||||||||||||
1784 | The list view itself is a focus scope (see \l{Keyboard Focus in Qt Quick} for more details). | - | ||||||||||||||||||||||||||||||
1785 | - | |||||||||||||||||||||||||||||||
1786 | Delegates are instantiated as needed and may be destroyed at any time. | - | ||||||||||||||||||||||||||||||
1787 | They are parented to ListView's \l {Flickable::contentItem}{contentItem}, not to the view itself. | - | ||||||||||||||||||||||||||||||
1788 | State should \e never be stored in a delegate. | - | ||||||||||||||||||||||||||||||
1789 | - | |||||||||||||||||||||||||||||||
1790 | ListView attaches a number of properties to the root item of the delegate, for example | - | ||||||||||||||||||||||||||||||
1791 | \c ListView.isCurrentItem. In the following example, the root delegate item can access | - | ||||||||||||||||||||||||||||||
1792 | this attached property directly as \c ListView.isCurrentItem, while the child | - | ||||||||||||||||||||||||||||||
1793 | \c contactInfo object must refer to this property as \c wrapper.ListView.isCurrentItem. | - | ||||||||||||||||||||||||||||||
1794 | - | |||||||||||||||||||||||||||||||
1795 | \snippet qml/listview/listview.qml isCurrentItem | - | ||||||||||||||||||||||||||||||
1796 | - | |||||||||||||||||||||||||||||||
1797 | \note Views do not enable \e clip automatically. If the view | - | ||||||||||||||||||||||||||||||
1798 | is not clipped by another item or the screen, it will be necessary | - | ||||||||||||||||||||||||||||||
1799 | to set \e {clip: true} in order to have the out of view items clipped | - | ||||||||||||||||||||||||||||||
1800 | nicely. | - | ||||||||||||||||||||||||||||||
1801 | - | |||||||||||||||||||||||||||||||
1802 | - | |||||||||||||||||||||||||||||||
1803 | \section1 ListView Layouts | - | ||||||||||||||||||||||||||||||
1804 | - | |||||||||||||||||||||||||||||||
1805 | The layout of the items in a ListView can be controlled by these properties: | - | ||||||||||||||||||||||||||||||
1806 | - | |||||||||||||||||||||||||||||||
1807 | \list | - | ||||||||||||||||||||||||||||||
1808 | \li \l orientation - controls whether items flow horizontally or vertically. | - | ||||||||||||||||||||||||||||||
1809 | This value can be either Qt.Horizontal or Qt.Vertical. | - | ||||||||||||||||||||||||||||||
1810 | \li \l layoutDirection - controls the horizontal layout direction for a | - | ||||||||||||||||||||||||||||||
1811 | horizontally-oriented view: that is, whether items are laid out from the left side of | - | ||||||||||||||||||||||||||||||
1812 | the view to the right, or vice-versa. This value can be either Qt.LeftToRight or Qt.RightToLeft. | - | ||||||||||||||||||||||||||||||
1813 | \li \l verticalLayoutDirection - controls the vertical layout direction for a vertically-oriented | - | ||||||||||||||||||||||||||||||
1814 | view: that is, whether items are laid out from the top of the view down towards the bottom of | - | ||||||||||||||||||||||||||||||
1815 | the view, or vice-versa. This value can be either ListView.TopToBottom or ListView.BottomToTop. | - | ||||||||||||||||||||||||||||||
1816 | \endlist | - | ||||||||||||||||||||||||||||||
1817 | - | |||||||||||||||||||||||||||||||
1818 | By default, a ListView has a vertical orientation, and items are laid out from top to bottom. The | - | ||||||||||||||||||||||||||||||
1819 | table below shows the different layouts that a ListView can have, depending on the values of | - | ||||||||||||||||||||||||||||||
1820 | the properties listed above. | - | ||||||||||||||||||||||||||||||
1821 | - | |||||||||||||||||||||||||||||||
1822 | \table | - | ||||||||||||||||||||||||||||||
1823 | \header | - | ||||||||||||||||||||||||||||||
1824 | \li {2, 1} | - | ||||||||||||||||||||||||||||||
1825 | \b ListViews with Qt.Vertical orientation | - | ||||||||||||||||||||||||||||||
1826 | \row | - | ||||||||||||||||||||||||||||||
1827 | \li Top to bottom | - | ||||||||||||||||||||||||||||||
1828 | \image listview-layout-toptobottom.png | - | ||||||||||||||||||||||||||||||
1829 | \li Bottom to top | - | ||||||||||||||||||||||||||||||
1830 | \image listview-layout-bottomtotop.png | - | ||||||||||||||||||||||||||||||
1831 | \header | - | ||||||||||||||||||||||||||||||
1832 | \li {2, 1} | - | ||||||||||||||||||||||||||||||
1833 | \b ListViews with Qt.Horizontal orientation | - | ||||||||||||||||||||||||||||||
1834 | \row | - | ||||||||||||||||||||||||||||||
1835 | \li Left to right | - | ||||||||||||||||||||||||||||||
1836 | \image listview-layout-lefttoright.png | - | ||||||||||||||||||||||||||||||
1837 | \li Right to left | - | ||||||||||||||||||||||||||||||
1838 | \image listview-layout-righttoleft.png | - | ||||||||||||||||||||||||||||||
1839 | \endtable | - | ||||||||||||||||||||||||||||||
1840 | - | |||||||||||||||||||||||||||||||
1841 | \section1 Flickable Direction | - | ||||||||||||||||||||||||||||||
1842 | - | |||||||||||||||||||||||||||||||
1843 | By default, a vertical ListView sets \l {Flickable::}{flickableDirection} to \e Flickable.Vertical, | - | ||||||||||||||||||||||||||||||
1844 | and a horizontal ListView sets it to \e Flickable.Horizontal. Furthermore, a vertical ListView only | - | ||||||||||||||||||||||||||||||
1845 | calculates (estimates) the \l {Flickable::}{contentHeight}, and a horizontal ListView only calculates | - | ||||||||||||||||||||||||||||||
1846 | the \l {Flickable::}{contentWidth}. The other dimension is set to \e -1. | - | ||||||||||||||||||||||||||||||
1847 | - | |||||||||||||||||||||||||||||||
1848 | Since Qt 5.9 (Qt Quick 2.9), it is possible to make a ListView that can be flicked to both directions. | - | ||||||||||||||||||||||||||||||
1849 | In order to do this, the \l {Flickable::}{flickableDirection} can be set to \e Flickable.AutoFlickDirection | - | ||||||||||||||||||||||||||||||
1850 | or \e Flickable.AutoFlickIfNeeded, and the desired \e contentWidth or \e contentHeight must be provided. | - | ||||||||||||||||||||||||||||||
1851 | - | |||||||||||||||||||||||||||||||
1852 | \snippet qml/listview/listview.qml flickBothDirections | - | ||||||||||||||||||||||||||||||
1853 | - | |||||||||||||||||||||||||||||||
1854 | \section1 Stacking Order in ListView | - | ||||||||||||||||||||||||||||||
1855 | - | |||||||||||||||||||||||||||||||
1856 | The \l {QQuickItem::z}{Z value} of items determines whether they are | - | ||||||||||||||||||||||||||||||
1857 | rendered above or below other items. ListView uses several different | - | ||||||||||||||||||||||||||||||
1858 | default Z values, depending on what type of item is being created: | - | ||||||||||||||||||||||||||||||
1859 | - | |||||||||||||||||||||||||||||||
1860 | \table | - | ||||||||||||||||||||||||||||||
1861 | \header | - | ||||||||||||||||||||||||||||||
1862 | \li Property | - | ||||||||||||||||||||||||||||||
1863 | \li Default Z value | - | ||||||||||||||||||||||||||||||
1864 | \row | - | ||||||||||||||||||||||||||||||
1865 | \li \l delegate | - | ||||||||||||||||||||||||||||||
1866 | \li 1 | - | ||||||||||||||||||||||||||||||
1867 | \row | - | ||||||||||||||||||||||||||||||
1868 | \li \l footer | - | ||||||||||||||||||||||||||||||
1869 | \li 1 | - | ||||||||||||||||||||||||||||||
1870 | \row | - | ||||||||||||||||||||||||||||||
1871 | \li \l header | - | ||||||||||||||||||||||||||||||
1872 | \li 1 | - | ||||||||||||||||||||||||||||||
1873 | \row | - | ||||||||||||||||||||||||||||||
1874 | \li \l highlight | - | ||||||||||||||||||||||||||||||
1875 | \li 0 | - | ||||||||||||||||||||||||||||||
1876 | \row | - | ||||||||||||||||||||||||||||||
1877 | \li \l section.delegate | - | ||||||||||||||||||||||||||||||
1878 | \li 2 | - | ||||||||||||||||||||||||||||||
1879 | \endtable | - | ||||||||||||||||||||||||||||||
1880 | - | |||||||||||||||||||||||||||||||
1881 | These default values are set if the Z value of the item is \c 0, so setting | - | ||||||||||||||||||||||||||||||
1882 | the Z value of these items to \c 0 has no effect. Note that the Z value is | - | ||||||||||||||||||||||||||||||
1883 | of type \l [QML] {real}, so it is possible to set fractional | - | ||||||||||||||||||||||||||||||
1884 | values like \c 0.1. | - | ||||||||||||||||||||||||||||||
1885 | - | |||||||||||||||||||||||||||||||
1886 | \sa {QML Data Models}, GridView, PathView, {Qt Quick Examples - Views} | - | ||||||||||||||||||||||||||||||
1887 | */ | - | ||||||||||||||||||||||||||||||
1888 | QQuickListView::QQuickListView(QQuickItem *parent) | - | ||||||||||||||||||||||||||||||
1889 | : QQuickItemView(*(new QQuickListViewPrivate), parent) | - | ||||||||||||||||||||||||||||||
1890 | { | - | ||||||||||||||||||||||||||||||
1891 | } executed 1920 times by 11 tests: end of block Executed by:
| 1920 | ||||||||||||||||||||||||||||||
1892 | - | |||||||||||||||||||||||||||||||
1893 | QQuickListView::~QQuickListView() | - | ||||||||||||||||||||||||||||||
1894 | { | - | ||||||||||||||||||||||||||||||
1895 | } | - | ||||||||||||||||||||||||||||||
1896 | - | |||||||||||||||||||||||||||||||
1897 | /*! | - | ||||||||||||||||||||||||||||||
1898 | \qmlattachedproperty bool QtQuick::ListView::isCurrentItem | - | ||||||||||||||||||||||||||||||
1899 | This attached property is true if this delegate is the current item; otherwise false. | - | ||||||||||||||||||||||||||||||
1900 | - | |||||||||||||||||||||||||||||||
1901 | It is attached to each instance of the delegate. | - | ||||||||||||||||||||||||||||||
1902 | - | |||||||||||||||||||||||||||||||
1903 | This property may be used to adjust the appearance of the current item, for example: | - | ||||||||||||||||||||||||||||||
1904 | - | |||||||||||||||||||||||||||||||
1905 | \snippet qml/listview/listview.qml isCurrentItem | - | ||||||||||||||||||||||||||||||
1906 | */ | - | ||||||||||||||||||||||||||||||
1907 | - | |||||||||||||||||||||||||||||||
1908 | /*! | - | ||||||||||||||||||||||||||||||
1909 | \qmlattachedproperty ListView QtQuick::ListView::view | - | ||||||||||||||||||||||||||||||
1910 | This attached property holds the view that manages this delegate instance. | - | ||||||||||||||||||||||||||||||
1911 | - | |||||||||||||||||||||||||||||||
1912 | It is attached to each instance of the delegate and also to the header, the footer, | - | ||||||||||||||||||||||||||||||
1913 | the section and the highlight delegates. | - | ||||||||||||||||||||||||||||||
1914 | */ | - | ||||||||||||||||||||||||||||||
1915 | - | |||||||||||||||||||||||||||||||
1916 | /*! | - | ||||||||||||||||||||||||||||||
1917 | \qmlattachedproperty string QtQuick::ListView::previousSection | - | ||||||||||||||||||||||||||||||
1918 | This attached property holds the section of the previous element. | - | ||||||||||||||||||||||||||||||
1919 | - | |||||||||||||||||||||||||||||||
1920 | It is attached to each instance of the delegate. | - | ||||||||||||||||||||||||||||||
1921 | - | |||||||||||||||||||||||||||||||
1922 | The section is evaluated using the \l {ListView::section.property}{section} properties. | - | ||||||||||||||||||||||||||||||
1923 | */ | - | ||||||||||||||||||||||||||||||
1924 | - | |||||||||||||||||||||||||||||||
1925 | /*! | - | ||||||||||||||||||||||||||||||
1926 | \qmlattachedproperty string QtQuick::ListView::nextSection | - | ||||||||||||||||||||||||||||||
1927 | This attached property holds the section of the next element. | - | ||||||||||||||||||||||||||||||
1928 | - | |||||||||||||||||||||||||||||||
1929 | It is attached to each instance of the delegate. | - | ||||||||||||||||||||||||||||||
1930 | - | |||||||||||||||||||||||||||||||
1931 | The section is evaluated using the \l {ListView::section.property}{section} properties. | - | ||||||||||||||||||||||||||||||
1932 | */ | - | ||||||||||||||||||||||||||||||
1933 | - | |||||||||||||||||||||||||||||||
1934 | /*! | - | ||||||||||||||||||||||||||||||
1935 | \qmlattachedproperty string QtQuick::ListView::section | - | ||||||||||||||||||||||||||||||
1936 | This attached property holds the section of this element. | - | ||||||||||||||||||||||||||||||
1937 | - | |||||||||||||||||||||||||||||||
1938 | It is attached to each instance of the delegate. | - | ||||||||||||||||||||||||||||||
1939 | - | |||||||||||||||||||||||||||||||
1940 | The section is evaluated using the \l {ListView::section.property}{section} properties. | - | ||||||||||||||||||||||||||||||
1941 | */ | - | ||||||||||||||||||||||||||||||
1942 | - | |||||||||||||||||||||||||||||||
1943 | /*! | - | ||||||||||||||||||||||||||||||
1944 | \qmlattachedproperty bool QtQuick::ListView::delayRemove | - | ||||||||||||||||||||||||||||||
1945 | - | |||||||||||||||||||||||||||||||
1946 | This attached property holds whether the delegate may be destroyed. It | - | ||||||||||||||||||||||||||||||
1947 | is attached to each instance of the delegate. The default value is false. | - | ||||||||||||||||||||||||||||||
1948 | - | |||||||||||||||||||||||||||||||
1949 | It is sometimes necessary to delay the destruction of an item | - | ||||||||||||||||||||||||||||||
1950 | until an animation completes. The example delegate below ensures that the | - | ||||||||||||||||||||||||||||||
1951 | animation completes before the item is removed from the list. | - | ||||||||||||||||||||||||||||||
1952 | - | |||||||||||||||||||||||||||||||
1953 | \snippet qml/listview/listview.qml delayRemove | - | ||||||||||||||||||||||||||||||
1954 | - | |||||||||||||||||||||||||||||||
1955 | If a \l remove transition has been specified, it will not be applied until | - | ||||||||||||||||||||||||||||||
1956 | delayRemove is returned to \c false. | - | ||||||||||||||||||||||||||||||
1957 | */ | - | ||||||||||||||||||||||||||||||
1958 | - | |||||||||||||||||||||||||||||||
1959 | /*! | - | ||||||||||||||||||||||||||||||
1960 | \qmlattachedsignal QtQuick::ListView::add() | - | ||||||||||||||||||||||||||||||
1961 | This attached signal is emitted immediately after an item is added to the view. | - | ||||||||||||||||||||||||||||||
1962 | - | |||||||||||||||||||||||||||||||
1963 | If an \l add transition is specified, it is applied immediately after | - | ||||||||||||||||||||||||||||||
1964 | this signal is handled. | - | ||||||||||||||||||||||||||||||
1965 | - | |||||||||||||||||||||||||||||||
1966 | The corresponding handler is \c onAdd. | - | ||||||||||||||||||||||||||||||
1967 | */ | - | ||||||||||||||||||||||||||||||
1968 | - | |||||||||||||||||||||||||||||||
1969 | /*! | - | ||||||||||||||||||||||||||||||
1970 | \qmlattachedsignal QtQuick::ListView::remove() | - | ||||||||||||||||||||||||||||||
1971 | This attached signal is emitted immediately before an item is removed from the view. | - | ||||||||||||||||||||||||||||||
1972 | - | |||||||||||||||||||||||||||||||
1973 | If a \l remove transition has been specified, it is applied after | - | ||||||||||||||||||||||||||||||
1974 | this signal is handled, providing that \l delayRemove is false. | - | ||||||||||||||||||||||||||||||
1975 | - | |||||||||||||||||||||||||||||||
1976 | The corresponding handler is \c onRemove. | - | ||||||||||||||||||||||||||||||
1977 | */ | - | ||||||||||||||||||||||||||||||
1978 | - | |||||||||||||||||||||||||||||||
1979 | /*! | - | ||||||||||||||||||||||||||||||
1980 | \qmlproperty model QtQuick::ListView::model | - | ||||||||||||||||||||||||||||||
1981 | This property holds the model providing data for the list. | - | ||||||||||||||||||||||||||||||
1982 | - | |||||||||||||||||||||||||||||||
1983 | The model provides the set of data that is used to create the items | - | ||||||||||||||||||||||||||||||
1984 | in the view. Models can be created directly in QML using \l ListModel, \l XmlListModel | - | ||||||||||||||||||||||||||||||
1985 | or \l VisualItemModel, or provided by C++ model classes. If a C++ model class is | - | ||||||||||||||||||||||||||||||
1986 | used, it must be a subclass of \l QAbstractItemModel or a simple list. | - | ||||||||||||||||||||||||||||||
1987 | - | |||||||||||||||||||||||||||||||
1988 | \sa {qml-data-models}{Data Models} | - | ||||||||||||||||||||||||||||||
1989 | */ | - | ||||||||||||||||||||||||||||||
1990 | - | |||||||||||||||||||||||||||||||
1991 | /*! | - | ||||||||||||||||||||||||||||||
1992 | \qmlproperty Component QtQuick::ListView::delegate | - | ||||||||||||||||||||||||||||||
1993 | - | |||||||||||||||||||||||||||||||
1994 | The delegate provides a template defining each item instantiated by the view. | - | ||||||||||||||||||||||||||||||
1995 | The index is exposed as an accessible \c index property. Properties of the | - | ||||||||||||||||||||||||||||||
1996 | model are also available depending upon the type of \l {qml-data-models}{Data Model}. | - | ||||||||||||||||||||||||||||||
1997 | - | |||||||||||||||||||||||||||||||
1998 | The number of objects and bindings in the delegate has a direct effect on the | - | ||||||||||||||||||||||||||||||
1999 | flicking performance of the view. If at all possible, place functionality | - | ||||||||||||||||||||||||||||||
2000 | that is not needed for the normal display of the delegate in a \l Loader which | - | ||||||||||||||||||||||||||||||
2001 | can load additional components when needed. | - | ||||||||||||||||||||||||||||||
2002 | - | |||||||||||||||||||||||||||||||
2003 | The ListView will lay out the items based on the size of the root item | - | ||||||||||||||||||||||||||||||
2004 | in the delegate. | - | ||||||||||||||||||||||||||||||
2005 | - | |||||||||||||||||||||||||||||||
2006 | It is recommended that the delegate's size be a whole number to avoid sub-pixel | - | ||||||||||||||||||||||||||||||
2007 | alignment of items. | - | ||||||||||||||||||||||||||||||
2008 | - | |||||||||||||||||||||||||||||||
2009 | The default \l {QQuickItem::z}{stacking order} of delegate instances is \c 1. | - | ||||||||||||||||||||||||||||||
2010 | - | |||||||||||||||||||||||||||||||
2011 | \note Delegates are instantiated as needed and may be destroyed at any time. | - | ||||||||||||||||||||||||||||||
2012 | They are parented to ListView's \l {Flickable::contentItem}{contentItem}, not to the view itself. | - | ||||||||||||||||||||||||||||||
2013 | State should \e never be stored in a delegate. | - | ||||||||||||||||||||||||||||||
2014 | - | |||||||||||||||||||||||||||||||
2015 | \sa {Stacking Order in ListView} | - | ||||||||||||||||||||||||||||||
2016 | */ | - | ||||||||||||||||||||||||||||||
2017 | /*! | - | ||||||||||||||||||||||||||||||
2018 | \qmlproperty int QtQuick::ListView::currentIndex | - | ||||||||||||||||||||||||||||||
2019 | \qmlproperty Item QtQuick::ListView::currentItem | - | ||||||||||||||||||||||||||||||
2020 | - | |||||||||||||||||||||||||||||||
2021 | The \c currentIndex property holds the index of the current item, and | - | ||||||||||||||||||||||||||||||
2022 | \c currentItem holds the current item. Setting the currentIndex to -1 | - | ||||||||||||||||||||||||||||||
2023 | will clear the highlight and set currentItem to null. | - | ||||||||||||||||||||||||||||||
2024 | - | |||||||||||||||||||||||||||||||
2025 | If highlightFollowsCurrentItem is \c true, setting either of these | - | ||||||||||||||||||||||||||||||
2026 | properties will smoothly scroll the ListView so that the current | - | ||||||||||||||||||||||||||||||
2027 | item becomes visible. | - | ||||||||||||||||||||||||||||||
2028 | - | |||||||||||||||||||||||||||||||
2029 | Note that the position of the current item | - | ||||||||||||||||||||||||||||||
2030 | may only be approximate until it becomes visible in the view. | - | ||||||||||||||||||||||||||||||
2031 | */ | - | ||||||||||||||||||||||||||||||
2032 | - | |||||||||||||||||||||||||||||||
2033 | /*! | - | ||||||||||||||||||||||||||||||
2034 | \qmlproperty Item QtQuick::ListView::highlightItem | - | ||||||||||||||||||||||||||||||
2035 | - | |||||||||||||||||||||||||||||||
2036 | This holds the highlight item created from the \l highlight component. | - | ||||||||||||||||||||||||||||||
2037 | - | |||||||||||||||||||||||||||||||
2038 | The \c highlightItem is managed by the view unless | - | ||||||||||||||||||||||||||||||
2039 | \l highlightFollowsCurrentItem is set to false. | - | ||||||||||||||||||||||||||||||
2040 | The default \l {QQuickItem::z}{stacking order} | - | ||||||||||||||||||||||||||||||
2041 | of the highlight item is \c 0. | - | ||||||||||||||||||||||||||||||
2042 | - | |||||||||||||||||||||||||||||||
2043 | \sa highlight, highlightFollowsCurrentItem, {Stacking Order in ListView} | - | ||||||||||||||||||||||||||||||
2044 | */ | - | ||||||||||||||||||||||||||||||
2045 | - | |||||||||||||||||||||||||||||||
2046 | /*! | - | ||||||||||||||||||||||||||||||
2047 | \qmlproperty int QtQuick::ListView::count | - | ||||||||||||||||||||||||||||||
2048 | This property holds the number of items in the view. | - | ||||||||||||||||||||||||||||||
2049 | */ | - | ||||||||||||||||||||||||||||||
2050 | - | |||||||||||||||||||||||||||||||
2051 | /*! | - | ||||||||||||||||||||||||||||||
2052 | \qmlproperty Component QtQuick::ListView::highlight | - | ||||||||||||||||||||||||||||||
2053 | This property holds the component to use as the highlight. | - | ||||||||||||||||||||||||||||||
2054 | - | |||||||||||||||||||||||||||||||
2055 | An instance of the highlight component is created for each list. | - | ||||||||||||||||||||||||||||||
2056 | The geometry of the resulting component instance is managed by the list | - | ||||||||||||||||||||||||||||||
2057 | so as to stay with the current item, unless the highlightFollowsCurrentItem | - | ||||||||||||||||||||||||||||||
2058 | property is false. The default \l {QQuickItem::z}{stacking order} of the | - | ||||||||||||||||||||||||||||||
2059 | highlight item is \c 0. | - | ||||||||||||||||||||||||||||||
2060 | - | |||||||||||||||||||||||||||||||
2061 | \sa highlightItem, highlightFollowsCurrentItem, | - | ||||||||||||||||||||||||||||||
2062 | {Qt Quick Examples - Views#Highlight}{ListView highlight example}, | - | ||||||||||||||||||||||||||||||
2063 | {Stacking Order in ListView} | - | ||||||||||||||||||||||||||||||
2064 | */ | - | ||||||||||||||||||||||||||||||
2065 | - | |||||||||||||||||||||||||||||||
2066 | /*! | - | ||||||||||||||||||||||||||||||
2067 | \qmlproperty bool QtQuick::ListView::highlightFollowsCurrentItem | - | ||||||||||||||||||||||||||||||
2068 | This property holds whether the highlight is managed by the view. | - | ||||||||||||||||||||||||||||||
2069 | - | |||||||||||||||||||||||||||||||
2070 | If this property is true (the default value), the highlight is moved smoothly | - | ||||||||||||||||||||||||||||||
2071 | to follow the current item. Otherwise, the | - | ||||||||||||||||||||||||||||||
2072 | highlight is not moved by the view, and any movement must be implemented | - | ||||||||||||||||||||||||||||||
2073 | by the highlight. | - | ||||||||||||||||||||||||||||||
2074 | - | |||||||||||||||||||||||||||||||
2075 | Here is a highlight with its motion defined by a \l {SpringAnimation} item: | - | ||||||||||||||||||||||||||||||
2076 | - | |||||||||||||||||||||||||||||||
2077 | \snippet qml/listview/listview.qml highlightFollowsCurrentItem | - | ||||||||||||||||||||||||||||||
2078 | - | |||||||||||||||||||||||||||||||
2079 | Note that the highlight animation also affects the way that the view | - | ||||||||||||||||||||||||||||||
2080 | is scrolled. This is because the view moves to maintain the | - | ||||||||||||||||||||||||||||||
2081 | highlight within the preferred highlight range (or visible viewport). | - | ||||||||||||||||||||||||||||||
2082 | - | |||||||||||||||||||||||||||||||
2083 | \sa highlight, highlightMoveVelocity | - | ||||||||||||||||||||||||||||||
2084 | */ | - | ||||||||||||||||||||||||||||||
2085 | //###Possibly rename these properties, since they are very useful even without a highlight? | - | ||||||||||||||||||||||||||||||
2086 | /*! | - | ||||||||||||||||||||||||||||||
2087 | \qmlproperty real QtQuick::ListView::preferredHighlightBegin | - | ||||||||||||||||||||||||||||||
2088 | \qmlproperty real QtQuick::ListView::preferredHighlightEnd | - | ||||||||||||||||||||||||||||||
2089 | \qmlproperty enumeration QtQuick::ListView::highlightRangeMode | - | ||||||||||||||||||||||||||||||
2090 | - | |||||||||||||||||||||||||||||||
2091 | These properties define the preferred range of the highlight (for the current item) | - | ||||||||||||||||||||||||||||||
2092 | within the view. The \c preferredHighlightBegin value must be less than the | - | ||||||||||||||||||||||||||||||
2093 | \c preferredHighlightEnd value. | - | ||||||||||||||||||||||||||||||
2094 | - | |||||||||||||||||||||||||||||||
2095 | These properties affect the position of the current item when the list is scrolled. | - | ||||||||||||||||||||||||||||||
2096 | For example, if the currently selected item should stay in the middle of the | - | ||||||||||||||||||||||||||||||
2097 | list when the view is scrolled, set the \c preferredHighlightBegin and | - | ||||||||||||||||||||||||||||||
2098 | \c preferredHighlightEnd values to the top and bottom coordinates of where the middle | - | ||||||||||||||||||||||||||||||
2099 | item would be. If the \c currentItem is changed programmatically, the list will | - | ||||||||||||||||||||||||||||||
2100 | automatically scroll so that the current item is in the middle of the view. | - | ||||||||||||||||||||||||||||||
2101 | Furthermore, the behavior of the current item index will occur whether or not a | - | ||||||||||||||||||||||||||||||
2102 | highlight exists. | - | ||||||||||||||||||||||||||||||
2103 | - | |||||||||||||||||||||||||||||||
2104 | Valid values for \c highlightRangeMode are: | - | ||||||||||||||||||||||||||||||
2105 | - | |||||||||||||||||||||||||||||||
2106 | \list | - | ||||||||||||||||||||||||||||||
2107 | \li ListView.ApplyRange - the view attempts to maintain the highlight within the range. | - | ||||||||||||||||||||||||||||||
2108 | However, the highlight can move outside of the range at the ends of the list or due | - | ||||||||||||||||||||||||||||||
2109 | to mouse interaction. | - | ||||||||||||||||||||||||||||||
2110 | \li ListView.StrictlyEnforceRange - the highlight never moves outside of the range. | - | ||||||||||||||||||||||||||||||
2111 | The current item changes if a keyboard or mouse action would cause the highlight to move | - | ||||||||||||||||||||||||||||||
2112 | outside of the range. | - | ||||||||||||||||||||||||||||||
2113 | \li ListView.NoHighlightRange - this is the default value. | - | ||||||||||||||||||||||||||||||
2114 | \endlist | - | ||||||||||||||||||||||||||||||
2115 | */ | - | ||||||||||||||||||||||||||||||
2116 | void QQuickListView::setHighlightFollowsCurrentItem(bool autoHighlight) | - | ||||||||||||||||||||||||||||||
2117 | { | - | ||||||||||||||||||||||||||||||
2118 | Q_D(QQuickListView); | - | ||||||||||||||||||||||||||||||
2119 | if (d->autoHighlight != autoHighlight) {
| 10-12 | ||||||||||||||||||||||||||||||
2120 | if (!autoHighlight) {
| 0-12 | ||||||||||||||||||||||||||||||
2121 | if (d->highlightPosAnimator)
| 4-8 | ||||||||||||||||||||||||||||||
2122 | d->highlightPosAnimator->stop(); executed 4 times by 1 test: d->highlightPosAnimator->stop(); Executed by:
| 4 | ||||||||||||||||||||||||||||||
2123 | if (d->highlightWidthAnimator)
| 4-8 | ||||||||||||||||||||||||||||||
2124 | d->highlightWidthAnimator->stop(); executed 4 times by 1 test: d->highlightWidthAnimator->stop(); Executed by:
| 4 | ||||||||||||||||||||||||||||||
2125 | if (d->highlightHeightAnimator)
| 4-8 | ||||||||||||||||||||||||||||||
2126 | d->highlightHeightAnimator->stop(); executed 4 times by 1 test: d->highlightHeightAnimator->stop(); Executed by:
| 4 | ||||||||||||||||||||||||||||||
2127 | } executed 12 times by 2 tests: end of block Executed by:
| 12 | ||||||||||||||||||||||||||||||
2128 | QQuickItemView::setHighlightFollowsCurrentItem(autoHighlight); | - | ||||||||||||||||||||||||||||||
2129 | } executed 12 times by 2 tests: end of block Executed by:
| 12 | ||||||||||||||||||||||||||||||
2130 | } executed 22 times by 2 tests: end of block Executed by:
| 22 | ||||||||||||||||||||||||||||||
2131 | - | |||||||||||||||||||||||||||||||
2132 | /*! | - | ||||||||||||||||||||||||||||||
2133 | \qmlproperty real QtQuick::ListView::spacing | - | ||||||||||||||||||||||||||||||
2134 | - | |||||||||||||||||||||||||||||||
2135 | This property holds the spacing between items. | - | ||||||||||||||||||||||||||||||
2136 | - | |||||||||||||||||||||||||||||||
2137 | The default value is 0. | - | ||||||||||||||||||||||||||||||
2138 | */ | - | ||||||||||||||||||||||||||||||
2139 | qreal QQuickListView::spacing() const | - | ||||||||||||||||||||||||||||||
2140 | { | - | ||||||||||||||||||||||||||||||
2141 | Q_D(const QQuickListView); | - | ||||||||||||||||||||||||||||||
2142 | return d->spacing; executed 8 times by 1 test: return d->spacing; Executed by:
| 8 | ||||||||||||||||||||||||||||||
2143 | } | - | ||||||||||||||||||||||||||||||
2144 | - | |||||||||||||||||||||||||||||||
2145 | void QQuickListView::setSpacing(qreal spacing) | - | ||||||||||||||||||||||||||||||
2146 | { | - | ||||||||||||||||||||||||||||||
2147 | Q_D(QQuickListView); | - | ||||||||||||||||||||||||||||||
2148 | if (spacing != d->spacing) {
| 0-22 | ||||||||||||||||||||||||||||||
2149 | d->spacing = spacing; | - | ||||||||||||||||||||||||||||||
2150 | d->forceLayoutPolish(); | - | ||||||||||||||||||||||||||||||
2151 | emit spacingChanged(); | - | ||||||||||||||||||||||||||||||
2152 | } executed 22 times by 2 tests: end of block Executed by:
| 22 | ||||||||||||||||||||||||||||||
2153 | } executed 22 times by 2 tests: end of block Executed by:
| 22 | ||||||||||||||||||||||||||||||
2154 | - | |||||||||||||||||||||||||||||||
2155 | /*! | - | ||||||||||||||||||||||||||||||
2156 | \qmlproperty enumeration QtQuick::ListView::orientation | - | ||||||||||||||||||||||||||||||
2157 | This property holds the orientation of the list. | - | ||||||||||||||||||||||||||||||
2158 | - | |||||||||||||||||||||||||||||||
2159 | Possible values: | - | ||||||||||||||||||||||||||||||
2160 | - | |||||||||||||||||||||||||||||||
2161 | \list | - | ||||||||||||||||||||||||||||||
2162 | \li ListView.Horizontal - Items are laid out horizontally | - | ||||||||||||||||||||||||||||||
2163 | \li ListView.Vertical (default) - Items are laid out vertically | - | ||||||||||||||||||||||||||||||
2164 | \endlist | - | ||||||||||||||||||||||||||||||
2165 | - | |||||||||||||||||||||||||||||||
2166 | \table | - | ||||||||||||||||||||||||||||||
2167 | \row | - | ||||||||||||||||||||||||||||||
2168 | \li Horizontal orientation: | - | ||||||||||||||||||||||||||||||
2169 | \image ListViewHorizontal.png | - | ||||||||||||||||||||||||||||||
2170 | - | |||||||||||||||||||||||||||||||
2171 | \row | - | ||||||||||||||||||||||||||||||
2172 | \li Vertical orientation: | - | ||||||||||||||||||||||||||||||
2173 | \image listview-highlight.png | - | ||||||||||||||||||||||||||||||
2174 | \endtable | - | ||||||||||||||||||||||||||||||
2175 | - | |||||||||||||||||||||||||||||||
2176 | \sa {Flickable Direction} | - | ||||||||||||||||||||||||||||||
2177 | */ | - | ||||||||||||||||||||||||||||||
2178 | QQuickListView::Orientation QQuickListView::orientation() const | - | ||||||||||||||||||||||||||||||
2179 | { | - | ||||||||||||||||||||||||||||||
2180 | Q_D(const QQuickListView); | - | ||||||||||||||||||||||||||||||
2181 | return d->orient; executed 982477 times by 10 tests: return d->orient; Executed by:
| 982477 | ||||||||||||||||||||||||||||||
2182 | } | - | ||||||||||||||||||||||||||||||
2183 | - | |||||||||||||||||||||||||||||||
2184 | void QQuickListView::setOrientation(QQuickListView::Orientation orientation) | - | ||||||||||||||||||||||||||||||
2185 | { | - | ||||||||||||||||||||||||||||||
2186 | Q_D(QQuickListView); | - | ||||||||||||||||||||||||||||||
2187 | if (d->orient != orientation) {
| 136-194 | ||||||||||||||||||||||||||||||
2188 | d->orient = orientation; | - | ||||||||||||||||||||||||||||||
2189 | if (d->orient == Vertical) {
| 24-170 | ||||||||||||||||||||||||||||||
2190 | if (d->flickableDirection == HorizontalFlick) {
| 0-24 | ||||||||||||||||||||||||||||||
2191 | setFlickableDirection(VerticalFlick); | - | ||||||||||||||||||||||||||||||
2192 | if (isComponentComplete())
| 0-24 | ||||||||||||||||||||||||||||||
2193 | setContentWidth(-1); executed 24 times by 1 test: setContentWidth(-1); Executed by:
| 24 | ||||||||||||||||||||||||||||||
2194 | } executed 24 times by 1 test: end of block Executed by:
| 24 | ||||||||||||||||||||||||||||||
2195 | setContentX(0); | - | ||||||||||||||||||||||||||||||
2196 | } else { executed 24 times by 1 test: end of block Executed by:
| 24 | ||||||||||||||||||||||||||||||
2197 | if (d->flickableDirection == VerticalFlick) {
| 2-168 | ||||||||||||||||||||||||||||||
2198 | setFlickableDirection(HorizontalFlick); | - | ||||||||||||||||||||||||||||||
2199 | if (isComponentComplete())
| 20-148 | ||||||||||||||||||||||||||||||
2200 | setContentHeight(-1); executed 20 times by 1 test: setContentHeight(-1); Executed by:
| 20 | ||||||||||||||||||||||||||||||
2201 | } executed 168 times by 2 tests: end of block Executed by:
| 168 | ||||||||||||||||||||||||||||||
2202 | setContentY(0); | - | ||||||||||||||||||||||||||||||
2203 | } executed 170 times by 2 tests: end of block Executed by:
| 170 | ||||||||||||||||||||||||||||||
2204 | d->regenerate(true); | - | ||||||||||||||||||||||||||||||
2205 | emit orientationChanged(); | - | ||||||||||||||||||||||||||||||
2206 | } executed 194 times by 2 tests: end of block Executed by:
| 194 | ||||||||||||||||||||||||||||||
2207 | } executed 330 times by 2 tests: end of block Executed by:
| 330 | ||||||||||||||||||||||||||||||
2208 | - | |||||||||||||||||||||||||||||||
2209 | /*! | - | ||||||||||||||||||||||||||||||
2210 | \qmlproperty enumeration QtQuick::ListView::layoutDirection | - | ||||||||||||||||||||||||||||||
2211 | This property holds the layout direction of a horizontally-oriented list. | - | ||||||||||||||||||||||||||||||
2212 | - | |||||||||||||||||||||||||||||||
2213 | Possible values: | - | ||||||||||||||||||||||||||||||
2214 | - | |||||||||||||||||||||||||||||||
2215 | \list | - | ||||||||||||||||||||||||||||||
2216 | \li Qt.LeftToRight (default) - Items will be laid out from left to right. | - | ||||||||||||||||||||||||||||||
2217 | \li Qt.RightToLeft - Items will be laid out from right to let. | - | ||||||||||||||||||||||||||||||
2218 | \endlist | - | ||||||||||||||||||||||||||||||
2219 | - | |||||||||||||||||||||||||||||||
2220 | Setting this property has no effect if the \l orientation is Qt.Vertical. | - | ||||||||||||||||||||||||||||||
2221 | - | |||||||||||||||||||||||||||||||
2222 | \sa ListView::effectiveLayoutDirection, ListView::verticalLayoutDirection | - | ||||||||||||||||||||||||||||||
2223 | */ | - | ||||||||||||||||||||||||||||||
2224 | - | |||||||||||||||||||||||||||||||
2225 | - | |||||||||||||||||||||||||||||||
2226 | /*! | - | ||||||||||||||||||||||||||||||
2227 | \qmlproperty enumeration QtQuick::ListView::effectiveLayoutDirection | - | ||||||||||||||||||||||||||||||
2228 | This property holds the effective layout direction of a horizontally-oriented list. | - | ||||||||||||||||||||||||||||||
2229 | - | |||||||||||||||||||||||||||||||
2230 | When using the attached property \l {LayoutMirroring::enabled}{LayoutMirroring::enabled} for locale layouts, | - | ||||||||||||||||||||||||||||||
2231 | the visual layout direction of the horizontal list will be mirrored. However, the | - | ||||||||||||||||||||||||||||||
2232 | property \l {ListView::layoutDirection}{layoutDirection} will remain unchanged. | - | ||||||||||||||||||||||||||||||
2233 | - | |||||||||||||||||||||||||||||||
2234 | \sa ListView::layoutDirection, {LayoutMirroring}{LayoutMirroring} | - | ||||||||||||||||||||||||||||||
2235 | */ | - | ||||||||||||||||||||||||||||||
2236 | - | |||||||||||||||||||||||||||||||
2237 | - | |||||||||||||||||||||||||||||||
2238 | /*! | - | ||||||||||||||||||||||||||||||
2239 | \qmlproperty enumeration QtQuick::ListView::verticalLayoutDirection | - | ||||||||||||||||||||||||||||||
2240 | This property holds the layout direction of a vertically-oriented list. | - | ||||||||||||||||||||||||||||||
2241 | - | |||||||||||||||||||||||||||||||
2242 | Possible values: | - | ||||||||||||||||||||||||||||||
2243 | - | |||||||||||||||||||||||||||||||
2244 | \list | - | ||||||||||||||||||||||||||||||
2245 | \li ListView.TopToBottom (default) - Items are laid out from the top of the view down to the bottom of the view. | - | ||||||||||||||||||||||||||||||
2246 | \li ListView.BottomToTop - Items are laid out from the bottom of the view up to the top of the view. | - | ||||||||||||||||||||||||||||||
2247 | \endlist | - | ||||||||||||||||||||||||||||||
2248 | - | |||||||||||||||||||||||||||||||
2249 | Setting this property has no effect if the \l orientation is Qt.Horizontal. | - | ||||||||||||||||||||||||||||||
2250 | - | |||||||||||||||||||||||||||||||
2251 | \sa ListView::layoutDirection | - | ||||||||||||||||||||||||||||||
2252 | */ | - | ||||||||||||||||||||||||||||||
2253 | - | |||||||||||||||||||||||||||||||
2254 | - | |||||||||||||||||||||||||||||||
2255 | /*! | - | ||||||||||||||||||||||||||||||
2256 | \qmlproperty bool QtQuick::ListView::keyNavigationWraps | - | ||||||||||||||||||||||||||||||
2257 | This property holds whether the list wraps key navigation. | - | ||||||||||||||||||||||||||||||
2258 | - | |||||||||||||||||||||||||||||||
2259 | If this is true, key navigation that would move the current item selection | - | ||||||||||||||||||||||||||||||
2260 | past the end of the list instead wraps around and moves the selection to | - | ||||||||||||||||||||||||||||||
2261 | the start of the list, and vice-versa. | - | ||||||||||||||||||||||||||||||
2262 | - | |||||||||||||||||||||||||||||||
2263 | By default, key navigation is not wrapped. | - | ||||||||||||||||||||||||||||||
2264 | */ | - | ||||||||||||||||||||||||||||||
2265 | - | |||||||||||||||||||||||||||||||
2266 | /*! | - | ||||||||||||||||||||||||||||||
2267 | \qmlproperty bool QtQuick::ListView::keyNavigationEnabled | - | ||||||||||||||||||||||||||||||
2268 | \since 5.7 | - | ||||||||||||||||||||||||||||||
2269 | - | |||||||||||||||||||||||||||||||
2270 | This property holds whether the key navigation of the list is enabled. | - | ||||||||||||||||||||||||||||||
2271 | - | |||||||||||||||||||||||||||||||
2272 | If this is \c true, the user can navigate the view with a keyboard. | - | ||||||||||||||||||||||||||||||
2273 | It is useful for applications that need to selectively enable or | - | ||||||||||||||||||||||||||||||
2274 | disable mouse and keyboard interaction. | - | ||||||||||||||||||||||||||||||
2275 | - | |||||||||||||||||||||||||||||||
2276 | By default, the value of this property is bound to | - | ||||||||||||||||||||||||||||||
2277 | \l {Flickable::}{interactive} to ensure behavior compatibility for | - | ||||||||||||||||||||||||||||||
2278 | existing applications. When explicitly set, it will cease to be bound to | - | ||||||||||||||||||||||||||||||
2279 | the interactive property. | - | ||||||||||||||||||||||||||||||
2280 | - | |||||||||||||||||||||||||||||||
2281 | \sa {Flickable::}{interactive} | - | ||||||||||||||||||||||||||||||
2282 | */ | - | ||||||||||||||||||||||||||||||
2283 | - | |||||||||||||||||||||||||||||||
2284 | - | |||||||||||||||||||||||||||||||
2285 | /*! | - | ||||||||||||||||||||||||||||||
2286 | \qmlproperty int QtQuick::ListView::cacheBuffer | - | ||||||||||||||||||||||||||||||
2287 | This property determines whether delegates are retained outside the | - | ||||||||||||||||||||||||||||||
2288 | visible area of the view. | - | ||||||||||||||||||||||||||||||
2289 | - | |||||||||||||||||||||||||||||||
2290 | If this value is greater than zero, the view may keep as many delegates | - | ||||||||||||||||||||||||||||||
2291 | instantiated as it can fit within the buffer specified. For example, | - | ||||||||||||||||||||||||||||||
2292 | if in a vertical view the delegate is 20 pixels high and \c cacheBuffer is | - | ||||||||||||||||||||||||||||||
2293 | set to 40, then up to 2 delegates above and 2 delegates below the visible | - | ||||||||||||||||||||||||||||||
2294 | area may be created/retained. The buffered delegates are created asynchronously, | - | ||||||||||||||||||||||||||||||
2295 | allowing creation to occur across multiple frames and reducing the | - | ||||||||||||||||||||||||||||||
2296 | likelihood of skipping frames. In order to improve painting performance | - | ||||||||||||||||||||||||||||||
2297 | delegates outside the visible area are not painted. | - | ||||||||||||||||||||||||||||||
2298 | - | |||||||||||||||||||||||||||||||
2299 | The default value of this property is platform dependent, but will usually | - | ||||||||||||||||||||||||||||||
2300 | be a value greater than zero. Negative values are ignored. | - | ||||||||||||||||||||||||||||||
2301 | - | |||||||||||||||||||||||||||||||
2302 | Note that cacheBuffer is not a pixel buffer - it only maintains additional | - | ||||||||||||||||||||||||||||||
2303 | instantiated delegates. | - | ||||||||||||||||||||||||||||||
2304 | - | |||||||||||||||||||||||||||||||
2305 | \note Setting this property is not a replacement for creating efficient delegates. | - | ||||||||||||||||||||||||||||||
2306 | It can improve the smoothness of scrolling behavior at the expense of additional | - | ||||||||||||||||||||||||||||||
2307 | memory usage. The fewer objects and bindings in a delegate, the faster a | - | ||||||||||||||||||||||||||||||
2308 | view can be scrolled. It is important to realize that setting a cacheBuffer | - | ||||||||||||||||||||||||||||||
2309 | will only postpone issues caused by slow-loading delegates, it is not a | - | ||||||||||||||||||||||||||||||
2310 | solution for this scenario. | - | ||||||||||||||||||||||||||||||
2311 | - | |||||||||||||||||||||||||||||||
2312 | The cacheBuffer operates outside of any display margins specified by | - | ||||||||||||||||||||||||||||||
2313 | displayMarginBeginning or displayMarginEnd. | - | ||||||||||||||||||||||||||||||
2314 | */ | - | ||||||||||||||||||||||||||||||
2315 | - | |||||||||||||||||||||||||||||||
2316 | /*! | - | ||||||||||||||||||||||||||||||
2317 | \qmlproperty int QtQuick::ListView::displayMarginBeginning | - | ||||||||||||||||||||||||||||||
2318 | \qmlproperty int QtQuick::ListView::displayMarginEnd | - | ||||||||||||||||||||||||||||||
2319 | \since QtQuick 2.3 | - | ||||||||||||||||||||||||||||||
2320 | - | |||||||||||||||||||||||||||||||
2321 | This property allows delegates to be displayed outside of the view geometry. | - | ||||||||||||||||||||||||||||||
2322 | - | |||||||||||||||||||||||||||||||
2323 | If this value is non-zero, the view will create extra delegates before the | - | ||||||||||||||||||||||||||||||
2324 | start of the view, or after the end. The view will create as many delegates | - | ||||||||||||||||||||||||||||||
2325 | as it can fit into the pixel size specified. | - | ||||||||||||||||||||||||||||||
2326 | - | |||||||||||||||||||||||||||||||
2327 | For example, if in a vertical view the delegate is 20 pixels high and | - | ||||||||||||||||||||||||||||||
2328 | \c displayMarginBeginning and \c displayMarginEnd are both set to 40, | - | ||||||||||||||||||||||||||||||
2329 | then 2 delegates above and 2 delegates below will be created and shown. | - | ||||||||||||||||||||||||||||||
2330 | - | |||||||||||||||||||||||||||||||
2331 | The default value is 0. | - | ||||||||||||||||||||||||||||||
2332 | - | |||||||||||||||||||||||||||||||
2333 | This property is meant for allowing certain UI configurations, | - | ||||||||||||||||||||||||||||||
2334 | and not as a performance optimization. If you wish to create delegates | - | ||||||||||||||||||||||||||||||
2335 | outside of the view geometry for performance reasons, you probably | - | ||||||||||||||||||||||||||||||
2336 | want to use the cacheBuffer property instead. | - | ||||||||||||||||||||||||||||||
2337 | */ | - | ||||||||||||||||||||||||||||||
2338 | - | |||||||||||||||||||||||||||||||
2339 | /*! | - | ||||||||||||||||||||||||||||||
2340 | \qmlpropertygroup QtQuick::ListView::section | - | ||||||||||||||||||||||||||||||
2341 | \qmlproperty string QtQuick::ListView::section.property | - | ||||||||||||||||||||||||||||||
2342 | \qmlproperty enumeration QtQuick::ListView::section.criteria | - | ||||||||||||||||||||||||||||||
2343 | \qmlproperty Component QtQuick::ListView::section.delegate | - | ||||||||||||||||||||||||||||||
2344 | \qmlproperty enumeration QtQuick::ListView::section.labelPositioning | - | ||||||||||||||||||||||||||||||
2345 | - | |||||||||||||||||||||||||||||||
2346 | These properties determine the expression to be evaluated and appearance | - | ||||||||||||||||||||||||||||||
2347 | of the section labels. | - | ||||||||||||||||||||||||||||||
2348 | - | |||||||||||||||||||||||||||||||
2349 | \c section.property holds the name of the property that is the basis | - | ||||||||||||||||||||||||||||||
2350 | of each section. | - | ||||||||||||||||||||||||||||||
2351 | - | |||||||||||||||||||||||||||||||
2352 | \c section.criteria holds the criteria for forming each section based on | - | ||||||||||||||||||||||||||||||
2353 | \c section.property. This value can be one of: | - | ||||||||||||||||||||||||||||||
2354 | - | |||||||||||||||||||||||||||||||
2355 | \list | - | ||||||||||||||||||||||||||||||
2356 | \li ViewSection.FullString (default) - sections are created based on the | - | ||||||||||||||||||||||||||||||
2357 | \c section.property value. | - | ||||||||||||||||||||||||||||||
2358 | \li ViewSection.FirstCharacter - sections are created based on the first | - | ||||||||||||||||||||||||||||||
2359 | character of the \c section.property value (for example, 'A', 'B', 'C' | - | ||||||||||||||||||||||||||||||
2360 | sections, etc. for an address book) | - | ||||||||||||||||||||||||||||||
2361 | \endlist | - | ||||||||||||||||||||||||||||||
2362 | - | |||||||||||||||||||||||||||||||
2363 | A case insensitive comparison is used when determining section | - | ||||||||||||||||||||||||||||||
2364 | boundaries. | - | ||||||||||||||||||||||||||||||
2365 | - | |||||||||||||||||||||||||||||||
2366 | \c section.delegate holds the delegate component for each section. The | - | ||||||||||||||||||||||||||||||
2367 | default \l {QQuickItem::z}{stacking order} of section delegate instances | - | ||||||||||||||||||||||||||||||
2368 | is \c 2. | - | ||||||||||||||||||||||||||||||
2369 | - | |||||||||||||||||||||||||||||||
2370 | \c section.labelPositioning determines whether the current and/or | - | ||||||||||||||||||||||||||||||
2371 | next section labels stick to the start/end of the view, and whether | - | ||||||||||||||||||||||||||||||
2372 | the labels are shown inline. This value can be a combination of: | - | ||||||||||||||||||||||||||||||
2373 | - | |||||||||||||||||||||||||||||||
2374 | \list | - | ||||||||||||||||||||||||||||||
2375 | \li ViewSection.InlineLabels - section labels are shown inline between | - | ||||||||||||||||||||||||||||||
2376 | the item delegates separating sections (default). | - | ||||||||||||||||||||||||||||||
2377 | \li ViewSection.CurrentLabelAtStart - the current section label sticks to the | - | ||||||||||||||||||||||||||||||
2378 | start of the view as it is moved. | - | ||||||||||||||||||||||||||||||
2379 | \li ViewSection.NextLabelAtEnd - the next section label (beyond all visible | - | ||||||||||||||||||||||||||||||
2380 | sections) sticks to the end of the view as it is moved. \note Enabling | - | ||||||||||||||||||||||||||||||
2381 | \c ViewSection.NextLabelAtEnd requires the view to scan ahead for the next | - | ||||||||||||||||||||||||||||||
2382 | section, which has performance implications, especially for slower models. | - | ||||||||||||||||||||||||||||||
2383 | \endlist | - | ||||||||||||||||||||||||||||||
2384 | - | |||||||||||||||||||||||||||||||
2385 | Each item in the list has attached properties named \c ListView.section, | - | ||||||||||||||||||||||||||||||
2386 | \c ListView.previousSection and \c ListView.nextSection. | - | ||||||||||||||||||||||||||||||
2387 | - | |||||||||||||||||||||||||||||||
2388 | For example, here is a ListView that displays a list of animals, separated | - | ||||||||||||||||||||||||||||||
2389 | into sections. Each item in the ListView is placed in a different section | - | ||||||||||||||||||||||||||||||
2390 | depending on the "size" property of the model item. The \c sectionHeading | - | ||||||||||||||||||||||||||||||
2391 | delegate component provides the light blue bar that marks the beginning of | - | ||||||||||||||||||||||||||||||
2392 | each section. | - | ||||||||||||||||||||||||||||||
2393 | - | |||||||||||||||||||||||||||||||
2394 | - | |||||||||||||||||||||||||||||||
2395 | \snippet views/listview/sections.qml 0 | - | ||||||||||||||||||||||||||||||
2396 | - | |||||||||||||||||||||||||||||||
2397 | \image qml-listview-sections-example.png | - | ||||||||||||||||||||||||||||||
2398 | - | |||||||||||||||||||||||||||||||
2399 | \note Adding sections to a ListView does not automatically re-order the | - | ||||||||||||||||||||||||||||||
2400 | list items by the section criteria. | - | ||||||||||||||||||||||||||||||
2401 | If the model is not ordered by section, then it is possible that | - | ||||||||||||||||||||||||||||||
2402 | the sections created will not be unique; each boundary between | - | ||||||||||||||||||||||||||||||
2403 | differing sections will result in a section header being created | - | ||||||||||||||||||||||||||||||
2404 | even if that section exists elsewhere. | - | ||||||||||||||||||||||||||||||
2405 | - | |||||||||||||||||||||||||||||||
2406 | \sa {Qt Quick Examples - Views}{ListView examples}, | - | ||||||||||||||||||||||||||||||
2407 | {Stacking Order in ListView} | - | ||||||||||||||||||||||||||||||
2408 | */ | - | ||||||||||||||||||||||||||||||
2409 | QQuickViewSection *QQuickListView::sectionCriteria() | - | ||||||||||||||||||||||||||||||
2410 | { | - | ||||||||||||||||||||||||||||||
2411 | Q_D(QQuickListView); | - | ||||||||||||||||||||||||||||||
2412 | if (!d->sectionCriteria)
| 6-46 | ||||||||||||||||||||||||||||||
2413 | d->sectionCriteria = new QQuickViewSection(this); executed 46 times by 4 tests: d->sectionCriteria = new QQuickViewSection(this); Executed by:
| 46 | ||||||||||||||||||||||||||||||
2414 | return d->sectionCriteria; executed 52 times by 4 tests: return d->sectionCriteria; Executed by:
| 52 | ||||||||||||||||||||||||||||||
2415 | } | - | ||||||||||||||||||||||||||||||
2416 | - | |||||||||||||||||||||||||||||||
2417 | /*! | - | ||||||||||||||||||||||||||||||
2418 | \qmlproperty string QtQuick::ListView::currentSection | - | ||||||||||||||||||||||||||||||
2419 | This property holds the section that is currently at the beginning of the view. | - | ||||||||||||||||||||||||||||||
2420 | */ | - | ||||||||||||||||||||||||||||||
2421 | QString QQuickListView::currentSection() const | - | ||||||||||||||||||||||||||||||
2422 | { | - | ||||||||||||||||||||||||||||||
2423 | Q_D(const QQuickListView); | - | ||||||||||||||||||||||||||||||
2424 | return d->currentSection; executed 56 times by 1 test: return d->currentSection; Executed by:
| 56 | ||||||||||||||||||||||||||||||
2425 | } | - | ||||||||||||||||||||||||||||||
2426 | - | |||||||||||||||||||||||||||||||
2427 | /*! | - | ||||||||||||||||||||||||||||||
2428 | \qmlproperty real QtQuick::ListView::highlightMoveVelocity | - | ||||||||||||||||||||||||||||||
2429 | \qmlproperty int QtQuick::ListView::highlightMoveDuration | - | ||||||||||||||||||||||||||||||
2430 | \qmlproperty real QtQuick::ListView::highlightResizeVelocity | - | ||||||||||||||||||||||||||||||
2431 | \qmlproperty int QtQuick::ListView::highlightResizeDuration | - | ||||||||||||||||||||||||||||||
2432 | - | |||||||||||||||||||||||||||||||
2433 | These properties control the speed of the move and resize animations for the | - | ||||||||||||||||||||||||||||||
2434 | highlight delegate. | - | ||||||||||||||||||||||||||||||
2435 | - | |||||||||||||||||||||||||||||||
2436 | \l highlightFollowsCurrentItem must be true for these properties | - | ||||||||||||||||||||||||||||||
2437 | to have effect. | - | ||||||||||||||||||||||||||||||
2438 | - | |||||||||||||||||||||||||||||||
2439 | The default value for the velocity properties is 400 pixels/second. | - | ||||||||||||||||||||||||||||||
2440 | The default value for the duration properties is -1, i.e. the | - | ||||||||||||||||||||||||||||||
2441 | highlight will take as much time as necessary to move at the set speed. | - | ||||||||||||||||||||||||||||||
2442 | - | |||||||||||||||||||||||||||||||
2443 | These properties have the same characteristics as a SmoothedAnimation. | - | ||||||||||||||||||||||||||||||
2444 | - | |||||||||||||||||||||||||||||||
2445 | \sa highlightFollowsCurrentItem | - | ||||||||||||||||||||||||||||||
2446 | */ | - | ||||||||||||||||||||||||||||||
2447 | qreal QQuickListView::highlightMoveVelocity() const | - | ||||||||||||||||||||||||||||||
2448 | { | - | ||||||||||||||||||||||||||||||
2449 | Q_D(const QQuickListView); | - | ||||||||||||||||||||||||||||||
2450 | return d->highlightMoveVelocity; executed 16 times by 1 test: return d->highlightMoveVelocity; Executed by:
| 16 | ||||||||||||||||||||||||||||||
2451 | } | - | ||||||||||||||||||||||||||||||
2452 | - | |||||||||||||||||||||||||||||||
2453 | void QQuickListView::setHighlightMoveVelocity(qreal speed) | - | ||||||||||||||||||||||||||||||
2454 | { | - | ||||||||||||||||||||||||||||||
2455 | Q_D(QQuickListView); | - | ||||||||||||||||||||||||||||||
2456 | if (d->highlightMoveVelocity != speed) {
| 6-582 | ||||||||||||||||||||||||||||||
2457 | d->highlightMoveVelocity = speed; | - | ||||||||||||||||||||||||||||||
2458 | if (d->highlightPosAnimator)
| 0-582 | ||||||||||||||||||||||||||||||
2459 | d->highlightPosAnimator->velocity = d->highlightMoveVelocity; never executed: d->highlightPosAnimator->velocity = d->highlightMoveVelocity; | 0 | ||||||||||||||||||||||||||||||
2460 | emit highlightMoveVelocityChanged(); | - | ||||||||||||||||||||||||||||||
2461 | } executed 582 times by 1 test: end of block Executed by:
| 582 | ||||||||||||||||||||||||||||||
2462 | } executed 588 times by 1 test: end of block Executed by:
| 588 | ||||||||||||||||||||||||||||||
2463 | - | |||||||||||||||||||||||||||||||
2464 | void QQuickListView::setHighlightMoveDuration(int duration) | - | ||||||||||||||||||||||||||||||
2465 | { | - | ||||||||||||||||||||||||||||||
2466 | Q_D(QQuickListView); | - | ||||||||||||||||||||||||||||||
2467 | if (d->highlightMoveDuration != duration) {
| 2-6 | ||||||||||||||||||||||||||||||
2468 | if (d->highlightPosAnimator)
| 0-2 | ||||||||||||||||||||||||||||||
2469 | d->highlightPosAnimator->userDuration = duration; executed 2 times by 1 test: d->highlightPosAnimator->userDuration = duration; Executed by:
| 2 | ||||||||||||||||||||||||||||||
2470 | QQuickItemView::setHighlightMoveDuration(duration); | - | ||||||||||||||||||||||||||||||
2471 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||||||||
2472 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||||||||
2473 | - | |||||||||||||||||||||||||||||||
2474 | qreal QQuickListView::highlightResizeVelocity() const | - | ||||||||||||||||||||||||||||||
2475 | { | - | ||||||||||||||||||||||||||||||
2476 | Q_D(const QQuickListView); | - | ||||||||||||||||||||||||||||||
2477 | return d->highlightResizeVelocity; executed 16 times by 1 test: return d->highlightResizeVelocity; Executed by:
| 16 | ||||||||||||||||||||||||||||||
2478 | } | - | ||||||||||||||||||||||||||||||
2479 | - | |||||||||||||||||||||||||||||||
2480 | void QQuickListView::setHighlightResizeVelocity(qreal speed) | - | ||||||||||||||||||||||||||||||
2481 | { | - | ||||||||||||||||||||||||||||||
2482 | Q_D(QQuickListView); | - | ||||||||||||||||||||||||||||||
2483 | if (d->highlightResizeVelocity != speed) {
| 0-566 | ||||||||||||||||||||||||||||||
2484 | d->highlightResizeVelocity = speed; | - | ||||||||||||||||||||||||||||||
2485 | if (d->highlightWidthAnimator)
| 0-566 | ||||||||||||||||||||||||||||||
2486 | d->highlightWidthAnimator->velocity = d->highlightResizeVelocity; never executed: d->highlightWidthAnimator->velocity = d->highlightResizeVelocity; | 0 | ||||||||||||||||||||||||||||||
2487 | if (d->highlightHeightAnimator)
| 0-566 | ||||||||||||||||||||||||||||||
2488 | d->highlightHeightAnimator->velocity = d->highlightResizeVelocity; never executed: d->highlightHeightAnimator->velocity = d->highlightResizeVelocity; | 0 | ||||||||||||||||||||||||||||||
2489 | emit highlightResizeVelocityChanged(); | - | ||||||||||||||||||||||||||||||
2490 | } executed 566 times by 1 test: end of block Executed by:
| 566 | ||||||||||||||||||||||||||||||
2491 | } executed 566 times by 1 test: end of block Executed by:
| 566 | ||||||||||||||||||||||||||||||
2492 | - | |||||||||||||||||||||||||||||||
2493 | int QQuickListView::highlightResizeDuration() const | - | ||||||||||||||||||||||||||||||
2494 | { | - | ||||||||||||||||||||||||||||||
2495 | Q_D(const QQuickListView); | - | ||||||||||||||||||||||||||||||
2496 | return d->highlightResizeDuration; never executed: return d->highlightResizeDuration; | 0 | ||||||||||||||||||||||||||||||
2497 | } | - | ||||||||||||||||||||||||||||||
2498 | - | |||||||||||||||||||||||||||||||
2499 | void QQuickListView::setHighlightResizeDuration(int duration) | - | ||||||||||||||||||||||||||||||
2500 | { | - | ||||||||||||||||||||||||||||||
2501 | Q_D(QQuickListView); | - | ||||||||||||||||||||||||||||||
2502 | if (d->highlightResizeDuration != duration) {
| 0 | ||||||||||||||||||||||||||||||
2503 | d->highlightResizeDuration = duration; | - | ||||||||||||||||||||||||||||||
2504 | if (d->highlightWidthAnimator)
| 0 | ||||||||||||||||||||||||||||||
2505 | d->highlightWidthAnimator->userDuration = d->highlightResizeDuration; never executed: d->highlightWidthAnimator->userDuration = d->highlightResizeDuration; | 0 | ||||||||||||||||||||||||||||||
2506 | if (d->highlightHeightAnimator)
| 0 | ||||||||||||||||||||||||||||||
2507 | d->highlightHeightAnimator->userDuration = d->highlightResizeDuration; never executed: d->highlightHeightAnimator->userDuration = d->highlightResizeDuration; | 0 | ||||||||||||||||||||||||||||||
2508 | emit highlightResizeDurationChanged(); | - | ||||||||||||||||||||||||||||||
2509 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
2510 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
2511 | - | |||||||||||||||||||||||||||||||
2512 | /*! | - | ||||||||||||||||||||||||||||||
2513 | \qmlproperty enumeration QtQuick::ListView::snapMode | - | ||||||||||||||||||||||||||||||
2514 | - | |||||||||||||||||||||||||||||||
2515 | This property determines how the view scrolling will settle following a drag or flick. | - | ||||||||||||||||||||||||||||||
2516 | The possible values are: | - | ||||||||||||||||||||||||||||||
2517 | - | |||||||||||||||||||||||||||||||
2518 | \list | - | ||||||||||||||||||||||||||||||
2519 | \li ListView.NoSnap (default) - the view stops anywhere within the visible area. | - | ||||||||||||||||||||||||||||||
2520 | \li ListView.SnapToItem - the view settles with an item aligned with the start of | - | ||||||||||||||||||||||||||||||
2521 | the view. | - | ||||||||||||||||||||||||||||||
2522 | \li ListView.SnapOneItem - the view settles no more than one item away from the first | - | ||||||||||||||||||||||||||||||
2523 | visible item at the time the mouse button is released. This mode is particularly | - | ||||||||||||||||||||||||||||||
2524 | useful for moving one page at a time. | - | ||||||||||||||||||||||||||||||
2525 | \endlist | - | ||||||||||||||||||||||||||||||
2526 | - | |||||||||||||||||||||||||||||||
2527 | \c snapMode does not affect the \l currentIndex. To update the | - | ||||||||||||||||||||||||||||||
2528 | \l currentIndex as the list is moved, set \l highlightRangeMode | - | ||||||||||||||||||||||||||||||
2529 | to \c ListView.StrictlyEnforceRange. | - | ||||||||||||||||||||||||||||||
2530 | - | |||||||||||||||||||||||||||||||
2531 | \sa highlightRangeMode | - | ||||||||||||||||||||||||||||||
2532 | */ | - | ||||||||||||||||||||||||||||||
2533 | QQuickListView::SnapMode QQuickListView::snapMode() const | - | ||||||||||||||||||||||||||||||
2534 | { | - | ||||||||||||||||||||||||||||||
2535 | Q_D(const QQuickListView); | - | ||||||||||||||||||||||||||||||
2536 | return d->snapMode; executed 16 times by 1 test: return d->snapMode; Executed by:
| 16 | ||||||||||||||||||||||||||||||
2537 | } | - | ||||||||||||||||||||||||||||||
2538 | - | |||||||||||||||||||||||||||||||
2539 | void QQuickListView::setSnapMode(SnapMode mode) | - | ||||||||||||||||||||||||||||||
2540 | { | - | ||||||||||||||||||||||||||||||
2541 | Q_D(QQuickListView); | - | ||||||||||||||||||||||||||||||
2542 | if (d->snapMode != mode) {
| 4-88 | ||||||||||||||||||||||||||||||
2543 | d->snapMode = mode; | - | ||||||||||||||||||||||||||||||
2544 | emit snapModeChanged(); | - | ||||||||||||||||||||||||||||||
2545 | d->fixupPosition(); | - | ||||||||||||||||||||||||||||||
2546 | } executed 88 times by 2 tests: end of block Executed by:
| 88 | ||||||||||||||||||||||||||||||
2547 | } executed 92 times by 2 tests: end of block Executed by:
| 92 | ||||||||||||||||||||||||||||||
2548 | - | |||||||||||||||||||||||||||||||
2549 | - | |||||||||||||||||||||||||||||||
2550 | /*! | - | ||||||||||||||||||||||||||||||
2551 | \qmlproperty Component QtQuick::ListView::footer | - | ||||||||||||||||||||||||||||||
2552 | This property holds the component to use as the footer. | - | ||||||||||||||||||||||||||||||
2553 | - | |||||||||||||||||||||||||||||||
2554 | An instance of the footer component is created for each view. The | - | ||||||||||||||||||||||||||||||
2555 | footer is positioned at the end of the view, after any items. The | - | ||||||||||||||||||||||||||||||
2556 | default \l {QQuickItem::z}{stacking order} of the footer is \c 1. | - | ||||||||||||||||||||||||||||||
2557 | - | |||||||||||||||||||||||||||||||
2558 | \sa header, footerItem, {Stacking Order in ListView} | - | ||||||||||||||||||||||||||||||
2559 | */ | - | ||||||||||||||||||||||||||||||
2560 | - | |||||||||||||||||||||||||||||||
2561 | - | |||||||||||||||||||||||||||||||
2562 | /*! | - | ||||||||||||||||||||||||||||||
2563 | \qmlproperty Component QtQuick::ListView::header | - | ||||||||||||||||||||||||||||||
2564 | This property holds the component to use as the header. | - | ||||||||||||||||||||||||||||||
2565 | - | |||||||||||||||||||||||||||||||
2566 | An instance of the header component is created for each view. The | - | ||||||||||||||||||||||||||||||
2567 | header is positioned at the beginning of the view, before any items. | - | ||||||||||||||||||||||||||||||
2568 | The default \l {QQuickItem::z}{stacking order} of the header is \c 1. | - | ||||||||||||||||||||||||||||||
2569 | - | |||||||||||||||||||||||||||||||
2570 | \sa footer, headerItem, {Stacking Order in ListView} | - | ||||||||||||||||||||||||||||||
2571 | */ | - | ||||||||||||||||||||||||||||||
2572 | - | |||||||||||||||||||||||||||||||
2573 | /*! | - | ||||||||||||||||||||||||||||||
2574 | \qmlproperty Item QtQuick::ListView::headerItem | - | ||||||||||||||||||||||||||||||
2575 | This holds the header item created from the \l header component. | - | ||||||||||||||||||||||||||||||
2576 | - | |||||||||||||||||||||||||||||||
2577 | An instance of the header component is created for each view. The | - | ||||||||||||||||||||||||||||||
2578 | header is positioned at the beginning of the view, before any items. | - | ||||||||||||||||||||||||||||||
2579 | The default \l {QQuickItem::z}{stacking order} of the header is \c 1. | - | ||||||||||||||||||||||||||||||
2580 | - | |||||||||||||||||||||||||||||||
2581 | \sa header, footerItem, {Stacking Order in ListView} | - | ||||||||||||||||||||||||||||||
2582 | */ | - | ||||||||||||||||||||||||||||||
2583 | - | |||||||||||||||||||||||||||||||
2584 | /*! | - | ||||||||||||||||||||||||||||||
2585 | \qmlproperty Item QtQuick::ListView::footerItem | - | ||||||||||||||||||||||||||||||
2586 | This holds the footer item created from the \l footer component. | - | ||||||||||||||||||||||||||||||
2587 | - | |||||||||||||||||||||||||||||||
2588 | An instance of the footer component is created for each view. The | - | ||||||||||||||||||||||||||||||
2589 | footer is positioned at the end of the view, after any items. The | - | ||||||||||||||||||||||||||||||
2590 | default \l {QQuickItem::z}{stacking order} of the footer is \c 1. | - | ||||||||||||||||||||||||||||||
2591 | - | |||||||||||||||||||||||||||||||
2592 | \sa footer, headerItem, {Stacking Order in ListView} | - | ||||||||||||||||||||||||||||||
2593 | */ | - | ||||||||||||||||||||||||||||||
2594 | - | |||||||||||||||||||||||||||||||
2595 | /*! | - | ||||||||||||||||||||||||||||||
2596 | \qmlproperty enumeration QtQuick::ListView::headerPositioning | - | ||||||||||||||||||||||||||||||
2597 | \since Qt 5.4 | - | ||||||||||||||||||||||||||||||
2598 | - | |||||||||||||||||||||||||||||||
2599 | This property determines the positioning of the \l{headerItem}{header item}. | - | ||||||||||||||||||||||||||||||
2600 | - | |||||||||||||||||||||||||||||||
2601 | The possible values are: | - | ||||||||||||||||||||||||||||||
2602 | \list | - | ||||||||||||||||||||||||||||||
2603 | \li ListView.InlineHeader (default) - the header is positioned in the beginning | - | ||||||||||||||||||||||||||||||
2604 | of the content and moves together with the content like an ordinary item. | - | ||||||||||||||||||||||||||||||
2605 | \li ListView.OverlayHeader - the header is positioned in the beginning of the view. | - | ||||||||||||||||||||||||||||||
2606 | \li ListView.PullBackHeader - the header is positioned in the beginning of the view. | - | ||||||||||||||||||||||||||||||
2607 | The header can be pushed away by moving the content forwards, and pulled back by | - | ||||||||||||||||||||||||||||||
2608 | moving the content backwards. | - | ||||||||||||||||||||||||||||||
2609 | \endlist | - | ||||||||||||||||||||||||||||||
2610 | - | |||||||||||||||||||||||||||||||
2611 | \note This property has no effect on the \l {QQuickItem::z}{stacking order} | - | ||||||||||||||||||||||||||||||
2612 | of the header. For example, if the header should be shown above the | - | ||||||||||||||||||||||||||||||
2613 | \l delegate items when using \c ListView.OverlayHeader, its Z value | - | ||||||||||||||||||||||||||||||
2614 | should be set to a value higher than that of the delegates. For more | - | ||||||||||||||||||||||||||||||
2615 | information, see \l {Stacking Order in ListView}. | - | ||||||||||||||||||||||||||||||
2616 | */ | - | ||||||||||||||||||||||||||||||
2617 | QQuickListView::HeaderPositioning QQuickListView::headerPositioning() const | - | ||||||||||||||||||||||||||||||
2618 | { | - | ||||||||||||||||||||||||||||||
2619 | Q_D(const QQuickListView); | - | ||||||||||||||||||||||||||||||
2620 | return d->headerPositioning; never executed: return d->headerPositioning; | 0 | ||||||||||||||||||||||||||||||
2621 | } | - | ||||||||||||||||||||||||||||||
2622 | - | |||||||||||||||||||||||||||||||
2623 | void QQuickListView::setHeaderPositioning(QQuickListView::HeaderPositioning positioning) | - | ||||||||||||||||||||||||||||||
2624 | { | - | ||||||||||||||||||||||||||||||
2625 | Q_D(QQuickListView); | - | ||||||||||||||||||||||||||||||
2626 | if (d->headerPositioning != positioning) {
| 0-86 | ||||||||||||||||||||||||||||||
2627 | d->applyPendingChanges(); | - | ||||||||||||||||||||||||||||||
2628 | d->headerPositioning = positioning; | - | ||||||||||||||||||||||||||||||
2629 | if (isComponentComplete()) {
| 0-86 | ||||||||||||||||||||||||||||||
2630 | d->updateHeader(); | - | ||||||||||||||||||||||||||||||
2631 | d->updateViewport(); | - | ||||||||||||||||||||||||||||||
2632 | d->fixupPosition(); | - | ||||||||||||||||||||||||||||||
2633 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
2634 | emit headerPositioningChanged(); | - | ||||||||||||||||||||||||||||||
2635 | } executed 86 times by 1 test: end of block Executed by:
| 86 | ||||||||||||||||||||||||||||||
2636 | } executed 86 times by 1 test: end of block Executed by:
| 86 | ||||||||||||||||||||||||||||||
2637 | - | |||||||||||||||||||||||||||||||
2638 | /*! | - | ||||||||||||||||||||||||||||||
2639 | \qmlproperty enumeration QtQuick::ListView::footerPositioning | - | ||||||||||||||||||||||||||||||
2640 | \since Qt 5.4 | - | ||||||||||||||||||||||||||||||
2641 | - | |||||||||||||||||||||||||||||||
2642 | This property determines the positioning of the \l{footerItem}{footer item}. | - | ||||||||||||||||||||||||||||||
2643 | - | |||||||||||||||||||||||||||||||
2644 | The possible values are: | - | ||||||||||||||||||||||||||||||
2645 | \list | - | ||||||||||||||||||||||||||||||
2646 | \li ListView.InlineFooter (default) - the footer is positioned in the end | - | ||||||||||||||||||||||||||||||
2647 | of the content and moves together with the content like an ordinary item. | - | ||||||||||||||||||||||||||||||
2648 | \li ListView.OverlayFooter - the footer is positioned in the end of the view. | - | ||||||||||||||||||||||||||||||
2649 | \li ListView.PullBackFooter - the footer is positioned in the end of the view. | - | ||||||||||||||||||||||||||||||
2650 | The footer can be pushed away by moving the content backwards, and pulled back by | - | ||||||||||||||||||||||||||||||
2651 | moving the content forwards. | - | ||||||||||||||||||||||||||||||
2652 | \endlist | - | ||||||||||||||||||||||||||||||
2653 | - | |||||||||||||||||||||||||||||||
2654 | \note This property has no effect on the \l {QQuickItem::z}{stacking order} | - | ||||||||||||||||||||||||||||||
2655 | of the footer. For example, if the footer should be shown above the | - | ||||||||||||||||||||||||||||||
2656 | \l delegate items when using \c ListView.OverlayFooter, its Z value | - | ||||||||||||||||||||||||||||||
2657 | should be set to a value higher than that of the delegates. For more | - | ||||||||||||||||||||||||||||||
2658 | information, see \l {Stacking Order in ListView}. | - | ||||||||||||||||||||||||||||||
2659 | */ | - | ||||||||||||||||||||||||||||||
2660 | QQuickListView::FooterPositioning QQuickListView::footerPositioning() const | - | ||||||||||||||||||||||||||||||
2661 | { | - | ||||||||||||||||||||||||||||||
2662 | Q_D(const QQuickListView); | - | ||||||||||||||||||||||||||||||
2663 | return d->footerPositioning; never executed: return d->footerPositioning; | 0 | ||||||||||||||||||||||||||||||
2664 | } | - | ||||||||||||||||||||||||||||||
2665 | - | |||||||||||||||||||||||||||||||
2666 | void QQuickListView::setFooterPositioning(QQuickListView::FooterPositioning positioning) | - | ||||||||||||||||||||||||||||||
2667 | { | - | ||||||||||||||||||||||||||||||
2668 | Q_D(QQuickListView); | - | ||||||||||||||||||||||||||||||
2669 | if (d->footerPositioning != positioning) {
| 0-82 | ||||||||||||||||||||||||||||||
2670 | d->applyPendingChanges(); | - | ||||||||||||||||||||||||||||||
2671 | d->footerPositioning = positioning; | - | ||||||||||||||||||||||||||||||
2672 | if (isComponentComplete()) {
| 0-82 | ||||||||||||||||||||||||||||||
2673 | d->updateFooter(); | - | ||||||||||||||||||||||||||||||
2674 | d->updateViewport(); | - | ||||||||||||||||||||||||||||||
2675 | d->fixupPosition(); | - | ||||||||||||||||||||||||||||||
2676 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
2677 | emit footerPositioningChanged(); | - | ||||||||||||||||||||||||||||||
2678 | } executed 82 times by 1 test: end of block Executed by:
| 82 | ||||||||||||||||||||||||||||||
2679 | } executed 82 times by 1 test: end of block Executed by:
| 82 | ||||||||||||||||||||||||||||||
2680 | - | |||||||||||||||||||||||||||||||
2681 | /*! | - | ||||||||||||||||||||||||||||||
2682 | \qmlproperty Transition QtQuick::ListView::populate | - | ||||||||||||||||||||||||||||||
2683 | - | |||||||||||||||||||||||||||||||
2684 | This property holds the transition to apply to the items that are initially created | - | ||||||||||||||||||||||||||||||
2685 | for a view. | - | ||||||||||||||||||||||||||||||
2686 | - | |||||||||||||||||||||||||||||||
2687 | It is applied to all items that are created when: | - | ||||||||||||||||||||||||||||||
2688 | - | |||||||||||||||||||||||||||||||
2689 | \list | - | ||||||||||||||||||||||||||||||
2690 | \li The view is first created | - | ||||||||||||||||||||||||||||||
2691 | \li The view's \l model changes | - | ||||||||||||||||||||||||||||||
2692 | \li The view's \l model is \l {QAbstractItemModel::reset()}{reset}, if the model is a QAbstractItemModel subclass | - | ||||||||||||||||||||||||||||||
2693 | \endlist | - | ||||||||||||||||||||||||||||||
2694 | - | |||||||||||||||||||||||||||||||
2695 | For example, here is a view that specifies such a transition: | - | ||||||||||||||||||||||||||||||
2696 | - | |||||||||||||||||||||||||||||||
2697 | \code | - | ||||||||||||||||||||||||||||||
2698 | ListView { | - | ||||||||||||||||||||||||||||||
2699 | ... | - | ||||||||||||||||||||||||||||||
2700 | populate: Transition { | - | ||||||||||||||||||||||||||||||
2701 | NumberAnimation { properties: "x,y"; duration: 1000 } | - | ||||||||||||||||||||||||||||||
2702 | } | - | ||||||||||||||||||||||||||||||
2703 | } | - | ||||||||||||||||||||||||||||||
2704 | \endcode | - | ||||||||||||||||||||||||||||||
2705 | - | |||||||||||||||||||||||||||||||
2706 | When the view is initialized, the view will create all the necessary items for the view, | - | ||||||||||||||||||||||||||||||
2707 | then animate them to their correct positions within the view over one second. | - | ||||||||||||||||||||||||||||||
2708 | - | |||||||||||||||||||||||||||||||
2709 | For more details and examples on how to use view transitions, see the ViewTransition | - | ||||||||||||||||||||||||||||||
2710 | documentation. | - | ||||||||||||||||||||||||||||||
2711 | - | |||||||||||||||||||||||||||||||
2712 | \sa add, ViewTransition | - | ||||||||||||||||||||||||||||||
2713 | */ | - | ||||||||||||||||||||||||||||||
2714 | - | |||||||||||||||||||||||||||||||
2715 | /*! | - | ||||||||||||||||||||||||||||||
2716 | \qmlproperty Transition QtQuick::ListView::add | - | ||||||||||||||||||||||||||||||
2717 | - | |||||||||||||||||||||||||||||||
2718 | This property holds the transition to apply to items that are added to the view. | - | ||||||||||||||||||||||||||||||
2719 | - | |||||||||||||||||||||||||||||||
2720 | For example, here is a view that specifies such a transition: | - | ||||||||||||||||||||||||||||||
2721 | - | |||||||||||||||||||||||||||||||
2722 | \code | - | ||||||||||||||||||||||||||||||
2723 | ListView { | - | ||||||||||||||||||||||||||||||
2724 | ... | - | ||||||||||||||||||||||||||||||
2725 | add: Transition { | - | ||||||||||||||||||||||||||||||
2726 | NumberAnimation { properties: "x,y"; from: 100; duration: 1000 } | - | ||||||||||||||||||||||||||||||
2727 | } | - | ||||||||||||||||||||||||||||||
2728 | } | - | ||||||||||||||||||||||||||||||
2729 | \endcode | - | ||||||||||||||||||||||||||||||
2730 | - | |||||||||||||||||||||||||||||||
2731 | Whenever an item is added to the above view, the item will be animated from the position (100,100) | - | ||||||||||||||||||||||||||||||
2732 | to its final x,y position within the view, over one second. The transition only applies to | - | ||||||||||||||||||||||||||||||
2733 | the new items that are added to the view; it does not apply to the items below that are | - | ||||||||||||||||||||||||||||||
2734 | displaced by the addition of the new items. To animate the displaced items, set the \l displaced | - | ||||||||||||||||||||||||||||||
2735 | or \l addDisplaced properties. | - | ||||||||||||||||||||||||||||||
2736 | - | |||||||||||||||||||||||||||||||
2737 | For more details and examples on how to use view transitions, see the ViewTransition | - | ||||||||||||||||||||||||||||||
2738 | documentation. | - | ||||||||||||||||||||||||||||||
2739 | - | |||||||||||||||||||||||||||||||
2740 | \note This transition is not applied to the items that are created when the view is initially | - | ||||||||||||||||||||||||||||||
2741 | populated, or when the view's \l model changes. (In those cases, the \l populate transition is | - | ||||||||||||||||||||||||||||||
2742 | applied instead.) Additionally, this transition should \e not animate the height of the new item; | - | ||||||||||||||||||||||||||||||
2743 | doing so will cause any items beneath the new item to be laid out at the wrong position. Instead, | - | ||||||||||||||||||||||||||||||
2744 | the height can be animated within the \l {add}{onAdd} handler in the delegate. | - | ||||||||||||||||||||||||||||||
2745 | - | |||||||||||||||||||||||||||||||
2746 | \sa addDisplaced, populate, ViewTransition | - | ||||||||||||||||||||||||||||||
2747 | */ | - | ||||||||||||||||||||||||||||||
2748 | - | |||||||||||||||||||||||||||||||
2749 | /*! | - | ||||||||||||||||||||||||||||||
2750 | \qmlproperty Transition QtQuick::ListView::addDisplaced | - | ||||||||||||||||||||||||||||||
2751 | - | |||||||||||||||||||||||||||||||
2752 | This property holds the transition to apply to items within the view that are displaced by | - | ||||||||||||||||||||||||||||||
2753 | the addition of other items to the view. | - | ||||||||||||||||||||||||||||||
2754 | - | |||||||||||||||||||||||||||||||
2755 | For example, here is a view that specifies such a transition: | - | ||||||||||||||||||||||||||||||
2756 | - | |||||||||||||||||||||||||||||||
2757 | \code | - | ||||||||||||||||||||||||||||||
2758 | ListView { | - | ||||||||||||||||||||||||||||||
2759 | ... | - | ||||||||||||||||||||||||||||||
2760 | addDisplaced: Transition { | - | ||||||||||||||||||||||||||||||
2761 | NumberAnimation { properties: "x,y"; duration: 1000 } | - | ||||||||||||||||||||||||||||||
2762 | } | - | ||||||||||||||||||||||||||||||
2763 | } | - | ||||||||||||||||||||||||||||||
2764 | \endcode | - | ||||||||||||||||||||||||||||||
2765 | - | |||||||||||||||||||||||||||||||
2766 | Whenever an item is added to the above view, all items beneath the new item are displaced, causing | - | ||||||||||||||||||||||||||||||
2767 | them to move down (or sideways, if horizontally orientated) within the view. As this | - | ||||||||||||||||||||||||||||||
2768 | displacement occurs, the items' movement to their new x,y positions within the view will be | - | ||||||||||||||||||||||||||||||
2769 | animated by a NumberAnimation over one second, as specified. This transition is not applied to | - | ||||||||||||||||||||||||||||||
2770 | the new item that has been added to the view; to animate the added items, set the \l add | - | ||||||||||||||||||||||||||||||
2771 | property. | - | ||||||||||||||||||||||||||||||
2772 | - | |||||||||||||||||||||||||||||||
2773 | If an item is displaced by multiple types of operations at the same time, it is not defined as to | - | ||||||||||||||||||||||||||||||
2774 | whether the addDisplaced, moveDisplaced or removeDisplaced transition will be applied. Additionally, | - | ||||||||||||||||||||||||||||||
2775 | if it is not necessary to specify different transitions depending on whether an item is displaced | - | ||||||||||||||||||||||||||||||
2776 | by an add, move or remove operation, consider setting the \l displaced property instead. | - | ||||||||||||||||||||||||||||||
2777 | - | |||||||||||||||||||||||||||||||
2778 | For more details and examples on how to use view transitions, see the ViewTransition | - | ||||||||||||||||||||||||||||||
2779 | documentation. | - | ||||||||||||||||||||||||||||||
2780 | - | |||||||||||||||||||||||||||||||
2781 | \note This transition is not applied to the items that are created when the view is initially | - | ||||||||||||||||||||||||||||||
2782 | populated, or when the view's \l model changes. In those cases, the \l populate transition is | - | ||||||||||||||||||||||||||||||
2783 | applied instead. | - | ||||||||||||||||||||||||||||||
2784 | - | |||||||||||||||||||||||||||||||
2785 | \sa displaced, add, populate, ViewTransition | - | ||||||||||||||||||||||||||||||
2786 | */ | - | ||||||||||||||||||||||||||||||
2787 | - | |||||||||||||||||||||||||||||||
2788 | /*! | - | ||||||||||||||||||||||||||||||
2789 | \qmlproperty Transition QtQuick::ListView::move | - | ||||||||||||||||||||||||||||||
2790 | - | |||||||||||||||||||||||||||||||
2791 | This property holds the transition to apply to items in the view that are being moved due | - | ||||||||||||||||||||||||||||||
2792 | to a move operation in the view's \l model. | - | ||||||||||||||||||||||||||||||
2793 | - | |||||||||||||||||||||||||||||||
2794 | For example, here is a view that specifies such a transition: | - | ||||||||||||||||||||||||||||||
2795 | - | |||||||||||||||||||||||||||||||
2796 | \code | - | ||||||||||||||||||||||||||||||
2797 | ListView { | - | ||||||||||||||||||||||||||||||
2798 | ... | - | ||||||||||||||||||||||||||||||
2799 | move: Transition { | - | ||||||||||||||||||||||||||||||
2800 | NumberAnimation { properties: "x,y"; duration: 1000 } | - | ||||||||||||||||||||||||||||||
2801 | } | - | ||||||||||||||||||||||||||||||
2802 | } | - | ||||||||||||||||||||||||||||||
2803 | \endcode | - | ||||||||||||||||||||||||||||||
2804 | - | |||||||||||||||||||||||||||||||
2805 | Whenever the \l model performs a move operation to move a particular set of indexes, the | - | ||||||||||||||||||||||||||||||
2806 | respective items in the view will be animated to their new positions in the view over one | - | ||||||||||||||||||||||||||||||
2807 | second. The transition only applies to the items that are the subject of the move operation | - | ||||||||||||||||||||||||||||||
2808 | in the model; it does not apply to items below them that are displaced by the move operation. | - | ||||||||||||||||||||||||||||||
2809 | To animate the displaced items, set the \l displaced or \l moveDisplaced properties. | - | ||||||||||||||||||||||||||||||
2810 | - | |||||||||||||||||||||||||||||||
2811 | For more details and examples on how to use view transitions, see the ViewTransition | - | ||||||||||||||||||||||||||||||
2812 | documentation. | - | ||||||||||||||||||||||||||||||
2813 | - | |||||||||||||||||||||||||||||||
2814 | \sa moveDisplaced, ViewTransition | - | ||||||||||||||||||||||||||||||
2815 | */ | - | ||||||||||||||||||||||||||||||
2816 | - | |||||||||||||||||||||||||||||||
2817 | /*! | - | ||||||||||||||||||||||||||||||
2818 | \qmlproperty Transition QtQuick::ListView::moveDisplaced | - | ||||||||||||||||||||||||||||||
2819 | - | |||||||||||||||||||||||||||||||
2820 | This property holds the transition to apply to items that are displaced by a move operation in | - | ||||||||||||||||||||||||||||||
2821 | the view's \l model. | - | ||||||||||||||||||||||||||||||
2822 | - | |||||||||||||||||||||||||||||||
2823 | For example, here is a view that specifies such a transition: | - | ||||||||||||||||||||||||||||||
2824 | - | |||||||||||||||||||||||||||||||
2825 | \code | - | ||||||||||||||||||||||||||||||
2826 | ListView { | - | ||||||||||||||||||||||||||||||
2827 | ... | - | ||||||||||||||||||||||||||||||
2828 | moveDisplaced: Transition { | - | ||||||||||||||||||||||||||||||
2829 | NumberAnimation { properties: "x,y"; duration: 1000 } | - | ||||||||||||||||||||||||||||||
2830 | } | - | ||||||||||||||||||||||||||||||
2831 | } | - | ||||||||||||||||||||||||||||||
2832 | \endcode | - | ||||||||||||||||||||||||||||||
2833 | - | |||||||||||||||||||||||||||||||
2834 | Whenever the \l model performs a move operation to move a particular set of indexes, the items | - | ||||||||||||||||||||||||||||||
2835 | between the source and destination indexes of the move operation are displaced, causing them | - | ||||||||||||||||||||||||||||||
2836 | to move upwards or downwards (or sideways, if horizontally orientated) within the view. As this | - | ||||||||||||||||||||||||||||||
2837 | displacement occurs, the items' movement to their new x,y positions within the view will be | - | ||||||||||||||||||||||||||||||
2838 | animated by a NumberAnimation over one second, as specified. This transition is not applied to | - | ||||||||||||||||||||||||||||||
2839 | the items that are the actual subjects of the move operation; to animate the moved items, set | - | ||||||||||||||||||||||||||||||
2840 | the \l move property. | - | ||||||||||||||||||||||||||||||
2841 | - | |||||||||||||||||||||||||||||||
2842 | If an item is displaced by multiple types of operations at the same time, it is not defined as to | - | ||||||||||||||||||||||||||||||
2843 | whether the addDisplaced, moveDisplaced or removeDisplaced transition will be applied. Additionally, | - | ||||||||||||||||||||||||||||||
2844 | if it is not necessary to specify different transitions depending on whether an item is displaced | - | ||||||||||||||||||||||||||||||
2845 | by an add, move or remove operation, consider setting the \l displaced property instead. | - | ||||||||||||||||||||||||||||||
2846 | - | |||||||||||||||||||||||||||||||
2847 | For more details and examples on how to use view transitions, see the ViewTransition | - | ||||||||||||||||||||||||||||||
2848 | documentation. | - | ||||||||||||||||||||||||||||||
2849 | - | |||||||||||||||||||||||||||||||
2850 | \sa displaced, move, ViewTransition | - | ||||||||||||||||||||||||||||||
2851 | */ | - | ||||||||||||||||||||||||||||||
2852 | - | |||||||||||||||||||||||||||||||
2853 | /*! | - | ||||||||||||||||||||||||||||||
2854 | \qmlproperty Transition QtQuick::ListView::remove | - | ||||||||||||||||||||||||||||||
2855 | - | |||||||||||||||||||||||||||||||
2856 | This property holds the transition to apply to items that are removed from the view. | - | ||||||||||||||||||||||||||||||
2857 | - | |||||||||||||||||||||||||||||||
2858 | For example, here is a view that specifies such a transition: | - | ||||||||||||||||||||||||||||||
2859 | - | |||||||||||||||||||||||||||||||
2860 | \code | - | ||||||||||||||||||||||||||||||
2861 | ListView { | - | ||||||||||||||||||||||||||||||
2862 | ... | - | ||||||||||||||||||||||||||||||
2863 | remove: Transition { | - | ||||||||||||||||||||||||||||||
2864 | ParallelAnimation { | - | ||||||||||||||||||||||||||||||
2865 | NumberAnimation { property: "opacity"; to: 0; duration: 1000 } | - | ||||||||||||||||||||||||||||||
2866 | NumberAnimation { properties: "x,y"; to: 100; duration: 1000 } | - | ||||||||||||||||||||||||||||||
2867 | } | - | ||||||||||||||||||||||||||||||
2868 | } | - | ||||||||||||||||||||||||||||||
2869 | } | - | ||||||||||||||||||||||||||||||
2870 | \endcode | - | ||||||||||||||||||||||||||||||
2871 | - | |||||||||||||||||||||||||||||||
2872 | Whenever an item is removed from the above view, the item will be animated to the position (100,100) | - | ||||||||||||||||||||||||||||||
2873 | over one second, and in parallel will also change its opacity to 0. The transition | - | ||||||||||||||||||||||||||||||
2874 | only applies to the items that are removed from the view; it does not apply to the items below | - | ||||||||||||||||||||||||||||||
2875 | them that are displaced by the removal of the items. To animate the displaced items, set the | - | ||||||||||||||||||||||||||||||
2876 | \l displaced or \l removeDisplaced properties. | - | ||||||||||||||||||||||||||||||
2877 | - | |||||||||||||||||||||||||||||||
2878 | Note that by the time the transition is applied, the item has already been removed from the | - | ||||||||||||||||||||||||||||||
2879 | model; any references to the model data for the removed index will not be valid. | - | ||||||||||||||||||||||||||||||
2880 | - | |||||||||||||||||||||||||||||||
2881 | Additionally, if the \l delayRemove attached property has been set for a delegate item, the | - | ||||||||||||||||||||||||||||||
2882 | remove transition will not be applied until \l delayRemove becomes false again. | - | ||||||||||||||||||||||||||||||
2883 | - | |||||||||||||||||||||||||||||||
2884 | For more details and examples on how to use view transitions, see the ViewTransition | - | ||||||||||||||||||||||||||||||
2885 | documentation. | - | ||||||||||||||||||||||||||||||
2886 | - | |||||||||||||||||||||||||||||||
2887 | \sa removeDisplaced, ViewTransition | - | ||||||||||||||||||||||||||||||
2888 | */ | - | ||||||||||||||||||||||||||||||
2889 | - | |||||||||||||||||||||||||||||||
2890 | /*! | - | ||||||||||||||||||||||||||||||
2891 | \qmlproperty Transition QtQuick::ListView::removeDisplaced | - | ||||||||||||||||||||||||||||||
2892 | - | |||||||||||||||||||||||||||||||
2893 | This property holds the transition to apply to items in the view that are displaced by the | - | ||||||||||||||||||||||||||||||
2894 | removal of other items in the view. | - | ||||||||||||||||||||||||||||||
2895 | - | |||||||||||||||||||||||||||||||
2896 | For example, here is a view that specifies such a transition: | - | ||||||||||||||||||||||||||||||
2897 | - | |||||||||||||||||||||||||||||||
2898 | \code | - | ||||||||||||||||||||||||||||||
2899 | ListView { | - | ||||||||||||||||||||||||||||||
2900 | ... | - | ||||||||||||||||||||||||||||||
2901 | removeDisplaced: Transition { | - | ||||||||||||||||||||||||||||||
2902 | NumberAnimation { properties: "x,y"; duration: 1000 } | - | ||||||||||||||||||||||||||||||
2903 | } | - | ||||||||||||||||||||||||||||||
2904 | } | - | ||||||||||||||||||||||||||||||
2905 | \endcode | - | ||||||||||||||||||||||||||||||
2906 | - | |||||||||||||||||||||||||||||||
2907 | Whenever an item is removed from the above view, all items beneath it are displaced, causing | - | ||||||||||||||||||||||||||||||
2908 | them to move upwards (or sideways, if horizontally orientated) within the view. As this | - | ||||||||||||||||||||||||||||||
2909 | displacement occurs, the items' movement to their new x,y positions within the view will be | - | ||||||||||||||||||||||||||||||
2910 | animated by a NumberAnimation over one second, as specified. This transition is not applied to | - | ||||||||||||||||||||||||||||||
2911 | the item that has actually been removed from the view; to animate the removed items, set the | - | ||||||||||||||||||||||||||||||
2912 | \l remove property. | - | ||||||||||||||||||||||||||||||
2913 | - | |||||||||||||||||||||||||||||||
2914 | If an item is displaced by multiple types of operations at the same time, it is not defined as to | - | ||||||||||||||||||||||||||||||
2915 | whether the addDisplaced, moveDisplaced or removeDisplaced transition will be applied. Additionally, | - | ||||||||||||||||||||||||||||||
2916 | if it is not necessary to specify different transitions depending on whether an item is displaced | - | ||||||||||||||||||||||||||||||
2917 | by an add, move or remove operation, consider setting the \l displaced property instead. | - | ||||||||||||||||||||||||||||||
2918 | - | |||||||||||||||||||||||||||||||
2919 | For more details and examples on how to use view transitions, see the ViewTransition | - | ||||||||||||||||||||||||||||||
2920 | documentation. | - | ||||||||||||||||||||||||||||||
2921 | - | |||||||||||||||||||||||||||||||
2922 | \sa displaced, remove, ViewTransition | - | ||||||||||||||||||||||||||||||
2923 | */ | - | ||||||||||||||||||||||||||||||
2924 | - | |||||||||||||||||||||||||||||||
2925 | /*! | - | ||||||||||||||||||||||||||||||
2926 | \qmlproperty Transition QtQuick::ListView::displaced | - | ||||||||||||||||||||||||||||||
2927 | This property holds the generic transition to apply to items that have been displaced by | - | ||||||||||||||||||||||||||||||
2928 | any model operation that affects the view. | - | ||||||||||||||||||||||||||||||
2929 | - | |||||||||||||||||||||||||||||||
2930 | This is a convenience for specifying the generic transition to be applied to any items | - | ||||||||||||||||||||||||||||||
2931 | that are displaced by an add, move or remove operation, without having to specify the | - | ||||||||||||||||||||||||||||||
2932 | individual addDisplaced, moveDisplaced and removeDisplaced properties. For example, here | - | ||||||||||||||||||||||||||||||
2933 | is a view that specifies a displaced transition: | - | ||||||||||||||||||||||||||||||
2934 | - | |||||||||||||||||||||||||||||||
2935 | \code | - | ||||||||||||||||||||||||||||||
2936 | ListView { | - | ||||||||||||||||||||||||||||||
2937 | ... | - | ||||||||||||||||||||||||||||||
2938 | displaced: Transition { | - | ||||||||||||||||||||||||||||||
2939 | NumberAnimation { properties: "x,y"; duration: 1000 } | - | ||||||||||||||||||||||||||||||
2940 | } | - | ||||||||||||||||||||||||||||||
2941 | } | - | ||||||||||||||||||||||||||||||
2942 | \endcode | - | ||||||||||||||||||||||||||||||
2943 | - | |||||||||||||||||||||||||||||||
2944 | When any item is added, moved or removed within the above view, the items below it are | - | ||||||||||||||||||||||||||||||
2945 | displaced, causing them to move down (or sideways, if horizontally orientated) within the | - | ||||||||||||||||||||||||||||||
2946 | view. As this displacement occurs, the items' movement to their new x,y positions within | - | ||||||||||||||||||||||||||||||
2947 | the view will be animated by a NumberAnimation over one second, as specified. | - | ||||||||||||||||||||||||||||||
2948 | - | |||||||||||||||||||||||||||||||
2949 | If a view specifies this generic displaced transition as well as a specific addDisplaced, | - | ||||||||||||||||||||||||||||||
2950 | moveDisplaced or removeDisplaced transition, the more specific transition will be used | - | ||||||||||||||||||||||||||||||
2951 | instead of the generic displaced transition when the relevant operation occurs, providing that | - | ||||||||||||||||||||||||||||||
2952 | the more specific transition has not been disabled (by setting \l {Transition::enabled}{enabled} | - | ||||||||||||||||||||||||||||||
2953 | to false). If it has indeed been disabled, the generic displaced transition is applied instead. | - | ||||||||||||||||||||||||||||||
2954 | - | |||||||||||||||||||||||||||||||
2955 | For more details and examples on how to use view transitions, see the ViewTransition | - | ||||||||||||||||||||||||||||||
2956 | documentation. | - | ||||||||||||||||||||||||||||||
2957 | - | |||||||||||||||||||||||||||||||
2958 | \sa addDisplaced, moveDisplaced, removeDisplaced, ViewTransition | - | ||||||||||||||||||||||||||||||
2959 | */ | - | ||||||||||||||||||||||||||||||
2960 | - | |||||||||||||||||||||||||||||||
2961 | void QQuickListView::viewportMoved(Qt::Orientations orient) | - | ||||||||||||||||||||||||||||||
2962 | { | - | ||||||||||||||||||||||||||||||
2963 | Q_D(QQuickListView); | - | ||||||||||||||||||||||||||||||
2964 | QQuickItemView::viewportMoved(orient); | - | ||||||||||||||||||||||||||||||
2965 | - | |||||||||||||||||||||||||||||||
2966 | if (!d->itemCount) {
| 562-9580 | ||||||||||||||||||||||||||||||
2967 | if (d->hasStickyHeader())
| 86-476 | ||||||||||||||||||||||||||||||
2968 | d->updateHeader(); executed 86 times by 1 test: d->updateHeader(); Executed by:
| 86 | ||||||||||||||||||||||||||||||
2969 | if (d->hasStickyFooter())
| 62-500 | ||||||||||||||||||||||||||||||
2970 | d->updateFooter(); executed 62 times by 1 test: d->updateFooter(); Executed by:
| 62 | ||||||||||||||||||||||||||||||
2971 | return; executed 562 times by 2 tests: return; Executed by:
| 562 | ||||||||||||||||||||||||||||||
2972 | } | - | ||||||||||||||||||||||||||||||
2973 | - | |||||||||||||||||||||||||||||||
2974 | // Recursion can occur due to refill changing the content size. | - | ||||||||||||||||||||||||||||||
2975 | if (d->inViewportMoved)
| 27-9553 | ||||||||||||||||||||||||||||||
2976 | return; executed 27 times by 1 test: return; Executed by:
| 27 | ||||||||||||||||||||||||||||||
2977 | d->inViewportMoved = true; | - | ||||||||||||||||||||||||||||||
2978 | - | |||||||||||||||||||||||||||||||
2979 | if (yflick()) {
| 3384-6169 | ||||||||||||||||||||||||||||||
2980 | if (d->isBottomToTop())
| 1566-4603 | ||||||||||||||||||||||||||||||
2981 | d->bufferMode = d->vData.smoothVelocity < 0 ? QQuickListViewPrivate::BufferAfter : QQuickListViewPrivate::BufferBefore; executed 1566 times by 1 test: d->bufferMode = d->vData.smoothVelocity < 0 ? QQuickListViewPrivate::BufferAfter : QQuickListViewPrivate::BufferBefore; Executed by:
| 709-1566 | ||||||||||||||||||||||||||||||
2982 | else | - | ||||||||||||||||||||||||||||||
2983 | d->bufferMode = d->vData.smoothVelocity < 0 ? QQuickListViewPrivate::BufferBefore : QQuickListViewPrivate::BufferAfter; executed 4603 times by 5 tests: d->bufferMode = d->vData.smoothVelocity < 0 ? QQuickListViewPrivate::BufferBefore : QQuickListViewPrivate::BufferAfter; Executed by:
| 1423-4603 | ||||||||||||||||||||||||||||||
2984 | } else { | - | ||||||||||||||||||||||||||||||
2985 | if (d->isRightToLeft())
| 1533-1851 | ||||||||||||||||||||||||||||||
2986 | d->bufferMode = d->hData.smoothVelocity < 0 ? QQuickListViewPrivate::BufferAfter : QQuickListViewPrivate::BufferBefore; executed 1533 times by 1 test: d->bufferMode = d->hData.smoothVelocity < 0 ? QQuickListViewPrivate::BufferAfter : QQuickListViewPrivate::BufferBefore; Executed by:
| 710-1533 | ||||||||||||||||||||||||||||||
2987 | else | - | ||||||||||||||||||||||||||||||
2988 | d->bufferMode = d->hData.smoothVelocity < 0 ? QQuickListViewPrivate::BufferBefore : QQuickListViewPrivate::BufferAfter; executed 1851 times by 2 tests: d->bufferMode = d->hData.smoothVelocity < 0 ? QQuickListViewPrivate::BufferBefore : QQuickListViewPrivate::BufferAfter; Executed by:
| 744-1851 | ||||||||||||||||||||||||||||||
2989 | } | - | ||||||||||||||||||||||||||||||
2990 | - | |||||||||||||||||||||||||||||||
2991 | d->refillOrLayout(); | - | ||||||||||||||||||||||||||||||
2992 | - | |||||||||||||||||||||||||||||||
2993 | // Set visibility of items to eliminate cost of items outside the visible area. | - | ||||||||||||||||||||||||||||||
2994 | qreal from = d->isContentFlowReversed() ? -d->position()-d->displayMarginBeginning-d->size() : d->position()-d->displayMarginBeginning;
| 3099-6454 | ||||||||||||||||||||||||||||||
2995 | qreal to = d->isContentFlowReversed() ? -d->position()+d->displayMarginEnd : d->position()+d->size()+d->displayMarginEnd;
| 3099-6454 | ||||||||||||||||||||||||||||||
2996 | for (FxViewItem *item : qAsConst(d->visibleItems)) { | - | ||||||||||||||||||||||||||||||
2997 | if (item->item)
| 0-87351 | ||||||||||||||||||||||||||||||
2998 | QQuickItemPrivate::get(item->item)->setCulled(item->endPosition() < from || item->position() > to); executed 87351 times by 5 tests: QQuickItemPrivate::get(item->item)->setCulled(item->endPosition() < from || item->position() > to); Executed by:
| 87351 | ||||||||||||||||||||||||||||||
2999 | } executed 87351 times by 5 tests: end of block Executed by:
| 87351 | ||||||||||||||||||||||||||||||
3000 | if (d->currentItem)
| 40-9513 | ||||||||||||||||||||||||||||||
3001 | QQuickItemPrivate::get(d->currentItem->item)->setCulled(d->currentItem->endPosition() < from || d->currentItem->position() > to); executed 9513 times by 5 tests: QQuickItemPrivate::get(d->currentItem->item)->setCulled(d->currentItem->endPosition() < from || d->currentItem->position() > to); Executed by:
| 9513 | ||||||||||||||||||||||||||||||
3002 | - | |||||||||||||||||||||||||||||||
3003 | if (d->hData.flicking || d->vData.flicking || d->hData.moving || d->vData.moving)
| 306-6794 | ||||||||||||||||||||||||||||||
3004 | d->moveReason = QQuickListViewPrivate::Mouse; executed 7392 times by 1 test: d->moveReason = QQuickListViewPrivate::Mouse; Executed by:
| 7392 | ||||||||||||||||||||||||||||||
3005 | if (d->moveReason != QQuickListViewPrivate::SetIndex) {
| 1069-8484 | ||||||||||||||||||||||||||||||
3006 | if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) {
| 0-5497 | ||||||||||||||||||||||||||||||
3007 | // reposition highlight | - | ||||||||||||||||||||||||||||||
3008 | qreal pos = d->highlight->position(); | - | ||||||||||||||||||||||||||||||
3009 | qreal viewPos = d->isContentFlowReversed() ? -d->position()-d->size() : d->position();
| 1217-1730 | ||||||||||||||||||||||||||||||
3010 | if (pos > viewPos + d->highlightRangeEnd - d->highlight->size())
| 1405-1542 | ||||||||||||||||||||||||||||||
3011 | pos = viewPos + d->highlightRangeEnd - d->highlight->size(); executed 1542 times by 1 test: pos = viewPos + d->highlightRangeEnd - d->highlight->size(); Executed by:
| 1542 | ||||||||||||||||||||||||||||||
3012 | if (pos < viewPos + d->highlightRangeStart)
| 1263-1684 | ||||||||||||||||||||||||||||||
3013 | pos = viewPos + d->highlightRangeStart; executed 1684 times by 1 test: pos = viewPos + d->highlightRangeStart; Executed by:
| 1684 | ||||||||||||||||||||||||||||||
3014 | if (pos != d->highlight->position()) {
| 62-2885 | ||||||||||||||||||||||||||||||
3015 | d->highlightPosAnimator->stop(); | - | ||||||||||||||||||||||||||||||
3016 | static_cast<FxListItemSG*>(d->highlight)->setPosition(pos); | - | ||||||||||||||||||||||||||||||
3017 | } else { executed 2885 times by 1 test: end of block Executed by:
| 2885 | ||||||||||||||||||||||||||||||
3018 | d->updateHighlight(); | - | ||||||||||||||||||||||||||||||
3019 | } executed 62 times by 1 test: end of block Executed by:
| 62 | ||||||||||||||||||||||||||||||
3020 | - | |||||||||||||||||||||||||||||||
3021 | // update current index | - | ||||||||||||||||||||||||||||||
3022 | if (FxViewItem *snapItem = d->snapItemAt(d->highlight->position())) {
| 208-2739 | ||||||||||||||||||||||||||||||
3023 | if (snapItem->index >= 0 && snapItem->index != d->currentIndex)
| 0-2739 | ||||||||||||||||||||||||||||||
3024 | d->updateCurrent(snapItem->index); executed 234 times by 1 test: d->updateCurrent(snapItem->index); Executed by:
| 234 | ||||||||||||||||||||||||||||||
3025 | } executed 2739 times by 1 test: end of block Executed by:
| 2739 | ||||||||||||||||||||||||||||||
3026 | } executed 2947 times by 1 test: end of block Executed by:
| 2947 | ||||||||||||||||||||||||||||||
3027 | } executed 8484 times by 4 tests: end of block Executed by:
| 8484 | ||||||||||||||||||||||||||||||
3028 | - | |||||||||||||||||||||||||||||||
3029 | if ((d->hData.flicking || d->vData.flicking) && d->correctFlick && !d->inFlickCorrection) {
| 0-6794 | ||||||||||||||||||||||||||||||
3030 | d->inFlickCorrection = true; | - | ||||||||||||||||||||||||||||||
3031 | // Near an end and it seems that the extent has changed? | - | ||||||||||||||||||||||||||||||
3032 | // Recalculate the flick so that we don't end up in an odd position. | - | ||||||||||||||||||||||||||||||
3033 | if (yflick() && !d->vData.inOvershoot) {
| 142-1576 | ||||||||||||||||||||||||||||||
3034 | if (d->vData.velocity > 0) {
| 635-799 | ||||||||||||||||||||||||||||||
3035 | const qreal minY = minYExtent(); | - | ||||||||||||||||||||||||||||||
3036 | if ((minY - d->vData.move.value() < height()/2 || d->vData.flickTarget - d->vData.move.value() < height()/2)
| 54-426 | ||||||||||||||||||||||||||||||
3037 | && minY != d->vData.flickTarget)
| 130-451 | ||||||||||||||||||||||||||||||
3038 | d->flickY(-d->vData.smoothVelocity.value()); executed 451 times by 1 test: d->flickY(-d->vData.smoothVelocity.value()); Executed by:
| 451 | ||||||||||||||||||||||||||||||
3039 | } else if (d->vData.velocity < 0) { executed 635 times by 1 test: end of block Executed by:
| 0-799 | ||||||||||||||||||||||||||||||
3040 | const qreal maxY = maxYExtent(); | - | ||||||||||||||||||||||||||||||
3041 | if ((d->vData.move.value() - maxY < height()/2 || d->vData.move.value() - d->vData.flickTarget < height()/2)
| 121-519 | ||||||||||||||||||||||||||||||
3042 | && maxY != d->vData.flickTarget)
| 197-481 | ||||||||||||||||||||||||||||||
3043 | d->flickY(-d->vData.smoothVelocity.value()); executed 481 times by 1 test: d->flickY(-d->vData.smoothVelocity.value()); Executed by:
| 481 | ||||||||||||||||||||||||||||||
3044 | } executed 799 times by 1 test: end of block Executed by:
| 799 | ||||||||||||||||||||||||||||||
3045 | } executed 1434 times by 1 test: end of block Executed by:
| 1434 | ||||||||||||||||||||||||||||||
3046 | - | |||||||||||||||||||||||||||||||
3047 | if (xflick() && !d->hData.inOvershoot) {
| 82-1576 | ||||||||||||||||||||||||||||||
3048 | if (d->hData.velocity > 0) {
| 601-602 | ||||||||||||||||||||||||||||||
3049 | const qreal minX = minXExtent(); | - | ||||||||||||||||||||||||||||||
3050 | if ((minX - d->hData.move.value() < width()/2 || d->hData.flickTarget - d->hData.move.value() < width()/2)
| 28-400 | ||||||||||||||||||||||||||||||
3051 | && minX != d->hData.flickTarget)
| 120-453 | ||||||||||||||||||||||||||||||
3052 | d->flickX(-d->hData.smoothVelocity.value()); executed 453 times by 1 test: d->flickX(-d->hData.smoothVelocity.value()); Executed by:
| 453 | ||||||||||||||||||||||||||||||
3053 | } else if (d->hData.velocity < 0) { executed 601 times by 1 test: end of block Executed by:
| 0-602 | ||||||||||||||||||||||||||||||
3054 | const qreal maxX = maxXExtent(); | - | ||||||||||||||||||||||||||||||
3055 | if ((d->hData.move.value() - maxX < width()/2 || d->hData.move.value() - d->hData.flickTarget < width()/2)
| 28-402 | ||||||||||||||||||||||||||||||
3056 | && maxX != d->hData.flickTarget)
| 120-454 | ||||||||||||||||||||||||||||||
3057 | d->flickX(-d->hData.smoothVelocity.value()); executed 454 times by 1 test: d->flickX(-d->hData.smoothVelocity.value()); Executed by:
| 454 | ||||||||||||||||||||||||||||||
3058 | } executed 602 times by 1 test: end of block Executed by:
| 602 | ||||||||||||||||||||||||||||||
3059 | } executed 1203 times by 1 test: end of block Executed by:
| 1203 | ||||||||||||||||||||||||||||||
3060 | d->inFlickCorrection = false; | - | ||||||||||||||||||||||||||||||
3061 | } executed 2861 times by 1 test: end of block Executed by:
| 2861 | ||||||||||||||||||||||||||||||
3062 | if (d->hasStickyHeader())
| 186-9367 | ||||||||||||||||||||||||||||||
3063 | d->updateHeader(); executed 186 times by 1 test: d->updateHeader(); Executed by:
| 186 | ||||||||||||||||||||||||||||||
3064 | if (d->hasStickyFooter())
| 222-9331 | ||||||||||||||||||||||||||||||
3065 | d->updateFooter(); executed 222 times by 1 test: d->updateFooter(); Executed by:
| 222 | ||||||||||||||||||||||||||||||
3066 | if (d->sectionCriteria) {
| 472-9081 | ||||||||||||||||||||||||||||||
3067 | d->updateCurrentSection(); | - | ||||||||||||||||||||||||||||||
3068 | d->updateStickySections(); | - | ||||||||||||||||||||||||||||||
3069 | } executed 472 times by 2 tests: end of block Executed by:
| 472 | ||||||||||||||||||||||||||||||
3070 | d->inViewportMoved = false; | - | ||||||||||||||||||||||||||||||
3071 | } executed 9553 times by 5 tests: end of block Executed by:
| 9553 | ||||||||||||||||||||||||||||||
3072 | - | |||||||||||||||||||||||||||||||
3073 | void QQuickListView::keyPressEvent(QKeyEvent *event) | - | ||||||||||||||||||||||||||||||
3074 | { | - | ||||||||||||||||||||||||||||||
3075 | Q_D(QQuickListView); | - | ||||||||||||||||||||||||||||||
3076 | if (d->model && d->model->count() && ((d->interactive && !d->explicitKeyNavigationEnabled)
| 0-90 | ||||||||||||||||||||||||||||||
3077 | || (d->explicitKeyNavigationEnabled && d->keyNavigationEnabled))) {
| 2-4 | ||||||||||||||||||||||||||||||
3078 | if ((d->orient == QQuickListView::Horizontal && !d->isRightToLeft() && event->key() == Qt::Key_Left)
| 0-86 | ||||||||||||||||||||||||||||||
3079 | || (d->orient == QQuickListView::Horizontal && d->isRightToLeft() && event->key() == Qt::Key_Right)
| 0-86 | ||||||||||||||||||||||||||||||
3080 | || (d->orient == QQuickListView::Vertical && !d->isBottomToTop() && event->key() == Qt::Key_Up)
| 0-86 | ||||||||||||||||||||||||||||||
3081 | || (d->orient == QQuickListView::Vertical && d->isBottomToTop() && event->key() == Qt::Key_Down)) {
| 0-86 | ||||||||||||||||||||||||||||||
3082 | if (currentIndex() > 0 || (d->wrap && !event->isAutoRepeat())) {
| 0 | ||||||||||||||||||||||||||||||
3083 | decrementCurrentIndex(); | - | ||||||||||||||||||||||||||||||
3084 | event->accept(); | - | ||||||||||||||||||||||||||||||
3085 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
3086 | } else if (d->wrap) {
| 0 | ||||||||||||||||||||||||||||||
3087 | event->accept(); | - | ||||||||||||||||||||||||||||||
3088 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
3089 | } | - | ||||||||||||||||||||||||||||||
3090 | } else if ((d->orient == QQuickListView::Horizontal && !d->isRightToLeft() && event->key() == Qt::Key_Right) never executed: end of block
| 0-86 | ||||||||||||||||||||||||||||||
3091 | || (d->orient == QQuickListView::Horizontal && d->isRightToLeft() && event->key() == Qt::Key_Left)
| 0-86 | ||||||||||||||||||||||||||||||
3092 | || (d->orient == QQuickListView::Vertical && !d->isBottomToTop() && event->key() == Qt::Key_Down)
| 0-86 | ||||||||||||||||||||||||||||||
3093 | || (d->orient == QQuickListView::Vertical && d->isBottomToTop() && event->key() == Qt::Key_Up)) {
| 0 | ||||||||||||||||||||||||||||||
3094 | if (currentIndex() < d->model->count() - 1 || (d->wrap && !event->isAutoRepeat())) {
| 0-86 | ||||||||||||||||||||||||||||||
3095 | incrementCurrentIndex(); | - | ||||||||||||||||||||||||||||||
3096 | event->accept(); | - | ||||||||||||||||||||||||||||||
3097 | return; executed 86 times by 1 test: return; Executed by:
| 86 | ||||||||||||||||||||||||||||||
3098 | } else if (d->wrap) {
| 0 | ||||||||||||||||||||||||||||||
3099 | event->accept(); | - | ||||||||||||||||||||||||||||||
3100 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
3101 | } | - | ||||||||||||||||||||||||||||||
3102 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
3103 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
3104 | event->ignore(); | - | ||||||||||||||||||||||||||||||
3105 | QQuickItemView::keyPressEvent(event); | - | ||||||||||||||||||||||||||||||
3106 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||||||||
3107 | - | |||||||||||||||||||||||||||||||
3108 | void QQuickListView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | - | ||||||||||||||||||||||||||||||
3109 | { | - | ||||||||||||||||||||||||||||||
3110 | Q_D(QQuickListView); | - | ||||||||||||||||||||||||||||||
3111 | if (d->isRightToLeft()) {
| 72-4000 | ||||||||||||||||||||||||||||||
3112 | // maintain position relative to the right edge | - | ||||||||||||||||||||||||||||||
3113 | qreal dx = newGeometry.width() - oldGeometry.width(); | - | ||||||||||||||||||||||||||||||
3114 | setContentX(contentX() - dx); | - | ||||||||||||||||||||||||||||||
3115 | } else if (d->isBottomToTop()) { executed 72 times by 1 test: end of block Executed by:
| 28-3972 | ||||||||||||||||||||||||||||||
3116 | // maintain position relative to the bottom edge | - | ||||||||||||||||||||||||||||||
3117 | qreal dy = newGeometry.height() - oldGeometry.height(); | - | ||||||||||||||||||||||||||||||
3118 | setContentY(contentY() - dy); | - | ||||||||||||||||||||||||||||||
3119 | } executed 28 times by 1 test: end of block Executed by:
| 28 | ||||||||||||||||||||||||||||||
3120 | QQuickItemView::geometryChanged(newGeometry, oldGeometry); | - | ||||||||||||||||||||||||||||||
3121 | } executed 4072 times by 9 tests: end of block Executed by:
| 4072 | ||||||||||||||||||||||||||||||
3122 | - | |||||||||||||||||||||||||||||||
3123 | void QQuickListView::initItem(int index, QObject *object) | - | ||||||||||||||||||||||||||||||
3124 | { | - | ||||||||||||||||||||||||||||||
3125 | QQuickItemView::initItem(index, object); | - | ||||||||||||||||||||||||||||||
3126 | - | |||||||||||||||||||||||||||||||
3127 | // setting the view from the FxViewItem wrapper is too late if the delegate | - | ||||||||||||||||||||||||||||||
3128 | // needs access to the view in Component.onCompleted | - | ||||||||||||||||||||||||||||||
3129 | QQuickItem *item = qmlobject_cast<QQuickItem*>(object); | - | ||||||||||||||||||||||||||||||
3130 | if (item) {
| 0-29948 | ||||||||||||||||||||||||||||||
3131 | QQuickListViewAttached *attached = static_cast<QQuickListViewAttached *>( | - | ||||||||||||||||||||||||||||||
3132 | qmlAttachedPropertiesObject<QQuickListView>(item)); | - | ||||||||||||||||||||||||||||||
3133 | if (attached)
| 0-29948 | ||||||||||||||||||||||||||||||
3134 | attached->setView(this); executed 29948 times by 10 tests: attached->setView(this); Executed by:
| 29948 | ||||||||||||||||||||||||||||||
3135 | } executed 29948 times by 10 tests: end of block Executed by:
| 29948 | ||||||||||||||||||||||||||||||
3136 | } executed 29948 times by 10 tests: end of block Executed by:
| 29948 | ||||||||||||||||||||||||||||||
3137 | - | |||||||||||||||||||||||||||||||
3138 | qreal QQuickListView::maxYExtent() const | - | ||||||||||||||||||||||||||||||
3139 | { | - | ||||||||||||||||||||||||||||||
3140 | Q_D(const QQuickListView); | - | ||||||||||||||||||||||||||||||
3141 | if (d->layoutOrientation() == Qt::Horizontal && d->flickableDirection != HorizontalFlick)
| 48-54514 | ||||||||||||||||||||||||||||||
3142 | return QQuickFlickable::maxYExtent(); executed 48 times by 1 test: return QQuickFlickable::maxYExtent(); Executed by:
| 48 | ||||||||||||||||||||||||||||||
3143 | return QQuickItemView::maxYExtent(); executed 60327 times by 11 tests: return QQuickItemView::maxYExtent(); Executed by:
| 60327 | ||||||||||||||||||||||||||||||
3144 | } | - | ||||||||||||||||||||||||||||||
3145 | - | |||||||||||||||||||||||||||||||
3146 | qreal QQuickListView::maxXExtent() const | - | ||||||||||||||||||||||||||||||
3147 | { | - | ||||||||||||||||||||||||||||||
3148 | Q_D(const QQuickListView); | - | ||||||||||||||||||||||||||||||
3149 | if (d->layoutOrientation() == Qt::Vertical && d->flickableDirection != VerticalFlick)
| 80-27304 | ||||||||||||||||||||||||||||||
3150 | return QQuickFlickable::maxXExtent(); executed 80 times by 2 tests: return QQuickFlickable::maxXExtent(); Executed by:
| 80 | ||||||||||||||||||||||||||||||
3151 | return QQuickItemView::maxXExtent(); executed 44024 times by 11 tests: return QQuickItemView::maxXExtent(); Executed by:
| 44024 | ||||||||||||||||||||||||||||||
3152 | } | - | ||||||||||||||||||||||||||||||
3153 | - | |||||||||||||||||||||||||||||||
3154 | /*! | - | ||||||||||||||||||||||||||||||
3155 | \qmlmethod QtQuick::ListView::incrementCurrentIndex() | - | ||||||||||||||||||||||||||||||
3156 | - | |||||||||||||||||||||||||||||||
3157 | Increments the current index. The current index will wrap | - | ||||||||||||||||||||||||||||||
3158 | if keyNavigationWraps is true and it is currently at the end. | - | ||||||||||||||||||||||||||||||
3159 | This method has no effect if the \l count is zero. | - | ||||||||||||||||||||||||||||||
3160 | - | |||||||||||||||||||||||||||||||
3161 | \b Note: methods should only be called after the Component has completed. | - | ||||||||||||||||||||||||||||||
3162 | */ | - | ||||||||||||||||||||||||||||||
3163 | void QQuickListView::incrementCurrentIndex() | - | ||||||||||||||||||||||||||||||
3164 | { | - | ||||||||||||||||||||||||||||||
3165 | Q_D(QQuickListView); | - | ||||||||||||||||||||||||||||||
3166 | int count = d->model ? d->model->count() : 0;
| 0-92 | ||||||||||||||||||||||||||||||
3167 | if (count && (currentIndex() < count - 1 || d->wrap)) {
| 0-92 | ||||||||||||||||||||||||||||||
3168 | d->moveReason = QQuickListViewPrivate::SetIndex; | - | ||||||||||||||||||||||||||||||
3169 | int index = currentIndex()+1; | - | ||||||||||||||||||||||||||||||
3170 | setCurrentIndex((index >= 0 && index < count) ? index : 0); | - | ||||||||||||||||||||||||||||||
3171 | } executed 92 times by 1 test: end of block Executed by:
| 92 | ||||||||||||||||||||||||||||||
3172 | } executed 92 times by 1 test: end of block Executed by:
| 92 | ||||||||||||||||||||||||||||||
3173 | - | |||||||||||||||||||||||||||||||
3174 | /*! | - | ||||||||||||||||||||||||||||||
3175 | \qmlmethod QtQuick::ListView::decrementCurrentIndex() | - | ||||||||||||||||||||||||||||||
3176 | - | |||||||||||||||||||||||||||||||
3177 | Decrements the current index. The current index will wrap | - | ||||||||||||||||||||||||||||||
3178 | if keyNavigationWraps is true and it is currently at the beginning. | - | ||||||||||||||||||||||||||||||
3179 | This method has no effect if the \l count is zero. | - | ||||||||||||||||||||||||||||||
3180 | - | |||||||||||||||||||||||||||||||
3181 | \b Note: methods should only be called after the Component has completed. | - | ||||||||||||||||||||||||||||||
3182 | */ | - | ||||||||||||||||||||||||||||||
3183 | void QQuickListView::decrementCurrentIndex() | - | ||||||||||||||||||||||||||||||
3184 | { | - | ||||||||||||||||||||||||||||||
3185 | Q_D(QQuickListView); | - | ||||||||||||||||||||||||||||||
3186 | int count = d->model ? d->model->count() : 0;
| 0-2 | ||||||||||||||||||||||||||||||
3187 | if (count && (currentIndex() > 0 || d->wrap)) {
| 0-2 | ||||||||||||||||||||||||||||||
3188 | d->moveReason = QQuickListViewPrivate::SetIndex; | - | ||||||||||||||||||||||||||||||
3189 | int index = currentIndex()-1; | - | ||||||||||||||||||||||||||||||
3190 | setCurrentIndex((index >= 0 && index < count) ? index : count-1); | - | ||||||||||||||||||||||||||||||
3191 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||||||||
3192 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||||||||
3193 | - | |||||||||||||||||||||||||||||||
3194 | void QQuickListViewPrivate::updateSectionCriteria() | - | ||||||||||||||||||||||||||||||
3195 | { | - | ||||||||||||||||||||||||||||||
3196 | Q_Q(QQuickListView); | - | ||||||||||||||||||||||||||||||
3197 | if (q->isComponentComplete() && model) {
| 48-1994 | ||||||||||||||||||||||||||||||
3198 | QList<QByteArray> roles; | - | ||||||||||||||||||||||||||||||
3199 | if (sectionCriteria && !sectionCriteria->property().isEmpty())
| 0-1924 | ||||||||||||||||||||||||||||||
3200 | roles << sectionCriteria->property().toUtf8(); executed 64 times by 4 tests: roles << sectionCriteria->property().toUtf8(); Executed by:
| 64 | ||||||||||||||||||||||||||||||
3201 | model->setWatchedRoles(roles); | - | ||||||||||||||||||||||||||||||
3202 | updateSections(); | - | ||||||||||||||||||||||||||||||
3203 | if (itemCount)
| 16-1972 | ||||||||||||||||||||||||||||||
3204 | forceLayoutPolish(); executed 16 times by 2 tests: forceLayoutPolish(); Executed by:
| 16 | ||||||||||||||||||||||||||||||
3205 | } executed 1988 times by 11 tests: end of block Executed by:
| 1988 | ||||||||||||||||||||||||||||||
3206 | } executed 2042 times by 11 tests: end of block Executed by:
| 2042 | ||||||||||||||||||||||||||||||
3207 | - | |||||||||||||||||||||||||||||||
3208 | bool QQuickListViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &change, ChangeResult *insertResult, QList<FxViewItem *> *addedItems, QList<MovedItem> *movingIntoView) | - | ||||||||||||||||||||||||||||||
3209 | { | - | ||||||||||||||||||||||||||||||
3210 | int modelIndex = change.index; | - | ||||||||||||||||||||||||||||||
3211 | int count = change.count; | - | ||||||||||||||||||||||||||||||
3212 | - | |||||||||||||||||||||||||||||||
3213 | qreal tempPos = isContentFlowReversed() ? -position()-size() : position();
| 108-1155 | ||||||||||||||||||||||||||||||
3214 | int index = visibleItems.count() ? mapFromModel(modelIndex) : 0;
| 276-987 | ||||||||||||||||||||||||||||||
3215 | qreal lastVisiblePos = buffer + displayMarginEnd + tempPos + size(); | - | ||||||||||||||||||||||||||||||
3216 | - | |||||||||||||||||||||||||||||||
3217 | if (index < 0) {
| 272-991 | ||||||||||||||||||||||||||||||
3218 | int i = visibleItems.count() - 1; | - | ||||||||||||||||||||||||||||||
3219 | while (i > 0 && visibleItems.at(i)->index == -1)
| 0-254 | ||||||||||||||||||||||||||||||
3220 | --i; never executed: --i; | 0 | ||||||||||||||||||||||||||||||
3221 | if (i == 0 && visibleItems.constFirst()->index == -1) {
| 0-254 | ||||||||||||||||||||||||||||||
3222 | // there are no visible items except items marked for removal | - | ||||||||||||||||||||||||||||||
3223 | index = visibleItems.count(); | - | ||||||||||||||||||||||||||||||
3224 | } else if (visibleItems.at(i)->index + 1 == modelIndex never executed: end of block
| 0-207 | ||||||||||||||||||||||||||||||
3225 | && visibleItems.at(i)->endPosition() <= lastVisiblePos) {
| 4-203 | ||||||||||||||||||||||||||||||
3226 | // Special case of appending an item to the model. | - | ||||||||||||||||||||||||||||||
3227 | index = visibleItems.count(); | - | ||||||||||||||||||||||||||||||
3228 | } else { executed 203 times by 2 tests: end of block Executed by:
| 203 | ||||||||||||||||||||||||||||||
3229 | if (modelIndex < visibleIndex) {
| 24-45 | ||||||||||||||||||||||||||||||
3230 | // Insert before visible items | - | ||||||||||||||||||||||||||||||
3231 | visibleIndex += count; | - | ||||||||||||||||||||||||||||||
3232 | for (FxViewItem *item : qAsConst(visibleItems)) { | - | ||||||||||||||||||||||||||||||
3233 | if (item->index != -1 && item->index >= modelIndex)
| 0-670 | ||||||||||||||||||||||||||||||
3234 | item->index += count; executed 670 times by 1 test: item->index += count; Executed by:
| 670 | ||||||||||||||||||||||||||||||
3235 | } executed 670 times by 1 test: end of block Executed by:
| 670 | ||||||||||||||||||||||||||||||
3236 | } executed 45 times by 1 test: end of block Executed by:
| 45 | ||||||||||||||||||||||||||||||
3237 | return true; executed 69 times by 1 test: return true; Executed by:
| 69 | ||||||||||||||||||||||||||||||
3238 | } | - | ||||||||||||||||||||||||||||||
3239 | } | - | ||||||||||||||||||||||||||||||
3240 | - | |||||||||||||||||||||||||||||||
3241 | // index can be the next item past the end of the visible items list (i.e. appended) | - | ||||||||||||||||||||||||||||||
3242 | qreal pos = 0; | - | ||||||||||||||||||||||||||||||
3243 | if (visibleItems.count()) {
| 276-918 | ||||||||||||||||||||||||||||||
3244 | pos = index < visibleItems.count() ? visibleItems.at(index)->position()
| 203-715 | ||||||||||||||||||||||||||||||
3245 | : visibleItems.constLast()->endPosition() + spacing; | - | ||||||||||||||||||||||||||||||
3246 | } executed 918 times by 2 tests: end of block Executed by:
| 918 | ||||||||||||||||||||||||||||||
3247 | - | |||||||||||||||||||||||||||||||
3248 | // Update the indexes of the following visible items. | - | ||||||||||||||||||||||||||||||
3249 | for (FxViewItem *item : qAsConst(visibleItems)) { | - | ||||||||||||||||||||||||||||||
3250 | if (item->index != -1 && item->index >= modelIndex) {
| 0-10307 | ||||||||||||||||||||||||||||||
3251 | item->index += count; | - | ||||||||||||||||||||||||||||||
3252 | if (change.isMove())
| 2464-3056 | ||||||||||||||||||||||||||||||
3253 | item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::MoveTransition, false); executed 2464 times by 1 test: item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::MoveTransition, false); Executed by:
| 2464 | ||||||||||||||||||||||||||||||
3254 | else | - | ||||||||||||||||||||||||||||||
3255 | item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, false); executed 3056 times by 2 tests: item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, false); Executed by:
| 3056 | ||||||||||||||||||||||||||||||
3256 | } | - | ||||||||||||||||||||||||||||||
3257 | } executed 10307 times by 2 tests: end of block Executed by:
| 10307 | ||||||||||||||||||||||||||||||
3258 | - | |||||||||||||||||||||||||||||||
3259 | bool visibleAffected = false; | - | ||||||||||||||||||||||||||||||
3260 | if (insertResult->visiblePos.isValid() && pos < insertResult->visiblePos) {
| 49-952 | ||||||||||||||||||||||||||||||
3261 | // Insert items before the visible item. | - | ||||||||||||||||||||||||||||||
3262 | int insertionIdx = index; | - | ||||||||||||||||||||||||||||||
3263 | int i = 0; | - | ||||||||||||||||||||||||||||||
3264 | qreal from = tempPos - displayMarginBeginning - buffer; | - | ||||||||||||||||||||||||||||||
3265 | - | |||||||||||||||||||||||||||||||
3266 | if (insertionIdx < visibleIndex) {
| 19-30 | ||||||||||||||||||||||||||||||
3267 | if (pos >= from) {
| 7-12 | ||||||||||||||||||||||||||||||
3268 | // items won't be visible, just note the size for repositioning | - | ||||||||||||||||||||||||||||||
3269 | insertResult->sizeChangesBeforeVisiblePos += count * (averageSize + spacing); | - | ||||||||||||||||||||||||||||||
3270 | } executed 7 times by 1 test: end of block Executed by:
| 7 | ||||||||||||||||||||||||||||||
3271 | } else { executed 19 times by 1 test: end of block Executed by:
| 19 | ||||||||||||||||||||||||||||||
3272 | for (i = count-1; i >= 0 && pos >= from; --i) {
| 10-38 | ||||||||||||||||||||||||||||||
3273 | // item is before first visible e.g. in cache buffer | - | ||||||||||||||||||||||||||||||
3274 | FxViewItem *item = nullptr; | - | ||||||||||||||||||||||||||||||
3275 | if (change.isMove() && (item = currentChanges.removedItems.take(change.moveKey(modelIndex + i))))
| 0-18 | ||||||||||||||||||||||||||||||
3276 | item->index = modelIndex + i; never executed: item->index = modelIndex + i; | 0 | ||||||||||||||||||||||||||||||
3277 | if (!item)
| 0-18 | ||||||||||||||||||||||||||||||
3278 | item = createItem(modelIndex + i, QQmlIncubator::Synchronous); executed 18 times by 1 test: item = createItem(modelIndex + i, QQmlIncubator::Synchronous); Executed by:
| 18 | ||||||||||||||||||||||||||||||
3279 | if (!item)
| 0-18 | ||||||||||||||||||||||||||||||
3280 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||
3281 | - | |||||||||||||||||||||||||||||||
3282 | visibleAffected = true; | - | ||||||||||||||||||||||||||||||
3283 | visibleItems.insert(insertionIdx, item); | - | ||||||||||||||||||||||||||||||
3284 | if (insertionIdx == 0)
| 9 | ||||||||||||||||||||||||||||||
3285 | insertResult->changedFirstItem = true; executed 9 times by 1 test: insertResult->changedFirstItem = true; Executed by:
| 9 | ||||||||||||||||||||||||||||||
3286 | if (!change.isMove()) {
| 0-18 | ||||||||||||||||||||||||||||||
3287 | addedItems->append(item); | - | ||||||||||||||||||||||||||||||
3288 | if (transitioner)
| 0-18 | ||||||||||||||||||||||||||||||
3289 | item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, true); never executed: item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, true); | 0 | ||||||||||||||||||||||||||||||
3290 | else | - | ||||||||||||||||||||||||||||||
3291 | static_cast<FxListItemSG *>(item)->setPosition(pos, true); executed 18 times by 1 test: static_cast<FxListItemSG *>(item)->setPosition(pos, true); Executed by:
| 18 | ||||||||||||||||||||||||||||||
3292 | } | - | ||||||||||||||||||||||||||||||
3293 | insertResult->sizeChangesBeforeVisiblePos += item->size() + spacing; | - | ||||||||||||||||||||||||||||||
3294 | pos -= item->size() + spacing; | - | ||||||||||||||||||||||||||||||
3295 | index++; | - | ||||||||||||||||||||||||||||||
3296 | } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||||||||||||||
3297 | } executed 30 times by 1 test: end of block Executed by:
| 30 | ||||||||||||||||||||||||||||||
3298 | - | |||||||||||||||||||||||||||||||
3299 | int firstOkIdx = -1; | - | ||||||||||||||||||||||||||||||
3300 | for (int i = 0; i <= insertionIdx && i < visibleItems.count() - 1; i++) {
| 20-59 | ||||||||||||||||||||||||||||||
3301 | if (visibleItems.at(i)->index + 1 != visibleItems.at(i + 1)->index) {
| 8-31 | ||||||||||||||||||||||||||||||
3302 | firstOkIdx = i + 1; | - | ||||||||||||||||||||||||||||||
3303 | break; executed 8 times by 1 test: break; Executed by:
| 8 | ||||||||||||||||||||||||||||||
3304 | } | - | ||||||||||||||||||||||||||||||
3305 | } executed 31 times by 1 test: end of block Executed by:
| 31 | ||||||||||||||||||||||||||||||
3306 | for (int i = 0; i < firstOkIdx; i++) {
| 12-49 | ||||||||||||||||||||||||||||||
3307 | FxViewItem *nvItem = visibleItems.takeFirst(); | - | ||||||||||||||||||||||||||||||
3308 | addedItems->removeOne(nvItem); | - | ||||||||||||||||||||||||||||||
3309 | removeItem(nvItem); | - | ||||||||||||||||||||||||||||||
3310 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||||||||
3311 | - | |||||||||||||||||||||||||||||||
3312 | } else { executed 49 times by 1 test: end of block Executed by:
| 49 | ||||||||||||||||||||||||||||||
3313 | for (int i = 0; i < count && pos <= lastVisiblePos; ++i) {
| 195-5011 | ||||||||||||||||||||||||||||||
3314 | visibleAffected = true; | - | ||||||||||||||||||||||||||||||
3315 | FxViewItem *item = nullptr; | - | ||||||||||||||||||||||||||||||
3316 | if (change.isMove() && (item = currentChanges.removedItems.take(change.moveKey(modelIndex + i))))
| 142-4242 | ||||||||||||||||||||||||||||||
3317 | item->index = modelIndex + i; executed 432 times by 1 test: item->index = modelIndex + i; Executed by:
| 432 | ||||||||||||||||||||||||||||||
3318 | bool newItem = !item; | - | ||||||||||||||||||||||||||||||
3319 | if (!item)
| 432-4384 | ||||||||||||||||||||||||||||||
3320 | item = createItem(modelIndex + i, QQmlIncubator::Synchronous); executed 4384 times by 3 tests: item = createItem(modelIndex + i, QQmlIncubator::Synchronous); Executed by:
| 4384 | ||||||||||||||||||||||||||||||
3321 | if (!item)
| 0-4816 | ||||||||||||||||||||||||||||||
3322 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||
3323 | - | |||||||||||||||||||||||||||||||
3324 | visibleItems.insert(index, item); | - | ||||||||||||||||||||||||||||||
3325 | if (index == 0)
| 499-4317 | ||||||||||||||||||||||||||||||
3326 | insertResult->changedFirstItem = true; executed 499 times by 3 tests: insertResult->changedFirstItem = true; Executed by:
| 499 | ||||||||||||||||||||||||||||||
3327 | if (change.isMove()) {
| 574-4242 | ||||||||||||||||||||||||||||||
3328 | // we know this is a move target, since move displaced items that are | - | ||||||||||||||||||||||||||||||
3329 | // shuffled into view due to a move would be added in refill() | - | ||||||||||||||||||||||||||||||
3330 | if (newItem && transitioner && transitioner->canTransition(QQuickItemViewTransitioner::MoveTransition, true))
| 0-432 | ||||||||||||||||||||||||||||||
3331 | movingIntoView->append(MovedItem(item, change.moveKey(item->index))); executed 32 times by 1 test: movingIntoView->append(MovedItem(item, change.moveKey(item->index))); Executed by:
| 32 | ||||||||||||||||||||||||||||||
3332 | } else { executed 574 times by 1 test: end of block Executed by:
| 574 | ||||||||||||||||||||||||||||||
3333 | addedItems->append(item); | - | ||||||||||||||||||||||||||||||
3334 | if (transitioner)
| 228-4014 | ||||||||||||||||||||||||||||||
3335 | item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, true); executed 228 times by 2 tests: item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, true); Executed by:
| 228 | ||||||||||||||||||||||||||||||
3336 | else | - | ||||||||||||||||||||||||||||||
3337 | static_cast<FxListItemSG *>(item)->setPosition(pos, true); executed 4014 times by 3 tests: static_cast<FxListItemSG *>(item)->setPosition(pos, true); Executed by:
| 4014 | ||||||||||||||||||||||||||||||
3338 | } | - | ||||||||||||||||||||||||||||||
3339 | insertResult->sizeChangesAfterVisiblePos += item->size() + spacing; | - | ||||||||||||||||||||||||||||||
3340 | pos += item->size() + spacing; | - | ||||||||||||||||||||||||||||||
3341 | ++index; | - | ||||||||||||||||||||||||||||||
3342 | } executed 4816 times by 3 tests: end of block Executed by:
| 4816 | ||||||||||||||||||||||||||||||
3343 | - | |||||||||||||||||||||||||||||||
3344 | if (0 < index && index < visibleItems.count()) {
| 0-1145 | ||||||||||||||||||||||||||||||
3345 | FxViewItem *prevItem = visibleItems.at(index - 1); | - | ||||||||||||||||||||||||||||||
3346 | FxViewItem *item = visibleItems.at(index); | - | ||||||||||||||||||||||||||||||
3347 | if (prevItem->index != item->index - 1) {
| 23-663 | ||||||||||||||||||||||||||||||
3348 | int i = index; | - | ||||||||||||||||||||||||||||||
3349 | qreal prevPos = prevItem->position(); | - | ||||||||||||||||||||||||||||||
3350 | while (i < visibleItems.count()) {
| 23-87 | ||||||||||||||||||||||||||||||
3351 | FxListItemSG *nvItem = static_cast<FxListItemSG *>(visibleItems.takeLast()); | - | ||||||||||||||||||||||||||||||
3352 | insertResult->sizeChangesAfterVisiblePos -= nvItem->size() + spacing; | - | ||||||||||||||||||||||||||||||
3353 | addedItems->removeOne(nvItem); | - | ||||||||||||||||||||||||||||||
3354 | if (nvItem->transitionScheduledOrRunning())
| 2-85 | ||||||||||||||||||||||||||||||
3355 | nvItem->setPosition(prevPos + (nvItem->index - prevItem->index) * averageSize); executed 2 times by 1 test: nvItem->setPosition(prevPos + (nvItem->index - prevItem->index) * averageSize); Executed by:
| 2 | ||||||||||||||||||||||||||||||
3356 | removeItem(nvItem); | - | ||||||||||||||||||||||||||||||
3357 | } executed 87 times by 1 test: end of block Executed by:
| 87 | ||||||||||||||||||||||||||||||
3358 | } executed 23 times by 1 test: end of block Executed by:
| 23 | ||||||||||||||||||||||||||||||
3359 | } executed 686 times by 2 tests: end of block Executed by:
| 686 | ||||||||||||||||||||||||||||||
3360 | } executed 1145 times by 3 tests: end of block Executed by:
| 1145 | ||||||||||||||||||||||||||||||
3361 | - | |||||||||||||||||||||||||||||||
3362 | updateVisibleIndex(); | - | ||||||||||||||||||||||||||||||
3363 | - | |||||||||||||||||||||||||||||||
3364 | return visibleAffected; executed 1194 times by 3 tests: return visibleAffected; Executed by:
| 1194 | ||||||||||||||||||||||||||||||
3365 | } | - | ||||||||||||||||||||||||||||||
3366 | - | |||||||||||||||||||||||||||||||
3367 | void QQuickListViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex, const ChangeResult &insertionResult, const ChangeResult &removalResult) | - | ||||||||||||||||||||||||||||||
3368 | { | - | ||||||||||||||||||||||||||||||
3369 | Q_UNUSED(insertionResult); | - | ||||||||||||||||||||||||||||||
3370 | - | |||||||||||||||||||||||||||||||
3371 | if (!transitioner)
| 0-240 | ||||||||||||||||||||||||||||||
3372 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
3373 | - | |||||||||||||||||||||||||||||||
3374 | int markerItemIndex = -1; | - | ||||||||||||||||||||||||||||||
3375 | for (int i=0; i<visibleItems.count(); i++) {
| 0-4056 | ||||||||||||||||||||||||||||||
3376 | if (visibleItems.at(i)->index == afterModelIndex) {
| 240-3816 | ||||||||||||||||||||||||||||||
3377 | markerItemIndex = i; | - | ||||||||||||||||||||||||||||||
3378 | break; executed 240 times by 2 tests: break; Executed by:
| 240 | ||||||||||||||||||||||||||||||
3379 | } | - | ||||||||||||||||||||||||||||||
3380 | } executed 3816 times by 2 tests: end of block Executed by:
| 3816 | ||||||||||||||||||||||||||||||
3381 | if (markerItemIndex < 0)
| 0-240 | ||||||||||||||||||||||||||||||
3382 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
3383 | - | |||||||||||||||||||||||||||||||
3384 | const qreal viewEndPos = isContentFlowReversed() ? -position() : position() + size();
| 0-240 | ||||||||||||||||||||||||||||||
3385 | qreal sizeRemoved = -removalResult.sizeChangesAfterVisiblePos | - | ||||||||||||||||||||||||||||||
3386 | - (removalResult.countChangeAfterVisibleItems * (averageSize + spacing)); | - | ||||||||||||||||||||||||||||||
3387 | - | |||||||||||||||||||||||||||||||
3388 | for (int i=markerItemIndex+1; i<visibleItems.count(); i++) {
| 120-138 | ||||||||||||||||||||||||||||||
3389 | FxListItemSG *listItem = static_cast<FxListItemSG *>(visibleItems.at(i)); | - | ||||||||||||||||||||||||||||||
3390 | if (listItem->position() >= viewEndPos)
| 18-102 | ||||||||||||||||||||||||||||||
3391 | break; executed 102 times by 1 test: break; Executed by:
| 102 | ||||||||||||||||||||||||||||||
3392 | if (!listItem->transitionScheduledOrRunning()) {
| 0-18 | ||||||||||||||||||||||||||||||
3393 | qreal pos = listItem->position(); | - | ||||||||||||||||||||||||||||||
3394 | listItem->setPosition(pos - sizeRemoved); | - | ||||||||||||||||||||||||||||||
3395 | listItem->transitionNextReposition(transitioner, QQuickItemViewTransitioner::RemoveTransition, false); | - | ||||||||||||||||||||||||||||||
3396 | listItem->setPosition(pos); | - | ||||||||||||||||||||||||||||||
3397 | } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||||||||||||||
3398 | } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||||||||||||||
3399 | } executed 240 times by 2 tests: end of block Executed by:
| 240 | ||||||||||||||||||||||||||||||
3400 | - | |||||||||||||||||||||||||||||||
3401 | /*! | - | ||||||||||||||||||||||||||||||
3402 | \qmlmethod QtQuick::ListView::positionViewAtIndex(int index, PositionMode mode) | - | ||||||||||||||||||||||||||||||
3403 | - | |||||||||||||||||||||||||||||||
3404 | Positions the view such that the \a index is at the position specified by | - | ||||||||||||||||||||||||||||||
3405 | \a mode: | - | ||||||||||||||||||||||||||||||
3406 | - | |||||||||||||||||||||||||||||||
3407 | \list | - | ||||||||||||||||||||||||||||||
3408 | \li ListView.Beginning - position item at the top (or left for horizontal orientation) of the view. | - | ||||||||||||||||||||||||||||||
3409 | \li ListView.Center - position item in the center of the view. | - | ||||||||||||||||||||||||||||||
3410 | \li ListView.End - position item at bottom (or right for horizontal orientation) of the view. | - | ||||||||||||||||||||||||||||||
3411 | \li ListView.Visible - if any part of the item is visible then take no action, otherwise | - | ||||||||||||||||||||||||||||||
3412 | bring the item into view. | - | ||||||||||||||||||||||||||||||
3413 | \li ListView.Contain - ensure the entire item is visible. If the item is larger than | - | ||||||||||||||||||||||||||||||
3414 | the view the item is positioned at the top (or left for horizontal orientation) of the view. | - | ||||||||||||||||||||||||||||||
3415 | \li ListView.SnapPosition - position the item at \l preferredHighlightBegin. This mode | - | ||||||||||||||||||||||||||||||
3416 | is only valid if \l highlightRangeMode is StrictlyEnforceRange or snapping is enabled | - | ||||||||||||||||||||||||||||||
3417 | via \l snapMode. | - | ||||||||||||||||||||||||||||||
3418 | \endlist | - | ||||||||||||||||||||||||||||||
3419 | - | |||||||||||||||||||||||||||||||
3420 | If positioning the view at \a index would cause empty space to be displayed at | - | ||||||||||||||||||||||||||||||
3421 | the beginning or end of the view, the view will be positioned at the boundary. | - | ||||||||||||||||||||||||||||||
3422 | - | |||||||||||||||||||||||||||||||
3423 | It is not recommended to use \l {Flickable::}{contentX} or \l {Flickable::}{contentY} to position the view | - | ||||||||||||||||||||||||||||||
3424 | at a particular index. This is unreliable since removing items from the start | - | ||||||||||||||||||||||||||||||
3425 | of the list does not cause all other items to be repositioned, and because | - | ||||||||||||||||||||||||||||||
3426 | the actual start of the view can vary based on the size of the delegates. | - | ||||||||||||||||||||||||||||||
3427 | The correct way to bring an item into view is with \c positionViewAtIndex. | - | ||||||||||||||||||||||||||||||
3428 | - | |||||||||||||||||||||||||||||||
3429 | \b Note: methods should only be called after the Component has completed. To position | - | ||||||||||||||||||||||||||||||
3430 | the view at startup, this method should be called by Component.onCompleted. For | - | ||||||||||||||||||||||||||||||
3431 | example, to position the view at the end: | - | ||||||||||||||||||||||||||||||
3432 | - | |||||||||||||||||||||||||||||||
3433 | \code | - | ||||||||||||||||||||||||||||||
3434 | Component.onCompleted: positionViewAtIndex(count - 1, ListView.Beginning) | - | ||||||||||||||||||||||||||||||
3435 | \endcode | - | ||||||||||||||||||||||||||||||
3436 | */ | - | ||||||||||||||||||||||||||||||
3437 | - | |||||||||||||||||||||||||||||||
3438 | /*! | - | ||||||||||||||||||||||||||||||
3439 | \qmlmethod QtQuick::ListView::positionViewAtBeginning() | - | ||||||||||||||||||||||||||||||
3440 | \qmlmethod QtQuick::ListView::positionViewAtEnd() | - | ||||||||||||||||||||||||||||||
3441 | - | |||||||||||||||||||||||||||||||
3442 | Positions the view at the beginning or end, taking into account any header or footer. | - | ||||||||||||||||||||||||||||||
3443 | - | |||||||||||||||||||||||||||||||
3444 | It is not recommended to use \l {Flickable::}{contentX} or \l {Flickable::}{contentY} to position the view | - | ||||||||||||||||||||||||||||||
3445 | at a particular index. This is unreliable since removing items from the start | - | ||||||||||||||||||||||||||||||
3446 | of the list does not cause all other items to be repositioned, and because | - | ||||||||||||||||||||||||||||||
3447 | the actual start of the view can vary based on the size of the delegates. | - | ||||||||||||||||||||||||||||||
3448 | - | |||||||||||||||||||||||||||||||
3449 | \b Note: methods should only be called after the Component has completed. To position | - | ||||||||||||||||||||||||||||||
3450 | the view at startup, this method should be called by Component.onCompleted. For | - | ||||||||||||||||||||||||||||||
3451 | example, to position the view at the end on startup: | - | ||||||||||||||||||||||||||||||
3452 | - | |||||||||||||||||||||||||||||||
3453 | \code | - | ||||||||||||||||||||||||||||||
3454 | Component.onCompleted: positionViewAtEnd() | - | ||||||||||||||||||||||||||||||
3455 | \endcode | - | ||||||||||||||||||||||||||||||
3456 | */ | - | ||||||||||||||||||||||||||||||
3457 | - | |||||||||||||||||||||||||||||||
3458 | /*! | - | ||||||||||||||||||||||||||||||
3459 | \qmlmethod int QtQuick::ListView::indexAt(real x, real y) | - | ||||||||||||||||||||||||||||||
3460 | - | |||||||||||||||||||||||||||||||
3461 | Returns the index of the visible item containing the point \a x, \a y in content | - | ||||||||||||||||||||||||||||||
3462 | coordinates. If there is no item at the point specified, or the item is | - | ||||||||||||||||||||||||||||||
3463 | not visible -1 is returned. | - | ||||||||||||||||||||||||||||||
3464 | - | |||||||||||||||||||||||||||||||
3465 | If the item is outside the visible area, -1 is returned, regardless of | - | ||||||||||||||||||||||||||||||
3466 | whether an item will exist at that point when scrolled into view. | - | ||||||||||||||||||||||||||||||
3467 | - | |||||||||||||||||||||||||||||||
3468 | \b Note: methods should only be called after the Component has completed. | - | ||||||||||||||||||||||||||||||
3469 | */ | - | ||||||||||||||||||||||||||||||
3470 | - | |||||||||||||||||||||||||||||||
3471 | /*! | - | ||||||||||||||||||||||||||||||
3472 | \qmlmethod Item QtQuick::ListView::itemAt(real x, real y) | - | ||||||||||||||||||||||||||||||
3473 | - | |||||||||||||||||||||||||||||||
3474 | Returns the visible item containing the point \a x, \a y in content | - | ||||||||||||||||||||||||||||||
3475 | coordinates. If there is no item at the point specified, or the item is | - | ||||||||||||||||||||||||||||||
3476 | not visible null is returned. | - | ||||||||||||||||||||||||||||||
3477 | - | |||||||||||||||||||||||||||||||
3478 | If the item is outside the visible area, null is returned, regardless of | - | ||||||||||||||||||||||||||||||
3479 | whether an item will exist at that point when scrolled into view. | - | ||||||||||||||||||||||||||||||
3480 | - | |||||||||||||||||||||||||||||||
3481 | \b Note: methods should only be called after the Component has completed. | - | ||||||||||||||||||||||||||||||
3482 | */ | - | ||||||||||||||||||||||||||||||
3483 | - | |||||||||||||||||||||||||||||||
3484 | /*! | - | ||||||||||||||||||||||||||||||
3485 | \qmlmethod QtQuick::ListView::forceLayout() | - | ||||||||||||||||||||||||||||||
3486 | - | |||||||||||||||||||||||||||||||
3487 | Responding to changes in the model is usually batched to happen only once | - | ||||||||||||||||||||||||||||||
3488 | per frame. This means that inside script blocks it is possible for the | - | ||||||||||||||||||||||||||||||
3489 | underlying model to have changed, but the ListView has not caught up yet. | - | ||||||||||||||||||||||||||||||
3490 | - | |||||||||||||||||||||||||||||||
3491 | This method forces the ListView to immediately respond to any outstanding | - | ||||||||||||||||||||||||||||||
3492 | changes in the model. | - | ||||||||||||||||||||||||||||||
3493 | - | |||||||||||||||||||||||||||||||
3494 | \since 5.1 | - | ||||||||||||||||||||||||||||||
3495 | - | |||||||||||||||||||||||||||||||
3496 | \b Note: methods should only be called after the Component has completed. | - | ||||||||||||||||||||||||||||||
3497 | */ | - | ||||||||||||||||||||||||||||||
3498 | - | |||||||||||||||||||||||||||||||
3499 | QQuickListViewAttached *QQuickListView::qmlAttachedProperties(QObject *obj) | - | ||||||||||||||||||||||||||||||
3500 | { | - | ||||||||||||||||||||||||||||||
3501 | return new QQuickListViewAttached(obj); executed 32708 times by 10 tests: return new QQuickListViewAttached(obj); Executed by:
| 32708 | ||||||||||||||||||||||||||||||
3502 | } | - | ||||||||||||||||||||||||||||||
3503 | - | |||||||||||||||||||||||||||||||
3504 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||||||||
3505 | - | |||||||||||||||||||||||||||||||
3506 | #include "moc_qquicklistview_p.cpp" | - | ||||||||||||||||||||||||||||||
Source code | Switch to Preprocessed file |