#include "sensorsettingsdialog.h"
#include "ui_sensorsettingsdialog.h"

SensorSettingsDialog::SensorSettingsDialog(const Sensor& sensor, QWidget* parent)
	: QDialog(parent)
	, ui(new Ui::SensorSettingsDialog)
{
	ui->setupUi(this);

	ui->label_typeValue->setText(QString::number(sensor.type));
	ui->label_idValue->setText(QString::number(sensor.id));
	ui->lineEdit_Name->setText(sensor.name);
	ui->checkBox_Hidden->setChecked(sensor.hidden);

	// Populate group dropdown with existing groups
	std::vector<QString> groups = globalSensors.allGroups();
	for(const QString& group : groups)
		ui->comboBox_Group->addItem(group);
	// Set current group (will be empty string if no group)
	ui->comboBox_Group->setCurrentText(sensor.groupName);
}

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

QString SensorSettingsDialog::getName() const
{
	return ui->lineEdit_Name->text();
}

QString SensorSettingsDialog::getGroupName() const
{
	return ui->comboBox_Group->currentText();
}

bool SensorSettingsDialog::getHidden() const
{
	return ui->checkBox_Hidden->isChecked();
}