#include "sitesimdialog.h"
#include "ui_sitesimdialog.h"

#include <QtGlobal>

static unsigned int sim_counter;

SiteSimDialog::SiteSimDialog(QWidget *parent) :
    QDialog(parent),
    sim(0),
    ui(new Ui::SiteSimDialog)
{
    ui->setupUi(this);
}

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

void SiteSimDialog::initialize(const QString& name, int /*nodeType*/, int port)
{
    static int counter;

    if (!sim)
    {
        sim=new QgTftpTargetSim(name, counter, port);
        ++counter;
        setWindowTitle(name);
        ui->lbSite->setText(QString("%1 @ %2)").arg(name).arg(port));

        connect(ui->spErase, QOverload<int>::of(&QSpinBox::valueChanged), sim, &QgTftpTargetSim::setEraseTime);
        connect(ui->spProgr, QOverload<int>::of(&QSpinBox::valueChanged), sim, &QgTftpTargetSim::setProgTime);

    }

    move(10+50, 10+100*sim_counter);
    ++sim_counter;
}

