#ifndef CONTROLER_H
#define CONTROLER_H

#include "ui_controller.h"
#include "menu.h"
#include "quizsettings.h"
#include "quiz.h"
#include "quizevaluation.h"
#include "managequestionsmenu.h"
#include "addquestion.h"
#include "addquestionsperfile.h"
#include "deletequestion.h"
#include "databaseerasmusapp.h"
#include "passwordcheck.h"
#include <QtWidgets>
#include <QtGui>

class Menu;
class QuizSettings;
class Quiz;
class QuizEvaluation;
class ManageQuestionsMenu;
class AddQuestion;
class AddQuestionsPerFile;
class DeleteQuestion;

class Controller : public QWidget, private Ui::Controller
{
  Q_OBJECT
  private:
    Menu *menu;
    QuizSettings *quizSettings;
    Quiz *quiz;
    QuizEvaluation *quizEvaluation;
    ManageQuestionsMenu *manageQuestionsMenu;
    AddQuestion* addQuestions;
    AddQuestionsPerFile *addQuestionsPerFile;
    DeleteQuestion *deleteQuestions;
    QTranslator translator;
    DatabaseErasmusApp db;
  public:
    Controller( QWidget *parent = 0 );
    ~Controller( void );
  public slots:
    void showMenu( void );
    void showQuizSettings( void );
    void showQuiz( void );
    void showQuizCancelWindow( void );
    void showQuizEvaluation( int numberOfTrueAnsweredQuestions, int numberOfQuestions, int averageTimePerQuestion );
    void showManageQuestionsMenu( void );
    void showAddQuestion( void );
    void showAddQuestionsPerFile( void );
    void showDeleteQuestion( void );
    void showPasswordCheck( void );
    void showDatabaseEditor( void );

    //Settings
    int getCurrentLanguageId( void );
    void changeLanguageToDE( void );
    void changeLanguageToEN( void );
    void changeLanguageToEE( void );
    void switchLanguage( void );

    //QuizSettings
    void setNumberOfQuestions( int qNumber );
    int getNumberOfQuestions( void );
    void setTimePerQuestion( int time );
    int getTimePerQuestion( void );
    void setCurrentCategoryIds( QList< int > categoryIds );
    QList< int > getCurrentCategoryIds( void );
    void saveQuizSettings( int numberOfQuestion, int timePerQuestion, QList< int > currentCategoryIds );

    //Category
    QList< int > getAllCategoryIds( void );
    QString getCategoryNameAt( int id );
    QList< QString > getCategoryNamesAt( int categoryId );
    QString getCategoryNameForQuestionId( int questionId );
    int getCategoryIdForQuestionId( int questionId );
    int addCategory( void );
    void setDECategoryText( int categoryId, QString DECategoryText );
    void setENCategoryText( int categoryId, QString ENCategoryText );
    void setEECategoryText( int categoryId, QString EECategoryText );

    //Question
    QList< int > getAllQuestionIds( void );
    QList< int > getQuestionIdsToCategoryIds( QList< int > categoryIds );
    QString getQuestionTextAt( int questionId );
    QList< QString > getQuestionTextsAt( int questionId );
    int addQuestion( int categoryId );
    void setDEQuestionText( int questionId, QString DEQuestionText );
    void setENQuestionText( int questionId, QString ENQuestionText );
    void setEEQuestionText( int questionId, QString EEQuestionText );
    void setQuestionAnswer( int answerId, int questionId, int isAnswerTrue );
    void deleteQuestionAndAnswers( int questionId );

    //Answer
    QList< QString > getTrueAnswerTextsToQuestionId( int questionId );
    QList< int > getTrueAnswerIdsToQuestionId( int questionId );
    QList< QString > getFalseAnswerTextsToQuestionId( int questionId );
    QList< int > getFalseAnswerIdsToQuestionId( int questionId );
    QList< QString > getAnswerTextsAt( int answerId );
    QString getExplanationTextToAnswerId( int answerId );
    QList< QString > getExplanationTextsToAnswerId( int answerId );
    int addAnswer( void );
    void setDEAnswerText( int answerId, QString DEAnswerText, QString DEExplanationText );
    void setENAnswerText( int answerId, QString ENAnswerText, QString ENExplanationText );
    void setEEAnswerText( int answerId, QString EEAnswerText, QString EEExplanationText );

  signals:
    void quizQuitted( void );
};

#endif // CONTROLER_H
