#ifndef DATABASEERASMUSAPP_H
#define DATABASEERASMUSAPP_H

#include <QObject>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QtGui>

class DatabaseErasmusApp : public QObject
{
  Q_OBJECT
  private:
    QSqlDatabase db;
    void openDatabase( void );
    void closeDatabase( void );
  public:
    explicit DatabaseErasmusApp( QObject *parent = 0 );
    ~DatabaseErasmusApp( void );
    //Settings
    void setCurrentCountryCode( QString countryCode );
    QString getCurrentCountryCode( void );
    void setCurrentLanguageId( int langId );
    int getCurrentLanguageId( void );

    //QuizSettings
    void setCurrentCategoryIds( QList< int > categoryIds );
    QList< int > getCurrentCategoryIds( void );
    void setNumberOfQuestions( int qNumber );
    int getNumberOfQuestions( void );
    void setTimePerQuestion( int time );
    int getTimePerQuestion( void );

    //Category
    QList< int > getAllCategoryIds( void );
    int getCategoryIdForQuestionId( int questionId );
    QString getCategoryNameAt( int categoryId );
    QList< QString > getCategoryNamesAt( int categoryId );
    QString getCategoryNameForQuestionId( int questionId );
    int addCategory( void );
    void deleteCategory( int categoryId );
    int getFreeCategoryId( void );
    int getMaxCategoryId( void );
    void setCategoryText( int langId, int categoryId, QString categoryText );

    //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 deleteQuestion( int questionId );
    int getFreeQuestionId( void );
    int getMaxQuestionId( void );
    void setQuestionText( int langId, int questionId, QString questionText );
    void setQuestionAnswer( int answerId, int questionId, bool isAnswerTrue );
    void deleteQuestionAnswer( int questionId );

    //Answer
    QList< int > getAllAnswerIds( void );
    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 deleteAnswer( int answerId );
    int getFreeAnswerId( void );
    int getMaxAnswerId( void );
    void setAnswerText( int langId, int answerId, QString answerText, QString explanationText );

    int getFreeId( QList< int > idList );
};

#endif // DATABASEERASMUSAPP_H
