| Line | Source Code | Coverage |
|---|
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | class QLCDNumberPrivate : public QFramePrivate | - |
| 6 | { | - |
| 7 | inline QLCDNumber* q_func() { return static_cast<QLCDNumber *>(q_ptr); } inline const QLCDNumber* q_func() const { return static_cast<const QLCDNumber *>(q_ptr); } friend class QLCDNumber; | - |
| 8 | public: | - |
| 9 | void init(); | - |
| 10 | void internalSetString(const QString& s); | - |
| 11 | void drawString(const QString& s, QPainter &, QBitArray * = 0, bool = true); | - |
| 12 | | - |
| 13 | void drawDigit(const QPoint &, QPainter &, int, char, char = ' '); | - |
| 14 | void drawSegment(const QPoint &, char, QPainter &, int, bool = false); | - |
| 15 | | - |
| 16 | int ndigits; | - |
| 17 | double val; | - |
| 18 | uint base : 2; | - |
| 19 | uint smallPoint : 1; | - |
| 20 | uint fill : 1; | - |
| 21 | uint shadow : 1; | - |
| 22 | QString digitStr; | - |
| 23 | QBitArray points; | - |
| 24 | }; | - |
| 25 | static QString int2string(int num, int base, int ndigits, bool *oflow) | - |
| 26 | { | - |
| 27 | QString s; | - |
| 28 | bool negative; | - |
| 29 | if (num < 0) { | 0 |
| 30 | negative = true; | - |
| 31 | num = -num; | - |
| 32 | } else { | 0 |
| 33 | negative = false; | - |
| 34 | } | 0 |
| 35 | switch(base) { | - |
| 36 | case QLCDNumber::Hex: | - |
| 37 | s.sprintf("%*x", ndigits, num); | - |
| 38 | break; | 0 |
| 39 | case QLCDNumber::Dec: | - |
| 40 | s.sprintf("%*i", ndigits, num); | - |
| 41 | break; | 0 |
| 42 | case QLCDNumber::Oct: | - |
| 43 | s.sprintf("%*o", ndigits, num); | - |
| 44 | break; | 0 |
| 45 | case QLCDNumber::Bin: | - |
| 46 | { | - |
| 47 | char buf[42]; | - |
| 48 | char *p = &buf[41]; | - |
| 49 | uint n = num; | - |
| 50 | int len = 0; | - |
| 51 | *p = '\0'; | - |
| 52 | do { | - |
| 53 | *--p = (char)((n&1)+'0'); | - |
| 54 | n >>= 1; | - |
| 55 | len++; | - |
| 56 | } while (n != 0); | 0 |
| 57 | len = ndigits - len; | - |
| 58 | if (len > 0) | 0 |
| 59 | s.fill(QLatin1Char(' '), len); never executed: s.fill(QLatin1Char(' '), len); | 0 |
| 60 | s += QString::fromLatin1(p); | - |
| 61 | } | - |
| 62 | break; | 0 |
| 63 | } | - |
| 64 | if (negative) { never evaluated: negative | 0 |
| 65 | for (int i=0; i<(int)s.length(); i++) { never evaluated: i<(int)s.length() | 0 |
| 66 | if (s[i] != QLatin1Char(' ')) { never evaluated: s[i] != QLatin1Char(' ') | 0 |
| 67 | if (i != 0) { | 0 |
| 68 | s[i-1] = QLatin1Char('-'); | - |
| 69 | } else { | 0 |
| 70 | s.insert(0, QLatin1Char('-')); | - |
| 71 | } | 0 |
| 72 | break; | 0 |
| 73 | } | - |
| 74 | } | 0 |
| 75 | } | 0 |
| 76 | if (oflow) | 0 |
| 77 | *oflow = (int)s.length() > ndigits; never executed: *oflow = (int)s.length() > ndigits; | 0 |
| 78 | return s; never executed: return s; | 0 |
| 79 | } | - |
| 80 | | - |
| 81 | | - |
| 82 | static QString double2string(double num, int base, int ndigits, bool *oflow) | - |
| 83 | { | - |
| 84 | QString s; | - |
| 85 | if (base != QLCDNumber::Dec) { partially evaluated: base != QLCDNumber::Dec| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 86 | bool of = num >= 2147483648.0 || num < -2147483648.0; never evaluated: num >= 2147483648.0 never evaluated: num < -2147483648.0 | 0 |
| 87 | if (of) { | 0 |
| 88 | if (oflow) | 0 |
| 89 | *oflow = true; never executed: *oflow = true; | 0 |
| 90 | return s; never executed: return s; | 0 |
| 91 | } | - |
| 92 | s = int2string((int)num, base, ndigits, 0); | - |
| 93 | } else { | 0 |
| 94 | int nd = ndigits; | - |
| 95 | do { | - |
| 96 | s.sprintf("%*.*g", ndigits, nd, num); | - |
| 97 | int i = s.indexOf(QLatin1Char('e')); | - |
| 98 | 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 |
| 99 | s[i] = QLatin1Char(' '); | - |
| 100 | s[i+1] = QLatin1Char('e'); | - |
| 101 | } | 0 |
| 102 | } 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 |
| 103 | } executed: }Execution Count:1 | 1 |
| 104 | if (oflow) partially evaluated: oflow| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 105 | *oflow = (int)s.length() > ndigits; executed: *oflow = (int)s.length() > ndigits;Execution Count:1 | 1 |
| 106 | return s; executed: return s;Execution Count:1 | 1 |
| 107 | } | - |
| 108 | | - |
| 109 | | - |
| 110 | static const char *getSegments(char ch) | - |
| 111 | { | - |
| 112 | static const char segments[30][8] = | - |
| 113 | { { 0, 1, 2, 4, 5, 6,99, 0}, | - |
| 114 | { 2, 5,99, 0, 0, 0, 0, 0}, | - |
| 115 | { 0, 2, 3, 4, 6,99, 0, 0}, | - |
| 116 | { 0, 2, 3, 5, 6,99, 0, 0}, | - |
| 117 | { 1, 2, 3, 5,99, 0, 0, 0}, | - |
| 118 | { 0, 1, 3, 5, 6,99, 0, 0}, | - |
| 119 | { 0, 1, 3, 4, 5, 6,99, 0}, | - |
| 120 | { 0, 2, 5,99, 0, 0, 0, 0}, | - |
| 121 | { 0, 1, 2, 3, 4, 5, 6,99}, | - |
| 122 | { 0, 1, 2, 3, 5, 6,99, 0}, | - |
| 123 | { 3,99, 0, 0, 0, 0, 0, 0}, | - |
| 124 | { 7,99, 0, 0, 0, 0, 0, 0}, | - |
| 125 | { 0, 1, 2, 3, 4, 5,99, 0}, | - |
| 126 | { 1, 3, 4, 5, 6,99, 0, 0}, | - |
| 127 | { 0, 1, 4, 6,99, 0, 0, 0}, | - |
| 128 | { 2, 3, 4, 5, 6,99, 0, 0}, | - |
| 129 | { 0, 1, 3, 4, 6,99, 0, 0}, | - |
| 130 | { 0, 1, 3, 4,99, 0, 0, 0}, | - |
| 131 | { 1, 3, 4, 5,99, 0, 0, 0}, | - |
| 132 | { 1, 2, 3, 4, 5,99, 0, 0}, | - |
| 133 | { 1, 4, 6,99, 0, 0, 0, 0}, | - |
| 134 | { 3, 4, 5, 6,99, 0, 0, 0}, | - |
| 135 | { 0, 1, 2, 3, 4,99, 0, 0}, | - |
| 136 | { 3, 4,99, 0, 0, 0, 0, 0}, | - |
| 137 | { 4, 5, 6,99, 0, 0, 0, 0}, | - |
| 138 | { 1, 2, 4, 5, 6,99, 0, 0}, | - |
| 139 | { 1, 2, 3, 5, 6,99, 0, 0}, | - |
| 140 | { 8, 9,99, 0, 0, 0, 0, 0}, | - |
| 141 | { 0, 1, 2, 3,99, 0, 0, 0}, | - |
| 142 | {99, 0, 0, 0, 0, 0, 0, 0} }; | - |
| 143 | | - |
| 144 | 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 |
| 145 | return segments[ch - '0']; executed: return segments[ch - '0'];Execution Count:1 | 1 |
| 146 | if (ch >= 'A' && ch <= 'F') partially evaluated: ch >= 'A'| no Evaluation Count:0 | yes Evaluation Count:9 |
never evaluated: ch <= 'F' | 0-9 |
| 147 | return segments[ch - 'A' + 12]; never executed: return segments[ch - 'A' + 12]; | 0 |
| 148 | if (ch >= 'a' && ch <= 'f') partially evaluated: ch >= 'a'| no Evaluation Count:0 | yes Evaluation Count:9 |
never evaluated: ch <= 'f' | 0-9 |
| 149 | return segments[ch - 'a' + 12]; never executed: return segments[ch - 'a' + 12]; | 0 |
| 150 | | - |
| 151 | int n; | - |
| 152 | switch (ch) { | - |
| 153 | case '-': | - |
| 154 | n = 10; break; | 0 |
| 155 | case 'O': | - |
| 156 | n = 0; break; | 0 |
| 157 | case 'g': | - |
| 158 | n = 9; break; | 0 |
| 159 | case '.': | - |
| 160 | n = 11; break; | 0 |
| 161 | case 'h': | - |
| 162 | n = 18; break; | 0 |
| 163 | case 'H': | - |
| 164 | n = 19; break; | 0 |
| 165 | case 'l': | - |
| 166 | case 'L': | - |
| 167 | n = 20; break; | 0 |
| 168 | case 'o': | - |
| 169 | n = 21; break; | 0 |
| 170 | case 'p': | - |
| 171 | case 'P': | - |
| 172 | n = 22; break; | 0 |
| 173 | case 'r': | - |
| 174 | case 'R': | - |
| 175 | n = 23; break; | 0 |
| 176 | case 's': | - |
| 177 | case 'S': | - |
| 178 | n = 5; break; | 0 |
| 179 | case 'u': | - |
| 180 | n = 24; break; | 0 |
| 181 | case 'U': | - |
| 182 | n = 25; break; | 0 |
| 183 | case 'y': | - |
| 184 | case 'Y': | - |
| 185 | n = 26; break; | 0 |
| 186 | case ':': | - |
| 187 | n = 27; break; | 0 |
| 188 | case '\'': | - |
| 189 | n = 28; break; | 0 |
| 190 | default: | - |
| 191 | n = 29; break; executed: break;Execution Count:9 | 9 |
| 192 | } | - |
| 193 | return segments[n]; executed: return segments[n];Execution Count:9 | 9 |
| 194 | } | - |
| 195 | QLCDNumber::QLCDNumber(QWidget *parent) | - |
| 196 | : QFrame(*new QLCDNumberPrivate, parent) | - |
| 197 | { | - |
| 198 | QLCDNumberPrivate * const d = d_func(); | - |
| 199 | d->ndigits = 5; | - |
| 200 | d->init(); | - |
| 201 | } executed: }Execution Count:2 | 2 |
| 202 | QLCDNumber::QLCDNumber(uint numDigits, QWidget *parent) | - |
| 203 | : QFrame(*new QLCDNumberPrivate, parent) | - |
| 204 | { | - |
| 205 | QLCDNumberPrivate * const d = d_func(); | - |
| 206 | d->ndigits = numDigits; | - |
| 207 | d->init(); | - |
| 208 | } | 0 |
| 209 | | - |
| 210 | void QLCDNumberPrivate::init() | - |
| 211 | { | - |
| 212 | QLCDNumber * const q = q_func(); | - |
| 213 | | - |
| 214 | q->setFrameStyle(QFrame::Box | QFrame::Raised); | - |
| 215 | val = 0; | - |
| 216 | base = QLCDNumber::Dec; | - |
| 217 | smallPoint = false; | - |
| 218 | q->setDigitCount(ndigits); | - |
| 219 | q->setSegmentStyle(QLCDNumber::Filled); | - |
| 220 | q->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); | - |
| 221 | } executed: }Execution Count:2 | 2 |
| 222 | | - |
| 223 | | - |
| 224 | | - |
| 225 | | - |
| 226 | | - |
| 227 | QLCDNumber::~QLCDNumber() | - |
| 228 | { | - |
| 229 | } | - |
| 230 | void QLCDNumber::setDigitCount(int numDigits) | - |
| 231 | { | - |
| 232 | QLCDNumberPrivate * const d = d_func(); | - |
| 233 | if (numDigits > 99) { evaluated: numDigits > 99| yes Evaluation Count:1 | yes Evaluation Count:4 |
| 1-4 |
| 234 | QMessageLogger("widgets/qlcdnumber.cpp", 414, __PRETTY_FUNCTION__).warning("QLCDNumber::setNumDigits: (%s) Max 99 digits allowed", | - |
| 235 | objectName().toLocal8Bit().constData()); | - |
| 236 | numDigits = 99; | - |
| 237 | } executed: }Execution Count:1 | 1 |
| 238 | if (numDigits < 0) { evaluated: numDigits < 0| yes Evaluation Count:1 | yes Evaluation Count:4 |
| 1-4 |
| 239 | QMessageLogger("widgets/qlcdnumber.cpp", 419, __PRETTY_FUNCTION__).warning("QLCDNumber::setNumDigits: (%s) Min 0 digits allowed", | - |
| 240 | objectName().toLocal8Bit().constData()); | - |
| 241 | numDigits = 0; | - |
| 242 | } executed: }Execution Count:1 | 1 |
| 243 | if (d->digitStr.isNull()) { evaluated: d->digitStr.isNull()| yes Evaluation Count:2 | yes Evaluation Count:3 |
| 2-3 |
| 244 | d->ndigits = numDigits; | - |
| 245 | d->digitStr.fill(QLatin1Char(' '), d->ndigits); | - |
| 246 | d->points.fill(0, d->ndigits); | - |
| 247 | d->digitStr[d->ndigits - 1] = QLatin1Char('0'); | - |
| 248 | } else { executed: }Execution Count:2 | 2 |
| 249 | bool doDisplay = d->ndigits == 0; | - |
| 250 | if (numDigits == d->ndigits) evaluated: numDigits == d->ndigits| yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
| 251 | return; executed: return;Execution Count:1 | 1 |
| 252 | register int i; | - |
| 253 | int dif; | - |
| 254 | if (numDigits > d->ndigits) { evaluated: numDigits > d->ndigits| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
| 255 | dif = numDigits - d->ndigits; | - |
| 256 | QString buf; | - |
| 257 | buf.fill(QLatin1Char(' '), dif); | - |
| 258 | d->digitStr.insert(0, buf); | - |
| 259 | d->points.resize(numDigits); | - |
| 260 | for (i=numDigits-1; i>=dif; i--) partially evaluated: i>=dif| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 261 | d->points.setBit(i, d->points.testBit(i-dif)); never executed: d->points.setBit(i, d->points.testBit(i-dif)); | 0 |
| 262 | for (i=0; i<dif; i++) evaluated: i<dif| yes Evaluation Count:99 | yes Evaluation Count:1 |
| 1-99 |
| 263 | d->points.clearBit(i); executed: d->points.clearBit(i);Execution Count:99 | 99 |
| 264 | } else { executed: }Execution Count:1 | 1 |
| 265 | dif = d->ndigits - numDigits; | - |
| 266 | d->digitStr = d->digitStr.right(numDigits); | - |
| 267 | QBitArray tmpPoints = d->points; | - |
| 268 | d->points.resize(numDigits); | - |
| 269 | for (i=0; i<(int)numDigits; i++) partially evaluated: i<(int)numDigits| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 270 | d->points.setBit(i, tmpPoints.testBit(i+dif)); never executed: d->points.setBit(i, tmpPoints.testBit(i+dif)); | 0 |
| 271 | } executed: }Execution Count:1 | 1 |
| 272 | d->ndigits = numDigits; | - |
| 273 | if (doDisplay) evaluated: doDisplay| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
| 274 | display(value()); executed: display(value());Execution Count:1 | 1 |
| 275 | update(); | - |
| 276 | } executed: }Execution Count:2 | 2 |
| 277 | } | - |
| 278 | | - |
| 279 | | - |
| 280 | | - |
| 281 | | - |
| 282 | int QLCDNumber::digitCount() const | - |
| 283 | { | - |
| 284 | const QLCDNumberPrivate * const d = d_func(); | - |
| 285 | return d->ndigits; executed: return d->ndigits;Execution Count:4 | 4 |
| 286 | } | - |
| 287 | bool QLCDNumber::checkOverflow(int num) const | - |
| 288 | { | - |
| 289 | const QLCDNumberPrivate * const d = d_func(); | - |
| 290 | bool of; | - |
| 291 | int2string(num, d->base, d->ndigits, &of); | - |
| 292 | return of; never executed: return of; | 0 |
| 293 | } | - |
| 294 | bool QLCDNumber::checkOverflow(double num) const | - |
| 295 | { | - |
| 296 | const QLCDNumberPrivate * const d = d_func(); | - |
| 297 | bool of; | - |
| 298 | double2string(num, d->base, d->ndigits, &of); | - |
| 299 | return of; never executed: return of; | 0 |
| 300 | } | - |
| 301 | QLCDNumber::Mode QLCDNumber::mode() const | - |
| 302 | { | - |
| 303 | const QLCDNumberPrivate * const d = d_func(); | - |
| 304 | return (QLCDNumber::Mode) d->base; never executed: return (QLCDNumber::Mode) d->base; | 0 |
| 305 | } | - |
| 306 | | - |
| 307 | void QLCDNumber::setMode(Mode m) | - |
| 308 | { | - |
| 309 | QLCDNumberPrivate * const d = d_func(); | - |
| 310 | d->base = m; | - |
| 311 | display(d->val); | - |
| 312 | } | 0 |
| 313 | double QLCDNumber::value() const | - |
| 314 | { | - |
| 315 | const QLCDNumberPrivate * const d = d_func(); | - |
| 316 | return d->val; executed: return d->val;Execution Count:1 | 1 |
| 317 | } | - |
| 318 | | - |
| 319 | | - |
| 320 | | - |
| 321 | | - |
| 322 | | - |
| 323 | | - |
| 324 | void QLCDNumber::display(double num) | - |
| 325 | { | - |
| 326 | QLCDNumberPrivate * const d = d_func(); | - |
| 327 | d->val = num; | - |
| 328 | bool of; | - |
| 329 | QString s = double2string(d->val, d->base, d->ndigits, &of); | - |
| 330 | if (of) partially evaluated: of| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 331 | overflow(); never executed: overflow(); | 0 |
| 332 | else | - |
| 333 | d->internalSetString(s); executed: d->internalSetString(s);Execution Count:1 | 1 |
| 334 | } | - |
| 335 | int QLCDNumber::intValue() const | - |
| 336 | { | - |
| 337 | const QLCDNumberPrivate * const d = d_func(); | - |
| 338 | return qRound(d->val); never executed: return qRound(d->val); | 0 |
| 339 | } | - |
| 340 | | - |
| 341 | | - |
| 342 | | - |
| 343 | | - |
| 344 | | - |
| 345 | | - |
| 346 | | - |
| 347 | void QLCDNumber::display(int num) | - |
| 348 | { | - |
| 349 | QLCDNumberPrivate * const d = d_func(); | - |
| 350 | d->val = (double)num; | - |
| 351 | bool of; | - |
| 352 | QString s = int2string(num, d->base, d->ndigits, &of); | - |
| 353 | if (of) | 0 |
| 354 | overflow(); never executed: overflow(); | 0 |
| 355 | else | - |
| 356 | d->internalSetString(s); never executed: d->internalSetString(s); | 0 |
| 357 | } | - |
| 358 | void QLCDNumber::display(const QString &s) | - |
| 359 | { | - |
| 360 | QLCDNumberPrivate * const d = d_func(); | - |
| 361 | d->val = 0; | - |
| 362 | bool ok = false; | - |
| 363 | double v = s.toDouble(&ok); | - |
| 364 | if (ok) | 0 |
| 365 | d->val = v; never executed: d->val = v; | 0 |
| 366 | d->internalSetString(s); | - |
| 367 | } | 0 |
| 368 | void QLCDNumber::setHexMode() | - |
| 369 | { | - |
| 370 | setMode(Hex); | - |
| 371 | } | 0 |
| 372 | void QLCDNumber::setDecMode() | - |
| 373 | { | - |
| 374 | setMode(Dec); | - |
| 375 | } | 0 |
| 376 | void QLCDNumber::setOctMode() | - |
| 377 | { | - |
| 378 | setMode(Oct); | - |
| 379 | } | 0 |
| 380 | void QLCDNumber::setBinMode() | - |
| 381 | { | - |
| 382 | setMode(Bin); | - |
| 383 | } | 0 |
| 384 | void QLCDNumber::setSmallDecimalPoint(bool b) | - |
| 385 | { | - |
| 386 | QLCDNumberPrivate * const d = d_func(); | - |
| 387 | d->smallPoint = b; | - |
| 388 | update(); | - |
| 389 | } | 0 |
| 390 | | - |
| 391 | bool QLCDNumber::smallDecimalPoint() const | - |
| 392 | { | - |
| 393 | const QLCDNumberPrivate * const d = d_func(); | - |
| 394 | return d->smallPoint; executed: return d->smallPoint;Execution Count:1 | 1 |
| 395 | } | - |
| 396 | | - |
| 397 | | - |
| 398 | | - |
| 399 | | - |
| 400 | | - |
| 401 | | - |
| 402 | | - |
| 403 | void QLCDNumber::paintEvent(QPaintEvent *) | - |
| 404 | { | - |
| 405 | QLCDNumberPrivate * const d = d_func(); | - |
| 406 | QPainter p(this); | - |
| 407 | drawFrame(&p); | - |
| 408 | p.setRenderHint(QPainter::Antialiasing); | - |
| 409 | if (d->shadow) partially evaluated: d->shadow| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 410 | p.translate(0.5, 0.5); executed: p.translate(0.5, 0.5);Execution Count:1 | 1 |
| 411 | | - |
| 412 | if (d->smallPoint) partially evaluated: d->smallPoint| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 413 | d->drawString(d->digitStr, p, &d->points, false); never executed: d->drawString(d->digitStr, p, &d->points, false); | 0 |
| 414 | else | - |
| 415 | d->drawString(d->digitStr, p, 0, false); executed: d->drawString(d->digitStr, p, 0, false);Execution Count:1 | 1 |
| 416 | } | - |
| 417 | | - |
| 418 | | - |
| 419 | void QLCDNumberPrivate::internalSetString(const QString& s) | - |
| 420 | { | - |
| 421 | QLCDNumber * const q = q_func(); | - |
| 422 | QString buffer; | - |
| 423 | int i; | - |
| 424 | int len = s.length(); | - |
| 425 | QBitArray newPoints(ndigits); | - |
| 426 | | - |
| 427 | if (!smallPoint) { partially evaluated: !smallPoint| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 428 | if (len == ndigits) partially evaluated: len == ndigits| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 429 | buffer = s; executed: buffer = s;Execution Count:1 | 1 |
| 430 | else | - |
| 431 | buffer = s.right(ndigits).rightJustified(ndigits, QLatin1Char(' ')); never executed: buffer = s.right(ndigits).rightJustified(ndigits, QLatin1Char(' ')); | 0 |
| 432 | } else { | - |
| 433 | int index = -1; | - |
| 434 | bool lastWasPoint = true; | - |
| 435 | newPoints.clearBit(0); | - |
| 436 | for (i=0; i<len; i++) { | 0 |
| 437 | if (s[i] == QLatin1Char('.')) { never evaluated: s[i] == QLatin1Char('.') | 0 |
| 438 | if (lastWasPoint) { never evaluated: lastWasPoint | 0 |
| 439 | if (index == ndigits - 1) never evaluated: index == ndigits - 1 | 0 |
| 440 | break; | 0 |
| 441 | index++; | - |
| 442 | buffer[index] = QLatin1Char(' '); | - |
| 443 | } | 0 |
| 444 | newPoints.setBit(index); | - |
| 445 | lastWasPoint = true; | - |
| 446 | } else { | 0 |
| 447 | if (index == ndigits - 1) never evaluated: index == ndigits - 1 | 0 |
| 448 | break; | 0 |
| 449 | index++; | - |
| 450 | buffer[index] = s[i]; | - |
| 451 | newPoints.clearBit(index); | - |
| 452 | lastWasPoint = false; | - |
| 453 | } | 0 |
| 454 | } | - |
| 455 | if (index < ((int) ndigits) - 1) { never evaluated: index < ((int) ndigits) - 1 | 0 |
| 456 | for(i=index; i>=0; i--) { | 0 |
| 457 | buffer[ndigits - 1 - index + i] = buffer[i]; | - |
| 458 | newPoints.setBit(ndigits - 1 - index + i, | - |
| 459 | newPoints.testBit(i)); | - |
| 460 | } | 0 |
| 461 | for(i=0; i<ndigits-index-1; i++) { never evaluated: i<ndigits-index-1 | 0 |
| 462 | buffer[i] = QLatin1Char(' '); | - |
| 463 | newPoints.clearBit(i); | - |
| 464 | } | 0 |
| 465 | } | 0 |
| 466 | } | 0 |
| 467 | | - |
| 468 | if (buffer == digitStr) partially evaluated: buffer == digitStr| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 469 | return; | 0 |
| 470 | | - |
| 471 | digitStr = buffer; | - |
| 472 | if (smallPoint) partially evaluated: smallPoint| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 473 | points = newPoints; never executed: points = newPoints; | 0 |
| 474 | q->update(); | - |
| 475 | } executed: }Execution Count:1 | 1 |
| 476 | | - |
| 477 | | - |
| 478 | | - |
| 479 | | - |
| 480 | | - |
| 481 | void QLCDNumberPrivate::drawString(const QString &s, QPainter &p, | - |
| 482 | QBitArray *newPoints, bool newString) | - |
| 483 | { | - |
| 484 | QLCDNumber * const q = q_func(); | - |
| 485 | QPoint pos; | - |
| 486 | | - |
| 487 | int digitSpace = smallPoint ? 2 : 1; partially evaluated: smallPoint| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 488 | int xSegLen = q->width()*5/(ndigits*(5 + digitSpace) + digitSpace); | - |
| 489 | int ySegLen = q->height()*5/12; | - |
| 490 | int segLen = ySegLen > xSegLen ? xSegLen : ySegLen; partially evaluated: ySegLen > xSegLen| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 491 | int xAdvance = segLen*(5 + digitSpace)/5; | - |
| 492 | int xOffset = (q->width() - ndigits*xAdvance + segLen/5)/2; | - |
| 493 | int yOffset = (q->height() - segLen*2)/2; | - |
| 494 | | - |
| 495 | for (int i=0; i<ndigits; i++) { evaluated: i<ndigits| yes Evaluation Count:5 | yes Evaluation Count:1 |
| 1-5 |
| 496 | pos = QPoint(xOffset + xAdvance*i, yOffset); | - |
| 497 | if (newString) partially evaluated: newString| no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
| 498 | drawDigit(pos, p, segLen, s[i].toLatin1(), digitStr[i].toLatin1()); never executed: drawDigit(pos, p, segLen, s[i].toLatin1(), digitStr[i].toLatin1()); | 0 |
| 499 | else | - |
| 500 | drawDigit(pos, p, segLen, s[i].toLatin1()); executed: drawDigit(pos, p, segLen, s[i].toLatin1());Execution Count:5 | 5 |
| 501 | if (newPoints) { partially evaluated: newPoints| no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
| 502 | char newPoint = newPoints->testBit(i) ? '.' : ' '; never evaluated: newPoints->testBit(i) | 0 |
| 503 | if (newString) { never evaluated: newString | 0 |
| 504 | char oldPoint = points.testBit(i) ? '.' : ' '; never evaluated: points.testBit(i) | 0 |
| 505 | drawDigit(pos, p, segLen, newPoint, oldPoint); | - |
| 506 | } else { | 0 |
| 507 | drawDigit(pos, p, segLen, newPoint); | - |
| 508 | } | 0 |
| 509 | } | - |
| 510 | } executed: }Execution Count:5 | 5 |
| 511 | if (newString) { partially evaluated: newString| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 512 | digitStr = s; | - |
| 513 | digitStr.truncate(ndigits); | - |
| 514 | if (newPoints) never evaluated: newPoints | 0 |
| 515 | points = *newPoints; never executed: points = *newPoints; | 0 |
| 516 | } | 0 |
| 517 | } executed: }Execution Count:1 | 1 |
| 518 | | - |
| 519 | | - |
| 520 | | - |
| 521 | | - |
| 522 | | - |
| 523 | | - |
| 524 | void QLCDNumberPrivate::drawDigit(const QPoint &pos, QPainter &p, int segLen, | - |
| 525 | char newCh, char oldCh) | - |
| 526 | { | - |
| 527 | | - |
| 528 | | - |
| 529 | | - |
| 530 | char updates[18][2]; | - |
| 531 | | - |
| 532 | int nErases; | - |
| 533 | int nUpdates; | - |
| 534 | const char *segs; | - |
| 535 | int i,j; | - |
| 536 | | - |
| 537 | const char erase = 0; | - |
| 538 | const char draw = 1; | - |
| 539 | const char leaveAlone = 2; | - |
| 540 | | - |
| 541 | segs = getSegments(oldCh); | - |
| 542 | for (nErases=0; segs[nErases] != 99; nErases++) { partially evaluated: segs[nErases] != 99| no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
| 543 | updates[nErases][0] = erase; | - |
| 544 | updates[nErases][1] = segs[nErases]; | - |
| 545 | } | 0 |
| 546 | nUpdates = nErases; | - |
| 547 | segs = getSegments(newCh); | - |
| 548 | for(i = 0 ; segs[i] != 99 ; i++) { evaluated: segs[i] != 99| yes Evaluation Count:6 | yes Evaluation Count:5 |
| 5-6 |
| 549 | for (j=0; j<nErases; j++) partially evaluated: j<nErases| no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
| 550 | if (segs[i] == updates[j][1]) { never evaluated: segs[i] == updates[j][1] | 0 |
| 551 | updates[j][0] = leaveAlone; | - |
| 552 | break; | 0 |
| 553 | } | - |
| 554 | if (j == nErases) { partially evaluated: j == nErases| yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
| 555 | updates[nUpdates][0] = draw; | - |
| 556 | updates[nUpdates][1] = segs[i]; | - |
| 557 | nUpdates++; | - |
| 558 | } executed: }Execution Count:6 | 6 |
| 559 | } executed: }Execution Count:6 | 6 |
| 560 | for (i=0; i<nUpdates; i++) { evaluated: i<nUpdates| yes Evaluation Count:6 | yes Evaluation Count:5 |
| 5-6 |
| 561 | if (updates[i][0] == draw) partially evaluated: updates[i][0] == draw| yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
| 562 | drawSegment(pos, updates[i][1], p, segLen); executed: drawSegment(pos, updates[i][1], p, segLen);Execution Count:6 | 6 |
| 563 | if (updates[i][0] == erase) partially evaluated: updates[i][0] == erase| no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
| 564 | drawSegment(pos, updates[i][1], p, segLen, true); never executed: drawSegment(pos, updates[i][1], p, segLen, true); | 0 |
| 565 | } executed: }Execution Count:6 | 6 |
| 566 | } executed: }Execution Count:5 | 5 |
| 567 | | - |
| 568 | | - |
| 569 | static void addPoint(QPolygon &a, const QPoint &p) | - |
| 570 | { | - |
| 571 | uint n = a.size(); | - |
| 572 | a.resize(n + 1); | - |
| 573 | a.setPoint(n, p); | - |
| 574 | } executed: }Execution Count:24 | 24 |
| 575 | | - |
| 576 | | - |
| 577 | | - |
| 578 | | - |
| 579 | | - |
| 580 | void QLCDNumberPrivate::drawSegment(const QPoint &pos, char segmentNo, QPainter &p, | - |
| 581 | int segLen, bool erase) | - |
| 582 | { | - |
| 583 | QLCDNumber * const q = q_func(); | - |
| 584 | QPoint ppt; | - |
| 585 | QPoint pt = pos; | - |
| 586 | int width = segLen/5; | - |
| 587 | | - |
| 588 | const QPalette &pal = q->palette(); | - |
| 589 | QColor lightColor,darkColor,fgColor; | - |
| 590 | if (erase){ partially evaluated: erase| no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
| 591 | lightColor = pal.color(q->backgroundRole()); | - |
| 592 | darkColor = lightColor; | - |
| 593 | fgColor = lightColor; | - |
| 594 | } else { | 0 |
| 595 | lightColor = pal.light().color(); | - |
| 596 | darkColor = pal.dark().color(); | - |
| 597 | fgColor = pal.color(q->foregroundRole()); | - |
| 598 | } executed: }Execution Count:6 | 6 |
| 599 | | - |
| 600 | | - |
| 601 | | - |
| 602 | | - |
| 603 | | - |
| 604 | | - |
| 605 | if (fill) { partially evaluated: fill| yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
| 606 | QPolygon a(0); | - |
| 607 | | - |
| 608 | | - |
| 609 | switch (segmentNo) { | - |
| 610 | case 0 : | - |
| 611 | ppt = pt; | - |
| 612 | ; | - |
| 613 | addPoint(a, QPoint(pt.x() + (segLen - 1),pt.y() + (0))); | - |
| 614 | ; | - |
| 615 | addPoint(a, QPoint(pt.x() + (segLen - width - 1),pt.y() + (width))); | - |
| 616 | addPoint(a, QPoint(pt.x() + (width),pt.y() + (width))); | - |
| 617 | addPoint(a, QPoint(pt.x() + (0),pt.y() + (0))); | - |
| 618 | break; executed: break;Execution Count:1 | 1 |
| 619 | case 1 : | - |
| 620 | pt += QPoint(0 , 1); | - |
| 621 | ppt = pt; | - |
| 622 | ; | - |
| 623 | addPoint(a, QPoint(pt.x() + (width),pt.y() + (width))); | - |
| 624 | ; | - |
| 625 | addPoint(a, QPoint(pt.x() + (width),pt.y() + (segLen - width/2 - 2))); | - |
| 626 | addPoint(a, QPoint(pt.x() + (0),pt.y() + (segLen - 2))); | - |
| 627 | ; | - |
| 628 | addPoint(a, QPoint(pt.x() + (0),pt.y() + (0))); | - |
| 629 | break; executed: break;Execution Count:1 | 1 |
| 630 | case 2 : | - |
| 631 | pt += QPoint(segLen - 1 , 1); | - |
| 632 | ppt = pt; | - |
| 633 | ; | - |
| 634 | addPoint(a, QPoint(pt.x() + (0),pt.y() + (segLen - 2))); | - |
| 635 | addPoint(a, QPoint(pt.x() + (-width),pt.y() + (segLen - width/2 - 2))); | - |
| 636 | ; | - |
| 637 | addPoint(a, QPoint(pt.x() + (-width),pt.y() + (width))); | - |
| 638 | addPoint(a, QPoint(pt.x() + (0),pt.y() + (0))); | - |
| 639 | break; executed: break;Execution Count:1 | 1 |
| 640 | case 3 : | - |
| 641 | pt += QPoint(0 , segLen); | - |
| 642 | ppt = pt; | - |
| 643 | ; | - |
| 644 | addPoint(a, QPoint(pt.x() + (width),pt.y() + (-width/2))); | - |
| 645 | addPoint(a, QPoint(pt.x() + (segLen - width - 1),pt.y() + (-width/2))); | - |
| 646 | addPoint(a, QPoint(pt.x() + (segLen - 1),pt.y() + (0))); | - |
| 647 | ; | - |
| 648 | if (width & 1) { never evaluated: width & 1 | 0 |
| 649 | addPoint(a, QPoint(pt.x() + (segLen - width - 3),pt.y() + (width/2 + 1))); | - |
| 650 | addPoint(a, QPoint(pt.x() + (width + 2),pt.y() + (width/2 + 1))); | - |
| 651 | } else { | 0 |
| 652 | addPoint(a, QPoint(pt.x() + (segLen - width - 1),pt.y() + (width/2))); | - |
| 653 | addPoint(a, QPoint(pt.x() + (width),pt.y() + (width/2))); | - |
| 654 | } | 0 |
| 655 | addPoint(a, QPoint(pt.x() + (0),pt.y() + (0))); | - |
| 656 | break; | 0 |
| 657 | case 4 : | - |
| 658 | pt += QPoint(0 , segLen + 1); | - |
| 659 | ppt = pt; | - |
| 660 | ; | - |
| 661 | addPoint(a, QPoint(pt.x() + (width),pt.y() + (width/2))); | - |
| 662 | ; | - |
| 663 | addPoint(a, QPoint(pt.x() + (width),pt.y() + (segLen - width - 2))); | - |
| 664 | addPoint(a, QPoint(pt.x() + (0),pt.y() + (segLen - 2))); | - |
| 665 | ; | - |
| 666 | addPoint(a, QPoint(pt.x() + (0),pt.y() + (0))); | - |
| 667 | break; executed: break;Execution Count:1 | 1 |
| 668 | case 5 : | - |
| 669 | pt += QPoint(segLen - 1 , segLen + 1); | - |
| 670 | ppt = pt; | - |
| 671 | ; | - |
| 672 | addPoint(a, QPoint(pt.x() + (0),pt.y() + (segLen - 2))); | - |
| 673 | addPoint(a, QPoint(pt.x() + (-width),pt.y() + (segLen - width - 2))); | - |
| 674 | ; | - |
| 675 | addPoint(a, QPoint(pt.x() + (-width),pt.y() + (width/2))); | - |
| 676 | addPoint(a, QPoint(pt.x() + (0),pt.y() + (0))); | - |
| 677 | break; executed: break;Execution Count:1 | 1 |
| 678 | case 6 : | - |
| 679 | pt += QPoint(0 , segLen*2); | - |
| 680 | ppt = pt; | - |
| 681 | ; | - |
| 682 | addPoint(a, QPoint(pt.x() + (width),pt.y() + (-width))); | - |
| 683 | addPoint(a, QPoint(pt.x() + (segLen - width - 1),pt.y() + (-width))); | - |
| 684 | addPoint(a, QPoint(pt.x() + (segLen - 1),pt.y() + (0))); | - |
| 685 | ; | - |
| 686 | addPoint(a, QPoint(pt.x() + (0),pt.y() + (0))); | - |
| 687 | break; executed: break;Execution Count:1 | 1 |
| 688 | case 7 : | - |
| 689 | if (smallPoint) never evaluated: smallPoint | 0 |
| 690 | pt += QPoint(segLen + width/2 , segLen*2); never executed: pt += QPoint(segLen + width/2 , segLen*2); | 0 |
| 691 | else | - |
| 692 | pt += QPoint(segLen/2 , segLen*2); never executed: pt += QPoint(segLen/2 , segLen*2); | 0 |
| 693 | ppt = pt; | - |
| 694 | ; | - |
| 695 | addPoint(a, QPoint(pt.x() + (width),pt.y() + (0))); | - |
| 696 | addPoint(a, QPoint(pt.x() + (width),pt.y() + (-width))); | - |
| 697 | ; | - |
| 698 | addPoint(a, QPoint(pt.x() + (0),pt.y() + (-width))); | - |
| 699 | addPoint(a, QPoint(pt.x() + (0),pt.y() + (0))); | - |
| 700 | break; | 0 |
| 701 | case 8 : | - |
| 702 | pt += QPoint(segLen/2 - width/2 + 1 , segLen/2 + width); | - |
| 703 | ppt = pt; | - |
| 704 | ; | - |
| 705 | addPoint(a, QPoint(pt.x() + (width),pt.y() + (0))); | - |
| 706 | addPoint(a, QPoint(pt.x() + (width),pt.y() + (-width))); | - |
| 707 | ; | - |
| 708 | addPoint(a, QPoint(pt.x() + (0),pt.y() + (-width))); | - |
| 709 | addPoint(a, QPoint(pt.x() + (0),pt.y() + (0))); | - |
| 710 | break; | 0 |
| 711 | case 9 : | - |
| 712 | pt += QPoint(segLen/2 - width/2 + 1 , 3*segLen/2 + width); | - |
| 713 | ppt = pt; | - |
| 714 | ; | - |
| 715 | addPoint(a, QPoint(pt.x() + (width),pt.y() + (0))); | - |
| 716 | addPoint(a, QPoint(pt.x() + (width),pt.y() + (-width))); | - |
| 717 | ; | - |
| 718 | addPoint(a, QPoint(pt.x() + (0),pt.y() + (-width))); | - |
| 719 | addPoint(a, QPoint(pt.x() + (0),pt.y() + (0))); | - |
| 720 | break; | 0 |
| 721 | default : | - |
| 722 | QMessageLogger("widgets/qlcdnumber.cpp", 1030, __PRETTY_FUNCTION__).warning("QLCDNumber::drawSegment: (%s) Illegal segment id: %d\n", | - |
| 723 | q->objectName().toLocal8Bit().constData(), segmentNo); | - |
| 724 | } | 0 |
| 725 | | - |
| 726 | p.setPen(Qt::NoPen); | - |
| 727 | p.setBrush(fgColor); | - |
| 728 | p.drawPolygon(a); | - |
| 729 | p.setBrush(Qt::NoBrush); | - |
| 730 | | - |
| 731 | pt = pos; | - |
| 732 | } executed: }Execution Count:6 | 6 |
| 733 | if (shadow) partially evaluated: shadow| yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
| 734 | switch (segmentNo) { | - |
| 735 | case 0 : | - |
| 736 | ppt = pt; | - |
| 737 | p.setPen(lightColor); | - |
| 738 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(segLen - 1), pt.y()+(0)); ppt = QPoint(pt.x()+(segLen - 1), pt.y()+(0)); | - |
| 739 | p.setPen(darkColor); | - |
| 740 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(segLen - width - 1), pt.y()+(width)); ppt = QPoint(pt.x()+(segLen - width - 1), pt.y()+(width)); | - |
| 741 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(width)); ppt = QPoint(pt.x()+(width), pt.y()+(width)); | - |
| 742 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(0)); ppt = QPoint(pt.x()+(0), pt.y()+(0)); | - |
| 743 | break; executed: break;Execution Count:1 | 1 |
| 744 | case 1 : | - |
| 745 | pt += QPoint(0,1); | - |
| 746 | ppt = pt; | - |
| 747 | p.setPen(lightColor); | - |
| 748 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(width)); ppt = QPoint(pt.x()+(width), pt.y()+(width)); | - |
| 749 | p.setPen(darkColor); | - |
| 750 | 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)); | - |
| 751 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(segLen - 2)); ppt = QPoint(pt.x()+(0), pt.y()+(segLen - 2)); | - |
| 752 | p.setPen(lightColor); | - |
| 753 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(0)); ppt = QPoint(pt.x()+(0), pt.y()+(0)); | - |
| 754 | break; executed: break;Execution Count:1 | 1 |
| 755 | case 2 : | - |
| 756 | pt += QPoint(segLen - 1 , 1); | - |
| 757 | ppt = pt; | - |
| 758 | p.setPen(darkColor); | - |
| 759 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(segLen - 2)); ppt = QPoint(pt.x()+(0), pt.y()+(segLen - 2)); | - |
| 760 | 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)); | - |
| 761 | p.setPen(lightColor); | - |
| 762 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(-width), pt.y()+(width)); ppt = QPoint(pt.x()+(-width), pt.y()+(width)); | - |
| 763 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(0)); ppt = QPoint(pt.x()+(0), pt.y()+(0)); | - |
| 764 | break; executed: break;Execution Count:1 | 1 |
| 765 | case 3 : | - |
| 766 | pt += QPoint(0 , segLen); | - |
| 767 | ppt = pt; | - |
| 768 | p.setPen(lightColor); | - |
| 769 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(-width/2)); ppt = QPoint(pt.x()+(width), pt.y()+(-width/2)); | - |
| 770 | 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)); | - |
| 771 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(segLen - 1), pt.y()+(0)); ppt = QPoint(pt.x()+(segLen - 1), pt.y()+(0)); | - |
| 772 | p.setPen(darkColor); | - |
| 773 | if (width & 1) { never evaluated: width & 1 | 0 |
| 774 | 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)); | - |
| 775 | 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)); | - |
| 776 | } else { | 0 |
| 777 | 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)); | - |
| 778 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(width/2)); ppt = QPoint(pt.x()+(width), pt.y()+(width/2)); | - |
| 779 | } | 0 |
| 780 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(0)); ppt = QPoint(pt.x()+(0), pt.y()+(0)); | - |
| 781 | break; | 0 |
| 782 | case 4 : | - |
| 783 | pt += QPoint(0 , segLen + 1); | - |
| 784 | ppt = pt; | - |
| 785 | p.setPen(lightColor); | - |
| 786 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(width/2)); ppt = QPoint(pt.x()+(width), pt.y()+(width/2)); | - |
| 787 | p.setPen(darkColor); | - |
| 788 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(segLen - width - 2)); ppt = QPoint(pt.x()+(width), pt.y()+(segLen - width - 2)); | - |
| 789 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(segLen - 2)); ppt = QPoint(pt.x()+(0), pt.y()+(segLen - 2)); | - |
| 790 | p.setPen(lightColor); | - |
| 791 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(0)); ppt = QPoint(pt.x()+(0), pt.y()+(0)); | - |
| 792 | break; executed: break;Execution Count:1 | 1 |
| 793 | case 5 : | - |
| 794 | pt += QPoint(segLen - 1 , segLen + 1); | - |
| 795 | ppt = pt; | - |
| 796 | p.setPen(darkColor); | - |
| 797 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(segLen - 2)); ppt = QPoint(pt.x()+(0), pt.y()+(segLen - 2)); | - |
| 798 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(-width), pt.y()+(segLen - width - 2)); ppt = QPoint(pt.x()+(-width), pt.y()+(segLen - width - 2)); | - |
| 799 | p.setPen(lightColor); | - |
| 800 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(-width), pt.y()+(width/2)); ppt = QPoint(pt.x()+(-width), pt.y()+(width/2)); | - |
| 801 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(0)); ppt = QPoint(pt.x()+(0), pt.y()+(0)); | - |
| 802 | break; executed: break;Execution Count:1 | 1 |
| 803 | case 6 : | - |
| 804 | pt += QPoint(0 , segLen*2); | - |
| 805 | ppt = pt; | - |
| 806 | p.setPen(lightColor); | - |
| 807 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(-width)); ppt = QPoint(pt.x()+(width), pt.y()+(-width)); | - |
| 808 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(segLen - width - 1), pt.y()+(-width)); ppt = QPoint(pt.x()+(segLen - width - 1), pt.y()+(-width)); | - |
| 809 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(segLen - 1), pt.y()+(0)); ppt = QPoint(pt.x()+(segLen - 1), pt.y()+(0)); | - |
| 810 | p.setPen(darkColor); | - |
| 811 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(0)); ppt = QPoint(pt.x()+(0), pt.y()+(0)); | - |
| 812 | break; executed: break;Execution Count:1 | 1 |
| 813 | case 7 : | - |
| 814 | if (smallPoint) never evaluated: smallPoint | 0 |
| 815 | pt += QPoint(segLen + width/2 , segLen*2); never executed: pt += QPoint(segLen + width/2 , segLen*2); | 0 |
| 816 | else | - |
| 817 | pt += QPoint(segLen/2 , segLen*2); never executed: pt += QPoint(segLen/2 , segLen*2); | 0 |
| 818 | ppt = pt; | - |
| 819 | p.setPen(darkColor); | - |
| 820 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(0)); ppt = QPoint(pt.x()+(width), pt.y()+(0)); | - |
| 821 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(-width)); ppt = QPoint(pt.x()+(width), pt.y()+(-width)); | - |
| 822 | p.setPen(lightColor); | - |
| 823 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(-width)); ppt = QPoint(pt.x()+(0), pt.y()+(-width)); | - |
| 824 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(0)); ppt = QPoint(pt.x()+(0), pt.y()+(0)); | - |
| 825 | break; | 0 |
| 826 | case 8 : | - |
| 827 | pt += QPoint(segLen/2 - width/2 + 1 , segLen/2 + width); | - |
| 828 | ppt = pt; | - |
| 829 | p.setPen(darkColor); | - |
| 830 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(0)); ppt = QPoint(pt.x()+(width), pt.y()+(0)); | - |
| 831 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(-width)); ppt = QPoint(pt.x()+(width), pt.y()+(-width)); | - |
| 832 | p.setPen(lightColor); | - |
| 833 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(-width)); ppt = QPoint(pt.x()+(0), pt.y()+(-width)); | - |
| 834 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(0)); ppt = QPoint(pt.x()+(0), pt.y()+(0)); | - |
| 835 | break; | 0 |
| 836 | case 9 : | - |
| 837 | pt += QPoint(segLen/2 - width/2 + 1 , 3*segLen/2 + width); | - |
| 838 | ppt = pt; | - |
| 839 | p.setPen(darkColor); | - |
| 840 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(0)); ppt = QPoint(pt.x()+(width), pt.y()+(0)); | - |
| 841 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(width), pt.y()+(-width)); ppt = QPoint(pt.x()+(width), pt.y()+(-width)); | - |
| 842 | p.setPen(lightColor); | - |
| 843 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(-width)); ppt = QPoint(pt.x()+(0), pt.y()+(-width)); | - |
| 844 | p.drawLine(ppt.x(), ppt.y(), pt.x()+(0), pt.y()+(0)); ppt = QPoint(pt.x()+(0), pt.y()+(0)); | - |
| 845 | break; | 0 |
| 846 | default : | - |
| 847 | QMessageLogger("widgets/qlcdnumber.cpp", 1163, __PRETTY_FUNCTION__).warning("QLCDNumber::drawSegment: (%s) Illegal segment id: %d\n", | - |
| 848 | q->objectName().toLocal8Bit().constData(), segmentNo); | - |
| 849 | } | 0 |
| 850 | | - |
| 851 | | - |
| 852 | | - |
| 853 | | - |
| 854 | } executed: }Execution Count:6 | 6 |
| 855 | void QLCDNumber::setSegmentStyle(SegmentStyle s) | - |
| 856 | { | - |
| 857 | QLCDNumberPrivate * const d = d_func(); | - |
| 858 | 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 |
| 859 | 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 |
| 860 | update(); | - |
| 861 | } executed: }Execution Count:2 | 2 |
| 862 | | - |
| 863 | QLCDNumber::SegmentStyle QLCDNumber::segmentStyle() const | - |
| 864 | { | - |
| 865 | const QLCDNumberPrivate * const d = d_func(); | - |
| 866 | qt_noop(); | - |
| 867 | if (!d->fill && d->shadow) never evaluated: !d->fill never evaluated: d->shadow | 0 |
| 868 | return Outline; never executed: return Outline; | 0 |
| 869 | if (d->fill && d->shadow) never evaluated: d->shadow | 0 |
| 870 | return Filled; never executed: return Filled; | 0 |
| 871 | return Flat; never executed: return Flat; | 0 |
| 872 | } | - |
| 873 | | - |
| 874 | | - |
| 875 | | - |
| 876 | | - |
| 877 | QSize QLCDNumber::sizeHint() const | - |
| 878 | { | - |
| 879 | return QSize(10 + 9 * (digitCount() + (smallDecimalPoint() ? 0 : 1)), 23); executed: return QSize(10 + 9 * (digitCount() + (smallDecimalPoint() ? 0 : 1)), 23);Execution Count:1 | 1 |
| 880 | } | - |
| 881 | | - |
| 882 | | - |
| 883 | bool QLCDNumber::event(QEvent *e) | - |
| 884 | { | - |
| 885 | return QFrame::event(e); executed: return QFrame::event(e);Execution Count:13 | 13 |
| 886 | } | - |
| 887 | | - |
| 888 | | - |
| 889 | | - |
| | |