Wed, 29 Jun 2022 22:19:39 +0200
Added DetailFermenter screen
317 | 1 | /** |
2 | * DetailFermenter.cpp is part of bmsapp. | |
3 | * | |
4 | * bmsapp is free software: you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation, either version 3 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * bmsapp is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | */ | |
17 | #include "DetailFermenter.h" | |
18 | #include "../ui/ui_DetailFermenter.h" | |
19 | #include "MainWindow.h" | |
20 | ||
21 | ||
22 | DetailFermenter::DetailFermenter(int id, QWidget *parent) : QDialog(parent), ui(new Ui::DetailFermenter) | |
23 | { | |
24 | qDebug() << "DetailFermenter record:" << id; | |
25 | ui->setupUi(this); | |
26 | this->recno = id; | |
27 | ||
28 | WindowTitle(); | |
29 | ||
30 | // connect(ui->nameEdit, &QLineEdit::textChanged, this, &DetailFermenter::is_changed); | |
31 | // connect(ui->unlimitedEdit, &QCheckBox::stateChanged, this, &DetailFermenter::is_changed); | |
32 | // connect(ui->caEdit, &QDoubleSpinBox::textChanged, this, &DetailFermenter::water_changed); | |
33 | ||
34 | emit refreshTable(); | |
35 | } | |
36 | ||
37 | ||
38 | void DetailFermenter::refreshTable() | |
39 | { | |
40 | QSqlQuery query; | |
41 | ||
42 | qDebug() << "refreshTable fermenter" << this->recno; | |
43 | ||
44 | query.prepare("SELECT * FROM mon_fermenters WHERE record = :recno"); | |
45 | query.bindValue(":recno", this->recno); | |
46 | query.exec(); | |
47 | if (query.next()) { | |
48 | ||
49 | if (query.value("online").toInt()) { | |
50 | if (query.value("mode").toString() == "OFF") { | |
51 | ui->powerLED->setChecked(false); | |
52 | // disable dropdowns select beer. | |
53 | } else { | |
54 | ui->powerLED->setChecked(true); | |
55 | // enable beerslect | |
56 | } | |
57 | ui->alarmLED->setChecked((query.value("alarm").toInt() != 0) ? true:false); | |
58 | ||
59 | if (query.value("air_state").toString() == "OK") { | |
60 | ui->airThermo->setValue(query.value("air_temperature").toDouble()); | |
61 | } | |
62 | if (query.value("beer_state").toString() == "OK") { | |
63 | ui->beerThermo->setValue(query.value("beer_temperature").toDouble()); | |
64 | } | |
65 | ||
66 | } else { | |
67 | /* Offline */ | |
68 | ui->powerLED->setChecked(false); | |
69 | ui->alarmLED->setChecked(true); | |
70 | ||
71 | } | |
72 | } | |
73 | ||
74 | } | |
75 | ||
76 | ||
77 | DetailFermenter::~DetailFermenter() | |
78 | { | |
79 | qDebug() << "DetailFermenter done"; | |
80 | delete ui; | |
81 | emit entry_changed(); | |
82 | } | |
83 | ||
84 | ||
85 | /* | |
86 | * Window header, mark any change with '**' | |
87 | */ | |
88 | void DetailFermenter::WindowTitle() | |
89 | { | |
90 | QString txt; | |
91 | ||
92 | txt = QString(tr("BMSapp - Edit brewing water %1").arg(this->recno)); | |
93 | setWindowTitle(txt); | |
94 | } | |
95 | ||
96 | ||
97 | void DetailFermenter::on_quitButton_clicked() | |
98 | { | |
99 | this->close(); | |
100 | this->setResult(1); | |
101 | } |