# HG changeset patch # User Michiel Broek # Date 1653308204 -7200 # Node ID d0b1640ba95110922313f73aba7bdc0a167846f3 # Parent 57dba736d10b99779e60f72664b5dd30ec209f62 Added inverntory waters nitrate column. Added nitrate and carbonate in the water edit screen. diff -r 57dba736d10b -r d0b1640ba951 src/EditWater.cpp --- a/src/EditWater.cpp Sun May 22 11:23:28 2022 +0200 +++ b/src/EditWater.cpp Mon May 23 14:16:44 2022 +0200 @@ -48,6 +48,7 @@ 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()); } else { /* Set some defaults */ ui->phEdit->setValue(7.0); @@ -66,6 +67,7 @@ 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); @@ -114,11 +116,11 @@ if (this->recno == -1) { query.prepare("INSERT INTO inventory_waters SET name=:name, unlimited_stock=:unlimited, calcium=:ca, " "bicarbonate=:hco, sulfate=:so4, chloride=:cl, sodium=:na, magnesium=:mg, ph=:ph, notes=:notes, " - "total_alkalinity=:alkalinity, inventory=:inventory, cost=:cost, uuid = :uuid"); + "total_alkalinity=:alkalinity, inventory=:inventory, cost=:cost, nitrate=:no, uuid = :uuid"); } else { query.prepare("UPDATE inventory_waters SET name=:name, unlimited_stock=:unlimited, calcium=:ca, " "bicarbonate=:hco, sulfate=:so4, chloride=:cl, sodium=:na, magnesium=:mg, ph=:ph, notes=:notes, " - "total_alkalinity=:alkalinity, inventory=:inventory, cost=:cost WHERE record = :recno"); + "total_alkalinity=:alkalinity, inventory=:inventory, cost=:cost, nitrate=:no WHERE record = :recno"); } query.bindValue(":name", ui->nameEdit->text()); query.bindValue(":unlimited", ui->unlimitedEdit->isChecked() ? 1:0); @@ -133,6 +135,7 @@ query.bindValue(":alkalinity", QString("%1").arg(ui->alkalinityEdit->value(), 2, 'f', 1, '0')); 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(":uuid", QUuid::createUuid().toString().mid(1, 36)); } else { @@ -184,10 +187,16 @@ { double cations, anions, balance; + 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) + (ui->so4Edit->value() / 48.031) + (ui->clEdit->value() / 35.4527); + 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; ui->balanceEdit->setValue(balance); + ui->co3Edit->setValue(CO3); + //qDebug() << A13 << B13 << CO3; if (balance <= 0.1 && balance >= -0.1) { ui->balanceIcon->setPixmap(QPixmap(":icons/silk/tick.png")); diff -r 57dba736d10b -r d0b1640ba951 ui/EditWater.ui --- a/ui/EditWater.ui Sun May 22 11:23:28 2022 +0200 +++ b/ui/EditWater.ui Mon May 23 14:16:44 2022 +0200 @@ -52,7 +52,7 @@ 10 - 340 + 370 141 20 @@ -67,8 +67,8 @@ - 540 - 340 + 320 + 370 171 20 @@ -113,7 +113,7 @@ 160 - 340 + 370 121 24 @@ -146,8 +146,8 @@ - 730 - 340 + 510 + 370 121 24 @@ -286,7 +286,7 @@ 10 - 290 + 320 141 20 @@ -302,7 +302,7 @@ 10 - 370 + 400 141 20 @@ -318,7 +318,7 @@ 160 - 370 + 400 85 21 @@ -415,7 +415,7 @@ 160 - 290 + 320 121 24 @@ -439,8 +439,8 @@ - 730 - 150 + 510 + 210 121 24 @@ -467,8 +467,8 @@ - 730 - 180 + 510 + 240 121 24 @@ -495,8 +495,8 @@ - 730 - 210 + 510 + 150 121 24 @@ -523,8 +523,8 @@ - 730 - 240 + 770 + 150 121 24 @@ -551,8 +551,8 @@ - 730 - 290 + 510 + 320 111 24 @@ -585,8 +585,8 @@ - 540 - 150 + 320 + 210 181 20 @@ -601,8 +601,8 @@ - 570 - 180 + 350 + 240 151 20 @@ -617,8 +617,8 @@ - 530 - 210 + 310 + 150 191 20 @@ -633,14 +633,14 @@ - 530 - 240 - 191 + 640 + 150 + 121 20 - Alkalinity (CaCO3) mg/L: + or (CaCO3) mg/L: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -649,8 +649,8 @@ - 540 - 290 + 320 + 320 181 20 @@ -665,8 +665,8 @@ - 860 - 290 + 630 + 320 56 20 @@ -675,6 +675,100 @@ :/icons/silk/tick.png + + + + 350 + 270 + 151 + 20 + + + + Nitrate (NO3) mg/L: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 510 + 270 + 121 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + 2 + + + 1000.000000000000000 + + + 0.100000000000000 + + + QAbstractSpinBox::DefaultStepType + + + + + + 320 + 180 + 181 + 20 + + + + Carbonate (CO3) mg/L: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 510 + 180 + 106 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + QAbstractSpinBox::NoButtons + + + false + + + 1 + + + 1000.000000000000000 + + + 0.100000000000000 + + + QAbstractSpinBox::DefaultStepType + + @@ -682,8 +776,20 @@ nameEdit notesEdit + caEdit + mgEdit + naEdit + hcoEdit + alkalinityEdit + co3Edit + so4Edit + clEdit + noEdit + phEdit + balanceEdit inventoryEdit costEdit + unlimitedEdit quitButton deleteButton saveButton