Mon, 23 May 2022 14:16:44 +0200
Added inverntory waters nitrate column. Added nitrate and carbonate in the water edit screen.
src/EditWater.cpp | file | annotate | diff | comparison | revisions | |
ui/EditWater.ui | file | annotate | diff | comparison | revisions |
--- 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"));
--- 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 @@ <property name="geometry"> <rect> <x>10</x> - <y>340</y> + <y>370</y> <width>141</width> <height>20</height> </rect> @@ -67,8 +67,8 @@ <widget class="QLabel" name="costLabel"> <property name="geometry"> <rect> - <x>540</x> - <y>340</y> + <x>320</x> + <y>370</y> <width>171</width> <height>20</height> </rect> @@ -113,7 +113,7 @@ <property name="geometry"> <rect> <x>160</x> - <y>340</y> + <y>370</y> <width>121</width> <height>24</height> </rect> @@ -146,8 +146,8 @@ <widget class="QDoubleSpinBox" name="costEdit"> <property name="geometry"> <rect> - <x>730</x> - <y>340</y> + <x>510</x> + <y>370</y> <width>121</width> <height>24</height> </rect> @@ -286,7 +286,7 @@ <property name="geometry"> <rect> <x>10</x> - <y>290</y> + <y>320</y> <width>141</width> <height>20</height> </rect> @@ -302,7 +302,7 @@ <property name="geometry"> <rect> <x>10</x> - <y>370</y> + <y>400</y> <width>141</width> <height>20</height> </rect> @@ -318,7 +318,7 @@ <property name="geometry"> <rect> <x>160</x> - <y>370</y> + <y>400</y> <width>85</width> <height>21</height> </rect> @@ -415,7 +415,7 @@ <property name="geometry"> <rect> <x>160</x> - <y>290</y> + <y>320</y> <width>121</width> <height>24</height> </rect> @@ -439,8 +439,8 @@ <widget class="QDoubleSpinBox" name="so4Edit"> <property name="geometry"> <rect> - <x>730</x> - <y>150</y> + <x>510</x> + <y>210</y> <width>121</width> <height>24</height> </rect> @@ -467,8 +467,8 @@ <widget class="QDoubleSpinBox" name="clEdit"> <property name="geometry"> <rect> - <x>730</x> - <y>180</y> + <x>510</x> + <y>240</y> <width>121</width> <height>24</height> </rect> @@ -495,8 +495,8 @@ <widget class="QDoubleSpinBox" name="hcoEdit"> <property name="geometry"> <rect> - <x>730</x> - <y>210</y> + <x>510</x> + <y>150</y> <width>121</width> <height>24</height> </rect> @@ -523,8 +523,8 @@ <widget class="QDoubleSpinBox" name="alkalinityEdit"> <property name="geometry"> <rect> - <x>730</x> - <y>240</y> + <x>770</x> + <y>150</y> <width>121</width> <height>24</height> </rect> @@ -551,8 +551,8 @@ <widget class="QDoubleSpinBox" name="balanceEdit"> <property name="geometry"> <rect> - <x>730</x> - <y>290</y> + <x>510</x> + <y>320</y> <width>111</width> <height>24</height> </rect> @@ -585,8 +585,8 @@ <widget class="QLabel" name="so4Label"> <property name="geometry"> <rect> - <x>540</x> - <y>150</y> + <x>320</x> + <y>210</y> <width>181</width> <height>20</height> </rect> @@ -601,8 +601,8 @@ <widget class="QLabel" name="clLabel"> <property name="geometry"> <rect> - <x>570</x> - <y>180</y> + <x>350</x> + <y>240</y> <width>151</width> <height>20</height> </rect> @@ -617,8 +617,8 @@ <widget class="QLabel" name="hcoLabel"> <property name="geometry"> <rect> - <x>530</x> - <y>210</y> + <x>310</x> + <y>150</y> <width>191</width> <height>20</height> </rect> @@ -633,14 +633,14 @@ <widget class="QLabel" name="alkalinityLabel"> <property name="geometry"> <rect> - <x>530</x> - <y>240</y> - <width>191</width> + <x>640</x> + <y>150</y> + <width>121</width> <height>20</height> </rect> </property> <property name="text"> - <string>Alkalinity (CaCO3) mg/L:</string> + <string>or (CaCO3) mg/L:</string> </property> <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> @@ -649,8 +649,8 @@ <widget class="QLabel" name="balanceLabel"> <property name="geometry"> <rect> - <x>540</x> - <y>290</y> + <x>320</x> + <y>320</y> <width>181</width> <height>20</height> </rect> @@ -665,8 +665,8 @@ <widget class="QLabel" name="balanceIcon"> <property name="geometry"> <rect> - <x>860</x> - <y>290</y> + <x>630</x> + <y>320</y> <width>56</width> <height>20</height> </rect> @@ -675,6 +675,100 @@ <pixmap resource="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc">:/icons/silk/tick.png</pixmap> </property> </widget> + <widget class="QLabel" name="noLabel"> + <property name="geometry"> + <rect> + <x>350</x> + <y>270</y> + <width>151</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Nitrate (NO3) mg/L:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QDoubleSpinBox" name="noEdit"> + <property name="geometry"> + <rect> + <x>510</x> + <y>270</y> + <width>121</width> + <height>24</height> + </rect> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="accelerated"> + <bool>true</bool> + </property> + <property name="decimals"> + <number>2</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>320</x> + <y>180</y> + <width>181</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 class="QDoubleSpinBox" name="co3Edit"> + <property name="geometry"> + <rect> + <x>510</x> + <y>180</y> + <width>106</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> </item> </layout> @@ -682,8 +776,20 @@ <tabstops> <tabstop>nameEdit</tabstop> <tabstop>notesEdit</tabstop> + <tabstop>caEdit</tabstop> + <tabstop>mgEdit</tabstop> + <tabstop>naEdit</tabstop> + <tabstop>hcoEdit</tabstop> + <tabstop>alkalinityEdit</tabstop> + <tabstop>co3Edit</tabstop> + <tabstop>so4Edit</tabstop> + <tabstop>clEdit</tabstop> + <tabstop>noEdit</tabstop> + <tabstop>phEdit</tabstop> + <tabstop>balanceEdit</tabstop> <tabstop>inventoryEdit</tabstop> <tabstop>costEdit</tabstop> + <tabstop>unlimitedEdit</tabstop> <tabstop>quitButton</tabstop> <tabstop>deleteButton</tabstop> <tabstop>saveButton</tabstop>