summaryrefslogtreecommitdiffstats
path: root/kpercentage/kpercentage/kpercentmain.h
blob: 6e6aea64ac230120494e35086822fb04268779d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/***************************************************************************
                         kpercentmain.h  -  description
                            -------------------
   begin                : Fri Nov 16 2001
   copyright            : (C) 2001 by Matthias Messmer &
                                      Carsten Niehaus &
                                      Robert Gogolok
   email                : bmlmessmer@web.de &
                          cniehaus@gmx.de &
                          mail@robert-gogolok.de
***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KPERCENTMAIN_H
#define KPERCENTMAIN_H

// Qt includes

// KDE includes

// local includes
#include "kanswer.h"

class QGridLayout;
class QHBoxLayout;
class QLabel;
class QLineEdit;
class QProgressBar;
class QPushButton;
class QVBoxLayout;

/**
 * Dialog for the exercises
 * @author Matthias Messmer & Rober Gogolok & Carsten Niehaus
 */
class KPercentMain : public KDialog
{
    Q_OBJECT
    public:
        KPercentMain( QWidget *parent, const char *name = 0 );
        /** checks, if the task is solved right */
        bool validateTask();
        /** prepares the dialog for a new task */
        void newTask();
        /** gets the numbers from the editlines */
        int getPercentvalue();
        int getBasevalue();
        int getPercentage();
        /** inserts the numbers of a new task in the editlines */
        void showNumbers();
        /** called, if number tasks are managed */
        void finished();
        /** shows the kanswer dialog modal with an proper answer about the success. */
        void showAnswer( int modus );
        /** sets the total amount of tasks selekted in opening screen */
        void setNumber( int anumber );
        /** Prepares the exercise for number tasks
        * espacially fills the arrays with proper numbers */
        void initExercise();

        // Public attributes
        /** total number of exercises */
        int number;
        /** actual number of managed exercises */
        int count;

        /** actual amount of given answers */
        int total_answers;
        /** actual count of right answers */
        int right_answers;
        /** actual count of wrong answers */
        int wrong_answers;

        /** in KPercentage selected type of task */
        int selected_type;
        /** percentages to be calculated with */
        int percentage[ 10 ];
        /** basevalues to be calculated with */
        int basevalue[ 10 ];
        /** percentvalues to be calculated with */
        int percentvalue[ 10 ];

        QLabel *label_1;
        QLabel *label_2;
        QLabel *label_number;
        QLabel *label_count;

        /** editline for the actual task */
        QLineEdit *line_edit_input;
        /** editline for the percentage */
        QLineEdit *line_edit_percentage;
        /** editline for the basevalue */
        QLineEdit *line_edit_basevalue;
        /** editline for the percentvalue */
        QLineEdit *line_edit_percentvalue;

        /** showing the effort of the user */
        QProgressBar *progress_bar_count;
        /** button to apply the current input */
        QPushButton *push_button_apply;
        /** button to cancel the exercise series */
        QPushButton *push_button_cancel;
        
        QProgressBar *progress_bar_right_wrong;
        QLabel *label_right;
        QLabel *label_wrong;

        /** the answer window */
        KAnswer *answer;
        /** stores the level selected in KPercentage's combo_box_level */
        int selected_level;

	private:
		void keyPressEvent( QKeyEvent * e );


    public slots:  // Public slots
        /**
         * checks, if the input is a val. number
         * calls validateTask then and if succeeds causes a newTask
         *
         * @see kpercentmain#validateTask kpercetmain#newTask
         */
        void slotApplyInput();
        /** reimplemented: growing the progressbar step by step */
        void timerEvent( QTimerEvent * );
};

#endif