| 382 | } |
| 383 | |
| 384 | void JudgingDialog::compileError(int progress, int compileState) { |
| 385 | bool isOnMaxValue = |
| 386 | ui->logViewer->verticalScrollBar()->value() == ui->logViewer->verticalScrollBar()->maximum(); |
| 387 | QTextBlockFormat blockFormat; |
| 388 | blockFormat.setLeftMargin(30); |
| 389 | cursor->insertBlock(blockFormat); |
| 390 | QTextCharFormat charFormat; |
| 391 | charFormat.setFontPointSize(9); |
| 392 | QString text; |
| 393 | |
| 394 | switch (CompileState(compileState)) { |
| 395 | case NoValidSourceFile: |
| 396 | text = tr("Cannot find valid source file"); |
| 397 | charFormat.setForeground(QBrush(Qt::white)); |
| 398 | charFormat.setBackground(QBrush(Qt::black)); |
| 399 | break; |
| 400 | |
| 401 | case NoValidGraderFile: |
| 402 | text = tr("Main grader (grader.*) cannot be found"); |
| 403 | charFormat.setForeground(QBrush(Qt::white)); |
| 404 | charFormat.setBackground(QBrush(Qt::red)); |
| 405 | break; |
| 406 | |
| 407 | case CompileError: |
| 408 | text = tr("Compile error"); |
| 409 | charFormat.setForeground(QBrush(Qt::red)); |
| 410 | charFormat.setBackground(QBrush(Qt::black)); |
| 411 | break; |
| 412 | |
| 413 | case CompileTimeLimitExceeded: |
| 414 | text = tr("Compile time limit exceeded"); |
| 415 | charFormat.setForeground(QBrush(Qt::yellow)); |
| 416 | charFormat.setBackground(QBrush(Qt::black)); |
| 417 | break; |
| 418 | |
| 419 | case InvalidCompiler: |
| 420 | text = tr("Invalid compiler"); |
| 421 | charFormat.setForeground(QBrush(Qt::magenta)); |
| 422 | charFormat.setBackground(QBrush(Qt::black)); |
| 423 | break; |
| 424 | |
| 425 | case CompileSuccessfully: |
| 426 | text = tr("Compile Successfully"); |
| 427 | charFormat.setForeground(QBrush(Qt::lightGray)); |
| 428 | break; |
| 429 | } |
| 430 | |
| 431 | cursor->insertText(text, charFormat); |
| 432 | ui->progressBar->setValue(ui->progressBar->value() + progress); |
| 433 | QScrollBar *bar = ui->logViewer->verticalScrollBar(); |
| 434 | |
| 435 | if (isOnMaxValue) |
| 436 | bar->setValue(bar->maximum()); |
| 437 | } |
| 438 | |
| 439 | void JudgingDialog::stopJudgingSlot() { |
| 440 | stopJudging = true; |
nothing calls this directly
no test coverage detected