Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.

Sat, 16 Jul 2022 15:06:40 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 16 Jul 2022 15:06:40 +0200
changeset 353
324a7268796b
parent 352
fcf222cabb98
child 354
d543a3a78071

Updated watersources editors to include water hardness and residual alkalinity. Layout changes. Only total_alkalinity edit, bicarbonate is now only calculated.

src/EditProfileWater.cpp file | annotate | diff | comparison | revisions
src/EditProfileWater.h file | annotate | diff | comparison | revisions
src/EditWater.cpp file | annotate | diff | comparison | revisions
src/EditWater.h file | annotate | diff | comparison | revisions
ui/EditProfileWater.ui file | annotate | diff | comparison | revisions
ui/EditWater.ui file | annotate | diff | comparison | revisions
--- a/src/EditProfileWater.cpp	Tue Jul 12 16:01:49 2022 +0200
+++ b/src/EditProfileWater.cpp	Sat Jul 16 15:06:40 2022 +0200
@@ -16,6 +16,8 @@
  */
 #include "EditProfileWater.h"
 #include "../ui/ui_EditProfileWater.h"
+#include "global.h"
+#include "Utils.h"
 #include "MainWindow.h"
 
 
@@ -35,34 +37,43 @@
 	query.exec();
 	query.next();
 
-	ui->nameEdit->setText(query.value(1).toString());
-        ui->caEdit->setValue(query.value(2).toDouble());
-	ui->hcoEdit->setValue(query.value(3).toDouble());
-	ui->so4Edit->setValue(query.value(4).toDouble());
-	ui->clEdit->setValue(query.value(5).toDouble());
-	ui->naEdit->setValue(query.value(6).toDouble());
-	ui->mgEdit->setValue(query.value(7).toDouble());
-	ui->phEdit->setValue(query.value(8).toDouble());
-	ui->notesEdit->setPlainText(query.value(9).toString());
-	ui->alkalinityEdit->setValue(query.value(10).toDouble());
+	ui->nameEdit->setText(query.value("name").toString());
+	calcium = query.value("calcium").toDouble();
+	ui->caEdit->setValue(query.value("calcium").toDouble());
+	bicarbonate = query.value("bicarbonate").toDouble();
+	ui->hcoEdit->setValue(query.value("bicarbonate").toDouble());
+	sulfate = query.value("sulfate").toDouble();
+	ui->so4Edit->setValue(query.value("sulfate").toDouble());
+	chloride = query.value("chloride").toDouble();
+	ui->clEdit->setValue(query.value("chloride").toDouble());
+	sodium = query.value("sodium").toDouble();
+	ui->naEdit->setValue(query.value("sodium").toDouble());
+	magnesium = query.value("magnesium").toDouble();
+	ui->mgEdit->setValue(query.value("magnesium").toDouble());
+	ph = query.value("ph").toDouble();
+	ui->phEdit->setValue(query.value("ph").toDouble());
+	ui->notesEdit->setPlainText(query.value("notes").toString());
+	total_alkalinity = query.value("total_alkalinity").toDouble();
+	ui->alkalinityEdit->setValue(query.value("total_alkalinity").toDouble());
     } else {
 	/* Set some defaults */
+	calcium = bicarbonate =  sulfate = chloride = 0;
+	sodium = magnesium = total_alkalinity = 0;
+	ph = 7.0;
 	ui->phEdit->setValue(7.0);
     }
+    ui->saveButton->setEnabled(false);
+    ui->deleteButton->setEnabled((id >= 0) ? true:false);
     WaterSet();
     connect(ui->nameEdit, &QLineEdit::textChanged, this, &EditProfileWater::is_changed);
-    connect(ui->caEdit, &QDoubleSpinBox::textChanged, this, &EditProfileWater::water_changed);
-    connect(ui->hcoEdit, &QDoubleSpinBox::textChanged, this, &EditProfileWater::hco_changed);
-    connect(ui->so4Edit, &QDoubleSpinBox::textChanged, this, &EditProfileWater::water_changed);
-    connect(ui->clEdit, &QDoubleSpinBox::textChanged, this, &EditProfileWater::water_changed);
-    connect(ui->naEdit, &QDoubleSpinBox::textChanged, this, &EditProfileWater::water_changed);
-    connect(ui->mgEdit, &QDoubleSpinBox::textChanged, this, &EditProfileWater::water_changed);
-    connect(ui->phEdit, &QDoubleSpinBox::textChanged, this, &EditProfileWater::water_changed);
-    connect(ui->alkalinityEdit, &QDoubleSpinBox::textChanged, this, &EditProfileWater::alkalinity_changed);
+    connect(ui->caEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProfileWater::calcium_changed);
+    connect(ui->so4Edit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProfileWater::sulfate_changed);
+    connect(ui->clEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProfileWater::chloride_changed);
+    connect(ui->naEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProfileWater::sodium_changed);
+    connect(ui->mgEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProfileWater::magnesium_changed);
+    connect(ui->phEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProfileWater::ph_changed);
+    connect(ui->alkalinityEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProfileWater::total_alkalinity_changed);
     connect(ui->notesEdit, SIGNAL(textChanged()), this, SLOT(is_changed()));
