Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickpathview_p_p.h |
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 | #ifndef QQUICKPATHVIEW_P_P_H | - | ||||||||||||||||||
41 | #define QQUICKPATHVIEW_P_P_H | - | ||||||||||||||||||
42 | - | |||||||||||||||||||
43 | // | - | ||||||||||||||||||
44 | // W A R N I N G | - | ||||||||||||||||||
45 | // ------------- | - | ||||||||||||||||||
46 | // | - | ||||||||||||||||||
47 | // This file is not part of the Qt API. It exists purely as an | - | ||||||||||||||||||
48 | // implementation detail. This header file may change from version to | - | ||||||||||||||||||
49 | // version without notice, or even be removed. | - | ||||||||||||||||||
50 | // | - | ||||||||||||||||||
51 | // We mean it. | - | ||||||||||||||||||
52 | // | - | ||||||||||||||||||
53 | - | |||||||||||||||||||
54 | #include <private/qtquickglobal_p.h> | - | ||||||||||||||||||
55 | - | |||||||||||||||||||
56 | QT_REQUIRE_CONFIG(quick_pathview); | - | ||||||||||||||||||
57 | - | |||||||||||||||||||
58 | #include "qquickpathview_p.h" | - | ||||||||||||||||||
59 | #include "qquickitem_p.h" | - | ||||||||||||||||||
60 | - | |||||||||||||||||||
61 | #include <QtQml/qqml.h> | - | ||||||||||||||||||
62 | #include <QtCore/qdatetime.h> | - | ||||||||||||||||||
63 | #include <QtCore/qcoreapplication.h> | - | ||||||||||||||||||
64 | - | |||||||||||||||||||
65 | #include <private/qquickanimation_p_p.h> | - | ||||||||||||||||||
66 | #include <private/qqmldelegatemodel_p.h> | - | ||||||||||||||||||
67 | #include <private/qquicktimeline_p_p.h> | - | ||||||||||||||||||
68 | #include <private/qpodvector_p.h> | - | ||||||||||||||||||
69 | - | |||||||||||||||||||
70 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
71 | - | |||||||||||||||||||
72 | class QQmlOpenMetaObjectType; | - | ||||||||||||||||||
73 | class QQuickPathViewAttached; | - | ||||||||||||||||||
74 | class QQuickPathViewPrivate : public QQuickItemPrivate, public QQuickItemChangeListener | - | ||||||||||||||||||
75 | { | - | ||||||||||||||||||
76 | Q_DECLARE_PUBLIC(QQuickPathView) | - | ||||||||||||||||||
77 | - | |||||||||||||||||||
78 | public: | - | ||||||||||||||||||
79 | QQuickPathViewPrivate(); | - | ||||||||||||||||||
80 | - | |||||||||||||||||||
81 | void init(); | - | ||||||||||||||||||
82 | - | |||||||||||||||||||
83 | void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &) override { | - | ||||||||||||||||||
84 | if (change.sizeChange() && (!highlightItem || item != highlightItem)) {
| 0-58250 | ||||||||||||||||||
85 | if (QQuickPathViewAttached *att = attached(item))
| 0-10 | ||||||||||||||||||
86 | att->m_percent = -1; executed 10 times by 1 test: att->m_percent = -1; Executed by:
| 10 | ||||||||||||||||||
87 | scheduleLayout(); | - | ||||||||||||||||||
88 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||
89 | } executed 58260 times by 3 tests: end of block Executed by:
| 58260 | ||||||||||||||||||
90 | - | |||||||||||||||||||
91 | void scheduleLayout() { | - | ||||||||||||||||||
92 | Q_Q(QQuickPathView); | - | ||||||||||||||||||
93 | if (!layoutScheduled) {
| 24-142 | ||||||||||||||||||
94 | layoutScheduled = true; | - | ||||||||||||||||||
95 | q->polish(); | - | ||||||||||||||||||
96 | } executed 142 times by 2 tests: end of block Executed by:
| 142 | ||||||||||||||||||
97 | } executed 166 times by 2 tests: end of block Executed by:
| 166 | ||||||||||||||||||
98 | - | |||||||||||||||||||
99 | QQuickItem *getItem(int modelIndex, qreal z = 0, bool async=false); | - | ||||||||||||||||||
100 | void releaseItem(QQuickItem *item); | - | ||||||||||||||||||
101 | QQuickPathViewAttached *attached(QQuickItem *item); | - | ||||||||||||||||||
102 | QQmlOpenMetaObjectType *attachedType(); | - | ||||||||||||||||||
103 | void clear(); | - | ||||||||||||||||||
104 | void updateMappedRange(); | - | ||||||||||||||||||
105 | qreal positionOfIndex(qreal index) const; | - | ||||||||||||||||||
106 | bool isInBound(qreal position, qreal lower, qreal upper) const; | - | ||||||||||||||||||
107 | void createHighlight(); | - | ||||||||||||||||||
108 | void updateHighlight(); | - | ||||||||||||||||||
109 | void setHighlightPosition(qreal pos); | - | ||||||||||||||||||
110 | bool isValid() const { | - | ||||||||||||||||||
111 | return model && model->count() > 0 && model->isValid() && path; executed 9019 times by 3 tests: return model && model->count() > 0 && model->isValid() && path; Executed by:
| 9019 | ||||||||||||||||||
112 | } | - | ||||||||||||||||||
113 | - | |||||||||||||||||||
114 | void handleMousePressEvent(QMouseEvent *event); | - | ||||||||||||||||||
115 | void handleMouseMoveEvent(QMouseEvent *event); | - | ||||||||||||||||||
116 | void handleMouseReleaseEvent(QMouseEvent *); | - | ||||||||||||||||||
117 | - | |||||||||||||||||||
118 | int calcCurrentIndex(); | - | ||||||||||||||||||
119 | void createCurrentItem(); | - | ||||||||||||||||||
120 | void updateCurrent(); | - | ||||||||||||||||||
121 | static void fixOffsetCallback(void*); | - | ||||||||||||||||||
122 | void fixOffset(); | - | ||||||||||||||||||
123 | void setOffset(qreal offset); | - | ||||||||||||||||||
124 | void setAdjustedOffset(qreal offset); | - | ||||||||||||||||||
125 | void regenerate(); | - | ||||||||||||||||||
126 | void updateItem(QQuickItem *, qreal); | - | ||||||||||||||||||
127 | enum MovementReason { Other, SetIndex, Mouse }; | - | ||||||||||||||||||
128 | void snapToIndex(int index, MovementReason reason); | - | ||||||||||||||||||
129 | QPointF pointNear(const QPointF &point, qreal *nearPercent=0) const; | - | ||||||||||||||||||
130 | void addVelocitySample(qreal v); | - | ||||||||||||||||||
131 | qreal calcVelocity() const; | - | ||||||||||||||||||
132 | qint64 computeCurrentTime(QInputEvent *event) const; | - | ||||||||||||||||||
133 | void setDragging(bool d); | - | ||||||||||||||||||
134 | - | |||||||||||||||||||
135 | QQuickPath *path; | - | ||||||||||||||||||
136 | int currentIndex; | - | ||||||||||||||||||
137 | QPointer<QQuickItem> currentItem; | - | ||||||||||||||||||
138 | qreal currentItemOffset; | - | ||||||||||||||||||
139 | qreal startPc; | - | ||||||||||||||||||
140 | QPointF startPoint; | - | ||||||||||||||||||
141 | QPointF startPos; | - | ||||||||||||||||||
142 | qreal offset; | - | ||||||||||||||||||
143 | qreal offsetAdj; | - | ||||||||||||||||||
144 | qreal mappedRange; | - | ||||||||||||||||||
145 | qreal mappedCache; | - | ||||||||||||||||||
146 | bool stealMouse : 1; | - | ||||||||||||||||||
147 | bool ownModel : 1; | - | ||||||||||||||||||
148 | bool interactive : 1; | - | ||||||||||||||||||
149 | bool haveHighlightRange : 1; | - | ||||||||||||||||||
150 | bool autoHighlight : 1; | - | ||||||||||||||||||
151 | bool highlightUp : 1; | - | ||||||||||||||||||
152 | bool layoutScheduled : 1; | - | ||||||||||||||||||
153 | bool moving : 1; | - | ||||||||||||||||||
154 | bool flicking : 1; | - | ||||||||||||||||||
155 | bool dragging : 1; | - | ||||||||||||||||||
156 | bool inRequest : 1; | - | ||||||||||||||||||
157 | bool delegateValidated : 1; | - | ||||||||||||||||||
158 | bool inRefill : 1; | - | ||||||||||||||||||
159 | QElapsedTimer timer; | - | ||||||||||||||||||
160 | qint64 lastPosTime; | - | ||||||||||||||||||
161 | QPointF lastPos; | - | ||||||||||||||||||
162 | qreal dragMargin; | - | ||||||||||||||||||
163 | qreal deceleration; | - | ||||||||||||||||||
164 | qreal maximumFlickVelocity; | - | ||||||||||||||||||
165 | QQuickTimeLine tl; | - | ||||||||||||||||||
166 | QQuickTimeLineValueProxy<QQuickPathViewPrivate> moveOffset; | - | ||||||||||||||||||
167 | int flickDuration; | - | ||||||||||||||||||
168 | int pathItems; | - | ||||||||||||||||||
169 | int requestedIndex; | - | ||||||||||||||||||
170 | int cacheSize; | - | ||||||||||||||||||
171 | qreal requestedZ; | - | ||||||||||||||||||
172 | QList<QQuickItem *> items; | - | ||||||||||||||||||
173 | QList<QQuickItem *> itemCache; | - | ||||||||||||||||||
174 | QPointer<QQmlInstanceModel> model; | - | ||||||||||||||||||
175 | QVariant modelVariant; | - | ||||||||||||||||||
176 | MovementReason moveReason; | - | ||||||||||||||||||
177 | QQuickPathView::MovementDirection movementDirection; // default | - | ||||||||||||||||||
178 | QQuickPathView::MovementDirection moveDirection; // next movement | - | ||||||||||||||||||
179 | QQmlOpenMetaObjectType *attType; | - | ||||||||||||||||||
180 | QQmlComponent *highlightComponent; | - | ||||||||||||||||||
181 | QQuickItem *highlightItem; | - | ||||||||||||||||||
182 | QQuickTimeLineValueProxy<QQuickPathViewPrivate> moveHighlight; | - | ||||||||||||||||||
183 | qreal highlightPosition; | - | ||||||||||||||||||
184 | qreal highlightRangeStart; | - | ||||||||||||||||||
185 | qreal highlightRangeEnd; | - | ||||||||||||||||||
186 | QQuickPathView::HighlightRangeMode highlightRangeMode; | - | ||||||||||||||||||
187 | int highlightMoveDuration; | - | ||||||||||||||||||
188 | int modelCount; | - | ||||||||||||||||||
189 | QPODVector<qreal,10> velocityBuffer; | - | ||||||||||||||||||
190 | QQuickPathView::SnapMode snapMode; | - | ||||||||||||||||||
191 | }; | - | ||||||||||||||||||
192 | - | |||||||||||||||||||
193 | QT_END_NAMESPACE | - | ||||||||||||||||||
194 | - | |||||||||||||||||||
195 | #endif | - | ||||||||||||||||||
Source code | Switch to Preprocessed file |