move from tabs to spaces
This commit is contained in:
@ -5,108 +5,108 @@
|
||||
#include <QSpinBox>
|
||||
|
||||
ActorSettingsDialog::ActorSettingsDialog(std::shared_ptr<AlarmTime> alarm, QWidget *parent):
|
||||
QDialog(parent),
|
||||
actor_(alarm),
|
||||
ui(new Ui::ActorSettingsDialog)
|
||||
QDialog(parent),
|
||||
actor_(alarm),
|
||||
ui(new Ui::ActorSettingsDialog)
|
||||
{
|
||||
init();
|
||||
init();
|
||||
|
||||
widget = new AlarmWidget(alarm, this);
|
||||
ui->vertlayout->addWidget(widget);
|
||||
widget = new AlarmWidget(alarm, this);
|
||||
ui->vertlayout->addWidget(widget);
|
||||
}
|
||||
|
||||
ActorSettingsDialog::ActorSettingsDialog(std::shared_ptr<SensorActor> actor, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
actor_(actor),
|
||||
ui(new Ui::ActorSettingsDialog)
|
||||
QDialog(parent),
|
||||
actor_(actor),
|
||||
ui(new Ui::ActorSettingsDialog)
|
||||
{
|
||||
init();
|
||||
init();
|
||||
|
||||
widget = new SensorActorWidget(actor, &globalSensors, this);
|
||||
ui->vertlayout->addWidget(widget);
|
||||
widget = new SensorActorWidget(actor, &globalSensors, this);
|
||||
ui->vertlayout->addWidget(widget);
|
||||
}
|
||||
|
||||
ActorSettingsDialog::ActorSettingsDialog(std::shared_ptr<Regulator> actor, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
actor_(actor),
|
||||
ui(new Ui::ActorSettingsDialog)
|
||||
QDialog(parent),
|
||||
actor_(actor),
|
||||
ui(new Ui::ActorSettingsDialog)
|
||||
{
|
||||
init();
|
||||
init();
|
||||
|
||||
widget = new RegulatorWdiget(actor, &globalSensors, this);
|
||||
ui->vertlayout->addWidget(widget);
|
||||
widget = new RegulatorWdiget(actor, &globalSensors, this);
|
||||
ui->vertlayout->addWidget(widget);
|
||||
}
|
||||
|
||||
ActorSettingsDialog::ActorSettingsDialog(std::shared_ptr<TimerActor> actor, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
actor_(actor),
|
||||
ui(new Ui::ActorSettingsDialog)
|
||||
QDialog(parent),
|
||||
actor_(actor),
|
||||
ui(new Ui::ActorSettingsDialog)
|
||||
{
|
||||
init();
|
||||
init();
|
||||
|
||||
widget = new TimerActorWidget(actor, this);
|
||||
ui->vertlayout->addWidget(widget);
|
||||
widget = new TimerActorWidget(actor, this);
|
||||
ui->vertlayout->addWidget(widget);
|
||||
}
|
||||
|
||||
ActorSettingsDialog::ActorSettingsDialog(std::shared_ptr<PolynomalActor> actor, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
actor_(actor),
|
||||
ui(new Ui::ActorSettingsDialog)
|
||||
QDialog(parent),
|
||||
actor_(actor),
|
||||
ui(new Ui::ActorSettingsDialog)
|
||||
{
|
||||
init();
|
||||
init();
|
||||
|
||||
widget = new PolynomalActorWidget(actor, &globalSensors, this);
|
||||
ui->vertlayout->addWidget(widget);
|
||||
widget = new PolynomalActorWidget(actor, &globalSensors, this);
|
||||
ui->vertlayout->addWidget(widget);
|
||||
}
|
||||
|
||||
ActorSettingsDialog::ActorSettingsDialog(std::shared_ptr<MultiFactorActor> actor, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
actor_(actor),
|
||||
ui(new Ui::ActorSettingsDialog)
|
||||
QDialog(parent),
|
||||
actor_(actor),
|
||||
ui(new Ui::ActorSettingsDialog)
|
||||
{
|
||||
init();
|
||||
widget = new FactorActorWidget(actor, this);
|
||||
ui->vertlayout->addWidget(widget);
|
||||
init();
|
||||
widget = new FactorActorWidget(actor, this);
|
||||
ui->vertlayout->addWidget(widget);
|
||||
}
|
||||
|
||||
ActorSettingsDialog::ActorSettingsDialog(std::shared_ptr<Actor> actor, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
actor_(actor),
|
||||
ui(new Ui::ActorSettingsDialog)
|
||||
QDialog(parent),
|
||||
actor_(actor),
|
||||
ui(new Ui::ActorSettingsDialog)
|
||||
{
|
||||
init();
|
||||
init();
|
||||
}
|
||||
|
||||
void ActorSettingsDialog::init()
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->comboBox_action, SIGNAL(currentIndexChanged(int)), this, SLOT(changeAction(int)));
|
||||
connect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(valueChanged(int)));
|
||||
connect(ui->pushButton_editItem, &QPushButton::clicked, this, &ActorSettingsDialog::editAsItem);
|
||||
ui->spinBox->hide();
|
||||
ui->setupUi(this);
|
||||
connect(ui->comboBox_action, SIGNAL(currentIndexChanged(int)), this, SLOT(changeAction(int)));
|
||||
connect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(valueChanged(int)));
|
||||
connect(ui->pushButton_editItem, &QPushButton::clicked, this, &ActorSettingsDialog::editAsItem);
|
||||
ui->spinBox->hide();
|
||||
|
||||
ui->spinBox->setValue(actor_->getTriggerValue());
|
||||
if(actor_->getTriggerValue() == 0) ui->comboBox_action->setCurrentIndex(0);
|
||||
else if(actor_->getTriggerValue() == 1) ui->comboBox_action->setCurrentIndex(1);
|
||||
else ui->comboBox_action->setCurrentIndex(2);
|
||||
ui->spinBox->setValue(actor_->getTriggerValue());
|
||||
if(actor_->getTriggerValue() == 0) ui->comboBox_action->setCurrentIndex(0);
|
||||
else if(actor_->getTriggerValue() == 1) ui->comboBox_action->setCurrentIndex(1);
|
||||
else ui->comboBox_action->setCurrentIndex(2);
|
||||
|
||||
ui->label_Exausted->setText(actor_->isExausted() ? "True" : "False");
|
||||
ui->label_Exausted->setText(actor_->isExausted() ? "True" : "False");
|
||||
}
|
||||
|
||||
ActorSettingsDialog::~ActorSettingsDialog()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ActorSettingsDialog::editAsItem()
|
||||
{
|
||||
ItemSettingsDialog itemSettingsDiag(actor_, this);
|
||||
itemSettingsDiag.exec();
|
||||
ItemSettingsDialog itemSettingsDiag(actor_, this);
|
||||
itemSettingsDiag.exec();
|
||||
}
|
||||
|
||||
void ActorSettingsDialog::valueChanged(int value)
|
||||
{
|
||||
actor_->setTriggerValue(value);
|
||||
actor_->setTriggerValue(value);
|
||||
}
|
||||
|
||||
void ActorSettingsDialog::hideCancle([[maybe_unused]] const bool hide)
|
||||
@ -116,13 +116,13 @@ void ActorSettingsDialog::hideCancle([[maybe_unused]] const bool hide)
|
||||
|
||||
void ActorSettingsDialog::changeAction(int index)
|
||||
{
|
||||
if(index == 0) actor_->setTriggerValue(0);
|
||||
else if(index == 1) actor_->setTriggerValue(1);
|
||||
else if(index == 2)
|
||||
{
|
||||
ui->spinBox->show();
|
||||
actor_->setTriggerValue(ui->spinBox->value());
|
||||
}
|
||||
if(index != 2)ui->spinBox->hide();
|
||||
if(index == 0) actor_->setTriggerValue(0);
|
||||
else if(index == 1) actor_->setTriggerValue(1);
|
||||
else if(index == 2)
|
||||
{
|
||||
ui->spinBox->show();
|
||||
actor_->setTriggerValue(ui->spinBox->value());
|
||||
}
|
||||
if(index != 2)ui->spinBox->hide();
|
||||
}
|
||||
|
||||
|
@ -10,40 +10,41 @@
|
||||
#include "actorwidgets/polynomalactorwidget.h"
|
||||
#include "actorwidgets/factoractorwidget.h"
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class ActorSettingsDialog;
|
||||
}
|
||||
|
||||
class ActorSettingsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
std::shared_ptr<Actor> actor_;
|
||||
QWidget* widget;
|
||||
std::shared_ptr<Actor> actor_;
|
||||
QWidget* widget;
|
||||
|
||||
void init();
|
||||
void init();
|
||||
|
||||
public:
|
||||
ActorSettingsDialog(std::shared_ptr<AlarmTime> actor, QWidget *parent = nullptr);
|
||||
ActorSettingsDialog(std::shared_ptr<SensorActor> actor, QWidget *parent = nullptr);
|
||||
ActorSettingsDialog(std::shared_ptr<Regulator> actor, QWidget *parent = nullptr);
|
||||
ActorSettingsDialog(std::shared_ptr<TimerActor> actor, QWidget *parent = nullptr);
|
||||
ActorSettingsDialog(std::shared_ptr<PolynomalActor> actor, QWidget *parent = nullptr);
|
||||
ActorSettingsDialog(std::shared_ptr<MultiFactorActor> actor, QWidget *parent = nullptr);
|
||||
ActorSettingsDialog(std::shared_ptr<Actor> actor, QWidget *parent);
|
||||
~ActorSettingsDialog();
|
||||
ActorSettingsDialog(std::shared_ptr<AlarmTime> actor, QWidget *parent = nullptr);
|
||||
ActorSettingsDialog(std::shared_ptr<SensorActor> actor, QWidget *parent = nullptr);
|
||||
ActorSettingsDialog(std::shared_ptr<Regulator> actor, QWidget *parent = nullptr);
|
||||
ActorSettingsDialog(std::shared_ptr<TimerActor> actor, QWidget *parent = nullptr);
|
||||
ActorSettingsDialog(std::shared_ptr<PolynomalActor> actor, QWidget *parent = nullptr);
|
||||
ActorSettingsDialog(std::shared_ptr<MultiFactorActor> actor, QWidget *parent = nullptr);
|
||||
ActorSettingsDialog(std::shared_ptr<Actor> actor, QWidget *parent);
|
||||
~ActorSettingsDialog();
|
||||
|
||||
void hideCancle(const bool hide);
|
||||
void hideCancle(const bool hide);
|
||||
|
||||
private slots:
|
||||
void changeAction(int index);
|
||||
void valueChanged(int value);
|
||||
void editAsItem();
|
||||
void changeAction(int index);
|
||||
void valueChanged(int value);
|
||||
void editAsItem();
|
||||
|
||||
|
||||
private:
|
||||
Ui::ActorSettingsDialog *ui;
|
||||
Ui::ActorSettingsDialog *ui;
|
||||
};
|
||||
|
||||
#endif // ACTORSETTINGSDIALOG_H
|
||||
|
@ -2,73 +2,73 @@
|
||||
#include "ui_alarmwidget.h"
|
||||
|
||||
AlarmWidget::AlarmWidget(std::shared_ptr<AlarmTime> alarm, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
alarm_(alarm),
|
||||
ui(new Ui::AlarmWidget)
|
||||
QWidget(parent),
|
||||
alarm_(alarm),
|
||||
ui(new Ui::AlarmWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->checkBox, &QCheckBox::stateChanged, this, &AlarmWidget::toggleRepeating);
|
||||
connect(ui->radioButton, &QRadioButton::clicked, this, &AlarmWidget::setRepeatingType);
|
||||
connect(ui->radioButton_2, &QRadioButton::clicked, this, &AlarmWidget::setRepeatingType);
|
||||
connect(ui->radioButton_3, &QRadioButton::clicked, this, &AlarmWidget::setRepeatingType);
|
||||
connect(ui->radioButton_4, &QRadioButton::clicked, this, &AlarmWidget::setRepeatingType);
|
||||
ui->setupUi(this);
|
||||
connect(ui->checkBox, &QCheckBox::stateChanged, this, &AlarmWidget::toggleRepeating);
|
||||
connect(ui->radioButton, &QRadioButton::clicked, this, &AlarmWidget::setRepeatingType);
|
||||
connect(ui->radioButton_2, &QRadioButton::clicked, this, &AlarmWidget::setRepeatingType);
|
||||
connect(ui->radioButton_3, &QRadioButton::clicked, this, &AlarmWidget::setRepeatingType);
|
||||
connect(ui->radioButton_4, &QRadioButton::clicked, this, &AlarmWidget::setRepeatingType);
|
||||
|
||||
ui->dateTimeEdit->setDateTime(alarm->getDateTime());
|
||||
ui->dateTimeEdit->setDateTime(alarm->getDateTime());
|
||||
|
||||
if(alarm_->getRepeat() == AlarmTime::REPEAT_NEVER)
|
||||
{
|
||||
ui->radioButton->setEnabled(false);
|
||||
ui->radioButton_2->setEnabled(false);
|
||||
ui->radioButton_3->setEnabled(false);
|
||||
ui->radioButton_4->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->checkBox->setChecked(true);
|
||||
ui->radioButton->setEnabled(true);
|
||||
ui->radioButton_2->setEnabled(true);
|
||||
ui->radioButton_3->setEnabled(true);
|
||||
ui->radioButton_4->setEnabled(true);
|
||||
}
|
||||
if(alarm_->getRepeat() == AlarmTime::REPEAT_NEVER)
|
||||
{
|
||||
ui->radioButton->setEnabled(false);
|
||||
ui->radioButton_2->setEnabled(false);
|
||||
ui->radioButton_3->setEnabled(false);
|
||||
ui->radioButton_4->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->checkBox->setChecked(true);
|
||||
ui->radioButton->setEnabled(true);
|
||||
ui->radioButton_2->setEnabled(true);
|
||||
ui->radioButton_3->setEnabled(true);
|
||||
ui->radioButton_4->setEnabled(true);
|
||||
}
|
||||
|
||||
if(alarm_->getRepeat() == AlarmTime::REPEAT_DAILY) ui->radioButton->setChecked(true);
|
||||
else if(alarm_->getRepeat() == AlarmTime::REPEAT_WEEKLY) ui->radioButton_2->setChecked(true);
|
||||
else if(alarm_->getRepeat() == AlarmTime::REPEAT_MONTHLY)ui->radioButton_3->setChecked(true);
|
||||
else if(alarm_->getRepeat() == AlarmTime::REPEAT_YEARLY) ui->radioButton_4->setChecked(true);
|
||||
if(alarm_->getRepeat() == AlarmTime::REPEAT_DAILY) ui->radioButton->setChecked(true);
|
||||
else if(alarm_->getRepeat() == AlarmTime::REPEAT_WEEKLY) ui->radioButton_2->setChecked(true);
|
||||
else if(alarm_->getRepeat() == AlarmTime::REPEAT_MONTHLY)ui->radioButton_3->setChecked(true);
|
||||
else if(alarm_->getRepeat() == AlarmTime::REPEAT_YEARLY) ui->radioButton_4->setChecked(true);
|
||||
|
||||
connect(ui->dateTimeEdit, &QDateTimeEdit::dateTimeChanged, alarm.get(), &AlarmTime::changeTime);
|
||||
connect(ui->dateTimeEdit, &QDateTimeEdit::dateTimeChanged, alarm.get(), &AlarmTime::changeTime);
|
||||
}
|
||||
|
||||
AlarmWidget::~AlarmWidget()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void AlarmWidget::setRepeatingType()
|
||||
{
|
||||
if(ui->radioButton->isChecked())alarm_->setRepeat(AlarmTime::REPEAT_DAILY);
|
||||
if(ui->radioButton_2->isChecked())alarm_->setRepeat(AlarmTime::REPEAT_WEEKLY);
|
||||
if(ui->radioButton_3->isChecked())alarm_->setRepeat(AlarmTime::REPEAT_MONTHLY);
|
||||
if(ui->radioButton_4->isChecked())alarm_->setRepeat(AlarmTime::REPEAT_YEARLY);
|
||||
if(ui->radioButton->isChecked())alarm_->setRepeat(AlarmTime::REPEAT_DAILY);
|
||||
if(ui->radioButton_2->isChecked())alarm_->setRepeat(AlarmTime::REPEAT_WEEKLY);
|
||||
if(ui->radioButton_3->isChecked())alarm_->setRepeat(AlarmTime::REPEAT_MONTHLY);
|
||||
if(ui->radioButton_4->isChecked())alarm_->setRepeat(AlarmTime::REPEAT_YEARLY);
|
||||
}
|
||||
|
||||
void AlarmWidget::toggleRepeating(int state)
|
||||
{
|
||||
if(state)
|
||||
{
|
||||
ui->radioButton->setEnabled(true);
|
||||
ui->radioButton_2->setEnabled(true);
|
||||
ui->radioButton_3->setEnabled(true);
|
||||
ui->radioButton_4->setEnabled(true);
|
||||
setRepeatingType();
|
||||
}
|
||||
else
|
||||
{
|
||||
alarm_->setRepeat(AlarmTime::REPEAT_NEVER);
|
||||
ui->radioButton->setEnabled(false);
|
||||
ui->radioButton_2->setEnabled(false);
|
||||
ui->radioButton_3->setEnabled(false);
|
||||
ui->radioButton_4->setEnabled(false);
|
||||
}
|
||||
if(state)
|
||||
{
|
||||
ui->radioButton->setEnabled(true);
|
||||
ui->radioButton_2->setEnabled(true);
|
||||
ui->radioButton_3->setEnabled(true);
|
||||
ui->radioButton_4->setEnabled(true);
|
||||
setRepeatingType();
|
||||
}
|
||||
else
|
||||
{
|
||||
alarm_->setRepeat(AlarmTime::REPEAT_NEVER);
|
||||
ui->radioButton->setEnabled(false);
|
||||
ui->radioButton_2->setEnabled(false);
|
||||
ui->radioButton_3->setEnabled(false);
|
||||
ui->radioButton_4->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,26 +5,27 @@
|
||||
#include <memory>
|
||||
#include "../../actors/alarmtime.h"
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class AlarmWidget;
|
||||
}
|
||||
|
||||
class AlarmWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
std::shared_ptr<AlarmTime> alarm_;
|
||||
std::shared_ptr<AlarmTime> alarm_;
|
||||
|
||||
public:
|
||||
explicit AlarmWidget(std::shared_ptr<AlarmTime> alarm, QWidget *parent = nullptr);
|
||||
~AlarmWidget();
|
||||
explicit AlarmWidget(std::shared_ptr<AlarmTime> alarm, QWidget *parent = nullptr);
|
||||
~AlarmWidget();
|
||||
|
||||
private slots:
|
||||
void toggleRepeating(int state);
|
||||
void setRepeatingType();
|
||||
void toggleRepeating(int state);
|
||||
void setRepeatingType();
|
||||
|
||||
private:
|
||||
Ui::AlarmWidget *ui;
|
||||
Ui::AlarmWidget *ui;
|
||||
};
|
||||
|
||||
#endif // ALARMWIDGET_H
|
||||
|
@ -3,82 +3,82 @@
|
||||
#include "../actorsettingsdialog.h"
|
||||
|
||||
FactorActorWidget::FactorActorWidget(std::shared_ptr<MultiFactorActor> actor, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
actor_(actor),
|
||||
ui(new Ui::FactorActorWidget)
|
||||
QWidget(parent),
|
||||
actor_(actor),
|
||||
ui(new Ui::FactorActorWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->comboBox->setCurrentText(actor_->getFactorDirection() ? "True" : "False");
|
||||
ui->spinBox->setValue(actor_->getPreCancleTime());
|
||||
if(actor_->getFactorActor()) ui->label_FactorActor->setText(actor_->getFactorActor()->getName());
|
||||
connect(ui->pushButton, &QPushButton::clicked, this, &FactorActorWidget::createFactorActor);
|
||||
connect(ui->comboBox_Direcion, &QComboBox::currentTextChanged, this, &FactorActorWidget::setDirection);
|
||||
connect(ui->spinBox, qOverload<int>(&QSpinBox::valueChanged), this, &FactorActorWidget::setPreCancleTime);
|
||||
ui->setupUi(this);
|
||||
ui->comboBox->setCurrentText(actor_->getFactorDirection() ? "True" : "False");
|
||||
ui->spinBox->setValue(actor_->getPreCancleTime());
|
||||
if(actor_->getFactorActor()) ui->label_FactorActor->setText(actor_->getFactorActor()->getName());
|
||||
connect(ui->pushButton, &QPushButton::clicked, this, &FactorActorWidget::createFactorActor);
|
||||
connect(ui->comboBox_Direcion, &QComboBox::currentTextChanged, this, &FactorActorWidget::setDirection);
|
||||
connect(ui->spinBox, qOverload<int>(&QSpinBox::valueChanged), this, &FactorActorWidget::setPreCancleTime);
|
||||
}
|
||||
|
||||
FactorActorWidget::~FactorActorWidget()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void FactorActorWidget::createFactorActor()
|
||||
{
|
||||
ActorSettingsDialog* dialog = nullptr;
|
||||
std::shared_ptr<Actor> actor = nullptr;
|
||||
ActorSettingsDialog* dialog = nullptr;
|
||||
std::shared_ptr<Actor> actor = nullptr;
|
||||
|
||||
if(ui->comboBox->currentText() == "Alarm")
|
||||
{
|
||||
std::shared_ptr<AlarmTime> alarm = std::shared_ptr<AlarmTime>(new AlarmTime);
|
||||
actor = alarm;
|
||||
dialog = new ActorSettingsDialog(alarm, this);
|
||||
}
|
||||
else if(ui->comboBox->currentText() == "Sensor")
|
||||
{
|
||||
std::shared_ptr<SensorActor> sensorActor = std::shared_ptr<SensorActor>(new SensorActor());
|
||||
actor = sensorActor;
|
||||
dialog = new ActorSettingsDialog(sensorActor, this);
|
||||
}
|
||||
else if(ui->comboBox->currentText() == "Timer" )
|
||||
{
|
||||
std::shared_ptr<TimerActor> timerActor = std::shared_ptr<TimerActor>(new TimerActor());
|
||||
actor = timerActor;
|
||||
dialog = new ActorSettingsDialog(timerActor, this);
|
||||
}
|
||||
else if(ui->comboBox->currentText() == "Regulator")
|
||||
{
|
||||
std::shared_ptr<Regulator> regulator = std::shared_ptr<Regulator>(new Regulator());
|
||||
actor = regulator;
|
||||
dialog = new ActorSettingsDialog(regulator, this);
|
||||
}
|
||||
if(ui->comboBox->currentText() == "Alarm")
|
||||
{
|
||||
std::shared_ptr<AlarmTime> alarm = std::shared_ptr<AlarmTime>(new AlarmTime);
|
||||
actor = alarm;
|
||||
dialog = new ActorSettingsDialog(alarm, this);
|
||||
}
|
||||
else if(ui->comboBox->currentText() == "Sensor")
|
||||
{
|
||||
std::shared_ptr<SensorActor> sensorActor = std::shared_ptr<SensorActor>(new SensorActor());
|
||||
actor = sensorActor;
|
||||
dialog = new ActorSettingsDialog(sensorActor, this);
|
||||
}
|
||||
else if(ui->comboBox->currentText() == "Timer" )
|
||||
{
|
||||
std::shared_ptr<TimerActor> timerActor = std::shared_ptr<TimerActor>(new TimerActor());
|
||||
actor = timerActor;
|
||||
dialog = new ActorSettingsDialog(timerActor, this);
|
||||
}
|
||||
else if(ui->comboBox->currentText() == "Regulator")
|
||||
{
|
||||
std::shared_ptr<Regulator> regulator = std::shared_ptr<Regulator>(new Regulator());
|
||||
actor = regulator;
|
||||
dialog = new ActorSettingsDialog(regulator, this);
|
||||
}
|
||||
|
||||
else if(ui->comboBox->currentText() == "Polynomal")
|
||||
{
|
||||
std::shared_ptr<PolynomalActor> polynomalActor = std::shared_ptr<PolynomalActor>(new PolynomalActor());
|
||||
actor = polynomalActor;
|
||||
dialog = new ActorSettingsDialog(polynomalActor, this);
|
||||
}
|
||||
else if(ui->comboBox->currentText() == "Polynomal")
|
||||
{
|
||||
std::shared_ptr<PolynomalActor> polynomalActor = std::shared_ptr<PolynomalActor>(new PolynomalActor());
|
||||
actor = polynomalActor;
|
||||
dialog = new ActorSettingsDialog(polynomalActor, this);
|
||||
}
|
||||
|
||||
|
||||
if(dialog != nullptr)
|
||||
{
|
||||
dialog->setParent(this);
|
||||
dialog->show();
|
||||
if(dialog->exec() == QDialog::Accepted)
|
||||
{
|
||||
actor_->setFactorActor(actor);
|
||||
ui->label_FactorActor->setText(actor->getName());
|
||||
}
|
||||
delete dialog;
|
||||
}
|
||||
if(dialog != nullptr)
|
||||
{
|
||||
dialog->setParent(this);
|
||||
dialog->show();
|
||||
if(dialog->exec() == QDialog::Accepted)
|
||||
{
|
||||
actor_->setFactorActor(actor);
|
||||
ui->label_FactorActor->setText(actor->getName());
|
||||
}
|
||||
delete dialog;
|
||||
}
|
||||
}
|
||||
|
||||
void FactorActorWidget::setDirection(const QString& type)
|
||||
{
|
||||
if(type == "True") actor_->setFactorDirection(true);
|
||||
else actor_->setFactorDirection(false);
|
||||
if(type == "True") actor_->setFactorDirection(true);
|
||||
else actor_->setFactorDirection(false);
|
||||
}
|
||||
|
||||
void FactorActorWidget::setPreCancleTime(int time)
|
||||
{
|
||||
actor_->setPreCancleTime(time);
|
||||
actor_->setPreCancleTime(time);
|
||||
}
|
||||
|
@ -4,27 +4,28 @@
|
||||
#include <QWidget>
|
||||
#include "../../actors/factoractor.h"
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class FactorActorWidget;
|
||||
}
|
||||
|
||||
class FactorActorWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
std::shared_ptr<MultiFactorActor> actor_;
|
||||
std::shared_ptr<MultiFactorActor> actor_;
|
||||
|
||||
public:
|
||||
explicit FactorActorWidget(std::shared_ptr<MultiFactorActor> actor, QWidget *parent = nullptr);
|
||||
~FactorActorWidget();
|
||||
explicit FactorActorWidget(std::shared_ptr<MultiFactorActor> actor, QWidget *parent = nullptr);
|
||||
~FactorActorWidget();
|
||||
|
||||
private slots:
|
||||
void createFactorActor();
|
||||
void setDirection(const QString& direction);
|
||||
void setPreCancleTime(int time);
|
||||
void createFactorActor();
|
||||
void setDirection(const QString& direction);
|
||||
void setPreCancleTime(int time);
|
||||
|
||||
private:
|
||||
Ui::FactorActorWidget *ui;
|
||||
Ui::FactorActorWidget *ui;
|
||||
};
|
||||
|
||||
#endif // FACTORACTORWIDGET_H
|
||||
|
@ -1,48 +1,50 @@
|
||||
#include "polynomalactorwidget.h"
|
||||
#include "ui_polynomalactorwidget.h"
|
||||
|
||||
PolynomalActorWidget::PolynomalActorWidget(std::shared_ptr<PolynomalActor> actor, SensorStore* sensors, QWidget *parent):
|
||||
QWidget(parent),
|
||||
sensors_(sensors),
|
||||
actor_(actor),
|
||||
ui(new Ui::PolynomalActorWidget)
|
||||
PolynomalActorWidget::PolynomalActorWidget(std::shared_ptr<PolynomalActor> actor, SensorStore* sensors,
|
||||
QWidget *parent):
|
||||
QWidget(parent),
|
||||
sensors_(sensors),
|
||||
actor_(actor),
|
||||
ui(new Ui::PolynomalActorWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
if(sensors)ui->listView->sensorsChanged(*(sensors->getSensors()));
|
||||
else
|
||||
{
|
||||
ui->listView->hide();
|
||||
ui->label->hide();
|
||||
}
|
||||
ui->setupUi(this);
|
||||
if(sensors)ui->listView->sensorsChanged(*(sensors->getSensors()));
|
||||
else
|
||||
{
|
||||
ui->listView->hide();
|
||||
ui->label->hide();
|
||||
}
|
||||
|
||||
double pow3, pow2, pow1, pow0;
|
||||
double pow3, pow2, pow1, pow0;
|
||||
|
||||
actor_->getCoeffiancts(pow3, pow2, pow1, pow0);
|
||||
actor_->getCoeffiancts(pow3, pow2, pow1, pow0);
|
||||
|
||||
ui->doubleSpinBox_pow0->setValue(pow0);
|
||||
ui->doubleSpinBox_pow1->setValue(pow1);
|
||||
ui->doubleSpinBox_pow2->setValue(pow2);
|
||||
ui->doubleSpinBox_pow3->setValue(pow3);
|
||||
ui->doubleSpinBox_pow0->setValue(pow0);
|
||||
ui->doubleSpinBox_pow1->setValue(pow1);
|
||||
ui->doubleSpinBox_pow2->setValue(pow2);
|
||||
ui->doubleSpinBox_pow3->setValue(pow3);
|
||||
|
||||
connect(ui->doubleSpinBox_pow3, &QDoubleSpinBox::editingFinished, this, &PolynomalActorWidget::setPow);
|
||||
connect(ui->doubleSpinBox_pow2, &QDoubleSpinBox::editingFinished, this, &PolynomalActorWidget::setPow);
|
||||
connect(ui->doubleSpinBox_pow1, &QDoubleSpinBox::editingFinished, this, &PolynomalActorWidget::setPow);
|
||||
connect(ui->doubleSpinBox_pow0, &QDoubleSpinBox::editingFinished, this, &PolynomalActorWidget::setPow);
|
||||
connect(ui->listView, &SensorListWidget::clicked, this, &PolynomalActorWidget::setSensor);
|
||||
connect(ui->doubleSpinBox_pow3, &QDoubleSpinBox::editingFinished, this, &PolynomalActorWidget::setPow);
|
||||
connect(ui->doubleSpinBox_pow2, &QDoubleSpinBox::editingFinished, this, &PolynomalActorWidget::setPow);
|
||||
connect(ui->doubleSpinBox_pow1, &QDoubleSpinBox::editingFinished, this, &PolynomalActorWidget::setPow);
|
||||
connect(ui->doubleSpinBox_pow0, &QDoubleSpinBox::editingFinished, this, &PolynomalActorWidget::setPow);
|
||||
connect(ui->listView, &SensorListWidget::clicked, this, &PolynomalActorWidget::setSensor);
|
||||
|
||||
}
|
||||
|
||||
PolynomalActorWidget::~PolynomalActorWidget()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void PolynomalActorWidget::setPow()
|
||||
{
|
||||
actor_->setCoeffiancts(ui->doubleSpinBox_pow3->value(), ui->doubleSpinBox_pow2->value(), ui->doubleSpinBox_pow1->value(), ui->doubleSpinBox_pow0->value());
|
||||
actor_->setCoeffiancts(ui->doubleSpinBox_pow3->value(), ui->doubleSpinBox_pow2->value(),
|
||||
ui->doubleSpinBox_pow1->value(), ui->doubleSpinBox_pow0->value());
|
||||
}
|
||||
|
||||
void PolynomalActorWidget::setSensor(const QModelIndex &index)
|
||||
{
|
||||
actor_->setSensor(sensors_->getSensors()->at(index.row()));
|
||||
actor_->setSensor(sensors_->getSensors()->at(index.row()));
|
||||
}
|
||||
|
@ -4,27 +4,29 @@
|
||||
#include <QWidget>
|
||||
#include "../../actors/polynomalactor.h"
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class PolynomalActorWidget;
|
||||
}
|
||||
|
||||
class PolynomalActorWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
SensorStore* sensors_;
|
||||
std::shared_ptr<PolynomalActor> actor_;
|
||||
Q_OBJECT
|
||||
SensorStore* sensors_;
|
||||
std::shared_ptr<PolynomalActor> actor_;
|
||||
|
||||
public:
|
||||
explicit PolynomalActorWidget(std::shared_ptr<PolynomalActor> regulator, SensorStore* sensors = nullptr, QWidget *parent = nullptr);
|
||||
~PolynomalActorWidget();
|
||||
explicit PolynomalActorWidget(std::shared_ptr<PolynomalActor> regulator, SensorStore* sensors = nullptr,
|
||||
QWidget *parent = nullptr);
|
||||
~PolynomalActorWidget();
|
||||
|
||||
private slots:
|
||||
|
||||
void setPow();
|
||||
void setSensor(const QModelIndex &index);
|
||||
void setPow();
|
||||
void setSensor(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
Ui::PolynomalActorWidget *ui;
|
||||
Ui::PolynomalActorWidget *ui;
|
||||
};
|
||||
|
||||
#endif // POLYNOMALACTORWIDGET_H
|
||||
|
@ -4,45 +4,45 @@
|
||||
|
||||
RegulatorWdiget::~RegulatorWdiget()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RegulatorWdiget::RegulatorWdiget(std::shared_ptr<Regulator> regulator, SensorStore* sensors, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
regulator_(regulator),
|
||||
sensors_(sensors),
|
||||
ui(new Ui::RegulatorWdiget)
|
||||
QWidget(parent),
|
||||
regulator_(regulator),
|
||||
sensors_(sensors),
|
||||
ui(new Ui::RegulatorWdiget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
if(sensors)ui->listView->sensorsChanged(*(sensors->getSensors()));
|
||||
else
|
||||
{
|
||||
ui->listView->hide();
|
||||
ui->label->hide();
|
||||
}
|
||||
ui->doubleSpinBox_setPoint->setValue(regulator->getSetPoint());
|
||||
ui->doubleSpinBox_band->setValue(regulator->getBand());
|
||||
ui->setupUi(this);
|
||||
if(sensors)ui->listView->sensorsChanged(*(sensors->getSensors()));
|
||||
else
|
||||
{
|
||||
ui->listView->hide();
|
||||
ui->label->hide();
|
||||
}
|
||||
ui->doubleSpinBox_setPoint->setValue(regulator->getSetPoint());
|
||||
ui->doubleSpinBox_band->setValue(regulator->getBand());
|
||||
|
||||
connect(ui->listView, &SensorListWidget::clicked, this, &RegulatorWdiget::setSensor);
|
||||
connect(ui->doubleSpinBox_setPoint, SIGNAL(valueChanged(double)), this, SLOT(setPoint(double)));
|
||||
connect(ui->doubleSpinBox_band, SIGNAL(valueChanged(double)), this, SLOT(setBand(double)));
|
||||
connect(ui->listView, &SensorListWidget::clicked, this, &RegulatorWdiget::setSensor);
|
||||
connect(ui->doubleSpinBox_setPoint, SIGNAL(valueChanged(double)), this, SLOT(setPoint(double)));
|
||||
connect(ui->doubleSpinBox_band, SIGNAL(valueChanged(double)), this, SLOT(setBand(double)));
|
||||
}
|
||||
|
||||
void RegulatorWdiget::setPoint(double in)
|
||||
{
|
||||
regulator_->setPoint(in);
|
||||
regulator_->setPoint(in);
|
||||
}
|
||||
|
||||
void RegulatorWdiget::setBand(double band)
|
||||
{
|
||||
regulator_->setBand(band);
|
||||
regulator_->setBand(band);
|
||||
}
|
||||
|
||||
void RegulatorWdiget::setSensor(const QModelIndex &index)
|
||||
{
|
||||
regulator_->setSensor(sensors_->getSensors()->at(index.row()));
|
||||
setPoint(sensors_->getSensors()->at(index.row()).field);
|
||||
ui->doubleSpinBox_setPoint->setValue(sensors_->getSensors()->at(index.row()).field);
|
||||
regulator_->setSensor(sensors_->getSensors()->at(index.row()));
|
||||
setPoint(sensors_->getSensors()->at(index.row()).field);
|
||||
ui->doubleSpinBox_setPoint->setValue(sensors_->getSensors()->at(index.row()).field);
|
||||
}
|
||||
|
@ -4,29 +4,31 @@
|
||||
#include <QWidget>
|
||||
#include "../../actors/regulator.h"
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class RegulatorWdiget;
|
||||
}
|
||||
|
||||
class RegulatorWdiget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
std::shared_ptr<Regulator> regulator_;
|
||||
SensorStore* sensors_;
|
||||
std::shared_ptr<Regulator> regulator_;
|
||||
SensorStore* sensors_;
|
||||
|
||||
public:
|
||||
explicit RegulatorWdiget(std::shared_ptr<Regulator> regulator, SensorStore* sensors = nullptr, QWidget *parent = nullptr);
|
||||
~RegulatorWdiget();
|
||||
explicit RegulatorWdiget(std::shared_ptr<Regulator> regulator, SensorStore* sensors = nullptr,
|
||||
QWidget *parent = nullptr);
|
||||
~RegulatorWdiget();
|
||||
|
||||
private slots:
|
||||
|
||||
void setPoint(double in);
|
||||
void setBand(double band);
|
||||
void setSensor(const QModelIndex &index);
|
||||
void setPoint(double in);
|
||||
void setBand(double band);
|
||||
void setSensor(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
Ui::RegulatorWdiget *ui;
|
||||
Ui::RegulatorWdiget *ui;
|
||||
};
|
||||
|
||||
#endif // REGULATORWDIGET_H
|
||||
|
@ -4,49 +4,49 @@
|
||||
#include <QDebug>
|
||||
|
||||
SensorActorWidget::SensorActorWidget(std::shared_ptr<SensorActor> sensorActor, SensorStore* sensors, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
sensorActor_(sensorActor),
|
||||
sensors_(sensors),
|
||||
ui(new Ui::SensorActorWidget)
|
||||
QWidget(parent),
|
||||
sensorActor_(sensorActor),
|
||||
sensors_(sensors),
|
||||
ui(new Ui::SensorActorWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
if(sensors)ui->listView->sensorsChanged(*(sensors->getSensors()));
|
||||
else
|
||||
{
|
||||
ui->listView->hide();
|
||||
ui->label->hide();
|
||||
}
|
||||
ui->setupUi(this);
|
||||
if(sensors)ui->listView->sensorsChanged(*(sensors->getSensors()));
|
||||
else
|
||||
{
|
||||
ui->listView->hide();
|
||||
ui->label->hide();
|
||||
}
|
||||
|
||||
if(sensorActor_->getSloap() == SensorActor::SLOPE_UP) ui->comboBox_slope->setCurrentIndex(0);
|
||||
else if(sensorActor_->getSloap() == SensorActor::SLOPE_DOWN) ui->comboBox_slope->setCurrentIndex(1);
|
||||
else if(sensorActor_->getSloap() == SensorActor::SLOPE_BOTH) ui->comboBox_slope->setCurrentIndex(2);
|
||||
if(sensorActor_->getSloap() == SensorActor::SLOPE_UP) ui->comboBox_slope->setCurrentIndex(0);
|
||||
else if(sensorActor_->getSloap() == SensorActor::SLOPE_DOWN) ui->comboBox_slope->setCurrentIndex(1);
|
||||
else if(sensorActor_->getSloap() == SensorActor::SLOPE_BOTH) ui->comboBox_slope->setCurrentIndex(2);
|
||||
|
||||
ui->doubleSpinBox_threshold->setValue(sensorActor_->getThreshold());
|
||||
ui->doubleSpinBox_threshold->setValue(sensorActor_->getThreshold());
|
||||
|
||||
connect(ui->listView, &SensorListWidget::clicked, this, &SensorActorWidget::setSensor);
|
||||
connect(ui->doubleSpinBox_threshold, SIGNAL(valueChanged(double)), this, SLOT(setThreshold(double)));
|
||||
connect(ui->comboBox_slope, SIGNAL(currentIndexChanged(int)), this, SLOT(setSlope(int)));
|
||||
connect(ui->listView, &SensorListWidget::clicked, this, &SensorActorWidget::setSensor);
|
||||
connect(ui->doubleSpinBox_threshold, SIGNAL(valueChanged(double)), this, SLOT(setThreshold(double)));
|
||||
connect(ui->comboBox_slope, SIGNAL(currentIndexChanged(int)), this, SLOT(setSlope(int)));
|
||||
}
|
||||
|
||||
SensorActorWidget::~SensorActorWidget()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void SensorActorWidget::setThreshold(double in)
|
||||
{
|
||||
sensorActor_->setThreshold(in);
|
||||
sensorActor_->setThreshold(in);
|
||||
}
|
||||
|
||||
void SensorActorWidget::setSlope(int index)
|
||||
{
|
||||
if(index == 0) sensorActor_->setSloap(SensorActor::SLOPE_UP);
|
||||
else if(index == 1) sensorActor_->setSloap(SensorActor::SLOPE_DOWN);
|
||||
else if(index == 2) sensorActor_->setSloap(SensorActor::SLOPE_BOTH);
|
||||
if(index == 0) sensorActor_->setSloap(SensorActor::SLOPE_UP);
|
||||
else if(index == 1) sensorActor_->setSloap(SensorActor::SLOPE_DOWN);
|
||||
else if(index == 2) sensorActor_->setSloap(SensorActor::SLOPE_BOTH);
|
||||
}
|
||||
|
||||
void SensorActorWidget::setSensor(const QModelIndex &index)
|
||||
{
|
||||
sensorActor_->setSensor(sensors_->getSensors()->at(index.row()));
|
||||
qDebug()<<"Selected "<<sensors_->getSensors()->at(index.row()).name;
|
||||
sensorActor_->setSensor(sensors_->getSensors()->at(index.row()));
|
||||
qDebug()<<"Selected "<<sensors_->getSensors()->at(index.row()).name;
|
||||
}
|
||||
|
@ -5,29 +5,31 @@
|
||||
#include <QItemSelection>
|
||||
#include "../../actors/sensoractor.h"
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class SensorActorWidget;
|
||||
}
|
||||
|
||||
class SensorActorWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
std::shared_ptr<SensorActor> sensorActor_;
|
||||
SensorStore* sensors_;
|
||||
std::shared_ptr<SensorActor> sensorActor_;
|
||||
SensorStore* sensors_;
|
||||
|
||||
public:
|
||||
explicit SensorActorWidget(std::shared_ptr<SensorActor> sensorActor, SensorStore* sensors = nullptr, QWidget *parent = nullptr);
|
||||
~SensorActorWidget();
|
||||
explicit SensorActorWidget(std::shared_ptr<SensorActor> sensorActor, SensorStore* sensors = nullptr,
|
||||
QWidget *parent = nullptr);
|
||||
~SensorActorWidget();
|
||||
|
||||
private slots:
|
||||
|
||||
void setThreshold(double in);
|
||||
void setSlope(int index);
|
||||
void setSensor(const QModelIndex &index);
|
||||
void setThreshold(double in);
|
||||
void setSlope(int index);
|
||||
void setSensor(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
Ui::SensorActorWidget *ui;
|
||||
Ui::SensorActorWidget *ui;
|
||||
};
|
||||
|
||||
#endif // SENSORACTORWIDGET_H
|
||||
|
@ -4,17 +4,17 @@
|
||||
#include <QSpinBox>
|
||||
|
||||
TimerActorWidget::TimerActorWidget(std::shared_ptr<TimerActor> actor, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::TimerActorWidget)
|
||||
QWidget(parent),
|
||||
ui(new Ui::TimerActorWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->spinBox->setValue(actor->getTimeout());
|
||||
ui->spinBox->setValue(actor->getTimeout());
|
||||
|
||||
connect(ui->spinBox, SIGNAL(valueChanged(int)), actor.get(), SLOT(setTimeout(int)));
|
||||
connect(ui->spinBox, SIGNAL(valueChanged(int)), actor.get(), SLOT(setTimeout(int)));
|
||||
}
|
||||
|
||||
TimerActorWidget::~TimerActorWidget()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
@ -4,20 +4,21 @@
|
||||
#include <QWidget>
|
||||
#include "../../actors/timeractor.h"
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class TimerActorWidget;
|
||||
}
|
||||
|
||||
class TimerActorWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TimerActorWidget(std::shared_ptr<TimerActor> actor, QWidget *parent = nullptr);
|
||||
~TimerActorWidget();
|
||||
explicit TimerActorWidget(std::shared_ptr<TimerActor> actor, QWidget *parent = nullptr);
|
||||
~TimerActorWidget();
|
||||
|
||||
private:
|
||||
Ui::TimerActorWidget *ui;
|
||||
Ui::TimerActorWidget *ui;
|
||||
};
|
||||
|
||||
#endif // TIMERACTORWIDGET_H
|
||||
|
@ -5,49 +5,49 @@
|
||||
#include "itemsettingswidgets/systemitemsettingswidget.h"
|
||||
|
||||
ItemCreationDialog::ItemCreationDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::ItemCreationDialog)
|
||||
QDialog(parent),
|
||||
ui(new Ui::ItemCreationDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
std::shared_ptr<MessageItem> messageItem(new MessageItem);
|
||||
item = messageItem;
|
||||
widget = new MessageItemSettingsWidget(messageItem, this);
|
||||
ui->verticalLayout->addWidget(widget);
|
||||
connect(ui->comboBox, &QComboBox::currentTextChanged, this, &ItemCreationDialog::itemTypeChanged);
|
||||
connect(ui->lineEdit, &QLineEdit::textChanged, this, &ItemCreationDialog::itemNameChanged);
|
||||
ui->setupUi(this);
|
||||
std::shared_ptr<MessageItem> messageItem(new MessageItem);
|
||||
item = messageItem;
|
||||
widget = new MessageItemSettingsWidget(messageItem, this);
|
||||
ui->verticalLayout->addWidget(widget);
|
||||
connect(ui->comboBox, &QComboBox::currentTextChanged, this, &ItemCreationDialog::itemTypeChanged);
|
||||
connect(ui->lineEdit, &QLineEdit::textChanged, this, &ItemCreationDialog::itemNameChanged);
|
||||
}
|
||||
|
||||
ItemCreationDialog::~ItemCreationDialog()
|
||||
{
|
||||
delete ui;
|
||||
delete widget;
|
||||
delete ui;
|
||||
delete widget;
|
||||
}
|
||||
|
||||
void ItemCreationDialog::itemTypeChanged(const QString& type)
|
||||
{
|
||||
ui->verticalLayout->removeWidget(widget);
|
||||
delete widget;
|
||||
if(type == "Message")
|
||||
{
|
||||
std::shared_ptr<MessageItem> messageItem(new MessageItem);
|
||||
item = messageItem;
|
||||
widget = new MessageItemSettingsWidget(messageItem, this);
|
||||
ui->verticalLayout->addWidget(widget);
|
||||
}
|
||||
if(type == "System")
|
||||
{
|
||||
std::shared_ptr<SystemItem> systemItem(new SystemItem);
|
||||
item = systemItem;
|
||||
widget = new SystemItemSettingsWidget(systemItem, this);
|
||||
ui->verticalLayout->addWidget(widget);
|
||||
}
|
||||
ui->verticalLayout->removeWidget(widget);
|
||||
delete widget;
|
||||
if(type == "Message")
|
||||
{
|
||||
std::shared_ptr<MessageItem> messageItem(new MessageItem);
|
||||
item = messageItem;
|
||||
widget = new MessageItemSettingsWidget(messageItem, this);
|
||||
ui->verticalLayout->addWidget(widget);
|
||||
}
|
||||
if(type == "System")
|
||||
{
|
||||
std::shared_ptr<SystemItem> systemItem(new SystemItem);
|
||||
item = systemItem;
|
||||
widget = new SystemItemSettingsWidget(systemItem, this);
|
||||
ui->verticalLayout->addWidget(widget);
|
||||
}
|
||||
}
|
||||
|
||||
void ItemCreationDialog::itemNameChanged(const QString& name)
|
||||
{
|
||||
if(item)
|
||||
{
|
||||
item->setName(name);
|
||||
}
|
||||
if(item)
|
||||
{
|
||||
item->setName(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,29 +5,30 @@
|
||||
#include <memory>
|
||||
#include "../items/item.h"
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class ItemCreationDialog;
|
||||
}
|
||||
|
||||
class ItemCreationDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
QWidget* widget;
|
||||
QWidget* widget;
|
||||
|
||||
public:
|
||||
explicit ItemCreationDialog(QWidget *parent = nullptr);
|
||||
~ItemCreationDialog();
|
||||
explicit ItemCreationDialog(QWidget *parent = nullptr);
|
||||
~ItemCreationDialog();
|
||||
|
||||
std::shared_ptr<Item> item;
|
||||
std::shared_ptr<Item> item;
|
||||
|
||||
private slots:
|
||||
|
||||
void itemTypeChanged(const QString& type);
|
||||
void itemNameChanged(const QString& name);
|
||||
void itemTypeChanged(const QString& type);
|
||||
void itemNameChanged(const QString& name);
|
||||
|
||||
private:
|
||||
Ui::ItemCreationDialog *ui;
|
||||
Ui::ItemCreationDialog *ui;
|
||||
};
|
||||
|
||||
#endif // ITEMCREATIONDIALOG_H
|
||||
|
@ -4,52 +4,52 @@
|
||||
#include "../items/messageitem.h"
|
||||
|
||||
ItemScrollBox::ItemScrollBox(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::RelayScrollBox)
|
||||
QWidget(parent),
|
||||
ui(new Ui::RelayScrollBox)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QScroller::grabGesture(ui->scrollArea, QScroller::TouchGesture);
|
||||
QScroller::grabGesture(ui->scrollArea, QScroller::LeftMouseButtonGesture);
|
||||
ui->setupUi(this);
|
||||
QScroller::grabGesture(ui->scrollArea, QScroller::TouchGesture);
|
||||
QScroller::grabGesture(ui->scrollArea, QScroller::LeftMouseButtonGesture);
|
||||
}
|
||||
|
||||
ItemScrollBox::~ItemScrollBox()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ItemScrollBox::addItem(std::weak_ptr<Item> item)
|
||||
{
|
||||
if(auto workItem = item.lock())
|
||||
{
|
||||
if(dynamic_cast<AuxItem*>(workItem.get()))
|
||||
{
|
||||
widgets_.push_back(new ItemWidget(item, true));
|
||||
}
|
||||
else if(dynamic_cast<MessageItem*>(workItem.get()))
|
||||
{
|
||||
widgets_.push_back(new ItemWidget(item, false, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
widgets_.push_back(new ItemWidget(item));
|
||||
}
|
||||
ui->relayWidgetVbox->addWidget(widgets_.back());
|
||||
connect(widgets_.back(), &ItemWidget::deleteRequest, this, &ItemScrollBox::deleteRequest);
|
||||
connect(widgets_.back(), &ItemWidget::deleteRequest, this, &ItemScrollBox::removeItem);
|
||||
}
|
||||
if(auto workItem = item.lock())
|
||||
{
|
||||
if(dynamic_cast<AuxItem*>(workItem.get()))
|
||||
{
|
||||
widgets_.push_back(new ItemWidget(item, true));
|
||||
}
|
||||
else if(dynamic_cast<MessageItem*>(workItem.get()))
|
||||
{
|
||||
widgets_.push_back(new ItemWidget(item, false, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
widgets_.push_back(new ItemWidget(item));
|
||||
}
|
||||
ui->relayWidgetVbox->addWidget(widgets_.back());
|
||||
connect(widgets_.back(), &ItemWidget::deleteRequest, this, &ItemScrollBox::deleteRequest);
|
||||
connect(widgets_.back(), &ItemWidget::deleteRequest, this, &ItemScrollBox::removeItem);
|
||||
}
|
||||
}
|
||||
|
||||
void ItemScrollBox::removeItem(const ItemData& item)
|
||||
{
|
||||
for(unsigned i = 0; i < widgets_.size(); i++)
|
||||
{
|
||||
if(widgets_[i]->controles(item))
|
||||
{
|
||||
ui->relayWidgetVbox->removeWidget(widgets_[i]);
|
||||
delete widgets_[i];
|
||||
widgets_.erase(widgets_.begin()+i);
|
||||
}
|
||||
}
|
||||
for(unsigned i = 0; i < widgets_.size(); i++)
|
||||
{
|
||||
if(widgets_[i]->controles(item))
|
||||
{
|
||||
ui->relayWidgetVbox->removeWidget(widgets_[i]);
|
||||
delete widgets_[i];
|
||||
widgets_.erase(widgets_.begin()+i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -11,33 +11,34 @@
|
||||
#include "../items/itemstore.h"
|
||||
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class RelayScrollBox;
|
||||
}
|
||||
|
||||
class ItemScrollBox : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
private:
|
||||
std::vector< ItemWidget* > widgets_;
|
||||
std::vector< ItemWidget* > widgets_;
|
||||
|
||||
signals:
|
||||
void deleteRequest(const ItemData& item);
|
||||
void deleteRequest(const ItemData& item);
|
||||
|
||||
|
||||
public:
|
||||
explicit ItemScrollBox(QWidget *parent = nullptr);
|
||||
~ItemScrollBox();
|
||||
explicit ItemScrollBox(QWidget *parent = nullptr);
|
||||
~ItemScrollBox();
|
||||
|
||||
void setItemStore(ItemStore* itemStore);
|
||||
void setItemStore(ItemStore* itemStore);
|
||||
|
||||
public slots:
|
||||
|
||||
void addItem(std::weak_ptr<Item> item);
|
||||
void removeItem(const ItemData& item);
|
||||
void addItem(std::weak_ptr<Item> item);
|
||||
void removeItem(const ItemData& item);
|
||||
|
||||
private:
|
||||
Ui::RelayScrollBox *ui;
|
||||
Ui::RelayScrollBox *ui;
|
||||
};
|
||||
|
||||
#endif // RELAYSCROLLBOX_H
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "itemsettingsdialog.h"
|
||||
#include "itemsettingsdialog.h"
|
||||
#include "ui_itemsettingsdialog.h"
|
||||
#include "actorsettingsdialog.h"
|
||||
#include "../actors/alarmtime.h"
|
||||
@ -14,174 +14,174 @@
|
||||
#include<memory>
|
||||
|
||||
ItemSettingsDialog::ItemSettingsDialog(std::shared_ptr<Item> item, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
item_(item),
|
||||
ui(new Ui::ItemSettingsDialog)
|
||||
QDialog(parent),
|
||||
item_(item),
|
||||
ui(new Ui::ItemSettingsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->setupUi(this);
|
||||
|
||||
setModal(false);
|
||||
setModal(false);
|
||||
|
||||
ui->label_name->setText(item_->getName());
|
||||
ui->checkBox_Override->setChecked(item_->getOverride());
|
||||
ui->label_name->setText(item_->getName());
|
||||
ui->checkBox_Override->setChecked(item_->getOverride());
|
||||
|
||||
|
||||
if(std::shared_ptr<Relay> relay = std::dynamic_pointer_cast<Relay>(item_))
|
||||
{
|
||||
itemSpecificWidget_ = new RelayItemSettingsWidget(relay);
|
||||
}
|
||||
else if(std::shared_ptr<MessageItem> msgItem = std::dynamic_pointer_cast<MessageItem>(item_))
|
||||
{
|
||||
itemSpecificWidget_ = new MessageItemSettingsWidget(msgItem);
|
||||
}
|
||||
else if(std::shared_ptr<SystemItem> sysItem = std::dynamic_pointer_cast<SystemItem>(item_))
|
||||
{
|
||||
itemSpecificWidget_ = new SystemItemSettingsWidget(sysItem);
|
||||
}
|
||||
if(std::shared_ptr<Relay> relay = std::dynamic_pointer_cast<Relay>(item_))
|
||||
{
|
||||
itemSpecificWidget_ = new RelayItemSettingsWidget(relay);
|
||||
}
|
||||
else if(std::shared_ptr<MessageItem> msgItem = std::dynamic_pointer_cast<MessageItem>(item_))
|
||||
{
|
||||
itemSpecificWidget_ = new MessageItemSettingsWidget(msgItem);
|
||||
}
|
||||
else if(std::shared_ptr<SystemItem> sysItem = std::dynamic_pointer_cast<SystemItem>(item_))
|
||||
{
|
||||
itemSpecificWidget_ = new SystemItemSettingsWidget(sysItem);
|
||||
}
|
||||
|
||||
if(itemSpecificWidget_)
|
||||
{
|
||||
ui->verticalLayout_2->addWidget(itemSpecificWidget_);
|
||||
}
|
||||
if(itemSpecificWidget_)
|
||||
{
|
||||
ui->verticalLayout_2->addWidget(itemSpecificWidget_);
|
||||
}
|
||||
|
||||
connect(ui->pushButton_add, &QPushButton::clicked, this, &ItemSettingsDialog::addActor);
|
||||
connect(ui->pushButton_remove, &QPushButton::clicked, this, &ItemSettingsDialog::removeActor);
|
||||
connect(ui->pushButton_edit, &QPushButton::clicked, this, &ItemSettingsDialog::editActor);
|
||||
connect(ui->checkBox_Override, &QPushButton::clicked, this, &ItemSettingsDialog::changeOverride);
|
||||
connect(ui->pushButton_add, &QPushButton::clicked, this, &ItemSettingsDialog::addActor);
|
||||
connect(ui->pushButton_remove, &QPushButton::clicked, this, &ItemSettingsDialog::removeActor);
|
||||
connect(ui->pushButton_edit, &QPushButton::clicked, this, &ItemSettingsDialog::editActor);
|
||||
connect(ui->checkBox_Override, &QPushButton::clicked, this, &ItemSettingsDialog::changeOverride);
|
||||
|
||||
|
||||
ui->tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem("Actor"));
|
||||
ui->tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem("Action"));
|
||||
ui->tableWidget->setHorizontalHeaderItem(2, new QTableWidgetItem("Enabled"));
|
||||
ui->tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
ui->tableWidget->horizontalHeader()->resizeSection(1, 60);
|
||||
ui->tableWidget->horizontalHeader()->resizeSection(2, 75);
|
||||
loadActorList();
|
||||
ui->tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem("Actor"));
|
||||
ui->tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem("Action"));
|
||||
ui->tableWidget->setHorizontalHeaderItem(2, new QTableWidgetItem("Enabled"));
|
||||
ui->tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
ui->tableWidget->horizontalHeader()->resizeSection(1, 60);
|
||||
ui->tableWidget->horizontalHeader()->resizeSection(2, 75);
|
||||
loadActorList();
|
||||
}
|
||||
|
||||
ItemSettingsDialog::~ItemSettingsDialog()
|
||||
{
|
||||
if(itemSpecificWidget_) delete itemSpecificWidget_;
|
||||
delete ui;
|
||||
if(itemSpecificWidget_) delete itemSpecificWidget_;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ItemSettingsDialog::changeOverride()
|
||||
{
|
||||
item_->setOverride(ui->checkBox_Override->isChecked());
|
||||
item_->setOverride(ui->checkBox_Override->isChecked());
|
||||
}
|
||||
|
||||
void ItemSettingsDialog::loadActorList()
|
||||
{
|
||||
//ui->listWidget->clear();
|
||||
ui->tableWidget->setRowCount(item_->getActors().size());
|
||||
//ui->listWidget->clear();
|
||||
ui->tableWidget->setRowCount(item_->getActors().size());
|
||||
|
||||
for(unsigned i = 0; i < item_->getActors().size(); i++)
|
||||
{
|
||||
ui->tableWidget->setItem(i, 0, new QTableWidgetItem(item_->getActors()[i]->getName()));
|
||||
ui->tableWidget->setItem(i, 1, new QTableWidgetItem(item_->getActors()[i]->actionName()));
|
||||
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(item_->getActors()[i]->isActive() ? "Y" : "N"));
|
||||
}
|
||||
for(unsigned i = 0; i < item_->getActors().size(); i++)
|
||||
{
|
||||
ui->tableWidget->setItem(i, 0, new QTableWidgetItem(item_->getActors()[i]->getName()));
|
||||
ui->tableWidget->setItem(i, 1, new QTableWidgetItem(item_->getActors()[i]->actionName()));
|
||||
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(item_->getActors()[i]->isActive() ? "Y" : "N"));
|
||||
}
|
||||
}
|
||||
|
||||
void ItemSettingsDialog::addActor()
|
||||
{
|
||||
ActorSettingsDialog* dialog = nullptr;
|
||||
std::shared_ptr<Actor> actor = nullptr;
|
||||
ActorSettingsDialog* dialog = nullptr;
|
||||
std::shared_ptr<Actor> actor = nullptr;
|
||||
|
||||
if(ui->comboBox->currentText() == "Alarm")
|
||||
{
|
||||
std::shared_ptr<AlarmTime> alarm = std::shared_ptr<AlarmTime>(new AlarmTime);
|
||||
actor = alarm;
|
||||
dialog = new ActorSettingsDialog(alarm, this);
|
||||
}
|
||||
else if(ui->comboBox->currentText() == "Sensor")
|
||||
{
|
||||
std::shared_ptr<SensorActor> sensorActor = std::shared_ptr<SensorActor>(new SensorActor);
|
||||
actor = sensorActor;
|
||||
dialog = new ActorSettingsDialog(sensorActor, this);
|
||||
}
|
||||
else if(ui->comboBox->currentText() == "Timer" )
|
||||
{
|
||||
std::shared_ptr<TimerActor> timerActor = std::shared_ptr<TimerActor>(new TimerActor);
|
||||
actor = timerActor;
|
||||
dialog = new ActorSettingsDialog(timerActor, this);
|
||||
}
|
||||
else if(ui->comboBox->currentText() == "Regulator")
|
||||
{
|
||||
std::shared_ptr<Regulator> regulator = std::shared_ptr<Regulator>(new Regulator);
|
||||
actor = regulator;
|
||||
dialog = new ActorSettingsDialog(regulator, this);
|
||||
}
|
||||
if(ui->comboBox->currentText() == "Alarm")
|
||||
{
|
||||
std::shared_ptr<AlarmTime> alarm = std::shared_ptr<AlarmTime>(new AlarmTime);
|
||||
actor = alarm;
|
||||
dialog = new ActorSettingsDialog(alarm, this);
|
||||
}
|
||||
else if(ui->comboBox->currentText() == "Sensor")
|
||||
{
|
||||
std::shared_ptr<SensorActor> sensorActor = std::shared_ptr<SensorActor>(new SensorActor);
|
||||
actor = sensorActor;
|
||||
dialog = new ActorSettingsDialog(sensorActor, this);
|
||||
}
|
||||
else if(ui->comboBox->currentText() == "Timer" )
|
||||
{
|
||||
std::shared_ptr<TimerActor> timerActor = std::shared_ptr<TimerActor>(new TimerActor);
|
||||
actor = timerActor;
|
||||
dialog = new ActorSettingsDialog(timerActor, this);
|
||||
}
|
||||
else if(ui->comboBox->currentText() == "Regulator")
|
||||
{
|
||||
std::shared_ptr<Regulator> regulator = std::shared_ptr<Regulator>(new Regulator);
|
||||
actor = regulator;
|
||||
dialog = new ActorSettingsDialog(regulator, this);
|
||||
}
|
||||
|
||||
else if(ui->comboBox->currentText() == "Polynomal")
|
||||
{
|
||||
std::shared_ptr<PolynomalActor> polynomalActor = std::shared_ptr<PolynomalActor>(new PolynomalActor);
|
||||
actor = polynomalActor;
|
||||
dialog = new ActorSettingsDialog(polynomalActor, this);
|
||||
}
|
||||
else if(ui->comboBox->currentText() == "Polynomal")
|
||||
{
|
||||
std::shared_ptr<PolynomalActor> polynomalActor = std::shared_ptr<PolynomalActor>(new PolynomalActor);
|
||||
actor = polynomalActor;
|
||||
dialog = new ActorSettingsDialog(polynomalActor, this);
|
||||
}
|
||||
|
||||
else if(ui->comboBox->currentText() == "Multi Factor")
|
||||
{
|
||||
std::shared_ptr<MultiFactorActor> polynomalActor = std::shared_ptr<MultiFactorActor>(new MultiFactorActor);
|
||||
actor = polynomalActor;
|
||||
dialog = new ActorSettingsDialog(polynomalActor, this);
|
||||
}
|
||||
else if(ui->comboBox->currentText() == "Multi Factor")
|
||||
{
|
||||
std::shared_ptr<MultiFactorActor> polynomalActor = std::shared_ptr<MultiFactorActor>(new MultiFactorActor);
|
||||
actor = polynomalActor;
|
||||
dialog = new ActorSettingsDialog(polynomalActor, this);
|
||||
}
|
||||
|
||||
|
||||
if(dialog != nullptr)
|
||||
{
|
||||
dialog->setParent(this);
|
||||
dialog->show();
|
||||
if(dialog->exec() == QDialog::Accepted)
|
||||
{
|
||||
item_->addActor(actor);
|
||||
loadActorList();
|
||||
}
|
||||
delete dialog;
|
||||
}
|
||||
if(dialog != nullptr)
|
||||
{
|
||||
dialog->setParent(this);
|
||||
dialog->show();
|
||||
if(dialog->exec() == QDialog::Accepted)
|
||||
{
|
||||
item_->addActor(actor);
|
||||
loadActorList();
|
||||
}
|
||||
delete dialog;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ItemSettingsDialog::removeActor()
|
||||
{
|
||||
if(item_->getActors().size() > ui->tableWidget->currentRow())
|
||||
{
|
||||
item_->removeActor(item_->getActors().at(ui->tableWidget->currentRow()));
|
||||
loadActorList();
|
||||
}
|
||||
if(item_->getActors().size() > ui->tableWidget->currentRow())
|
||||
{
|
||||
item_->removeActor(item_->getActors().at(ui->tableWidget->currentRow()));
|
||||
loadActorList();
|
||||
}
|
||||
}
|
||||
|
||||
void ItemSettingsDialog::editActor()
|
||||
{
|
||||
if(item_->getActors().size() > ui->tableWidget->currentRow())
|
||||
{
|
||||
std::shared_ptr<Actor> actor = item_->getActors()[ui->tableWidget->currentRow()];
|
||||
if(item_->getActors().size() > ui->tableWidget->currentRow())
|
||||
{
|
||||
std::shared_ptr<Actor> actor = item_->getActors()[ui->tableWidget->currentRow()];
|
||||
|
||||
std::shared_ptr<AlarmTime> alarmTime = std::dynamic_pointer_cast<AlarmTime>(actor);
|
||||
std::shared_ptr<Regulator> regulator = std::dynamic_pointer_cast<Regulator>(actor);
|
||||
std::shared_ptr<SensorActor> sensorActor = std::dynamic_pointer_cast<SensorActor>(actor);
|
||||
std::shared_ptr<TimerActor> timerActor = std::dynamic_pointer_cast<TimerActor>(actor);
|
||||
std::shared_ptr<PolynomalActor> polynomalActor = std::dynamic_pointer_cast<PolynomalActor>(actor);
|
||||
std::shared_ptr<MultiFactorActor> factorActor = std::dynamic_pointer_cast<MultiFactorActor>(actor);
|
||||
std::shared_ptr<AlarmTime> alarmTime = std::dynamic_pointer_cast<AlarmTime>(actor);
|
||||
std::shared_ptr<Regulator> regulator = std::dynamic_pointer_cast<Regulator>(actor);
|
||||
std::shared_ptr<SensorActor> sensorActor = std::dynamic_pointer_cast<SensorActor>(actor);
|
||||
std::shared_ptr<TimerActor> timerActor = std::dynamic_pointer_cast<TimerActor>(actor);
|
||||
std::shared_ptr<PolynomalActor> polynomalActor = std::dynamic_pointer_cast<PolynomalActor>(actor);
|
||||
std::shared_ptr<MultiFactorActor> factorActor = std::dynamic_pointer_cast<MultiFactorActor>(actor);
|
||||
|
||||
ActorSettingsDialog* dialog;
|
||||
ActorSettingsDialog* dialog;
|
||||
|
||||
if(alarmTime) dialog = new ActorSettingsDialog(alarmTime, this);
|
||||
else if(regulator) dialog = new ActorSettingsDialog(regulator, this);
|
||||
else if(sensorActor) dialog = new ActorSettingsDialog(sensorActor, this);
|
||||
else if(timerActor) dialog = new ActorSettingsDialog(timerActor, this);
|
||||
else if(polynomalActor) dialog = new ActorSettingsDialog(polynomalActor, this);
|
||||
else if(factorActor) dialog = new ActorSettingsDialog(factorActor, this);
|
||||
else dialog = new ActorSettingsDialog(actor, this);
|
||||
dialog->setParent(this);
|
||||
dialog->show();
|
||||
dialog->exec();
|
||||
if(alarmTime) dialog = new ActorSettingsDialog(alarmTime, this);
|
||||
else if(regulator) dialog = new ActorSettingsDialog(regulator, this);
|
||||
else if(sensorActor) dialog = new ActorSettingsDialog(sensorActor, this);
|
||||
else if(timerActor) dialog = new ActorSettingsDialog(timerActor, this);
|
||||
else if(polynomalActor) dialog = new ActorSettingsDialog(polynomalActor, this);
|
||||
else if(factorActor) dialog = new ActorSettingsDialog(factorActor, this);
|
||||
else dialog = new ActorSettingsDialog(actor, this);
|
||||
dialog->setParent(this);
|
||||
dialog->show();
|
||||
dialog->exec();
|
||||
|
||||
for(int i = 0; i < ui->tableWidget->rowCount() && i < item_->getActors().size(); ++i)
|
||||
{
|
||||
ui->tableWidget->item(i, 0)->setText(item_->getActors()[i]->getName());
|
||||
ui->tableWidget->item(i, 1)->setText(item_->getActors()[i]->actionName());
|
||||
ui->tableWidget->item(i, 2)->setText(item_->getActors()[i]->isActive() ? "Y" : "N");
|
||||
}
|
||||
}
|
||||
for(int i = 0; i < ui->tableWidget->rowCount() && i < item_->getActors().size(); ++i)
|
||||
{
|
||||
ui->tableWidget->item(i, 0)->setText(item_->getActors()[i]->getName());
|
||||
ui->tableWidget->item(i, 1)->setText(item_->getActors()[i]->actionName());
|
||||
ui->tableWidget->item(i, 2)->setText(item_->getActors()[i]->isActive() ? "Y" : "N");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,32 +6,33 @@
|
||||
#include <memory>
|
||||
#include "../items/relay.h"
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class ItemSettingsDialog;
|
||||
}
|
||||
|
||||
class ItemSettingsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
std::shared_ptr<Item> item_;
|
||||
QWidget* itemSpecificWidget_ = nullptr;
|
||||
Q_OBJECT
|
||||
std::shared_ptr<Item> item_;
|
||||
QWidget* itemSpecificWidget_ = nullptr;
|
||||
|
||||
private:
|
||||
void loadActorList();
|
||||
void loadActorList();
|
||||
|
||||
public:
|
||||
explicit ItemSettingsDialog(std::shared_ptr<Item> item, QWidget *parent = nullptr);
|
||||
~ItemSettingsDialog();
|
||||
explicit ItemSettingsDialog(std::shared_ptr<Item> item, QWidget *parent = nullptr);
|
||||
~ItemSettingsDialog();
|
||||
|
||||
private slots:
|
||||
|
||||
void removeActor();
|
||||
void addActor();
|
||||
void editActor();
|
||||
void changeOverride();
|
||||
void removeActor();
|
||||
void addActor();
|
||||
void editActor();
|
||||
void changeOverride();
|
||||
|
||||
private:
|
||||
Ui::ItemSettingsDialog *ui;
|
||||
Ui::ItemSettingsDialog *ui;
|
||||
};
|
||||
|
||||
#endif // RELAYSETTINGSDIALOG_H
|
||||
|
@ -5,41 +5,44 @@
|
||||
#include <QDebug>
|
||||
|
||||
MessageItemSettingsWidget::MessageItemSettingsWidget(std::weak_ptr<MessageItem> item, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
item_(item),
|
||||
ui(new Ui::MessageItemSettingsWidget)
|
||||
QWidget(parent),
|
||||
item_(item),
|
||||
ui(new Ui::MessageItemSettingsWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
qDebug()<<"test";
|
||||
if(auto workingItem = item_.lock())
|
||||
{
|
||||
ui->lineEdit->setText(workingItem->getMessage());
|
||||
ui->lineEdit_alert->setText(workingItem->getAlert());
|
||||
}
|
||||
ui->setupUi(this);
|
||||
qDebug()<<"test";
|
||||
if(auto workingItem = item_.lock())
|
||||
{
|
||||
ui->lineEdit->setText(workingItem->getMessage());
|
||||
ui->lineEdit_alert->setText(workingItem->getAlert());
|
||||
}
|
||||
|
||||
connect(ui->lineEdit, &QLineEdit::textChanged, this, &MessageItemSettingsWidget::setText);
|
||||
connect(ui->lineEdit_alert, &QLineEdit::textChanged, this, &MessageItemSettingsWidget::setAlert);
|
||||
connect(ui->pushButton, &QPushButton::pressed, [this](){ui->lineEdit_alert->setText(QFileDialog::getOpenFileName(this, "Choose File"));});
|
||||
connect(ui->lineEdit, &QLineEdit::textChanged, this, &MessageItemSettingsWidget::setText);
|
||||
connect(ui->lineEdit_alert, &QLineEdit::textChanged, this, &MessageItemSettingsWidget::setAlert);
|
||||
connect(ui->pushButton, &QPushButton::pressed, [this]()
|
||||
{
|
||||
ui->lineEdit_alert->setText(QFileDialog::getOpenFileName(this, "Choose File"));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void MessageItemSettingsWidget::setText(const QString& text)
|
||||
{
|
||||
if(auto workingItem = item_.lock())
|
||||
{
|
||||
workingItem->setMessage(text);
|
||||
}
|
||||
if(auto workingItem = item_.lock())
|
||||
{
|
||||
workingItem->setMessage(text);
|
||||
}
|
||||
}
|
||||
|
||||
void MessageItemSettingsWidget::setAlert(const QString &in)
|
||||
{
|
||||
if(auto workingItem = item_.lock())
|
||||
{
|
||||
workingItem->setAlert(in);
|
||||
}
|
||||
if(auto workingItem = item_.lock())
|
||||
{
|
||||
workingItem->setAlert(in);
|
||||
}
|
||||
}
|
||||
|
||||
MessageItemSettingsWidget::~MessageItemSettingsWidget()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
@ -5,26 +5,27 @@
|
||||
#include <memory>
|
||||
#include "../../items/messageitem.h"
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class MessageItemSettingsWidget;
|
||||
}
|
||||
|
||||
class MessageItemSettingsWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
std::weak_ptr<MessageItem> item_;
|
||||
Q_OBJECT
|
||||
std::weak_ptr<MessageItem> item_;
|
||||
|
||||
private slots:
|
||||
|
||||
void setText(const QString& text);
|
||||
void setAlert(const QString &in);
|
||||
void setText(const QString& text);
|
||||
void setAlert(const QString &in);
|
||||
|
||||
public:
|
||||
explicit MessageItemSettingsWidget(std::weak_ptr<MessageItem> item, QWidget *parent = nullptr);
|
||||
~MessageItemSettingsWidget();
|
||||
explicit MessageItemSettingsWidget(std::weak_ptr<MessageItem> item, QWidget *parent = nullptr);
|
||||
~MessageItemSettingsWidget();
|
||||
|
||||
private:
|
||||
Ui::MessageItemSettingsWidget *ui;
|
||||
Ui::MessageItemSettingsWidget *ui;
|
||||
};
|
||||
|
||||
#endif // MESSAGEITEMSETTINGSWIDGET_H
|
||||
|
@ -3,19 +3,19 @@
|
||||
|
||||
|
||||
RelayItemSettingsWidget::RelayItemSettingsWidget(std::weak_ptr<Relay> relay, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::RelayItemSettingsWidget)
|
||||
QWidget(parent),
|
||||
ui(new Ui::RelayItemSettingsWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
auto relayPtr = relay.lock();
|
||||
if(relayPtr)
|
||||
{
|
||||
ui->label_ID->setText(QString::number(relayPtr->getId()));
|
||||
ui->label_Addr->setText(QString::number(relayPtr->getAddress(),2));
|
||||
}
|
||||
ui->setupUi(this);
|
||||
auto relayPtr = relay.lock();
|
||||
if(relayPtr)
|
||||
{
|
||||
ui->label_ID->setText(QString::number(relayPtr->getId()));
|
||||
ui->label_Addr->setText(QString::number(relayPtr->getAddress(),2));
|
||||
}
|
||||
}
|
||||
|
||||
RelayItemSettingsWidget::~RelayItemSettingsWidget()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
@ -5,20 +5,21 @@
|
||||
#include <memory>
|
||||
#include "../../items/relay.h"
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class RelayItemSettingsWidget;
|
||||
}
|
||||
|
||||
class RelayItemSettingsWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RelayItemSettingsWidget(std::weak_ptr<Relay> relay, QWidget *parent = nullptr);
|
||||
~RelayItemSettingsWidget();
|
||||
explicit RelayItemSettingsWidget(std::weak_ptr<Relay> relay, QWidget *parent = nullptr);
|
||||
~RelayItemSettingsWidget();
|
||||
|
||||
private:
|
||||
Ui::RelayItemSettingsWidget *ui;
|
||||
Ui::RelayItemSettingsWidget *ui;
|
||||
};
|
||||
|
||||
#endif // RELAYITEMSETTINGSWIDGET_H
|
||||
|
@ -2,39 +2,39 @@
|
||||
#include "ui_systemitemsettingswidget.h"
|
||||
|
||||
SystemItemSettingsWidget::SystemItemSettingsWidget(std::weak_ptr<SystemItem> item, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
item_(item),
|
||||
ui(new Ui::SystemItemSettingsWidget)
|
||||
QWidget(parent),
|
||||
item_(item),
|
||||
ui(new Ui::SystemItemSettingsWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
if(auto itemPtr = item_.lock())
|
||||
{
|
||||
ui->lineEdit_on->setText(itemPtr->getOnCommand());
|
||||
ui->lineEdit_off->setText(itemPtr->getOffCommand());
|
||||
}
|
||||
else setDisabled(true);
|
||||
ui->setupUi(this);
|
||||
if(auto itemPtr = item_.lock())
|
||||
{
|
||||
ui->lineEdit_on->setText(itemPtr->getOnCommand());
|
||||
ui->lineEdit_off->setText(itemPtr->getOffCommand());
|
||||
}
|
||||
else setDisabled(true);
|
||||
|
||||
connect(ui->lineEdit_on, &QLineEdit::textChanged, this, &SystemItemSettingsWidget::setOn);
|
||||
connect(ui->lineEdit_off, &QLineEdit::textChanged, this, &SystemItemSettingsWidget::setOff);
|
||||
connect(ui->lineEdit_on, &QLineEdit::textChanged, this, &SystemItemSettingsWidget::setOn);
|
||||
connect(ui->lineEdit_off, &QLineEdit::textChanged, this, &SystemItemSettingsWidget::setOff);
|
||||
}
|
||||
|
||||
void SystemItemSettingsWidget::setOn(const QString& in)
|
||||
{
|
||||
if(auto itemPtr = item_.lock())
|
||||
{
|
||||
itemPtr->setOnCommand(in);
|
||||
}
|
||||
if(auto itemPtr = item_.lock())
|
||||
{
|
||||
itemPtr->setOnCommand(in);
|
||||
}
|
||||
}
|
||||
|
||||
void SystemItemSettingsWidget::setOff(const QString& in)
|
||||
{
|
||||
if(auto itemPtr = item_.lock())
|
||||
{
|
||||
itemPtr->setOffCommand(in);
|
||||
}
|
||||
if(auto itemPtr = item_.lock())
|
||||
{
|
||||
itemPtr->setOffCommand(in);
|
||||
}
|
||||
}
|
||||
|
||||
SystemItemSettingsWidget::~SystemItemSettingsWidget()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
@ -5,26 +5,27 @@
|
||||
#include <memory>
|
||||
#include "../../items/systemitem.h"
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class SystemItemSettingsWidget;
|
||||
}
|
||||
|
||||
class SystemItemSettingsWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
std::weak_ptr<SystemItem> item_;
|
||||
Q_OBJECT
|
||||
std::weak_ptr<SystemItem> item_;
|
||||
|
||||
private slots:
|
||||
|
||||
void setOn(const QString &in);
|
||||
void setOff(const QString &in);
|
||||
void setOn(const QString &in);
|
||||
void setOff(const QString &in);
|
||||
|
||||
public:
|
||||
explicit SystemItemSettingsWidget(std::weak_ptr<SystemItem> item, QWidget *parent = nullptr);
|
||||
~SystemItemSettingsWidget();
|
||||
explicit SystemItemSettingsWidget(std::weak_ptr<SystemItem> item, QWidget *parent = nullptr);
|
||||
~SystemItemSettingsWidget();
|
||||
|
||||
private:
|
||||
Ui::SystemItemSettingsWidget *ui;
|
||||
Ui::SystemItemSettingsWidget *ui;
|
||||
};
|
||||
|
||||
#endif // SYSTEMITEMSETTINGSWIDGET_H
|
||||
|
@ -6,105 +6,105 @@
|
||||
#include <QSlider>
|
||||
|
||||
ItemWidget::ItemWidget(std::weak_ptr<Item> item, bool analog, bool nameOnly, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
item_(item),
|
||||
ui(new Ui::ItemWidget)
|
||||
QWidget(parent),
|
||||
item_(item),
|
||||
ui(new Ui::ItemWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->setupUi(this);
|
||||
|
||||
if(analog)
|
||||
{
|
||||
ui->horizontalSpacer->changeSize(0,0);
|
||||
ui->checkBox->hide();
|
||||
}
|
||||
else if(nameOnly)
|
||||
{
|
||||
ui->checkBox->hide();
|
||||
ui->slider->hide();
|
||||
}
|
||||
else ui->slider->hide();
|
||||
if(analog)
|
||||
{
|
||||
ui->horizontalSpacer->changeSize(0,0);
|
||||
ui->checkBox->hide();
|
||||
}
|
||||
else if(nameOnly)
|
||||
{
|
||||
ui->checkBox->hide();
|
||||
ui->slider->hide();
|
||||
}
|
||||
else ui->slider->hide();
|
||||
|
||||
if(auto workingRelay = item_.lock())
|
||||
{
|
||||
ui->checkBox->setChecked(workingRelay->getValue());
|
||||
if(auto workingRelay = item_.lock())
|
||||
{
|
||||
ui->checkBox->setChecked(workingRelay->getValue());
|
||||
|
||||
ui->label->setText(workingRelay->getName());
|
||||
ui->label->setText(workingRelay->getName());
|
||||
|
||||
if(analog)connect(ui->slider, &QSlider::valueChanged, this, &ItemWidget::moveToValue);
|
||||
else connect(ui->checkBox, &QCheckBox::toggled, this, &ItemWidget::moveToState);
|
||||
connect(ui->pushButton, &QPushButton::clicked, this, &ItemWidget::showSettingsDialog);
|
||||
connect(workingRelay.get(), &Relay::valueChanged, this, &ItemWidget::stateChanged);
|
||||
connect(ui->pushButton_Remove, &QPushButton::clicked, this, &ItemWidget::deleteItem);
|
||||
if(analog)connect(ui->slider, &QSlider::valueChanged, this, &ItemWidget::moveToValue);
|
||||
else connect(ui->checkBox, &QCheckBox::toggled, this, &ItemWidget::moveToState);
|
||||
connect(ui->pushButton, &QPushButton::clicked, this, &ItemWidget::showSettingsDialog);
|
||||
connect(workingRelay.get(), &Relay::valueChanged, this, &ItemWidget::stateChanged);
|
||||
connect(ui->pushButton_Remove, &QPushButton::clicked, this, &ItemWidget::deleteItem);
|
||||
|
||||
}
|
||||
else disable();
|
||||
}
|
||||
else disable();
|
||||
}
|
||||
|
||||
void ItemWidget::deleteItem()
|
||||
{
|
||||
if(auto workingItem = item_.lock())
|
||||
{
|
||||
deleteRequest(*workingItem);
|
||||
}
|
||||
if(auto workingItem = item_.lock())
|
||||
{
|
||||
deleteRequest(*workingItem);
|
||||
}
|
||||
}
|
||||
|
||||
void ItemWidget::moveToValue(int value)
|
||||
{
|
||||
if(auto workingItem = item_.lock()) workingItem->setValue(value);
|
||||
else disable();
|
||||
if(auto workingItem = item_.lock()) workingItem->setValue(value);
|
||||
else disable();
|
||||
}
|
||||
|
||||
void ItemWidget::moveToState(bool state)
|
||||
{
|
||||
if(auto workingItem = item_.lock()) workingItem->setValue(state);
|
||||
else disable();
|
||||
if(auto workingItem = item_.lock()) workingItem->setValue(state);
|
||||
else disable();
|
||||
}
|
||||
|
||||
void ItemWidget::disable()
|
||||
{
|
||||
ui->checkBox->setEnabled(false);
|
||||
ui->label->setEnabled(false);
|
||||
ui->slider->setEnabled(false);
|
||||
ui->pushButton_Remove->setEnabled(false);
|
||||
ui->checkBox->setEnabled(false);
|
||||
ui->label->setEnabled(false);
|
||||
ui->slider->setEnabled(false);
|
||||
ui->pushButton_Remove->setEnabled(false);
|
||||
}
|
||||
|
||||
bool ItemWidget::controles(const ItemData& relay)
|
||||
{
|
||||
if(auto workingRelay = item_.lock())
|
||||
{
|
||||
if(relay == *workingRelay) return true;
|
||||
else return false;
|
||||
}
|
||||
return true;
|
||||
if(auto workingRelay = item_.lock())
|
||||
{
|
||||
if(relay == *workingRelay) return true;
|
||||
else return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ItemWidget::showSettingsDialog()
|
||||
{
|
||||
if(auto workingRelay = item_.lock())
|
||||
{
|
||||
ItemSettingsDialog dialog(workingRelay, this);
|
||||
dialog.exec();
|
||||
}
|
||||
else disable();
|
||||
if(auto workingRelay = item_.lock())
|
||||
{
|
||||
ItemSettingsDialog dialog(workingRelay, this);
|
||||
dialog.exec();
|
||||
}
|
||||
else disable();
|
||||
}
|
||||
|
||||
std::weak_ptr<Item> ItemWidget::getItem()
|
||||
{
|
||||
return item_;
|
||||
return item_;
|
||||
}
|
||||
|
||||
void ItemWidget::stateChanged(int state)
|
||||
{
|
||||
qDebug()<<"widget got state "<<state;
|
||||
ui->slider->blockSignals(true);
|
||||
ui->slider->setValue(state);
|
||||
ui->slider->blockSignals(false);
|
||||
ui->checkBox->blockSignals(true);
|
||||
ui->checkBox->setChecked(state);
|
||||
ui->checkBox->blockSignals(false);
|
||||
qDebug()<<"widget got state "<<state;
|
||||
ui->slider->blockSignals(true);
|
||||
ui->slider->setValue(state);
|
||||
ui->slider->blockSignals(false);
|
||||
ui->checkBox->blockSignals(true);
|
||||
ui->checkBox->setChecked(state);
|
||||
ui->checkBox->blockSignals(false);
|
||||
}
|
||||
|
||||
ItemWidget::~ItemWidget()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
@ -6,40 +6,41 @@
|
||||
#include "itemsettingsdialog.h"
|
||||
#include "../items/item.h"
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class ItemWidget;
|
||||
}
|
||||
|
||||
class ItemWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
private:
|
||||
std::weak_ptr<Item> item_;
|
||||
std::weak_ptr<Item> item_;
|
||||
|
||||
void disable();
|
||||
void disable();
|
||||
|
||||
signals:
|
||||
|
||||
void deleteRequest(const ItemData& item);
|
||||
void deleteRequest(const ItemData& item);
|
||||
|
||||
private slots:
|
||||
void showSettingsDialog();
|
||||
void moveToState(bool state);
|
||||
void moveToValue(int value);
|
||||
void deleteItem();
|
||||
void showSettingsDialog();
|
||||
void moveToState(bool state);
|
||||
void moveToValue(int value);
|
||||
void deleteItem();
|
||||
|
||||
public:
|
||||
explicit ItemWidget(std::weak_ptr<Item> item, bool analog = false, bool nameOnly = false, QWidget *parent = nullptr);
|
||||
std::weak_ptr<Item> getItem();
|
||||
bool controles(const ItemData& relay);
|
||||
~ItemWidget();
|
||||
explicit ItemWidget(std::weak_ptr<Item> item, bool analog = false, bool nameOnly = false, QWidget *parent = nullptr);
|
||||
std::weak_ptr<Item> getItem();
|
||||
bool controles(const ItemData& relay);
|
||||
~ItemWidget();
|
||||
|
||||
public slots:
|
||||
|
||||
void stateChanged(int state);
|
||||
void stateChanged(int state);
|
||||
|
||||
private:
|
||||
Ui::ItemWidget *ui;
|
||||
Ui::ItemWidget *ui;
|
||||
};
|
||||
|
||||
#endif // RELAYWIDGET_H
|
||||
|
@ -7,13 +7,13 @@
|
||||
#include <QMessageBox>
|
||||
|
||||
MainWindow::MainWindow(MainObject * const mainObject, QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow),
|
||||
colorChooser(this),
|
||||
_micro(&mainObject->micro),
|
||||
_powerItem(mainObject->powerItem)
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow),
|
||||
colorChooser(this),
|
||||
_micro(&mainObject->micro),
|
||||
_powerItem(mainObject->powerItem)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->setupUi(this);
|
||||
|
||||
if(!mainObject->master)
|
||||
{
|
||||
@ -25,47 +25,47 @@ MainWindow::MainWindow(MainObject * const mainObject, QWidget *parent) :
|
||||
connect(ui->pushButton_broadcast, &QPushButton::clicked, this, &MainWindow::saved);
|
||||
}
|
||||
|
||||
connect(ui->pushButton_power, SIGNAL(clicked()), this, SLOT(showPowerItemDialog()));
|
||||
connect(ui->pushButton_power, SIGNAL(clicked()), this, SLOT(showPowerItemDialog()));
|
||||
|
||||
//Relays
|
||||
if(mainObject->master)connect(ui->pushButton_refesh, &QPushButton::clicked, _micro, &Microcontroller::requestState);
|
||||
else
|
||||
{
|
||||
connect(ui->pushButton_refesh, &QPushButton::clicked, &mainObject->broadCast, &BroadCast::requestJson);
|
||||
connect(ui->pushButton_refesh, &QPushButton::clicked, &mainObject->broadCast, &BroadCast::requestSensors);
|
||||
}
|
||||
connect(&mainObject->items, &ItemStore::itemAdded, ui->relayList, &ItemScrollBox::addItem);
|
||||
connect(&mainObject->items, &ItemStore::itemDeleted, ui->relayList, &ItemScrollBox::removeItem);
|
||||
//Relays
|
||||
if(mainObject->master)connect(ui->pushButton_refesh, &QPushButton::clicked, _micro, &Microcontroller::requestState);
|
||||
else
|
||||
{
|
||||
connect(ui->pushButton_refesh, &QPushButton::clicked, &mainObject->broadCast, &BroadCast::requestJson);
|
||||
connect(ui->pushButton_refesh, &QPushButton::clicked, &mainObject->broadCast, &BroadCast::requestSensors);
|
||||
}
|
||||
connect(&mainObject->items, &ItemStore::itemAdded, ui->relayList, &ItemScrollBox::addItem);
|
||||
connect(&mainObject->items, &ItemStore::itemDeleted, ui->relayList, &ItemScrollBox::removeItem);
|
||||
|
||||
for(size_t i = 0; i < mainObject->items.getItems()->size(); ++i)
|
||||
{
|
||||
ui->relayList->addItem(mainObject->items.getItems()->at(i));
|
||||
}
|
||||
for(size_t i = 0; i < mainObject->items.getItems()->size(); ++i)
|
||||
{
|
||||
ui->relayList->addItem(mainObject->items.getItems()->at(i));
|
||||
}
|
||||
|
||||
//Sensors
|
||||
ui->sensorListView->setShowHidden(false);
|
||||
ui->sensorListView->sensorsChanged(*globalSensors.getSensors());
|
||||
connect(&globalSensors, &SensorStore::stateChenged, ui->sensorListView, &SensorListWidget::sensorsChanged);
|
||||
//Sensors
|
||||
ui->sensorListView->setShowHidden(false);
|
||||
ui->sensorListView->sensorsChanged(*globalSensors.getSensors());
|
||||
connect(&globalSensors, &SensorStore::stateChenged, ui->sensorListView, &SensorListWidget::sensorsChanged);
|
||||
|
||||
//RGB Leds
|
||||
//RGB Leds
|
||||
connect(&colorChooser, SIGNAL(colorSelected(QColor)), this, SLOT(slotChangedRgb(QColor)));
|
||||
connect(ui->button_quit, SIGNAL(clicked()), this, SLOT(close()));
|
||||
connect(ui->button_color, SIGNAL(clicked()), &colorChooser, SLOT(show()));
|
||||
connect(ui->button_quit, SIGNAL(clicked()), this, SLOT(close()));
|
||||
connect(ui->button_color, SIGNAL(clicked()), &colorChooser, SLOT(show()));
|
||||
|
||||
connect(ui->pushButton_addItem, &QPushButton::clicked, this, &MainWindow::showItemCreationDialog);
|
||||
connect(ui->relayList, &ItemScrollBox::deleteRequest, &mainObject->items, &ItemStore::removeItem);
|
||||
connect(ui->pushButton_addItem, &QPushButton::clicked, this, &MainWindow::showItemCreationDialog);
|
||||
connect(ui->relayList, &ItemScrollBox::deleteRequest, &mainObject->items, &ItemStore::removeItem);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::showPowerItemDialog()
|
||||
{
|
||||
ItemSettingsDialog diag(std::shared_ptr<Item>(_powerItem), this);
|
||||
diag.show();
|
||||
diag.exec();
|
||||
ItemSettingsDialog diag(std::shared_ptr<Item>(_powerItem), this);
|
||||
diag.show();
|
||||
diag.exec();
|
||||
}
|
||||
|
||||
void MainWindow::saved()
|
||||
@ -75,25 +75,25 @@ void MainWindow::saved()
|
||||
|
||||
void MainWindow::slotChangedRgb(const QColor color)
|
||||
{
|
||||
_micro->changeRgbColor(color);
|
||||
_micro->changeRgbColor(color);
|
||||
}
|
||||
|
||||
void MainWindow::showItemCreationDialog()
|
||||
{
|
||||
ItemCreationDialog diag(this);
|
||||
diag.show();
|
||||
if(diag.exec())
|
||||
{
|
||||
createdItem(diag.item);
|
||||
}
|
||||
ItemCreationDialog diag(this);
|
||||
diag.show();
|
||||
if(diag.exec())
|
||||
{
|
||||
createdItem(diag.item);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::changeHeaderLableText(QString string)
|
||||
{
|
||||
if(string.size() > 28)
|
||||
{
|
||||
string.remove(28, string.size()-(28));
|
||||
string.append("...");
|
||||
}
|
||||
ui->label_serialRecive->setText(string);
|
||||
if(string.size() > 28)
|
||||
{
|
||||
string.remove(28, string.size()-(28));
|
||||
string.append("...");
|
||||
}
|
||||
ui->label_serialRecive->setText(string);
|
||||
}
|
||||
|
@ -23,33 +23,33 @@ class MainWindow;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(MainObject * const mainObject, QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
explicit MainWindow(MainObject * const mainObject, QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
Ui::MainWindow *ui;
|
||||
|
||||
QColorDialog colorChooser;
|
||||
QColorDialog colorChooser;
|
||||
|
||||
Microcontroller *_micro;
|
||||
Microcontroller *_micro;
|
||||
|
||||
std::shared_ptr<PowerItem> _powerItem;
|
||||
std::shared_ptr<PowerItem> _powerItem;
|
||||
|
||||
signals:
|
||||
|
||||
void sigBrodcast();
|
||||
void sigBrodcast();
|
||||
void sigSave();
|
||||
void createdItem(std::shared_ptr<Item> item);
|
||||
void createdItem(std::shared_ptr<Item> item);
|
||||
|
||||
private slots:
|
||||
|
||||
//RGB
|
||||
void slotChangedRgb(const QColor color);
|
||||
void showPowerItemDialog();
|
||||
void showItemCreationDialog();
|
||||
//RGB
|
||||
void slotChangedRgb(const QColor color);
|
||||
void showPowerItemDialog();
|
||||
void showItemCreationDialog();
|
||||
void saved();
|
||||
|
||||
public slots:
|
||||
|
@ -4,69 +4,71 @@
|
||||
#include <QHeaderView>
|
||||
#include <QScroller>
|
||||
|
||||
SensorListWidget::SensorListWidget(const bool showHidden, QWidget *parent): QTableWidget(parent), showHidden_(showHidden)
|
||||
SensorListWidget::SensorListWidget(const bool showHidden, QWidget *parent): QTableWidget(parent),
|
||||
showHidden_(showHidden)
|
||||
{
|
||||
setColumnCount(2);
|
||||
setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
QScroller::grabGesture(this, QScroller::LeftMouseButtonGesture);
|
||||
setAutoScroll(true);
|
||||
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
setHorizontalHeaderItem(0, new QTableWidgetItem("Sensor"));
|
||||
setHorizontalHeaderItem(1, new QTableWidgetItem("Value"));
|
||||
setColumnCount(2);
|
||||
setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
QScroller::grabGesture(this, QScroller::LeftMouseButtonGesture);
|
||||
setAutoScroll(true);
|
||||
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
setHorizontalHeaderItem(0, new QTableWidgetItem("Sensor"));
|
||||
setHorizontalHeaderItem(1, new QTableWidgetItem("Value"));
|
||||
}
|
||||
|
||||
SensorListWidget::SensorListWidget(SensorStore& sensorStore, const bool showHidden, QWidget* parent): QTableWidget (parent), showHidden_(showHidden)
|
||||
SensorListWidget::SensorListWidget(SensorStore& sensorStore, const bool showHidden,
|
||||
QWidget* parent): QTableWidget (parent), showHidden_(showHidden)
|
||||
{
|
||||
sensorsChanged(*(sensorStore.getSensors()));
|
||||
sensorsChanged(*(sensorStore.getSensors()));
|
||||
}
|
||||
|
||||
void SensorListWidget::sensorsChanged(std::vector<Sensor> sensors)
|
||||
{
|
||||
clear();
|
||||
setHorizontalHeaderItem(0, new QTableWidgetItem("Sensor"));
|
||||
setHorizontalHeaderItem(1, new QTableWidgetItem("Value"));
|
||||
size_t nonHiddenCount = sensors.size();
|
||||
if(!showHidden_)
|
||||
{
|
||||
nonHiddenCount = 0;
|
||||
for(size_t i = 0; i < sensors.size(); ++i)
|
||||
{
|
||||
if(!sensors[i].hidden) nonHiddenCount++;
|
||||
}
|
||||
}
|
||||
size_t listLen = 0;
|
||||
for(size_t i = 0; i < sensors.size(); ++i) if(showHidden_ || !sensors[i].hidden) ++listLen;
|
||||
setRowCount(static_cast<int>(listLen));
|
||||
size_t row = 0;
|
||||
for(size_t i = 0; i < sensors.size(); ++i)
|
||||
{
|
||||
if(showHidden_ || !sensors[i].hidden)
|
||||
{
|
||||
QString itemString;
|
||||
itemString.append(QString::number(sensors[i].field));
|
||||
itemString.append(' ');
|
||||
clear();
|
||||
setHorizontalHeaderItem(0, new QTableWidgetItem("Sensor"));
|
||||
setHorizontalHeaderItem(1, new QTableWidgetItem("Value"));
|
||||
size_t nonHiddenCount = sensors.size();
|
||||
if(!showHidden_)
|
||||
{
|
||||
nonHiddenCount = 0;
|
||||
for(size_t i = 0; i < sensors.size(); ++i)
|
||||
{
|
||||
if(!sensors[i].hidden) nonHiddenCount++;
|
||||
}
|
||||
}
|
||||
size_t listLen = 0;
|
||||
for(size_t i = 0; i < sensors.size(); ++i) if(showHidden_ || !sensors[i].hidden) ++listLen;
|
||||
setRowCount(static_cast<int>(listLen));
|
||||
size_t row = 0;
|
||||
for(size_t i = 0; i < sensors.size(); ++i)
|
||||
{
|
||||
if(showHidden_ || !sensors[i].hidden)
|
||||
{
|
||||
QString itemString;
|
||||
itemString.append(QString::number(sensors[i].field));
|
||||
itemString.append(' ');
|
||||
|
||||
if(sensors[i].type == Sensor::TYPE_DOOR)
|
||||
{
|
||||
if(static_cast<bool>(sensors[i].field)) itemString.append("\"Open\"");
|
||||
else itemString.append("\"Closed\"");
|
||||
}
|
||||
else if(sensors[i].type == Sensor::TYPE_AUDIO_OUTPUT)
|
||||
{
|
||||
if(static_cast<bool>(sensors[i].field)) itemString.append("\"Playing\"");
|
||||
else itemString.append("\"Silent\"");
|
||||
}
|
||||
if(sensors[i].type == Sensor::TYPE_DOOR)
|
||||
{
|
||||
if(static_cast<bool>(sensors[i].field)) itemString.append("\"Open\"");
|
||||
else itemString.append("\"Closed\"");
|
||||
}
|
||||
else if(sensors[i].type == Sensor::TYPE_AUDIO_OUTPUT)
|
||||
{
|
||||
if(static_cast<bool>(sensors[i].field)) itemString.append("\"Playing\"");
|
||||
else itemString.append("\"Silent\"");
|
||||
}
|
||||
|
||||
setItem(static_cast<int>(row), 0, new QTableWidgetItem(sensors[i].name + (sensors[i].hidden ? "(H)" : "")));
|
||||
setItem(static_cast<int>(row), 1, new QTableWidgetItem(itemString));
|
||||
++row;
|
||||
}
|
||||
}
|
||||
setItem(static_cast<int>(row), 0, new QTableWidgetItem(sensors[i].name + (sensors[i].hidden ? "(H)" : "")));
|
||||
setItem(static_cast<int>(row), 1, new QTableWidgetItem(itemString));
|
||||
++row;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SensorListWidget::setShowHidden(const bool showHidden)
|
||||
{
|
||||
showHidden_=showHidden;
|
||||
showHidden_=showHidden;
|
||||
}
|
||||
|
||||
|
@ -5,19 +5,19 @@
|
||||
|
||||
class SensorListWidget : public QTableWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
bool showHidden_;
|
||||
bool showHidden_;
|
||||
|
||||
public:
|
||||
|
||||
SensorListWidget(const bool showHidden = true, QWidget *parent = nullptr);
|
||||
SensorListWidget(SensorStore& sensorStore, const bool showHidden = true, QWidget* parent = nullptr);
|
||||
virtual ~SensorListWidget(){}
|
||||
void setShowHidden(const bool showHidden);
|
||||
SensorListWidget(const bool showHidden = true, QWidget *parent = nullptr);
|
||||
SensorListWidget(SensorStore& sensorStore, const bool showHidden = true, QWidget* parent = nullptr);
|
||||
virtual ~SensorListWidget() {}
|
||||
void setShowHidden(const bool showHidden);
|
||||
|
||||
public slots:
|
||||
|
||||
void sensorsChanged(std::vector<Sensor> sensors);
|
||||
void sensorsChanged(std::vector<Sensor> sensors);
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user