#include "dialogedittrainee.h"
#include "ui_dialogedittrainee.h"

DialogEditTrainee::DialogEditTrainee(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DialogEditTrainee),
    traineeInput()
{
    ui->setupUi(this);
}

DialogEditTrainee::~DialogEditTrainee()
{
    delete ui;
}

void DialogEditTrainee::setTrainee(Trainee trainee)
{
    traineeInput = trainee;

    ui->editName->setText(trainee.getName());
    ui->editLogin->setText(trainee.getLogin());
    ui->editPassword->setText(trainee.getPassword());

    ui->checkArchived->setChecked(trainee.getArchived());
    ui->checkLoggedIn->setChecked(trainee.getLoggedIn());
}

Trainee DialogEditTrainee::getTrainee()
{
    Trainee trainee = traineeInput;

    trainee.setName(ui->editName->text());
    trainee.setLogin(ui->editLogin->text());
    trainee.setPassword(ui->editPassword->text());

    trainee.setArchived(ui->checkArchived->isChecked());
    trainee.setLoggedIn(ui->checkLoggedIn->isChecked());

    return trainee;
}
