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

0001 /*
0002     StatisticsView.cpp  -  Header File
0003     SPDX-FileCopyrightText: 2001-2004 Sebastian Stein <seb.kde@hpfsc.de>
0004     SPDX-FileCopyrightText: 2001-2004 Eva Brucherseifer
0005     SPDX-FileCopyrightText: 2008 Tadeu Araujo <tadeu.araujo@ltia.fc.unesp.br>
0006     SPDX-FileCopyrightText: 2008 Danilo Balzaque <danilo.balzaque@ltia.fc.unesp.br>
0007     SPDX-FileCopyrightText: 2008 Tiago Porangaba <tiago.porangaba@ltia.fc.unesp.br>
0008 
0009     SPDX-License-Identifier: GPL-2.0-or-later
0010 */
0011 
0012 #ifndef STATISTICSVIEW_H
0013 #define STATISTICSVIEW_H
0014 
0015 #include <QLabel>
0016 #include <QWidget>
0017 
0018 class QPushButton;
0019 class QVBoxLayout;
0020 class QHBoxLayout;
0021 class QGridLayout;
0022 
0023 class StatisticsBarWidget;
0024 
0025 
0026 /*!
0027   * StatisticsView takes care of the statistics of a test.
0028   * It saves the number of correct and wrong answers and
0029   * displays this data to the user.
0030   * \author Sebastian Stein
0031   * \author Eva Brucherseifer
0032   */
0033 
0034 class StatisticsView : public QFrame
0035 {
0036     Q_OBJECT
0037 public:
0038     /** constructor */
0039     explicit StatisticsView(QWidget * parent = nullptr);
0040 
0041     /** destructor */
0042     ~StatisticsView() override;
0043 
0044     /** increment number of correct answers */
0045     void addCorrect();
0046 
0047     /** increment number of skipped answers */
0048     void addSkipped();
0049 
0050     /** increment number of wrong answers */
0051     void addWrong();
0052 
0053     /** set statistics to zero.
0054      *  Triggered by internal button or when a new test is started
0055      */
0056     void resetStatistics();
0057 private:
0058     /** calculate percentages and update view */
0059     void calc();
0060 
0061     unsigned int m_count;
0062     unsigned int m_correct;
0063     unsigned int m_skipped;
0064 
0065     QHBoxLayout * buttonLayout;
0066     QVBoxLayout * layout1;
0067     QGridLayout * labelGrid;
0068     QLabel * result1Label;
0069     QLabel * result2Label;
0070     QLabel * result3Label;
0071     QLabel * result4Label;
0072     QLabel * info1Label;
0073     QLabel * info2Label;
0074     QLabel * info3Label;
0075     QLabel * info4Label;
0076 
0077     QFont defaultFont;
0078 
0079     QPushButton * resetButton;
0080 
0081     StatisticsBarWidget * statisticsBar;
0082 };
0083 
0084 #endif