qpen.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/painting/qpen.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5typedef QPenPrivate QPenData;-
6inline QPenPrivate::QPenPrivate(const QBrush &_brush, qreal _width, Qt::PenStyle penStyle,-
7 Qt::PenCapStyle _capStyle, Qt::PenJoinStyle _joinStyle, bool _defaultWidth)-
8 : ref(1), dashOffset(0), miterLimit(2),-
9 cosmetic(false), defaultWidth(_defaultWidth)-
10{-
11 width = _width;-
12 brush = _brush;-
13 style = penStyle;-
14 capStyle = _capStyle;-
15 joinStyle = _joinStyle;-
16}
never executed: end of block
0
17-
18static const Qt::PenCapStyle qpen_default_cap = Qt::SquareCap;-
19static const Qt::PenJoinStyle qpen_default_join = Qt::BevelJoin;-
20-
21class QPenDataHolder-
22{-
23public:-
24 QPenData *pen;-
25 QPenDataHolder(const QBrush &brush, qreal width, Qt::PenStyle penStyle,-
26 Qt::PenCapStyle penCapStyle, Qt::PenJoinStyle _joinStyle)-
27 : pen(new QPenData(brush, width, penStyle, penCapStyle, _joinStyle))-
28 { }
never executed: end of block
0
29 ~QPenDataHolder()-
30 {-
31 if (!pen->ref.deref()
!pen->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
32 delete pen;
never executed: delete pen;
0
33 pen = 0;-
34 }
never executed: end of block
0
35};-
36-
37namespace { namespace Q_QGS_defaultPenInstance { typedef QPenDataHolder Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
) guard.store(QtGlobalStatic::Destroyed);
never executed: guard.store(QtGlobalStatic::Destroyed);
}
never executed: end of block
}; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type (Qt::black, 1, Qt::SolidLine, qpen_default_cap, qpen_default_join))) : value (Qt::black, 1, Qt::SolidLine, qpen_default_cap, qpen_default_join) { guard.store(QtGlobalStatic::Initialized); } } holder; return
never executed: return &holder.value;
&holder.value;
never executed: return &holder.value;
} } } static QGlobalStatic<QPenDataHolder, Q_QGS_defaultPenInstance::innerFunction, Q_QGS_defaultPenInstance::guard> defaultPenInstance;
0
38-
39namespace { namespace Q_QGS_nullPenInstance { typedef QPenDataHolder Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
) guard.store(QtGlobalStatic::Destroyed);
never executed: guard.store(QtGlobalStatic::Destroyed);
}
never executed: end of block
}; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type (Qt::black, 1, Qt::NoPen, qpen_default_cap, qpen_default_join))) : value (Qt::black, 1, Qt::NoPen, qpen_default_cap, qpen_default_join) { guard.store(QtGlobalStatic::Initialized); } } holder; return
never executed: return &holder.value;
&holder.value;
never executed: return &holder.value;
} } } static QGlobalStatic<QPenDataHolder, Q_QGS_nullPenInstance::innerFunction, Q_QGS_nullPenInstance::guard> nullPenInstance;
0
40-
41-
42-
43-
44-
45-
46QPen::QPen()-
47{-
48 d = defaultPenInstance()->pen;-
49 d->ref.ref();-
50}
never executed: end of block
0
51-
52-
53-
54-
55-
56-
57-
58QPen::QPen(Qt::PenStyle style)-
59{-
60 if (style == Qt::NoPen
style == Qt::NoPenDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
61 d = nullPenInstance()->pen;-
62 d->ref.ref();-
63 }
never executed: end of block
else {
0
64 d = new QPenData(Qt::black, 1, style, qpen_default_cap, qpen_default_join);-
65 }
never executed: end of block
0
66}-
67QPen::QPen(const QColor &color)-
68{-
69 d = new QPenData(color, 1, Qt::SolidLine, qpen_default_cap, qpen_default_join);-
70}
never executed: end of block
0
71QPen::QPen(const QBrush &brush, qreal width, Qt::PenStyle s, Qt::PenCapStyle c, Qt::PenJoinStyle j)-
72{-
73 d = new QPenData(brush, width, s, c, j, false);-
74}
never executed: end of block
0
75-
76-
77-
78-
79-
80-
81-
82QPen::QPen(const QPen &p) noexcept-
83{-
84 d = p.d;-
85 if (d
dDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
86 d->ref.ref();
never executed: d->ref.ref();
0
87}
never executed: end of block
0
88QPen::~QPen()-
89{-
90 if (d
dDescription
TRUEnever evaluated
FALSEnever evaluated
&& !d->ref.deref()
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
91 delete d;
never executed: delete d;
0
92}
never executed: end of block
0
93void QPen::detach()-
94{-
95 if (d->ref.load() == 1
d->ref.load() == 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
96 return;
never executed: return;
0
97-
98 QPenData *x = new QPenData(*static_cast<QPenData *>(d));-
99 if (!d->ref.deref()
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
100 delete d;
never executed: delete d;
0
101 x->ref.store(1);-
102 d = x;-
103}
never executed: end of block
0
104QPen &QPen::operator=(const QPen &p) noexcept-
105{-
106 QPen(p).swap(*this);-
107 return
never executed: return *this;
*this;
never executed: return *this;
0
108}-
109QPen::operator QVariant() const-
110{-
111 return
never executed: return QVariant(QVariant::Pen, this);
QVariant(QVariant::Pen, this);
never executed: return QVariant(QVariant::Pen, this);
0
112}-
113Qt::PenStyle QPen::style() const-
114{-
115 return
never executed: return d->style;
d->style;
never executed: return d->style;
0
116}-
117void QPen::setStyle(Qt::PenStyle s)-
118{-
119 if (d->style == s
d->style == sDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
120 return;
never executed: return;
0
121 detach();-
122 d->style = s;-
123 QPenData *dd = static_cast<QPenData *>(d);-
124 dd->dashPattern.clear();-
125 dd->dashOffset = 0;-
126}
never executed: end of block
0
127-
128-
129-
130-
131-
132-
133QVector<qreal> QPen::dashPattern() const-
134{-
135 QPenData *dd = static_cast<QPenData *>(d);-
136 if (d->style == Qt::SolidLine
d->style == Qt::SolidLineDescription
TRUEnever evaluated
FALSEnever evaluated
|| d->style == Qt::NoPen
d->style == Qt::NoPenDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
137 return
never executed: return QVector<qreal>();
QVector<qreal>();
never executed: return QVector<qreal>();
0
138 } else if (dd->dashPattern.isEmpty()
dd->dashPattern.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
139 const qreal space = 2;-
140 const qreal dot = 1;-
141 const qreal dash = 4;-
142-
143 switch (d->style) {-
144 case
never executed: case Qt::DashLine:
Qt::DashLine:
never executed: case Qt::DashLine:
0
145 dd->dashPattern.reserve(2);-
146 dd->dashPattern << dash << space;-
147 break;
never executed: break;
0
148 case
never executed: case Qt::DotLine:
Qt::DotLine:
never executed: case Qt::DotLine:
0
149 dd->dashPattern.reserve(2);-
150 dd->dashPattern << dot << space;-
151 break;
never executed: break;
0
152 case
never executed: case Qt::DashDotLine:
Qt::DashDotLine:
never executed: case Qt::DashDotLine:
0
153 dd->dashPattern.reserve(4);-
154 dd->dashPattern << dash << space << dot << space;-
155 break;
never executed: break;
0
156 case
never executed: case Qt::DashDotDotLine:
Qt::DashDotDotLine:
never executed: case Qt::DashDotDotLine:
0
157 dd->dashPattern.reserve(6);-
158 dd->dashPattern << dash << space << dot << space << dot << space;-
159 break;
never executed: break;
0
160 default
never executed: default:
:
never executed: default:
0
161 break;
never executed: break;
0
162 }-
163 }-
164 return
never executed: return dd->dashPattern;
dd->dashPattern;
never executed: return dd->dashPattern;
0
165}-
166void QPen::setDashPattern(const QVector<qreal> &pattern)-
167{-
168 if (pattern.isEmpty()
pattern.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
169 return;
never executed: return;
0
170 detach();-
171-
172 QPenData *dd = static_cast<QPenData *>(d);-
173 dd->dashPattern = pattern;-
174 d->style = Qt::CustomDashLine;-
175-
176 if ((
(dd->dashPatte...ze() % 2) == 1Description
TRUEnever evaluated
FALSEnever evaluated
dd->dashPattern.size() % 2) == 1
(dd->dashPatte...ze() % 2) == 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
177 QMessageLogger(__FILE__, 531, __PRETTY_FUNCTION__).warning("QPen::setDashPattern: Pattern not of even length");-
178 dd->dashPattern << 1;-
179 }
never executed: end of block
0
180}
never executed: end of block
0
181-
182-
183-
184-
185-
186-
187-
188qreal QPen::dashOffset() const-
189{-
190 QPenData *dd = static_cast<QPenData *>(d);-
191 return
never executed: return dd->dashOffset;
dd->dashOffset;
never executed: return dd->dashOffset;
0
192}-
193void QPen::setDashOffset(qreal offset)-
194{-
195 if (qFuzzyCompare(offset, static_cast<QPenData *>(d)->dashOffset)
qFuzzyCompare(...)->dashOffset)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
196 return;
never executed: return;
0
197 detach();-
198 QPenData *dd = static_cast<QPenData *>(d);-
199 dd->dashOffset = offset;-
200 if (d->style != Qt::CustomDashLine
d->style != Qt::CustomDashLineDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
201 dd->dashPattern = dashPattern();-
202 d->style = Qt::CustomDashLine;-
203 }
never executed: end of block
0
204}
never executed: end of block
0
205-
206-
207-
208-
209-
210-
211-
212qreal QPen::miterLimit() const-
213{-
214 const QPenData *dd = static_cast<QPenData *>(d);-
215 return
never executed: return dd->miterLimit;
dd->miterLimit;
never executed: return dd->miterLimit;
0
216}-
217void QPen::setMiterLimit(qreal limit)-
218{-
219 detach();-
220 QPenData *dd = static_cast<QPenData *>(d);-
221 dd->miterLimit = limit;-
222}
never executed: end of block
0
223int QPen::width() const-
224{-
225 return
never executed: return qRound(d->width);
qRound(d->width);
never executed: return qRound(d->width);
0
226}-
227qreal QPen::widthF() const-
228{-
229 return
never executed: return d->width;
d->width;
never executed: return d->width;
0
230}-
231void QPen::setWidth(int width)-
232{-
233 if (width < 0
width < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
234 QMessageLogger(__FILE__, 657, __PRETTY_FUNCTION__).warning("QPen::setWidth: Setting a pen width with a negative value is not defined");
never executed: QMessageLogger(__FILE__, 657, __PRETTY_FUNCTION__).warning("QPen::setWidth: Setting a pen width with a negative value is not defined");
0
235 if ((
(qreal)width == d->widthDescription
TRUEnever evaluated
FALSEnever evaluated
qreal)width == d->width
(qreal)width == d->widthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
236 return;
never executed: return;
0
237 detach();-
238 d->width = width;-
239}
never executed: end of block
0
240void QPen::setWidthF(qreal width)-
241{-
242 if (width < 0.f
width < 0.fDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
243 QMessageLogger(__FILE__, 681, __PRETTY_FUNCTION__).warning("QPen::setWidthF: Setting a pen width with a negative value is not defined");-
244 return;
never executed: return;
0
245 }-
246 if (qAbs(d->width - width) < 0.00000001f
qAbs(d->width ... < 0.00000001fDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
247 return;
never executed: return;
0
248 detach();-
249 d->width = width;-
250 d->defaultWidth = false;-
251}
never executed: end of block
0
252-
253-
254-
255-
256-
257-
258-
259Qt::PenCapStyle QPen::capStyle() const-
260{-
261 return
never executed: return d->capStyle;
d->capStyle;
never executed: return d->capStyle;
0
262}-
263void QPen::setCapStyle(Qt::PenCapStyle c)-
264{-
265 if (d->capStyle == c
d->capStyle == cDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
266 return;
never executed: return;
0
267 detach();-
268 d->capStyle = c;-
269}
never executed: end of block
0
270-
271-
272-
273-
274-
275-
276Qt::PenJoinStyle QPen::joinStyle() const-
277{-
278 return
never executed: return d->joinStyle;
d->joinStyle;
never executed: return d->joinStyle;
0
279}-
280void QPen::setJoinStyle(Qt::PenJoinStyle j)-
281{-
282 if (d->joinStyle == j
d->joinStyle == jDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
283 return;
never executed: return;
0
284 detach();-
285 d->joinStyle = j;-
286}
never executed: end of block
0
287QColor QPen::color() const-
288{-
289 return
never executed: return d->brush.color();
d->brush.color();
never executed: return d->brush.color();
0
290}-
291void QPen::setColor(const QColor &c)-
292{-
293 detach();-
294 d->brush = QBrush(c);-
295}
never executed: end of block
0
296-
297-
298-
299-
300-
301QBrush QPen::brush() const-
302{-
303 return
never executed: return d->brush;
d->brush;
never executed: return d->brush;
0
304}-
305-
306-
307-
308-
309-
310-
311-
312void QPen::setBrush(const QBrush &brush)-
313{-
314 detach();-
315 d->brush = brush;-
316}
never executed: end of block
0
317-
318-
319-
320-
321-
322-
323-
324bool QPen::isSolid() const-
325{-
326 return
never executed: return d->brush.style() == Qt::SolidPattern;
d->brush.style() == Qt::SolidPattern;
never executed: return d->brush.style() == Qt::SolidPattern;
0
327}-
328bool QPen::isCosmetic() const-
329{-
330 QPenData *dd = static_cast<QPenData *>(d);-
331 return
never executed: return (dd->cosmetic == true) || d->width == 0;
(dd->cosmetic == true) || d->width == 0;
never executed: return (dd->cosmetic == true) || d->width == 0;
0
332}-
333void QPen::setCosmetic(bool cosmetic)-
334{-
335 detach();-
336 QPenData *dd = static_cast<QPenData *>(d);-
337 dd->cosmetic = cosmetic;-
338}
never executed: end of block
0
339bool QPen::operator==(const QPen &p) const-
340{-
341 QPenData *dd = static_cast<QPenData *>(d);-
342 QPenData *pdd = static_cast<QPenData *>(p.d);-
343 return
never executed: return (p.d == d) || (p.d->style == d->style && p.d->capStyle == d->capStyle && p.d->joinStyle == d->joinStyle && p.d->width == d->width && pdd->miterLimit == dd->miterLimit && (d->style != Qt::CustomDashLine || (qFuzzyCompare(pdd->dashOffset, dd->dashOffset) && pdd->dashPattern == dd->dashPattern)) && p.d->brush == d->brush && pdd->cosmetic == dd->cosmetic && pdd->defaultWidth == dd->defaultWidth);
(p.d == d)
never executed: return (p.d == d) || (p.d->style == d->style && p.d->capStyle == d->capStyle && p.d->joinStyle == d->joinStyle && p.d->width == d->width && pdd->miterLimit == dd->miterLimit && (d->style != Qt::CustomDashLine || (qFuzzyCompare(pdd->dashOffset, dd->dashOffset) && pdd->dashPattern == dd->dashPattern)) && p.d->brush == d->brush && pdd->cosmetic == dd->cosmetic && pdd->defaultWidth == dd->defaultWidth);
0
344 || (p.d->style == d->style
never executed: return (p.d == d) || (p.d->style == d->style && p.d->capStyle == d->capStyle && p.d->joinStyle == d->joinStyle && p.d->width == d->width && pdd->miterLimit == dd->miterLimit && (d->style != Qt::CustomDashLine || (qFuzzyCompare(pdd->dashOffset, dd->dashOffset) && pdd->dashPattern == dd->dashPattern)) && p.d->brush == d->brush && pdd->cosmetic == dd->cosmetic && pdd->defaultWidth == dd->defaultWidth);
0
345 && p.d->capStyle == d->capStyle
never executed: return (p.d == d) || (p.d->style == d->style && p.d->capStyle == d->capStyle && p.d->joinStyle == d->joinStyle && p.d->width == d->width && pdd->miterLimit == dd->miterLimit && (d->style != Qt::CustomDashLine || (qFuzzyCompare(pdd->dashOffset, dd->dashOffset) && pdd->dashPattern == dd->dashPattern)) && p.d->brush == d->brush && pdd->cosmetic == dd->cosmetic && pdd->defaultWidth == dd->defaultWidth);
0
346 && p.d->joinStyle == d->joinStyle
never executed: return (p.d == d) || (p.d->style == d->style && p.d->capStyle == d->capStyle && p.d->joinStyle == d->joinStyle && p.d->width == d->width && pdd->miterLimit == dd->miterLimit && (d->style != Qt::CustomDashLine || (qFuzzyCompare(pdd->dashOffset, dd->dashOffset) && pdd->dashPattern == dd->dashPattern)) && p.d->brush == d->brush && pdd->cosmetic == dd->cosmetic && pdd->defaultWidth == dd->defaultWidth);
0
347 && p.d->width == d->width
never executed: return (p.d == d) || (p.d->style == d->style && p.d->capStyle == d->capStyle && p.d->joinStyle == d->joinStyle && p.d->width == d->width && pdd->miterLimit == dd->miterLimit && (d->style != Qt::CustomDashLine || (qFuzzyCompare(pdd->dashOffset, dd->dashOffset) && pdd->dashPattern == dd->dashPattern)) && p.d->brush == d->brush && pdd->cosmetic == dd->cosmetic && pdd->defaultWidth == dd->defaultWidth);
0
348 && pdd->miterLimit == dd->miterLimit
never executed: return (p.d == d) || (p.d->style == d->style && p.d->capStyle == d->capStyle && p.d->joinStyle == d->joinStyle && p.d->width == d->width && pdd->miterLimit == dd->miterLimit && (d->style != Qt::CustomDashLine || (qFuzzyCompare(pdd->dashOffset, dd->dashOffset) && pdd->dashPattern == dd->dashPattern)) && p.d->brush == d->brush && pdd->cosmetic == dd->cosmetic && pdd->defaultWidth == dd->defaultWidth);
0
349 && (d->style != Qt::CustomDashLine
never executed: return (p.d == d) || (p.d->style == d->style && p.d->capStyle == d->capStyle && p.d->joinStyle == d->joinStyle && p.d->width == d->width && pdd->miterLimit == dd->miterLimit && (d->style != Qt::CustomDashLine || (qFuzzyCompare(pdd->dashOffset, dd->dashOffset) && pdd->dashPattern == dd->dashPattern)) && p.d->brush == d->brush && pdd->cosmetic == dd->cosmetic && pdd->defaultWidth == dd->defaultWidth);
0
350 || (qFuzzyCompare(pdd->dashOffset, dd->dashOffset) &&
never executed: return (p.d == d) || (p.d->style == d->style && p.d->capStyle == d->capStyle && p.d->joinStyle == d->joinStyle && p.d->width == d->width && pdd->miterLimit == dd->miterLimit && (d->style != Qt::CustomDashLine || (qFuzzyCompare(pdd->dashOffset, dd->dashOffset) && pdd->dashPattern == dd->dashPattern)) && p.d->brush == d->brush && pdd->cosmetic == dd->cosmetic && pdd->defaultWidth == dd->defaultWidth);
0
351 pdd->dashPattern == dd->dashPattern))
never executed: return (p.d == d) || (p.d->style == d->style && p.d->capStyle == d->capStyle && p.d->joinStyle == d->joinStyle && p.d->width == d->width && pdd->miterLimit == dd->miterLimit && (d->style != Qt::CustomDashLine || (qFuzzyCompare(pdd->dashOffset, dd->dashOffset) && pdd->dashPattern == dd->dashPattern)) && p.d->brush == d->brush && pdd->cosmetic == dd->cosmetic && pdd->defaultWidth == dd->defaultWidth);
0
352 && p.d->brush == d->brush
never executed: return (p.d == d) || (p.d->style == d->style && p.d->capStyle == d->capStyle && p.d->joinStyle == d->joinStyle && p.d->width == d->width && pdd->miterLimit == dd->miterLimit && (d->style != Qt::CustomDashLine || (qFuzzyCompare(pdd->dashOffset, dd->dashOffset) && pdd->dashPattern == dd->dashPattern)) && p.d->brush == d->brush && pdd->cosmetic == dd->cosmetic && pdd->defaultWidth == dd->defaultWidth);
0
353 && pdd->cosmetic == dd->cosmetic
never executed: return (p.d == d) || (p.d->style == d->style && p.d->capStyle == d->capStyle && p.d->joinStyle == d->joinStyle && p.d->width == d->width && pdd->miterLimit == dd->miterLimit && (d->style != Qt::CustomDashLine || (qFuzzyCompare(pdd->dashOffset, dd->dashOffset) && pdd->dashPattern == dd->dashPattern)) && p.d->brush == d->brush && pdd->cosmetic == dd->cosmetic && pdd->defaultWidth == dd->defaultWidth);
0
354 && pdd->defaultWidth == dd->defaultWidth);
never executed: return (p.d == d) || (p.d->style == d->style && p.d->capStyle == d->capStyle && p.d->joinStyle == d->joinStyle && p.d->width == d->width && pdd->miterLimit == dd->miterLimit && (d->style != Qt::CustomDashLine || (qFuzzyCompare(pdd->dashOffset, dd->dashOffset) && pdd->dashPattern == dd->dashPattern)) && p.d->brush == d->brush && pdd->cosmetic == dd->cosmetic && pdd->defaultWidth == dd->defaultWidth);
0
355}-
356bool QPen::isDetached()-
357{-
358 return
never executed: return d->ref.load() == 1;
d->ref.load() == 1;
never executed: return d->ref.load() == 1;
0
359}-
360QDataStream &operator<<(QDataStream &s, const QPen &p)-
361{-
362 QPenData *dd = static_cast<QPenData *>(p.d);-
363 if (s.version() < 3
s.version() < 3Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
364 s << (quint8)p.style();-
365 }
never executed: end of block
else if (s.version() < QDataStream::Qt_4_3
s.version() < ...Stream::Qt_4_3Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
366 s << (quint8)(p.style() | p.capStyle() | p.joinStyle());-
367 }
never executed: end of block
else {
0
368 s << (quint16)(p.style() | p.capStyle() | p.joinStyle());-
369 s << (bool)(dd->cosmetic);-
370 }
never executed: end of block
0
371-
372 if (s.version() < 7
s.version() < 7Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
373 s << (quint8)p.width();-
374 s << p.color();-
375 }
never executed: end of block
else {
0
376 s << double(p.widthF());-
377 s << p.brush();-
378 s << double(p.miterLimit());-
379 if (sizeof(qreal) == sizeof(double)
sizeof(qreal) ...sizeof(double)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
380 s << p.dashPattern();-
381 }
never executed: end of block
else {
0
382-
383-
384-
385 QVector<qreal> pattern = p.dashPattern();-
386 s << quint32(pattern.size());-
387 for (int i = 0; i < pattern.size()
i < pattern.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
388 s << double(pattern.at(i));
never executed: s << double(pattern.at(i));
0
389 }
never executed: end of block
0
390 if (s.version() >= 9
s.version() >= 9Description
TRUEnever evaluated
FALSEnever evaluated
)
0
391 s << double(p.dashOffset());
never executed: s << double(p.dashOffset());
0
392 if (s.version() >= QDataStream::Qt_5_0
s.version() >=...Stream::Qt_5_0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
393 s << bool(dd->defaultWidth);
never executed: s << bool(dd->defaultWidth);
0
394 }
never executed: end of block
0
395 return
never executed: return s;
s;
never executed: return s;
0
396}-
397QDataStream &operator>>(QDataStream &s, QPen &p)-
398{-
399 quint16 style;-
400 quint8 width8 = 0;-
401 double width = 0;-
402 QColor color;-
403 QBrush brush;-
404 double miterLimit = 2;-
405 QVector<qreal> dashPattern;-
406 double dashOffset = 0;-
407 bool cosmetic = false;-
408 bool defaultWidth = false;-
409 if (s.version() < QDataStream::Qt_4_3
s.version() < ...Stream::Qt_4_3Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
410 quint8 style8;-
411 s >> style8;-
412 style = style8;-
413 }
never executed: end of block
else {
0
414 s >> style;-
415 s >> cosmetic;-
416 }
never executed: end of block
0
417 if (s.version() < 7
s.version() < 7Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
418 s >> width8;-
419 s >> color;-
420 brush = color;-
421 width = width8;-
422 }
never executed: end of block
else {
0
423 s >> width;-
424 s >> brush;-
425 s >> miterLimit;-
426 if (sizeof(qreal) == sizeof(double)
sizeof(qreal) ...sizeof(double)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
427 s >> dashPattern;-
428 }
never executed: end of block
else {
0
429 quint32 numDashes;-
430 s >> numDashes;-
431 double dash;-
432 dashPattern.reserve(numDashes);-
433 for (quint32 i = 0; i < numDashes
i < numDashesDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
434 s >> dash;-
435 dashPattern << dash;-
436 }
never executed: end of block
0
437 }
never executed: end of block
0
438 if (s.version() >= 9
s.version() >= 9Description
TRUEnever evaluated
FALSEnever evaluated
)
0
439 s >> dashOffset;
never executed: s >> dashOffset;
0
440 }
never executed: end of block
0
441-
442 if (s.version() >= QDataStream::Qt_5_0
s.version() >=...Stream::Qt_5_0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
443 s >> defaultWidth;-
444 }
never executed: end of block
else {
0
445-
446 defaultWidth = qFuzzyIsNull(width);-
447 }
never executed: end of block
0
448-
449 p.detach();-
450 QPenData *dd = static_cast<QPenData *>(p.d);-
451 dd->width = width;-
452 dd->brush = brush;-
453 dd->style = Qt::PenStyle(style & Qt::MPenStyle);-
454 dd->capStyle = Qt::PenCapStyle(style & Qt::MPenCapStyle);-
455 dd->joinStyle = Qt::PenJoinStyle(style & Qt::MPenJoinStyle);-
456 dd->dashPattern = dashPattern;-
457 dd->miterLimit = miterLimit;-
458 dd->dashOffset = dashOffset;-
459 dd->cosmetic = cosmetic;-
460 dd->defaultWidth = defaultWidth;-
461-
462 return
never executed: return s;
s;
never executed: return s;
0
463}-
464-
465-
466-
467QDebug operator<<(QDebug dbg, const QPen &p)-
468{-
469 const char *PEN_STYLES[] = {-
470 "NoPen",-
471 "SolidLine",-
472 "DashLine",-
473 "DotLine",-
474 "DashDotLine",-
475 "DashDotDotLine",-
476 "CustomDashLine"-
477 };-
478-
479 QDebugStateSaver saver(dbg);-
480 dbg.nospace() << "QPen(" << p.width() << ',' << p.brush()-
481 << ',' << PEN_STYLES[p.style()] << ',' << int(p.capStyle())-
482 << ',' << int(p.joinStyle()) << ',' << p.dashPattern()-
483 << ',' << p.dashOffset()-
484 << ',' << p.miterLimit() << ')';-
485 return
never executed: return dbg;
dbg;
never executed: return dbg;
0
486}-
487-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9