src/DetailFermenter.cpp

changeset 317
f78827503fb0
child 318
ff02aca2b63c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/DetailFermenter.cpp	Wed Jun 29 22:19:39 2022 +0200
@@ -0,0 +1,101 @@
+/**
+ * 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);
+}

mercurial