File indexing completed on 2024-04-28 07:29:09
0001 /* 0002 SPDX-FileCopyrightText: 2001-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 TASKVIEW_H 0010 #define TASKVIEW_H 0011 0012 #define _CHECK_TASK 0 0013 #define _NEXT_TASK 1 0014 0015 #include "ExerciseBase.h" 0016 #include "ResultWidget.h" 0017 #include "Task.h" 0018 #include "TaskWidget.h" 0019 0020 #include <QWidget> 0021 0022 0023 class QGridLayout; 0024 class QPushButton; 0025 0026 class QLineEdit; 0027 class QFrame; 0028 /*! Constructs a QWidget, which shows the task to the user. 0029 * The class also provides input fields, so that the user can enter the result. 0030 * It also controls the interaction, so that the entered result gets checked 0031 * and a new task can be generated. 0032 * \author Sebastian Stein 0033 * */ 0034 class TaskView : public ExerciseBase 0035 { 0036 Q_OBJECT 0037 0038 public: 0039 /** constructor */ 0040 explicit TaskView(QWidget * parent = nullptr, 0041 bool padd_add = true, bool padd_div = false, 0042 bool padd_mult = false, bool padd_sub = false, 0043 unsigned int pnr_ratios = 2, unsigned int pmax_md = 10); 0044 0045 /** destructor */ 0046 ~TaskView() override; 0047 0048 /** set new task parameters, which will be used for the next task to be 0049 * generated */ 0050 void setTaskParameters(bool padd_add = true, bool padd_div = false, 0051 bool padd_mult = false, bool padd_sub = false, 0052 unsigned int pnr_ratios = 2, unsigned int pmax_md = 2); 0053 0054 /** force the creation of a new task */ 0055 void forceNewTask() override; 0056 0057 void setReducedForm(bool value); 0058 void setQuestionMixed(bool value); 0059 void setAnswerMixed(bool value); 0060 0061 Q_SIGNALS: 0062 /** class emits this signal, if the task was solved correctly by the user */ 0063 void signalTaskSolvedCorrect(); 0064 0065 /** class emits this signal, if the task was skipped by the user */ 0066 void signalTaskSkipped(); 0067 0068 /** class emits this signal, if the task was solved not correctly by the user 0069 * */ 0070 void signalTaskSolvedWrong(); 0071 0072 private: 0073 bool m_questionMixed; 0074 bool m_answerMixed; 0075 bool m_solutionMixed; 0076 bool m_reducedForm; 0077 bool m_addAdd; 0078 bool m_addDiv; 0079 bool m_addMult; 0080 bool m_addSub; 0081 unsigned int nr_ratios; 0082 unsigned int curr_nr_ratios; 0083 unsigned int max_md; 0084 short m_currentState; 0085 0086 ResultWidget* m_resultWidget; 0087 0088 QPushButton* m_checkButton; 0089 QPushButton* m_skipButton; 0090 0091 TaskWidget* m_taskWidget; 0092 QLineEdit* numer_edit; 0093 QFrame* edit_line; 0094 QLineEdit* deno_edit; 0095 QLineEdit* integer_edit; 0096 0097 QGridLayout* checkLayout; 0098 QGridLayout* taskLayout; 0099 QGridLayout* baseGrid; 0100 0101 QWidget * checkWidget; 0102 QWidget * taskWidget; 0103 0104 Task current_task; 0105 Ratio solution; 0106 Ratio entered_result; 0107 QFont defaultFont; 0108 0109 void showResult(); 0110 void nextTask(); 0111 0112 void slotCheckButtonClicked(); 0113 void slotSkipButtonClicked(); 0114 void numeratorReturnPressed(); 0115 void integerReturnPressed(); 0116 void denominatorReturnPressed(); 0117 0118 protected: 0119 void showEvent(QShowEvent * event) override; 0120 }; 0121 0122 #endif