Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickflipable.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | - | |||||||||||||
8 | class QQuickLocalTransform : public QQuickTransform | - | ||||||||||||
9 | { | - | ||||||||||||
10 | public: | - | ||||||||||||
11 | #pragma GCC diagnostic push | - | ||||||||||||
12 | - | |||||||||||||
13 | #pragma GCC diagnostic ignored "-Wsuggest-override" | - | ||||||||||||
14 | static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: | - | ||||||||||||
15 | #pragma GCC diagnostic ignored "-Wattributes" | - | ||||||||||||
16 | __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); | - | ||||||||||||
17 | #pragma GCC diagnostic pop | - | ||||||||||||
18 | struct QPrivateSignal {}; | - | ||||||||||||
19 | public: | - | ||||||||||||
20 | QQuickLocalTransform(QObject *parent) : QQuickTransform(parent) {} executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
21 | - | |||||||||||||
22 | void setTransform(const QTransform &t) { | - | ||||||||||||
23 | transform = t; | - | ||||||||||||
24 | update(); | - | ||||||||||||
25 | } executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||||||||
26 | void applyTo(QMatrix4x4 *matrix) const override { | - | ||||||||||||
27 | *matrix *= transform; | - | ||||||||||||
28 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||
29 | private: | - | ||||||||||||
30 | QTransform transform; | - | ||||||||||||
31 | }; | - | ||||||||||||
32 | - | |||||||||||||
33 | class QQuickFlipablePrivate : public QQuickItemPrivate | - | ||||||||||||
34 | { | - | ||||||||||||
35 | inline QQuickFlipable* q_func() { return static_cast<QQuickFlipable *>(q_ptr); } inline const QQuickFlipable* q_func() const { return static_cast<const QQuickFlipable *>(q_ptr); } friend class QQuickFlipable; | - | ||||||||||||
36 | public: | - | ||||||||||||
37 | QQuickFlipablePrivate() : current(QQuickFlipable::Front), front(nullptr), back(nullptr), sideDirty(false) {} executed 18 times by 2 tests: end of block Executed by:
| 18 | ||||||||||||
38 | - | |||||||||||||
39 | void transformChanged() override; | - | ||||||||||||
40 | void updateSide(); | - | ||||||||||||
41 | void setBackTransform(); | - | ||||||||||||
42 | - | |||||||||||||
43 | QQuickFlipable::Side current; | - | ||||||||||||
44 | QPointer<QQuickLocalTransform> backTransform; | - | ||||||||||||
45 | QPointer<QQuickItem> front; | - | ||||||||||||
46 | QPointer<QQuickItem> back; | - | ||||||||||||
47 | - | |||||||||||||
48 | bool sideDirty; | - | ||||||||||||
49 | bool wantBackXFlipped; | - | ||||||||||||
50 | bool wantBackYFlipped; | - | ||||||||||||
51 | }; | - | ||||||||||||
52 | QQuickFlipable::QQuickFlipable(QQuickItem *parent) | - | ||||||||||||
53 | : QQuickItem(*(new QQuickFlipablePrivate), parent) | - | ||||||||||||
54 | { | - | ||||||||||||
55 | } executed 18 times by 2 tests: end of block Executed by:
| 18 | ||||||||||||
56 | - | |||||||||||||
57 | QQuickFlipable::~QQuickFlipable() | - | ||||||||||||
58 | { | - | ||||||||||||
59 | } | - | ||||||||||||
60 | QQuickItem *QQuickFlipable::front() const | - | ||||||||||||
61 | { | - | ||||||||||||
62 | const QQuickFlipablePrivate * const d = d_func(); | - | ||||||||||||
63 | return executed 20 times by 2 tests: d->front;return d->front; Executed by:
executed 20 times by 2 tests: return d->front; Executed by:
| 20 | ||||||||||||
64 | } | - | ||||||||||||
65 | - | |||||||||||||
66 | void QQuickFlipable::setFront(QQuickItem *front) | - | ||||||||||||
67 | { | - | ||||||||||||
68 | QQuickFlipablePrivate * const d = d_func(); | - | ||||||||||||
69 | if (d->front
| 2-14 | ||||||||||||
70 | qmlWarning(this) << tr("front is a write-once property"); | - | ||||||||||||
71 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||
72 | } | - | ||||||||||||
73 | d->front = front; | - | ||||||||||||
74 | d->front->setParentItem(this); | - | ||||||||||||
75 | if (Back == d->current
| 0-14 | ||||||||||||
76 | d->front->setOpacity(0.); | - | ||||||||||||
77 | d->front->setEnabled(false); | - | ||||||||||||
78 | } never executed: end of block | 0 | ||||||||||||
79 | frontChanged(); | - | ||||||||||||
80 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
81 | - | |||||||||||||
82 | QQuickItem *QQuickFlipable::back() | - | ||||||||||||
83 | { | - | ||||||||||||
84 | const QQuickFlipablePrivate * const d = d_func(); | - | ||||||||||||
85 | return executed 4 times by 1 test: d->back;return d->back; Executed by:
executed 4 times by 1 test: return d->back; Executed by:
| 4 | ||||||||||||
86 | } | - | ||||||||||||
87 | - | |||||||||||||
88 | void QQuickFlipable::setBack(QQuickItem *back) | - | ||||||||||||
89 | { | - | ||||||||||||
90 | QQuickFlipablePrivate * const d = d_func(); | - | ||||||||||||
91 | if (d->back
| 2-14 | ||||||||||||
92 | qmlWarning(this) << tr("back is a write-once property"); | - | ||||||||||||
93 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||
94 | } | - | ||||||||||||
95 | if (back == nullptr
| 0-14 | ||||||||||||
96 | return; never executed: return; | 0 | ||||||||||||
97 | d->back = back; | - | ||||||||||||
98 | d->back->setParentItem(this); | - | ||||||||||||
99 | - | |||||||||||||
100 | d->backTransform = new QQuickLocalTransform(d->back); | - | ||||||||||||
101 | d->backTransform->prependToItem(d->back); | - | ||||||||||||
102 | - | |||||||||||||
103 | if (Front == d->current
| 0-14 | ||||||||||||
104 | d->back->setOpacity(0.); | - | ||||||||||||
105 | d->back->setEnabled(false); | - | ||||||||||||
106 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
107 | - | |||||||||||||
108 | connect(back, qFlagLocation("2""widthChanged()" "\0" __FILE__ ":" "194"), | - | ||||||||||||
109 | this, qFlagLocation("1""retransformBack()" "\0" __FILE__ ":" "195")); | - | ||||||||||||
110 | connect(back, qFlagLocation("2""heightChanged()" "\0" __FILE__ ":" "196"), | - | ||||||||||||
111 | this, qFlagLocation("1""retransformBack()" "\0" __FILE__ ":" "197")); | - | ||||||||||||
112 | backChanged(); | - | ||||||||||||
113 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
114 | - | |||||||||||||
115 | void QQuickFlipable::retransformBack() | - | ||||||||||||
116 | { | - | ||||||||||||
117 | QQuickFlipablePrivate * const d = d_func(); | - | ||||||||||||
118 | if (d->current == QQuickFlipable::Back
| 0-24 | ||||||||||||
119 | d->setBackTransform(); never executed: d->setBackTransform(); | 0 | ||||||||||||
120 | } executed 24 times by 2 tests: end of block Executed by:
| 24 | ||||||||||||
121 | - | |||||||||||||
122 | - | |||||||||||||
123 | - | |||||||||||||
124 | - | |||||||||||||
125 | - | |||||||||||||
126 | - | |||||||||||||
127 | - | |||||||||||||
128 | QQuickFlipable::Side QQuickFlipable::side() const | - | ||||||||||||
129 | { | - | ||||||||||||
130 | const QQuickFlipablePrivate * const d = d_func(); | - | ||||||||||||
131 | - | |||||||||||||
132 | const_cast<QQuickFlipablePrivate *>(d)->updateSide(); | - | ||||||||||||
133 | return executed 46 times by 1 test: d->current;return d->current; Executed by:
executed 46 times by 1 test: return d->current; Executed by:
| 46 | ||||||||||||
134 | } | - | ||||||||||||
135 | - | |||||||||||||
136 | void QQuickFlipablePrivate::transformChanged() | - | ||||||||||||
137 | { | - | ||||||||||||
138 | QQuickFlipable * const q = q_func(); | - | ||||||||||||
139 | - | |||||||||||||
140 | if (!sideDirty
| 37-83 | ||||||||||||
141 | sideDirty = true; | - | ||||||||||||
142 | q->polish(); | - | ||||||||||||
143 | } executed 37 times by 2 tests: end of block Executed by:
| 37 | ||||||||||||
144 | - | |||||||||||||
145 | QQuickItemPrivate::transformChanged(); | - | ||||||||||||
146 | } executed 120 times by 2 tests: end of block Executed by:
| 120 | ||||||||||||
147 | - | |||||||||||||
148 | void QQuickFlipable::updatePolish() | - | ||||||||||||
149 | { | - | ||||||||||||
150 | QQuickFlipablePrivate * const d = d_func(); | - | ||||||||||||
151 | d->updateSide(); | - | ||||||||||||
152 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||
153 | - | |||||||||||||
154 | - | |||||||||||||
155 | - | |||||||||||||
156 | - | |||||||||||||
157 | void QQuickFlipablePrivate::updateSide() | - | ||||||||||||
158 | { | - | ||||||||||||
159 | QQuickFlipable * const q = q_func(); | - | ||||||||||||
160 | - | |||||||||||||
161 | if (!sideDirty
| 23-29 | ||||||||||||
162 | return; executed 23 times by 1 test: return; Executed by:
| 23 | ||||||||||||
163 | - | |||||||||||||
164 | sideDirty = false; | - | ||||||||||||
165 | - | |||||||||||||
166 | QTransform sceneTransform; | - | ||||||||||||
167 | itemToParentTransform(sceneTransform); | - | ||||||||||||
168 | - | |||||||||||||
169 | QPointF p1(0, 0); | - | ||||||||||||
170 | QPointF p2(1, 0); | - | ||||||||||||
171 | QPointF p3(1, 1); | - | ||||||||||||
172 | - | |||||||||||||
173 | QPointF scenep1 = sceneTransform.map(p1); | - | ||||||||||||
174 | QPointF scenep2 = sceneTransform.map(p2); | - | ||||||||||||
175 | QPointF scenep3 = sceneTransform.map(p3); | - | ||||||||||||
176 | - | |||||||||||||
177 | - | |||||||||||||
178 | - | |||||||||||||
179 | - | |||||||||||||
180 | - | |||||||||||||
181 | - | |||||||||||||
182 | qreal cross = (scenep1.x() - scenep2.x()) * (scenep3.y() - scenep2.y()) - | - | ||||||||||||
183 | (scenep1.y() - scenep2.y()) * (scenep3.x() - scenep2.x()); | - | ||||||||||||
184 | - | |||||||||||||
185 | wantBackYFlipped = scenep1.x() >= scenep2.x(); | - | ||||||||||||
186 | wantBackXFlipped = scenep2.y() >= scenep3.y(); | - | ||||||||||||
187 | - | |||||||||||||
188 | QQuickFlipable::Side newSide; | - | ||||||||||||
189 | if (cross > 0
| 14-15 | ||||||||||||
190 | newSide = QQuickFlipable::Back; | - | ||||||||||||
191 | } executed 14 times by 2 tests: else {end of block Executed by:
| 14 | ||||||||||||
192 | newSide = QQuickFlipable::Front; | - | ||||||||||||
193 | } executed 15 times by 2 tests: end of block Executed by:
| 15 | ||||||||||||
194 | - | |||||||||||||
195 | if (newSide != current
| 10-19 | ||||||||||||
196 | current = newSide; | - | ||||||||||||
197 | if (current == QQuickFlipable::Back
| 2-8 | ||||||||||||
198 | setBackTransform(); executed 8 times by 2 tests: setBackTransform(); Executed by:
| 8 | ||||||||||||
199 | if (front
| 0-10 | ||||||||||||
200 | front->setOpacity((current==QQuickFlipable::Front)?1.:0.); | - | ||||||||||||
201 | front->setEnabled((current==QQuickFlipable::Front)?true:false); | - | ||||||||||||
202 | } executed 10 times by 2 tests: end of block Executed by:
| 10 | ||||||||||||
203 | if (back
| 0-10 | ||||||||||||
204 | back->setOpacity((current==QQuickFlipable::Back)?1.:0.); | - | ||||||||||||
205 | back->setEnabled((current==QQuickFlipable::Back)?true:false); | - | ||||||||||||
206 | } executed 10 times by 2 tests: end of block Executed by:
| 10 | ||||||||||||
207 | q->sideChanged(); | - | ||||||||||||
208 | } executed 10 times by 2 tests: end of block Executed by:
| 10 | ||||||||||||
209 | } executed 29 times by 2 tests: end of block Executed by:
| 29 | ||||||||||||
210 | - | |||||||||||||
211 | - | |||||||||||||
212 | - | |||||||||||||
213 | - | |||||||||||||
214 | void QQuickFlipablePrivate::setBackTransform() | - | ||||||||||||
215 | { | - | ||||||||||||
216 | QTransform mat; | - | ||||||||||||
217 | mat.translate(back->width()/2,back->height()/2); | - | ||||||||||||
218 | if (back->width() && wantBackYFlipped
| 2-6 | ||||||||||||
219 | mat.rotate(180, Qt::YAxis); executed 6 times by 2 tests: mat.rotate(180, Qt::YAxis); Executed by:
| 6 | ||||||||||||
220 | if (back->height() && wantBackXFlipped
| 2-6 | ||||||||||||
221 | mat.rotate(180, Qt::XAxis); executed 2 times by 1 test: mat.rotate(180, Qt::XAxis); Executed by:
| 2 | ||||||||||||
222 | mat.translate(-back->width()/2,-back->height()/2); | - | ||||||||||||
223 | - | |||||||||||||
224 | if (backTransform
| 0-8 | ||||||||||||
225 | backTransform->setTransform(mat); executed 8 times by 2 tests: backTransform->setTransform(mat); Executed by:
| 8 | ||||||||||||
226 | } executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||||||||
227 | - | |||||||||||||
228 | - | |||||||||||||
229 | - | |||||||||||||
Switch to Source code | Preprocessed file |