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

0001 /*
0002     RatioWidget.h  -  paint a ratio
0003     SPDX-FileCopyrightText: 2004 Sebastian Stein <seb.kde@hpfsc.de>
0004     SPDX-FileCopyrightText: 2008 Tadeu Araujo <tadeu.araujo@ltia.fc.unesp.br>
0005     SPDX-FileCopyrightText: 2008 Danilo Balzaque <danilo.balzaque@ltia.fc.unesp.br>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #ifndef RESULTWIDGET_H
0011 #define RESULTWIDGET_H
0012 
0013 #include "FractionBaseWidget.h"
0014 #include "Ratio.h"
0015 
0016 #include <QWidget>
0017 
0018 class QGridLayout;
0019 class QLabel;
0020 class QPaintEvent;
0021 
0022 // a list containing uints
0023 typedef QList<uint> uintList;
0024 
0025 /*! class to paint the result
0026  *
0027  *  \author Sebastian Stein */
0028 class ResultWidget : public FractionBaseWidget
0029 {
0030     Q_OBJECT
0031 public:
0032     /** constructors */
0033     ResultWidget(QWidget * parent, const Ratio &para_result);
0034     ResultWidget(QWidget * parent, const uintList &para_factors);
0035     explicit ResultWidget(QWidget * parent = nullptr);
0036 
0037     /** destructor */
0038     ~ResultWidget() override;
0039 
0040     /** set the task to be displayed */
0041     void setResult(const Ratio &para_result, int k);
0042     void setResult(int k);
0043 
0044     int KindView();
0045 
0046     /** set the task to be displayed */
0047     void setFactors(const uintList &para_factors);
0048 
0049     void setAnswerMixed(bool value);
0050 
0051 private:
0052     bool m_answerMixed;
0053     /** the prime factors of the number */
0054     uintList m_factors;
0055 
0056     QFont defaultFont;
0057 
0058     QLabel * m_primaryText;
0059     QLabel * m_secondaryText;
0060 
0061     QGridLayout * layout;
0062 
0063     // 1 = Correct, 0 = Incorrect (with solution), 2 = Incorrect (without solution),
0064     short m_kindView;
0065 
0066     short m_ExerciseView;
0067 
0068     /** the ratio to be displayed */
0069     Ratio m_result;
0070 
0071     /** overriding the paint event of FractionBaseWidget */
0072     void paintEvent(QPaintEvent*) override;
0073 
0074     void Init();
0075     void showResult()   ;
0076 };
0077 
0078 #endif