#include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); _initialize_all(); // initialize all user controls } MainWindow::~MainWindow() { delete ui; } void MainWindow::_initialize_all() { ui->comboBox_thesis_spervisorEvaluation->activated(0); ui->comboBox_thesis_examinerEvaluation->activated(0); ui->comboBox_thesis_presentationEvaluation->activated(0); ui->comboBox_exam_questionsEvaluation->activated(0); ui->checkBox_comment1_presentation->checkStateChanged(Qt::Checked); ui->radioButton_comment2_quality1->click(); ui->radioButton_comment3_yes->click(); ui->checkBox_comment4_explanations->checkStateChanged(Qt::Checked); ui->radioButton_comment4_quality1->click(); ui->radioButton_comment5_confidence1->click(); ui->radioButton_comment5_quality1->click(); } void MainWindow::_calculate_thesisEvaluation() { double value = WEIGHT_THESIS_SUPERVISOR * _eval_thesis_supervisor + WEIGHT_THESIS_EXAMINER * _eval_thesis_examiner + WEIGHT_THESIS_PRESENTATION * _eval_thesis_presentation; _eval_thesis_final_text = _convert_evaluation_from_number(std::round(value * 100.0) / 100.0); } void MainWindow::_calculate_finalEvaluation() { double eval_thesis_final_num = _convert_evaluation_from_text(_eval_thesis_final_text); double value = (eval_thesis_final_num + _eval_exam_questions) / 2.0; if (_eval_exam_questions >= EVAL_NUM_VALUES.back() || eval_thesis_final_num >= EVAL_NUM_VALUES.back()) _eval_final_text = EVAL_TOTAL_BAD; else if (value <= EVAL_TOTAL_WELL_THRESHOLD) _eval_final_text = EVAL_TOTAL_WELL; else _eval_final_text = EVAL_TOTAL_OK; } void MainWindow::_show_thesisEvaluation() { ui->label_thesis_finalEvaluation_text->setText(_eval_thesis_final_text); } void MainWindow::_show_finalEvaluation() { ui->label_finalEvaluation_text->setText(_eval_final_text); } void MainWindow::_show_finalComment() { ui->textEdit_finalComment->setText(_comment1 + _comment2 + _comment3 + _comment4 + _comment5); } QString MainWindow::_convert_evaluation_from_number(double x) { for (auto interval: EVAL_INTERVALS) { if (interval.in(x)) return interval.getLabel(); } return "-"; } double MainWindow::_convert_evaluation_from_text(QString x) { for (size_t i = 0; i < EVAL_INTERVALS.size(); i++) { if (EVAL_INTERVALS[i].getLabel() == x) return EVAL_NUM_VALUES[i]; } return 0; } void MainWindow::_compose_comment1() { QString first = ""; QString second = ""; QString third = ""; if (_comm1_isPresentation && _comm1_isPrototype && _comm1_isVideo) { first = ui->checkBox_comment1_presentation->text() + ", ", second = ui->checkBox_comment1_prototype->text() + " a ", third = ui->checkBox_comment1_video->text(); } else if (_comm1_isPresentation && _comm1_isPrototype) { first = ui->checkBox_comment1_presentation->text() + " a ", second = ui->checkBox_comment1_prototype->text(); } else if (_comm1_isPresentation && _comm1_isVideo) { first = ui->checkBox_comment1_presentation->text() + " a ", second = ui->checkBox_comment1_video->text(); } else if (_comm1_isPrototype && _comm1_isVideo) { first = ui->checkBox_comment1_prototype->text() + " a ", second = ui->checkBox_comment1_video->text(); } else if (_comm1_isPresentation) { first = ui->checkBox_comment1_presentation->text(); } else if (_comm1_isPrototype) { first = ui->checkBox_comment1_prototype->text(); } else if (_comm1_isVideo) { first = ui->checkBox_comment1_video->text(); } else { _comment1 = ""; return; } _comment1 = QString("%1 %2%3%4, ") .arg(ui->label_comment1->text()) .arg(first) .arg(second) .arg(third); } void MainWindow::_compose_comment2() { _comment2 = QString("%1 %2. ") .arg(ui->label_comment2->text()) .arg(_comm2_selectedQuality); } void MainWindow::_compose_comment3() { _comment3 = QString("%1 %2. ") .arg(ui->label_comment3->text()) .arg(_comm3_selectedAnswer); } void MainWindow::_compose_comment4() { _comment4 = QString("%1 %2%3. ") .arg(ui->label_comment4->text()) .arg(_comm4_explanations) .arg(_comm4_selectedQuality); } void MainWindow::_compose_comment5() { QString selectedQuality = _comm5_isNoAnswer ? "" : " " + _comm5_selectedQuality; _comment5 = QString("%1 %2%3.") .arg(ui->label_comment5->text()) .arg(_comm5_selectedConfidence) .arg(selectedQuality); } void MainWindow::on_comboBox_thesis_spervisorEvaluation_activated(int index) { _eval_thesis_supervisor = EVAL_NUM_VALUES[ui->comboBox_thesis_spervisorEvaluation->currentIndex()]; _calculate_thesisEvaluation(); _calculate_finalEvaluation(); _show_thesisEvaluation(); _show_finalEvaluation(); } void MainWindow::on_comboBox_thesis_examinerEvaluation_activated(int index) { _eval_thesis_examiner = EVAL_NUM_VALUES[ui->comboBox_thesis_examinerEvaluation->currentIndex()]; _calculate_thesisEvaluation(); _calculate_finalEvaluation(); _show_thesisEvaluation(); _show_finalEvaluation(); } void MainWindow::on_comboBox_thesis_presentationEvaluation_activated(int index) { _eval_thesis_presentation = EVAL_NUM_VALUES[ui->comboBox_thesis_presentationEvaluation->currentIndex()]; _calculate_thesisEvaluation(); _calculate_finalEvaluation(); _show_thesisEvaluation(); _show_finalEvaluation(); } void MainWindow::on_comboBox_exam_questionsEvaluation_activated(int index) { _eval_exam_questions = EVAL_NUM_VALUES[ui->comboBox_exam_questionsEvaluation->currentIndex()]; _calculate_finalEvaluation(); _show_finalEvaluation(); } void MainWindow::on_checkBox_comment1_presentation_checkStateChanged(const Qt::CheckState &arg1) { _comm1_isPresentation = arg1 == Qt::CheckState::Checked; _compose_comment1(); _show_finalComment(); } void MainWindow::on_checkBox_comment1_prototype_checkStateChanged(const Qt::CheckState &arg1) { _comm1_isPrototype = arg1 == Qt::CheckState::Checked; _compose_comment1(); _show_finalComment(); } void MainWindow::on_checkBox_comment1_video_checkStateChanged(const Qt::CheckState &arg1) { _comm1_isVideo = arg1 == Qt::CheckState::Checked; _compose_comment1(); _show_finalComment(); } void MainWindow::on_radioButton_comment2_quality1_clicked() { _comm2_selectedQuality = ui->radioButton_comment2_quality1->text(); _compose_comment2(); _show_finalComment(); } void MainWindow::on_radioButton_comment2_quality2_clicked() { _comm2_selectedQuality = ui->radioButton_comment2_quality2->text(); _compose_comment2(); _show_finalComment(); } void MainWindow::on_radioButton_comment2_quality3_clicked() { _comm2_selectedQuality = ui->radioButton_comment2_quality3->text(); _compose_comment2(); _show_finalComment(); } void MainWindow::on_radioButton_comment2_quality4_clicked() { _comm2_selectedQuality = ui->radioButton_comment2_quality4->text(); _compose_comment2(); _show_finalComment(); } void MainWindow::on_radioButton_comment2_quality5_clicked() { _comm2_selectedQuality = ui->radioButton_comment2_quality5->text(); _compose_comment2(); _show_finalComment(); } void MainWindow::on_radioButton_comment3_yes_clicked() { _comm3_selectedAnswer = ui->radioButton_comment3_yes->text(); _compose_comment3(); _show_finalComment(); } void MainWindow::on_radioButton_comment3_no_clicked() { _comm3_selectedAnswer = ui->radioButton_comment3_no->text(); _compose_comment3(); _show_finalComment(); } void MainWindow::on_checkBox_comment4_explanations_checkStateChanged(const Qt::CheckState &arg1) { if (arg1 == Qt::CheckState::Checked) _comm4_explanations = ui->checkBox_comment4_explanations->text() + " "; else _comm4_explanations = ""; _compose_comment4(); _show_finalComment(); } void MainWindow::on_radioButton_comment4_quality1_clicked() { _comm4_selectedQuality = ui->radioButton_comment4_quality1->text(); _compose_comment4(); _show_finalComment(); } void MainWindow::on_radioButton_comment4_quality2_clicked() { _comm4_selectedQuality = ui->radioButton_comment4_quality2->text(); _compose_comment4(); _show_finalComment(); } void MainWindow::on_radioButton_comment4_quality3_clicked() { _comm4_selectedQuality = ui->radioButton_comment4_quality3->text(); _compose_comment4(); _show_finalComment(); } void MainWindow::on_radioButton_comment4_quality4_clicked() { _comm4_selectedQuality = ui->radioButton_comment4_quality4->text(); _compose_comment4(); _show_finalComment(); } void MainWindow::on_radioButton_comment5_confidence1_clicked() { _comm5_isNoAnswer = false; _comm5_selectedConfidence = ui->radioButton_comment5_confidence1->text(); _compose_comment5(); _show_finalComment(); } void MainWindow::on_radioButton_comment5_confidence2_clicked() { _comm5_isNoAnswer = false; _comm5_selectedConfidence = ui->radioButton_comment5_confidence2->text(); _compose_comment5(); _show_finalComment(); } void MainWindow::on_radioButton_comment5_confidence3_clicked() { _comm5_isNoAnswer = true; _comm5_selectedConfidence = ui->radioButton_comment5_confidence3->text(); _compose_comment5(); _show_finalComment(); } void MainWindow::on_radioButton_comment5_quality1_clicked() { _comm5_selectedQuality = ui->radioButton_comment5_quality1->text(); _compose_comment5(); _show_finalComment(); } void MainWindow::on_radioButton_comment5_quality2_clicked() { _comm5_selectedQuality = ui->radioButton_comment5_quality2->text(); _compose_comment5(); _show_finalComment(); } void MainWindow::on_radioButton_comment5_quality3_clicked() { _comm5_selectedQuality = ui->radioButton_comment5_quality3->text(); _compose_comment5(); _show_finalComment(); }