| 424 | } |
| 425 | |
| 426 | QLineSeries *numberOfReports(const QString &fileName, const QString &severity) |
| 427 | { |
| 428 | auto *series = new QLineSeries(); |
| 429 | series->setName(severity); |
| 430 | QFile f(fileName); |
| 431 | if (f.open(QIODevice::ReadOnly | QIODevice::Text)) { |
| 432 | quint64 t = 0; |
| 433 | QTextStream in(&f); |
| 434 | while (!in.atEnd()) { |
| 435 | QString line = in.readLine(); |
| 436 | static const QRegularExpression rxdate("^\\[(\\d\\d)\\.(\\d\\d)\\.(\\d\\d\\d\\d)\\]$"); |
| 437 | const QRegularExpressionMatch matchRes = rxdate.match(line); |
| 438 | if (matchRes.hasMatch()) { |
| 439 | const int y = matchRes.captured(3).toInt(); |
| 440 | const int m = matchRes.captured(2).toInt(); |
| 441 | const int d = matchRes.captured(1).toInt(); |
| 442 | QDateTime dt; |
| 443 | dt.setDate(QDate(y,m,d)); |
| 444 | if (t == dt.toMSecsSinceEpoch()) |
| 445 | t += 1000; |
| 446 | else |
| 447 | t = dt.toMSecsSinceEpoch(); |
| 448 | } |
| 449 | if (line.startsWith(severity + ':')) { |
| 450 | const int y = line.mid(1+severity.length()).toInt(); |
| 451 | series->append(t, y); |
| 452 | } |
| 453 | } |
| 454 | } |
| 455 | return series; |
| 456 | } |
| 457 | #endif |
no test coverage detected