#include "cdlgcasslotstatuset.h"
#include "ui_cdlgcasslotstatuset.h"
#include "cworker.h"
#include "cworkerdriver.h"
#include "logic.h"
#include "mainwindow.h"
CDlgCasslotStatuSet::CDlgCasslotStatuSet(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::CDlgCasslotStatuSet)
{
    ui->setupUi(this);

	Init();
}

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

void CDlgCasslotStatuSet::on_pushButton_OK_clicked()
{
	int nSlot = ui->comboBox_slot->currentText().toInt();
	int nStatus = ui->comboBox_status->currentData().toInt();
	CCassette* pCass = GET_CHDIRECT(CASSETTE, CCassette);
	int iSlotCount = pCass->m_Variants.get_VData(Var_Cass_Slot_Count)
		->toInt();

	if (nSlot >= 0
		&& nSlot < iSlotCount)
	{
		pCass->vslots[nSlot].WPstatus = SLOT_STATUS(nStatus);
	}
    accept();
}

void CDlgCasslotStatuSet::on_pushButton_Cancel_clicked()
{
    reject();
}

void CDlgCasslotStatuSet::Init()
{
	ui->comboBox_status->addItem("UNSCANED", 0);
	ui->comboBox_status->addItem("NOWP", 1);
	ui->comboBox_status->addItem("WPUNCUT", 2);

	CCassette* pCass = GET_CHDIRECT(CASSETTE, CCassette);
	int iSlotCount = pCass->m_Variants.get_VData(Var_Cass_Slot_Count)
		->toInt();
	for (int i = 0; i < iSlotCount; ++i)
	{
		ui->comboBox_slot->addItem(QString("%1").arg(i), i);
	}
}