OpenCoverage

qquickflipable.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickflipable.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8class 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 {};-
19public:-
20 QQuickLocalTransform(QObject *parent) : QQuickTransform(parent) {}
executed 14 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickflipable
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:
  • tst_examples
  • tst_qquickflipable
8
26 void applyTo(QMatrix4x4 *matrix) const override {-
27 *matrix *= transform;-
28 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_examples
6
29private:-
30 QTransform transform;-
31};-
32-
33class 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;-
36public:-
37 QQuickFlipablePrivate() : current(QQuickFlipable::Front), front(nullptr), back(nullptr), sideDirty(false) {}
executed 18 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickflipable
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};-
52QQuickFlipable::QQuickFlipable(QQuickItem *parent)-
53: QQuickItem(*(new QQuickFlipablePrivate), parent)-
54{-
55}
executed 18 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickflipable
18
56-
57QQuickFlipable::~QQuickFlipable()-
58{-
59}-
60QQuickItem *QQuickFlipable::front() const-
61{-
62 const QQuickFlipablePrivate * const d = d_func();-
63 return
executed 20 times by 2 tests: return d->front;
Executed by:
  • tst_examples
  • tst_qquickflipable
d->front;
executed 20 times by 2 tests: return d->front;
Executed by:
  • tst_examples
  • tst_qquickflipable
20
64}-
65-
66void QQuickFlipable::setFront(QQuickItem *front)-
67{-
68 QQuickFlipablePrivate * const d = d_func();-
69 if (d->front
d->frontDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickflipable
FALSEevaluated 14 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickflipable
) {
2-14
70 qmlWarning(this) << tr("front is a write-once property");-
71 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_qquickflipable
2
72 }-
73 d->front = front;-
74 d->front->setParentItem(this);-
75 if (Back == d->current
Back == d->currentDescription
TRUEnever evaluated
FALSEevaluated 14 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickflipable
) {
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:
  • tst_examples
  • tst_qquickflipable
14
81-
82QQuickItem *QQuickFlipable::back()-
83{-
84 const QQuickFlipablePrivate * const d = d_func();-
85 return
executed 4 times by 1 test: return d->back;
Executed by:
  • tst_qquickflipable
d->back;
executed 4 times by 1 test: return d->back;
Executed by:
  • tst_qquickflipable
4
86}-
87-
88void QQuickFlipable::setBack(QQuickItem *back)-
89{-
90 QQuickFlipablePrivate * const d = d_func();-
91 if (d->back
d->backDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickflipable
FALSEevaluated 14 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickflipable
) {
2-14
92 qmlWarning(this) << tr("back is a write-once property");-
93 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_qquickflipable
2
94 }-
95 if (back == nullptr
back == nullptrDescription
TRUEnever evaluated
FALSEevaluated 14 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickflipable
)
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
Front == d->currentDescription
TRUEevaluated 14 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickflipable
FALSEnever evaluated
) {
0-14
104 d->back->setOpacity(0.);-
105 d->back->setEnabled(false);-
106 }
executed 14 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickflipable
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:
  • tst_examples
  • tst_qquickflipable
14
114-
115void QQuickFlipable::retransformBack()-
116{-
117 QQuickFlipablePrivate * const d = d_func();-
118 if (d->current == QQuickFlipable::Back
d->current == ...Flipable::BackDescription
TRUEnever evaluated
FALSEevaluated 24 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickflipable
&& d->back
d->backDescription
TRUEnever evaluated
FALSEnever evaluated
)
0-24
119 d->setBackTransform();
never executed: d->setBackTransform();
0
120}
executed 24 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickflipable
24
121-
122-
123-
124-
125-
126-
127-
128QQuickFlipable::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: return d->current;
Executed by:
  • tst_qquickflipable
d->current;
executed 46 times by 1 test: return d->current;
Executed by:
  • tst_qquickflipable
46
134}-
135-
136void QQuickFlipablePrivate::transformChanged()-
137{-
138 QQuickFlipable * const q = q_func();-
139-
140 if (!sideDirty
!sideDirtyDescription
TRUEevaluated 37 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickflipable
FALSEevaluated 83 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickflipable
) {
37-83
141 sideDirty = true;-
142 q->polish();-
143 }
executed 37 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickflipable
37
144-
145 QQuickItemPrivate::transformChanged();-
146}
executed 120 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickflipable
120
147-
148void QQuickFlipable::updatePolish()-
149{-
150 QQuickFlipablePrivate * const d = d_func();-
151 d->updateSide();-
152}
executed 6 times by 1 test: end of block
Executed by:
  • tst_examples
6
153-
154-
155-
156-
157void QQuickFlipablePrivate::updateSide()-
158{-
159 QQuickFlipable * const q = q_func();-
160-
161 if (!sideDirty
!sideDirtyDescription
TRUEevaluated 23 times by 1 test
Evaluated by:
  • tst_qquickflipable
FALSEevaluated 29 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickflipable
)
23-29
162 return;
executed 23 times by 1 test: return;
Executed by:
  • tst_qquickflipable
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
cross > 0Description
TRUEevaluated 14 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickflipable
FALSEevaluated 15 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickflipable
) {
14-15
190 newSide = QQuickFlipable::Back;-
191 }
executed 14 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickflipable
else {
14
192 newSide = QQuickFlipable::Front;-
193 }
executed 15 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickflipable
15
194-
195 if (newSide != current
newSide != currentDescription
TRUEevaluated 10 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickflipable
FALSEevaluated 19 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickflipable
) {
10-19
196 current = newSide;-
197 if (current == QQuickFlipable::Back
current == QQu...Flipable::BackDescription
TRUEevaluated 8 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickflipable
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickflipable
&& back)
2-8
198 setBackTransform();
executed 8 times by 2 tests: setBackTransform();
Executed by:
  • tst_examples
  • tst_qquickflipable
8
199 if (front
frontDescription
TRUEevaluated 10 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickflipable
FALSEnever evaluated
) {
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:
  • tst_examples
  • tst_qquickflipable
10
203 if (back
backDescription
TRUEevaluated 10 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickflipable
FALSEnever evaluated
) {
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:
  • tst_examples
  • tst_qquickflipable
10
207 q->sideChanged();-
208 }
executed 10 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickflipable
10
209}
executed 29 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickflipable
29
210-
211-
212-
213-
214void QQuickFlipablePrivate::setBackTransform()-
215{-
216 QTransform mat;-
217 mat.translate(back->width()/2,back->height()/2);-
218 if (back->width() && wantBackYFlipped
wantBackYFlippedDescription
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickflipable
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_examples
)
2-6
219 mat.rotate(180, Qt::YAxis);
executed 6 times by 2 tests: mat.rotate(180, Qt::YAxis);
Executed by:
  • tst_examples
  • tst_qquickflipable
6
220 if (back->height() && wantBackXFlipped
wantBackXFlippedDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_examples
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickflipable
)
2-6
221 mat.rotate(180, Qt::XAxis);
executed 2 times by 1 test: mat.rotate(180, Qt::XAxis);
Executed by:
  • tst_examples
2
222 mat.translate(-back->width()/2,-back->height()/2);-
223-
224 if (backTransform
backTransformDescription
TRUEevaluated 8 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickflipable
FALSEnever evaluated
)
0-8
225 backTransform->setTransform(mat);
executed 8 times by 2 tests: backTransform->setTransform(mat);
Executed by:
  • tst_examples
  • tst_qquickflipable
8
226}
executed 8 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickflipable
8
227-
228-
229-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.0