#ifndef ANSWERSEDIT_H
#define ANSWERSEDIT_H
#include <QWidget>
#include <QLineEdit>
#include <QCheckBox>
#include <QRadioButton>
#include <QLabel>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "mttoolbutton.h"
#include "question_item.h"
inline QString removeLineBreaks(QString str) { return str.remove("\n"); }
class AnswersEdit;
class AnswerEdit : public QWidget
{
Q_OBJECT
public:
AnswerEdit(int, AnswersEdit *);
public slots:
void setVisible(bool);
bool isVisible();
private:
QLineEdit * ans_text;
QCheckBox * ans_correct;
MTToolButton * ans_remove;
QLabel * ans_label;
bool ans_visible;
friend class AnswersEdit;
};
class AnswersEdit : public QWidget
{
Q_OBJECT
public:
AnswersEdit(QWidget * = 0);
void setAnswers(QStringList);
void setAnswers(QStringList, Question::Answers, Question::SelectionType = Question::SingleSelection);
QStringList answers();
void setCorrectAnswers(Question::Answers);
Question::Answers correctAnswers();
void replaceAnswer(int, QString);
QString answer(int);
void setSelectionType(Question::SelectionType);
Question::SelectionType selectionType();
int count();
public slots:
void addAnswer();
void removeAnswer(QString);
void removeAnswer(int);
void clear();
protected:
void enableAddAnswerButton();
private:
QList<AnswerEdit *> ae_answers;
QToolButton * ae_add_button;
QRadioButton * ae_singleselection;
QRadioButton * ae_multiselection;
QLabel * ae_answers_label;
QLabel * ae_correct_label;
};
#endif