File indexing completed on 2022-11-29 18:12:04

0001 /*
0002     SPDX-FileCopyrightText: 2004 Sebastian Stein <seb.kde@hpfsc.de>
0003     SPDX-FileCopyrightText: 2008 Tadeu Araujo <tadeu.araujo@ltia.fc.unesp.br>
0004     SPDX-FileCopyrightText: 2008 Danilo Balzaque <danilo.balzaque@ltia.fc.unesp.br>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #ifndef EXERCISECOMPARE_H
0010 #define EXERCISECOMPARE_H
0011 
0012 #include <QGridLayout>
0013 #include <QWidget>
0014 
0015 
0016 #include "ExerciseBase.h"
0017 #include "Ratio.h"
0018 #include "RatioWidget.h"
0019 #include "ResultWidget.h"
0020 
0021 class QPushButton;
0022 
0023 /*! Constructs a QWidget, which shows the task to the user.
0024  *  The class also provides input fields, so that the user can enter the result.
0025  *  It also controls the interaction, so that the entered result gets checked
0026  *  and a new task can be generated.
0027  *  \author Sebastian Stein
0028  * */
0029 class ExerciseCompare : public ExerciseBase
0030 {
0031     Q_OBJECT
0032 
0033 public:
0034     /** constructor */
0035     explicit ExerciseCompare(QWidget * parent = nullptr);
0036 
0037     /** destructor */
0038     ~ExerciseCompare() override;
0039 
0040     /** force the creation of a new task */
0041     void forceNewTask() override;
0042 
0043     void setQuestionMixed(bool value);
0044 
0045     void update();
0046 
0047 Q_SIGNALS:
0048     /** class emits this signal, if the task was solved correctly by the user */
0049     void signalExerciseSolvedCorrect();
0050 
0051     /** class emits this signal, if the task was skipped by the user */
0052     void signalExerciseSkipped();
0053 
0054     /** class emits this signal, if the task was solved not correctly by the user
0055      * */
0056     void signalExerciseSolvedWrong();
0057 
0058 private:
0059     short m_currentState;
0060 
0061     bool m_questionMixed;
0062 
0063     RatioWidget * m_firstRatioWidget;
0064     RatioWidget * m_secondRatioWidget;
0065 
0066     // Buttons to select the comparison
0067     QPushButton * m_skipButton;
0068     QPushButton * m_moreButton;
0069     QPushButton * m_minorButton;
0070     QPushButton * m_equalButton;
0071 
0072     Ratio m_firstRatio;
0073     Ratio m_secondRatio;
0074 
0075     // Layout Structures
0076     QGridLayout * checkLayout;
0077     QGridLayout * taskLayout;
0078     QGridLayout * baseGrid;
0079 
0080     enum SignButtonState {
0081         lessThen,
0082         greaterThen,
0083         equalTo
0084     };
0085     SignButtonState m_signButtonState;
0086 
0087     QWidget * checkWidget;
0088     QWidget * taskWidget;
0089 
0090     ResultWidget* m_resultWidget;
0091 
0092     void createTask();
0093     void showResult();
0094     void nextTask();
0095 
0096     void slotSkipButtonClicked();
0097     void slotMinorButtonClicked();
0098     void slotMoreButtonClicked();
0099     void slotEqualButtonClicked();
0100 };
0101 
0102 #endif