#include "oitautoanalysisparamform.h"
#include "ui_oitautoanalysisparamform.h"

#include "global.h"
#include "logger.h"

OITAutoAnalysisParamForm::OITAutoAnalysisParamForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::OITAutoAnalysisParamForm)
{
    ui->setupUi(this);

    ui->LineEditCoefficient->setEnabled(false);
    ui->LineEditThreshold->setEnabled(false);

    ui->LineEditCoefficient->setText(
                Global::converDoubleToStr(Global::_OITAutoAnalysisCoefficient));
    ui->LineEditThreshold->setText(
                Global::converDoubleToStr(Global::_OITAutoAnalysisThreshold));
}

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

void OITAutoAnalysisParamForm::on_pushButtonOk_clicked()
{
    hide();

    if(ui->checkBoxAutoAnalysisEnable->checkState() == Qt::Checked){
        Global::_OITAutoAnalysisModeFlag = true;
    }else if(ui->checkBoxAutoAnalysisEnable->checkState() == Qt::Unchecked){
        Global::_OITAutoAnalysisModeFlag = false;
    }

    Global::_OITAutoAnalysisCoefficient =
            ui->LineEditCoefficient->text().toDouble();
    Global::_OITAutoAnalysisThreshold =
            ui->LineEditThreshold->text().toDouble();

    logde<<"flag:"<<Global::_OITAutoAnalysisModeFlag;
    logde<<"coefficient:"<<Global::_OITAutoAnalysisCoefficient;
    logde<<"threshold:"<<Global::_OITAutoAnalysisThreshold;
}

void OITAutoAnalysisParamForm::on_checkBoxAutoAnalysisEnable_stateChanged(int arg1)
{
    if(arg1 == Qt::Checked){
        ui->LineEditCoefficient->setEnabled(true);
        ui->LineEditThreshold->setEnabled(true);
    }else if(arg1 == Qt::Unchecked){
        ui->LineEditCoefficient->setEnabled(false);
        ui->LineEditThreshold->setEnabled(false);
    }
}
