Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickitemview_p_p.h |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | static_assert(bool(1 == 1), "Required feature " "quick_itemview" " for file " __FILE__ " not available."); | - | ||||||
3 | - | |||||||
4 | - | |||||||
5 | - | |||||||
6 | - | |||||||
7 | - | |||||||
8 | - | |||||||
9 | - | |||||||
10 | class __attribute__((visibility("default"))) FxViewItem : public QQuickItemViewFxItem | - | ||||||
11 | { | - | ||||||
12 | public: | - | ||||||
13 | FxViewItem(QQuickItem *, QQuickItemView *, bool own, QQuickItemViewAttached *attached); | - | ||||||
14 | - | |||||||
15 | QQuickItemView *view; | - | ||||||
16 | QQuickItemViewAttached *attached; | - | ||||||
17 | }; | - | ||||||
18 | - | |||||||
19 | - | |||||||
20 | class QQuickItemViewChangeSet | - | ||||||
21 | { | - | ||||||
22 | public: | - | ||||||
23 | QQuickItemViewChangeSet(); | - | ||||||
24 | - | |||||||
25 | bool hasPendingChanges() const; | - | ||||||
26 | void prepare(int currentIndex, int count); | - | ||||||
27 | void reset(); | - | ||||||
28 | - | |||||||
29 | void applyChanges(const QQmlChangeSet &changeSet); | - | ||||||
30 | - | |||||||
31 | void applyBufferedChanges(const QQuickItemViewChangeSet &other); | - | ||||||
32 | - | |||||||
33 | int itemCount; | - | ||||||
34 | int newCurrentIndex; | - | ||||||
35 | QQmlChangeSet pendingChanges; | - | ||||||
36 | QHash<QQmlChangeSet::MoveKey, FxViewItem *> removedItems; | - | ||||||
37 | - | |||||||
38 | bool active : 1; | - | ||||||
39 | bool currentChanged : 1; | - | ||||||
40 | bool currentRemoved : 1; | - | ||||||
41 | }; | - | ||||||
42 | - | |||||||
43 | - | |||||||
44 | class __attribute__((visibility("default"))) QQuickItemViewPrivate : public QQuickFlickablePrivate, public QQuickItemViewTransitionChangeListener, public QAnimationJobChangeListener | - | ||||||
45 | { | - | ||||||
46 | inline QQuickItemView* q_func() { return static_cast<QQuickItemView *>(q_ptr); } inline const QQuickItemView* q_func() const { return static_cast<const QQuickItemView *>(q_ptr); } friend class QQuickItemView; | - | ||||||
47 | public: | - | ||||||
48 | QQuickItemViewPrivate(); | - | ||||||
49 | ~QQuickItemViewPrivate(); | - | ||||||
50 | - | |||||||
51 | static inline QQuickItemViewPrivate *get(QQuickItemView *o) { return executed 88082 times by 11 tests: o->d_func();return o->d_func(); Executed by:
executed 88082 times by 11 tests: }return o->d_func(); Executed by:
| 88082 | ||||||
52 | - | |||||||
53 | struct ChangeResult { | - | ||||||
54 | QQmlNullableValue<qreal> visiblePos; | - | ||||||
55 | bool changedFirstItem; | - | ||||||
56 | qreal sizeChangesBeforeVisiblePos; | - | ||||||
57 | qreal sizeChangesAfterVisiblePos; | - | ||||||
58 | int countChangeBeforeVisible; | - | ||||||
59 | int countChangeAfterVisibleItems; | - | ||||||
60 | - | |||||||
61 | ChangeResult() | - | ||||||
62 | : visiblePos(0), changedFirstItem(false), | - | ||||||
63 | sizeChangesBeforeVisiblePos(0), sizeChangesAfterVisiblePos(0), | - | ||||||
64 | countChangeBeforeVisible(0), countChangeAfterVisibleItems(0) {} executed 14770 times by 8 tests: end of block Executed by:
| 14770 | ||||||
65 | - | |||||||
66 | ChangeResult(const QQmlNullableValue<qreal> &p) | - | ||||||
67 | : visiblePos(p), changedFirstItem(false), | - | ||||||
68 | sizeChangesBeforeVisiblePos(0), sizeChangesAfterVisiblePos(0), | - | ||||||
69 | countChangeBeforeVisible(0), countChangeAfterVisibleItems(0) {} executed 7662 times by 4 tests: end of block Executed by:
| 7662 | ||||||
70 | - | |||||||
71 | ChangeResult &operator+=(const ChangeResult &other) { | - | ||||||
72 | if (&other == this
| 0-6354 | ||||||
73 | return never executed: *this;return *this; never executed: return *this; | 0 | ||||||
74 | changedFirstItem &= other.changedFirstItem; | - | ||||||
75 | sizeChangesBeforeVisiblePos += other.sizeChangesBeforeVisiblePos; | - | ||||||
76 | sizeChangesAfterVisiblePos += other.sizeChangesAfterVisiblePos; | - | ||||||
77 | countChangeBeforeVisible += other.countChangeBeforeVisible; | - | ||||||
78 | countChangeAfterVisibleItems += other.countChangeAfterVisibleItems; | - | ||||||
79 | return executed 6354 times by 4 tests: *this;return *this; Executed by:
executed 6354 times by 4 tests: return *this; Executed by:
| 6354 | ||||||
80 | } | - | ||||||
81 | - | |||||||
82 | void reset() { | - | ||||||
83 | changedFirstItem = false; | - | ||||||
84 | sizeChangesBeforeVisiblePos = 0.0; | - | ||||||
85 | sizeChangesAfterVisiblePos = 0.0; | - | ||||||
86 | countChangeBeforeVisible = 0; | - | ||||||
87 | countChangeAfterVisibleItems = 0; | - | ||||||
88 | } executed 8894 times by 3 tests: end of block Executed by:
| 8894 | ||||||
89 | }; | - | ||||||
90 | - | |||||||
91 | enum BufferMode { NoBuffer = 0x00, BufferBefore = 0x01, BufferAfter = 0x02 }; | - | ||||||
92 | enum MovementReason { Other, SetIndex, Mouse }; | - | ||||||
93 | - | |||||||
94 | bool isValid() const; | - | ||||||
95 | qreal position() const; | - | ||||||
96 | qreal size() const; | - | ||||||
97 | qreal startPosition() const; | - | ||||||
98 | qreal endPosition() const; | - | ||||||
99 | qreal contentStartOffset() const; | - | ||||||
100 | int findLastVisibleIndex(int defaultValue = -1) const; | - | ||||||
101 | FxViewItem *visibleItem(int modelIndex) const; | - | ||||||
102 | FxViewItem *firstVisibleItem() const; | - | ||||||
103 | int findLastIndexInView() const; | - | ||||||
104 | int mapFromModel(int modelIndex) const; | - | ||||||
105 | - | |||||||
106 | virtual void init(); | - | ||||||
107 | virtual void clear(); | - | ||||||
108 | virtual void updateViewport(); | - | ||||||
109 | - | |||||||
110 | void regenerate(bool orientationChanged=false); | - | ||||||
111 | void layout(); | - | ||||||
112 | void animationFinished(QAbstractAnimationJob *) override; | - | ||||||
113 | void refill(); | - | ||||||
114 | void refill(qreal from, qreal to); | - | ||||||
115 | void mirrorChange() override; | - | ||||||
116 | - | |||||||
117 | FxViewItem *createItem(int modelIndex,QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested); | - | ||||||
118 | virtual bool releaseItem(FxViewItem *item); | - | ||||||
119 | - | |||||||
120 | QQuickItem *createHighlightItem() const; | - | ||||||
121 | QQuickItem *createComponentItem(QQmlComponent *component, qreal zValue, bool createDefault = false) const; | - | ||||||
122 | - | |||||||
123 | void updateCurrent(int modelIndex); | - | ||||||
124 | void updateTrackedItem(); | - | ||||||
125 | void updateUnrequestedIndexes(); | - | ||||||
126 | void updateUnrequestedPositions(); | - | ||||||
127 | void updateVisibleIndex(); | - | ||||||
128 | void positionViewAtIndex(int index, int mode); | - | ||||||
129 | - | |||||||
130 | qreal minExtentForAxis(const AxisData &axisData, bool forXAxis) const; | - | ||||||
131 | qreal maxExtentForAxis(const AxisData &axisData, bool forXAxis) const; | - | ||||||
132 | qreal calculatedMinExtent() const; | - | ||||||
133 | qreal calculatedMaxExtent() const; | - | ||||||
134 | - | |||||||
135 | void applyPendingChanges(); | - | ||||||
136 | bool applyModelChanges(ChangeResult *insertionResult, ChangeResult *removalResult); | - | ||||||
137 | bool applyRemovalChange(const QQmlChangeSet::Change &removal, ChangeResult *changeResult, int *removedCount); | - | ||||||
138 | void removeItem(FxViewItem *item, const QQmlChangeSet::Change &removal, ChangeResult *removeResult); | - | ||||||
139 | virtual void updateSizeChangesBeforeVisiblePos(FxViewItem *item, ChangeResult *removeResult); | - | ||||||
140 | void repositionFirstItem(FxViewItem *prevVisibleItemsFirst, qreal prevVisibleItemsFirstPos, | - | ||||||
141 | FxViewItem *prevFirstVisible, ChangeResult *insertionResult, ChangeResult *removalResult); | - | ||||||
142 | - | |||||||
143 | void createTransitioner(); | - | ||||||
144 | void prepareVisibleItemTransitions(); | - | ||||||
145 | void prepareRemoveTransitions(QHash<QQmlChangeSet::MoveKey, FxViewItem *> *removedItems); | - | ||||||
146 | bool prepareNonVisibleItemTransition(FxViewItem *item, const QRectF &viewBounds); | - | ||||||
147 | void viewItemTransitionFinished(QQuickItemViewTransitionableItem *item) override; | - | ||||||
148 | - | |||||||
149 | int findMoveKeyIndex(QQmlChangeSet::MoveKey key, const QVector<QQmlChangeSet::Change> &changes) const; | - | ||||||
150 | - | |||||||
151 | void checkVisible() const; | - | ||||||
152 | void showVisibleItems() const; | - | ||||||
153 | - | |||||||
154 | void markExtentsDirty() { | - | ||||||
155 | if (layoutOrientation() == Qt::Vertical
| 6528-28216 | ||||||
156 | vData.markExtentsDirty(); executed 28216 times by 12 tests: vData.markExtentsDirty(); Executed by:
| 28216 | ||||||
157 | else | - | ||||||
158 | hData.markExtentsDirty(); executed 6528 times by 3 tests: hData.markExtentsDirty(); Executed by:
| 6528 | ||||||
159 | } | - | ||||||
160 | - | |||||||
161 | bool hasPendingChanges() const { | - | ||||||
162 | return executed 27099 times by 8 tests: currentChanges.hasPendingChanges()return currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() ||runDelayedRemoveTransition; Executed by:
executed 27099 times by 8 tests: return currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() ||runDelayedRemoveTransition; Executed by:
| 27099 | ||||||
163 | || bufferedChanges.hasPendingChanges() executed 27099 times by 8 tests: return currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() ||runDelayedRemoveTransition; Executed by:
| 27099 | ||||||
164 | ||runDelayedRemoveTransition; executed 27099 times by 8 tests: return currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() ||runDelayedRemoveTransition; Executed by:
| 27099 | ||||||
165 | } | - | ||||||
166 | - | |||||||
167 | void refillOrLayout() { | - | ||||||
168 | if (hasPendingChanges()
| 31-16757 | ||||||
169 | layout(); executed 31 times by 2 tests: layout(); Executed by:
| 31 | ||||||
170 | else | - | ||||||
171 | refill(); executed 16757 times by 5 tests: refill(); Executed by:
| 16757 | ||||||
172 | } | - | ||||||
173 | - | |||||||
174 | void forceLayoutPolish() { | - | ||||||
175 | QQuickItemView * const q = q_func(); | - | ||||||
176 | forceLayout = true; | - | ||||||
177 | q->polish(); | - | ||||||
178 | } executed 7637 times by 11 tests: end of block Executed by:
| 7637 | ||||||
179 | - | |||||||
180 | void releaseVisibleItems() { | - | ||||||
181 | - | |||||||
182 | - | |||||||
183 | const QList<FxViewItem *> oldVisible = visibleItems; | - | ||||||
184 | visibleItems.clear(); | - | ||||||
185 | for (FxViewItem *item : oldVisible) | - | ||||||
186 | releaseItem(item); executed 61007 times by 10 tests: releaseItem(item); Executed by:
| 61007 | ||||||
187 | } executed 11450 times by 12 tests: end of block Executed by:
| 11450 | ||||||
188 | - | |||||||
189 | QPointer<QQmlInstanceModel> model; | - | ||||||
190 | QVariant modelVariant; | - | ||||||
191 | int itemCount; | - | ||||||
192 | int buffer; | - | ||||||
193 | int bufferMode; | - | ||||||
194 | int displayMarginBeginning; | - | ||||||
195 | int displayMarginEnd; | - | ||||||
196 | Qt::LayoutDirection layoutDirection; | - | ||||||
197 | QQuickItemView::VerticalLayoutDirection verticalLayoutDirection; | - | ||||||
198 | - | |||||||
199 | MovementReason moveReason; | - | ||||||
200 | - | |||||||
201 | QList<FxViewItem *> visibleItems; | - | ||||||
202 | int visibleIndex; | - | ||||||
203 | int currentIndex; | - | ||||||
204 | FxViewItem *currentItem; | - | ||||||
205 | FxViewItem *trackedItem; | - | ||||||
206 | QHash<QQuickItem*,int> unrequestedItems; | - | ||||||
207 | int requestedIndex; | - | ||||||
208 | QQuickItemViewChangeSet currentChanges; | - | ||||||
209 | QQuickItemViewChangeSet bufferedChanges; | - | ||||||
210 | QPauseAnimationJob bufferPause; | - | ||||||
211 | - | |||||||
212 | QQmlComponent *highlightComponent; | - | ||||||
213 | FxViewItem *highlight; | - | ||||||
214 | int highlightRange; | - | ||||||
215 | qreal highlightRangeStart; | - | ||||||
216 | qreal highlightRangeEnd; | - | ||||||
217 | int highlightMoveDuration; | - | ||||||
218 | - | |||||||
219 | QQmlComponent *headerComponent; | - | ||||||
220 | FxViewItem *header; | - | ||||||
221 | QQmlComponent *footerComponent; | - | ||||||
222 | FxViewItem *footer; | - | ||||||
223 | - | |||||||
224 | struct MovedItem { | - | ||||||
225 | FxViewItem *item; | - | ||||||
226 | QQmlChangeSet::MoveKey moveKey; | - | ||||||
227 | MovedItem(FxViewItem *i, QQmlChangeSet::MoveKey k) | - | ||||||
228 | : item(i), moveKey(k) {} executed 90 times by 2 tests: end of block Executed by:
| 90 | ||||||
229 | }; | - | ||||||
230 | QQuickItemViewTransitioner *transitioner; | - | ||||||
231 | QList<FxViewItem *> releasePendingTransition; | - | ||||||
232 | - | |||||||
233 | mutable qreal minExtent; | - | ||||||
234 | mutable qreal maxExtent; | - | ||||||
235 | - | |||||||
236 | bool ownModel : 1; | - | ||||||
237 | bool wrap : 1; | - | ||||||
238 | bool keyNavigationEnabled : 1; | - | ||||||
239 | bool explicitKeyNavigationEnabled : 1; | - | ||||||
240 | bool inLayout : 1; | - | ||||||
241 | bool inViewportMoved : 1; | - | ||||||
242 | bool forceLayout : 1; | - | ||||||
243 | bool currentIndexCleared : 1; | - | ||||||
244 | bool haveHighlightRange : 1; | - | ||||||
245 | bool autoHighlight : 1; | - | ||||||
246 | bool highlightRangeStartValid : 1; | - | ||||||
247 | bool highlightRangeEndValid : 1; | - | ||||||
248 | bool fillCacheBuffer : 1; | - | ||||||
249 | bool inRequest : 1; | - | ||||||
250 | bool runDelayedRemoveTransition : 1; | - | ||||||
251 | bool delegateValidated : 1; | - | ||||||
252 | - | |||||||
253 | protected: | - | ||||||
254 | virtual Qt::Orientation layoutOrientation() const = 0; | - | ||||||
255 | virtual bool isContentFlowReversed() const = 0; | - | ||||||
256 | - | |||||||
257 | virtual qreal positionAt(int index) const = 0; | - | ||||||
258 | virtual qreal endPositionAt(int index) const = 0; | - | ||||||
259 | virtual qreal originPosition() const = 0; | - | ||||||
260 | virtual qreal lastPosition() const = 0; | - | ||||||
261 | - | |||||||
262 | virtual qreal headerSize() const = 0; | - | ||||||
263 | virtual qreal footerSize() const = 0; | - | ||||||
264 | virtual bool showHeaderForIndex(int index) const = 0; | - | ||||||
265 | virtual bool showFooterForIndex(int index) const = 0; | - | ||||||
266 | virtual void updateHeader() = 0; | - | ||||||
267 | virtual void updateFooter() = 0; | - | ||||||
268 | virtual bool hasStickyHeader() const { return executed 130 times by 1 test: false;return false; Executed by:
executed 130 times by 1 test: }return false; Executed by:
| 130 | ||||||
269 | virtual bool hasStickyFooter() const { return executed 130 times by 1 test: false;return false; Executed by:
executed 130 times by 1 test: }return false; Executed by:
| 130 | ||||||
270 | - | |||||||
271 | virtual void createHighlight() = 0; | - | ||||||
272 | virtual void updateHighlight() = 0; | - | ||||||
273 | virtual void resetHighlightPosition() = 0; | - | ||||||
274 | virtual bool movingFromHighlight() { return executed 3523 times by 4 tests: false;return false; Executed by:
executed 3523 times by 4 tests: }return false; Executed by:
| 3523 | ||||||
275 | - | |||||||
276 | virtual void setPosition(qreal pos) = 0; | - | ||||||
277 | virtual void fixupPosition() = 0; | - | ||||||
278 | - | |||||||
279 | virtual bool addVisibleItems(qreal fillFrom, qreal fillTo, qreal bufferFrom, qreal bufferTo, bool doBuffer) = 0; | - | ||||||
280 | virtual bool removeNonVisibleItems(qreal bufferFrom, qreal bufferTo) = 0; | - | ||||||
281 | virtual void visibleItemsChanged() {} | - | ||||||
282 | - | |||||||
283 | virtual FxViewItem *newViewItem(int index, QQuickItem *item) = 0; | - | ||||||
284 | virtual void repositionItemAt(FxViewItem *item, int index, qreal sizeBuffer) = 0; | - | ||||||
285 | virtual void repositionPackageItemAt(QQuickItem *item, int index) = 0; | - | ||||||
286 | virtual void resetFirstItemPosition(qreal pos = 0.0) = 0; | - | ||||||
287 | virtual void adjustFirstItem(qreal forwards, qreal backwards, int changeBeforeVisible) = 0; | - | ||||||
288 | - | |||||||
289 | virtual void layoutVisibleItems(int fromModelIndex = 0) = 0; | - | ||||||
290 | virtual void changedVisibleIndex(int newIndex) = 0; | - | ||||||
291 | - | |||||||
292 | virtual bool applyInsertionChange(const QQmlChangeSet::Change &insert, ChangeResult *changeResult, | - | ||||||
293 | QList<FxViewItem *> *newItems, QList<MovedItem> *movingIntoView) = 0; | - | ||||||
294 | - | |||||||
295 | virtual bool needsRefillForAddedOrRemovedIndex(int) const { return executed 79 times by 1 test: false;return false; Executed by:
executed 79 times by 1 test: }return false; Executed by:
| 79 | ||||||
296 | virtual void translateAndTransitionItemsAfter(int afterIndex, const ChangeResult &insertionResult, const ChangeResult &removalResult) = 0; | - | ||||||
297 | - | |||||||
298 | virtual void initializeViewItem(FxViewItem *) {} | - | ||||||
299 | virtual void initializeCurrentItem() {} | - | ||||||
300 | virtual void updateSectionCriteria() {} | - | ||||||
301 | virtual void updateSections() {} | - | ||||||
302 | - | |||||||
303 | void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &) override; | - | ||||||
304 | }; | - | ||||||
305 | - | |||||||
306 | - | |||||||
307 | - | |||||||
Switch to Source code | Preprocessed file |