| Line | Source Code | Coverage |
|---|
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | class QValidatorPrivate : public QObjectPrivate{ | - |
| 7 | inline QValidator* q_func() { return static_cast<QValidator *>(q_ptr); } inline const QValidator* q_func() const { return static_cast<const QValidator *>(q_ptr); } friend class QValidator; | - |
| 8 | public: | - |
| 9 | QValidatorPrivate() : QObjectPrivate() | - |
| 10 | { | - |
| 11 | } executed: }Execution Count:714 | 714 |
| 12 | | - |
| 13 | QLocale locale; | - |
| 14 | }; | - |
| 15 | | - |
| 16 | | - |
| 17 | | - |
| 18 | | - |
| 19 | | - |
| 20 | | - |
| 21 | | - |
| 22 | QValidator::QValidator(QObject * parent) | - |
| 23 | : QObject(*new QValidatorPrivate, parent) | - |
| 24 | { | - |
| 25 | } executed: }Execution Count:549 | 549 |
| 26 | | - |
| 27 | | - |
| 28 | | - |
| 29 | | - |
| 30 | | - |
| 31 | | - |
| 32 | QValidator::~QValidator() | - |
| 33 | { | - |
| 34 | } | - |
| 35 | | - |
| 36 | | - |
| 37 | | - |
| 38 | | - |
| 39 | | - |
| 40 | | - |
| 41 | | - |
| 42 | QLocale QValidator::locale() const | - |
| 43 | { | - |
| 44 | const QValidatorPrivate * const d = d_func(); | - |
| 45 | return d->locale; executed: return d->locale;Execution Count:605 | 605 |
| 46 | } | - |
| 47 | void QValidator::setLocale(const QLocale &locale) | - |
| 48 | { | - |
| 49 | QValidatorPrivate * const d = d_func(); | - |
| 50 | if (d->locale != locale) { evaluated: d->locale != locale| yes Evaluation Count:109 | yes Evaluation Count:6 |
| 6-109 |
| 51 | d->locale = locale; | - |
| 52 | changed(); | - |
| 53 | } executed: }Execution Count:109 | 109 |
| 54 | } executed: }Execution Count:115 | 115 |
| 55 | void QValidator::fixup(QString &) const | - |
| 56 | { | - |
| 57 | } | - |
| 58 | QIntValidator::QIntValidator(QObject * parent) | - |
| 59 | : QValidator(parent) | - |
| 60 | { | - |
| 61 | b = (-2147483647 - 1); | - |
| 62 | t = 2147483647; | - |
| 63 | } executed: }Execution Count:3 | 3 |
| 64 | | - |
| 65 | | - |
| 66 | | - |
| 67 | | - |
| 68 | | - |
| 69 | | - |
| 70 | | - |
| 71 | QIntValidator::QIntValidator(int minimum, int maximum, | - |
| 72 | QObject * parent) | - |
| 73 | : QValidator(parent) | - |
| 74 | { | - |
| 75 | b = minimum; | - |
| 76 | t = maximum; | - |
| 77 | } executed: }Execution Count:140 | 140 |
| 78 | | - |
| 79 | | - |
| 80 | | - |
| 81 | | - |
| 82 | | - |
| 83 | | - |
| 84 | QIntValidator::~QIntValidator() | - |
| 85 | { | - |
| 86 | | - |
| 87 | } | - |
| 88 | static int numDigits(qlonglong n) | - |
| 89 | { | - |
| 90 | if (n == 0) evaluated: n == 0| yes Evaluation Count:2 | yes Evaluation Count:32 |
| 2-32 |
| 91 | return 1; executed: return 1;Execution Count:2 | 2 |
| 92 | return (int)log10(double(n)) + 1; executed: return (int)log10(double(n)) + 1;Execution Count:32 | 32 |
| 93 | } | - |
| 94 | | - |
| 95 | static qlonglong pow10(int exp) | - |
| 96 | { | - |
| 97 | qlonglong result = 1; | - |
| 98 | for (int i = 0; i < exp; ++i) evaluated: i < exp| yes Evaluation Count:67 | yes Evaluation Count:34 |
| 34-67 |
| 99 | result *= 10; executed: result *= 10;Execution Count:67 | 67 |
| 100 | return result; executed: return result;Execution Count:34 | 34 |
| 101 | } | - |
| 102 | | - |
| 103 | QValidator::State QIntValidator::validate(QString & input, int&) const | - |
| 104 | { | - |
| 105 | QByteArray buff; | - |
| 106 | if (!locale().d->validateChars(input, QLocalePrivate::IntegerMode, &buff)) { evaluated: !locale().d->validateChars(input, QLocalePrivate::IntegerMode, &buff)| yes Evaluation Count:30 | yes Evaluation Count:195 |
| 30-195 |
| 107 | return Invalid; executed: return Invalid;Execution Count:30 | 30 |
| 108 | } | - |
| 109 | | - |
| 110 | if (buff.isEmpty()) evaluated: buff.isEmpty()| yes Evaluation Count:16 | yes Evaluation Count:179 |
| 16-179 |
| 111 | return Intermediate; executed: return Intermediate;Execution Count:16 | 16 |
| 112 | | - |
| 113 | if (b >= 0 && buff.startsWith('-')) evaluated: b >= 0| yes Evaluation Count:108 | yes Evaluation Count:71 |
evaluated: buff.startsWith('-')| yes Evaluation Count:13 | yes Evaluation Count:95 |
| 13-108 |
| 114 | return Invalid; executed: return Invalid;Execution Count:13 | 13 |
| 115 | | - |
| 116 | if (t < 0 && buff.startsWith('+')) evaluated: t < 0| yes Evaluation Count:25 | yes Evaluation Count:141 |
evaluated: buff.startsWith('+')| yes Evaluation Count:3 | yes Evaluation Count:22 |
| 3-141 |
| 117 | return Invalid; executed: return Invalid;Execution Count:3 | 3 |
| 118 | | - |
| 119 | if (buff.size() == 1 && (buff.at(0) == '+' || buff.at(0) == '-')) evaluated: buff.size() == 1| yes Evaluation Count:54 | yes Evaluation Count:109 |
evaluated: buff.at(0) == '+'| yes Evaluation Count:2 | yes Evaluation Count:52 |
evaluated: buff.at(0) == '-'| yes Evaluation Count:6 | yes Evaluation Count:46 |
| 2-109 |
| 120 | return Intermediate; executed: return Intermediate;Execution Count:8 | 8 |
| 121 | | - |
| 122 | bool ok, overflow; | - |
| 123 | qlonglong entered = QLocalePrivate::bytearrayToLongLong(buff.constData(), 10, &ok, &overflow); | - |
| 124 | if (overflow || !ok) partially evaluated: !ok| no Evaluation Count:0 | yes Evaluation Count:154 |
evaluated: overflow| yes Evaluation Count:1 | yes Evaluation Count:154 |
| 0-154 |
| 125 | return Invalid; executed: return Invalid;Execution Count:1 | 1 |
| 126 | | - |
| 127 | if (entered >= b && entered <= t) { evaluated: entered >= b| yes Evaluation Count:128 | yes Evaluation Count:26 |
evaluated: entered <= t| yes Evaluation Count:96 | yes Evaluation Count:32 |
| 26-128 |
| 128 | locale().toInt(input, &ok); | - |
| 129 | return ok ? Acceptable : Intermediate; executed: return ok ? Acceptable : Intermediate;Execution Count:96 | 96 |
| 130 | } | - |
| 131 | | - |
| 132 | if (entered >= 0) { evaluated: entered >= 0| yes Evaluation Count:44 | yes Evaluation Count:14 |
| 14-44 |
| 133 | | - |
| 134 | | - |
| 135 | return (entered > t && -entered < b) ? Invalid : Intermediate; executed: return (entered > t && -entered < b) ? Invalid : Intermediate;Execution Count:44 | 44 |
| 136 | } else { | - |
| 137 | return (entered < b) ? Invalid : Intermediate; executed: return (entered < b) ? Invalid : Intermediate;Execution Count:14 | 14 |
| 138 | } | - |
| 139 | } | - |
| 140 | | - |
| 141 | | - |
| 142 | void QIntValidator::fixup(QString &input) const | - |
| 143 | { | - |
| 144 | QByteArray buff; | - |
| 145 | if (!locale().d->validateChars(input, QLocalePrivate::IntegerMode, &buff)) { partially evaluated: !locale().d->validateChars(input, QLocalePrivate::IntegerMode, &buff)| no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
| 146 | return; | 0 |
| 147 | } | - |
| 148 | bool ok, overflow; | - |
| 149 | qlonglong entered = QLocalePrivate::bytearrayToLongLong(buff.constData(), 10, &ok, &overflow); | - |
| 150 | if (ok && !overflow) evaluated: ok| yes Evaluation Count:5 | yes Evaluation Count:4 |
partially evaluated: !overflow| yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
| 151 | input = locale().toString(entered); executed: input = locale().toString(entered);Execution Count:5 | 5 |
| 152 | } executed: }Execution Count:9 | 9 |
| 153 | | - |
| 154 | | - |
| 155 | | - |
| 156 | | - |
| 157 | | - |
| 158 | | - |
| 159 | void QIntValidator::setRange(int bottom, int top) | - |
| 160 | { | - |
| 161 | bool rangeChanged = false; | - |
| 162 | if (b != bottom) { evaluated: b != bottom| yes Evaluation Count:3 | yes Evaluation Count:3 |
| 3 |
| 163 | b = bottom; | - |
| 164 | rangeChanged = true; | - |
| 165 | bottomChanged(b); | - |
| 166 | } executed: }Execution Count:3 | 3 |
| 167 | | - |
| 168 | if (t != top) { evaluated: t != top| yes Evaluation Count:3 | yes Evaluation Count:3 |
| 3 |
| 169 | t = top; | - |
| 170 | rangeChanged = true; | - |
| 171 | topChanged(t); | - |
| 172 | } executed: }Execution Count:3 | 3 |
| 173 | | - |
| 174 | if (rangeChanged) evaluated: rangeChanged| yes Evaluation Count:5 | yes Evaluation Count:1 |
| 1-5 |
| 175 | changed(); executed: changed();Execution Count:5 | 5 |
| 176 | } executed: }Execution Count:6 | 6 |
| 177 | void QIntValidator::setBottom(int bottom) | - |
| 178 | { | - |
| 179 | setRange(bottom, top()); | - |
| 180 | } executed: }Execution Count:1 | 1 |
| 181 | void QIntValidator::setTop(int top) | - |
| 182 | { | - |
| 183 | setRange(bottom(), top); | - |
| 184 | } executed: }Execution Count:1 | 1 |
| 185 | | - |
| 186 | | - |
| 187 | | - |
| 188 | | - |
| 189 | | - |
| 190 | | - |
| 191 | | - |
| 192 | QValidator::QValidator(QObjectPrivate &d, QObject *parent) | - |
| 193 | : QObject(d, parent) | - |
| 194 | { | - |
| 195 | } | 0 |
| 196 | | - |
| 197 | | - |
| 198 | | - |
| 199 | | - |
| 200 | QValidator::QValidator(QValidatorPrivate &d, QObject *parent) | - |
| 201 | : QObject(d, parent) | - |
| 202 | { | - |
| 203 | } executed: }Execution Count:165 | 165 |
| 204 | | - |
| 205 | class QDoubleValidatorPrivate : public QValidatorPrivate | - |
| 206 | { | - |
| 207 | inline QDoubleValidator* q_func() { return static_cast<QDoubleValidator *>(q_ptr); } inline const QDoubleValidator* q_func() const { return static_cast<const QDoubleValidator *>(q_ptr); } friend class QDoubleValidator; | - |
| 208 | public: | - |
| 209 | QDoubleValidatorPrivate() | - |
| 210 | : QValidatorPrivate() | - |
| 211 | , notation(QDoubleValidator::ScientificNotation) | - |
| 212 | { | - |
| 213 | } executed: }Execution Count:165 | 165 |
| 214 | | - |
| 215 | QDoubleValidator::Notation notation; | - |
| 216 | | - |
| 217 | QValidator::State validateWithLocale(QString & input, QLocalePrivate::NumberMode numMode, const QLocale &locale) const; | - |
| 218 | }; | - |
| 219 | QDoubleValidator::QDoubleValidator(QObject * parent) | - |
| 220 | : QValidator(*new QDoubleValidatorPrivate , parent) | - |
| 221 | { | - |
| 222 | b = -(__builtin_huge_val()); | - |
| 223 | t = (__builtin_huge_val()); | - |
| 224 | dec = 1000; | - |
| 225 | } | 0 |
| 226 | QDoubleValidator::QDoubleValidator(double bottom, double top, int decimals, | - |
| 227 | QObject * parent) | - |
| 228 | : QValidator(*new QDoubleValidatorPrivate , parent) | - |
| 229 | { | - |
| 230 | b = bottom; | - |
| 231 | t = top; | - |
| 232 | dec = decimals; | - |
| 233 | } executed: }Execution Count:165 | 165 |
| 234 | | - |
| 235 | | - |
| 236 | | - |
| 237 | | - |
| 238 | | - |
| 239 | | - |
| 240 | QDoubleValidator::~QDoubleValidator() | - |
| 241 | { | - |
| 242 | } | - |
| 243 | QValidator::State QDoubleValidator::validate(QString & input, int &) const | - |
| 244 | { | - |
| 245 | const QDoubleValidatorPrivate * const d = d_func(); | - |
| 246 | | - |
| 247 | QLocalePrivate::NumberMode numMode = QLocalePrivate::DoubleStandardMode; | - |
| 248 | switch (d->notation) { | - |
| 249 | case StandardNotation: | - |
| 250 | numMode = QLocalePrivate::DoubleStandardMode; | - |
| 251 | break; executed: break;Execution Count:156 | 156 |
| 252 | case ScientificNotation: | - |
| 253 | numMode = QLocalePrivate::DoubleScientificMode; | - |
| 254 | break; executed: break;Execution Count:113 | 113 |
| 255 | } | - |
| 256 | | - |
| 257 | return d->validateWithLocale(input, numMode, locale()); executed: return d->validateWithLocale(input, numMode, locale());Execution Count:269 | 269 |
| 258 | } | - |
| 259 | | - |
| 260 | QValidator::State QDoubleValidatorPrivate::validateWithLocale(QString &input, QLocalePrivate::NumberMode numMode, const QLocale &locale) const | - |
| 261 | { | - |
| 262 | const QDoubleValidator * const q = q_func(); | - |
| 263 | QByteArray buff; | - |
| 264 | if (!locale.d->validateChars(input, numMode, &buff, q->dec)) evaluated: !locale.d->validateChars(input, numMode, &buff, q->dec)| yes Evaluation Count:91 | yes Evaluation Count:178 |
| 91-178 |
| 265 | return QValidator::Invalid; executed: return QValidator::Invalid;Execution Count:91 | 91 |
| 266 | | - |
| 267 | if (buff.isEmpty()) evaluated: buff.isEmpty()| yes Evaluation Count:2 | yes Evaluation Count:176 |
| 2-176 |
| 268 | return QValidator::Intermediate; executed: return QValidator::Intermediate;Execution Count:2 | 2 |
| 269 | | - |
| 270 | if (q->b >= 0 && buff.startsWith('-')) evaluated: q->b >= 0| yes Evaluation Count:123 | yes Evaluation Count:53 |
evaluated: buff.startsWith('-')| yes Evaluation Count:15 | yes Evaluation Count:108 |
| 15-123 |
| 271 | return QValidator::Invalid; executed: return QValidator::Invalid;Execution Count:15 | 15 |
| 272 | | - |
| 273 | if (q->t < 0 && buff.startsWith('+')) evaluated: q->t < 0| yes Evaluation Count:17 | yes Evaluation Count:144 |
evaluated: buff.startsWith('+')| yes Evaluation Count:4 | yes Evaluation Count:13 |
| 4-144 |
| 274 | return QValidator::Invalid; executed: return QValidator::Invalid;Execution Count:4 | 4 |
| 275 | | - |
| 276 | bool ok, overflow; | - |
| 277 | double i = QLocalePrivate::bytearrayToDouble(buff.constData(), &ok, &overflow); | - |
| 278 | if (overflow) partially evaluated: overflow| no Evaluation Count:0 | yes Evaluation Count:157 |
| 0-157 |
| 279 | return QValidator::Invalid; never executed: return QValidator::Invalid; | 0 |
| 280 | if (!ok) evaluated: !ok| yes Evaluation Count:48 | yes Evaluation Count:109 |
| 48-109 |
| 281 | return QValidator::Intermediate; executed: return QValidator::Intermediate;Execution Count:48 | 48 |
| 282 | | - |
| 283 | if (i >= q->b && i <= q->t) evaluated: i >= q->b| yes Evaluation Count:95 | yes Evaluation Count:14 |
evaluated: i <= q->t| yes Evaluation Count:59 | yes Evaluation Count:36 |
| 14-95 |
| 284 | return QValidator::Acceptable; executed: return QValidator::Acceptable;Execution Count:59 | 59 |
| 285 | | - |
| 286 | if (notation == QDoubleValidator::StandardNotation) { evaluated: notation == QDoubleValidator::StandardNotation| yes Evaluation Count:34 | yes Evaluation Count:16 |
| 16-34 |
| 287 | double max = qMax(qAbs(q->b), qAbs(q->t)); | - |
| 288 | if (max < 9223372036854775807LL) { partially evaluated: max < 9223372036854775807LL| yes Evaluation Count:34 | no Evaluation Count:0 |
| 0-34 |
| 289 | qlonglong n = pow10(numDigits(qlonglong(max))) - 1; | - |
| 290 | if (qAbs(i) > n) evaluated: qAbs(i) > n| yes Evaluation Count:7 | yes Evaluation Count:27 |
| 7-27 |
| 291 | return QValidator::Invalid; executed: return QValidator::Invalid;Execution Count:7 | 7 |
| 292 | } executed: }Execution Count:27 | 27 |
| 293 | } executed: }Execution Count:27 | 27 |
| 294 | | - |
| 295 | return QValidator::Intermediate; executed: return QValidator::Intermediate;Execution Count:43 | 43 |
| 296 | } | - |
| 297 | void QDoubleValidator::setRange(double minimum, double maximum, int decimals) | - |
| 298 | { | - |
| 299 | bool rangeChanged = false; | - |
| 300 | if (b != minimum) { evaluated: b != minimum| yes Evaluation Count:3 | yes Evaluation Count:5 |
| 3-5 |
| 301 | b = minimum; | - |
| 302 | rangeChanged = true; | - |
| 303 | bottomChanged(b); | - |
| 304 | } executed: }Execution Count:3 | 3 |
| 305 | | - |
| 306 | if (t != maximum) { evaluated: t != maximum| yes Evaluation Count:3 | yes Evaluation Count:5 |
| 3-5 |
| 307 | t = maximum; | - |
| 308 | rangeChanged = true; | - |
| 309 | topChanged(t); | - |
| 310 | } executed: }Execution Count:3 | 3 |
| 311 | | - |
| 312 | if (dec != decimals) { evaluated: dec != decimals| yes Evaluation Count:3 | yes Evaluation Count:5 |
| 3-5 |
| 313 | dec = decimals; | - |
| 314 | rangeChanged = true; | - |
| 315 | decimalsChanged(dec); | - |
| 316 | } executed: }Execution Count:3 | 3 |
| 317 | if (rangeChanged) evaluated: rangeChanged| yes Evaluation Count:7 | yes Evaluation Count:1 |
| 1-7 |
| 318 | changed(); executed: changed();Execution Count:7 | 7 |
| 319 | } executed: }Execution Count:8 | 8 |
| 320 | void QDoubleValidator::setBottom(double bottom) | - |
| 321 | { | - |
| 322 | setRange(bottom, top(), decimals()); | - |
| 323 | } executed: }Execution Count:1 | 1 |
| 324 | void QDoubleValidator::setTop(double top) | - |
| 325 | { | - |
| 326 | setRange(bottom(), top, decimals()); | - |
| 327 | } executed: }Execution Count:1 | 1 |
| 328 | void QDoubleValidator::setDecimals(int decimals) | - |
| 329 | { | - |
| 330 | setRange(bottom(), top(), decimals); | - |
| 331 | } executed: }Execution Count:1 | 1 |
| 332 | void QDoubleValidator::setNotation(Notation newNotation) | - |
| 333 | { | - |
| 334 | QDoubleValidatorPrivate * const d = d_func(); | - |
| 335 | if (d->notation != newNotation) { evaluated: d->notation != newNotation| yes Evaluation Count:157 | yes Evaluation Count:9 |
| 9-157 |
| 336 | d->notation = newNotation; | - |
| 337 | notationChanged(d->notation); | - |
| 338 | changed(); | - |
| 339 | } executed: }Execution Count:157 | 157 |
| 340 | } executed: }Execution Count:166 | 166 |
| 341 | | - |
| 342 | QDoubleValidator::Notation QDoubleValidator::notation() const | - |
| 343 | { | - |
| 344 | const QDoubleValidatorPrivate * const d = d_func(); | - |
| 345 | return d->notation; executed: return d->notation;Execution Count:2 | 2 |
| 346 | } | - |
| 347 | QRegExpValidator::QRegExpValidator(QObject *parent) | - |
| 348 | : QValidator(parent), r(QString::fromLatin1(".*")) | - |
| 349 | { | - |
| 350 | } executed: }Execution Count:11 | 11 |
| 351 | QRegExpValidator::QRegExpValidator(const QRegExp& rx, QObject *parent) | - |
| 352 | : QValidator(parent), r(rx) | - |
| 353 | { | - |
| 354 | } | 0 |
| 355 | | - |
| 356 | | - |
| 357 | | - |
| 358 | | - |
| 359 | | - |
| 360 | | - |
| 361 | QRegExpValidator::~QRegExpValidator() | - |
| 362 | { | - |
| 363 | } | - |
| 364 | QValidator::State QRegExpValidator::validate(QString &input, int& pos) const | - |
| 365 | { | - |
| 366 | QRegExp copy = r; | - |
| 367 | if (copy.exactMatch(input)) { evaluated: copy.exactMatch(input)| yes Evaluation Count:4 | yes Evaluation Count:7 |
| 4-7 |
| 368 | return Acceptable; executed: return Acceptable;Execution Count:4 | 4 |
| 369 | } else { | - |
| 370 | if (copy.matchedLength() == input.size()) { evaluated: copy.matchedLength() == input.size()| yes Evaluation Count:2 | yes Evaluation Count:5 |
| 2-5 |
| 371 | return Intermediate; executed: return Intermediate;Execution Count:2 | 2 |
| 372 | } else { | - |
| 373 | pos = input.size(); | - |
| 374 | return Invalid; executed: return Invalid;Execution Count:5 | 5 |
| 375 | } | - |
| 376 | } | - |
| 377 | } | - |
| 378 | void QRegExpValidator::setRegExp(const QRegExp& rx) | - |
| 379 | { | - |
| 380 | if (r != rx) { partially evaluated: r != rx| yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-11 |
| 381 | r = rx; | - |
| 382 | regExpChanged(r); | - |
| 383 | changed(); | - |
| 384 | } executed: }Execution Count:11 | 11 |
| 385 | } executed: }Execution Count:11 | 11 |
| 386 | | - |
| 387 | | - |
| 388 | | - |
| 389 | | - |
| 390 | | - |
| | |