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 EXERCISECONVERT_H
0010 #define EXERCISECONVERT_H
0011 
0012 #include "ExerciseBase.h"
0013 #include "Ratio.h"
0014 
0015 #include <QGridLayout>
0016 
0017 class RationalWidget;
0018 class ResultWidget;
0019 
0020 class QLineEdit;
0021 class QPushButton;
0022 class QString;
0023 class QFrame;
0024 /*! Construct the exercise widget to convert rational numbers into fractions
0025  *
0026  *  \author Sebastian Stein
0027  * */
0028 class ExerciseConvert : public ExerciseBase
0029 {
0030     Q_OBJECT
0031 
0032 public:
0033     /** constructor */
0034     explicit ExerciseConvert(QWidget * parent = nullptr);
0035 
0036     /** destructor */
0037     ~ExerciseConvert() 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     QString m_number;
0059     uint m_periodStart;
0060     uint m_periodLength;
0061     Ratio m_result;
0062 
0063     // Visible components
0064     RationalWidget * m_rationalWidget;
0065     ResultWidget * m_resultWidget;
0066     QLineEdit * numer_edit;
0067     QFrame * edit_line;
0068     QLineEdit * deno_edit;
0069 
0070     QPushButton* m_checkButton;
0071     QPushButton* m_skipButton;
0072 
0073     // Layout Structures
0074     QGridLayout* checkLayout;
0075     QGridLayout* taskLayout;
0076     QGridLayout* baseGrid;
0077 
0078     QWidget * checkWidget;
0079     QWidget * taskWidget;
0080 
0081     // Operation functions
0082     void createTask();
0083     void showResult();
0084     void nextTask();
0085 
0086     void slotCheckButtonClicked();
0087     void slotSkipButtonClicked();
0088     void numeratorReturnPressed();
0089     void denominatorReturnPressed();
0090 
0091 protected:
0092     void showEvent(QShowEvent * event) override;
0093 };
0094 
0095 #endif
0096