File indexing completed on 2024-04-21 03:41:48

0001 /*
0002     SPDX-FileCopyrightText: 2008 Tiago Porangaba <tiago.porangaba@ltia.fc.unesp.br>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef EXERCISEPERCENTAGE_H
0008 #define EXERCISEPERCENTAGE_H
0009 
0010 #include "ExerciseBase.h"
0011 #include "Ratio.h"
0012 
0013 #include <QLabel>
0014 
0015 class RationalWidget;
0016 class ResultWidget;
0017 
0018 class QLineEdit;
0019 
0020 class QGridLayout;
0021 class QPushButton;
0022 
0023 /*! Construct the exercise widget to work with percentage
0024  *
0025  *  \author Sebastian Stein
0026  *  \author Tiago Porangaba
0027  * */
0028 class ExercisePercentage : public ExerciseBase
0029 {
0030     Q_OBJECT
0031 
0032 public:
0033     /** constructor */
0034     explicit ExercisePercentage(QWidget * parent = nullptr);
0035 
0036     /** destructor */
0037     ~ExercisePercentage() override;
0038 
0039     /** force the creation of a new task */
0040     void forceNewTask() override;
0041 
0042     void update();
0043 
0044 Q_SIGNALS:
0045     /** class emits this signal, if the task was solved correctly by the user */
0046     void signalExerciseSolvedCorrect();
0047 
0048     /** class emits this signal, if the task was skipped by the user */
0049     void signalExerciseSkipped();
0050 
0051     /** class emits this signal, if the task was solved not correctly by the user
0052      * */
0053     void signalExerciseSolvedWrong();
0054 
0055 private:
0056     short m_currentState;
0057 
0058     Ratio m_result;
0059 
0060     QString m_numberPercentage;
0061     QString m_numberPercentageOf;
0062     QString m_resultPercentage;
0063 
0064     QLabel * m_taskLabel;
0065 
0066     RationalWidget * m_rationalWidget;
0067     ResultWidget * m_resultWidget;
0068     QFrame * edit_line;
0069     QLineEdit * answer_edit;
0070 
0071     QPushButton* m_checkButton;
0072     QPushButton* m_skipButton;
0073 
0074     QGridLayout* checkLayout;
0075     QGridLayout* taskLayout;
0076     QGridLayout* baseGrid;
0077 
0078     QWidget * checkWidget;
0079     QWidget * taskWidget;
0080 
0081     void createTask();
0082     void showResult();
0083     void nextTask();
0084 
0085     void slotCheckButtonClicked();
0086     void slotSkipButtonClicked();
0087     void answerReturnPressed();
0088 };
0089 
0090 #endif
0091