/***************************************************************************
 *   Copyright (C) 2004 by Kraschinski Arnold                              *
 *   arnold.kra67@gmx.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.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.           *
 ***************************************************************************/
#ifndef QCOUNTERVIEW_H
#define QCOUNTERVIEW_H

#include <QWidget>
#include <QSize>

/** 
This widget shows the learners success. It counts the solved exercises, the
number of correct solutions and calculates the percentage of the correct
solutions.

@author Kraschinski Arnold
*/
class QCounterView : public QWidget
{
Q_OBJECT
public:
    QCounterView(QWidget *parent = 0);

    ~QCounterView();
    virtual QSize sizeHint() const {return QSize(COUNTER_WIDTH, COUNTER_HEIGHT); };
    
    /** get some information about the learning process
        the number of solved exercises
      */
    int getExerciseSolved();
    /** get some information about the learning process
        the number of solved exercises with correct solutions
      */    
    int getExerciseCorretSolved();
    /** get some information about the learning process
        the percentage of right solutions
      */
    int getPercentageCorrect();
    
public slots:
    /** Add n solved exercises. correct is the number of the 
     * exercises that have been solved correctly. correct is alwayx <= n
     *
     * @param n number of solved exercises
     * @param correct the number of correct answers
     */
    void slotAdd(int n, int correct);
    
signals:
    /** The signal will be emitted of some correct answers are reported to the counterView.
      * This signal can be connected to other displaying classes like the jigsaw.
      */
    void someCorrectAnswers(int correct);

protected:
    /** Three informations need to be painted here:
      * - the total number of solved exercises
      * - the number of exercises with correct solution
      * - the percentage of correct solutions so far (cor. sol. / sol. ex.) * 100
      */
    virtual void paintEvent(QPaintEvent* e);  
    
private:
    /** the number of solved exercises */
    int                     m_solved;
    
    /** the number of correct solutions */
    int                     m_correct;
    
    /** The values for the different colours from red to yellow and finally to green. */
    static const int        farbenR[21];
    static const int        farbenG[21];
    static const int        farbenB[21];
    
    static const int        COUNTER_WIDTH;
    static const int        COUNTER_HEIGHT;
};

#endif
