/***************************************************************************
 *   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 VERBVIEWTRAINER_H
#define VERBVIEWTRAINER_H

#include <QWidget>
#include <trainer.h>


class KLineEdit;
class KHTMLPart;
class QWidget;

/** The class shows a KLineEdit to the use where he can enter the infinitive of a verb.
  * When he presses 'ENTER' the verb is conjugated and the forms are shown to the user
  * in a KHTMLPart.
  * If the user enters an infinitive which can be found in the verb-data he gets a point
  * that is added to the result as a correct answer. If the infinitive cannot be found
  * a false answer is reported.
  *
  * @short trainer call to just look up all the forms of a verb
  * @author Kraschinski Arnold <arnold.kra67@gmx.de>
  * @version 2.00.00
  */

class VerbViewTrainer : public Trainer  {
   Q_OBJECT
public:
    VerbViewTrainer(QWidget *parent=0);
    ~VerbViewTrainer();
    
    /** is called from qlearning when the user pressed the next button */
    virtual void next();

public slots:
    /** Receives a signal when the user changes the input line for the infinitive.
      */
    void slotVerbChanged();
    
    /** Receives a signal when the user has entered a new infinitive into the input line
      * and has pressed the enter button.
      *
      * @param QString the infinitive in the input line
      */
    void slotVerbEntered(const QString &s);
    
    /** Go on to the next verb.
      */
    virtual void slotContinue() {};
    
    /** receive one of the special characters ñ, á, é, í, ó, ú from
     * the button line. The character will be added to the active lineInput
     */
    virtual void slotChar(QString ch);

private:
    KHTMLPart               *m_htmlRenderer;
    KLineEdit               *m_lineEdit;
    
    /** m_clear indicates if some text is displayed in the htmlRenderer. m_clear is true if there
     *  is some text that should be erased when the infinitive in the input line is changed. The
     *  input line is cleared too if m_clear is true. It is flase, when the renderer widget is empty
     *  an there isn't any text to erase.
     */
    bool                    m_clear;
    QString                 m_oldVerb;
    
    /** This function maps the sequence of forms that is produced by the Verbdata classes to the sequence the
     *  forms are presented in the verbviewtrainer. That is the sequence of forms in the verbtabelle.html file.
     */
    static const int        function[64];
    /** The empty HTML document that is shown when the user enters an infinitive. The class gets the information
     *  that the verb has changed but not a new infinitive is enterd. During that time the empty document is shown.
     */
    static const QString    EMPTY;
    /** The user gets the hint to enter an infinitive of a Spanish verb.
     */
    static const QString    HINT_MESSAGE;
    /** The user gets the information that the entered infinitive isn't in the verb database of the program.
     */
    static const QString    UNKNOWN_MESSAGE;
};

#endif
