Wed, 29 Jun 2022 22:19:39 +0200
Added DetailFermenter screen
/** * DetailFermenter.cpp is part of bmsapp. * * bmsapp is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * bmsapp is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "DetailFermenter.h" #include "../ui/ui_DetailFermenter.h" #include "MainWindow.h" DetailFermenter::DetailFermenter(int id, QWidget *parent) : QDialog(parent), ui(new Ui::DetailFermenter) { qDebug() << "DetailFermenter record:" << id; ui->setupUi(this); this->recno = id; WindowTitle(); // connect(ui->nameEdit, &QLineEdit::textChanged, this, &DetailFermenter::is_changed); // connect(ui->unlimitedEdit, &QCheckBox::stateChanged, this, &DetailFermenter::is_changed); // connect(ui->caEdit, &QDoubleSpinBox::textChanged, this, &DetailFermenter::water_changed); emit refreshTable(); } void DetailFermenter::refreshTable() { QSqlQuery query; qDebug() << "refreshTable fermenter" << this->recno; query.prepare("SELECT * FROM mon_fermenters WHERE record = :recno"); query.bindValue(":recno", this->recno); query.exec(); if (query.next()) { if (query.value("online").toInt()) { if (query.value("mode").toString() == "OFF") { ui->powerLED->setChecked(false); // disable dropdowns select beer. } else { ui->powerLED->setChecked(true); // enable beerslect } ui->alarmLED->setChecked((query.value("alarm").toInt() != 0) ? true:false); if (query.value("air_state").toString() == "OK") { ui->airThermo->setValue(query.value("air_temperature").toDouble()); } if (query.value("beer_state").toString() == "OK") { ui->beerThermo->setValue(query.value("beer_temperature").toDouble()); } } else { /* Offline */ ui->powerLED->setChecked(false); ui->alarmLED->setChecked(true); } } } DetailFermenter::~DetailFermenter() { qDebug() << "DetailFermenter done"; delete ui; emit entry_changed(); } /* * Window header, mark any change with '**' */ void DetailFermenter::WindowTitle() { QString txt; txt = QString(tr("BMSapp - Edit brewing water %1").arg(this->recno)); setWindowTitle(txt); } void DetailFermenter::on_quitButton_clicked() { this->close(); this->setResult(1); }