#ifndef QUESTION_H
#define QUESTION_H

#include <QWidget>

#include "changeQuestion.h"
#include "paperDef.h"
#include "CBaseWidget.h"

#include "CHttpBll.h"
#include <mutex>

namespace Ui {
class question;
}

class question : public QWidget
{
    Q_OBJECT

public:
    explicit question(CQuestionStruct &qs, int nOrder, int nTotalSubQuestion, QWidget *parent = nullptr);
    ~question();

    void setUI(const int nLeft, const int nTop, const int nWidth, const int nHeight);
    void showBtn(int nType);
	
	void setGroupInfo(QString sTitle, QString sProgress);

    void handinPaper();
signals:
    void previousQuestion(int nOrder);
    void nextQuestion(int nOrder);
    void markedItem(bool bMarked, int nIndex);
    void questionAnswered(bool bAnswered, int nIndex);
    void uploadAnswer(int nIndex, __int64 timeStamp, QString sAnswer);
private slots:
    void onPreviousQuestion();
    void onNextQuestion();
    void onMarkedItem(bool bMarked, int nOrder);
    void onQuestionAnswered(bool bAnswered, int nOrder);
    void onUploadAnswer(int nOrder, __int64 timeStamp, QString sAnswer);
private:
    int initQuestionItem(CSubQuestionStruct &subQuestionItem);

    Ui::question *ui;
	
    changeQuestion *m_pWidgetChangeQuestion;
    CQuestionStruct &m_qs;
    int m_nOrder;
    int m_nTotalSubQuestion;
    int m_nListHeight;
	std::mutex m_uiMutex;
};

#endif // QUESTION_H
