Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtGui 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 Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qlcdnumber.h" | - |
43 | #ifndef QT_NO_LCDNUMBER | - |
44 | #include "qbitarray.h" | - |
45 | #include "qpainter.h" | - |
46 | #include "private/qframe_p.h" | - |
47 | | - |
48 | QT_BEGIN_NAMESPACE | - |
49 | | - |
50 | class QLCDNumberPrivate : public QFramePrivate | - |
51 | { | - |
52 | Q_DECLARE_PUBLIC(QLCDNumber) | - |
53 | public: | - |
54 | void init(); | - |
55 | void internalSetString(const QString& s); | - |
56 | void drawString(const QString& s, QPainter &, QBitArray * = 0, bool = true); | - |
57 | //void drawString(const QString &, QPainter &, QBitArray * = 0) const; | - |
58 | void drawDigit(const QPoint &, QPainter &, int, char, char = ' '); | - |
59 | void drawSegment(const QPoint &, char, QPainter &, int, bool = false); | - |
60 | | - |
61 | int ndigits; | - |
62 | double val; | - |
63 | uint base : 2; | - |
64 | uint smallPoint : 1; | - |
65 | uint fill : 1; | - |
66 | uint shadow : 1; | - |
67 | QString digitStr; | - |
68 | QBitArray points; | - |
69 | }; | - |
70 | | - |
71 | /*! | - |
72 | \class QLCDNumber | - |
73 | | - |
74 | \brief The QLCDNumber widget displays a number with LCD-like digits. | - |
75 | | - |
76 | \ingroup basicwidgets | - |
77 | \inmodule QtWidgets | - |
78 | | - |
79 | It can display a number in just about any size. It can display | - |
80 | decimal, hexadecimal, octal or binary numbers. It is easy to | - |
81 | connect to data sources using the display() slot, which is | - |
82 | overloaded to take any of five argument types. | - |
83 | | - |
84 | There are also slots to change the base with setMode() and the | - |
85 | decimal point with setSmallDecimalPoint(). | - |
86 | | - |
87 | QLCDNumber emits the overflow() signal when it is asked to display | - |
88 | something beyond its range. The range is set by setDigitCount(), | - |
89 | but setSmallDecimalPoint() also influences it. If the display is | - |
90 | set to hexadecimal, octal or binary, the integer equivalent of the | - |
91 | value is displayed. | - |
92 | | - |
93 | These digits and other symbols can be shown: 0/O, 1, 2, 3, 4, 5/S, | - |
94 | 6, 7, 8, 9/g, minus, decimal point, A, B, C, D, E, F, h, H, L, o, | - |
95 | P, r, u, U, Y, colon, degree sign (which is specified as single | - |
96 | quote in the string) and space. QLCDNumber substitutes spaces for | - |
97 | illegal characters. | - |
98 | | - |
99 | It is not possible to retrieve the contents of a QLCDNumber | - |
100 | object, although you can retrieve the numeric value with value(). | - |
101 | If you really need the text, we recommend that you connect the | - |
102 | signals that feed the display() slot to another slot as well and | - |
103 | store the value there. | - |
104 | | - |
105 | Incidentally, QLCDNumber is the very oldest part of Qt, tracing | - |
106 | its roots back to a BASIC program on the \l{Sinclair Spectrum}{Sinclair Spectrum}. | - |
107 | | - |
108 | \table | - |
109 | \row \li | - |
110 | \inlineimage windows-lcdnumber.png Screenshot of a Windows style LCD number widget | - |
111 | \inlineimage windowsvista-lcdnumber.png Screenshot of a Windows Vista style LCD number widget | - |
112 | \inlineimage macintosh-lcdnumber.png Screenshot of a Macintosh style LCD number widget | - |
113 | \inlineimage fusion-lcdnumber.png Screenshot of a Fusion style LCD number widget | - |
114 | \row \li LCD number widgets shown in various widget styles (from left to right): | - |
115 | \l{Windows Style Widget Gallery}{Windows}, \l{Windows Vista Style Widget Gallery}{Windows Vista}, | - |
116 | \l{Macintosh Style Widget Gallery}{Macintosh}, \l{Fusion Style Widget Gallery}{Fusion}. | - |
117 | \endtable | - |
118 | | - |
119 | \sa QLabel, QFrame, {Digital Clock Example}, {Tetrix Example} | - |
120 | */ | - |
121 | | - |
122 | /*! | - |
123 | \enum QLCDNumber::Mode | - |
124 | | - |
125 | This type determines how numbers are shown. | - |
126 | | - |
127 | \value Hex Hexadecimal | - |
128 | \value Dec Decimal | - |
129 | \value Oct Octal | - |
130 | \value Bin Binary | - |
131 | | - |
132 | If the display is set to hexadecimal, octal or binary, the integer | - |
133 | equivalent of the value is displayed. | - |
134 | */ | - |
135 | | - |
136 | /*! | - |
137 | \enum QLCDNumber::SegmentStyle | - |
138 | | - |
139 | This type determines the visual appearance of the QLCDNumber | - |
140 | widget. | - |
141 | | - |
142 | \value Outline gives raised segments filled with the background color. | - |
143 | \value Filled gives raised segments filled with the windowText color. | - |
144 | \value Flat gives flat segments filled with the windowText color. | - |
145 | */ | - |
146 | | - |
147 | | - |
148 | | - |
149 | /*! | - |
150 | \fn void QLCDNumber::overflow() | - |
151 | | - |
152 | This signal is emitted whenever the QLCDNumber is asked to display | - |
153 | a too-large number or a too-long string. | - |
154 | | - |
155 | It is never emitted by setDigitCount(). | - |
156 | */ | - |
157 | | - |
158 | | - |
159 | static QString int2string(int num, int base, int ndigits, bool *oflow) | - |
160 | { | - |
161 | QString s; never executed (the execution status of this line is deduced): QString s; | - |
162 | bool negative; never executed (the execution status of this line is deduced): bool negative; | - |
163 | if (num < 0) { | 0 |
164 | negative = true; never executed (the execution status of this line is deduced): negative = true; | - |
165 | num = -num; never executed (the execution status of this line is deduced): num = -num; | - |
166 | } else { | 0 |
167 | negative = false; never executed (the execution status of this line is deduced): negative = false; | - |
168 | } | 0 |
169 | switch(base) { | - |
170 | case QLCDNumber::Hex: | - |
171 | s.sprintf("%*x", ndigits, num); never executed (the execution status of this line is deduced): s.sprintf("%*x", ndigits, num); | - |
172 | break; | 0 |
173 | case QLCDNumber::Dec: | - |
174 | s.sprintf("%*i", ndigits, num); never executed (the execution status of this line is deduced): s.sprintf("%*i", ndigits, num); | - |
175 | break; | 0 |
176 | case QLCDNumber::Oct: | - |
177 | s.sprintf("%*o", ndigits, num); never executed (the execution status of this line is deduced): s.sprintf("%*o", ndigits, num); | - |
178 | break; | 0 |
179 | case QLCDNumber::Bin: | - |
180 | { | - |
181 | char buf[42]; never executed (the execution status of this line is deduced): char buf[42]; | - |
182 | char *p = &buf[41]; never executed (the execution status of this line is deduced): char *p = &buf[41]; | - |
183 | uint n = num; never executed (the execution status of this line is deduced): uint n = num; | - |
184 | int len = 0; never executed (the execution status of this line is deduced): int len = 0; | - |
185 | *p = '\0'; never executed (the execution status of this line is deduced): *p = '\0'; | - |
186 | do { | - |
187 | *--p = (char)((n&1)+'0'); never executed (the execution status of this line is deduced): *--p = (char)((n&1)+'0'); | - |
188 | n >>= 1; never executed (the execution status of this line is deduced): n >>= 1; | - |
189 | len++; never executed (the execution status of this line is deduced): len++; | - |
190 | } while (n != 0); never executed: } never evaluated: n != 0 | 0 |
191 | len = ndigits - len; never executed (the execution status of this line is deduced): len = ndigits - len; | - |
192 | if (len > 0) | 0 |
193 | s.fill(QLatin1Char(' '), len); never executed: s.fill(QLatin1Char(' '), len); | 0 |
194 | s += QString::fromLatin1(p); never executed (the execution status of this line is deduced): s += QString::fromLatin1(p); | - |
195 | } | - |
196 | break; | 0 |
197 | } | - |
198 | if (negative) { never evaluated: negative | 0 |
199 | for (int i=0; i<(int)s.length(); i++) { never evaluated: i<(int)s.length() | 0 |
200 | if (s[i] != QLatin1Char(' ')) { never evaluated: s[i] != QLatin1Char(' ') | 0 |
201 | if (i != 0) { | 0 |
202 | s[i-1] = QLatin1Char('-'); never executed (the execution status of this line is deduced): s[i-1] = QLatin1Char('-'); | - |
203 | } else { | 0 |
204 | s.insert(0, QLatin1Char('-')); never executed (the execution status of this line is deduced): s.insert(0, QLatin1Char('-')); | - |
205 | } | 0 |
206 | break; | 0 |
207 | } | - |
208 | } | 0 |
209 | } | 0 |
210 | if (oflow) | 0 |
211 | *oflow = (int)s.length() > ndigits; never executed: *oflow = (int)s.length() > ndigits; | 0 |
212 | return s; never executed: return s; | 0 |
213 | } | - |
214 | | - |
215 | | - |
216 | static QString double2string(double num, int base, int ndigits, bool *oflow) | - |
217 | { | - |
218 | QString s; executed (the execution status of this line is deduced): QString s; | - |
219 | if (base != QLCDNumber::Dec) { partially evaluated: base != QLCDNumber::Dec no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
220 | bool of = num >= 2147483648.0 || num < -2147483648.0; never evaluated: num >= 2147483648.0 never evaluated: num < -2147483648.0 | 0 |
221 | if (of) { // oops, integer overflow | 0 |
222 | if (oflow) | 0 |
223 | *oflow = true; never executed: *oflow = true; | 0 |
224 | return s; never executed: return s; | 0 |
225 | } | - |
226 | s = int2string((int)num, base, ndigits, 0); never executed (the execution status of this line is deduced): s = int2string((int)num, base, ndigits, 0); | - |
227 | } else { // decimal base | 0 |
228 | int nd = ndigits; executed (the execution status of this line is deduced): int nd = ndigits; | - |
229 | do { | - |
230 | s.sprintf("%*.*g", ndigits, nd, num); executed (the execution status of this line is deduced): s.sprintf("%*.*g", ndigits, nd, num); | - |
231 | int i = s.indexOf(QLatin1Char('e')); executed (the execution status of this line is deduced): int i = s.indexOf(QLatin1Char('e')); | - |
232 | if (i > 0 && s[i+1]==QLatin1Char('+')) { partially evaluated: i > 0 no Evaluation Count:0 | yes Evaluation Count:1 |
never evaluated: s[i+1]==QLatin1Char('+') | 0-1 |
233 | s[i] = QLatin1Char(' '); never executed (the execution status of this line is deduced): s[i] = QLatin1Char(' '); | - |
234 | s[i+1] = QLatin1Char('e'); never executed (the execution status of this line is deduced): s[i+1] = QLatin1Char('e'); | - |
235 | } | 0 |
236 | } while (nd-- && (int)s.length() > ndigits); executed: } Execution Count:1 partially evaluated: nd-- yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: (int)s.length() > ndigits no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
237 | } executed: } Execution Count:1 | 1 |
238 | if (oflow) partially evaluated: oflow yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
239 | *oflow = (int)s.length() > ndigits; executed: *oflow = (int)s.length() > ndigits; Execution Count:1 | 1 |
240 | return s; executed: return s; Execution Count:1 | 1 |
241 | } | - |
242 | | - |
243 | | - |
244 | static const char *getSegments(char ch) // gets list of segments for ch | - |
245 | { | - |
246 | static const char segments[30][8] = | - |
247 | { { 0, 1, 2, 4, 5, 6,99, 0}, // 0 0 / O | - |
248 | { 2, 5,99, 0, 0, 0, 0, 0}, // 1 1 | - |
249 | { 0, 2, 3, 4, 6,99, 0, 0}, // 2 2 | - |
250 | { 0, 2, 3, 5, 6,99, 0, 0}, // 3 3 | - |
251 | { 1, 2, 3, 5,99, 0, 0, 0}, // 4 4 | - |
252 | { 0, 1, 3, 5, 6,99, 0, 0}, // 5 5 / S | - |
253 | { 0, 1, 3, 4, 5, 6,99, 0}, // 6 6 | - |
254 | { 0, 2, 5,99, 0, 0, 0, 0}, // 7 7 | - |
255 | { 0, 1, 2, 3, 4, 5, 6,99}, // 8 8 | - |
256 | { 0, 1, 2, 3, 5, 6,99, 0}, // 9 9 / g | - |
257 | { 3,99, 0, 0, 0, 0, 0, 0}, // 10 - | - |
258 | { 7,99, 0, 0, 0, 0, 0, 0}, // 11 . | - |
259 | { 0, 1, 2, 3, 4, 5,99, 0}, // 12 A | - |
260 | { 1, 3, 4, 5, 6,99, 0, 0}, // 13 B | - |
261 | { 0, 1, 4, 6,99, 0, 0, 0}, // 14 C | - |
262 | { 2, 3, 4, 5, 6,99, 0, 0}, // 15 D | - |
263 | { 0, 1, 3, 4, 6,99, 0, 0}, // 16 E | - |
264 | { 0, 1, 3, 4,99, 0, 0, 0}, // 17 F | - |
265 | { 1, 3, 4, 5,99, 0, 0, 0}, // 18 h | - |
266 | { 1, 2, 3, 4, 5,99, 0, 0}, // 19 H | - |
267 | { 1, 4, 6,99, 0, 0, 0, 0}, // 20 L | - |
268 | { 3, 4, 5, 6,99, 0, 0, 0}, // 21 o | - |
269 | { 0, 1, 2, 3, 4,99, 0, 0}, // 22 P | - |
270 | { 3, 4,99, 0, 0, 0, 0, 0}, // 23 r | - |
271 | { 4, 5, 6,99, 0, 0, 0, 0}, // 24 u | - |
272 | { 1, 2, 4, 5, 6,99, 0, 0}, // 25 U | - |
273 | { 1, 2, 3, 5, 6,99, 0, 0}, // 26 Y | - |
274 | { 8, 9,99, 0, 0, 0, 0, 0}, // 27 : | - |
275 | { 0, 1, 2, 3,99, 0, 0, 0}, // 28 ' | - |
276 | {99, 0, 0, 0, 0, 0, 0, 0} }; // 29 empty | - |
277 | | - |
278 | if (ch >= '0' && ch <= '9') evaluated: ch >= '0' yes Evaluation Count:1 | yes Evaluation Count:9 |
partially evaluated: ch <= '9' yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-9 |
279 | return segments[ch - '0']; executed: return segments[ch - '0']; Execution Count:1 | 1 |
280 | if (ch >= 'A' && ch <= 'F') partially evaluated: ch >= 'A' no Evaluation Count:0 | yes Evaluation Count:9 |
never evaluated: ch <= 'F' | 0-9 |
281 | return segments[ch - 'A' + 12]; never executed: return segments[ch - 'A' + 12]; | 0 |
282 | if (ch >= 'a' && ch <= 'f') partially evaluated: ch >= 'a' no Evaluation Count:0 | yes Evaluation Count:9 |
never evaluated: ch <= 'f' | 0-9 |
283 | return segments[ch - 'a' + 12]; never executed: return segments[ch - 'a' + 12]; | 0 |
284 | | - |
285 | int n; executed (the execution status of this line is deduced): int n; | - |
286 | switch (ch) { | - |
287 | case '-': | - |
288 | n = 10; break; | 0 |
289 | case 'O': | - |
290 | n = 0; break; | 0 |
291 | case 'g': | - |
292 | n = 9; break; | 0 |
293 | case '.': | - |
294 | n = 11; break; | 0 |
295 | case 'h': | - |
296 | n = 18; break; | 0 |
297 | case 'H': | - |
298 | n = 19; break; | 0 |
299 | case 'l': | - |
300 | case 'L': | - |
301 | n = 20; break; | 0 |
302 | case 'o': | - |
303 | n = 21; break; | 0 |
304 | case 'p': | - |
305 | case 'P': | - |
306 | n = 22; break; | 0 |
307 | case 'r': | - |
308 | case 'R': | - |
309 | n = 23; break; | 0 |
310 | case 's': | - |
311 | case 'S': | - |
312 | n = 5; break; | 0 |
313 | case 'u': | - |
314 | n = 24; break; | 0 |
315 | case 'U': | - |
316 | n = 25; break; | 0 |
317 | case 'y': | - |
318 | case 'Y': | - |
319 | n = 26; break; | 0 |
320 | case ':': | - |
321 | n = 27; break; | 0 |
322 | case '\'': | - |
323 | n = 28; break; | 0 |
324 | default: | - |
325 | n = 29; break; executed: break; Execution Count:9 | 9 |
326 | } | - |
327 | return segments[n]; executed: return segments[n]; Execution Count:9 | 9 |
328 | } | - |
329 | | - |
330 | | - |
331 | | - |
332 | /*! | - |
333 | Constructs an LCD number, sets the number of digits to 5, the base | - |
334 | to decimal, the decimal point mode to 'small' and the frame style | - |
335 | to a raised box. The segmentStyle() is set to \c Outline. | - |
336 | | - |
337 | The \a parent argument is passed to the QFrame constructor. | - |
338 | | - |
339 | \sa setDigitCount(), setSmallDecimalPoint() | - |
340 | */ | - |
341 | | - |
342 | QLCDNumber::QLCDNumber(QWidget *parent) | - |
343 | : QFrame(*new QLCDNumberPrivate, parent) | - |
344 | { | - |
345 | Q_D(QLCDNumber); executed (the execution status of this line is deduced): QLCDNumberPrivate * const d = d_func(); | - |
346 | d->ndigits = 5; executed (the execution status of this line is deduced): d->ndigits = 5; | - |
347 | d->init(); executed (the execution status of this line is deduced): d->init(); | - |
348 | } executed: } Execution Count:2 | 2 |
349 | | - |
350 | | - |
351 | /*! | - |
352 | Constructs an LCD number, sets the number of digits to \a | - |
353 | numDigits, the base to decimal, the decimal point mode to 'small' | - |
354 | and the frame style to a raised box. The segmentStyle() is set to | - |
355 | \c Filled. | - |
356 | | - |
357 | The \a parent argument is passed to the QFrame constructor. | - |
358 | | - |
359 | \sa setDigitCount(), setSmallDecimalPoint() | - |
360 | */ | - |
361 | | - |
362 | QLCDNumber::QLCDNumber(uint numDigits, QWidget *parent) | - |
363 | : QFrame(*new QLCDNumberPrivate, parent) | - |
364 | { | - |
365 | Q_D(QLCDNumber); never executed (the execution status of this line is deduced): QLCDNumberPrivate * const d = d_func(); | - |
366 | d->ndigits = numDigits; never executed (the execution status of this line is deduced): d->ndigits = numDigits; | - |
367 | d->init(); never executed (the execution status of this line is deduced): d->init(); | - |
368 | } | 0 |
369 | | - |
370 | void QLCDNumberPrivate::init() | - |
371 | { | - |
372 | Q_Q(QLCDNumber); executed (the execution status of this line is deduced): QLCDNumber * const q = q_func(); | - |
373 | | - |
374 | q->setFrameStyle(QFrame::Box | QFrame::Raised); executed (the execution status of this line is deduced): q->setFrameStyle(QFrame::Box | QFrame::Raised); | - |
375 | val = 0; executed (the execution status of this line is deduced): val = 0; | - |
376 | base = QLCDNumber::Dec; executed (the execution status of this line is deduced): base = QLCDNumber::Dec; | - |
377 | smallPoint = false; executed (the execution status of this line is deduced): smallPoint = false; | - |
378 | q->setDigitCount(ndigits); executed (the execution status of this line is deduced): q->setDigitCount(ndigits); | - |
379 | q->setSegmentStyle(QLCDNumber::Filled); executed (the execution status of this line is deduced): q->setSegmentStyle(QLCDNumber::Filled); | - |
380 | q->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); executed (the execution status of this line is deduced): q->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); | - |
381 | } executed: } Execution Count:2 | 2 |
382 | | - |
383 | /*! | - |
384 | Destroys the LCD number. | - |
385 | */ | - |
386 | | - |
387 | QLCDNumber::~QLCDNumber() | - |
388 | { | - |
389 | } | - |
390 | | - |
391 | | - |
392 | /*! | - |
393 | \since 4.6 | - |
394 | \property QLCDNumber::digitCount | - |
395 | \brief the current number of digits displayed | - |
396 | | - |
397 | Corresponds to the current number of digits. If \l | - |
398 | QLCDNumber::smallDecimalPoint is false, the decimal point occupies | - |
399 | one digit position. | - |
400 | | - |
401 | By default, this property contains a value of 5. | - |
402 | | - |
403 | \sa smallDecimalPoint | - |
404 | */ | - |
405 | | - |
406 | /*! | - |
407 | Sets the current number of digits to \a numDigits. Must | - |
408 | be in the range 0..99. | - |
409 | */ | - |
410 | void QLCDNumber::setDigitCount(int numDigits) | - |
411 | { | - |
412 | Q_D(QLCDNumber); executed (the execution status of this line is deduced): QLCDNumberPrivate * const d = d_func(); | - |
413 | if (numDigits > 99) { evaluated: numDigits > 99 yes Evaluation Count:1 | yes Evaluation Count:4 |
| 1-4 |
414 | qWarning("QLCDNumber::setNumDigits: (%s) Max 99 digits allowed", executed (the execution status of this line is deduced): QMessageLogger("widgets/qlcdnumber.cpp", 414, __PRETTY_FUNCTION__).warning("QLCDNumber::setNumDigits: (%s) Max 99 digits allowed", | - |
415 | objectName().toLocal8Bit().constData()); executed (the execution status of this line is deduced): objectName().toLocal8Bit().constData()); | - |
416 | numDigits = 99; executed (the execution status of this line is deduced): numDigits = 99; | - |
417 | } executed: } Execution Count:1 | 1 |
418 | if (numDigits < 0) { evaluated: numDigits < 0 yes Evaluation Count:1 | yes Evaluation Count:4 |
| 1-4 |
419 | qWarning("QLCDNumber::setNumDigits: (%s) Min 0 digits allowed", executed (the execution status of this line is deduced): QMessageLogger("widgets/qlcdnumber.cpp", 419, __PRETTY_FUNCTION__).warning("QLCDNumber::setNumDigits: (%s) Min 0 digits allowed", | - |
420 | objectName().toLocal8Bit().constData()); executed (the execution status of this line is deduced): objectName().toLocal8Bit().constData()); | - |
421 | numDigits = 0; executed (the execution status of this line is deduced): numDigits = 0; | - |
422 | } executed: } Execution Count:1 | 1 |
423 | if (d->digitStr.isNull()) { // from constructor evaluated: d->digitStr.isNull() yes Evaluation Count:2 | yes Evaluation Count:3 |
| 2-3 |
424 | d->ndigits = numDigits; executed (the execution status of this line is deduced): d->ndigits = numDigits; | - |
425 | d->digitStr.fill(QLatin1Char(' '), d->ndigits); executed (the execution status of this line is deduced): d->digitStr.fill(QLatin1Char(' '), d->ndigits); | - |
426 | d->points.fill(0, d->ndigits); executed (the execution status of this line is deduced): d->points.fill(0, d->ndigits); | - |
427 | d->digitStr[d->ndigits - 1] = QLatin1Char('0'); // "0" is the default number executed (the execution status of this line is deduced): d->digitStr[d->ndigits - 1] = QLatin1Char('0'); | - |
428 | } else { executed: } Execution Count:2 | 2 |
429 | bool doDisplay = d->ndigits == 0; executed (the execution status of this line is deduced): bool doDisplay = d->ndigits == 0; | - |
430 | if (numDigits == d->ndigits) // no change evaluated: numDigits == d->ndigits yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
431 | return; executed: return; Execution Count:1 | 1 |
432 | register int i; executed (the execution status of this line is deduced): register int i; | - |
433 | int dif; executed (the execution status of this line is deduced): int dif; | - |
434 | if (numDigits > d->ndigits) { // expand evaluated: numDigits > d->ndigits yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
435 | dif = numDigits - d->ndigits; executed (the execution status of this line is deduced): dif = numDigits - d->ndigits; | - |
436 | QString buf; executed (the execution status of this line is deduced): QString buf; | - |
437 | buf.fill(QLatin1Char(' '), dif); executed (the execution status of this line is deduced): buf.fill(QLatin1Char(' '), dif); | - |
438 | d->digitStr.insert(0, buf); executed (the execution status of this line is deduced): d->digitStr.insert(0, buf); | - |
439 | d->points.resize(numDigits); executed (the execution status of this line is deduced): d->points.resize(numDigits); | - |
440 | for (i=numDigits-1; i>=dif; i--) partially evaluated: i>=dif no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
441 | d->points.setBit(i, d->points.testBit(i-dif)); never executed: d->points.setBit(i, d->points.testBit(i-dif)); | 0 |
442 | for (i=0; i<dif; i++) evaluated: i<dif yes Evaluation Count:99 | yes Evaluation Count:1 |
| 1-99 |
443 | d->points.clearBit(i); executed: d->points.clearBit(i); Execution Count:99 | 99 |
444 | } else { // shrink executed: } Execution Count:1 | 1 |
445 | dif = d->ndigits - numDigits; executed (the execution status of this line is deduced): dif = d->ndigits - numDigits; | - |
446 | d->digitStr = d->digitStr.right(numDigits); executed (the execution status of this line is deduced): d->digitStr = d->digitStr.right(numDigits); | - |
447 | QBitArray tmpPoints = d->points; executed (the execution status of this line is deduced): QBitArray tmpPoints = d->points; | - |
448 | d->points.resize(numDigits); executed (the execution status of this line is deduced): d->points.resize(numDigits); | - |
449 | for (i=0; i<(int)numDigits; i++) partially evaluated: i<(int)numDigits no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
450 | d->points.setBit(i, tmpPoints.testBit(i+dif)); never executed: d->points.setBit(i, tmpPoints.testBit(i+dif)); | 0 |
451 | } executed: } Execution Count:1 | 1 |
452 | d->ndigits = numDigits; executed (the execution status of this line is deduced): d->ndigits = numDigits; | - |
453 | if (doDisplay) evaluated: doDisplay yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
454 | display(value()); executed: display(value()); Execution Count:1 | 1 |
455 | update(); executed (the execution status of this line is deduced): update(); | - |
456 | } executed: } Execution Count:2 | 2 |
457 | } | - |
458 | | - |
459 | /*! | - |
460 | Returns the current number of digits. | - |
461 | */ | - |
462 | int QLCDNumber::digitCount() const | - |
463 | { | - |
464 | Q_D(const QLCDNumber); executed (the execution status of this line is deduced): const QLCDNumberPrivate * const d = d_func(); | - |
465 | return d->ndigits; executed: return d->ndigits; Execution Count:4 | 4 |
466 | } | - |
467 | | - |
468 | /*! | - |
469 | \overload | - |
470 | | - |
471 | Returns true if \a num is too big to be displayed in its entirety; | - |
472 | otherwise returns false. | - |
473 | | - |
474 | \sa display(), digitCount(), smallDecimalPoint() | - |
475 | */ | - |
476 | | - |
477 | bool QLCDNumber::checkOverflow(int num) const | - |
478 | { | - |
479 | Q_D(const QLCDNumber); never executed (the execution status of this line is deduced): const QLCDNumberPrivate * const d = d_func(); | - |
480 | bool of; never executed (the execution status of this line is deduced): bool of; | - |
481 | int2string(num, d->base, d->ndigits, &of); never executed (the execution status of this line is deduced): int2string(num, d->base, d->ndigits, &of); | - |
482 | return of; never executed: return of; | 0 |
483 | } | - |
484 | | - |
485 | | - |
486 | /*! | - |
487 | Returns true if \a num is too big to be displayed in its entirety; | - |
488 | otherwise returns false. | - |
489 | | - |
490 | \sa display(), digitCount(), smallDecimalPoint() | - |
491 | */ | - |
492 | | - |
493 | bool QLCDNumber::checkOverflow(double num) const | - |
494 | { | - |
495 | Q_D(const QLCDNumber); never executed (the execution status of this line is deduced): const QLCDNumberPrivate * const d = d_func(); | - |
496 | bool of; never executed (the execution status of this line is deduced): bool of; | - |
497 | double2string(num, d->base, d->ndigits, &of); never executed (the execution status of this line is deduced): double2string(num, d->base, d->ndigits, &of); | - |
498 | return of; never executed: return of; | 0 |
499 | } | - |
500 | | - |
501 | | - |
502 | /*! | - |
503 | \property QLCDNumber::mode | - |
504 | \brief the current display mode (number base) | - |
505 | | - |
506 | Corresponds to the current display mode, which is one of \c Bin, | - |
507 | \c Oct, \c Dec (the default) and \c Hex. \c Dec mode can display | - |
508 | floating point values, the other modes display the integer | - |
509 | equivalent. | - |
510 | | - |
511 | \sa smallDecimalPoint(), setHexMode(), setDecMode(), setOctMode(), setBinMode() | - |
512 | */ | - |
513 | | - |
514 | QLCDNumber::Mode QLCDNumber::mode() const | - |
515 | { | - |
516 | Q_D(const QLCDNumber); never executed (the execution status of this line is deduced): const QLCDNumberPrivate * const d = d_func(); | - |
517 | return (QLCDNumber::Mode) d->base; never executed: return (QLCDNumber::Mode) d->base; | 0 |
518 | } | - |
519 | | - |
520 | void QLCDNumber::setMode(Mode m) | - |
521 | { | - |
522 | Q_D(QLCDNumber); never executed (the execution status of this line is deduced): QLCDNumberPrivate * const d = d_func(); | - |
523 | d->base = m; never executed (the execution status of this line is deduced): d->base = m; | - |
524 | display(d->val); never executed (the execution status of this line is deduced): display(d->val); | - |
525 | } | 0 |
526 | | - |
527 | | - |
528 | /*! | - |
529 | \property QLCDNumber::value | - |
530 | \brief the displayed value | - |
531 | | - |
532 | This property corresponds to the current value displayed by the | - |
533 | LCDNumber. | - |
534 | | - |
535 | If the displayed value is not a number, the property has a value | - |
536 | of 0. | - |
537 | | - |
538 | By default, this property contains a value of 0. | - |
539 | */ | - |
540 | | - |
541 | double QLCDNumber::value() const | - |
542 | { | - |
543 | Q_D(const QLCDNumber); executed (the execution status of this line is deduced): const QLCDNumberPrivate * const d = d_func(); | - |
544 | return d->val; executed: return d->val; Execution Count:1 | 1 |
545 | } | - |
546 | | - |
547 | /*! | - |
548 | \overload | - |
549 | | - |
550 | Displays the number \a num. | - |
551 | */ | - |
552 | void QLCDNumber::display(double num) | - |
553 | { | - |
554 | Q_D(QLCDNumber); executed (the execution status of this line is deduced): QLCDNumberPrivate * const d = d_func(); | - |
555 | d->val = num; executed (the execution status of this line is deduced): d->val = num; | - |
556 | bool of; executed (the execution status of this line is deduced): bool of; | - |
557 | QString s = double2string(d->val, d->base, d->ndigits, &of); executed (the execution status of this line is deduced): QString s = double2string(d->val, d->base, d->ndigits, &of); | - |
558 | if (of) partially evaluated: of no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
559 | emit overflow(); never executed: overflow(); | 0 |
560 | else | - |
561 | d->internalSetString(s); executed: d->internalSetString(s); Execution Count:1 | 1 |
562 | } | - |
563 | | - |
564 | /*! | - |
565 | \property QLCDNumber::intValue | - |
566 | \brief the displayed value rounded to the nearest integer | - |
567 | | - |
568 | This property corresponds to the nearest integer to the current | - |
569 | value displayed by the LCDNumber. This is the value used for | - |
570 | hexadecimal, octal and binary modes. | - |
571 | | - |
572 | If the displayed value is not a number, the property has a value | - |
573 | of 0. | - |
574 | | - |
575 | By default, this property contains a value of 0. | - |
576 | */ | - |
577 | int QLCDNumber::intValue() const | - |
578 | { | - |
579 | Q_D(const QLCDNumber); never executed (the execution status of this line is deduced): const QLCDNumberPrivate * const d = d_func(); | - |
580 | return qRound(d->val); never executed: return qRound(d->val); | 0 |
581 | } | - |
582 | | - |
583 | | - |
584 | /*! | - |
585 | \overload | - |
586 | | - |
587 | Displays the number \a num. | - |
588 | */ | - |
589 | void QLCDNumber::display(int num) | - |
590 | { | - |
591 | Q_D(QLCDNumber); never executed (the execution status of this line is deduced): QLCDNumberPrivate * const d = d_func(); | - |
592 | d->val = (double)num; never executed (the execution status of this line is deduced): d->val = (double)num; | - |
593 | bool of; never executed (the execution status of this line is deduced): bool of; | - |
594 | QString s = int2string(num, d->base, d->ndigits, &of); never executed (the execution status of this line is deduced): QString s = int2string(num, d->base, d->ndigits, &of); | - |
595 | if (of) | 0 |
596 | emit overflow(); never executed: overflow(); | 0 |
597 | else | - |
598 | d->internalSetString(s); never executed: d->internalSetString(s); | 0 |
599 | } | - |
600 | | - |
601 | | - |
602 | /*! | - |
603 | Displays the number represented by the string \a s. | - |
604 | | - |
605 | This version of the function disregards mode() and | - |
606 | smallDecimalPoint(). | - |
607 | | - |
608 | These digits and other symbols can be shown: 0/O, 1, 2, 3, 4, 5/S, | - |
609 | 6, 7, 8, 9/g, minus, decimal point, A, B, C, D, E, F, h, H, L, o, | - |
610 | P, r, u, U, Y, colon, degree sign (which is specified as single | - |
611 | quote in the string) and space. QLCDNumber substitutes spaces for | - |
612 | illegal characters. | - |
613 | */ | - |
614 | | - |
615 | void QLCDNumber::display(const QString &s) | - |
616 | { | - |
617 | Q_D(QLCDNumber); never executed (the execution status of this line is deduced): QLCDNumberPrivate * const d = d_func(); | - |
618 | d->val = 0; never executed (the execution status of this line is deduced): d->val = 0; | - |
619 | bool ok = false; never executed (the execution status of this line is deduced): bool ok = false; | - |
620 | double v = s.toDouble(&ok); never executed (the execution status of this line is deduced): double v = s.toDouble(&ok); | - |
621 | if (ok) | 0 |
622 | d->val = v; never executed: d->val = v; | 0 |
623 | d->internalSetString(s); never executed (the execution status of this line is deduced): d->internalSetString(s); | - |
624 | } | 0 |
625 | | - |
626 | /*! | - |
627 | Calls setMode(Hex). Provided for convenience (e.g. for | - |
628 | connecting buttons to it). | - |
629 | | - |
630 | \sa setMode(), setDecMode(), setOctMode(), setBinMode(), mode() | - |
631 | */ | - |
632 | | - |
633 | void QLCDNumber::setHexMode() | - |
634 | { | - |
635 | setMode(Hex); never executed (the execution status of this line is deduced): setMode(Hex); | - |
636 | } | 0 |
637 | | - |
638 | | - |
639 | /*! | - |
640 | Calls setMode(Dec). Provided for convenience (e.g. for | - |
641 | connecting buttons to it). | - |
642 | | - |
643 | \sa setMode(), setHexMode(), setOctMode(), setBinMode(), mode() | - |
644 | */ | - |
645 | | - |
646 | void QLCDNumber::setDecMode() | - |
647 | { | - |
648 | setMode(Dec); never executed (the execution status of this line is deduced): setMode(Dec); | - |
649 | } | 0 |
650 | | - |
651 | | - |
652 | /*! | - |
653 | Calls setMode(Oct). Provided for convenience (e.g. for | - |
654 | connecting buttons to it). | - |
655 | | - |
656 | \sa setMode(), setHexMode(), setDecMode(), setBinMode(), mode() | - |
657 | */ | - |
658 | | - |
659 | void QLCDNumber::setOctMode() | - |
660 | { | - |
661 | setMode(Oct); never executed (the execution status of this line is deduced): setMode(Oct); | - |
662 | } | 0 |
663 | | - |
664 | | - |
665 | /*! | - |
666 | Calls setMode(Bin). Provided for convenience (e.g. for | - |
667 | connecting buttons to it). | - |
668 | | - |
669 | \sa setMode(), setHexMode(), setDecMode(), setOctMode(), mode() | - |
670 | */ | - |
671 | | - |
672 | void QLCDNumber::setBinMode() | - |
673 | { | - |
674 | setMode(Bin); never executed (the execution status of this line is deduced): setMode(Bin); | - |
675 | } | 0 |
676 | | - |
677 | | - |
678 | /*! | - |
679 | \property QLCDNumber::smallDecimalPoint | - |
680 | \brief the style of the decimal point | - |
681 | | - |
682 | If true the decimal point is drawn between two digit positions. | - |
683 | Otherwise it occupies a digit position of its own, i.e. is drawn | - |
684 | in a digit position. The default is false. | - |
685 | | - |
686 | The inter-digit space is made slightly wider when the decimal | - |
687 | point is drawn between the digits. | - |
688 | | - |
689 | \sa mode | - |
690 | */ | - |
691 | | - |
692 | void QLCDNumber::setSmallDecimalPoint(bool b) | - |
693 | { | - |
694 | Q_D(QLCDNumber); never executed (the execution status of this line is deduced): QLCDNumberPrivate * const d = d_func(); | - |
695 | d->smallPoint = b; never executed (the execution status of this line is deduced): d->smallPoint = b; | - |
696 | update(); never executed (the execution status of this line is deduced): update(); | - |
697 | } | 0 |
698 | | - |
699 | bool QLCDNumber::smallDecimalPoint() const | - |
700 | { | - |
701 | Q_D(const QLCDNumber); executed (the execution status of this line is deduced): const QLCDNumberPrivate * const d = d_func(); | - |
702 | return d->smallPoint; executed: return d->smallPoint; Execution Count:1 | 1 |
703 | } | - |
704 | | - |
705 | | - |
706 | | - |
707 | /*!\reimp | - |
708 | */ | - |
709 | | - |
710 | | - |
711 | void QLCDNumber::paintEvent(QPaintEvent *) | - |
712 | { | - |
713 | Q_D(QLCDNumber); executed (the execution status of this line is deduced): QLCDNumberPrivate * const d = d_func(); | - |
714 | QPainter p(this); executed (the execution status of this line is deduced): QPainter p(this); | - |
715 | drawFrame(&p); executed (the execution status of this line is deduced): drawFrame(&p); | - |
716 | p.setRenderHint(QPainter::Antialiasing); executed (the execution status of this line is deduced): p.setRenderHint(QPainter::Antialiasing); | - |
717 | if (d->shadow) partially evaluated: d->shadow yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
718 | p.translate(0.5, 0.5); executed: p.translate(0.5, 0.5); Execution Count:1 | 1 |
719 | | - |
720 | if (d->smallPoint) partially evaluated: d->smallPoint no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
721 | d->drawString(d->digitStr, p, &d->points, false); never executed: d->drawString(d->digitStr, p, &d->points, false); | 0 |
722 | else | - |
723 | d->drawString(d->digitStr, p, 0, false); executed: d->drawString(d->digitStr, p, 0, false); Execution Count:1 | 1 |
724 | } | - |
725 | | - |
726 | | - |
727 | void QLCDNumberPrivate::internalSetString(const QString& s) | - |
728 | { | - |
729 | Q_Q(QLCDNumber); executed (the execution status of this line is deduced): QLCDNumber * const q = q_func(); | - |
730 | QString buffer; executed (the execution status of this line is deduced): QString buffer; | - |
731 | int i; executed (the execution status of this line is deduced): int i; | - |
732 | int len = s.length(); executed (the execution status of this line is deduced): int len = s.length(); | - |
733 | QBitArray newPoints(ndigits); executed (the execution status of this line is deduced): QBitArray newPoints(ndigits); | - |
734 | | - |
735 | if (!smallPoint) { partially evaluated: !smallPoint yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
736 | if (len == ndigits) partially evaluated: len == ndigits yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
737 | buffer = s; executed: buffer = s; Execution Count:1 | 1 |
738 | else | - |
739 | buffer = s.right(ndigits).rightJustified(ndigits, QLatin1Char(' ')); never executed: buffer = s.right(ndigits).rightJustified(ndigits, QLatin1Char(' ')); | 0 |
740 | } else { | - |
741 | int index = -1; never executed (the execution status of this line is deduced): int index = -1; | - |
742 | bool lastWasPoint = true; never executed (the execution status of this line is deduced): bool lastWasPoint = true; | - |
743 | newPoints.clearBit(0); never executed (the execution status of this line is deduced): newPoints.clearBit(0); | - |
744 | for (i=0; i<len; i++) { | 0 |
745 | if (s[i] == QLatin1Char('.')) { never evaluated: s[i] == QLatin1Char('.') | 0 |
746 | if (lastWasPoint) { // point already set for digit? never evaluated: lastWasPoint | 0 |
747 | if (index == ndigits - 1) // no more digits never evaluated: index == ndigits - 1 | 0 |
748 | break; | 0 |
749 | index++; never executed (the execution status of this line is deduced): index++; | - |
750 | buffer[index] = QLatin1Char(' '); // 2 points in a row, add space never executed (the execution status of this line is deduced): buffer[index] = QLatin1Char(' '); | - |
751 | } | 0 |
752 | newPoints.setBit(index); // set decimal point never executed (the execution status of this line is deduced): newPoints.setBit(index); | - |
753 | lastWasPoint = true; never executed (the execution status of this line is deduced): lastWasPoint = true; | - |
754 | } else { | 0 |
755 | if (index == ndigits - 1) never evaluated: index == ndigits - 1 | 0 |
756 | break; | 0 |
757 | index++; never executed (the execution status of this line is deduced): index++; | - |
758 | buffer[index] = s[i]; never executed (the execution status of this line is deduced): buffer[index] = s[i]; | - |
759 | newPoints.clearBit(index); // decimal point default off never executed (the execution status of this line is deduced): newPoints.clearBit(index); | - |
760 | lastWasPoint = false; never executed (the execution status of this line is deduced): lastWasPoint = false; | - |
761 | } | 0 |
762 | } | - |
763 | if (index < ((int) ndigits) - 1) { never evaluated: index < ((int) ndigits) - 1 | 0 |
764 | for(i=index; i>=0; i--) { | 0 |
765 | buffer[ndigits - 1 - index + i] = buffer[i]; never executed (the execution status of this line is deduced): buffer[ndigits - 1 - index + i] = buffer[i]; | - |
766 | newPoints.setBit(ndigits - 1 - index + i, never executed (the execution status of this line is deduced): newPoints.setBit(ndigits - 1 - index + i, | - |
767 | newPoints.testBit(i)); never executed (the execution status of this line is deduced): newPoints.testBit(i)); | - |
768 | } | 0 |
769 | for(i=0; i<ndigits-index-1; i++) { never evaluated: i<ndigits-index-1 | 0 |
770 | buffer[i] = QLatin1Char(' '); never executed (the execution status of this line is deduced): buffer[i] = QLatin1Char(' '); | - |
771 | newPoints.clearBit(i); never executed (the execution status of this line is deduced): newPoints.clearBit(i); | - |
772 | } | 0 |
773 | } | 0 |
774 | } | 0 |
775 | | - |
776 | if (buffer == digitStr) partially evaluated: buffer == digitStr no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
777 | return; | 0 |
778 | | - |
779 | digitStr = buffer; executed (the execution status of this line is deduced): digitStr = buffer; | - |
780 | if (smallPoint) partially evaluated: smallPoint no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
781 | points = newPoints; never executed: points = newPoints; | 0 |
782 | q->update(); executed (the execution status of this line is deduced): q->update(); | - |
783 | } executed: } Execution Count:1 | 1 |
784 | | - |
785 | /*! | - |
786 | \internal | - |
787 | */ | - |
788 | | - |
789 | void QLCDNumberPrivate::drawString(const QString &s, QPainter &p, | - |
790 | QBitArray *newPoints, bool newString) | - |
791 | { | - |
792 | Q_Q(QLCDNumber); executed (the execution status of this line is deduced): QLCDNumber * const q = q_func(); | - |
793 | QPoint pos; executed (the execution status of this line is deduced): QPoint pos; | - |
794 | | - |
795 | int digitSpace = smallPoint ? 2 : 1; partially evaluated: smallPoint no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
796 | int xSegLen = q->width()*5/(ndigits*(5 + digitSpace) + digitSpace); executed (the execution status of this line is deduced): int xSegLen = q->width()*5/(ndigits*(5 + digitSpace) + digitSpace); | - |
797 | int ySegLen = q->height()*5/12; executed (the execution status of this line is deduced): int ySegLen = q->height()*5/12; | - |
798 | int segLen = ySegLen > xSegLen ? xSegLen : ySegLen; partially evaluated: ySegLen > xSegLen yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
799 | int xAdvance = segLen*(5 + digitSpace)/5; executed (the execution status of this line is deduced): int xAdvance = segLen*(5 + digitSpace)/5; | - |
800 | int xOffset = (q->width() - ndigits*xAdvance + segLen/5)/2; executed (the execution status of this line is deduced): int xOffset = (q->width() - ndigits*xAdvance + segLen/5)/2; | - |
801 | int yOffset = (q->height() - segLen*2)/2; executed (the execution status of this line is deduced): int yOffset = (q->height() - segLen*2)/2; | - |
802 | | - |
803 | for (int i=0; i<ndigits; i++) { evaluated: i<ndigits yes Evaluation Count:5 | yes Evaluation Count:1 |
| 1-5 |
804 | pos = QPoint(xOffset + xAdvance*i, yOffset); executed (the execution status of this line is deduced): pos = QPoint(xOffset + xAdvance*i, yOffset); | - |
805 | if (newString) partially evaluated: newString no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
806 | drawDigit(pos, p, segLen, s[i].toLatin1(), digitStr[i].toLatin1()); never executed: drawDigit(pos, p, segLen, s[i].toLatin1(), digitStr[i].toLatin1()); | 0 |
807 | else | - |
808 | drawDigit(pos, p, segLen, s[i].toLatin1()); executed: drawDigit(pos, p, segLen, s[i].toLatin1()); Execution Count:5 | 5 |
809 | if (newPoints) { partially evaluated: newPoints no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
810 | char newPoint = newPoints->testBit(i) ? '.' : ' '; never evaluated: newPoints->testBit(i) | 0 |
811 | if (newString) { never evaluated: newString | 0 |
812 | char oldPoint = points.testBit(i) ? '.' : ' '; never evaluated: points.testBit(i) | 0 |
813 | drawDigit(pos, p, segLen, newPoint, oldPoint); never executed (the execution status of this line is deduced): drawDigit(pos, p, segLen, newPoint, oldPoint); | - |
814 | } else { | 0 |
815 | drawDigit(pos, p, segLen, newPoint); never executed (the execution status of this line is deduced): drawDigit(pos, p, segLen, newPoint); | - |
816 | } | 0 |
817 | } | - |
818 | } executed: } Execution Count:5 | 5 |
819 | if (newString) { partially evaluated: newString no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
820 | digitStr = s; never executed (the execution status of this line is deduced): digitStr = s; | - |
821 | digitStr.truncate(ndigits); never executed (the execution status of this line is deduced): digitStr.truncate(ndigits); | - |
822 | if (newPoints) never evaluated: newPoints | 0 |
823 | points = *newPoints; never executed: points = *newPoints; | 0 |
824 | } | 0 |
825 | } executed: } Execution Count:1 | 1 |
826 | | - |
827 | | - |
828 | /*! | - |
829 | \internal | - |
830 | */ | - |
831 | | - |
832 | void QLCDNumberPrivate::drawDigit(const QPoint &pos, QPainter &p, int segLen, | - |
833 | char newCh, char oldCh) | - |
834 | { | - |
835 | // Draws and/or erases segments to change display of a single digit | - |
836 | // from oldCh to newCh | - |
837 | | - |
838 | char updates[18][2]; // can hold 2 times number of segments, only executed (the execution status of this line is deduced): char updates[18][2]; | - |
839 | // first 9 used if segment table is correct | - |
840 | int nErases; executed (the execution status of this line is deduced): int nErases; | - |
841 | int nUpdates; executed (the execution status of this line is deduced): int nUpdates; | - |
842 | const char *segs; executed (the execution status of this line is deduced): const char *segs; | - |
843 | int i,j; executed (the execution status of this line is deduced): int i,j; | - |
844 | | - |
845 | const char erase = 0; executed (the execution status of this line is deduced): const char erase = 0; | - |
846 | const char draw = 1; executed (the execution status of this line is deduced): const char draw = 1; | - |
847 | const char leaveAlone = 2; executed (the execution status of this line is deduced): const char leaveAlone = 2; | - |
848 | | - |
849 | segs = getSegments(oldCh); executed (the execution status of this line is deduced): segs = getSegments(oldCh); | - |
850 | for (nErases=0; segs[nErases] != 99; nErases++) { partially evaluated: segs[nErases] != 99 no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
851 | updates[nErases][0] = erase; // get segments to erase to never executed (the execution status of this line is deduced): updates[nErases][0] = erase; | - |
852 | updates[nErases][1] = segs[nErases]; // remove old char never executed (the execution status of this line is deduced): updates[nErases][1] = segs[nErases]; | - |
853 | } | 0 |
854 | nUpdates = nErases; executed (the execution status of this line is deduced): nUpdates = nErases; | - |
855 | segs = getSegments(newCh); executed (the execution status of this line is deduced): segs = getSegments(newCh); | - |
856 | for(i = 0 ; segs[i] != 99 ; i++) { evaluated: segs[i] != 99 yes Evaluation Count:6 | yes Evaluation Count:5 |
| 5-6 |
857 | for (j=0; j<nErases; j++) partially evaluated: j<nErases no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
858 | if (segs[i] == updates[j][1]) { // same segment ? never evaluated: segs[i] == updates[j][1] | 0 |
859 | updates[j][0] = leaveAlone; // yes, already on screen never executed (the execution status of this line is deduced): updates[j][0] = leaveAlone; | - |
860 | break; | 0 |
861 | } | - |
862 | if (j == nErases) { // if not already on screen partially evaluated: j == nErases yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
863 | updates[nUpdates][0] = draw; executed (the execution status of this line is deduced): updates[nUpdates][0] = draw; | - |
864 | updates[nUpdates][1] = segs[i]; executed (the execution status of this line is deduced): updates[nUpdates][1] = segs[i]; | - |
865 | nUpdates++; executed (the execution status of this line is deduced): nUpdates++; | - |
866 | } executed: } Execution Count:6 | 6 |
867 | } executed: } Execution Count:6 | 6 |
868 | for (i=0; i<nUpdates; i++) { evaluated: i<nUpdates yes Evaluation Count:6 | yes Evaluation Count:5 |
| 5-6 |
869 | if (updates[i][0] == draw) partially evaluated: updates[i][0] == draw yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
870 | drawSegment(pos, updates[i][1], p, segLen); executed: drawSegment(pos, updates[i][1], p, segLen); Execution Count:6 | 6 |
871 | if (updates[i][0] == erase) partially evaluated: updates[i][0] == erase no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
872 | drawSegment(pos, updates[i][1], p, segLen, true); never executed: drawSegment(pos, updates[i][1], p, segLen, true); | 0 |
873 | } executed: } Execution Count:6 | 6 |
874 | } executed: } Execution Count:5 | 5 |
875 | | - |
876 | | - |
877 | static void addPoint(QPolygon &a, const QPoint &p) | - |
878 | { | - |
879 | uint n = a.size(); executed (the execution status of this line is deduced): uint n = a.size(); | - |
880 | a.resize(n + 1); executed (the execution status of this line is deduced): a.resize(n + 1); | - |
881 | a.setPoint(n, p); executed (the execution status of this line is deduced): a.setPoint(n, p); | - |
882 | } executed: } Execution Count:24 | 24 |
883 | | - |
884 | /*! | - |
885 | \internal | - |
886 | */ | - |
887 | | - |
888 | void QLCDNumberPrivate::drawSegment(const QPoint &pos, char segmentNo, QPainter &p, | - |
889 | int segLen, bool erase) | - |
890 | { | - |
891 | Q_Q(QLCDNumber); executed (the execution status of this line is deduced): QLCDNumber * const q = q_func(); | - |
892 | QPoint ppt; executed (the execution status of this line is deduced): QPoint ppt; | - |
893 | QPoint pt = pos; executed (the execution status of this line is deduced): QPoint pt = pos; | - |
894 | int width = segLen/5; executed (the execution status of this line is deduced): int width = segLen/5; | - |
895 | | - |
896 | const QPalette &pal = q->palette(); executed (the execution status of this line is deduced): const QPalette &pal = q->palette(); | - |
897 | QColor lightColor,darkColor,fgColor; executed (the execution status of this line is deduced): QColor lightColor,darkColor,fgColor; | - |
898 | if (erase){ partially evaluated: erase no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
899 | lightColor = pal.color(q->backgroundRole()); never executed (the execution status of this line is deduced): lightColor = pal.color(q->backgroundRole()); | - |
900 | darkColor = lightColor; never executed (the execution status of this line is deduced): darkColor = lightColor; | - |
901 | fgColor = lightColor; never executed (the execution status of this line is deduced): fgColor = lightColor; | - |
902 | } else { | 0 |
903 | lightColor = pal.light().color(); executed (the execution status of this line is deduced): lightColor = pal.light().color(); | - |
904 | darkColor = pal.dark().color(); executed (the execution status of this line is deduced): darkColor = pal.dark().color(); | - |
905 | fgColor = pal.color(q->foregroundRole()); executed (the execution status of this line is deduced): fgColor = pal.color(q->foregroundRole()); | - |
906 | } executed: } Execution Count:6 | 6 |
907 | | - |
908 | | - |
909 | #define LINETO(X,Y) addPoint(a, QPoint(pt.x() + (X),pt.y() + (Y))) | - |
910 | #define LIGHT | - |
911 | #define DARK | - |
912 | | - |
913 | if (fill) { partially evaluated: fill yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
914 | QPolygon a(0); executed (the execution status of this line is deduced): QPolygon a(0); | - |
915 | //The following is an exact copy of the switch below. | - |
916 | //don't make any changes here | - |
917 | switch (segmentNo) { | - |
918 | case 0 : | - |
919 | ppt = pt; executed (the execution status of this line is deduced): ppt = pt; | - |
920 | LIGHT; | - |
921 | LINETO(segLen - 1,0); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (segLen - 1),pt.y() + (0))); | - |
922 | DARK; | - |
923 | LINETO(segLen - width - 1,width); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (segLen - width - 1),pt.y() + (width))); | - |
924 | LINETO(width,width); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (width),pt.y() + (width))); | - |
925 | LINETO(0,0); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (0),pt.y() + (0))); | - |
926 | break; executed: break; Execution Count:1 | 1 |
927 | case 1 : | - |
928 | pt += QPoint(0 , 1); executed (the execution status of this line is deduced): pt += QPoint(0 , 1); | - |
929 | ppt = pt; executed (the execution status of this line is deduced): ppt = pt; | - |
930 | LIGHT; | - |
931 | LINETO(width,width); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (width),pt.y() + (width))); | - |
932 | DARK; | - |
933 | LINETO(width,segLen - width/2 - 2); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (width),pt.y() + (segLen - width/2 - 2))); | - |
934 | LINETO(0,segLen - 2); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (0),pt.y() + (segLen - 2))); | - |
935 | LIGHT; | - |
936 | LINETO(0,0); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (0),pt.y() + (0))); | - |
937 | break; executed: break; Execution Count:1 | 1 |
938 | case 2 : | - |
939 | pt += QPoint(segLen - 1 , 1); executed (the execution status of this line is deduced): pt += QPoint(segLen - 1 , 1); | - |
940 | ppt = pt; executed (the execution status of this line is deduced): ppt = pt; | - |
941 | DARK; | - |
942 | LINETO(0,segLen - 2); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (0),pt.y() + (segLen - 2))); | - |
943 | LINETO(-width,segLen - width/2 - 2); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (-width),pt.y() + (segLen - width/2 - 2))); | - |
944 | LIGHT; | - |
945 | LINETO(-width,width); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (-width),pt.y() + (width))); | - |
946 | LINETO(0,0); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (0),pt.y() + (0))); | - |
947 | break; executed: break; Execution Count:1 | 1 |
948 | case 3 : | - |
949 | pt += QPoint(0 , segLen); never executed (the execution status of this line is deduced): pt += QPoint(0 , segLen); | - |
950 | ppt = pt; never executed (the execution status of this line is deduced): ppt = pt; | - |
951 | LIGHT; | - |
952 | LINETO(width,-width/2); never executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (width),pt.y() + (-width/2))); | - |
953 | LINETO(segLen - width - 1,-width/2); never executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (segLen - width - 1),pt.y() + (-width/2))); | - |
954 | LINETO(segLen - 1,0); never executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (segLen - 1),pt.y() + (0))); | - |
955 | DARK; | - |
956 | if (width & 1) { // adjust for integer division error never evaluated: width & 1 | 0 |
957 | LINETO(segLen - width - 3,width/2 + 1); never executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (segLen - width - 3),pt.y() + (width/2 + 1))); | - |
958 | LINETO(width + 2,width/2 + 1); never executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (width + 2),pt.y() + (width/2 + 1))); | - |
959 | } else { | 0 |
960 | LINETO(segLen - width - 1,width/2); never executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (segLen - width - 1),pt.y() + (width/2))); | - |
961 | LINETO(width,width/2); never executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (width),pt.y() + (width/2))); | - |
962 | } | 0 |
963 | LINETO(0,0); never executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (0),pt.y() + (0))); | - |
964 | break; | 0 |
965 | case 4 : | - |
966 | pt += QPoint(0 , segLen + 1); executed (the execution status of this line is deduced): pt += QPoint(0 , segLen + 1); | - |
967 | ppt = pt; executed (the execution status of this line is deduced): ppt = pt; | - |
968 | LIGHT; | - |
969 | LINETO(width,width/2); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (width),pt.y() + (width/2))); | - |
970 | DARK; | - |
971 | LINETO(width,segLen - width - 2); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (width),pt.y() + (segLen - width - 2))); | - |
972 | LINETO(0,segLen - 2); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (0),pt.y() + (segLen - 2))); | - |
973 | LIGHT; | - |
974 | LINETO(0,0); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (0),pt.y() + (0))); | - |
975 | break; executed: break; Execution Count:1 | 1 |
976 | case 5 : | - |
977 | pt += QPoint(segLen - 1 , segLen + 1); executed (the execution status of this line is deduced): pt += QPoint(segLen - 1 , segLen + 1); | - |
978 | ppt = pt; executed (the execution status of this line is deduced): ppt = pt; | - |
979 | DARK; | - |
980 | LINETO(0,segLen - 2); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (0),pt.y() + (segLen - 2))); | - |
981 | LINETO(-width,segLen - width - 2); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (-width),pt.y() + (segLen - width - 2))); | - |
982 | LIGHT; | - |
983 | LINETO(-width,width/2); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (-width),pt.y() + (width/2))); | - |
984 | LINETO(0,0); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (0),pt.y() + (0))); | - |
985 | break; executed: break; Execution Count:1 | 1 |
986 | case 6 : | - |
987 | pt += QPoint(0 , segLen*2); executed (the execution status of this line is deduced): pt += QPoint(0 , segLen*2); | - |
988 | ppt = pt; executed (the execution status of this line is deduced): ppt = pt; | - |
989 | LIGHT; | - |
990 | LINETO(width,-width); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (width),pt.y() + (-width))); | - |
991 | LINETO(segLen - width - 1,-width); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (segLen - width - 1),pt.y() + (-width))); | - |
992 | LINETO(segLen - 1,0); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (segLen - 1),pt.y() + (0))); | - |
993 | DARK; | - |
994 | LINETO(0,0); executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (0),pt.y() + (0))); | - |
995 | break; executed: break; Execution Count:1 | 1 |
996 | case 7 : | - |
997 | if (smallPoint) // if smallpoint place'.' between other digits never evaluated: smallPoint | 0 |
998 | pt += QPoint(segLen + width/2 , segLen*2); never executed: pt += QPoint(segLen + width/2 , segLen*2); | 0 |
999 | else | - |
1000 | pt += QPoint(segLen/2 , segLen*2); never executed: pt += QPoint(segLen/2 , segLen*2); | 0 |
1001 | ppt = pt; never executed (the execution status of this line is deduced): ppt = pt; | - |
1002 | DARK; | - |
1003 | LINETO(width,0); never executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (width),pt.y() + (0))); | - |
1004 | LINETO(width,-width); never executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (width),pt.y() + (-width))); | - |
1005 | LIGHT; | - |
1006 | LINETO(0,-width); never executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (0),pt.y() + (-width))); | - |
1007 | LINETO(0,0); never executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (0),pt.y() + (0))); | - |
1008 | break; | 0 |
1009 | case 8 : | - |
1010 | pt += QPoint(segLen/2 - width/2 + 1 , segLen/2 + width); never executed (the execution status of this line is deduced): pt += QPoint(segLen/2 - width/2 + 1 , segLen/2 + width); | - |
1011 | ppt = pt; never executed (the execution status of this line is deduced): ppt = pt; | - |
1012 | DARK; | - |
1013 | LINETO(width,0); never executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (width),pt.y() + (0))); | - |
1014 | LINETO(width,-width); never executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (width),pt.y() + (-width))); | - |
1015 | LIGHT; | - |
1016 | LINETO(0,-width); never executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (0),pt.y() + (-width))); | - |
1017 | LINETO(0,0); never executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (0),pt.y() + (0))); | - |
1018 | break; | 0 |
1019 | case 9 : | - |
1020 | pt += QPoint(segLen/2 - width/2 + 1 , 3*segLen/2 + width); never executed (the execution status of this line is deduced): pt += QPoint(segLen/2 - width/2 + 1 , 3*segLen/2 + width); | - |
1021 | ppt = pt; never executed (the execution status of this line is deduced): ppt = pt; | - |
1022 | DARK; | - |
1023 | LINETO(width,0); never executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (width),pt.y() + (0))); | - |
1024 | LINETO(width,-width); never executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (width),pt.y() + (-width))); | - |
1025 | LIGHT; | - |
1026 | LINETO(0,-width); never executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (0),pt.y() + (-width))); | - |
1027 | LINETO(0,0); never executed (the execution status of this line is deduced): addPoint(a, QPoint(pt.x() + (0),pt.y() + (0))); | - |
1028 | break; | 0 |
1029 | default : | - |
1030 | qWarning("QLCDNumber::drawSegment: (%s) Illegal segment id: %d\n", never executed (the execution status of this line is deduced): QMessageLogger("widgets/qlcdnumber.cpp", 1030, __PRETTY_FUNCTION__).warning("QLCDNumber::drawSegment: (%s) Illegal segment id: %d\n", | - |
1031 | q->objectName().toLocal8Bit().constData(), segmentNo); never executed (the execution status of this line is deduced): q->objectName().toLocal8Bit().constData(), segmentNo); | - |
1032 | } | 0 |
1033 | // End exact copy | - |
1034 | p.setPen(Qt::NoPen); executed (the execution status of this line is deduced): p.setPen(Qt::NoPen); | - |
1035 | p.setBrush(fgColor); executed (the execution status of this line is deduced): p.setBrush(fgColor); | - |
1036 | p.drawPolygon(a); executed (the execution status of this line is deduced): p.drawPolygon(a); | - |
1037 | p.setBrush(Qt::NoBrush); executed (the execution status of this line is deduced): p.setBrush(Qt::NoBrush); | - |
1038 | | - |
1039 | pt = pos; executed (the execution status of this line is deduced): pt = pos; | - |
1040 | } executed: } Execution Count:6 | 6 |
1041 | #undef LINETO | - |
1042 | #undef LIGHT | - |
1043 | #undef DARK | - |
1044 | | - |
1045 | #define LINETO(X,Y) p.drawLine(ppt.x(), ppt.y(), pt.x()+(X), pt.y()+(Y)); \ | - |
1046 | ppt = QPoint(pt.x()+(X), pt.y()+(Y)) | - |
1047 | #define LIGHT p.setPen(lightColor) | - |
1048 | #define DARK p.setPen(darkColor) | - |
1049 | if (shadow) partially evaluated: shadow yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
1050 | switch (segmentNo) { | - |
1051 | case 0 : | - |
1052 | ppt = pt; executed (the execution status of this line is deduced): ppt = pt; | - |
1053 | LIGHT; executed (the execution status of this line is deduced): p.setPen(lightColor); | - |
1054 | LINETO(segLen - 1,0); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(segLen - 1), pt.y()+(0)); ppt = QPoint(pt.x()+(segLen - 1), pt.y()+(0)); | - |
1055 | DARK; executed (the execution status of this line is deduced): p.setPen(darkColor); | - |
1056 | LINETO(segLen - width - 1,width); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(segLen - width - 1), pt.y()+(width)); ppt = QPoint(pt.x()+(segLen - width - 1), pt.y()+(width)); | - |
1057 | LINETO(width,width); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(width)); ppt = QPoint(pt.x()+(width), pt.y()+(width)); | - |
1058 | LINETO(0,0); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(0)); ppt = QPoint(pt.x()+(0), pt.y()+(0)); | - |
1059 | break; executed: break; Execution Count:1 | 1 |
1060 | case 1 : | - |
1061 | pt += QPoint(0,1); executed (the execution status of this line is deduced): pt += QPoint(0,1); | - |
1062 | ppt = pt; executed (the execution status of this line is deduced): ppt = pt; | - |
1063 | LIGHT; executed (the execution status of this line is deduced): p.setPen(lightColor); | - |
1064 | LINETO(width,width); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(width)); ppt = QPoint(pt.x()+(width), pt.y()+(width)); | - |
1065 | DARK; executed (the execution status of this line is deduced): p.setPen(darkColor); | - |
1066 | LINETO(width,segLen - width/2 - 2); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(segLen - width/2 - 2)); ppt = QPoint(pt.x()+(width), pt.y()+(segLen - width/2 - 2)); | - |
1067 | LINETO(0,segLen - 2); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(segLen - 2)); ppt = QPoint(pt.x()+(0), pt.y()+(segLen - 2)); | - |
1068 | LIGHT; executed (the execution status of this line is deduced): p.setPen(lightColor); | - |
1069 | LINETO(0,0); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(0)); ppt = QPoint(pt.x()+(0), pt.y()+(0)); | - |
1070 | break; executed: break; Execution Count:1 | 1 |
1071 | case 2 : | - |
1072 | pt += QPoint(segLen - 1 , 1); executed (the execution status of this line is deduced): pt += QPoint(segLen - 1 , 1); | - |
1073 | ppt = pt; executed (the execution status of this line is deduced): ppt = pt; | - |
1074 | DARK; executed (the execution status of this line is deduced): p.setPen(darkColor); | - |
1075 | LINETO(0,segLen - 2); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(segLen - 2)); ppt = QPoint(pt.x()+(0), pt.y()+(segLen - 2)); | - |
1076 | LINETO(-width,segLen - width/2 - 2); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(-width), pt.y()+(segLen - width/2 - 2)); ppt = QPoint(pt.x()+(-width), pt.y()+(segLen - width/2 - 2)); | - |
1077 | LIGHT; executed (the execution status of this line is deduced): p.setPen(lightColor); | - |
1078 | LINETO(-width,width); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(-width), pt.y()+(width)); ppt = QPoint(pt.x()+(-width), pt.y()+(width)); | - |
1079 | LINETO(0,0); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(0)); ppt = QPoint(pt.x()+(0), pt.y()+(0)); | - |
1080 | break; executed: break; Execution Count:1 | 1 |
1081 | case 3 : | - |
1082 | pt += QPoint(0 , segLen); never executed (the execution status of this line is deduced): pt += QPoint(0 , segLen); | - |
1083 | ppt = pt; never executed (the execution status of this line is deduced): ppt = pt; | - |
1084 | LIGHT; never executed (the execution status of this line is deduced): p.setPen(lightColor); | - |
1085 | LINETO(width,-width/2); never executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(-width/2)); ppt = QPoint(pt.x()+(width), pt.y()+(-width/2)); | - |
1086 | LINETO(segLen - width - 1,-width/2); never executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(segLen - width - 1), pt.y()+(-width/2)); ppt = QPoint(pt.x()+(segLen - width - 1), pt.y()+(-width/2)); | - |
1087 | LINETO(segLen - 1,0); never executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(segLen - 1), pt.y()+(0)); ppt = QPoint(pt.x()+(segLen - 1), pt.y()+(0)); | - |
1088 | DARK; never executed (the execution status of this line is deduced): p.setPen(darkColor); | - |
1089 | if (width & 1) { // adjust for integer division error never evaluated: width & 1 | 0 |
1090 | LINETO(segLen - width - 3,width/2 + 1); never executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(segLen - width - 3), pt.y()+(width/2 + 1)); ppt = QPoint(pt.x()+(segLen - width - 3), pt.y()+(width/2 + 1)); | - |
1091 | LINETO(width + 2,width/2 + 1); never executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(width + 2), pt.y()+(width/2 + 1)); ppt = QPoint(pt.x()+(width + 2), pt.y()+(width/2 + 1)); | - |
1092 | } else { | 0 |
1093 | LINETO(segLen - width - 1,width/2); never executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(segLen - width - 1), pt.y()+(width/2)); ppt = QPoint(pt.x()+(segLen - width - 1), pt.y()+(width/2)); | - |
1094 | LINETO(width,width/2); never executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(width/2)); ppt = QPoint(pt.x()+(width), pt.y()+(width/2)); | - |
1095 | } | 0 |
1096 | LINETO(0,0); never executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(0)); ppt = QPoint(pt.x()+(0), pt.y()+(0)); | - |
1097 | break; | 0 |
1098 | case 4 : | - |
1099 | pt += QPoint(0 , segLen + 1); executed (the execution status of this line is deduced): pt += QPoint(0 , segLen + 1); | - |
1100 | ppt = pt; executed (the execution status of this line is deduced): ppt = pt; | - |
1101 | LIGHT; executed (the execution status of this line is deduced): p.setPen(lightColor); | - |
1102 | LINETO(width,width/2); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(width/2)); ppt = QPoint(pt.x()+(width), pt.y()+(width/2)); | - |
1103 | DARK; executed (the execution status of this line is deduced): p.setPen(darkColor); | - |
1104 | LINETO(width,segLen - width - 2); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(segLen - width - 2)); ppt = QPoint(pt.x()+(width), pt.y()+(segLen - width - 2)); | - |
1105 | LINETO(0,segLen - 2); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(segLen - 2)); ppt = QPoint(pt.x()+(0), pt.y()+(segLen - 2)); | - |
1106 | LIGHT; executed (the execution status of this line is deduced): p.setPen(lightColor); | - |
1107 | LINETO(0,0); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(0)); ppt = QPoint(pt.x()+(0), pt.y()+(0)); | - |
1108 | break; executed: break; Execution Count:1 | 1 |
1109 | case 5 : | - |
1110 | pt += QPoint(segLen - 1 , segLen + 1); executed (the execution status of this line is deduced): pt += QPoint(segLen - 1 , segLen + 1); | - |
1111 | ppt = pt; executed (the execution status of this line is deduced): ppt = pt; | - |
1112 | DARK; executed (the execution status of this line is deduced): p.setPen(darkColor); | - |
1113 | LINETO(0,segLen - 2); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(segLen - 2)); ppt = QPoint(pt.x()+(0), pt.y()+(segLen - 2)); | - |
1114 | LINETO(-width,segLen - width - 2); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(-width), pt.y()+(segLen - width - 2)); ppt = QPoint(pt.x()+(-width), pt.y()+(segLen - width - 2)); | - |
1115 | LIGHT; executed (the execution status of this line is deduced): p.setPen(lightColor); | - |
1116 | LINETO(-width,width/2); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(-width), pt.y()+(width/2)); ppt = QPoint(pt.x()+(-width), pt.y()+(width/2)); | - |
1117 | LINETO(0,0); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(0)); ppt = QPoint(pt.x()+(0), pt.y()+(0)); | - |
1118 | break; executed: break; Execution Count:1 | 1 |
1119 | case 6 : | - |
1120 | pt += QPoint(0 , segLen*2); executed (the execution status of this line is deduced): pt += QPoint(0 , segLen*2); | - |
1121 | ppt = pt; executed (the execution status of this line is deduced): ppt = pt; | - |
1122 | LIGHT; executed (the execution status of this line is deduced): p.setPen(lightColor); | - |
1123 | LINETO(width,-width); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(-width)); ppt = QPoint(pt.x()+(width), pt.y()+(-width)); | - |
1124 | LINETO(segLen - width - 1,-width); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(segLen - width - 1), pt.y()+(-width)); ppt = QPoint(pt.x()+(segLen - width - 1), pt.y()+(-width)); | - |
1125 | LINETO(segLen - 1,0); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(segLen - 1), pt.y()+(0)); ppt = QPoint(pt.x()+(segLen - 1), pt.y()+(0)); | - |
1126 | DARK; executed (the execution status of this line is deduced): p.setPen(darkColor); | - |
1127 | LINETO(0,0); executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(0)); ppt = QPoint(pt.x()+(0), pt.y()+(0)); | - |
1128 | break; executed: break; Execution Count:1 | 1 |
1129 | case 7 : | - |
1130 | if (smallPoint) // if smallpoint place'.' between other digits never evaluated: smallPoint | 0 |
1131 | pt += QPoint(segLen + width/2 , segLen*2); never executed: pt += QPoint(segLen + width/2 , segLen*2); | 0 |
1132 | else | - |
1133 | pt += QPoint(segLen/2 , segLen*2); never executed: pt += QPoint(segLen/2 , segLen*2); | 0 |
1134 | ppt = pt; never executed (the execution status of this line is deduced): ppt = pt; | - |
1135 | DARK; never executed (the execution status of this line is deduced): p.setPen(darkColor); | - |
1136 | LINETO(width,0); never executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(0)); ppt = QPoint(pt.x()+(width), pt.y()+(0)); | - |
1137 | LINETO(width,-width); never executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(-width)); ppt = QPoint(pt.x()+(width), pt.y()+(-width)); | - |
1138 | LIGHT; never executed (the execution status of this line is deduced): p.setPen(lightColor); | - |
1139 | LINETO(0,-width); never executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(-width)); ppt = QPoint(pt.x()+(0), pt.y()+(-width)); | - |
1140 | LINETO(0,0); never executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(0)); ppt = QPoint(pt.x()+(0), pt.y()+(0)); | - |
1141 | break; | 0 |
1142 | case 8 : | - |
1143 | pt += QPoint(segLen/2 - width/2 + 1 , segLen/2 + width); never executed (the execution status of this line is deduced): pt += QPoint(segLen/2 - width/2 + 1 , segLen/2 + width); | - |
1144 | ppt = pt; never executed (the execution status of this line is deduced): ppt = pt; | - |
1145 | DARK; never executed (the execution status of this line is deduced): p.setPen(darkColor); | - |
1146 | LINETO(width,0); never executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(0)); ppt = QPoint(pt.x()+(width), pt.y()+(0)); | - |
1147 | LINETO(width,-width); never executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(-width)); ppt = QPoint(pt.x()+(width), pt.y()+(-width)); | - |
1148 | LIGHT; never executed (the execution status of this line is deduced): p.setPen(lightColor); | - |
1149 | LINETO(0,-width); never executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(-width)); ppt = QPoint(pt.x()+(0), pt.y()+(-width)); | - |
1150 | LINETO(0,0); never executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(0)); ppt = QPoint(pt.x()+(0), pt.y()+(0)); | - |
1151 | break; | 0 |
1152 | case 9 : | - |
1153 | pt += QPoint(segLen/2 - width/2 + 1 , 3*segLen/2 + width); never executed (the execution status of this line is deduced): pt += QPoint(segLen/2 - width/2 + 1 , 3*segLen/2 + width); | - |
1154 | ppt = pt; never executed (the execution status of this line is deduced): ppt = pt; | - |
1155 | DARK; never executed (the execution status of this line is deduced): p.setPen(darkColor); | - |
1156 | LINETO(width,0); never executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(0)); ppt = QPoint(pt.x()+(width), pt.y()+(0)); | - |
1157 | LINETO(width,-width); never executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(-width)); ppt = QPoint(pt.x()+(width), pt.y()+(-width)); | - |
1158 | LIGHT; never executed (the execution status of this line is deduced): p.setPen(lightColor); | - |
1159 | LINETO(0,-width); never executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(-width)); ppt = QPoint(pt.x()+(0), pt.y()+(-width)); | - |
1160 | LINETO(0,0); never executed (the execution status of this line is deduced): p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(0)); ppt = QPoint(pt.x()+(0), pt.y()+(0)); | - |
1161 | break; | 0 |
1162 | default : | - |
1163 | qWarning("QLCDNumber::drawSegment: (%s) Illegal segment id: %d\n", | - |
1164 | q->objectName().toLocal8Bit().constData(), segmentNo); | - |
1165 | } | 0 |
1166 | | - |
1167 | #undef LINETO | - |
1168 | #undef LIGHT | - |
1169 | #undef DARK | - |
1170 | } executed: } Execution Count:6 | 6 |
1171 | | - |
1172 | | - |
1173 | | - |
1174 | /*! | - |
1175 | \property QLCDNumber::segmentStyle | - |
1176 | \brief the style of the LCDNumber | - |
1177 | | - |
1178 | \table | - |
1179 | \header \li Style \li Result | - |
1180 | \row \li \c Outline | - |
1181 | \li Produces raised segments filled with the background color | - |
1182 | \row \li \c Filled | - |
1183 | (this is the default). | - |
1184 | \li Produces raised segments filled with the foreground color. | - |
1185 | \row \li \c Flat | - |
1186 | \li Produces flat segments filled with the foreground color. | - |
1187 | \endtable | - |
1188 | | - |
1189 | \c Outline and \c Filled will additionally use | - |
1190 | QPalette::light() and QPalette::dark() for shadow effects. | - |
1191 | */ | - |
1192 | void QLCDNumber::setSegmentStyle(SegmentStyle s) | - |
1193 | { | - |
1194 | Q_D(QLCDNumber); executed (the execution status of this line is deduced): QLCDNumberPrivate * const d = d_func(); | - |
1195 | d->fill = (s == Flat || s == Filled); partially evaluated: s == Flat no Evaluation Count:0 | yes Evaluation Count:2 |
partially evaluated: s == Filled yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
1196 | d->shadow = (s == Outline || s == Filled); partially evaluated: s == Outline no Evaluation Count:0 | yes Evaluation Count:2 |
partially evaluated: s == Filled yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
1197 | update(); executed (the execution status of this line is deduced): update(); | - |
1198 | } executed: } Execution Count:2 | 2 |
1199 | | - |
1200 | QLCDNumber::SegmentStyle QLCDNumber::segmentStyle() const | - |
1201 | { | - |
1202 | Q_D(const QLCDNumber); never executed (the execution status of this line is deduced): const QLCDNumberPrivate * const d = d_func(); | - |
1203 | Q_ASSERT(d->fill || d->shadow); never executed (the execution status of this line is deduced): qt_noop(); | - |
1204 | if (!d->fill && d->shadow) never evaluated: !d->fill never evaluated: d->shadow | 0 |
1205 | return Outline; never executed: return Outline; | 0 |
1206 | if (d->fill && d->shadow) never evaluated: d->fill never evaluated: d->shadow | 0 |
1207 | return Filled; never executed: return Filled; | 0 |
1208 | return Flat; never executed: return Flat; | 0 |
1209 | } | - |
1210 | | - |
1211 | | - |
1212 | /*!\reimp | - |
1213 | */ | - |
1214 | QSize QLCDNumber::sizeHint() const | - |
1215 | { | - |
1216 | return QSize(10 + 9 * (digitCount() + (smallDecimalPoint() ? 0 : 1)), 23); executed: return QSize(10 + 9 * (digitCount() + (smallDecimalPoint() ? 0 : 1)), 23); Execution Count:1 | 1 |
1217 | } | - |
1218 | | - |
1219 | /*! \reimp */ | - |
1220 | bool QLCDNumber::event(QEvent *e) | - |
1221 | { | - |
1222 | return QFrame::event(e); executed: return QFrame::event(e); Execution Count:13 | 13 |
1223 | } | - |
1224 | | - |
1225 | QT_END_NAMESPACE | - |
1226 | | - |
1227 | #endif // QT_NO_LCDNUMBER | - |
1228 | | - |
| | |