-
-    ui->saveButton->setEnabled(false);
-    ui->deleteButton->setEnabled((id >= 0) ? true:false);
 }
 
 
@@ -81,10 +92,10 @@
 {
     QString txt;
 
-    if (this->recno < 0) {
+    if (recno < 0) {
 	txt = QString(tr("BMSapp - Add new brewing water"));
     } else {
-	txt = QString(tr("BMSapp - Edit brewing water %1").arg(this->recno));
+	txt = QString(tr("BMSapp - Edit brewing water %1").arg(recno));
     }
 
     if (this->textIsChanged) {
@@ -105,7 +116,7 @@
     }
 
     if (this->textIsChanged) {
-    	if (this->recno == -1) {
+    	if (recno == -1) {
     	    query.prepare("INSERT INTO profile_water SET name=:name, calcium=:ca, "
 		"bicarbonate=:hco, sulfate=:so4, chloride=:cl, sodium=:na, magnesium=:mg, ph=:ph, notes=:notes, "
 		"total_alkalinity=:alkalinity, uuid = :uuid");
@@ -115,16 +126,16 @@
                 "total_alkalinity=:alkalinity WHERE record = :recno");
     	}
 	query.bindValue(":name", ui->nameEdit->text());
-	query.bindValue(":ca", QString("%1").arg(ui->caEdit->value(), 2, 'f', 1, '0'));
-	query.bindValue(":hco", QString("%1").arg(ui->hcoEdit->value(), 2, 'f', 1, '0'));
-	query.bindValue(":so4", QString("%1").arg(ui->so4Edit->value(), 2, 'f', 1, '0'));
-	query.bindValue(":cl", QString("%1").arg(ui->clEdit->value(), 2, 'f', 1, '0'));
-	query.bindValue(":na", QString("%1").arg(ui->naEdit->value(), 2, 'f', 1, '0'));
-	query.bindValue(":mg", QString("%1").arg(ui->mgEdit->value(), 2, 'f', 1, '0'));
-	query.bindValue(":ph", QString("%1").arg(ui->phEdit->value(), 3, 'f', 2, '0'));
+	query.bindValue(":ca", round(calcium * 1000) / 1000);
+	query.bindValue(":hco", round(bicarbonate * 1000) / 1000);
+	query.bindValue(":so4", round(sulfate * 1000) / 1000);
+	query.bindValue(":cl", round(chloride * 1000) / 1000);
+	query.bindValue(":na", round(sodium * 1000) / 1000);
+	query.bindValue(":mg", round(magnesium * 1000) / 1000);
+	query.bindValue(":ph", round(ph * 1000) / 1000);
 	query.bindValue(":notes", ui->notesEdit->toPlainText());
-	query.bindValue(":alkalinity", QString("%1").arg(ui->alkalinityEdit->value(), 2, 'f', 1, '0'));
-	if (this->recno == -1) {
+	query.bindValue(":alkalinity", round(total_alkalinity * 1000) / 1000);
+	if (recno == -1) {
 	    query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36));
 	} else {
 	    query.bindValue(":recno", this->recno);
@@ -173,12 +184,21 @@
 
 void EditProfileWater::WaterSet()
 {
-    double cations, anions, balance;
+    double CO3 = total_alkalinity * pow(10, ph - 10.33) / (1+2* pow(10, ph - 10.33)) * MMCO3 / (MMCaCO3 / 2);
+    double t_bicarbonate = Utils::Bicarbonate(total_alkalinity, ph);
+    qDebug() << t_bicarbonate << bicarbonate;
+    if ((round(t_bicarbonate * 1000) / 1000) != bicarbonate)
+	is_changed();
+    bicarbonate = t_bicarbonate;
+    ui->hcoEdit->setValue(bicarbonate);
 
-    cations = (ui->caEdit->value() / 20.039) + (ui->mgEdit->value() / 12.1525) + (ui->naEdit->value() / 22.989);
-    anions = (ui->hcoEdit->value() / 61.016) + (ui->so4Edit->value() / 48.031) + (ui->clEdit->value() / 35.4527);
-    balance = round((cations - anions) * 100) / 100;
+    double cations = (2*calcium / MMCa) + (2*magnesium / MMMg) + (sodium / MMNa);
+    double anions = (bicarbonate / MMHCO3) + (2*CO3 / MMCO3) + (2*sulfate / MMSO4) + (chloride / MMCl);
+    double balance = round((cations - anions) * 100) / 100;
     ui->balanceEdit->setValue(balance);
+    ui->co3Edit->setValue(CO3);
+    ui->hardnessEdit->setValue(Utils::Hardness(calcium, magnesium));
+    ui->raEdit->setValue(Utils::ResidualAlkalinity(total_alkalinity, calcium, magnesium));
 
     if (balance <= 0.1 && balance >= -0.1) {
 	ui->balanceIcon->setPixmap(QPixmap(":icons/silk/tick.png"));
@@ -206,16 +226,51 @@
 }
 
 
-void EditProfileWater::hco_changed()
+void EditProfileWater::calcium_changed(double val)
+{
+    calcium = val;
+    water_changed();
+}
+
+
+void EditProfileWater::total_alkalinity_changed(double val)
 {
-    ui->alkalinityEdit->setValue(ui->hcoEdit->value() * 50 / 61);
+    total_alkalinity = val;
+    water_changed();
+}
+
+
+void EditProfileWater::sulfate_changed(double val)
+{
+    sulfate = val;
     water_changed();
 }
 
 
-void EditProfileWater::alkalinity_changed()
+void EditProfileWater::chloride_changed(double val)
+{
+    chloride = val;
+    water_changed();
+}
+
+
+void EditProfileWater::sodium_changed(double val)
 {
-    ui->hcoEdit->setValue(ui->alkalinityEdit->value() * 1.22);
+    sodium = val;
+    water_changed();
+}
+
+
+void EditProfileWater::magnesium_changed(double val)
+{
+    magnesium = val;
+    water_changed();
+}
+
+
+void EditProfileWater::ph_changed(double val)
+{
+    ph = val;
     water_changed();
 }
 
--- a/src/EditProfileWater.h	Tue Jul 12 16:01:49 2022 +0200
+++ b/src/EditProfileWater.h	Sat Jul 16 15:06:40 2022 +0200
@@ -25,13 +25,19 @@
     void on_deleteButton_clicked();
     void is_changed();
     void water_changed();
-    void hco_changed();
-    void alkalinity_changed();
+    void calcium_changed(double val);
+    void total_alkalinity_changed(double val);
+    void sulfate_changed(double val);
+    void chloride_changed(double val);
+    void sodium_changed(double val);
+    void magnesium_changed(double val);
+    void ph_changed(double val);
 
 private:
     Ui::EditProfileWater *ui;
     int recno;
     bool textIsChanged = false;
+    double calcium, bicarbonate, sulfate, chloride, sodium, magnesium, ph, total_alkalinity;
 
     void WindowTitle();
     void WaterSet();
--- a/src/EditWater.cpp	Tue Jul 12 16:01:49 2022 +0200
+++ b/src/EditWater.cpp	Sat Jul 16 15:06:40 2022 +0200
@@ -16,6 +16,8 @@
  */
 #include "EditWater.h"
 #include "../ui/ui_EditWater.h"
+#include "global.h"
+#include "Utils.h"
 #include "MainWindow.h"
 
 
@@ -35,42 +37,52 @@
 	query.exec();
 	query.next();
 
-	ui->nameEdit->setText(query.value(1).toString());
-	ui->unlimitedEdit->setChecked(query.value(2).toInt() ? true:false);
-        ui->caEdit->setValue(query.value(3).toDouble());
-	ui->hcoEdit->setValue(query.value(4).toDouble());
-	ui->so4Edit->setValue(query.value(5).toDouble());
-	ui->clEdit->setValue(query.value(6).toDouble());
-	ui->naEdit->setValue(query.value(7).toDouble());
-	ui->mgEdit->setValue(query.value(8).toDouble());
-	ui->phEdit->setValue(query.value(9).toDouble());
-	ui->notesEdit->setPlainText(query.value(10).toString());
-	ui->alkalinityEdit->setValue(query.value(11).toDouble());
-	ui->inventoryEdit->setValue(query.value(12).toDouble());
-	ui->costEdit->setValue(query.value(13).toDouble());
-	ui->noEdit->setValue(query.value(15).toDouble());
+	ui->nameEdit->setText(query.value("name").toString());
+	ui->unlimitedEdit->setChecked(query.value("unlimited_stock").toInt() ? true:false);
+	calcium = query.value("calcium").toDouble();
+        ui->caEdit->setValue(query.value("calcium").toDouble());
+	bicarbonate = query.value("bicarbonate").toDouble();
+	ui->hcoEdit->setValue(query.value("bicarbonate").toDouble());
+	sulfate = query.value("sulfate").toDouble();
+	ui->so4Edit->setValue(query.value("sulfate").toDouble());
+	chloride = query.value("chloride").toDouble();
+	ui->clEdit->setValue(query.value("chloride").toDouble());
+	sodium = query.value("sodium").toDouble();
+	ui->naEdit->setValue(query.value("sodium").toDouble());
+	magnesium = query.value("magnesium").toDouble();
+	ui->mgEdit->setValue(query.value("magnesium").toDouble());
+	ph = query.value("ph").toDouble();
+	ui->phEdit->setValue(query.value("ph").toDouble());
+	ui->notesEdit->setPlainText(query.value("notes").toString());
+	total_alkalinity = query.value("total_alkalinity").toDouble();
+	ui->alkalinityEdit->setValue(query.value("total_alkalinity").toDouble());
+	ui->inventoryEdit->setValue(query.value("inventory").toDouble());
+	ui->costEdit->setValue(query.value("cost").toDouble());
+	nitrate = query.value("nitrate").toDouble();
+	ui->noEdit->setValue(query.value("nitrate").toDouble());
     } else {
 	/* Set some defaults */
+	calcium = bicarbonate =  sulfate = chloride = 0;
+	sodium = magnesium = total_alkalinity = nitrate = 0;
+	ph = 7.0;
 	ui->phEdit->setValue(7.0);
     }
+    ui->saveButton->setEnabled(false);
+    ui->deleteButton->setEnabled((ui->inventoryEdit->value() == 0 && id >= 0) ? true:false);
     WaterSet();
     connect(ui->nameEdit, &QLineEdit::textChanged, this, &EditWater::is_changed);
     connect(ui->unlimitedEdit, &QCheckBox::stateChanged, this, &EditWater::is_changed);
-    connect(ui->caEdit, &QDoubleSpinBox::textChanged, this, &EditWater::water_changed);
-    connect(ui->hcoEdit, &QDoubleSpinBox::textChanged, this, &EditWater::hco_changed);
-    connect(ui->so4Edit, &QDoubleSpinBox::textChanged, this, &EditWater::water_changed);
-    connect(ui->clEdit, &QDoubleSpinBox::textChanged, this, &EditWater::water_changed);
-    connect(ui->naEdit, &QDoubleSpinBox::textChanged, this, &EditWater::water_changed);
-    connect(ui->mgEdit, &QDoubleSpinBox::textChanged, this, &EditWater::water_changed);
-    connect(ui->phEdit, &QDoubleSpinBox::textChanged, this, &EditWater::water_changed);
-    connect(ui->alkalinityEdit, &QDoubleSpinBox::textChanged, this, &EditWater::alkalinity_changed);
+    connect(ui->caEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditWater::calcium_changed);
+    connect(ui->so4Edit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditWater::sulfate_changed);
+    connect(ui->clEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditWater::chloride_changed);
+    connect(ui->naEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditWater::sodium_changed);
+    connect(ui->mgEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditWater::magnesium_changed);
+    connect(ui->phEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditWater::ph_changed);
+    connect(ui->alkalinityEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditWater::total_alkalinity_changed);
     connect(ui->notesEdit, SIGNAL(textChanged()), this, SLOT(is_changed()));
     connect(ui->inventoryEdit, &QDoubleSpinBox::textChanged, this, &EditWater::is_changed);
     connect(ui->costEdit, &QDoubleSpinBox::textChanged, this, &EditWater::is_changed);
-    connect(ui->noEdit, &QDoubleSpinBox::textChanged, this, &EditWater::water_changed);
-
-    ui->saveButton->setEnabled(false);
-    ui->deleteButton->setEnabled((ui->inventoryEdit->value() == 0 && id >= 0) ? true:false);
+    connect(ui->noEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditWater::nitrate_changed);
 }
 
 
@@ -89,10 +101,10 @@
 {
     QString txt;
 
-    if (this->recno < 0) {
+    if (recno < 0) {
 	txt = QString(tr("BMSapp - Add new brewing water"));
     } else {
-	txt = QString(tr("BMSapp - Edit brewing water %1").arg(this->recno));
+	txt = QString(tr("BMSapp - Edit brewing water %1").arg(recno));
     }
 
     if (this->textIsChanged) {
@@ -124,22 +136,22 @@
     	}
 	query.bindValue(":name", ui->nameEdit->text());
 	query.bindValue(":unlimited", ui->unlimitedEdit->isChecked() ? 1:0);
-	query.bindValue(":ca", QString("%1").arg(ui->caEdit->value(), 2, 'f', 1, '0'));
-	query.bindValue(":hco", QString("%1").arg(ui->hcoEdit->value(), 2, 'f', 1, '0'));
-	query.bindValue(":so4", QString("%1").arg(ui->so4Edit->value(), 2, 'f', 1, '0'));
-	query.bindValue(":cl", QString("%1").arg(ui->clEdit->value(), 2, 'f', 1, '0'));
-	query.bindValue(":na", QString("%1").arg(ui->naEdit->value(), 2, 'f', 1, '0'));
-	query.bindValue(":mg", QString("%1").arg(ui->mgEdit->value(), 2, 'f', 1, '0'));
-	query.bindValue(":ph", QString("%1").arg(ui->phEdit->value(), 3, 'f', 2, '0'));
+	query.bindValue(":ca", round(calcium * 1000) / 1000);
+	query.bindValue(":hco", round(bicarbonate * 1000) / 1000);
+	query.bindValue(":so4", round(sulfate * 1000) / 1000);
+	query.bindValue(":cl", round(chloride * 1000) / 1000);
+	query.bindValue(":na", round(sodium * 1000) / 1000);
+	query.bindValue(":mg", round(magnesium * 1000) / 1000);
+	query.bindValue(":ph", round(ph * 1000) / 1000);
 	query.bindValue(":notes", ui->notesEdit->toPlainText());
-	query.bindValue(":alkalinity", QString("%1").arg(ui->alkalinityEdit->value(), 2, 'f', 1, '0'));
+	query.bindValue(":alkalinity", round(total_alkalinity * 1000) / 1000);
 	query.bindValue(":inventory", QString("%1").arg(ui->inventoryEdit->value(), 2, 'f', 1, '0'));
 	query.bindValue(":cost", QString("%1").arg(ui->costEdit->value(), 6, 'f', 5, '0'));
-	query.bindValue(":no", QString("%1").arg(ui->noEdit->value(), 3, 'f', 2, '0'));
-	if (this->recno == -1) {
+	query.bindValue(":no", round(nitrate * 1000) / 1000);
+	if (recno == -1) {
 	    query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36));
 	} else {
-	    query.bindValue(":recno", this->recno);
+	    query.bindValue(":recno", recno);
 	}
 	query.exec();
 	if (query.lastError().isValid()) {
@@ -185,18 +197,21 @@
 
 void EditWater::WaterSet()
 {
-    double cations, anions, balance;
+    double CO3 = total_alkalinity * pow(10, ph - 10.33) / (1+2* pow(10, ph - 10.33)) * MMCO3 / (MMCaCO3 / 2);
+    double t_bicarbonate = Utils::Bicarbonate(total_alkalinity, ph);
+    qDebug() << t_bicarbonate << bicarbonate;
+    if ((round(t_bicarbonate * 1000) / 1000) != bicarbonate)
+	is_changed();
+    bicarbonate = t_bicarbonate;
+    ui->hcoEdit->setValue(bicarbonate);
 
-    double CaCO3 = ui->hcoEdit->value() / 1.22;
-    double pH = ui->phEdit->value();
-    double CO3 = ((CaCO3 / 50) / (1+(2* pow(10, pH - 10.33))) * pow(10, pH - 10.33)) * 60;
-    cations = (ui->caEdit->value() / 20.039) + (ui->mgEdit->value() / 12.1525) + (ui->naEdit->value() / 22.989);
-    anions = (ui->hcoEdit->value() / 61.016) + (CO3 / 30) + (ui->so4Edit->value() / 48.031) +
-	     (ui->clEdit->value() / 35.4527) + (ui->noEdit->value() / 62.0049);
-    balance = round((cations - anions) * 100) / 100;
+    double cations = (2*calcium / MMCa) + (2*magnesium / MMMg) + (sodium / MMNa);
+    double anions = (bicarbonate / MMHCO3) + (2*CO3 / MMCO3) + (2*sulfate / MMSO4) + (chloride / MMCl) + (nitrate / MMNO3);
+    double balance = round((cations - anions) * 100) / 100;
     ui->balanceEdit->setValue(balance);
     ui->co3Edit->setValue(CO3);
-    //qDebug() << A13 << B13 << CO3;
+    ui->hardnessEdit->setValue(Utils::Hardness(calcium, magnesium));
+    ui->raEdit->setValue(Utils::ResidualAlkalinity(total_alkalinity, calcium, magnesium));
 
     if (balance <= 0.1 && balance >= -0.1) {
 	ui->balanceIcon->setPixmap(QPixmap(":icons/silk/tick.png"));
@@ -224,16 +239,58 @@
 }
 
 
-void EditWater::hco_changed()
+void EditWater::calcium_changed(double val)
+{
+    calcium = val;
+    water_changed();
+}
+
+
+void EditWater::total_alkalinity_changed(double val)
 {
-    ui->alkalinityEdit->setValue(ui->hcoEdit->value() * 50 / 61);
+    total_alkalinity = val;
+    water_changed();
+}
+
+
+void EditWater::sulfate_changed(double val)
+{
+    sulfate = val;
     water_changed();
 }
 
 
-void EditWater::alkalinity_changed()
+void EditWater::chloride_changed(double val)
+{
+    chloride = val;
+    water_changed();
+}
+
+
+void EditWater::sodium_changed(double val)
+{
+    sodium = val;
+    water_changed();
+}
+
+
+void EditWater::magnesium_changed(double val)
 {
-    ui->hcoEdit->setValue(ui->alkalinityEdit->value() * 1.22);
+    magnesium = val;
+    water_changed();
+}
+
+
+void EditWater::ph_changed(double val)
+{
+    ph = val;
+    water_changed();
+}
+
+
+void EditWater::nitrate_changed(double val)
+{
+    nitrate = val;
     water_changed();
 }
 
--- a/src/EditWater.h	Tue Jul 12 16:01:49 2022 +0200
+++ b/src/EditWater.h	Sat Jul 16 15:06:40 2022 +0200
@@ -25,13 +25,20 @@
     void on_deleteButton_clicked();
     void is_changed();
     void water_changed();
-    void hco_changed();
-    void alkalinity_changed();
+    void calcium_changed(double val);
+    void total_alkalinity_changed(double val);
+    void sulfate_changed(double val);
+    void chloride_changed(double val);
+    void sodium_changed(double val);
+    void magnesium_changed(double val);
+    void ph_changed(double val);
+    void nitrate_changed(double val);
 
 private:
     Ui::EditWater *ui;
     int recno;
     bool textIsChanged = false;
+    double calcium, bicarbonate, sulfate, chloride, sodium, magnesium, ph, total_alkalinity, nitrate;
 
     void WindowTitle();
     void WaterSet();
--- a/ui/EditProfileWater.ui	Tue Jul 12 16:01:49 2022 +0200
+++ b/ui/EditProfileWater.ui	Sat Jul 16 15:06:40 2022 +0200
@@ -198,7 +198,7 @@
        </rect>
       </property>
       <property name="text">
-       <string>Acid pH:</string>
+       <string>pH:</string>
       </property>
       <property name="alignment">
        <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -316,7 +316,7 @@
      <widget class="QDoubleSpinBox" name="so4Edit">
       <property name="geometry">
        <rect>
-        <x>730</x>
+        <x>510</x>
         <y>150</y>
         <width>121</width>
         <height>24</height>
@@ -344,7 +344,7 @@
      <widget class="QDoubleSpinBox" name="clEdit">
       <property name="geometry">
        <rect>
-        <x>730</x>
+        <x>510</x>
         <y>180</y>
         <width>121</width>
         <height>24</height>
@@ -372,17 +372,23 @@
      <widget class="QDoubleSpinBox" name="hcoEdit">
       <property name="geometry">
        <rect>
-        <x>730</x>
+        <x>850</x>
         <y>210</y>
-        <width>121</width>
+        <width>111</width>
         <height>24</height>
        </rect>
       </property>
       <property name="alignment">
        <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
       </property>
+      <property name="readOnly">
+       <bool>true</bool>
+      </property>
+      <property name="buttonSymbols">
+       <enum>QAbstractSpinBox::NoButtons</enum>
+      </property>
       <property name="accelerated">
-       <bool>true</bool>
+       <bool>false</bool>
       </property>
       <property name="decimals">
        <number>1</number>
@@ -400,8 +406,8 @@
      <widget class="QDoubleSpinBox" name="alkalinityEdit">
       <property name="geometry">
        <rect>
-        <x>730</x>
-        <y>240</y>
+        <x>510</x>
+        <y>210</y>
         <width>121</width>
         <height>24</height>
        </rect>
@@ -428,7 +434,7 @@
      <widget class="QDoubleSpinBox" name="balanceEdit">
       <property name="geometry">
        <rect>
-        <x>730</x>
+        <x>510</x>
         <y>290</y>
         <width>111</width>
         <height>24</height>
@@ -462,9 +468,9 @@
      <widget class="QLabel" name="so4Label">
       <property name="geometry">
        <rect>
-        <x>540</x>
+        <x>300</x>
         <y>150</y>
-        <width>181</width>
+        <width>201</width>
         <height>20</height>
        </rect>
       </property>
@@ -478,9 +484,9 @@
      <widget class="QLabel" name="clLabel">
       <property name="geometry">
        <rect>
-        <x>570</x>
+        <x>300</x>
         <y>180</y>
-        <width>151</width>
+        <width>201</width>
         <height>20</height>
        </rect>
       </property>
@@ -494,7 +500,7 @@
      <widget class="QLabel" name="hcoLabel">
       <property name="geometry">
        <rect>
-        <x>530</x>
+        <x>650</x>
         <y>210</y>
         <width>191</width>
         <height>20</height>
@@ -510,14 +516,14 @@
      <widget class="QLabel" name="alkalinityLabel">
       <property name="geometry">
        <rect>
-        <x>530</x>
-        <y>240</y>
-        <width>191</width>
+        <x>300</x>
+        <y>210</y>
+        <width>201</width>
         <height>20</height>
        </rect>
       </property>
       <property name="text">
-       <string>Alkalinity (CaCO3) mg/L:</string>
+       <string>Total Alkalinity (CaCO3) mg/L:</string>
       </property>
       <property name="alignment">
        <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -526,7 +532,7 @@
      <widget class="QLabel" name="balanceLabel">
       <property name="geometry">
        <rect>
-        <x>540</x>
+        <x>320</x>
         <y>290</y>
         <width>181</width>
         <height>20</height>
@@ -542,7 +548,7 @@
      <widget class="QLabel" name="balanceIcon">
       <property name="geometry">
        <rect>
-        <x>860</x>
+        <x>630</x>
         <y>290</y>
         <width>56</width>
         <height>20</height>
@@ -552,6 +558,156 @@
        <pixmap resource="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc">:/icons/silk/tick.png</pixmap>
       </property>
      </widget>
+     <widget class="QLabel" name="raLabel">
+      <property name="geometry">
+       <rect>
+        <x>650</x>
+        <y>180</y>
+        <width>191</width>
+        <height>20</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>Residual Alkalinity as CaCO3:</string>
+      </property>
+      <property name="alignment">
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
+     </widget>
+     <widget class="QDoubleSpinBox" name="raEdit">
+      <property name="geometry">
+       <rect>
+        <x>850</x>
+        <y>180</y>
+        <width>111</width>
+        <height>24</height>
+       </rect>
+      </property>
+      <property name="alignment">
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
+      <property name="readOnly">
+       <bool>true</bool>
+      </property>
+      <property name="buttonSymbols">
+       <enum>QAbstractSpinBox::NoButtons</enum>
+      </property>
+      <property name="accelerated">
+       <bool>false</bool>
+      </property>
+      <property name="decimals">
+       <number>0</number>
+      </property>
+      <property name="maximum">
+       <double>1000.000000000000000</double>
+      </property>
+      <property name="singleStep">
+       <double>0.100000000000000</double>
+      </property>
+      <property name="stepType">
+       <enum>QAbstractSpinBox::DefaultStepType</enum>
+      </property>
+     </widget>
+     <widget class="QDoubleSpinBox" name="hardnessEdit">
+      <property name="geometry">
+       <rect>
+        <x>850</x>
+        <y>150</y>
+        <width>111</width>
+        <height>24</height>
+       </rect>
+      </property>
+      <property name="alignment">
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
+      <property name="readOnly">
+       <bool>true</bool>
+      </property>
+      <property name="buttonSymbols">
+       <enum>QAbstractSpinBox::NoButtons</enum>
+      </property>
+      <property name="accelerated">
+       <bool>false</bool>
+      </property>
+      <property name="decimals">
+       <number>1</number>
+      </property>
+      <property name="maximum">
+       <double>1000.000000000000000</double>
+      </property>
+      <property name="singleStep">
+       <double>0.100000000000000</double>
+      </property>
+      <property name="stepType">
+       <enum>QAbstractSpinBox::DefaultStepType</enum>
+      </property>
+     </widget>
+     <widget class="QLabel" name="hardnessLabel">
+      <property name="geometry">
+       <rect>
+        <x>650</x>
+        <y>150</y>
+        <width>191</width>
+        <height>20</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>Hardness as CaCO3:</string>
+      </property>
+      <property name="alignment">
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
+     </widget>
+     <widget class="QDoubleSpinBox" name="co3Edit">
+      <property name="geometry">
+       <rect>
+        <x>850</x>
+        <y>240</y>
+        <width>111</width>
+        <height>24</height>
+       </rect>
+      </property>
+      <property name="alignment">
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
+      <property name="readOnly">
+       <bool>true</bool>
+      </property>
+      <property name="buttonSymbols">
+       <enum>QAbstractSpinBox::NoButtons</enum>
+      </property>
+      <property name="accelerated">
+       <bool>false</bool>
+      </property>
+      <property name="decimals">
+       <number>1</number>
+      </property>
+      <property name="maximum">
+       <double>1000.000000000000000</double>
+      </property>
+      <property name="singleStep">
+       <double>0.100000000000000</double>
+      </property>
+      <property name="stepType">
+       <enum>QAbstractSpinBox::DefaultStepType</enum>
+      </property>
+     </widget>
+     <widget class="QLabel" name="co3Label">
+      <property name="geometry">
+       <rect>
+        <x>650</x>
+        <y>240</y>
+        <width>191</width>
+        <height>20</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>Carbonate (CO3) mg/L:</string>
+      </property>
+      <property name="alignment">
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
+     </widget>
     </widget>
    </item>
   </layout>
--- a/ui/EditWater.ui	Tue Jul 12 16:01:49 2022 +0200
+++ b/ui/EditWater.ui	Sat Jul 16 15:06:40 2022 +0200
@@ -292,7 +292,7 @@
        </rect>
       </property>
       <property name="text">
-       <string>Acid pH:</string>
+       <string>pH:</string>
       </property>
       <property name="alignment">
        <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -440,7 +440,7 @@
       <property name="geometry">
        <rect>
         <x>510</x>
-        <y>210</y>
+        <y>150</y>
         <width>121</width>
         <height>24</height>
        </rect>
@@ -468,7 +468,7 @@
       <property name="geometry">
        <rect>
         <x>510</x>
-        <y>240</y>
+        <y>180</y>
         <width>121</width>
         <height>24</height>
        </rect>
@@ -495,17 +495,23 @@
      <widget class="QDoubleSpinBox" name="hcoEdit">
       <property name="geometry">
        <rect>
-        <x>510</x>
-        <y>150</y>
-        <width>121</width>
+        <x>850</x>
+        <y>210</y>
+        <width>111</width>
         <height>24</height>
        </rect>
       </property>
       <property name="alignment">
        <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
       </property>
+      <property name="readOnly">
+       <bool>true</bool>
+      </property>
+      <property name="buttonSymbols">
+       <enum>QAbstractSpinBox::NoButtons</enum>
+      </property>
       <property name="accelerated">
-       <bool>true</bool>
+       <bool>false</bool>
       </property>
       <property name="decimals">
        <number>1</number>
@@ -513,9 +519,6 @@
       <property name="maximum">
        <double>1000.000000000000000</double>
       </property>
-      <property name="singleStep">
-       <double>0.100000000000000</double>
-      </property>
       <property name="stepType">
        <enum>QAbstractSpinBox::DefaultStepType</enum>
       </property>
@@ -523,8 +526,8 @@
      <widget class="QDoubleSpinBox" name="alkalinityEdit">
       <property name="geometry">
        <rect>
-        <x>770</x>
-        <y>150</y>
+        <x>510</x>
+        <y>210</y>
         <width>121</width>
         <height>24</height>
        </rect>
@@ -585,9 +588,9 @@
      <widget class="QLabel" name="so4Label">
       <property name="geometry">
        <rect>
-        <x>320</x>
-        <y>210</y>
-        <width>181</width>
+        <x>300</x>
+        <y>150</y>
+        <width>201</width>
         <height>20</height>
        </rect>
       </property>
@@ -601,9 +604,9 @@
      <widget class="QLabel" name="clLabel">
       <property name="geometry">
        <rect>
-        <x>350</x>
-        <y>240</y>
-        <width>151</width>
+        <x>300</x>
+        <y>180</y>
+        <width>201</width>
         <height>20</height>
        </rect>
       </property>
@@ -617,8 +620,8 @@
      <widget class="QLabel" name="hcoLabel">
       <property name="geometry">
        <rect>
-        <x>310</x>
-        <y>150</y>
+        <x>650</x>
+        <y>210</y>
         <width>191</width>
         <height>20</height>
        </rect>
@@ -633,14 +636,14 @@
      <widget class="QLabel" name="alkalinityLabel">
       <property name="geometry">
        <rect>
-        <x>640</x>
-        <y>150</y>
-        <width>121</width>
+        <x>300</x>
+        <y>210</y>
+        <width>201</width>
         <height>20</height>
        </rect>
       </property>
       <property name="text">
-       <string>or (CaCO3) mg/L:</string>
+       <string>Total Alkalinity (CaCO3) mg/L:</string>
       </property>
       <property name="alignment">
        <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -656,7 +659,7 @@
        </rect>
       </property>
       <property name="text">
-       <string>Ion balance meq/L:</string>
+       <string>Ion balance mEq/L:</string>
       </property>
       <property name="alignment">
        <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -678,9 +681,9 @@
      <widget class="QLabel" name="noLabel">
       <property name="geometry">
        <rect>
-        <x>350</x>
-        <y>270</y>
-        <width>151</width>
+        <x>300</x>
+        <y>240</y>
+        <width>201</width>
         <height>20</height>
        </rect>
       </property>
@@ -695,7 +698,7 @@
       <property name="geometry">
        <rect>
         <x>510</x>
-        <y>270</y>
+        <y>240</y>
         <width>121</width>
         <height>24</height>
        </rect>
@@ -722,9 +725,9 @@
      <widget class="QLabel" name="co3Label">
       <property name="geometry">
        <rect>
-        <x>320</x>
-        <y>180</y>
-        <width>181</width>
+        <x>650</x>
+        <y>240</y>
+        <width>191</width>
         <height>20</height>
        </rect>
       </property>
@@ -738,9 +741,9 @@
      <widget class="QDoubleSpinBox" name="co3Edit">
       <property name="geometry">
        <rect>
-        <x>510</x>
-        <y>180</y>
-        <width>106</width>
+        <x>850</x>
+        <y>240</y>
+        <width>111</width>
         <height>24</height>
        </rect>
       </property>
@@ -769,6 +772,106 @@
        <enum>QAbstractSpinBox::DefaultStepType</enum>
       </property>
      </widget>
+     <widget class="QLabel" name="hardnessLabel">
+      <property name="geometry">
+       <rect>
+        <x>650</x>
+        <y>150</y>
+        <width>191</width>
+        <height>20</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>Hardness as CaCO3:</string>
+      </property>
+      <property name="alignment">
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
+     </widget>
+     <widget class="QLabel" name="raLabel">
+      <property name="geometry">
+       <rect>
+        <x>650</x>
+        <y>180</y>
+        <width>191</width>
+        <height>20</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>Residual Alkalinity as CaCO3:</string>
+      </property>
+      <property name="alignment">
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
+     </widget>
+     <widget class="QDoubleSpinBox" name="hardnessEdit">
+      <property name="geometry">
+       <rect>
+        <x>850</x>
+        <y>150</y>
+        <width>111</width>
+        <height>24</height>
+       </rect>
+      </property>
+      <property name="alignment">
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
+      <property name="readOnly">
+       <bool>true</bool>
+      </property>
+      <property name="buttonSymbols">
+       <enum>QAbstractSpinBox::NoButtons</enum>
+      </property>
+      <property name="accelerated">
+       <bool>false</bool>
+      </property>
+      <property name="decimals">
+       <number>1</number>
+      </property>
+      <property name="maximum">
+       <double>1000.000000000000000</double>
+      </property>
+      <property name="singleStep">
+       <double>0.100000000000000</double>
+      </property>
+      <property name="stepType">
+       <enum>QAbstractSpinBox::DefaultStepType</enum>
+      </property>
+     </widget>
+     <widget class="QDoubleSpinBox" name="raEdit">
+      <property name="geometry">
+       <rect>
+        <x>850</x>
+        <y>180</y>
+        <width>111</width>
+        <height>24</height>
+       </rect>
+      </property>
+      <property name="alignment">
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
+      <property name="readOnly">
+       <bool>true</bool>
+      </property>
+      <property name="buttonSymbols">
+       <enum>QAbstractSpinBox::NoButtons</enum>
+      </property>
+      <property name="accelerated">
+       <bool>false</bool>
+      </property>
+      <property name="decimals">
+       <number>0</number>
+      </property>
+      <property name="maximum">
+       <double>1000.000000000000000</double>
+      </property>
+      <property name="singleStep">
+       <double>0.100000000000000</double>
+      </property>
+      <property name="stepType">
+       <enum>QAbstractSpinBox::DefaultStepType</enum>
+      </property>
+     </widget>
     </widget>
    </item>
   </layout>

mercurial