switched from qsettings to json added editng of actors

This commit is contained in:
Carl Klemm 2019-06-06 21:19:12 +02:00
parent b04fbfb5bc
commit df27b622a0
141 changed files with 4402 additions and 5068 deletions

View file

@ -0,0 +1,73 @@
#include "alarmwidget.h"
#include "ui_alarmwidget.h"
AlarmWidget::AlarmWidget(AlarmTime* alarm, QWidget *parent) :
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->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->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);
connect(ui->dateTimeEdit, &QDateTimeEdit::dateTimeChanged, alarm, &AlarmTime::changeTime);
}
AlarmWidget::~AlarmWidget()
{
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);
}
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);
}
}

View file

@ -0,0 +1,29 @@
#ifndef ALARMWIDGET_H
#define ALARMWIDGET_H
#include <QWidget>
#include "../../actors/alarmtime.h"
namespace Ui {
class AlarmWidget;
}
class AlarmWidget : public QWidget
{
Q_OBJECT
AlarmTime* alarm_;
public:
explicit AlarmWidget(AlarmTime* alarm, QWidget *parent = nullptr);
~AlarmWidget();
private slots:
void toggleRepeating(int state);
void setRepeatingType();
private:
Ui::AlarmWidget *ui;
};
#endif // ALARMWIDGET_H

View file

@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AlarmWidget</class>
<widget class="QWidget" name="AlarmWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>357</width>
<height>208</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="rowWrapPolicy">
<enum>QFormLayout::DontWrapRows</enum>
</property>
<property name="labelAlignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="formAlignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="horizontalSpacing">
<number>50</number>
</property>
<property name="verticalSpacing">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Time:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDateTimeEdit" name="dateTimeEdit">
<property name="locale">
<locale language="English" country="Germany"/>
</property>
<property name="showGroupSeparator" stdset="0">
<bool>false</bool>
</property>
<property name="currentSection">
<enum>QDateTimeEdit::DaySection</enum>
</property>
<property name="displayFormat">
<string>dd.MM.yyyy hh:mm</string>
</property>
<property name="calendarPopup">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Repeating:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QRadioButton" name="radioButton_2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Wee&amp;kly</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QRadioButton" name="radioButton_3">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Monthly</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QRadioButton" name="radioButton_4">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Yearly</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QRadioButton" name="radioButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Daily</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string> Enable</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -0,0 +1,48 @@
#include "regulatorwdiget.h"
#include "ui_regulatorwdiget.h"
#include <QDebug>
RegulatorWdiget::~RegulatorWdiget()
{
delete ui;
}
RegulatorWdiget::RegulatorWdiget(Regulator* regulator, SensorStore* sensors, QWidget *parent) :
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());
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);
}
void RegulatorWdiget::setBand(double 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);
}

View file

@ -0,0 +1,32 @@
#ifndef REGULATORWDIGET_H
#define REGULATORWDIGET_H
#include <QWidget>
#include "../../actors/regulator.h"
namespace Ui {
class RegulatorWdiget;
}
class RegulatorWdiget : public QWidget
{
Q_OBJECT
Regulator* regulator_;
SensorStore* sensors_;
public:
explicit RegulatorWdiget(Regulator* regulator, SensorStore* sensors = nullptr, QWidget *parent = nullptr);
~RegulatorWdiget();
private slots:
void setPoint(double in);
void setBand(double band);
void setSensor(const QModelIndex &index);
private:
Ui::RegulatorWdiget *ui;
};
#endif // REGULATORWDIGET_H

View file

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RegulatorWdiget</class>
<widget class="QWidget" name="RegulatorWdiget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>326</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Select Sensor</string>
</property>
</widget>
</item>
<item>
<widget class="SensorListWidget" name="listView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Set Point</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBox_setPoint">
<property name="minimum">
<double>-9999.989999999999782</double>
</property>
<property name="maximum">
<double>9999.989999999999782</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Band</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBox_band"/>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>SensorListWidget</class>
<extends>QListView</extends>
<header location="global">../src/ui/sensorlistwidget.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View file

@ -0,0 +1,52 @@
#include "sensoractorwidget.h"
#include "ui_sensoractorwidget.h"
#include <QDebug>
SensorActorWidget::SensorActorWidget(SensorActor* sensorActor, SensorStore* sensors, QWidget *parent) :
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();
}
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());
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;
}
void SensorActorWidget::setThreshold(double 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);
}
void SensorActorWidget::setSensor(const QModelIndex &index)
{
sensorActor_->setSensor(sensors_->getSensors()->at(index.row()));
qDebug()<<"Selected "<<sensors_->getSensors()->at(index.row()).name;
}

View file

@ -0,0 +1,33 @@
#ifndef SENSORACTORWIDGET_H
#define SENSORACTORWIDGET_H
#include <QWidget>
#include <QItemSelection>
#include "../../actors/sensoractor.h"
namespace Ui {
class SensorActorWidget;
}
class SensorActorWidget : public QWidget
{
Q_OBJECT
SensorActor* sensorActor_;
SensorStore* sensors_;
public:
explicit SensorActorWidget(SensorActor* sensorActor, SensorStore* sensors = nullptr, QWidget *parent = nullptr);
~SensorActorWidget();
private slots:
void setThreshold(double in);
void setSlope(int index);
void setSensor(const QModelIndex &index);
private:
Ui::SensorActorWidget *ui;
};
#endif // SENSORACTORWIDGET_H

View file

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SensorActorWidget</class>
<widget class="QWidget" name="SensorActorWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>326</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Select Sensor</string>
</property>
</widget>
</item>
<item>
<widget class="SensorListWidget" name="listView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Threshold</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_slope">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>&gt; =</string>
</property>
</item>
<item>
<property name="text">
<string>&lt; =</string>
</property>
</item>
<item>
<property name="text">
<string>Passes</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBox_threshold">
<property name="minimum">
<double>-9999.989999999999782</double>
</property>
<property name="maximum">
<double>9999.989999999999782</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>SensorListWidget</class>
<extends>QListView</extends>
<header location="global">../src/ui/sensorlistwidget.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View file

@ -0,0 +1,20 @@
#include "timeractorwidget.h"
#include "ui_timeractorwidget.h"
#include <QSpinBox>
TimerActorWidget::TimerActorWidget(TimerActor* actor, QWidget *parent) :
QWidget(parent),
ui(new Ui::TimerActorWidget)
{
ui->setupUi(this);
ui->spinBox->setValue(actor->getTimeout());
connect(ui->spinBox, SIGNAL(valueChanged(int)), actor, SLOT(setTimeout(int)));
}
TimerActorWidget::~TimerActorWidget()
{
delete ui;
}

View file

@ -0,0 +1,23 @@
#ifndef TIMERACTORWIDGET_H
#define TIMERACTORWIDGET_H
#include <QWidget>
#include "../../actors/timeractor.h"
namespace Ui {
class TimerActorWidget;
}
class TimerActorWidget : public QWidget
{
Q_OBJECT
public:
explicit TimerActorWidget(TimerActor* actor, QWidget *parent = nullptr);
~TimerActorWidget();
private:
Ui::TimerActorWidget *ui;
};
#endif // TIMERACTORWIDGET_H

View file

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TimerActorWidget</class>
<widget class="QWidget" name="TimerActorWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>50</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Timeout</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox">
<property name="maximum">
<number>999999</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Seconds</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>