kernel/qcursor.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6QDataStream &operator<<(QDataStream &s, const QCursor &c) -
7{ -
8 s << (qint16)c.shape(); -
9 if (c.shape() == Qt::BitmapCursor) {
evaluated: c.shape() == Qt::BitmapCursor
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:31
24-31
10 bool isPixmap = false; -
11 if (s.version() >= 7) {
partially evaluated: s.version() >= 7
TRUEFALSE
yes
Evaluation Count:24
no
Evaluation Count:0
0-24
12 isPixmap = !c.pixmap().isNull(); -
13 s << isPixmap; -
14 }
executed: }
Execution Count:24
24
15 if (isPixmap)
evaluated: isPixmap
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:6
6-18
16 s << c.pixmap();
executed: s << c.pixmap();
Execution Count:18
18
17 else -
18 s << *c.bitmap() << *c.mask();
executed: s << *c.bitmap() << *c.mask();
Execution Count:6
6
19 s << c.hotSpot(); -
20 }
executed: }
Execution Count:24
24
21 return s;
executed: return s;
Execution Count:55
55
22} -
23QDataStream &operator>>(QDataStream &s, QCursor &c) -
24{ -
25 qint16 shape; -
26 s >> shape; -
27 if (shape == Qt::BitmapCursor) {
evaluated: shape == Qt::BitmapCursor
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:31
24-31
28 bool isPixmap = false; -
29 if (s.version() >= 7)
partially evaluated: s.version() >= 7
TRUEFALSE
yes
Evaluation Count:24
no
Evaluation Count:0
0-24
30 s >> isPixmap;
executed: s >> isPixmap;
Execution Count:24
24
31 if (isPixmap) {
evaluated: isPixmap
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:6
6-18
32 QPixmap pm; -
33 QPoint hot; -
34 s >> pm >> hot; -
35 c = QCursor(pm, hot.x(), hot.y()); -
36 } else {
executed: }
Execution Count:18
18
37 QBitmap bm, bmm; -
38 QPoint hot; -
39 s >> bm >> bmm >> hot; -
40 c = QCursor(bm, bmm, hot.x(), hot.y()); -
41 }
executed: }
Execution Count:6
6
42 } else { -
43 c.setShape((Qt::CursorShape)shape); -
44 }
executed: }
Execution Count:31
31
45 return s;
executed: return s;
Execution Count:55
55
46} -
47QCursor::QCursor(const QPixmap &pixmap, int hotX, int hotY) -
48 : d(0) -
49{ -
50 QImage img = pixmap.toImage().convertToFormat(QImage::Format_Indexed8, Qt::ThresholdDither|Qt::AvoidDither); -
51 QBitmap bm = QBitmap::fromImage(img, Qt::ThresholdDither|Qt::AvoidDither); -
52 QBitmap bmm = pixmap.mask(); -
53 if (!bmm.isNull()) {
partially evaluated: !bmm.isNull()
TRUEFALSE
yes
Evaluation Count:54
no
Evaluation Count:0
0-54
54 QBitmap nullBm; -
55 bm.setMask(nullBm); -
56 }
executed: }
Execution Count:54
54
57 else if (!pixmap.mask().isNull()) {
never evaluated: !pixmap.mask().isNull()
0
58 QImage mimg = pixmap.mask().toImage().convertToFormat(QImage::Format_Indexed8, Qt::ThresholdDither|Qt::AvoidDither); -
59 bmm = QBitmap::fromImage(mimg, Qt::ThresholdDither|Qt::AvoidDither); -
60 }
never executed: }
0
61 else { -
62 bmm = QBitmap(bm.size()); -
63 bmm.fill(Qt::color1); -
64 }
never executed: }
0
65 -
66 d = QCursorData::setBitmap(bm, bmm, hotX, hotY); -
67 d->pixmap = pixmap; -
68}
executed: }
Execution Count:54
54
69QCursor::QCursor(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY) -
70 : d(0) -
71{ -
72 d = QCursorData::setBitmap(bitmap, mask, hotX, hotY); -
73}
executed: }
Execution Count:18
18
74 -
75QCursorData *qt_cursorTable[Qt::LastCursor + 1]; -
76bool QCursorData::initialized = false; -
77 -
78 -
79void QCursorData::cleanup() -
80{ -
81 if(!QCursorData::initialized)
partially evaluated: !QCursorData::initialized
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:287
0-287
82 return;
never executed: return;
0
83 -
84 for (int shape = 0; shape <= Qt::LastCursor; ++shape) {
evaluated: shape <= Qt::LastCursor
TRUEFALSE
yes
Evaluation Count:6314
yes
Evaluation Count:287
287-6314
85 -
86 if (!qt_cursorTable[shape]->ref.deref())
evaluated: !qt_cursorTable[shape]->ref.deref()
TRUEFALSE
yes
Evaluation Count:6293
yes
Evaluation Count:21
21-6293
87 delete qt_cursorTable[shape];
executed: delete qt_cursorTable[shape];
Execution Count:6293
6293
88 qt_cursorTable[shape] = 0; -
89 }
executed: }
Execution Count:6314
6314
90 QCursorData::initialized = false; -
91}
executed: }
Execution Count:287
287
92 -
93 -
94void QCursorData::initialize() -
95{ -
96 if (QCursorData::initialized)
partially evaluated: QCursorData::initialized
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:289
0-289
97 return;
never executed: return;
0
98 for (int shape = 0; shape <= Qt::LastCursor; ++shape)
evaluated: shape <= Qt::LastCursor
TRUEFALSE
yes
Evaluation Count:6358
yes
Evaluation Count:289
289-6358
99 qt_cursorTable[shape] = new QCursorData((Qt::CursorShape)shape);
executed: qt_cursorTable[shape] = new QCursorData((Qt::CursorShape)shape);
Execution Count:6358
6358
100 QCursorData::initialized = true; -
101}
executed: }
Execution Count:289
289
102 -
103 -
104 -
105 -
106QCursor::QCursor() -
107{ -
108 if (!QCursorData::initialized) {
partially evaluated: !QCursorData::initialized
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2036
0-2036
109 if (QCoreApplication::startingUp()) {
never evaluated: QCoreApplication::startingUp()
0
110 d = 0; -
111 return;
never executed: return;
0
112 } -
113 QCursorData::initialize(); -
114 }
never executed: }
0
115 QCursorData *c = qt_cursorTable[0]; -
116 c->ref.ref(); -
117 d = c; -
118}
executed: }
Execution Count:2036
2036
119QCursor::QCursor(Qt::CursorShape shape) -
120 : d(0) -
121{ -
122 if (!QCursorData::initialized)
partially evaluated: !QCursorData::initialized
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9848
0-9848
123 QCursorData::initialize();
never executed: QCursorData::initialize();
0
124 setShape(shape); -
125}
executed: }
Execution Count:9848
9848
126Qt::CursorShape QCursor::shape() const -
127{ -
128 if (!QCursorData::initialized)
partially evaluated: !QCursorData::initialized
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16174
0-16174
129 QCursorData::initialize();
never executed: QCursorData::initialize();
0
130 return d->cshape;
executed: return d->cshape;
Execution Count:16174
16174
131} -
132void QCursor::setShape(Qt::CursorShape shape) -
133{ -
134 if (!QCursorData::initialized)
partially evaluated: !QCursorData::initialized
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9879
0-9879
135 QCursorData::initialize();
never executed: QCursorData::initialize();
0
136 QCursorData *c = uint(shape) <= Qt::LastCursor ? qt_cursorTable[shape] : 0;
evaluated: uint(shape) <= Qt::LastCursor
TRUEFALSE
yes
Evaluation Count:9867
yes
Evaluation Count:12
12-9867
137 if (!c)
evaluated: !c
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:9867
12-9867
138 c = qt_cursorTable[0];
executed: c = qt_cursorTable[0];
Execution Count:12
12
139 c->ref.ref(); -
140 if (!d) {
evaluated: !d
TRUEFALSE
yes
Evaluation Count:9848
yes
Evaluation Count:31
31-9848
141 d = c; -
142 } else {
executed: }
Execution Count:9848
9848
143 if (!d->ref.deref())
partially evaluated: !d->ref.deref()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:31
0-31
144 delete d;
never executed: delete d;
0
145 d = c; -
146 }
executed: }
Execution Count:31
31
147} -
148 -
149 -
150 -
151 -
152 -
153const QBitmap *QCursor::bitmap() const -
154{ -
155 if (!QCursorData::initialized)
partially evaluated: !QCursorData::initialized
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:246
0-246
156 QCursorData::initialize();
never executed: QCursorData::initialize();
0
157 return d->bm;
executed: return d->bm;
Execution Count:246
246
158} -
159 -
160 -
161 -
162 -
163 -
164 -
165const QBitmap *QCursor::mask() const -
166{ -
167 if (!QCursorData::initialized)
partially evaluated: !QCursorData::initialized
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:246
0-246
168 QCursorData::initialize();
never executed: QCursorData::initialize();
0
169 return d->bmm;
executed: return d->bmm;
Execution Count:246
246
170} -
171 -
172 -
173 -
174 -
175 -
176 -
177QPixmap QCursor::pixmap() const -
178{ -
179 if (!QCursorData::initialized)
partially evaluated: !QCursorData::initialized
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:42
0-42
180 QCursorData::initialize();
never executed: QCursorData::initialize();
0
181 return d->pixmap;
executed: return d->pixmap;
Execution Count:42
42
182} -
183 -
184 -
185 -
186 -
187 -
188 -
189QPoint QCursor::hotSpot() const -
190{ -
191 if (!QCursorData::initialized)
partially evaluated: !QCursorData::initialized
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:132
0-132
192 QCursorData::initialize();
never executed: QCursorData::initialize();
0
193 return QPoint(d->hx, d->hy);
executed: return QPoint(d->hx, d->hy);
Execution Count:132
132
194} -
195 -
196 -
197 -
198 -
199 -
200QCursor::QCursor(const QCursor &c) -
201{ -
202 if (!QCursorData::initialized)
partially evaluated: !QCursorData::initialized
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9435
0-9435
203 QCursorData::initialize();
never executed: QCursorData::initialize();
0
204 d = c.d; -
205 d->ref.ref(); -
206}
executed: }
Execution Count:9435
9435
207 -
208 -
209 -
210 -
211 -
212QCursor::~QCursor() -
213{ -
214 if (d && !d->ref.deref())
partially evaluated: d
TRUEFALSE
yes
Evaluation Count:21331
no
Evaluation Count:0
evaluated: !d->ref.deref()
TRUEFALSE
yes
Evaluation Count:74
yes
Evaluation Count:21257
0-21331
215 delete d;
executed: delete d;
Execution Count:74
74
216}
executed: }
Execution Count:21331
21331
217 -
218 -
219 -
220 -
221 -
222 -
223 -
224QCursor &QCursor::operator=(const QCursor &c) -
225{ -
226 if (!QCursorData::initialized)
partially evaluated: !QCursorData::initialized
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3775
0-3775
227 QCursorData::initialize();
never executed: QCursorData::initialize();
0
228 if (c.d)
partially evaluated: c.d
TRUEFALSE
yes
Evaluation Count:3775
no
Evaluation Count:0
0-3775
229 c.d->ref.ref();
executed: c.d->ref.ref();
Execution Count:3775
3775
230 if (d && !d->ref.deref())
partially evaluated: d
TRUEFALSE
yes
Evaluation Count:3775
no
Evaluation Count:0
partially evaluated: !d->ref.deref()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3775
0-3775
231 delete d;
never executed: delete d;
0
232 d = c.d; -
233 return *this;
executed: return *this;
Execution Count:3775
3775
234} -
235 -
236 -
237 -
238 -
239QCursor::operator QVariant() const -
240{ -
241 return QVariant(QVariant::Cursor, this);
executed: return QVariant(QVariant::Cursor, this);
Execution Count:9
9
242} -
243 -
244 -
245QDebug operator<<(QDebug dbg, const QCursor &c) -
246{ -
247 dbg.nospace() << "QCursor(Qt::CursorShape(" << c.shape() << "))"; -
248 return dbg.space();
executed: return dbg.space();
Execution Count:1
1
249} -
250 -
251 -
252 -
253 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial