Thu, 02 Jun 2022 16:31:33 +0200
Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
--- a/src/EditFermentable.cpp Wed Jun 01 21:46:26 2022 +0200 +++ b/src/EditFermentable.cpp Thu Jun 02 16:31:33 2022 +0200 @@ -57,36 +57,41 @@ query.exec(); query.next(); - ui->nameEdit->setText(query.value(1).toString()); - ui->notesEdit->setPlainText(query.value(8).toString()); - ui->originEdit->setText(query.value(6).toString()); - ui->supplierEdit->setText(query.value(7).toString()); - ui->typeEdit->setCurrentIndex(query.value(2).toInt()); - ui->graintypeEdit->setCurrentIndex(query.value(20).toInt()); - ui->maxinbatchEdit->setValue(query.value(14).toDouble()); - ui->mashEdit->setChecked(query.value(15).toInt() ? true:false); - ui->addafterEdit->setChecked(query.value(5).toInt() ? true:false); - ui->addedEdit->setCurrentIndex(query.value(17).toInt()); - ui->alwaysEdit->setChecked(query.value(5).toInt() ? true:false); - ui->inventoryEdit->setValue(query.value(21).toDouble()); - ui->costEdit->setValue(query.value(22).toDouble()); - ui->valueEdit->setValue(query.value(21).toDouble() * query.value(22).toDouble()); - ui->yieldEdit->setValue(query.value(3).toDouble()); - ui->colorEdit->setValue(query.value(4).toDouble()); - ui->moistureEdit->setValue(query.value(10).toDouble()); - ui->coarseEdit->setValue(query.value(9).toDouble()); - ui->proteinEdit->setValue(query.value(12).toDouble()); - ui->dissolvedEdit->setValue(query.value(13).toDouble()); - ui->diastaticEdit->setValue(Utils::lintner_to_kolbach(query.value(11).toDouble())); - ui->diphEdit->setValue(query.value(18).toDouble()); - ui->acidphEdit->setValue(query.value(19).toDouble()); - if (query.value(23).toString().length() == 10) { - ui->prodEdit->setDate(query.value(23).toDate()); + QSqlRecord rec = query.record(); + for (int i = 0; i < rec.count(); i++) + qDebug() << i << rec.fieldName(i) << query.value(i); + + ui->nameEdit->setText(query.value("name").toString()); + ui->notesEdit->setPlainText(query.value("notes").toString()); + ui->originEdit->setText(query.value("origin").toString()); + ui->supplierEdit->setText(query.value("supplier").toString()); + ui->typeEdit->setCurrentIndex(query.value("type").toInt()); + ui->graintypeEdit->setCurrentIndex(query.value("graintype").toInt()); + ui->maxinbatchEdit->setValue(query.value("max_in_batch").toDouble()); + ui->mashEdit->setChecked(query.value("recommend_mash").toInt() ? true:false); + ui->addafterEdit->setChecked(query.value("add_after_boil").toInt() ? true:false); + ui->addedEdit->setCurrentIndex(query.value("added").toInt()); + ui->alwaysEdit->setChecked(query.value("always_on_stock").toInt() ? true:false); + ui->inventoryEdit->setValue(query.value("inventory").toDouble()); + ui->costEdit->setValue(query.value("cost").toDouble()); + ui->valueEdit->setValue(query.value("inventory").toDouble() * query.value("cost").toDouble()); + ui->yieldEdit->setValue(query.value("yield").toDouble()); + ui->colorEdit->setValue(query.value("color").toDouble()); + ui->moistureEdit->setValue(query.value("moisture").toDouble()); + ui->coarseEdit->setValue(query.value("coarse_fine_diff").toDouble()); + ui->proteinEdit->setValue(query.value("protein").toDouble()); + ui->dissolvedEdit->setValue(query.value("dissolved_protein").toDouble()); + ui->lintnerEdit->setValue(query.value("diastatic_power").toDouble()); + ui->wkEdit->setValue(Utils::lintner_to_kolbach(query.value("diastatic_power").toDouble())); + ui->diphEdit->setValue(query.value("di_ph").toDouble()); + ui->acidphEdit->setValue(query.value("acid_to_ph_57").toDouble()); + if (query.value("production_date").toString().length() == 10) { + ui->prodEdit->setDate(query.value("production_date").toDate()); } else { ui->prodEdit->clear(); } - if (query.value(24).toString().length() == 10) { - ui->thtEdit->setDate(query.value(24).toDate()); + if (query.value("tht_date").toString().length() == 10) { + ui->thtEdit->setDate(query.value("tht_date").toDate()); } else { ui->thtEdit->clear(); } @@ -123,7 +128,8 @@ connect(ui->coarseEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed); connect(ui->proteinEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed); connect(ui->dissolvedEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed); - connect(ui->diastaticEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed); + connect(ui->wkEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditFermentable::wk_changed); + connect(ui->lintnerEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditFermentable::lintner_changed); connect(ui->diphEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed); connect(ui->acidphEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed); connect(ui->prodEdit, &QDateEdit::dateChanged, this, &EditFermentable::is_changed); @@ -206,7 +212,7 @@ query.bindValue(":notes", ui->notesEdit->toPlainText()); query.bindValue(":coarse", QString("%1").arg(ui->coarseEdit->value(), 2, 'f', 1, '0')); query.bindValue(":moisture", QString("%1").arg(ui->moistureEdit->value(), 2, 'f', 1, '0')); - query.bindValue(":diastatic", Utils::kolbach_to_lintner(ui->diastaticEdit->value())); + query.bindValue(":diastatic", Utils::kolbach_to_lintner(ui->wkEdit->value())); query.bindValue(":protein", QString("%1").arg(ui->proteinEdit->value(), 2, 'f', 1, '0')); query.bindValue(":dissolved", QString("%1").arg(ui->dissolvedEdit->value(), 2, 'f', 1, '0')); query.bindValue(":maxinbatch", QString("%1").arg(ui->maxinbatchEdit->value(), 2, 'f', 1, '0')); @@ -278,6 +284,25 @@ } +void EditFermentable::wk_changed(double val) +{ + const QSignalBlocker blocker1(ui->lintnerEdit); + if (val == 0) + ui->lintnerEdit->setValue(0); + else + ui->lintnerEdit->setValue(Utils::kolbach_to_lintner(val)); + is_changed(); +} + + +void EditFermentable::lintner_changed(double val) +{ + const QSignalBlocker blocker1(ui->wkEdit); + ui->wkEdit->setValue(Utils::lintner_to_kolbach(val)); + is_changed(); +} + + void EditFermentable::on_quitButton_clicked() { if (this->textIsChanged) {
--- a/src/EditFermentable.h Wed Jun 01 21:46:26 2022 +0200 +++ b/src/EditFermentable.h Thu Jun 02 16:31:33 2022 +0200 @@ -24,6 +24,8 @@ void on_quitButton_clicked(); void on_deleteButton_clicked(); void is_changed(); + void wk_changed(double val); + void lintner_changed(double val); private: Ui::EditFermentable *ui;
--- a/ui/EditFermentable.ui Wed Jun 01 21:46:26 2022 +0200 +++ b/ui/EditFermentable.ui Thu Jun 02 16:31:33 2022 +0200 @@ -196,13 +196,13 @@ <property name="geometry"> <rect> <x>5</x> - <y>410</y> + <y>440</y> <width>131</width> <height>20</height> </rect> </property> <property name="text"> - <string>Inventory:</string> + <string>Inventory Kg:</string> </property> <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> @@ -212,7 +212,7 @@ <property name="geometry"> <rect> <x>5</x> - <y>440</y> + <y>470</y> <width>131</width> <height>20</height> </rect> @@ -227,14 +227,14 @@ <widget class="QLabel" name="valueLabel"> <property name="geometry"> <rect> - <x>5</x> + <x>270</x> <y>470</y> - <width>131</width> + <width>71</width> <height>20</height> </rect> </property> <property name="text"> - <string>Total value:</string> + <string>Total:</string> </property> <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> @@ -320,7 +320,7 @@ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> </widget> - <widget class="QLabel" name="diastaticLabel"> + <widget class="QLabel" name="wkLabel"> <property name="geometry"> <rect> <x>660</x> @@ -330,7 +330,7 @@ </rect> </property> <property name="text"> - <string>Diastatic power:</string> + <string>Windisch-Kolbach:</string> </property> <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> @@ -356,7 +356,7 @@ <property name="geometry"> <rect> <x>660</x> - <y>340</y> + <y>370</y> <width>141</width> <height>20</height> </rect> @@ -372,7 +372,7 @@ <property name="geometry"> <rect> <x>660</x> - <y>370</y> + <y>400</y> <width>141</width> <height>20</height> </rect> @@ -388,7 +388,7 @@ <property name="geometry"> <rect> <x>660</x> - <y>410</y> + <y>440</y> <width>141</width> <height>20</height> </rect> @@ -404,7 +404,7 @@ <property name="geometry"> <rect> <x>660</x> - <y>440</y> + <y>470</y> <width>141</width> <height>20</height> </rect> @@ -538,7 +538,7 @@ <property name="geometry"> <rect> <x>140</x> - <y>410</y> + <y>440</y> <width>121</width> <height>24</height> </rect> @@ -572,7 +572,7 @@ <property name="geometry"> <rect> <x>140</x> - <y>440</y> + <y>470</y> <width>121</width> <height>24</height> </rect> @@ -608,6 +608,9 @@ <property name="accelerated"> <bool>true</bool> </property> + <property name="suffix"> + <string> %</string> + </property> <property name="decimals"> <number>1</number> </property> @@ -649,6 +652,9 @@ <property name="accelerated"> <bool>true</bool> </property> + <property name="suffix"> + <string> %</string> + </property> <property name="decimals"> <number>1</number> </property> @@ -687,6 +693,9 @@ <property name="accelerated"> <bool>true</bool> </property> + <property name="suffix"> + <string> %</string> + </property> <property name="decimals"> <number>1</number> </property> @@ -706,11 +715,14 @@ <property name="accelerated"> <bool>true</bool> </property> + <property name="suffix"> + <string> %</string> + </property> <property name="decimals"> <number>1</number> </property> </widget> - <widget class="QDoubleSpinBox" name="diastaticEdit"> + <widget class="QDoubleSpinBox" name="wkEdit"> <property name="geometry"> <rect> <x>810</x> @@ -725,6 +737,9 @@ <property name="accelerated"> <bool>true</bool> </property> + <property name="suffix"> + <string> WK</string> + </property> <property name="decimals"> <number>0</number> </property> @@ -736,7 +751,7 @@ <property name="geometry"> <rect> <x>810</x> - <y>340</y> + <y>370</y> <width>121</width> <height>24</height> </rect> @@ -752,7 +767,7 @@ <property name="geometry"> <rect> <x>810</x> - <y>370</y> + <y>400</y> <width>121</width> <height>24</height> </rect> @@ -832,7 +847,7 @@ <property name="geometry"> <rect> <x>810</x> - <y>410</y> + <y>440</y> <width>121</width> <height>24</height> </rect> @@ -843,6 +858,16 @@ <minute>0</minute> <second>0</second> <year>2000</year> + <month>9</month> + <day>14</day> + </datetime> + </property> + <property name="minimumDateTime"> + <datetime> + <hour>0</hour> + <minute>0</minute> + <second>0</second> + <year>2000</year> <month>1</month> <day>1</day> </datetime> @@ -858,11 +883,21 @@ <property name="geometry"> <rect> <x>810</x> - <y>440</y> + <y>470</y> <width>121</width> <height>24</height> </rect> </property> + <property name="minimumDateTime"> + <datetime> + <hour>0</hour> + <minute>0</minute> + <second>0</second> + <year>2000</year> + <month>1</month> + <day>1</day> + </datetime> + </property> <property name="displayFormat"> <string>yyyy-MM-dd</string> </property> @@ -936,7 +971,7 @@ <widget class="QDoubleSpinBox" name="valueEdit"> <property name="geometry"> <rect> - <x>140</x> + <x>350</x> <y>470</y> <width>107</width> <height>24</height> @@ -952,6 +987,47 @@ <enum>QAbstractSpinBox::NoButtons</enum> </property> </widget> + <widget class="QLabel" name="lintnerLabel"> + <property name="geometry"> + <rect> + <x>660</x> + <y>340</y> + <width>141</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Lintner:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QDoubleSpinBox" name="lintnerEdit"> + <property name="geometry"> + <rect> + <x>810</x> + <y>340</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>3</number> + </property> + <property name="maximum"> + <double>10000.000000000000000</double> + </property> + <property name="singleStep"> + <double>0.500000000000000</double> + </property> + </widget> </widget> </item> </layout> @@ -983,7 +1059,7 @@ <tabstop>coarseEdit</tabstop> <tabstop>proteinEdit</tabstop> <tabstop>dissolvedEdit</tabstop> - <tabstop>diastaticEdit</tabstop> + <tabstop>wkEdit</tabstop> <tabstop>diphEdit</tabstop> <tabstop>acidphEdit</tabstop> <tabstop>prodEdit</tabstop>